刘俊驰 6 月之前
父节点
当前提交
d9cb8fd290

+ 24 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/open/UserOrderClient.java

@@ -2,6 +2,8 @@ package com.yonge.cooleshow.admin.controller.open;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.microsvc.toolkit.common.response.template.R;
+import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentResp;
 import com.yonge.cooleshow.biz.dal.entity.UserOrder;
 import com.yonge.cooleshow.biz.dal.entity.UserOrderPayment;
 import com.yonge.cooleshow.biz.dal.entity.UserOrderRefundBill;
@@ -10,6 +12,7 @@ import com.yonge.cooleshow.biz.dal.service.UserOrderPaymentService;
 import com.yonge.cooleshow.biz.dal.service.UserOrderRefundService;
 import com.yonge.cooleshow.biz.dal.service.UserOrderService;
 import com.yonge.cooleshow.biz.dal.vo.UserOrderVo;
+import com.yonge.cooleshow.biz.dal.wrapper.UserPaymentOrderWrapper;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.ContractDto;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
@@ -25,6 +28,8 @@ import com.yonge.toolset.payment.base.model.callback.PaymentCallBack;
 import com.yonge.toolset.payment.core.service.PaymentClient;
 import com.yonge.toolset.payment.util.DistributedLock;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
@@ -40,6 +45,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 
 @RestController
@@ -54,6 +60,9 @@ public class UserOrderClient extends BaseController {
     private UserOrderRefundService userOrderRefundService;
     @Autowired
     private UserOrderService userOrderService;
+
+    @Autowired
+    private UserOrderPaymentService userOrderPaymentService;
     @Autowired
     private PaymentClient paymentClient;
     @Autowired
@@ -203,4 +212,19 @@ public class UserOrderClient extends BaseController {
         paymentService.setContractRecord(contract.getType(), contract.getUserId());
         return succeed(true);
     }
+
+    @ApiOperation(value = "关闭订单测试", notes = "关闭订单测试")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name = "orderNo", value = "订单号", dataType = "String")
+    })
+    @GetMapping("/closedV1/{orderNo}")
+    public HttpResponseResult<Boolean> testOrderClosed(@PathVariable("orderNo") String orderNo) {
+        if (!debugMode) {
+            return HttpResponseResult.failed("当前环境不允许调用");
+        }
+        // 测试订单关闭
+        userOrderPaymentService.onlyClosePaymentAndReqOpen( orderNo,"关闭订单测试");
+
+        return HttpResponseResult.succeed();
+    }
 }

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserOrderPaymentService.java

@@ -59,6 +59,8 @@ public interface UserOrderPaymentService extends IService<UserOrderPayment> {
     Boolean closePaymentAndReqOpen(String orderNo, String reason);
 
 
+    UserOrderPayment onlyClosePaymentAndReqOpen(String orderNo, String reason);
+
     /***
      * 创建付款单
      * @author liweifan

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

@@ -94,9 +94,19 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
 
     @Override
     public Boolean closePaymentAndReqOpen(String orderNo, String reason) {
+        UserOrderPayment userOrderPayment = onlyClosePaymentAndReqOpen(orderNo, reason);
+        if (userOrderPayment != null) {
+            updateById(userOrderPayment);
+        }
+        return true;
+    }
+
+
+    @Override
+    public UserOrderPayment onlyClosePaymentAndReqOpen(String orderNo, String reason) {
         UserOrderPayment orderPayment = baseMapper.selectOne(Wrappers.<UserOrderPayment>lambdaQuery().eq(UserOrderPayment::getOrderNo, orderNo).eq(UserOrderPayment::getStatus, TradeStatusEnum.pending));
         if (null == orderPayment) {
-            return true;
+            return null;
         }
         //更新付款单
         orderPayment.setStatus(TradeStatusEnum.close);
@@ -123,8 +133,7 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
                 }
             }
         }
-        updateById(orderPayment);
-        return true;
+        return orderPayment;
     }
 
     @Override