Bladeren bron

门店基础信息 店铺注销 店铺撤销注销

qxy 1 week geleden
bovenliggende
commit
ad1111f0c1

+ 4 - 0
alien-entity/src/main/java/shop/alien/entity/store/StoreInfo.java

@@ -172,4 +172,8 @@ public class StoreInfo {
     @ApiModelProperty(value = "原因")
     @TableField("reason")
     private String reason;
+
+    @ApiModelProperty(value = "注销code")
+    @TableField("logout_code")
+    private String logoutCode;
 }

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreInfoVo.java

@@ -166,4 +166,7 @@ public class StoreInfoVo extends StoreInfo {
 
     @ApiModelProperty(value = "是否营业中(0否1是)")
     private Integer yyFlag;
+
+    @ApiModelProperty(value = "验证码")
+    private String verificationCode;
 }

+ 7 - 20
alien-store/src/main/java/shop/alien/store/controller/StoreInfoController.java

@@ -59,14 +59,6 @@ public class StoreInfoController {
     public R saveOrUpdate(@RequestBody StoreInfo storeInfo) {
         log.info("StoreInfoController.saveOrUpdate?storeInfo={}", storeInfo);
         return R.data(storeInfoService.saveOrUpdateStoreInfo(storeInfo));
-//        Integer id = storeInfo.getId();
-//        if (storeInfoService.saveOrUpdate(storeInfo)) {
-//            if (null != id) {
-//                return R.success("修改成功");
-//            }
-//            return R.success("新增成功");
-//        }
-//        return R.fail("失败");
     }
 
     @ApiOperation("web端新增门店")
@@ -405,32 +397,27 @@ public class StoreInfoController {
     @ApiOperation(value = "注销店铺")
     @ApiOperationSupport(order = 14)
     @PostMapping("/logoutStore")
-    public R logoutStore(@RequestBody StoreInfo storeInfo) {
-        log.info("StoreInfoController.logoutStore?id={},reason={}", storeInfo.getId(), storeInfo.getLogoutReason());
+    public R logoutStore(@RequestBody StoreInfoVo storeInfo) {
+        log.info("StoreInfoController.logoutStore?storeInfo={}", storeInfo);
         try {
-            if (storeInfoService.logoutStore(storeInfo.getId(), storeInfo.getLogoutReason())) {
-                return R.success("注销成功");
-            }
-
-            return R.fail("注销失败");
+            storeInfoService.logoutStore(storeInfo);
         } catch (Exception e) {
             return R.fail(e.getMessage());
         }
+        return R.success("注销成功");
     }
 
     @ApiOperation(value = "取消注销店铺")
     @ApiOperationSupport(order = 15)
     @PostMapping("/cancelLogoutStore")
-    public R cancelLogoutStore(@RequestBody StoreInfo storeInfo) {
+    public R cancelLogoutStore(@RequestBody StoreInfoVo  storeInfo) {
         log.info("StoreInfoController.cancelLogoutStore?id={}", storeInfo.getId());
         try {
-            if (storeInfoService.cancelLogoutStore(storeInfo.getId())) {
-                return R.success("取消注销成功");
-            }
-            return R.fail("取消注销失败");
+            storeInfoService.cancelLogoutStore(storeInfo);
         } catch (Exception e) {
             return R.fail(e.getMessage());
         }
+        return R.success("撤销注销成功");
     }
 
     /**

+ 4 - 5
alien-store/src/main/java/shop/alien/store/service/StoreInfoService.java

@@ -187,19 +187,18 @@ public interface StoreInfoService extends IService<StoreInfo> {
     /**
      * 注销店铺
      *
-     * @param storeId 店铺ID
-     * @param reason  注销原因
+     * @param storeInfo 店铺Vo
      * @return boolean
      */
-    boolean logoutStore(Integer storeId, String reason);
+    void logoutStore(StoreInfoVo storeInfo);
 
     /**
      * 取消注销店铺
      *
-     * @param storeId 店铺ID
+     * @param storeInfo 店铺Vo
      * @return boolean
      */
-    boolean cancelLogoutStore(Integer storeId);
+    void cancelLogoutStore(StoreInfoVo storeInfo);
 
     /**
      * web-查询店铺信息根据门店电话

+ 72 - 26
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -40,6 +40,7 @@ import shop.alien.util.common.DistanceUtil;
 
 import java.io.IOException;
 import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
@@ -1375,37 +1376,82 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
     }
 
     @Override
-    public boolean logoutStore(Integer storeId, String reason) {
-        StoreInfo storeInfo = this.getById(storeId);
-        if (storeInfo == null) {
-            throw new RuntimeException("店铺不存在");
-        }
-        if (storeInfo.getLogoutFlag() == 1) {
-            throw new RuntimeException("店铺已经注销");
+    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);
+                }
+            }
+        }else{
+            throw new RuntimeException("验证码错误");
         }
-
-        storeInfo.setLogoutFlag(1);
-        storeInfo.setLogoutReason(reason);
-        storeInfo.setLogoutTime(new Date());
-
-        return this.updateById(storeInfo);
     }
 
     @Override
-    public boolean cancelLogoutStore(Integer storeId) {
-        StoreInfo storeInfo = this.getById(storeId);
-        if (storeInfo == null) {
-            throw new RuntimeException("店铺不存在");
-        }
-        if (storeInfo.getLogoutFlag() == 0) {
-            throw new RuntimeException("店铺未注销");
+    public void cancelLogoutStore(StoreInfoVo storeInfo) {
+        // 通过id获取当前商家账号信息
+        LambdaQueryWrapper<StoreInfo> storeUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        storeUserLambdaQueryWrapper.eq(StoreInfo::getId, storeInfo.getId());
+        StoreInfo storeIn = storeInfoMapper.selectOne(storeUserLambdaQueryWrapper);
+        // 修改注销标记为0
+        storeIn.setLogoutFlag(0);
+        // 注销状态变为可用
+        storeIn.setStoreStatus(0);
+        // 清空注销原因
+        storeIn.setLogoutReason(null);
+        // 清空注销code
+        storeIn.setLogoutCode(null);
+        // 清空注销申请时间
+        storeIn.setLogoutTime(null);
+        // 更新logout_flag状态为0
+        storeIn.setLogoutFlag(0);
+        int num = storeInfoMapper.updateById(storeIn);
+        if (num > 0) {
+            // 发送通知
+            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 text = "处理结果:已撤回注销申请" +
+                    "处理时间:" + storeDate +
+                    "当前账号状态已恢复正常. 您可以继续使用该店铺登录并享受各项服务, 所有店铺数据均已妥善保留." +
+                    "若您后续仍有注销需求, 可随时通过门店装修页面重新提交申请. 感谢您的理解与支持!";
+            lifeMessage.setContext(text);
+            lifeMessage.setTitle("撤销注销通知");
+            lifeMessage.setSenderId("system");
+            lifeMessage.setIsRead(0);
+            lifeMessage.setNoticeType(1);
+            lifeNoticeMapper.insert(lifeMessage);
         }
-
-        storeInfo.setLogoutFlag(0);
-        storeInfo.setLogoutReason(null);
-        storeInfo.setLogoutTime(null);
-
-        return this.updateById(storeInfo);
     }
 
     @Override