liujunchi 3 lat temu
rodzic
commit
cfe75d78a7

+ 1 - 1
cooleshow-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/OmsOrderReturnApplyServiceImpl.java

@@ -110,7 +110,7 @@ public class OmsOrderReturnApplyServiceImpl implements OmsOrderReturnApplyServic
      */
     private void refundAmount(OmsOrderReturnApply returnApply) {
         // 退款
-        UserOrderPayment userOrderPayment = userOrderPaymentMapper.selectByTranNo(returnApply.getOrderSn());
+        UserOrderPayment userOrderPayment = userOrderPaymentMapper.selectByOrderNoAndStatusSucceeded(returnApply.getOrderSn());
         OrderRefundReq refundReq = new OrderRefundReq();
         refundReq.setOrderNo(returnApply.getOrderSn());
         refundReq.setRefundAmount(returnApply.getReturnAmount().setScale(2, RoundingMode.HALF_UP).toString());

+ 2 - 0
cooleshow-mall/mall-mbg/src/main/java/com/yonge/cooleshow/mbg/mapper/UserOrderPaymentMapper.java

@@ -22,4 +22,6 @@ public interface UserOrderPaymentMapper {
             "payChannel") String payChannel, @Param("payStatus") String payStatus);
 
     UserOrderPayment selectByOrderNoAndStatusPaying(@Param("orderSn") String orderSn);
+
+    UserOrderPayment selectByOrderNoAndStatusSucceeded(@Param("orderSn") String orderSn);
 }

+ 6 - 0
cooleshow-mall/mall-mbg/src/main/resources/config/mybatis/UserOrderPaymentMapper.xml

@@ -245,4 +245,10 @@
         from user_order_payment where order_no_ = #{orderSn}
         and status_ = #{payStatus} and pay_channel_ = #{payChannel}
     </select>
+
+    <select id="selectByOrderNoAndStatusSucceeded" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from user_order_payment where order_no_ = #{orderSn} and status_ = 'succeeded'
+    </select>
 </mapper>

+ 16 - 1
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/UserOrderPaymentService.java

@@ -49,5 +49,20 @@ public interface UserOrderPaymentService {
      */
     void closePayment(String orderSn, String message);
 
-    UserOrderPayment selectByOrderNoAndStatusPaying(String orderSn);
+    /**
+     * 查询支付中的订单, 最多只有一个
+     *
+     * @param orderSn
+     * @return
+     */
+    UserOrderPayment getByOrderNoAndStatusPaying(String orderSn);
+
+
+    /**
+     * 查询支付成功的订单, 最多只有一个
+     *
+     * @param orderSn
+     * @return
+     */
+    UserOrderPayment getByOrderNoAndStatusSucceeded(String orderSn);
 }

+ 3 - 4
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/OmsPortalOrderServiceImpl.java

@@ -615,9 +615,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
     @Transactional(rollbackFor = Exception.class)
     void payingOrderHandle(OmsOrder userOrder) {
         //判断汇付订单状态
-        UserOrderPayment orderPayment = userOrderPaymentService.getByTranNo(userOrder.getOrderSn());
+        UserOrderPayment orderPayment = userOrderPaymentService.getByOrderNoAndStatusPaying(userOrder.getOrderSn());
         if (null == orderPayment) {
-            return;
+            cancelOrder(userOrder.getId(), "支付超时");
         }
         try {
             Map<String, Object> resMap = paymentSdk.queryPayment(orderPayment.getTransNo());
@@ -639,14 +639,13 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
     /**
      * 订单完成
      *
-     * @author liweifan
      * @param: detail
      * @updateTime 2022/4/13 17:17
      */
     @Transactional(rollbackFor = Exception.class)
     void orderSuccess(OmsOrder detail, JSONObject hfRes) {
         //更新订单
-        UserOrderPayment orderPayment = userOrderPaymentService.getByTranNo(detail.getOrderSn());
+        UserOrderPayment orderPayment = userOrderPaymentService.getByOrderNoAndStatusPaying(detail.getOrderSn());
         if (orderPayment.getPayChannel().equals("alipay")) {
             paySuccess(detail.getId(),1);
         } else if (orderPayment.getPayChannel().equals("wx_lite")) {

+ 6 - 1
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/UserOrderPaymentServiceImpl.java

@@ -88,7 +88,12 @@ public class UserOrderPaymentServiceImpl implements UserOrderPaymentService {
     }
 
     @Override
-    public UserOrderPayment selectByOrderNoAndStatusPaying(String orderSn) {
+    public UserOrderPayment getByOrderNoAndStatusPaying(String orderSn) {
         return userOrderPaymentMapper.selectByOrderNoAndStatusPaying(orderSn);
     }
+
+    @Override
+    public UserOrderPayment getByOrderNoAndStatusSucceeded(String orderSn) {
+        return userOrderPaymentMapper.selectByOrderNoAndStatusSucceeded(orderSn);
+    }
 }