|
@@ -1,10 +1,10 @@
|
|
package com.zanxiang.sdk.controller;
|
|
package com.zanxiang.sdk.controller;
|
|
|
|
|
|
import com.zanxiang.common.domain.ResultMap;
|
|
import com.zanxiang.common.domain.ResultMap;
|
|
-import com.zanxiang.common.enums.HttpStatusEnum;
|
|
|
|
import com.zanxiang.common.enums.PayWayEnum;
|
|
import com.zanxiang.common.enums.PayWayEnum;
|
|
-import com.zanxiang.common.utils.IpUtils;
|
|
|
|
import com.zanxiang.common.utils.StringUtils;
|
|
import com.zanxiang.common.utils.StringUtils;
|
|
|
|
+import com.zanxiang.sdk.annotation.UnSignCheck;
|
|
|
|
+import com.zanxiang.sdk.annotation.ValidLogin;
|
|
import com.zanxiang.sdk.domain.bo.PlatformOrderBO;
|
|
import com.zanxiang.sdk.domain.bo.PlatformOrderBO;
|
|
import com.zanxiang.sdk.domain.bo.ProductPayParamBO;
|
|
import com.zanxiang.sdk.domain.bo.ProductPayParamBO;
|
|
import com.zanxiang.sdk.domain.params.ProductPayParam;
|
|
import com.zanxiang.sdk.domain.params.ProductPayParam;
|
|
@@ -22,8 +22,6 @@ import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.math.BigDecimal;
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 支付公共入口
|
|
* 支付公共入口
|
|
@@ -45,25 +43,17 @@ public class PayController {
|
|
|
|
|
|
@ApiOperation(value = "支付参数生成")
|
|
@ApiOperation(value = "支付参数生成")
|
|
@PostMapping(value = "/create")
|
|
@PostMapping(value = "/create")
|
|
- public ResultMap create(@Validated @RequestBody ProductPayParam product, UserData userData, HttpServletRequest request) {
|
|
|
|
|
|
+ public ResultMap create(@Validated @RequestBody ProductPayParam product, @ValidLogin UserData userData) {
|
|
String userId = String.valueOf(userData.getUserId());
|
|
String userId = String.valueOf(userData.getUserId());
|
|
-// String userId = "1";
|
|
|
|
String cpId = "1";
|
|
String cpId = "1";
|
|
if (StringUtils.isEmpty(product.getOrderId())) {
|
|
if (StringUtils.isEmpty(product.getOrderId())) {
|
|
- //虚拟充值情况,直接传金额实时生成订单
|
|
|
|
- if (product.getAmount() == null || Objects.equals(product.getAmount(), BigDecimal.ZERO)) {
|
|
|
|
- return ResultMap.error(HttpStatusEnum.ORDER_AMOUNT_IS_NULL.getMsg());
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isEmpty(product.getGameId())) {
|
|
|
|
- return ResultMap.error(HttpStatusEnum.ORDER_GAME_ID_IS_NULL.getMsg());
|
|
|
|
- }
|
|
|
|
PlatformOrderBO orderBO = new PlatformOrderBO();
|
|
PlatformOrderBO orderBO = new PlatformOrderBO();
|
|
orderBO.setAmount(product.getAmount());
|
|
orderBO.setAmount(product.getAmount());
|
|
- orderBO.setProductName(product.getAmount().toString());
|
|
|
|
- orderBO.setProductId("ptb_charge");
|
|
|
|
- orderBO.setMgUserId(product.getMgUserId());
|
|
|
|
|
|
+ orderBO.setProductName(product.getProductName());
|
|
|
|
+ orderBO.setProductId(product.getProductId());
|
|
|
|
+ orderBO.setMgUserId(userData.getUserId());
|
|
orderBO.setUserId(userId);
|
|
orderBO.setUserId(userId);
|
|
- orderBO.setGameId(Long.valueOf(product.getGameId()));
|
|
|
|
|
|
+ orderBO.setGameId(userData.getGameId());
|
|
orderBO.setCpId(cpId);
|
|
orderBO.setCpId(cpId);
|
|
orderBO.setFromDevice(userData.getDeviceSystem());
|
|
orderBO.setFromDevice(userData.getDeviceSystem());
|
|
orderBO.setPayDevice(userData.getDeviceType().toString());
|
|
orderBO.setPayDevice(userData.getDeviceType().toString());
|
|
@@ -71,29 +61,32 @@ public class PayController {
|
|
product.setOrderId(orderId);
|
|
product.setOrderId(orderId);
|
|
}
|
|
}
|
|
ProductPayParamBO bo = new ProductPayParamBO();
|
|
ProductPayParamBO bo = new ProductPayParamBO();
|
|
- bo.setGameId(product.getGameId());
|
|
|
|
|
|
+ bo.setGameId(userData.getGameId().toString());
|
|
bo.setUserId(userId);
|
|
bo.setUserId(userId);
|
|
bo.setPayDevice(product.getPayDevice() == null ? userData.getDeviceType() : product.getPayDevice());
|
|
bo.setPayDevice(product.getPayDevice() == null ? userData.getDeviceType() : product.getPayDevice());
|
|
bo.setDeviceSystem(userData.getDeviceSystem());
|
|
bo.setDeviceSystem(userData.getDeviceSystem());
|
|
- bo.setSpbillCreateIp(IpUtils.getRealIp(request));
|
|
|
|
|
|
+ bo.setSpbillCreateIp(userData.getIp());
|
|
bo.setOutTradeNo(product.getOrderId());
|
|
bo.setOutTradeNo(product.getOrderId());
|
|
bo.setPayWay(product.getPayWay());
|
|
bo.setPayWay(product.getPayWay());
|
|
bo.setCode(product.getCode());
|
|
bo.setCode(product.getCode());
|
|
return orderPayService.payCreate(bo);
|
|
return orderPayService.payCreate(bo);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @UnSignCheck
|
|
@ApiOperation(value = "支付宝支付异步回调(二维码、H5、网站)")
|
|
@ApiOperation(value = "支付宝支付异步回调(二维码、H5、网站)")
|
|
@RequestMapping(value = "notify", method = RequestMethod.POST)
|
|
@RequestMapping(value = "notify", method = RequestMethod.POST)
|
|
public String aliPayNotify(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
public String aliPayNotify(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
return orderPayService.notify(request, response, PayWayEnum.ALIPAY.getNum());
|
|
return orderPayService.notify(request, response, PayWayEnum.ALIPAY.getNum());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @UnSignCheck
|
|
@ApiOperation(value = "微信支付")
|
|
@ApiOperation(value = "微信支付")
|
|
@RequestMapping(value = "wxPayNotify", method = RequestMethod.POST)
|
|
@RequestMapping(value = "wxPayNotify", method = RequestMethod.POST)
|
|
public String wxPayNotify(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
public String wxPayNotify(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
return orderPayService.notify(request, response, PayWayEnum.WXPAY.getNum());
|
|
return orderPayService.notify(request, response, PayWayEnum.WXPAY.getNum());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @UnSignCheck
|
|
@ApiOperation(value = "支付宝支付同步回调(二维码、H5、网站)")
|
|
@ApiOperation(value = "支付宝支付同步回调(二维码、H5、网站)")
|
|
@RequestMapping(value = "alipaySynNotify", method = RequestMethod.GET)
|
|
@RequestMapping(value = "alipaySynNotify", method = RequestMethod.GET)
|
|
public ResultMap synNotify(HttpServletRequest request) {
|
|
public ResultMap synNotify(HttpServletRequest request) {
|