Ver código fonte

fix 海外支付

zoujiajian 2 anos atrás
pai
commit
cf4adc93a1

+ 1 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/OrderMasterDon.java

@@ -174,6 +174,7 @@ public class OrderMasterDon extends BaseEntity{
 		EQUIPMENT("equipment", "实物设备分销"),
 		PAY_EQUIPMENT("pay_equipment", "自购设备"),
 		BALANCE("balance", "余额支付"),
+		GALAXYCOIN("galaxycoin", "银河币支付"),
 		PAYPAL("paypal","paypal支付"),
 		STRIPE("stripe","stripe支付")
 		;

+ 12 - 0
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -1079,6 +1079,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 			if (orderSku.getIsNoLogin()) {
 				orderSku.setExCode(exchangeCodeService.getExCode(goodsId, orderSku.getSkuId(), 1));
 			}
+			if (orderSku.getMoney().compareTo(BigDecimal.ZERO) > 0) {
+				orderSku.setType(OrderDon.Type.WeChat);
+			}
 			unifiedHandlerOrderNotify(orderSku, goodsDon, sku);
 		});
 	}
@@ -1414,6 +1417,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
 			}
 			GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
+			if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0) {
+				orderDon.setType(OrderDon.Type.ALI_PAY);
+			}
 			unifiedHandlerOrderNotify(orderDon, goodsDon, sku);
 		});
 	}
@@ -2136,6 +2142,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 						orderDonlist.forEach(orderDon -> {
 							GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
 							orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
+							if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0) {
+								orderDon.setType(OrderDon.Type.WeChat);
+							}
 							updateNoPayment(orderDon, goodsDon);
 						});
 						return OrderMasterDon.Status.hasPayment;
@@ -2156,6 +2165,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 						orderDonlist.forEach(orderDon -> {
 							GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
 							orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
+							if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0) {
+								orderDon.setType(OrderDon.Type.ALI_PAY);
+							}
 							updateNoPayment(orderDon, goodsDon);
 						});
 						return OrderMasterDon.Status.hasPayment;

+ 12 - 6
netflix-service/src/main/java/com/cyksj/service/paypal/PayPalService.java

@@ -85,6 +85,9 @@ public class PayPalService{
             List<OrderDon> orderDonList = orderDonService.list(Wrappers.lambdaQuery(OrderDon.class)
                     .eq(OrderDon::getMOid, mOid));
             orderDonList.forEach(orderDon -> {
+                if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0) {
+                    orderDon.setType(OrderDon.Type.PAYPAL);
+                }
                 orderDonService.orderNotify(orderDon);
             });
 
@@ -120,14 +123,17 @@ public class PayPalService{
     }
 
 
-    public Payment createPayment(Long orderId,String successUrl) throws PayPalRESTException {
-        redisService.set(RedisService.key.ABROAD_SUCCESS_URL.getName() + orderId,successUrl,RedisService.key.ABROAD_SUCCESS_URL.getTimeout());
-        OrderDon orderDon = orderDonService.getById(orderId);
+    public Payment createPayment(Long mOid,String successUrl) throws PayPalRESTException {
+        redisService.set(RedisService.key.ABROAD_SUCCESS_URL.getName() + mOid,successUrl,RedisService.key.ABROAD_SUCCESS_URL.getTimeout());
+        OrderMasterDon orderDon = orderMasterDonService.getById(mOid);
+
         BigDecimal money = orderDon.getMoney().divide(new BigDecimal(7),2,RoundingMode.HALF_DOWN);
         orderDon.setAbroadMoney(money);
-        orderDon.setType(OrderDon.Type.PAYPAL);
-        orderDonService.updateById(orderDon);
-        if (OrderDon.Status.hasPayment.equals(orderDon.getStatus())) {
+        orderDon.setType(OrderMasterDon.Type.PAYPAL);
+
+        orderMasterDonService.updateById(orderDon);
+
+        if (OrderMasterDon.Status.hasPayment.equals(orderDon.getStatus())) {
             throw new BusinessRuntimeException(GatewayApiCode.METADATA_SYSTEM_ERROR.getCode(),"该捐款已支付");
         }
         PaypalPayConfig paypalPayConfig = paypalPayConfigService.getById(1);

+ 9 - 6
netflix-service/src/main/java/com/cyksj/service/stripe/StripeService.java

@@ -49,13 +49,13 @@ public class StripeService {
 
 
 
-    public String checkOutStripe(Long orderId,String successUrl) throws Exception{
-       OrderDon orderDon = orderDonService.getById(orderId);
-       BigDecimal money = orderDon.getMoney();
-       orderDon.setType(OrderDon.Type.STRIPE);
-       orderDonService.updateById(orderDon);
+    public String checkOutStripe(Long mOid,String successUrl) throws Exception{
+        OrderMasterDon orderDon = orderMasterDonService.getById(mOid);
+        BigDecimal money = orderDon.getMoney();
+        orderDon.setType(OrderMasterDon.Type.STRIPE);
+        orderMasterDonService.updateById(orderDon);
        HashMap<String, String> responseData = new HashMap<String, String>();
-       if (OrderDon.Status.hasPayment.equals(orderDon.getStatus())) {
+        if (!orderDon.getStatus().equals(OrderMasterDon.Status.noPayment) && !orderDon.getStatus().equals(OrderMasterDon.Status.close)) {
            throw new BusinessRuntimeException(GatewayApiCode.METADATA_SYSTEM_ERROR.getCode(),"The donation has been paid");
        }
        StripePayConfig stripePayConfig = stripePayConfigMapper.selectById(1);
@@ -121,6 +121,9 @@ public class StripeService {
        List<OrderDon> orderDonList = orderDonService.list(Wrappers.lambdaQuery(OrderDon.class)
                .eq(OrderDon::getMOid, mOid));
        orderDonList.forEach(orderDon->{
+           if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0) {
+               orderDon.setType(OrderDon.Type.STRIPE);
+           }
            orderDonService.orderNotify(orderDon);
        });
    }

+ 9 - 9
netflix-web/src/main/java/com/cyksj/web/controller/payment/OrderController.java

@@ -545,19 +545,19 @@ public class OrderController {
     /**
      * paypal支付
      */
-    @PostMapping("/paypal/pay/{orderId}")
-    public Result<String> paypalPay(@PathVariable Long orderId,String successUrl) throws Exception {
+    @PostMapping("/paypal/pay/{mOid}")
+    public Result<String> paypalPay(@PathVariable Long mOid,String successUrl) throws Exception {
         final String methodName = "paypal支付";
-        log.info("{}[start] orderId:{}",methodName,orderId);
+        log.info("{}[start] orderId:{}",methodName,mOid);
 
-        Payment payment = payPalService.createPayment(orderId,successUrl);
+        Payment payment = payPalService.createPayment(mOid,successUrl);
         String payUrl = "/";
         log.info("paypal links:{}",payment.getLinks());
         for(Links links : payment.getLinks()){
             if("approval_url".equals(links.getRel())){
                 // 客户付款登陆地址
                 String payPalUrl = links.getHref();
-                log.info("PayPal调起支付成功[end]:{}", orderId);
+                log.info("PayPal调起支付成功[end]:{}", mOid);
                 payUrl = payPalUrl;
             }
         }
@@ -571,11 +571,11 @@ public class OrderController {
     /**
      * stripe支付
      */
-    @PostMapping("/stripe/pay/{orderId}")
-    public Result<String> stripePay(@PathVariable Long orderId,String successUrl) throws Exception {
+    @PostMapping("/stripe/pay/{mOid}")
+    public Result<String> stripePay(@PathVariable Long mOid,String successUrl) throws Exception {
         final String methodName = "stripe支付";
-        log.info("{}[start] orderId:{}",methodName,orderId);
-        String payUrl = stripeService.checkOutStripe(orderId,successUrl);
+        log.info("{}[start] orderId:{}",methodName,mOid);
+        String payUrl = stripeService.checkOutStripe(mOid,successUrl);
 
         log.info("Stripe支付成功 result:{}[end]",payUrl);
         return GatewayResponse.SUCCESS.newBuilder().toResult(payUrl);