Explorar el Código

同步更新和调整

liuchengsen hace 1 mes
padre
commit
1cacaef0a4

+ 5 - 3
zhijiayun-user/src/main/java/com/xuekairui/user/controller/AdminUserController.java

@@ -41,17 +41,19 @@ public class AdminUserController {
     }
 
     /**
-     * 按手机号模糊 / 用户ID精确搜索用户(含入驻信息+会员等级)
+     * 搜索用户/入驻信息(含会员等级)
      * GET /api/admin/users/search?phone=138&page=1&size=20
      * GET /api/admin/users/search?userId=123456&page=1&size=20
+     * GET /api/admin/users/search?phone=138&noLicense=true(仅查未入驻用户)
      */
     @GetMapping("/search")
     public Result<IPage<AdminUserDetailResponse>> searchUsers(
             @RequestParam(defaultValue = "1") Integer page,
             @RequestParam(defaultValue = "20") Integer size,
             @RequestParam(required = false) String phone,
-            @RequestParam(required = false) Long userId) {
-        return Result.success(adminUserService.searchUsers(page, size, phone, userId));
+            @RequestParam(required = false) Long userId,
+            @RequestParam(required = false) Boolean noLicense) {
+        return Result.success(adminUserService.searchUsers(page, size, phone, userId, noLicense));
     }
 
     /**

+ 33 - 0
zhijiayun-user/src/main/java/com/xuekairui/user/dto/AdminUserDetailResponse.java

@@ -63,15 +63,48 @@ public class AdminUserDetailResponse {
     /** 终端类型:SINGLE/CHAIN/CLINIC */
     private String terminalType;
 
+    /** 省 */
+    private String province;
+
+    /** 市 */
+    private String city;
+
+    /** 区 */
+    private String district;
+
+    /** 店铺地址 */
+    private String storeAddress;
+
     /** 联系人 */
     private String contactPerson;
 
     /** 联系电话 */
     private String contactPhone;
 
+    /** 统一社会信用代码 */
+    private String creditCode;
+
+    /** 营业执照图片URL */
+    private String licenseImageUrl;
+
+    /** 药品经营许可证图片URL */
+    private String drugLicenseUrl;
+
+    /** 二类医疗器械备案图片URL */
+    private String medicalDeviceClass2Url;
+
+    /** 三类医疗器械许可证图片URL */
+    private String medicalDeviceClass3Url;
+
     /** 审核状态:NOT_SUBMITTED/PENDING/APPROVED/REJECTED */
     private String reviewStatus;
 
+    /** 驳回原因 */
+    private String rejectReason;
+
+    /** 备注 */
+    private String remark;
+
     /** 第三方同步状态:0-未同步 1-同步成功 2-同步失败(无入驻记录时为 null) */
     private Integer syncStatus;
 

+ 14 - 12
zhijiayun-user/src/main/java/com/xuekairui/user/mapper/UserMapper.java

@@ -16,28 +16,30 @@ import org.apache.ibatis.annotations.Select;
 public interface UserMapper extends BaseMapper<User> {
 
     /**
-     * 按手机号模糊 / 用户ID精确搜索用户,LEFT JOIN 入驻信息,返回聚合结果。
-     * 未提交入驻信息的用户,入驻相关字段为 null。
-     * phone 和 userId 至少传一个,同时传时 phone 优先。
-     *
-     * @param page   分页参数
-     * @param phone  手机号关键词(LIKE 模糊匹配,可选)
-     * @param userId 用户ID(精确匹配,可选)
-     * @return 分页聚合结果
+     * 以用户表为主,LEFT JOIN 入驻信息搜索。
+     * 未入驻用户的入驻字段为 null。
+     * noLicense=true 只返回没有入驻信息的用户。
+     * phone 和 userId 必须至少传一个,同时传时 phone 优先。
      */
     @Select("<script>" +
             "SELECT u.id AS userId, u.phone, u.nickname, u.wechat_nickname, u.status AS userStatus, " +
             "u.create_time, u.membership_level, u.membership_expire_at, " +
             "bl.id AS licenseId, bl.store_name, bl.terminal_type, " +
-            "bl.contact_person, bl.contact_phone, bl.review_status, bl.status AS syncStatus, bl.external_id " +
+            "bl.province, bl.city, bl.district, bl.store_address, " +
+            "bl.contact_person, bl.contact_phone, bl.credit_code, " +
+            "bl.license_image_url, bl.drug_license_url, " +
+            "bl.medical_device_class2_url, bl.medical_device_class3_url, " +
+            "bl.review_status, bl.reject_reason, bl.remark, bl.status AS syncStatus, bl.external_id " +
             "FROM t_user u LEFT JOIN t_business_license bl ON u.id = bl.user_id " +
             "<where>" +
-            "<if test='phone != null and phone != \"\"'>u.phone LIKE CONCAT('%', #{phone}, '%')</if>" +
-            "<if test='userId != null'>u.id = #{userId}</if>" +
+            "<if test='noLicense != null and noLicense == true'>bl.id IS NULL</if>" +
+            "<if test='phone != null and phone != \"\"'>AND u.phone LIKE CONCAT('%', #{phone}, '%')</if>" +
+            "<if test='userId != null'>AND u.id = #{userId}</if>" +
             "</where>" +
             "ORDER BY u.create_time DESC" +
             "</script>")
     IPage<AdminUserDetailResponse> selectUsersWithLicense(Page<?> page,
                                                           @Param("phone") String phone,
-                                                          @Param("userId") Long userId);
+                                                          @Param("userId") Long userId,
+                                                          @Param("noLicense") Boolean noLicense);
 }

+ 10 - 10
zhijiayun-user/src/main/java/com/xuekairui/user/service/AdminUserService.java

@@ -61,25 +61,25 @@ public class AdminUserService {
     }
 
     /**
-     * 按手机号模糊 / 用户ID精确搜索用户,关联入驻信息一起返回。
-     * phone 和 userId 至少传一个,同时传时 phone 优先。
-     *
-     * @param pageNum  页码
-     * @param pageSize 每页大小
-     * @param phone    手机号关键词(LIKE 模糊匹配,可选)
-     * @param userId   用户ID(精确匹配,可选)
-     * @return 分页聚合结果
+     * 搜索入驻信息(含用户信息+会员等级),以入驻信息为主表。
+     * noLicense=true 时查询没有入驻信息的用户(供新增入驻时搜索)。
+     * phone 和 userId 必须至少传一个,同时传时 phone 优先。
      */
-    public IPage<AdminUserDetailResponse> searchUsers(Integer pageNum, Integer pageSize, String phone, Long userId) {
+    public IPage<AdminUserDetailResponse> searchUsers(Integer pageNum, Integer pageSize,
+                                                       String phone, Long userId, Boolean noLicense) {
         boolean hasPhone = phone != null && !phone.isBlank();
         boolean hasUserId = userId != null;
         if (!hasPhone && !hasUserId) {
             throw new BusinessException(ErrorCode.PARAM_ERROR, "请输入手机号或用户ID");
         }
+        if (hasPhone && phone.trim().length() < 4) {
+            throw new BusinessException(ErrorCode.PARAM_ERROR, "手机号至少输入4位");
+        }
         // 同时传时 phone 优先,userId 置空避免 SQL 同时命中两个条件
         String effectivePhone = hasPhone ? phone.trim() : null;
         Long effectiveUserId = hasPhone ? null : userId;
-        return userMapper.selectUsersWithLicense(new Page<>(pageNum, pageSize), effectivePhone, effectiveUserId);
+        return userMapper.selectUsersWithLicense(new Page<>(pageNum, pageSize),
+                effectivePhone, effectiveUserId, noLicense);
     }
 
     /**