Selaa lähdekoodia

支付问题修改

liweifan 3 vuotta sitten
vanhempi
commit
eb15a6d50b

+ 10 - 5
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderRefundServiceImpl.java

@@ -140,14 +140,18 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
                     HttpResponseResult<RefundCreateRes> apply = refundCreateFunction.apply(refundReq);
                     if (apply.getStatus()) {
                         detilIds.add(vo.getId());
-                        actualPrice.add(apply.getData().getActualPrice());
+                        actualPrice = actualPrice.add(apply.getData().getActualPrice());
                     }
                 } else {
                     detilIds.add(vo.getId());
-                    actualPrice.add(vo.getActualPrice());
+                    actualPrice = actualPrice.add(vo.getActualPrice());
                 }
             }
         }
+        if(actualPrice.doubleValue() <= 0){
+            throw new BizException("退款金额不能为0");
+        }
+
         String join = StringUtil.join(detilIds, ",");
 
         UserOrderRefund orderRefunds = new UserOrderRefund();
@@ -253,11 +257,11 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
                 HttpResponseResult<RefundCreateRes> apply = refundCreateFunction.apply(orderRefundReq);
                 if (apply.getStatus()) {
                     detilIds.add(vo.getId());
-                    actualPrice.add(apply.getData().getActualPrice());
+                    actualPrice = actualPrice.add(apply.getData().getActualPrice());
                 }
             } else {
                 detilIds.add(vo.getId());
-                actualPrice.add(vo.getActualPrice());
+                actualPrice = actualPrice.add(vo.getActualPrice());
             }
         }
         String join = StringUtil.join(detilIds, ",");
@@ -310,7 +314,8 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
 
         RefundBill refundBill = new RefundBill(payment.getOpenType(),
                 PaymentClientEnum.valueOf(payment.getPaymentClient()), payment.getPayChannel());
-        refundBill.setId(payment.getTransNo());
+        refundBill.setTradeNo(payment.getTransNo());
+        refundBill.setPaymentNo(payment.getPaymentNo());
         refundBill.setRefundNo(billNo.toString());
         refundBill.setOrderAmt(payment.getPayAmt());
         refundBill.setRefundAmt(orderRefund.getActualAmount());

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java

@@ -254,7 +254,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
         //验证参数,必须验证参数
         for (OrderReq.OrderReqInfo info : orderReq.getOrderInfos()) {
             Function<OrderReq.OrderReqInfo, HttpResponseResult<OrderCreateRes>> createFunction = orderCreate.get(info.getGoodType());
-            if (!Objects.isNull(createFunction)) {
+            if (Objects.isNull(createFunction)) {
                 return HttpResponseResult.failed("订单商品信息获取失败");
             }
             info.setOrderNo(orderReq.getOrderNo());

+ 7 - 4
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/wx/OriginalWxAppTemplate.java

@@ -217,10 +217,10 @@ public class OriginalWxAppTemplate implements PaymentTemplate {
             return BaseResult.succeed(refundBill);
         } catch (WxPayException e) {
             log.error("微信APP支付请求失败:{}", e.toString());
-            return BaseResult.failed(e.toString());
+            throw new BizException(e.toString());
         } catch (Exception e) {
             e.printStackTrace();
-            return BaseResult.failed("微信APP支付关单请求失败");
+            throw new BizException("微信APP支付关单请求失败");
         }
     }
 
@@ -236,7 +236,6 @@ public class OriginalWxAppTemplate implements PaymentTemplate {
         String params = WebUtil.getBodyData(request);
         log.info("微信APP回调:{}", params);
 
-
         PaymentCallBack paymentCallBack = new PaymentCallBack();
         paymentCallBack.setMethodName(methodName);
 
@@ -301,7 +300,11 @@ public class OriginalWxAppTemplate implements PaymentTemplate {
                 RefundPaymentCallBack refundPayment = new RefundPaymentCallBack();
                 refundPayment.setBillNo(result.getOutRefundNo());
                 refundPayment.setTransNo(result.getRefundId());
-                refundPayment.setRefundAmt(result.getAmount().getRefund());
+                refundPayment.setRefundAmt(
+                        new BigDecimal(result.getAmount().getRefund())
+                                .divide(new BigDecimal("100"))
+                                .toString()
+                );
 
                 if (!StringUtil.isEmpty(result.getSuccessTime())) {
                     Date date = new DateTime(result.getSuccessTime()).toDate();