소스 검색

中台bug修复 返回值类型更新

wuchen 2 달 전
부모
커밋
6699ad953d

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

@@ -422,8 +422,11 @@ public class StoreUserController {
     @PostMapping("/deleteStoreAccountInfo")
     public R<String> deleteStoreAccountInfo(@RequestBody StoreUserVo storeUserVo) {
         log.info("StoreUserController.deleteStoreAccountInfo?phone={}, id={}", storeUserVo.getPhone(), storeUserVo.getSubAccountId());
-        boolean ok = storeUserService.deleteStoreAccountInfo(storeUserVo);
-        return ok ? R.success("删除成功") : R.fail("删除失败,请传子账号联系电话(phone)或用户不存在");
+        String errMsg = storeUserService.deleteStoreAccountInfo(storeUserVo);
+        if (errMsg == null || errMsg.isEmpty()) {
+            return R.success("删除成功");
+        }
+        return R.fail(errMsg);
     }
 
     /**

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

@@ -174,8 +174,9 @@ public interface StoreUserService extends IService<StoreUser> {
 
     /**
      * 手动删除商家账号及店铺 进行校验
+     * @return 成功返回 null;失败返回具体原因:当前账号下存在店铺 禁止删除 / 当前账号下存在子账号禁止删除 / 删除失败
      */
-    boolean deleteStoreAccountInfo(StoreUserVo storeUserVo);
+    String deleteStoreAccountInfo(StoreUserVo storeUserVo);
 
     /**
      * 获取主键集合

+ 7 - 9
alien-store/src/main/java/shop/alien/store/service/impl/StoreUserServiceImpl.java

@@ -831,7 +831,6 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
             vo.setSerialNumber(++serialNumber);
             vo.setParentAccountId(mainAccount != null ? mainAccount.getId() : null);
             vo.setParentAccountPhone(mainAccount != null ? mainAccount.getPhone() : null);
-            vo.setSubAccountId(subAccount.getId());
             vo.setPhone(subAccount.getPhone());
             vo.setCreatedTime(subAccount.getCreatedTime() != null ? subAccount.getCreatedTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter) : null);
             int rowStatus = (subAccount.getStatus() != null && subAccount.getStatus() == -1) ? -1
@@ -1075,7 +1074,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
      */
 
     @Override
-    public boolean deleteStoreAccountInfo(StoreUserVo storeUserVo) {
+    public String deleteStoreAccountInfo(StoreUserVo storeUserVo) {
         // 解析用户:优先用子账号联系方式 phone 查;未传 phone 时用 id/subAccountId 查 store_user,后端从库中拿到子账号联系方式(phone)
         StoreUser storeUser = null;
         if ((storeUserVo.getId() != null || storeUserVo.getSubAccountId() != null)) {
@@ -1088,7 +1087,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         }
         if (storeUserVo == null) {
             log.warn("deleteStoreAccountInfo 用户不存在或已删除,请传子账号联系电话(phone)或用户id");
-            return false;
+            return "删除失败";
         }
         // 通过 phone 再尝试解析用户(前端可能只传 phone)
         if (storeUser == null && storeUserVo.getPhone() != null) {
@@ -1097,7 +1096,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         }
         if (storeUser == null) {
             log.warn("deleteStoreAccountInfo 用户不存在或已删除,请传子账号联系电话(phone)或用户id");
-            return false;
+            return "删除失败";
         }
         Integer userId = storeUser.getId();
 
@@ -1105,14 +1104,14 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         if (storeUserVo.getAccountType() != null && storeUserVo.getAccountType() == 1) {
             if (storeUser.getStoreId() != null) {
                 log.error("该主账号下存在店铺,禁止删除");
-                return false;
+                return "当前账号下存在店铺 禁止删除";
             }
             Integer mainIdForCheck = storeUserVo.getId();
             if (mainIdForCheck != null) {
                 List<StoreUser> subAccounts = getSubAccountsByMainAccountId(mainIdForCheck);
                 if (subAccounts != null && !subAccounts.isEmpty()) {
                     log.error("该主账号下存在关联子账号,禁止删除");
-                    return false;
+                    return "当前账号下存在子账号禁止删除";
                 }
             }
         }
@@ -1121,7 +1120,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         Integer mainAccountId = storeUser.getSubAccountId() != null ? storeUser.getSubAccountId() : storeUserVo.getParentAccountId();
         if (mainAccountId == null) {
             log.warn("deleteStoreAccountInfo 无法确定主账号,请传 parentAccountId 或保证子账号 store_user.sub_account_id 有值");
-            return false;
+            return "删除失败";
         }
         // 查询主账号下的子账号数量(按 store_user 统计:account_type=2 且 sub_account_id=主账号id)
         List<StoreUser> subAccountsUnderMain = getSubAccountsByMainAccountId(mainAccountId);
@@ -1152,8 +1151,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         } else {
             log.info("主账号下子账号数不为1,仅逻辑删除 store_platform_user_role,不删 store_user: mainAccountId={}, subAccountCount={}", mainAccountId, subAccountCount);
         }
-        return true;
-
+        return "删除失败";
     }
 
     @Override