Browse Source

订单回调测试

liujc 1 year ago
parent
commit
5cbaa0ae52

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

@@ -393,7 +393,7 @@ public class TenantAlbumServiceImpl extends ServiceImpl<TenantAlbumMapper, Tenan
 
 
         TenantAlbumWrapper.TenantAlbumContent tenantAlbumContent = JSON
-                .parseObject(JSON.toJSONString(orderGoodsInfo.getBizContent()), TenantAlbumWrapper.TenantAlbumContent.class);
+                .parseObject(orderGoodsInfo.getUserOrderDetail().getBizContent(), TenantAlbumWrapper.TenantAlbumContent.class);
         TenantAlbumPurchase tenantAlbumPurchase = new TenantAlbumPurchase();
         tenantAlbumPurchase.setTenantId(tenantAlbumContent.getTenantId());
         tenantAlbumPurchase.setTenantAlbumId(orderGoodsInfo.getBizId());

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

@@ -3,8 +3,12 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
+import com.microsvc.toolkit.config.jwt.utils.JwtUserInfo;
+import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentResp;
+import com.microsvc.toolkit.middleware.payment.common.api.enums.PaymentStatus;
 import com.yonge.cooleshow.biz.dal.dao.UserOrderDao;
 import com.yonge.cooleshow.biz.dal.dto.UserAccountRecordDto;
 import com.yonge.cooleshow.biz.dal.dto.req.OrderPayReq;
@@ -329,13 +333,48 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
                 || OrderStatusEnum.PAYING.equals(detail.getStatus())) {
 
             if (OrderStatusEnum.CLOSE.equals(orderStatus)) {
-                doOrderCancel(detail, orderStatus, "测试接口-订单关闭");
+                if (detail.getPaymentVersion().equals(EPaymentVersion.V1))
+                    doOrderCancel(detail, orderStatus, "测试接口-订单关闭");
+                else {
+                    // 用户取消支付
+                    userPaymentCoreService.cancelPayment(JwtUserInfo.builder().userId(detail.getUserId().toString())
+                            .clientType(detail.getPaymentClient()).build(), orderNo);
+                }
             }
             if (OrderStatusEnum.FAIL.equals(orderStatus)) {
-                doOrderCancel(detail, orderStatus, "测试接口-订单交易失败");
+                if (detail.getPaymentVersion().equals(EPaymentVersion.V1))
+                    doOrderCancel(detail, orderStatus, "测试接口-订单交易失败");
+                else {
+                    // 用户取消支付
+                    PaymentResp resp = new PaymentResp();
+                    resp.setMerOrderNo(orderNo);
+                    resp.setPaymentStatus(PaymentStatus.FAILED);
+                    resp.setTriggerTime(new Date());
+                    resp.setTransNo(detail.getTransNo());
+                    resp.setPaymentAmount(detail.getActualPrice());
+                    resp.setPaymentChannel(detail.getPaymentChannel());
+                    resp.setMsg("测试订单失败");
+                    // 执行支付回调流程
+                    userPaymentCoreService.executePaymentCallback(resp);
+                }
             }
             if (OrderStatusEnum.PAID.equals(orderStatus)) {
-                testOrderSuccess(detail.getOrderNo());
+                if (detail.getPaymentVersion().equals(EPaymentVersion.V1))
+                    testOrderSuccess(detail.getOrderNo());
+                else {
+                    // 用户取消支付
+                    PaymentResp resp = new PaymentResp();
+                    resp.setMerOrderNo(orderNo);
+                    resp.setPaymentStatus(PaymentStatus.SUCCESSED);
+                    resp.setTriggerTime(new Date());
+                    resp.setTransNo(detail.getTransNo());
+                    resp.setPaymentAmount(detail.getActualPrice());
+                    resp.setServiceCharge(BigDecimal.ZERO);
+                    resp.setPaymentChannel(detail.getPaymentChannel());
+                    resp.setMsg("测试订单成功");
+                    // 执行支付回调流程
+                    userPaymentCoreService.executePaymentCallback(resp);
+                }
             }
         }
         return true;

+ 7 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserPaymentCoreServiceImpl.java

@@ -266,6 +266,9 @@ public class UserPaymentCoreServiceImpl implements UserPaymentCoreService {
                         .updateTime(DateTime.now().toDate())
                         .build();
                     userPaymentOrderService.updateById(order);
+
+                    // 订单关闭后的数据处理流程
+                    userOrderService.payCancel(userOrderService.detail(order.getId()));
                 }
 
                 log.info("executePaymentCallback WAIT_PAY, status={}, paymentResp={}", paymentOrder.getStatus(),
@@ -778,6 +781,8 @@ public class UserPaymentCoreServiceImpl implements UserPaymentCoreService {
                         .build();
                     userPaymentOrderService.updateById(update);
 
+                    // 订单关闭后的数据处理流程
+                    userOrderService.payCancel(userOrderService.detail(reqConfig.getMerOrderNo(),null));
                     throw BizException.from("支付超时");
                 }
 
@@ -881,6 +886,8 @@ public class UserPaymentCoreServiceImpl implements UserPaymentCoreService {
                     .build();
                 userPaymentOrderService.updateById(order);
 
+                // 订单关闭后的数据处理流程
+                userOrderService.payCancel(userOrderService.detail(order.getId()));
 
             } else {
                 // 获取三方支付订单信息,根据订单状处理

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserPaymentOrderServiceImpl.java

@@ -151,6 +151,9 @@ public class UserPaymentOrderServiceImpl  implements UserPaymentOrderService {
         userOrder.setId(id);
         userOrder.setStatus(OrderStatusEnum.CLOSE);
         userOrderService.updateById(userOrder);
+
+        // 订单关闭后的数据处理流程
+        userOrderService.payCancel(userOrderService.detail(id));
     }