Browse Source

平台端账号管理代码修正

wuchen 3 months ago
parent
commit
408b24bac0

+ 1 - 0
alien-entity/src/main/java/shop/alien/entity/store/StoreUser.java

@@ -69,6 +69,7 @@ public class StoreUser extends Model<StoreUser> {
     @TableField("status")
     @TableField("status")
     private Integer status;
     private Integer status;
 
 
+
     @ApiModelProperty(value = "密码状态, 0:初始密码, 1:已修改, 2:手机号已验证")
     @ApiModelProperty(value = "密码状态, 0:初始密码, 1:已修改, 2:手机号已验证")
     @TableField("pass_type")
     @TableField("pass_type")
     private Integer passType;
     private Integer passType;

+ 16 - 1
alien-entity/src/main/java/shop/alien/entity/store/excelVo/StoreUserExcelVo.java

@@ -12,7 +12,7 @@ import shop.alien.entity.store.excelVo.util.ExcelHeader;
  */
  */
 @Data
 @Data
 @JsonInclude
 @JsonInclude
-@ApiModel(value = "StoreUser表Excel导出对象", description = "商家端账号信息")
+@ApiModel(value = "StoreUser表Excel导出对象", description = "商家端账号信息")
 public class StoreUserExcelVo {
 public class StoreUserExcelVo {
 
 
     @ExcelHeader("序号")
     @ExcelHeader("序号")
@@ -23,6 +23,11 @@ public class StoreUserExcelVo {
     @ExcelHeader(value = "账号ID")
     @ExcelHeader(value = "账号ID")
     private Integer id;
     private Integer id;
 
 
+//    @ApiModelProperty(value = "主账号手机号")
+//    @ExcelHeader(value = "主账号手机号码")
+//    @JsonInclude(JsonInclude.Include.NON_NULL)
+//    private String parentAccountPhone;
+
     @ApiModelProperty(value = "手机号码")
     @ApiModelProperty(value = "手机号码")
     @ExcelHeader(value = "手机号码")
     @ExcelHeader(value = "手机号码")
     private String phone;
     private String phone;
@@ -31,7 +36,17 @@ public class StoreUserExcelVo {
     @ExcelHeader(value = "创建时间")
     @ExcelHeader(value = "创建时间")
     private String createdTime;
     private String createdTime;
 
 
+    @ApiModelProperty(value = "子账号数量")
+    @ExcelHeader(value = "子账号数量")
+    private Integer childAccountCount;
+
     @ApiModelProperty(value = "状态")
     @ApiModelProperty(value = "状态")
     @ExcelHeader(value = "状态")
     @ExcelHeader(value = "状态")
     private String status;
     private String status;
+
+
+
+
+
+
 }
 }

+ 37 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreSubExcelVo.java

@@ -0,0 +1,37 @@
+package shop.alien.entity.store.vo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import shop.alien.entity.store.excelVo.util.ExcelHeader;
+
+@Data
+@JsonInclude
+@ApiModel(value = "StoreUser表Excel导出对象", description = "商家端子账号信息")
+public class StoreSubExcelVo {
+
+    @ExcelHeader("序号")
+    @ApiModelProperty(value = "序号")
+    private Integer serialNumber;
+
+    @ApiModelProperty(value = "主键")
+    @ExcelHeader(value = "账号ID")
+    private Integer id;
+
+    @ApiModelProperty(value = "主账号手机号")
+    @ExcelHeader(value = "主账号手机号码")
+    private String parentAccountPhone;
+
+    @ApiModelProperty(value = "手机号码")
+    @ExcelHeader(value = "手机号码")
+    private String phone;
+
+    @ApiModelProperty(value = "创建时间")
+    @ExcelHeader(value = "创建时间")
+    private String createdTime;
+
+    @ApiModelProperty(value = "状态")
+    @ExcelHeader(value = "状态")
+    private String status;
+}

+ 16 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreUserVo.java

@@ -7,6 +7,8 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.EqualsAndHashCode;
 import shop.alien.entity.store.StoreUser;
 import shop.alien.entity.store.StoreUser;
 
 
+import java.util.List;
+
 /**
 /**
  * 二期-门店用户扩展
  * 二期-门店用户扩展
  *
  *
@@ -18,6 +20,8 @@ import shop.alien.entity.store.StoreUser;
 @JsonInclude
 @JsonInclude
 @ApiModel(value = "StoreUserVo对象", description = "门店用户扩展")
 @ApiModel(value = "StoreUserVo对象", description = "门店用户扩展")
 public class StoreUserVo extends StoreUser {
 public class StoreUserVo extends StoreUser {
+     @ApiModelProperty(value = "父账号Id")
+    private Integer parentAccountId;
 
 
     @ApiModelProperty(value = "登录Token")
     @ApiModelProperty(value = "登录Token")
     private String token;
     private String token;
@@ -42,4 +46,16 @@ public class StoreUserVo extends StoreUser {
 
 
     @ApiModelProperty(value = "是否提供餐食")
     @ApiModelProperty(value = "是否提供餐食")
     private Integer mealsFlag;
     private Integer mealsFlag;
+
+    @ApiModelProperty(value = "子账号列表")
+    private List<StoreUser> childAccounts;
+
+    @ApiModelProperty(value = "主账号姓名")
+    private String parentAccountName;
+
+    @ApiModelProperty(value = "主账号手机号")
+    private String parentAccountPhone;
+
+
+
 }
 }

+ 16 - 9
alien-store/src/main/java/shop/alien/store/controller/StoreUserController.java

@@ -208,15 +208,22 @@ public class StoreUserController {
     }
     }
 
 
     /**
     /**
-     * web端查询用户列表
+     * web端查询用户列表(支持主账号和子账号查询)
      */
      */
-    @ApiOperation("web端查询用户列表")
+    @ApiOperation("web端查询用户列表(支持主账号和子账号查询)")
     @ApiOperationSupport(order = 7)
     @ApiOperationSupport(order = 7)
     @GetMapping("/getStoreUserList")
     @GetMapping("/getStoreUserList")
-    @ApiImplicitParams({@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), @ApiImplicitParam(name = "pageSize", value = "页容", dataType = "int", paramType = "query", required = true), @ApiImplicitParam(name = "storeName", value = "门店名称", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "storeContact", value = "门店联系人", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "storePhone", value = "门店电话", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "storeType", value = "门店类型", dataType = "String", paramType = "query")})
-    public R<IPage<StoreUserVo>> getStoreUserList(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int pageSize, @RequestParam(required = false) String id, @RequestParam(required = false) String phone, @RequestParam(required = false) Integer status) {
-        log.info("StoreInfoController.getStoreUserList?pageNum={},pageSize={},id={},phone={},status={}", pageNum, pageSize, id, phone, status);
-        R<IPage<StoreUserVo>> storeUserVoR = storeUserService.getStoreUserList(pageNum, pageSize, id, phone, status);
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = false),
+            @ApiImplicitParam(name = "pageSize", value = "页容", dataType = "int", paramType = "query", required = false),
+            @ApiImplicitParam(name = "id", value = "账号ID", dataType = "String", paramType = "query", required = false),
+            @ApiImplicitParam(name = "phone", value = "联系电话", dataType = "String", paramType = "query", required = false),
+            @ApiImplicitParam(name = "status", value = "状态", dataType = "int", paramType = "query", required = false),
+            @ApiImplicitParam(name = "accountType", value = "账号类型:1-主账号,2-子账号", dataType = "int", paramType = "query", required = true)
+    })
+    public R<IPage<StoreUserVo>> getStoreUserList(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int pageSize, @RequestParam(required = false) String id, @RequestParam(required = false) String phone, @RequestParam(required = false) Integer status, @RequestParam(required = true) Integer accountType) {
+        log.info("StoreUserController.getStoreUserList?pageNum={},pageSize={},id={},phone={},status={},accountType={}", pageNum, pageSize, id, phone, status, accountType);
+        R<IPage<StoreUserVo>> storeUserVoR = storeUserService.getStoreUserList(pageNum, pageSize, id, phone, status, accountType);
         return storeUserVoR;
         return storeUserVoR;
     }
     }
 
 
@@ -290,11 +297,11 @@ public class StoreUserController {
     @ApiOperation(value = "web端导出商家端账号相关信息")
     @ApiOperation(value = "web端导出商家端账号相关信息")
     @ApiOperationSupport(order = 6)
     @ApiOperationSupport(order = 6)
     @GetMapping("/exportExcel")
     @GetMapping("/exportExcel")
-    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "用户id", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "phone", value = "联系电话", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "status", value = "状态", dataType = "String", paramType = "query"),})
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "用户id", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "phone", value = "联系电话", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "status", value = "状态", dataType = "String", paramType = "query"),@ApiImplicitParam(name = "accountType", value = "账号类型:1-主账号,2-子账号", dataType = "int", paramType = "query")})
     @ResponseBody
     @ResponseBody
-    public R exportExcel(@RequestParam(value = "id", required = false) String id, @RequestParam(value = "phone", required = false) String phone, @RequestParam(value = "status", required = false) String status) throws IOException {
+    public R exportExcel(@RequestParam(value = "id", required = false) String id, @RequestParam(value = "phone", required = false) String phone, @RequestParam(value = "status", required = false) String status, @RequestParam(required = false) Integer accountType) throws IOException {
         log.info("StoreInfoController.exportExcel");
         log.info("StoreInfoController.exportExcel");
-        String excelPath = storeUserService.exportExcel(id, phone, status);
+        String excelPath = storeUserService.exportExcel(id, phone, status,accountType);
         return R.data(excelPath);
         return R.data(excelPath);
     }
     }
 
 

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

@@ -100,7 +100,8 @@ public interface StoreUserService extends IService<StoreUser> {
      *
      *
      * @return boolean
      * @return boolean
      */
      */
-    R<IPage<StoreUserVo>> getStoreUserList(int pageNum, int pageSize, String id, String phone, Integer status);
+    R<IPage<StoreUserVo>> getStoreUserList(int pageNum, int pageSize, String id, String phone, Integer status,Integer accountType);
+
 
 
     /**
     /**
      * web端编辑用户列表
      * web端编辑用户列表
@@ -134,7 +135,7 @@ public interface StoreUserService extends IService<StoreUser> {
     /**
     /**
      * web端导出商家端账号相关信息
      * web端导出商家端账号相关信息
      */
      */
-    String exportExcel(String id, String phone, String status) throws IOException;
+    String exportExcel(String id, String phone, String status, Integer accountType) throws IOException;
 
 
 
 
     /**
     /**
@@ -191,4 +192,9 @@ public interface StoreUserService extends IService<StoreUser> {
     List<String> getIds(String name, String phone);
     List<String> getIds(String name, String phone);
 
 
     R<Boolean> havePayPassword(String storeUserId, String password);
     R<Boolean> havePayPassword(String storeUserId, String password);
+
+    List<StoreUser> getSubAccountsByMainAccountId(Integer mainAccountId);
+
+
+    List<StoreUser> getChildAccountsByParentId(String Id);
 }
 }

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

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
 import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.netease.yidun.sdk.anticheat.v3.AnticheatCheckRequest;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.tuple.Triple;
 import org.apache.commons.lang3.tuple.Triple;
@@ -21,6 +22,7 @@ import shop.alien.entity.result.R;
 import shop.alien.entity.store.*;
 import shop.alien.entity.store.*;
 import shop.alien.entity.store.excelVo.StoreUserExcelVo;
 import shop.alien.entity.store.excelVo.StoreUserExcelVo;
 import shop.alien.entity.store.excelVo.util.ExcelGenerator;
 import shop.alien.entity.store.excelVo.util.ExcelGenerator;
+import shop.alien.entity.store.vo.StoreSubExcelVo;
 import shop.alien.entity.store.vo.StoreUserVo;
 import shop.alien.entity.store.vo.StoreUserVo;
 import shop.alien.entity.store.vo.WebSocketVo;
 import shop.alien.entity.store.vo.WebSocketVo;
 import shop.alien.mapper.*;
 import shop.alien.mapper.*;
@@ -44,6 +46,7 @@ import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * 二期-门店用户 服务实现类
  * 二期-门店用户 服务实现类
@@ -397,21 +400,86 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
     }
     }
 
 
     @Override
     @Override
-    public R<IPage<StoreUserVo>> getStoreUserList(int pageNum, int pageSize, String id, String phone, Integer status) {
+    public R<IPage<StoreUserVo>> getStoreUserList(int pageNum, int pageSize, String id, String phone, Integer status,Integer accountType) {
+
         IPage<StoreUser> page = new Page<>(pageNum, pageSize);
         IPage<StoreUser> page = new Page<>(pageNum, pageSize);
+        IPage<StoreUserVo> storeUserVoIPage = new Page<>();
+
+        // 查询子账号(accountType == 2)
+        if (accountType == 2) {
+            // 构建子账号查询条件
+            LambdaQueryWrapper<StoreUser> subAccountWrapper = new LambdaQueryWrapper<>();
+            subAccountWrapper.eq(StoreUser::getAccountType, 2) // 子账号类型
+                    .like(!StringUtils.isEmpty(id), StoreUser::getId, id)
+                    .and(StringUtils.isNotEmpty(phone), qw -> qw
+                            .like(StoreUser::getPhone, phone)  // 子账号手机号模糊匹配
+                            .or()
+                            .exists("SELECT 1 FROM store_user su WHERE su.id = " +
+                                    "store_user.sub_account_id AND su.phone LIKE CONCAT('%', '" + phone + "', '%')") // 主账号手机号模糊匹配
+                    )
+                    .eq(status != null, StoreUser::getStatus, status)
+                    .orderByDesc(StoreUser::getCreatedTime);
+            
+            IPage<StoreUser> subAccountsPage = storeUserMapper.selectPage(page, subAccountWrapper);
+            BeanUtils.copyProperties(subAccountsPage, storeUserVoIPage);
+            
+            List<StoreUserVo> resultRecords = new ArrayList<>();
+            for (StoreUser subAccount : subAccountsPage.getRecords()) {
+                StoreUserVo storeUserVo = new StoreUserVo();
+                BeanUtils.copyProperties(subAccount, storeUserVo);
+                
+                // 查询主账号信息(通过 subAccountId 关联)
+                if (subAccount.getSubAccountId() != null) {
+                    StoreUser mainAccount = storeUserMapper.selectById(subAccount.getSubAccountId());
+                    if (mainAccount != null) {
+                        // 设置主账号联系电话
+                        storeUserVo.setParentAccountPhone(mainAccount.getPhone());
+                        storeUserVo.setParentAccountId(mainAccount.getId());
+                        storeUserVo.setParentAccountName(mainAccount.getName());
+                    }
+                }
+                
+                // 不返回密码
+                storeUserVo.setPassword(null);
+                storeUserVo.setPayPassword(null);
+                
+                resultRecords.add(storeUserVo);
+            }
+            
+            storeUserVoIPage.setRecords(resultRecords);
+            return R.data(storeUserVoIPage);
+        }
+
+        // 查询主账号(accountType == 1)
         LambdaQueryWrapper<StoreUser> storeUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
         LambdaQueryWrapper<StoreUser> storeUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        storeUserLambdaQueryWrapper.like(!StringUtils.isEmpty(id), StoreUser::getId, id);
-        storeUserLambdaQueryWrapper.like(!StringUtils.isEmpty(phone), StoreUser::getPhone, phone);
-        storeUserLambdaQueryWrapper.eq(status != null, StoreUser::getStatus, status);
-        storeUserLambdaQueryWrapper.orderByDesc(StoreUser::getCreatedTime);
+        storeUserLambdaQueryWrapper.like(!StringUtils.isEmpty(id), StoreUser::getId, id)
+                .like(!StringUtils.isEmpty(phone), StoreUser::getPhone, phone)
+                .eq(status != null, StoreUser::getStatus, status)
+                .eq(StoreUser::getAccountType, accountType)
+                .orderByDesc(StoreUser::getCreatedTime);
+        
         IPage<StoreUser> storeUsers = storeUserMapper.selectPage(page, storeUserLambdaQueryWrapper);
         IPage<StoreUser> storeUsers = storeUserMapper.selectPage(page, storeUserLambdaQueryWrapper);
-        IPage<StoreUserVo> storeUserVoIPage = new Page<>();
         BeanUtils.copyProperties(storeUsers, storeUserVoIPage);
         BeanUtils.copyProperties(storeUsers, storeUserVoIPage);
+        
         for (StoreUser storeUser : storeUserVoIPage.getRecords()) {
         for (StoreUser storeUser : storeUserVoIPage.getRecords()) {
-            //不返回密码
+            // 不返回密码
             storeUser.setPassword(null);
             storeUser.setPassword(null);
             storeUser.setPayPassword(null);
             storeUser.setPayPassword(null);
+
+            // 如果是主账号,统计子账号数量
+            if (accountType == 1) {
+                List<StoreUser> childAccounts = getChildAccountsByParentId(String.valueOf(storeUser.getId()));
+                Integer childCount = childAccounts != null ? childAccounts.size() : 0;
+                storeUser.setChildAccountCount(childCount);
+                if (childAccounts != null && !childAccounts.isEmpty()) {
+                    List<String> childPhoneNumbers = childAccounts.stream()
+                            .map(StoreUser::getPhone)
+                            .collect(Collectors.toList());
+                    storeUser.setChildPhoneNumbers(childPhoneNumbers);
+                }
+            }
         }
         }
+
         return R.data(storeUserVoIPage);
         return R.data(storeUserVoIPage);
     }
     }
 
 
@@ -481,21 +549,26 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
     }
     }
 
 
     @Override
     @Override
-    public String exportExcel(String id, String phone, String status) throws IOException {
+    public String exportExcel(String id, String phone, String status, Integer accountType) throws IOException {
         // 定义格式化模式
         // 定义格式化模式
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-        // 先将 Date 转换为 Instant
+        if (accountType==1){
         List<StoreUser> storeUsers = storeUserMapper.selectList(
         List<StoreUser> storeUsers = storeUserMapper.selectList(
                 new LambdaQueryWrapper<StoreUser>()
                 new LambdaQueryWrapper<StoreUser>()
                         .like(StringUtils.isNotEmpty(id), StoreUser::getId, id)
                         .like(StringUtils.isNotEmpty(id), StoreUser::getId, id)
                         .like(StringUtils.isNotEmpty(phone), StoreUser::getPhone, phone)
                         .like(StringUtils.isNotEmpty(phone), StoreUser::getPhone, phone)
                         .eq(StringUtils.isNotEmpty(status), StoreUser::getStatus, status)
                         .eq(StringUtils.isNotEmpty(status), StoreUser::getStatus, status)
+                        .eq(StoreUser::getAccountType, 1)
+                        .orderByDesc(StoreUser::getCreatedTime)
         );
         );
+
         List<StoreUserExcelVo> storeUserExcelVoList = new ArrayList<>();
         List<StoreUserExcelVo> storeUserExcelVoList = new ArrayList<>();
         int serialNumber = 0;
         int serialNumber = 0;
         for (StoreUser storeUser : storeUsers) {
         for (StoreUser storeUser : storeUsers) {
             StoreUserExcelVo storeUserExcelVo = new StoreUserExcelVo();
             StoreUserExcelVo storeUserExcelVo = new StoreUserExcelVo();
             storeUserExcelVo.setSerialNumber(++serialNumber);
             storeUserExcelVo.setSerialNumber(++serialNumber);
+
+            Integer currentUserId = storeUser.getId();
             BeanUtils.copyProperties(storeUser, storeUserExcelVo);
             BeanUtils.copyProperties(storeUser, storeUserExcelVo);
             Instant instant = storeUser.getCreatedTime().toInstant();
             Instant instant = storeUser.getCreatedTime().toInstant();
             // 格式化时间
             // 格式化时间
@@ -503,13 +576,51 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
             storeUserExcelVo.setCreatedTime(formattedTime);
             storeUserExcelVo.setCreatedTime(formattedTime);
             //格式化状态
             //格式化状态
             storeUserExcelVo.setStatus(storeUser.getStatus() == 0 ? "启用" : "禁用");
             storeUserExcelVo.setStatus(storeUser.getStatus() == 0 ? "启用" : "禁用");
+            List<StoreUser> childAccounts = getChildAccountsByParentId(String.valueOf(currentUserId));
+            Integer childCount = childAccounts != null ? childAccounts.size() : 0;
+            storeUserExcelVo.setChildAccountCount(childCount);
             storeUserExcelVoList.add(storeUserExcelVo);
             storeUserExcelVoList.add(storeUserExcelVo);
         }
         }
         String fileName = UUID.randomUUID().toString().replace("-", "");
         String fileName = UUID.randomUUID().toString().replace("-", "");
         String filePath = ExcelGenerator.generateExcel(excelPath + excelGeneratePath + fileName + ".xlsx", storeUserExcelVoList, StoreUserExcelVo.class);
         String filePath = ExcelGenerator.generateExcel(excelPath + excelGeneratePath + fileName + ".xlsx", storeUserExcelVoList, StoreUserExcelVo.class);
         return aliOSSUtil.uploadFile(new File(filePath), "excel/" + fileName + ".xlsx");
         return aliOSSUtil.uploadFile(new File(filePath), "excel/" + fileName + ".xlsx");
+        }
+        List<StoreUser> storeUsers = storeUserMapper.selectList(
+                new LambdaQueryWrapper<StoreUser>()
+                        .like(StringUtils.isNotEmpty(id), StoreUser::getId, id)
+                        .like(StringUtils.isNotEmpty(phone), StoreUser::getPhone, phone)
+                        .eq(StringUtils.isNotEmpty(status), StoreUser::getStatus, status)
+                        .eq(StoreUser::getAccountType, 2)
+                        .orderByDesc(StoreUser::getCreatedTime)
+        );
+        List<StoreSubExcelVo> storeUserExcelVoList = new ArrayList<>();
+        int serialNumber = 0;
+        for (StoreUser subAccount : storeUsers) {
+            StoreSubExcelVo storeUserExcelVo = new StoreSubExcelVo();
+            storeUserExcelVo.setSerialNumber(++serialNumber);
+            BeanUtils.copyProperties(subAccount, storeUserExcelVo);
+            if (subAccount.getSubAccountId() != null){
+                StoreUser mainAccount = storeUserMapper.selectById(subAccount.getSubAccountId());
+                if (mainAccount != null){
+                    storeUserExcelVo.setId(mainAccount.getId());
+                    storeUserExcelVo.setParentAccountPhone(mainAccount.getPhone());
+                }
+            }
+
+            Instant instant = subAccount.getCreatedTime().toInstant();
+            // 格式化时间
+            String formattedTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter);
+            storeUserExcelVo.setCreatedTime(formattedTime);
+            //格式化状态
+            storeUserExcelVo.setStatus(subAccount.getStatus() == 0 ? "启用" : "禁用");
+            storeUserExcelVoList.add(storeUserExcelVo);
+        }
+        String fileName = UUID.randomUUID().toString().replace("-", "");
+        String filePath = ExcelGenerator.generateExcel(excelPath + excelGeneratePath + fileName + ".xlsx", storeUserExcelVoList, StoreSubExcelVo.class);
+        return aliOSSUtil.uploadFile(new File(filePath), "excel/" + fileName + ".xlsx");
     }
     }
 
 
+
     /**
     /**
      * 注册校验
      * 注册校验
      *
      *
@@ -794,4 +905,50 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
         return R.data(returnMap);
         return R.data(returnMap);
     }
     }
 
 
+    @Override
+    public List<StoreUser> getSubAccountsByMainAccountId(Integer mainAccountId) {
+        LambdaQueryWrapper<StoreUser> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(StoreUser::getAccountType, 2)  // 子账号类型
+                .eq(StoreUser::getSubAccountId, mainAccountId)  // 关联主账号ID
+                .eq(StoreUser::getDeleteFlag, 0)  // 未删除的账号
+                .orderByDesc(StoreUser::getCreatedTime);  // 按创建时间倒序
+
+        return storeUserMapper.selectList(queryWrapper);
+    }
+
+
+    @Override
+    public List<StoreUser> getChildAccountsByParentId(String Id) {
+        Integer parentId = safeParseInt(Id);
+        if (parentId == null) {
+            return Collections.emptyList();
+        }
+
+        LambdaQueryWrapper<StoreUser> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(StoreUser::getSubAccountId, Id)
+                .eq(StoreUser::getAccountType, 2)  // 子账号
+                .eq(StoreUser::getDeleteFlag, 0)
+                .orderByAsc(StoreUser::getCreatedTime);
+
+        List<StoreUser> result = this.list(wrapper);
+
+        // 确保返回非空集合
+        return result != null ? result : Collections.emptyList();
+
+    }
+
+    /**
+     * 安全解析字符串为整数
+     */
+    private Integer safeParseInt(String str) {
+        if (str == null || str.trim().isEmpty()) {
+            return null;
+        }
+        try {
+            return Integer.valueOf(str.trim());
+        } catch (NumberFormatException e) {
+            log.warn("无法解析字符串为整数: {}", str);
+            return null;
+        }
+    }
 }
 }