Browse Source

fix(order): 启用订单退款校验逻辑

- 启用订单分账状态校验,禁止分账后退款
- 校验订单类型,仅允许指定类型退款
- 校验订单商品使用状态,已使用商品不可退款
- 根据门店退款规则判断是否支持退款
- 对提前退款时间进行校验,超时不可退款
-修复退款校验逻辑被注释导致的问题
wzq 4 weeks ago
parent
commit
f35a4ae40d

+ 34 - 34
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/OrderServiceImpl.java

@@ -1856,40 +1856,40 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
         List<String> refundOrderProInfoIds = new ArrayList<>(Arrays.asList(refundOrderForm.getOrderProInfoIds().split(",")));
         List<AppOrderProInfo> appOrderProInfoList = new ArrayList<>();
         if (ObjectUtil.isNotEmpty(appOrder)) {
-//            if (appOrder.getProfitSharingStatus() > CommonConstant.NUMBER_0) {
-//                throw new JeecgBootException("当前订单无法进行退款,请联系客服处理!");
-//            }
-//            if(!Objects.equals(appOrder.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_1) && !appOrder.getOrderType().equals(CommonConstant.ORDER_PRO_INFO_TYPE_2)){
-//                throw new JeecgBootException("当前订单类型不支持退款!");
-//            }
-//            if (Objects.equals(appOrder.getOrderStatus(), CommonConstant.ORDER_STATUS_2)) {
-//                throw new JeecgBootException("订单商品已使用,无法进行退款!");
-//            }
-//            //通过订单查询门店退款规则,判断是否可以进行退款
-//            String s = appOrder.getProductIds().split(",")[0];
-//            String priceRuleId = s.split("\\|")[0];
-//            AppSitePriceRules appSitePriceRules =
-//                    appSitePriceRulesMapper.selectOne(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getId, priceRuleId).last("limit 1"));
-//            String sitePlaceId = appSitePriceRules.getSitePlaceId();
-//            AppSitePlace appSitePlace = appSitePlaceMapper.selectById(sitePlaceId);
-//            if (Objects.equals(appOrder.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_2) && Objects.equals(appSitePlace.getRefundType(),
-//                    CommonConstant.NUMBER_2)) {
-//                throw new JeecgBootException("当前门店不支持退款!");
-//            }
-//            if (Objects.equals(appSitePlace.getRefundType(), CommonConstant.NUMBER_1)) {
-//
-//                for (String refundOrderProInfoId : refundOrderProInfoIds) {
-//                    AppOrderProInfo appOrderProInfo = appOrderProInfoMapper.selectById(refundOrderProInfoId);
-//                    String productId = appOrderProInfo.getProductId();
-//                    AppSitePriceRules sitePriceRules = appSitePriceRulesMapper.selectById(productId);
-//                    Instant originalInstant  = sitePriceRules.getStartTime().toInstant();
-//                    Instant time = originalInstant.minusSeconds(appSitePlace.getEarlyRefundTime() * 60);
-//                    Instant now = Instant.now();
-//                    if (!now.isBefore(time)) {
-//                        throw new JeecgBootException("商品:"+ appOrderProInfo.getProductName() +" 已超过可退时间,无法进行退款!");
-//                    }
-//                }
-//            }
+            if (appOrder.getProfitSharingStatus() > CommonConstant.NUMBER_0) {
+                throw new JeecgBootException("当前订单无法进行退款,请联系客服处理!");
+            }
+            if(!Objects.equals(appOrder.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_1) && !appOrder.getOrderType().equals(CommonConstant.ORDER_PRO_INFO_TYPE_2)){
+                throw new JeecgBootException("当前订单类型不支持退款!");
+            }
+            if (Objects.equals(appOrder.getOrderStatus(), CommonConstant.ORDER_STATUS_2)) {
+                throw new JeecgBootException("订单商品已使用,无法进行退款!");
+            }
+            //通过订单查询门店退款规则,判断是否可以进行退款
+            String s = appOrder.getProductIds().split(",")[0];
+            String priceRuleId = s.split("\\|")[0];
+            AppSitePriceRules appSitePriceRules =
+                    appSitePriceRulesMapper.selectOne(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getId, priceRuleId).last("limit 1"));
+            String sitePlaceId = appSitePriceRules.getSitePlaceId();
+            AppSitePlace appSitePlace = appSitePlaceMapper.selectById(sitePlaceId);
+            if (Objects.equals(appOrder.getOrderType(), CommonConstant.ORDER_PRO_INFO_TYPE_2) && Objects.equals(appSitePlace.getRefundType(),
+                    CommonConstant.NUMBER_2)) {
+                throw new JeecgBootException("当前门店不支持退款!");
+            }
+            if (Objects.equals(appSitePlace.getRefundType(), CommonConstant.NUMBER_1)) {
+
+                for (String refundOrderProInfoId : refundOrderProInfoIds) {
+                    AppOrderProInfo appOrderProInfo = appOrderProInfoMapper.selectById(refundOrderProInfoId);
+                    String productId = appOrderProInfo.getProductId();
+                    AppSitePriceRules sitePriceRules = appSitePriceRulesMapper.selectById(productId);
+                    Instant originalInstant  = sitePriceRules.getStartTime().toInstant();
+                    Instant time = originalInstant.minusSeconds(appSitePlace.getEarlyRefundTime() * 60);
+                    Instant now = Instant.now();
+                    if (!now.isBefore(time)) {
+                        throw new JeecgBootException("商品:"+ appOrderProInfo.getProductName() +" 已超过可退时间,无法进行退款!");
+                    }
+                }
+            }
 
             //退款金额统计(不为保险的子订单)
             for (String refundOrderProInfoId : refundOrderProInfoIds) {