|
|
@@ -537,7 +537,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
StoreUser mainAccount = role.getStoreId() == null ? null : mainAccountMap.get(role.getStoreId());
|
|
|
StoreUserVo storeUserVo = new StoreUserVo();
|
|
|
BeanUtils.copyProperties(subAccount, storeUserVo);
|
|
|
- // 分页列表:账号ID、parentAccountId 均为主账号 id(与主账号联系电话对应),子账号 id 放入 subAccountId
|
|
|
+ // 分页:返回主账号id(id/parentAccountId)及主账号对应的子账号联系方式id(subAccountId),禁用/删除时用 subAccountId
|
|
|
Integer mainId = mainAccount != null ? mainAccount.getId() : subAccount.getSubAccountId();
|
|
|
storeUserVo.setId(mainId != null ? mainId : subAccount.getId());
|
|
|
storeUserVo.setSubAccountId(subAccount.getId());
|
|
|
@@ -631,8 +631,9 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * web端切换商家端用户状态(主账号底下有子账号时禁止禁用;子账号无限制)。
|
|
|
- * 若同一账号既是主账号又是子账号:禁用时只禁用子账号角色,主账号保持启用。
|
|
|
+ * web端切换商家端用户状态(禁用/启用)。
|
|
|
+ * 禁用逻辑:1)主账号:有关联子账号则禁止禁用,无关联子账号可禁用;2)子账号:可禁用;
|
|
|
+ * 若既是主账号也是子账号且本次为禁用:只禁用子账号角色(store_platform_user_role),不更新 store_user,主账号保持启用;子账号在列表按 status 展示为禁用。
|
|
|
*/
|
|
|
@Override
|
|
|
public R<StoreUserVo> switchingStates(StoreUserVo storeUserParam) {
|
|
|
@@ -662,7 +663,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
storePlatformUserRoleMapper.update(null, roleUpdateWrapper);
|
|
|
StoreUserVo vo = new StoreUserVo();
|
|
|
vo.setId(storeUser.getId());
|
|
|
- vo.setStatus(newStatus);
|
|
|
+ vo.setStatus(currentStatus);
|
|
|
vo.setSwitchStatus(newStatus == 0);
|
|
|
return R.data(vo);
|
|
|
}
|
|
|
@@ -673,7 +674,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
storePlatformUserRoleMapper.update(null, roleUpdateWrapper);
|
|
|
baseRedisService.delete("store_" + storeUser.getPhone());
|
|
|
LambdaUpdateWrapper<StoreUser> userUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- userUpdateWrapper.eq(StoreUser::getId, storeUser.getId()).set(StoreUser::getStatus, currentStatus);
|
|
|
+ userUpdateWrapper.eq(StoreUser::getId, storeUser.getId()).set(StoreUser::getStatus, newStatus);
|
|
|
storeUserMapper.update(null, userUpdateWrapper);
|
|
|
StoreUserVo vo = new StoreUserVo();
|
|
|
vo.setId(storeUser.getId());
|
|
|
@@ -683,23 +684,20 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
|
|
|
}
|
|
|
|
|
|
- // 本次为禁用
|
|
|
- if (newStatus == 0) {
|
|
|
- // 2 对于主账号:有关联子账号则禁止禁用,请先删除主账号下的子账号
|
|
|
- if (isMainAccount) {
|
|
|
- List<StoreUser> subAccounts = getSubAccountsByMainAccountId(storeUserParam.getId());
|
|
|
- if (subAccounts != null && !subAccounts.isEmpty()) {
|
|
|
- throw new RuntimeException("请先删除主账号下的子账号后再禁用");
|
|
|
- }
|
|
|
+ // 本次为禁用(newStatus==1):主账号有关联子账号则禁止禁用,无关联子账号可禁用
|
|
|
+ if (newStatus == 1 && isMainAccount) {
|
|
|
+ List<StoreUser> subAccounts = getSubAccountsByMainAccountId(storeUserParam.getId());
|
|
|
+ if (subAccounts != null && !subAccounts.isEmpty()) {
|
|
|
+ throw new RuntimeException("请先删除主账号下的子账号后再禁用");
|
|
|
}
|
|
|
}
|
|
|
// 启用/禁用:更新 store_user 的 status(禁用 0→1,启用 1→0),列表即时展示用返回的 vo
|
|
|
LambdaUpdateWrapper<StoreUser> userUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- userUpdateWrapper.eq(StoreUser::getId, storeUserParam.getId()).set(StoreUser::getStatus, newStatus);
|
|
|
+ userUpdateWrapper.eq(StoreUser::getId, storeUserParam.getId()).set(StoreUser::getStatus, currentStatus);
|
|
|
storeUserMapper.update(null, userUpdateWrapper);
|
|
|
StoreUserVo vo = new StoreUserVo();
|
|
|
vo.setId(storeUserParam.getId());
|
|
|
- vo.setStatus(newStatus);
|
|
|
+ vo.setStatus(currentStatus);
|
|
|
vo.setSwitchStatus(newStatus == 0);
|
|
|
return R.data(vo);
|
|
|
}
|
|
|
@@ -1074,11 +1072,9 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 删除门店
|
|
|
- *
|
|
|
- * @param storeUserVo
|
|
|
+ * 删除商家账号:主账号下有店铺或有关联子账号禁止删除;子账号则逻辑删除 store_platform_user_role,
|
|
|
+ * 若主账号下仅关联一个子账号则同时逻辑删除 store_platform_user_role 和 store_user,若多个子账号则仅逻辑删除 store_platform_user_role。
|
|
|
*/
|
|
|
-
|
|
|
@Override
|
|
|
public String deleteStoreAccountInfo(StoreUserVo storeUserVo) {
|
|
|
// 解析用户:优先用子账号联系方式 phone 查;未传 phone 时用 id/subAccountId 查 store_user,后端从库中拿到子账号联系方式(phone)
|
|
|
@@ -1157,7 +1153,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
} else {
|
|
|
log.info("主账号下子账号数不为1,仅逻辑删除 store_platform_user_role,不删 store_user: mainAccountId={}, subAccountCount={}", mainAccountId, subAccountCount);
|
|
|
}
|
|
|
- return "删除失败";
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|