Parcourir la source

添加商家端注销校验

lutong il y a 7 heures
Parent
commit
20f2411423

+ 3 - 1
alien-store/src/main/java/shop/alien/store/service/StoreUserService.java

@@ -159,7 +159,9 @@ public interface StoreUserService extends IService<StoreUser> {
     R<Boolean> register(String phone, String password);
 
     /**
-     * 效验商家端账号注销
+     * 效验商家端账号注销。
+     * accountMoney/accountStore/accountDiningOrder/accountReservationOrder:0 未通过,1 通过;
+     * accountDiningOrderCount/accountReservationOrderCount:未完成订单数量。
      */
     Map<String,String> storeCancelAccountVerification(StoreUserVo storeUserVo);
 

+ 37 - 5
alien-store/src/main/java/shop/alien/store/service/impl/StoreUserServiceImpl.java

@@ -95,6 +95,16 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
     @Value("${jwt.expiration-time}")
     private String effectiveTime;
 
+    /** 点餐订单未完成:待支付、已支付未完结 */
+    private static final List<Integer> PENDING_DINING_ORDER_STATUSES = Arrays.asList(0, 1);
+
+    /** 预订订单未完成:待支付、待使用、退款中、商家预订 */
+    private static final List<Integer> PENDING_RESERVATION_ORDER_STATUSES = Arrays.asList(0, 1, 6, 8);
+
+    private final StoreOrderMapper storeOrderMapper;
+
+    private final UserReservationOrderMapper userReservationOrderMapper;
+
     /**
      * 设定初始化默认密码
      */
@@ -979,25 +989,47 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         if (storeUser != null) {
             storeMap.put("status", storeUser.getStatus().toString());
             if (null != storeUser.getStoreId()) {
-                StoreInfo storeInfo = storeInfoMapper.selectById(storeUser.getStoreId());
-                //vaule为0代表有商铺未注销
+                // value为0代表有商铺未注销
                 storeMap.put("accountStore", "0");
+                fillPendingOrderVerification(storeMap, storeUser.getStoreId());
             } else {
-                //vaule为1代表绑定店铺已注销
+                // value为1代表绑定店铺已注销
                 storeMap.put("accountStore", "1");
+                storeMap.put("accountDiningOrder", "1");
+                storeMap.put("accountReservationOrder", "1");
             }
             //钱包功能暂未完成此效验默认状态都是1通过
             if (storeUser.getMoney() != null && storeUser.getMoney() > 0) {
-                //vaule为0代表有未体现的现金
+                // value为0代表有未体现的现金
                 storeMap.put("accountMoney", "0");
             } else {
-                //vaule为1代表没有未体现的现金
+                // value为1代表没有未体现的现金
                 storeMap.put("accountMoney", "1");
             }
         }
         return storeMap;
     }
 
+    /**
+     * 注销校验:店铺是否存在未结束的点餐/预订订单。
+     * value 为 0 表示存在未完成订单,1 表示通过。
+     */
+    private void fillPendingOrderVerification(Map<String, String> storeMap, Integer storeId) {
+        long pendingDiningCount = storeOrderMapper.selectCount(new LambdaQueryWrapper<StoreOrder>()
+                .eq(StoreOrder::getStoreId, storeId)
+                .in(StoreOrder::getOrderStatus, PENDING_DINING_ORDER_STATUSES)
+                .eq(StoreOrder::getDeleteFlag, 0));
+        storeMap.put("accountDiningOrder", pendingDiningCount > 0 ? "0" : "1");
+        storeMap.put("accountDiningOrderCount", String.valueOf(pendingDiningCount));
+
+        long pendingReservationCount = userReservationOrderMapper.selectCount(new LambdaQueryWrapper<UserReservationOrder>()
+                .eq(UserReservationOrder::getStoreId, storeId)
+                .in(UserReservationOrder::getOrderStatus, PENDING_RESERVATION_ORDER_STATUSES)
+                .eq(UserReservationOrder::getDeleteFlag, 0));
+        storeMap.put("accountReservationOrder", pendingReservationCount > 0 ? "0" : "1");
+        storeMap.put("accountReservationOrderCount", String.valueOf(pendingReservationCount));
+    }
+
 
     /**
      * @param phone