Browse Source

增加注册接口

FengChaoYu 2 tuần trước cách đây
mục cha
commit
a755bc49be

+ 8 - 1
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/common/CommonController.java

@@ -77,7 +77,7 @@ public class CommonController {
 
     @GetMapping("/express/company")
     @ApiOperation(value = "所有物流公司")
-    public ResponseHelper<List<ExpressCompany>> companyList(
+    public ResponseHelper<List<ExpressCompany>> expressCompanyList(
     ) throws IOException, RemoteServiceException {
         List<ExpressCompany> expressCompanies = expressLogic.expressCompanyList();
         return ResponseHelper.success(expressCompanies);
@@ -224,4 +224,11 @@ public class CommonController {
         return ResponseHelper.success(list);
     }
 
+    @ApiNotAuth
+    @PostMapping("/company/list")
+    @ApiOperation(value = "商户列表")
+    public ResponseHelper<List<AdminCompanyWechat>> companyList() {
+        List<AdminCompanyWechat> region = commonLogic.companyList();
+        return ResponseHelper.success(region);
+    }
 }

+ 20 - 2
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/user/UserController.java

@@ -20,9 +20,11 @@ import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.validation.constraints.NotBlank;
 import java.math.BigDecimal;
 import java.util.List;
 
@@ -30,6 +32,7 @@ import java.util.List;
 @RestController
 @Api(value = "小程序用户", tags ={"小程序用户"} )
 @RequestMapping(value = "/user", produces = "application/json; charset=utf-8")
+@Validated
 public class UserController {
 
 
@@ -216,9 +219,10 @@ public class UserController {
     public ResponseHelper<UserWxBean> workerMobileLogin(
             @ApiParam(value = "手机号",required = true) @RequestParam String mobile,
             @ApiParam(value = "短信code",required = true) @RequestParam String messageCode,
-            @ApiParam(value = "经度,纬度") @RequestParam(required = false) String locate
+            @ApiParam(value = "经度,纬度") @RequestParam(required = false) String locate,
+            HttpServletRequest request
     ) throws Exception {
-        UserWxBean userWxBean = userLogic.workerMobileLogin(mobile, messageCode, locate);
+        UserWxBean userWxBean = userLogic.workerMobileLogin(mobile, messageCode, locate, request);
         userLogic.addVisit(userWxBean);
         return ResponseHelper.success(userWxBean);
     }
@@ -255,4 +259,18 @@ public class UserController {
         userLogic.leaveMessage(firstName, lastName, companyName, mobile, message);
         return ResponseHelper.success();
     }
+
+    @ApiNotAuth
+    @PostMapping("/register/user")
+    @ApiOperation(value = "注册")
+    public ResponseHelper registerUser(
+            @ApiParam(value = "商户id", required = true) @RequestParam @NotBlank(message = "商户不能为空") String companyWechatId,
+            @ApiParam(value = "姓", required = true) @RequestParam @NotBlank(message = "姓不能为空") String firstName,
+            @ApiParam(value = "名", required = true) @RequestParam @NotBlank(message = "名不能为空") String lastName,
+            @ApiParam(value = "联系电话", required = true) @RequestParam @NotBlank(message = "联系电话不能为空") String mobile,
+            @ApiParam(value = "电子邮箱", required = true) @RequestParam @NotBlank(message = "电子邮箱不能为空") String email
+    ) throws Exception {
+        userLogic.registerUser(companyWechatId, firstName, lastName, mobile, email);
+        return ResponseHelper.success();
+    }
 }

+ 4 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/common/CommonLogic.java

@@ -448,4 +448,8 @@ public class CommonLogic {
 
         return beanList;
     }
+
+    public List<AdminCompanyWechat> companyList() {
+        return adminCompanyWechatService.list();
+    }
 }

+ 42 - 3
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/user/UserLogic.java

@@ -293,6 +293,7 @@ public class UserLogic {
         List<UserWait> list = userWaitService.lambdaQuery()
                 .eq(UserWait::getMobile, mobile)
                 .eq(UserWait::getIsAdd, false)
+                .eq(UserWait::getExamineStatus, ExamineStatusEnum.OK.getKey())
                 .list();
         if (CollectionUtils.isEmpty(list)) {
             return;
@@ -314,6 +315,7 @@ public class UserLogic {
         userWaitService.lambdaUpdate()
                 .set(UserWait::getIsAdd, true)
                 .in(UserWait::getId, list.stream().map(UserWait::getId).collect(Collectors.toList()))
+                .eq(UserWait::getExamineStatus, ExamineStatusEnum.OK.getKey())
                 .update();
     }
 
@@ -739,7 +741,7 @@ public class UserLogic {
     }
 
     @Transactional
-    public UserWxBean workerMobileLogin(String mobile, String messageCode, String locate) throws Exception {
+    public UserWxBean workerMobileLogin(String mobile, String messageCode, String locate, HttpServletRequest request) throws Exception {
         Object validMessageCode = redisUtil.get(Constant.RedisPrefix.SMS + ":" + mobile);
         if (Objects.isNull(validMessageCode)) {
             throw new RemoteServiceException("短信验证码过期");
@@ -749,12 +751,12 @@ public class UserLogic {
             throw new RemoteServiceException("短信验证码错误");
         }
 
-        User user = this.initAppUser(mobile, locate);
+        User user = this.initAppUser(mobile, locate, request);
 
         return this.appUser(user);
     }
 
-    private User initAppUser(String mobile, String locate) throws Exception {
+    private User initAppUser(String mobile, String locate, HttpServletRequest request) throws Exception {
         String key = Constant.RedisPrefix.LOCK_AUTH + ":" + mobile;
         Lock obtain = redisLockRegistry.obtain(key);
         if (!obtain.tryLock(2, TimeUnit.SECONDS)) {
@@ -773,10 +775,15 @@ public class UserLogic {
                 userWait = userWaitService.lambdaQuery()
                         .eq(UserWait::getMobile, mobile)
                         .eq(UserWait::getUserType, UserTypeEnum.WORKER.getKey())
+                        .eq(UserWait::getExamineStatus, ExamineStatusEnum.OK.getKey())
                         .last("limit 1")
                         .one();
 
                 if (Objects.isNull(userWait)) {
+                    final String source = CommonUtils.getSource(request);
+                    if (StringUtils.isBlank(source) || source.equals("PC")) {
+                        throw new RemoteServiceException("账号密码错误!");
+                    }
                     // 如果初始化师傅信息表没有,就注册一个
                     user = new User();
                     user.setUserId(IdWorker.getIdStr())
@@ -791,6 +798,9 @@ public class UserLogic {
                     // 否则按初始化信息新注册
                     user = new User();
                     user.setUserId(userWait.getWorkerNumber())
+                            .setFirstName(userWait.getFirstName())
+                            .setLastName(userWait.getLastName())
+                            .setExamineStatus(userWait.getExamineStatus())
                             .setCreateTime(new Date())
                             .setMobile(mobile);
                 }
@@ -847,4 +857,33 @@ public class UserLogic {
                 .setCreateTime(DateUtil.date())
                 .insert();
     }
+
+    public void registerUser(String companyWechatId, String firstName, String lastName, String mobile, String email) {
+        final AdminCompanyWechat adminCompanyWechat = adminCompanyWechatService.getById(companyWechatId);
+        if (Objects.isNull(adminCompanyWechat)) {
+            throw new RemoteServiceException("商户异常");
+        }
+
+        final Integer count = userService.lambdaQuery()
+                .eq(User::getMobile, StringUtils.trim(mobile))
+                .count();
+
+        if (count > 0) {
+            throw new RemoteServiceException("信息已存在");
+        }
+
+
+        UserWait userWait = new UserWait();
+        userWait.setId(IdWorker.getIdStr())
+                .setUserType(UserTypeEnum.WORKER.getKey())
+                .setWorkerNumber(userWait.getId())
+                .setCompanyWechatId(companyWechatId)
+                .setCompanyWechatName(adminCompanyWechat.getCompanyName())
+                .setFirstName(firstName)
+                .setLastName(lastName)
+                .setMobile(StringUtils.trim(mobile))
+                .setEMail(StringUtils.trim(email))
+                .setExamineStatus(ExamineStatusEnum.WAIT.getKey())
+                .insert();
+    }
 }

+ 36 - 21
mall-server-api/src/main/java/com/gree/mall/manager/bean/listvo/workorder/UserWaitVO.java

@@ -1,7 +1,7 @@
 package com.gree.mall.manager.bean.listvo.workorder;
 
 import com.gree.mall.manager.annotation.ZfireField;
-import com.gree.mall.manager.enums.UserTypeEnum;
+import com.gree.mall.manager.enums.ExamineStatusEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -16,37 +16,46 @@ public class UserWaitVO {
     @ZfireField(hide = true)
     private String id;
 
-    @ApiModelProperty(value = "用户类型")
-    private UserTypeEnum userType;
+//    @ApiModelProperty(value = "用户类型")
+//    private UserTypeEnum userType;
 
     @ApiModelProperty(value = "手机号")
     private String mobile;
 
-    @ZfireField(hide = true)
-    @ApiModelProperty(value = "网点id")
-    private String websitId;
-
-    @ApiModelProperty(value = "网点名称")
-    private String websitName;
-
+//    @ZfireField(hide = true)
+//    @ApiModelProperty(value = "网点id")
+//    private String websitId;
+//
+//    @ApiModelProperty(value = "网点名称")
+//    private String websitName;
+//
     @ApiModelProperty(value = "师傅编号")
     private String workerNumber;
 
-    @ApiModelProperty(value = "名称")
-    private String name;
+    @ApiModelProperty(value = "")
+    private String firstName;
 
-    @ApiModelProperty(value = "身份证")
-    private String idcard;
+    @ApiModelProperty(value = "")
+    private String lastName;
 
-    @ApiModelProperty("银行卡")
-    private String bankAccount;
+    @ApiModelProperty(value = "电子邮箱")
+    private String eMail;
 
-//    @ZfireField(hide = true)
-//    @ApiModelProperty(value = "商户id")
-//    private String companyWechatId;
+//    @ApiModelProperty(value = "身份证")
+//    private String idcard;
 //
-//    @ApiModelProperty(value = "商户名称")
-//    private String companyWechatName;
+//    @ApiModelProperty("银行卡")
+//    private String bankAccount;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "商户id")
+    private String companyWechatId;
+
+    @ApiModelProperty(value = "商户名称")
+    private String companyWechatName;
+
+    @ApiModelProperty(value = "审核状态")
+    private ExamineStatusEnum examineStatus;
 
     @ApiModelProperty(value = "创建时间")
     private Date createTime;
@@ -54,5 +63,11 @@ public class UserWaitVO {
     @ApiModelProperty(value = "创建人")
     private String createBy;
 
+    @ApiModelProperty(value = "审核时间")
+    private Date examineTime;
+
+    @ApiModelProperty(value = "审核人")
+    private String examineBy;
+
 
 }

+ 11 - 0
mall-server-api/src/main/java/com/gree/mall/manager/controller/member/MemberController.java

@@ -170,6 +170,17 @@ public class MemberController {
         return ResponseHelper.success();
     }
 
+    @PostMapping("/wait2/examine")
+    @ApiOperation("注册师傅审核")
+    public ResponseHelper wait2Examine(
+            @ApiParam(value = "userId", required = true) @RequestParam String id,
+            @ApiParam(value = "OK=审核通过, FAIL=驳回", required = true) @RequestParam ExamineStatusEnum statusEnum,
+            @ApiParam(value = "备注", required = true) @RequestParam String remark
+    ) {
+        userLogic.wait2Examine(id, statusEnum, remark);
+        return ResponseHelper.success();
+    }
+
 
     @PostMapping("/worker/update")
     @ApiOperation("修改师傅资料")

+ 34 - 7
mall-server-api/src/main/java/com/gree/mall/manager/logic/user/UserLogic.java

@@ -200,21 +200,27 @@ public class UserLogic {
             String errPrefix = "第" + index + "行";
             List<Object> row = (List<Object>) o;
             CommonUtils.initList2(row, 10);
-            String name = (String) row.get(0);
-            String mobile = (String) row.get(1);
-            String bankAccount = (String) row.get(2);
+            String firstName = (String) row.get(0);
+            String lastName = (String) row.get(1);
+            String mobile = (String) row.get(2);
+            String email = (String) row.get(3);
 
-            if (StringUtils.isAnyBlank(name, mobile)) {
+            if (StringUtils.isAnyBlank(firstName, lastName, mobile, email)) {
                 throw new RemoteServiceException(errPrefix + "黄色区域为必填项");
             }
 
             UserWait userWait = new UserWait();
+            userWait.setId(IdWorker.getIdStr());
             userWait.setUserType(UserTypeEnum.WORKER.getKey());
             userWait.setMobile(mobile);
 
-            userWait.setName(name);
-            userWait.setBankAccount(bankAccount);
-            userWait.setWorkerNumber(IdWorker.getIdStr());
+            userWait.setFirstName(firstName);
+            userWait.setLastName(lastName);
+            userWait.setEMail(email);
+            userWait.setWorkerNumber(userWait.getId());
+            userWait.setExamineStatus(ExamineStatusEnum.OK.getKey());
+            userWait.setExamineBy(adminUser.getNickName());
+            userWait.setExamineTime(DateUtil.date());
             userWaits.add(userWait);
         }
         userWaitService.saveBatch(userWaits);
@@ -763,4 +769,25 @@ public class UserLogic {
                 .remove();
     }
 
+    @Transactional
+    public void wait2Examine(String id, ExamineStatusEnum statusEnum, String remark) {
+        final AdminUserCom adminUser = commonLogic.getAdminUser();
+        final UserWait userWait = userWaitService.getById(id);
+
+        if (Objects.isNull(userWait)) {
+            throw new RemoteServiceException("参数异常");
+        }
+
+        final Integer count = userService.lambdaQuery()
+                .eq(User::getMobile, StringUtils.trim(userWait.getMobile()))
+                .count();
+
+        if (count > 0) {
+            throw new RemoteServiceException("信息已存在");
+        }
+
+        userWait.setExamineRemark(remark)
+                .setExamineTime(DateUtil.date())
+                .setExamineStatus(statusEnum.getKey());
+    }
 }

+ 2 - 7
mall-server-api/src/main/resources/mapper/CommonMapper.xml

@@ -413,13 +413,8 @@
           ${ex.selected}
         FROM user_wait a
         ${ex.query}
-        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
-            AND (
-            a.websit_id IN
-            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-            )
+        <if test="ex.orderBy == null or ex.orderBy ==''">
+            ORDER BY a.create_time DESC
         </if>
         ${ex.orderBy}
     </select>

BIN
mall-server-api/src/main/resources/template/师傅资料初始化.xlsx → mall-server-api/src/main/resources/template/workerInfoInit.xlsx