Ver Fonte

注册链接

Aslee há 2 anos atrás
pai
commit
0d49626b1e

+ 7 - 1
src/main/java/com/caimei/controller/wechat/RegisterApi.java

@@ -36,6 +36,12 @@ public class RegisterApi {
         String verifyCode = parseObject.getString("verifyCode");
         String password = parseObject.getString("password");
         Integer authUserId = parseObject.getInteger("authUserId");
+        Integer authId = parseObject.getInteger("authId");
+        // 注册类型:1密码注册,2验证码注册(默认密码,短信推送)
+        int registerType = 1;
+        if (null != authId && StringUtils.isEmpty(password)) {
+            registerType = 2;
+        }
         if (StringUtils.isEmpty(mobile)) {
             return ResponseJson.error("手机号不能为空", null);
         }
@@ -48,7 +54,7 @@ public class RegisterApi {
         if (null == authUserId) {
             return ResponseJson.error("供应商用户id不能为空", null);
         }
-        return registerService.simpleRegister(mobile, verifyCode, password, authUserId, null);
+        return registerService.simpleRegister(mobile, verifyCode, password, authUserId, null, registerType);
     }
 
     @ApiOperation("全部注册")

+ 5 - 0
src/main/java/com/caimei/model/vo/AuthVo.java

@@ -69,4 +69,9 @@ public class AuthVo {
      * 供应商审核时间
      */
     private Date shopAuditTime;
+
+    /**
+     * 机构下设备数量
+     */
+    private Integer productNum;
 }

+ 2 - 2
src/main/java/com/caimei/service/auth/impl/AuthClubServiceImpl.java

@@ -147,7 +147,8 @@ public class AuthClubServiceImpl implements AuthClubService {
                 return ResponseJson.error("该用户已存在,请勿重复添加");
             }
             clubUser.setAddTime(new Date());
-            clubUser.setPassword("rzt123456");
+            String md5Password = Md5Util.md5("rzt123456");
+            clubUser.setPassword(md5Password);
             clubUser.setStatus(1);
             clubMapper.insertClubUser(clubUser);
             String content = "您认证通登录密码为:rzt123456";
@@ -157,7 +158,6 @@ public class AuthClubServiceImpl implements AuthClubService {
                 return ResponseJson.error("发送失败,请确认手机号无误");
             } else {
                 log.info("供应商添加机构用户-密码发送成功,手机号:" + mobile);
-
             }
         } else {
             clubUser.setId(clubUserId);

+ 1 - 1
src/main/java/com/caimei/service/wechat/RegisterService.java

@@ -14,7 +14,7 @@ public interface RegisterService {
     /**
      * 普通注册
      */
-    ResponseJson<WxClubUserVo> simpleRegister(String mobile, String verifyCode, String password, Integer authUserId, Integer authId);
+    ResponseJson<WxClubUserVo> simpleRegister(String mobile, String verifyCode, String password, Integer authUserId, Integer authId, Integer registerType);
 
     /**
      * 全部注册

+ 17 - 2
src/main/java/com/caimei/service/wechat/impl/RegisterServiceImpl.java

@@ -14,6 +14,7 @@ import com.caimei.service.auth.AuthProductService;
 import com.caimei.service.auth.AuthService;
 import com.caimei.service.wechat.RegisterService;
 import com.caimei.utils.Md5Util;
+import com.caimei.utils.SmsUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
@@ -47,7 +48,7 @@ public class RegisterServiceImpl implements RegisterService {
     private AuthProductService authProductService;
 
     @Override
-    public ResponseJson<WxClubUserVo> simpleRegister(String mobile, String verifyCode, String password, Integer authUserId, Integer authId) {
+    public ResponseJson<WxClubUserVo> simpleRegister(String mobile, String verifyCode, String password, Integer authUserId, Integer authId, Integer registerType) {
         // 校验手机号
         WxClubUserVo clubUserVo = clubMapper.getWxClubUser(mobile, null, authUserId, null, null);
         if (null != clubUserVo) {
@@ -68,6 +69,10 @@ public class RegisterServiceImpl implements RegisterService {
         if (!verifyCode.equals(redisVerifyCode)) {
             return ResponseJson.error("验证码错误,请重新输入", null);
         }
+        if (2 == registerType) {
+            // 验证码注册,默认密码
+            password = "rzt123456";
+        }
         String md5Password = Md5Util.md5(password);
         /*
          * 构建机构用户数据
@@ -90,6 +95,16 @@ public class RegisterServiceImpl implements RegisterService {
         clubUser.setAddTime(new Date());
         clubMapper.insertClubUser(clubUser);
         clubUserVo = clubMapper.getWxClubUser(mobile, null, authUserId, null, null);
+        if (2 == registerType) {
+            // 验证码注册,推送默认密码短信
+            String content = "您认证通登录密码为:rzt123456";
+            Boolean sendSms = SmsUtils.sendSms(11, mobile, content);
+            if (!sendSms) {
+                log.info("机构用户验证码注册-密码发送失败,手机号:" + mobile);
+            } else {
+                log.info("机构用户验证码注册-密码发送成功,手机号:" + mobile);
+            }
+        }
         return ResponseJson.success(clubUserVo);
     }
 
@@ -104,7 +119,7 @@ public class RegisterServiceImpl implements RegisterService {
             String mobile = (String) clubUserMap.get("mobile");
             String verifyCode = (String) clubUserMap.get("verifyCode");
             String password = (String) clubUserMap.get("password");
-            ResponseJson<WxClubUserVo> result = simpleRegister(mobile, verifyCode, password, authUserId, authId);
+            ResponseJson<WxClubUserVo> result = simpleRegister(mobile, verifyCode, password, authUserId, authId, 1);
             int code = result.getCode();
             if (0 != code) {
                 return result;

+ 22 - 19
src/main/java/com/caimei/utils/SmsUtils.java

@@ -37,27 +37,30 @@ public class SmsUtils {
 
     public static Boolean sendSms(int martId, String mobile, String content) {
         try {
-            if (!"prod".equals(active)) {
-                return true;
-            }
-            if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
-                String regex = "^(1[3-9]\\d{9}$)";
-                Pattern pattern = Pattern.compile(regex);
-                Matcher matcher = pattern.matcher(mobile);
-                if (matcher.matches()) {
-                    Map<String, Object> map = new HashMap<>(2);
-                    map.put("content", content);
-                    map.put("mobile", mobile);
-                    String url = core + "/tools/sms/send";
-                    String result = HttpRequest.sendPost(url, map);
-                    JSONObject parseObject = JSONObject.parseObject(result);
-                    Integer code = parseObject.getInteger("code");
-                    if (code != 0) {
-                        log.info("短信发送失败,手机号>>>>" + mobile);
-                    } else {
-                        return true;
+            List<String> passList = new ArrayList<>();
+            passList.add("15113936829");
+            if ("prod".equals(active) || passList.contains(mobile)) {
+                if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
+                    String regex = "^(1[3-9]\\d{9}$)";
+                    Pattern pattern = Pattern.compile(regex);
+                    Matcher matcher = pattern.matcher(mobile);
+                    if (matcher.matches()) {
+                        Map<String, Object> map = new HashMap<>(2);
+                        map.put("content", content);
+                        map.put("mobile", mobile);
+                        String url = core + "/tools/sms/send";
+                        String result = HttpRequest.sendPost(url, map);
+                        JSONObject parseObject = JSONObject.parseObject(result);
+                        Integer code = parseObject.getInteger("code");
+                        if (code != 0) {
+                            log.info("短信发送失败,手机号>>>>" + mobile);
+                        } else {
+                            return true;
+                        }
                     }
                 }
+            } else {
+                return true;
             }
         } catch (Exception e) {
             log.error("短信推送异常", e);

+ 4 - 1
src/main/resources/mapper/AuthMapper.xml

@@ -102,7 +102,8 @@
                a.sendStatus, au1.name as shopAuditBy,a.shopAuditTime,
             ifnull(ap.waitAuditNum,0) as waitAuditNum,
             ifnull(bp.waitAuditNum,0) as shopWaitAuditNum,
-            if(ifnull(ap.waitAuditNum,0)>0,0,1) as lowerAuditStatus
+            if(ifnull(ap.waitAuditNum,0)>0,0,1) as lowerAuditStatus,
+            ifnull(cp.productNum,0) as productNum
         from cm_brand_auth a
         left join cm_brand_auth_user cu on a.createBy = cu.authUserId
         left join cm_brand_club_user cbcu1 on a.createBy = cbcu1.id
@@ -113,6 +114,8 @@
             authId) ap on a.id = ap.authId
         left join (select authId,count(*) as waitAuditNum from cm_brand_auth_product where shopAuditStatus = 2 group by
             authId) bp on a.id = bp.authId
+        left join (select authId,count(*) as productNum from cm_brand_auth_product group by
+            authId) cp on a.id = cp.authId
         where a.authUserId = #{authUserId} and a.delFlag = 0
         <if test="authParty != null and authParty != ''">
             and a.authParty like CONCAT('%',#{authParty},'%')