Sfoglia il codice sorgente

支付回调添加参数payType

lyhzzz 2 anni fa
parent
commit
a7ebf50d90

+ 1 - 0
src/main/java/com/fdkankan/pay/common/ResultCode.java

@@ -14,6 +14,7 @@ public enum ResultCode {
     ALIPAY_CONFIG_ERROR(10007, "支付宝config缺失!"),
     PAYPAL_ERROR(10008, "paypal支付失败!"),
     PAYPAL_CONFIG_ERROR(10009, "paypal-config缺失!"),
+    ORDER_NO_PAY(10010, "订单未支付"),
 
     ;
 

+ 3 - 3
src/main/java/com/fdkankan/pay/controller/PayController.java

@@ -56,10 +56,10 @@ public class PayController extends BaseController {
     }
 
 
-    @RequestMapping(value = "/callBack/{orderSn}")
-    public String callback(@PathVariable String orderSn) {
+    @RequestMapping(value = "/callBack/{orderSn}/{payType}")
+    public String callback(@PathVariable String orderSn,@PathVariable Integer payType) {
         if(request.getMethod().equals("POST")){
-            payOrderService.callBack(orderSn, request, response);
+            payOrderService.callBack(orderSn,payType, request, response);
         }else {
             log.info("wx-callBack--无效req:{}",request.getMethod());
         }

+ 2 - 1
src/main/java/com/fdkankan/pay/service/impl/PayOrderService.java

@@ -57,7 +57,7 @@ public class PayOrderService {
         return null;
     }
 
-    public Boolean callBack(String orderSn, HttpServletRequest request, HttpServletResponse response) {
+    public Boolean callBack(String orderSn, Integer payType,HttpServletRequest request, HttpServletResponse response) {
         Order order = orderService.getByOrderSn(orderSn);
         if(order == null){
             throw new BusinessException(ResultCode.ORDER_NOT_EXIST);
@@ -65,6 +65,7 @@ public class PayOrderService {
         if(order.getPayStatus() != 0){
             return false;
         }
+        order.setPayType(payType);
         //微信支付回调
         if(order.getPayType() == 0 || order.getPayType() == 1 || order.getPayType() == 2){
             return wechatPayService.callBack(request,response,order);

+ 1 - 1
src/main/java/com/fdkankan/pay/util/alipay/sdk/AlipayService.java

@@ -60,7 +60,7 @@ public class AlipayService {
         if(aliConfig == null){
             throw new BusinessException(ResultCode.ALIPAY_CONFIG_ERROR);
         }
-        aliConfig.setCallBackUrl( CacheUtil.mainUrl + aliConfig.getCallBackUrl() + "/" + orderSn);
+        aliConfig.setCallBackUrl( CacheUtil.mainUrl + aliConfig.getCallBackUrl() + "/" + orderSn+"/"+param.getPayType());
         String body = subject;
 
         List<AlipayGoodsDetail> goodsDetailList = new ArrayList<>();

+ 2 - 3
src/main/java/com/fdkankan/pay/util/paypal/sdk/PaypalService.java

@@ -48,7 +48,7 @@ public class PaypalService {
         if(paypalConfig == null){
             throw new BusinessException(ResultCode.PAYPAL_CONFIG_ERROR);
         }
-        paypalConfig.setCallBackUrl( CacheUtil.mainUrl + paypalConfig.getCallBackUrl() +"/"+orderSn);
+        paypalConfig.setCallBackUrl( CacheUtil.mainUrl + paypalConfig.getCallBackUrl() +"/"+orderSn+"/"+param.getPayType());
         String body = subject;
         //paypal支付
         if(param.getPayType() == 5){
@@ -80,8 +80,7 @@ public class PaypalService {
     }
 
     public Boolean callBack(HttpServletRequest request, HttpServletResponse response, Order order) {
-
-        log.info("ali-callBack--order:{}",order);
+        log.info("paypal-callBack--order:{}",order);
         Boolean payFlag = false;
         String trade_no = null;
         String openId = null;

+ 1 - 1
src/main/java/com/fdkankan/pay/util/wx/WechatPayService.java

@@ -41,7 +41,7 @@ public class WechatPayService {
         if(wxConfig == null){
             throw new BusinessException(ResultCode.WX_CONFIG_NOT);
         }
-        wxConfig.setCallBackUrl( CacheUtil.mainUrl + wxConfig.getCallBackUrl() +"/"+orderSn);
+        wxConfig.setCallBackUrl( CacheUtil.mainUrl + wxConfig.getCallBackUrl() +"/"+orderSn+"/"+param.getPayType());
         BigDecimal totalFee = amount.multiply(new BigDecimal(100));
         String body = subject;
         if(param.getPayType() == 0){