Browse Source

中台代码修复

wuchen 2 months ago
parent
commit
d176922912

+ 2 - 11
alien-store/src/main/java/shop/alien/store/controller/StoreUserController.java

@@ -281,19 +281,10 @@ public class StoreUserController {
         return R.success("初始化成功");
     }
 
-    /**
-     * web端删除商家端用户
-     */
-    @ApiOperation("web端删除商家端用户")
-    @ApiOperationSupport(order = 7)
-    @DeleteMapping("/deleteStoreUser")
-    public R<StoreUserVo> deleteStoreUser(@RequestParam(value = "id") String id) {
-        log.info("StoreUserController.deleteStoreUser?id={}", id);
-        return storeUserService.deleteStoreUser(id);
-    }
+
 
     /**
-     * web端切换商家端用户状态(主账号有子账号时禁止禁用;子账号无限制;返回更新后状态供前端及时展示)
+     * web端切换商家端用户状态  (主账号有子账号时禁止禁用;子账号无限制;返回更新后状态供前端及时展示)
      */
     @ApiOperation("web端切换商家端用户状态(主账号有子账号时禁止禁用;返回更新后状态供前端及时展示)")
     @ApiOperationSupport(order = 7)

+ 4 - 2
alien-store/src/main/java/shop/alien/store/service/StoreUserService.java

@@ -117,8 +117,10 @@ public interface StoreUserService extends IService<StoreUser> {
      */
     void resetStoreUserPassword(StoreUser storeUser);
 
+
+
     /**
-     * web端切换商家端用户状态(主账号底下有子账号时禁止禁用;子账号无限制)
+     * web端切换商家端用户状态
      *
      * @return   更新后的用户信息(含最新 status),供前端及时展示
      */
@@ -126,7 +128,7 @@ public interface StoreUserService extends IService<StoreUser> {
 
 
     /**
-     * web端导出商家端主账号和子账号相关信息
+     * web端导出商家端账号相关信息
      */
     String exportExcel(String id, String phone, String status, Integer accountType) throws IOException;
 

+ 25 - 11
alien-store/src/main/java/shop/alien/store/service/impl/StoreUserServiceImpl.java

@@ -403,7 +403,6 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         return R.data(vo);
     }
 
-
     @Override
     public R<IPage<StoreUserVo>> getStoreUserList(int pageNum, int pageSize, String id, String phone, Integer status, Integer accountType, String mainAccountId, String mainAccountPhone) {
         IPage<StoreUser> page = new Page<>(pageNum, pageSize);
@@ -562,6 +561,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         return list == null ? Collections.emptyList() : list.stream().map(StorePlatformUserRole::getUserId).distinct().collect(Collectors.toList());
     }
 
+
     @Override
     public R<StoreUserVo> editStoreUser(StoreUser storeUser) {
         storeUserMapper.updateById(storeUser);
@@ -580,6 +580,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
     }
 
 
+
     /**
      * web端切换商家端用户状态(主账号底下有子账号时禁止禁用;子账号无限制)
      * @param storeUserParam
@@ -604,6 +605,20 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         }
         // 根据当前状态切另一个状态
         int newStatus = storeUser.getStatus() == 0 ? 1 : 0;
+        if(storeUser.getAccountType() != null && storeUser.getAccountType() == 1){
+            LambdaUpdateWrapper<StoreUser> queryWrapper = new LambdaUpdateWrapper<>();
+            queryWrapper.eq(StoreUser::getId, storeUser.getId())
+                    .set(StoreUser::getStatus, newStatus);
+            int updateCount = storeUserMapper.update(null, queryWrapper);
+            if (updateCount <= 0) {
+                throw new RuntimeException("更新失败");
+            }
+            StoreUserVo vo = new StoreUserVo();
+            vo.setId(storeUser.getId());
+            vo.setStatus(newStatus);
+            vo.setSwitchStatus(newStatus == 0);
+            return R.data(vo);
+        }
         LambdaUpdateWrapper<StoreUser> queryWrapper = new LambdaUpdateWrapper<>();
         queryWrapper.eq(StoreUser::getId, storeUser.getId())
                 .set(StoreUser::getStatus, newStatus);
@@ -611,6 +626,15 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         if (updateCount <= 0) {
             throw new RuntimeException("更新失败");
         }
+//        StoreUserVo vo = new StoreUserVo();
+//        vo.setId(storeUser.getId());
+//        vo.setStatus(newStatus);
+//        vo.setSwitchStatus(newStatus == 0);
+        // 子账号启用/禁用时同步更新 store_platform_user_role 的 status(0 启用,1 禁用)
+        LambdaUpdateWrapper<StorePlatformUserRole> roleUpdateWrapper = new LambdaUpdateWrapper<>();
+        roleUpdateWrapper.eq(StorePlatformUserRole::getUserId, storeUser.getId())
+                .set(StorePlatformUserRole::getStatus, newStatus);
+        storePlatformUserRoleMapper.update(null, roleUpdateWrapper);
         // 返回更新后的状态,供前端及时展示
         StoreUserVo vo = new StoreUserVo();
         vo.setId(storeUser.getId());
@@ -619,16 +643,6 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         return R.data(vo);
     }
 
-    /**
-     *  分页查询
-     * @param pageNum
-     * @param pageSize
-     * @param id
-     * @param phone
-     * @param status
-     * @param accountType
-     * @return
-     */
     @Override
     public String exportExcel(String id, String phone, String status, Integer accountType) throws IOException {
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");