Forráskód Böngészése

店铺注销 撤回注销 注销前效验

qxy 1 napja
szülő
commit
c2b586f5bc

+ 43 - 45
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package shop.alien.store.service.impl;
 
+import cn.hutool.core.date.DateTime;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -108,6 +109,8 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
 
     private final LifeNoticeMapper lifeNoticeMapper;
 
+    private final LifeGroupBuyMainMapper lifeGroupBuyMainMapper;
+
     @Value("${spring.web.resources.excel-path}")
     private String excelPath;
 
@@ -196,7 +199,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
             storeMainInfoVo.setRenewContractStatus(0);
         }
 
-        if (storeMainInfoVo.getBusinessStatus() == -1) {
+        if (storeMainInfoVo.getStoreStatus() == -1) {
             LocalDateTime localDateTime = storeMainInfoVo.getLogoutTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
             LocalDateTime future = localDateTime.plusDays(7);
             LocalDateTime now = LocalDateTime.now();
@@ -1532,43 +1535,37 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
 
     @Override
     public void logoutStore(StoreInfoVo storeInfo) {
-        String key = "verification_" + storeInfo.getStorePhone();
-        String redisVerificationCode = baseRedisService.getString(key);
-        if (redisVerificationCode.equals(storeInfo.getVerificationCode())) {
-            // 通过id获取当前店铺信息
-            LambdaQueryWrapper<StoreInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-            lambdaQueryWrapper.eq(StoreInfo::getId, storeInfo.getId());
-            StoreInfo storeIn = storeInfoMapper.selectOne(lambdaQueryWrapper);
-            if (storeIn != null) {
-                // 添加注销原因
-                storeIn.setLogoutReason(storeIn.getLogoutReason());
-                // 添加注销code
-                storeIn.setLogoutCode(storeIn.getLogoutCode());
-                // 注销中状态
-                storeIn.setStoreStatus(-1);
-                // 添加注销申请时间
-                storeIn.setLogoutTime(new Date());
-                // 更新logout_flag状态为1
-                storeIn.setLogoutFlag(1);
-                int num = storeInfoMapper.updateById(storeIn);
-                if (num > 0) {
-                    // 发送通知
-                    LifeNotice lifeMessage = new LifeNotice();
-                    lifeMessage.setReceiverId("store_" + storeInfo.getStorePhone());
-                    String text = "您提交的店铺注销申请已成功提交, 系统将按流程进行处理. 注销申请提交后, 将进入7天的冷静期. 期间您可以随时在" +
-                            "[门店装修]-[操作]中撤回申请. 冷静期结束后, 系统将正式开始注销操作. 店铺内所有数据将被永久清除, 且无法恢复." +
-                            "如有疑问, 可联系客服咨询. 感谢您使用我们的服务.";
-                    lifeMessage.setContext(text);
-                    lifeMessage.setTitle("注销通知");
-                    lifeMessage.setSenderId("system");
-                    lifeMessage.setIsRead(0);
-                    lifeMessage.setNoticeType(1);
-                    lifeNoticeMapper.insert(lifeMessage);
+                // 通过id获取当前店铺信息
+                LambdaQueryWrapper<StoreInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+                lambdaQueryWrapper.eq(StoreInfo::getId, storeInfo.getId());
+                StoreInfo storeIn = storeInfoMapper.selectOne(lambdaQueryWrapper);
+                if (storeIn != null) {
+                    // 添加注销原因
+                    storeIn.setLogoutReason(storeInfo.getLogoutReason());
+                    // 添加注销code
+                    storeIn.setLogoutCode(storeInfo.getLogoutCode());
+                    // 注销中状态
+                    storeIn.setStoreStatus(-1);
+                    // 添加注销申请时间
+                    storeIn.setLogoutTime(new Date());
+                    // 更新logout_flag状态为1
+                    storeIn.setLogoutFlag(1);
+                    int num = storeInfoMapper.updateById(storeIn);
+                    if (num > 0) {
+                        // 发送通知
+                        LifeNotice lifeMessage = new LifeNotice();
+                        lifeMessage.setReceiverId("store_" + storeInfo.getStorePhone());
+                        String text = "您提交的店铺注销申请已成功提交, 系统将按流程进行处理. 注销申请提交后, 将进入7天的冷静期. 期间您可以随时在" +
+                                "[门店装修]-[操作]中撤回申请. 冷静期结束后, 系统将正式开始注销操作. 店铺内所有数据将被永久清除, 且无法恢复." +
+                                "如有疑问, 可联系客服咨询. 感谢您使用我们的服务.";
+                        lifeMessage.setContext(text);
+                        lifeMessage.setTitle("注销通知");
+                        lifeMessage.setSenderId("system");
+                        lifeMessage.setIsRead(0);
+                        lifeMessage.setNoticeType(1);
+                        lifeNoticeMapper.insert(lifeMessage);
+                    }
                 }
-            }
-        } else {
-            throw new RuntimeException("验证码错误");
-        }
     }
 
     @Override
@@ -1582,9 +1579,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         // 注销状态变为可用
         storeIn.setStoreStatus(0);
         // 清空注销原因
-        storeIn.setLogoutReason(null);
+        storeIn.setLogoutReason("");
         // 清空注销code
-        storeIn.setLogoutCode(null);
+        storeIn.setLogoutCode("");
         // 清空注销申请时间
         storeIn.setLogoutTime(null);
         int num = storeInfoMapper.updateById(storeIn);
@@ -1593,7 +1590,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
             LifeNotice lifeMessage = new LifeNotice();
             lifeMessage.setReceiverId("store_" + storeInfo.getStorePhone());
             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            String storeDate = simpleDateFormat.format(storeInfo.getCreatedTime());
+            String storeDate = simpleDateFormat.format(new DateTime());
             String text = "处理结果:已撤回注销申请" +
                     "处理时间:" + storeDate +
                     "当前账号状态已恢复正常. 您可以继续使用该店铺登录并享受各项服务, 所有店铺数据均已妥善保留." +
@@ -1686,7 +1683,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
     }
 
     @Override
-    public Map<String, String> storeInfoVerification(int id) {
+    public Map<String, String>  storeInfoVerification(int id) {
         Map<String, String> storeInfoMap = new HashMap<>();
         LambdaQueryWrapper<StoreInfo> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(StoreInfo::getId, id);
@@ -1696,9 +1693,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
             //钱包功能暂未完成此效验默认状态都是1通过
             StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, id));
             if (storeUser.getMoney() != null && storeUser.getMoney() > 0) {
-                storeInfoMap.put("storetMoneyStatus", "1");
+                storeInfoMap.put("storeMoneyStatus", "1");
             } else {
-                storeInfoMap.put("storetMoneyStatus", "1");
+                storeInfoMap.put("storeMoneyStatus", "1");
             }
             //判断店铺存在未完成订单 0:未通过 1:通过
             List<LifeUserOrder> lifeUserOrders = lifeUserOrderMapper.selectList(new LambdaQueryWrapper<LifeUserOrder>().in(LifeUserOrder::getStatus, 0, 3).eq(LifeUserOrder::getStoreId, id).eq(LifeUserOrder::getDeleteFlag, 0));
@@ -1708,9 +1705,10 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 storeInfoMap.put("storeOrderStatus", "1");
             }
             //判断店铺存在正在售卖的商品 0:未通过 1:通过
+            List<LifeGroupBuyMain> lifeGroupBuyMainList = lifeGroupBuyMainMapper.selectList(new LambdaQueryWrapper<LifeGroupBuyMain>().eq(LifeGroupBuyMain::getStoreId,id).eq(LifeGroupBuyMain::getStatus,5).eq(LifeGroupBuyMain::getDeleteFlag,0));
             List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectList(new LambdaQueryWrapper<LifeCoupon>().in(LifeCoupon::getStatus, 0, 1)
                     .and(qw -> qw.gt(LifeCoupon::getStockQty, 0).or().gt(LifeCoupon::getSingleQty, 0)).eq(LifeCoupon::getStoreId, id).eq(LifeCoupon::getDeleteFlag, 0));
-            if (!CollectionUtils.isEmpty(lifeCoupons)) {
+            if (!CollectionUtils.isEmpty(lifeCoupons) || !CollectionUtils.isEmpty(lifeGroupBuyMainList)) {
                 storeInfoMap.put("storeGoodsStatus", "0");
             } else {
                 storeInfoMap.put("storeGoodsStatus", "1");
@@ -1724,7 +1722,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         LambdaQueryWrapper<StoreInfo> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(StoreInfo::getId, id);
         StoreInfo storeInfo = storeInfoMapper.selectOne(queryWrapper);
-        if (storeInfo != null && storeInfo.getBusinessStatus() == -1) {
+        if (storeInfo != null && storeInfo.getStoreStatus() == -1) {
             storeInfoMapper.deleteById(id);
         }
     }

+ 34 - 29
alien-store/src/main/java/shop/alien/store/service/impl/StoreUserServiceImpl.java

@@ -1,5 +1,6 @@
 package shop.alien.store.service.impl;
 
+import cn.hutool.core.date.DateTime;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -653,35 +654,39 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         StoreUser storeUser = storeUserMapper.selectOne(storeUserLambdaQueryWrapper);
         String key = "verification_" + storeUser.getPhone();
         String redisVerificationCode = baseRedisService.getString(key);
-        if (redisVerificationCode.equals(storeUserVo.getVerificationCode())) {
-            if (storeUser != null) {
-                // 添加注销原因
-                storeUser.setLogoutReason(storeUserVo.getLogoutReason());
-                // 添加注销code
-                storeUser.setLogoutCode(storeUserVo.getLogoutCode());
-                // 注销中状态
-                storeUser.setStatus(-1);
-                // 添加注销申请时间
-                storeUser.setLogoutTime(new Date());
-                // 更新logout_flag状态为1
-                storeUser.setLogoutFlag(1);
-                int num = storeUserMapper.updateById(storeUser);
-                if (num > 0) {
-                    // 发送通知
-                    LifeNotice lifeMessage = new LifeNotice();
-                    lifeMessage.setReceiverId("store_" + storeUser.getPhone());
-                    String text = "您提交的账号注销申请已成功提交, 系统将按流程进行处理. 注销申请提交后, 将进入7天的冷静期. 期间您可以随时在" +
-                            "[账号信息]撤回申请. 冷静期结束后, 系统将正式开始注销操作. 账号内所有数据(包括但不限于个人信息、 资产等) 将被永久清除, 且无法恢复." +
-                            "如有疑问, 可联系【客服】咨询. 感谢您使用我们的服务.";
-                    lifeMessage.setContext(text);
-                    lifeMessage.setTitle("注销通知");
-                    lifeMessage.setSenderId("system");
-                    lifeMessage.setIsRead(0);
-                    lifeMessage.setNoticeType(1);
-                    lifeNoticeMapper.insert(lifeMessage);
+        if(redisVerificationCode!=null){
+            if (redisVerificationCode.equals(storeUserVo.getVerificationCode())) {
+                if (storeUser != null) {
+                    // 添加注销原因
+                    storeUser.setLogoutReason(storeUserVo.getLogoutReason());
+                    // 添加注销code
+                    storeUser.setLogoutCode(storeUserVo.getLogoutCode());
+                    // 注销中状态
+                    storeUser.setStatus(-1);
+                    // 添加注销申请时间
+                    storeUser.setLogoutTime(new Date());
+                    // 更新logout_flag状态为1
+                    storeUser.setLogoutFlag(1);
+                    int num = storeUserMapper.updateById(storeUser);
+                    if (num > 0) {
+                        // 发送通知
+                        LifeNotice lifeMessage = new LifeNotice();
+                        lifeMessage.setReceiverId("store_" + new DateTime());
+                        String text = "您提交的账号注销申请已成功提交, 系统将按流程进行处理. 注销申请提交后, 将进入7天的冷静期. 期间您可以随时在" +
+                                "[账号信息]撤回申请. 冷静期结束后, 系统将正式开始注销操作. 账号内所有数据(包括但不限于个人信息、 资产等) 将被永久清除, 且无法恢复." +
+                                "如有疑问, 可联系【客服】咨询. 感谢您使用我们的服务.";
+                        lifeMessage.setContext(text);
+                        lifeMessage.setTitle("注销通知");
+                        lifeMessage.setSenderId("system");
+                        lifeMessage.setIsRead(0);
+                        lifeMessage.setNoticeType(1);
+                        lifeNoticeMapper.insert(lifeMessage);
+                    }
                 }
+            } else {
+                throw new RuntimeException("验证码错误");
             }
-        } else {
+        }else{
             throw new RuntimeException("验证码错误");
         }
     }
@@ -697,9 +702,9 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         // 注销状态变为可用
         storeUser.setStatus(0);
         // 清空注销原因
-        storeUser.setLogoutReason(null);
+        storeUser.setLogoutReason("");
         // 清空注销code
-        storeUser.setLogoutCode(null);
+        storeUser.setLogoutCode("");
         // 清空注销申请时间
         storeUser.setLogoutTime(null);
         // 更新logout_flag状态为0