Browse Source

1.调整删除用户逻辑

qmj 1 day ago
parent
commit
3791c630af

+ 13 - 0
ruoyi-admin/src/main/java/com/ruoyi/app/user/InfoUserController.java

@@ -29,6 +29,7 @@ import com.ruoyi.system.mapper.InfoUserMapper;
 import com.ruoyi.system.mapper.PosOrderMapper;
 import com.ruoyi.system.mapper.PosStoreMapper;
 import com.ruoyi.system.service.IInfoUserService;
+import com.ruoyi.system.service.IPosOrderService;
 import com.ruoyi.system.service.IUserWalletService;
 import com.ruoyi.system.service.IVipUserService;
 import com.ruoyi.system.utils.Auth;
@@ -48,6 +49,7 @@ import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
@@ -76,6 +78,9 @@ public class InfoUserController extends BaseController {
     private IUserWalletService userWalletService;
     @Autowired
     private RedisCache redisCache;
+    @Autowired
+    private IPosOrderService posOrderService;
+
 
     @Anonymous
     @PostMapping("/testBathPush")
@@ -206,6 +211,14 @@ public class InfoUserController extends BaseController {
     public AjaxResult deleuser(@RequestHeader String token) {
         JwtUtil jwtUtil = new JwtUtil();
         String id = jwtUtil.getusid(token);
+        LambdaQueryWrapper<PosOrder> query=new LambdaQueryWrapper<>();
+        Long userId=Long.valueOf(id);
+        query.in(PosOrder::getState,0L,1L,2L,3L,4L,9L);
+        query.apply("(user_id="+userId+" or qs_id="+userId+" or sh_id="+userId+")");
+        boolean exist=posOrderService.exists(query);
+        if(exist){
+            throw new ServiceException("抱歉,您還有未完成的訂單,無法刪除帳號");
+        }
         return toAjax(infoUserService.deleteInfoUserByUserId(Long.valueOf(id)));
     }
 

+ 8 - 7
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InfoUserServiceImpl.java

@@ -13,7 +13,7 @@ import com.ruoyi.system.service.IInfoUserService;
 
 /**
  * 用户信息Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2023-06-25
  */
@@ -44,6 +44,7 @@ public class InfoUserServiceImpl extends ServiceImpl<BaseMapper<InfoUser>,InfoUs
         //查询数据库存不存在用户
         QueryWrapper<InfoUser> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("phone",phone);
+        queryWrapper.eq("del_flag", "0");
         return getOne(queryWrapper);
     }
     @Autowired
@@ -51,7 +52,7 @@ public class InfoUserServiceImpl extends ServiceImpl<BaseMapper<InfoUser>,InfoUs
 
     /**
      * 查询用户信息
-     * 
+     *
      * @param userId 用户信息主键
      * @return 用户信息
      */
@@ -63,7 +64,7 @@ public class InfoUserServiceImpl extends ServiceImpl<BaseMapper<InfoUser>,InfoUs
 
     /**
      * 查询用户信息列表
-     * 
+     *
      * @param infoUser 用户信息
      * @return 用户信息
      */
@@ -75,7 +76,7 @@ public class InfoUserServiceImpl extends ServiceImpl<BaseMapper<InfoUser>,InfoUs
 
     /**
      * 新增用户信息
-     * 
+     *
      * @param infoUser 用户信息
      * @return 结果
      */
@@ -87,7 +88,7 @@ public class InfoUserServiceImpl extends ServiceImpl<BaseMapper<InfoUser>,InfoUs
 
     /**
      * 修改用户信息
-     * 
+     *
      * @param infoUser 用户信息
      * @return 结果
      */
@@ -99,7 +100,7 @@ public class InfoUserServiceImpl extends ServiceImpl<BaseMapper<InfoUser>,InfoUs
 
     /**
      * 批量删除用户信息
-     * 
+     *
      * @param userIds 需要删除的用户信息主键
      * @return 结果
      */
@@ -111,7 +112,7 @@ public class InfoUserServiceImpl extends ServiceImpl<BaseMapper<InfoUser>,InfoUs
 
     /**
      * 删除用户信息信息
-     * 
+     *
      * @param userId 用户信息主键
      * @return 结果
      */