Browse Source

Merge remote-tracking branch 'origin/developerD' into developerD

kaick 2 years ago
parent
commit
9cabcb6d21

+ 34 - 1
src/main/java/com/caimei365/user/controller/LoginApi.java

@@ -119,7 +119,16 @@ public class LoginApi {
         String unionId = loginPasswordDto.getUnionId();
         return sellerService.passwordLogin(mobile, password, unionId);
     }
-
+    /**
+     * 采购员登录(手机号,验证码) --组织
+     *
+     * @return UserLoginVo
+     */
+    @ApiOperation("采购员登录(手机号,验证码) --组织")
+    @PostMapping("/organizeSeller")
+    public ResponseJson<UserLoginVo> organizesellerLogin(LoginCodeDto loginCodeDto) {
+        return sellerService.organizeCodeLogin(loginCodeDto);
+    }
     /**
      * 微信授权登录(小程序),用户数据存入Redis,key前缀:wxInfo:applets:
      * <p>
@@ -391,6 +400,30 @@ public class LoginApi {
         return loginService.invitationCodeLogin(invitationCode, nickName, avatarUrl, unionId);
     }
 
+    /**
+     * 运营人员邀请码授权登录 -- 组织
+     * <p>
+     * spi旧接口:/club/invitationCode
+     *
+     * @param authInvitationDto {
+     *                          invitationCode 邀请码
+     *                          nickName       微信昵称
+     *                          avatarUrl      微信头像(headimgurl)
+     *                          unionId        微信unionId
+     *                          }
+     * @return UserLoginVo
+     */
+    @ApiOperation("运营人员邀请码授权登录 -- 组织")
+    @PostMapping("/auth/invitationOrganize")
+    public ResponseJson<UserLoginVo> invitationCodeOrganizeLogin(AuthInvitationOrganizeDto authInvitationDto) {
+        String invitationCode = authInvitationDto.getInvitationCode();
+        String nickName = authInvitationDto.getNickName();
+        String avatarUrl = authInvitationDto.getAvatarUrl();
+        String unionId = authInvitationDto.getUnionId();
+        Integer organizeId = authInvitationDto.getOrganizeId();
+        return loginService.invitationCodeOrganizeLogin(invitationCode, nickName, avatarUrl, unionId, organizeId);
+    }
+
     /**
      * 运营人员绑定微信
      * <p>

+ 7 - 1
src/main/java/com/caimei365/user/mapper/BaseMapper.java

@@ -51,13 +51,19 @@ public interface BaseMapper {
      */
     Integer getUserIdByOrganize(@Param("organizeId") Integer organizeId, @Param("mobile") String mobile);
 
+    /**
+     * 获取协销信息
+     * @param mobile
+     * @return
+     */
+    UserLoginVo getServiceProvider(@Param("mobile") String mobile);
     /**
      * 获取组织机构审核状态
      * @param organizeId
      * @param mobile
      * @return
      */
-    Integer getUserIdByOrganizeStatus(@Param("organizeId") Integer organizeId, @Param("mobile") String mobile);
+    UserLoginVo getUserIdByOrganizeStatus(@Param("organizeId") Integer organizeId, @Param("mobile") String mobile);
     /**
      * 根据运营人员手机号获用户Id
      *

+ 7 - 0
src/main/java/com/caimei365/user/mapper/LoginMapper.java

@@ -117,6 +117,13 @@ public interface LoginMapper {
      */
     UserLoginVo getOperationUserByInvitationCode(String invitationCode);
 
+    /**
+     * 根据邀请码获取运营人员 -- 组织
+     * @param invitationCode
+     * @param organizeId
+     * @return
+     */
+    UserLoginVo getOperationOrganizeUserByInvitationCode(String invitationCode, Integer organizeId);
     /**
      * 根据Id获取运营人员用户信息(关联user)
      * @param operationId    用户Id

+ 7 - 0
src/main/java/com/caimei365/user/mapper/OperationMapper.java

@@ -60,6 +60,13 @@ public interface OperationMapper {
      * 查找供应商名称
      */
     String findShopNameById(Integer shopId);
+    /**
+     * 根据手机号查询运营人员信息
+     * @param mobile
+     * @param organizeId
+     * @return
+     */
+    OperationPo getInfoByMobile(@Param("mobile") String mobile, @Param("organizeId") Integer organizeId);
     /**
      * 新增运营人员
      */

+ 45 - 0
src/main/java/com/caimei365/user/model/dto/AuthInvitationOrganizeDto.java

@@ -0,0 +1,45 @@
+package com.caimei365.user.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/6/1
+ */
+@ApiModel("运营人员邀请码授权登录--组织")
+@Data
+public class AuthInvitationOrganizeDto implements Serializable {
+    /**
+     * 邀请码
+     */
+    @NotNull
+    @ApiModelProperty("邀请码")
+    private String invitationCode;
+    /**
+     * 微信昵称
+     */
+    @ApiModelProperty("微信昵称")
+    private String nickName;
+    /**
+     * 微信头像(headimgurl)
+     */
+    @ApiModelProperty("微信头像(headimgurl)")
+    private String avatarUrl;
+    /**
+     * 微信unionId
+     */
+    @ApiModelProperty("微信unionId")
+    private String unionId;
+    /**
+     * 组织Id
+     */
+    @ApiModelProperty("组织Id")
+    private Integer organizeId;
+}

+ 11 - 0
src/main/java/com/caimei365/user/service/LoginService.java

@@ -172,6 +172,17 @@ public interface LoginService {
      */
     ResponseJson<UserLoginVo> invitationCodeLogin(String invitationCode, String nickName, String avatarUrl, String unionId);
 
+    /**
+     * 邀请码登录
+     *
+     * @param invitationCode    邀请码
+     * @param nickName          微信昵称
+     * @param avatarUrl         微信头像(headimgurl)
+     * @param unionId           微信unionId
+     * @param organizeId        组织Id
+     * @return UserLoginVo
+     */
+    ResponseJson<UserLoginVo> invitationCodeOrganizeLogin(String invitationCode, String nickName, String avatarUrl, String unionId, Integer organizeId);
     /**
      * 运营人员绑定微信
      *

+ 7 - 0
src/main/java/com/caimei365/user/service/SellerService.java

@@ -2,6 +2,7 @@ package com.caimei365.user.service;
 
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.ClubTemporaryDto;
+import com.caimei365.user.model.dto.LoginCodeDto;
 import com.caimei365.user.model.po.ServiceProviderPo;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
 import com.caimei365.user.model.vo.ClubVo;
@@ -39,6 +40,12 @@ public interface SellerService {
      */
     ResponseJson<UserLoginVo> passwordLogin(String mobile, String password, String unionId);
 
+    /**
+     * 采购员验证码登录 --组织
+     * @param loginCodeDto
+     * @return
+     */
+    ResponseJson<UserLoginVo> organizeCodeLogin(LoginCodeDto loginCodeDto);
     /**
      * 待注册机构列表
      *

+ 62 - 38
src/main/java/com/caimei365/user/service/impl/BaseServiceImpl.java

@@ -120,7 +120,7 @@ public class BaseServiceImpl implements BaseService {
      * 获取短信验证码
      *
      * @param mobile           手机号
-     * @param activateCodeType 1:找回密码,2:手机号注册机构,3:供应商注册,4:修改手机号-旧手机验证码,5:修改手机号-新手机验证码,7:手机验证码登录,8:联合丽格注册,9:联合丽格登录验证,10:联合丽格找回密码,11:联合丽格更换手机号
+     * @param activateCodeType 1:找回密码,2:手机号注册机构,3:供应商注册,4:修改手机号-旧手机验证码,5:修改手机号-新手机验证码,7:手机验证码登录,8:联合丽格注册,9:联合丽格登录验证,10:联合丽格找回密码,11:联合丽格更换手机号--旧手机验证码,12:联合丽格更换手机号--新手机验证码,13联合丽格采购员登录
      * @param platformType     0:www,1:crm/h5,2:小程序
      * @param isCheckCaptcha   是否检查图片验证码,0:检查,1:不检查
      * @param imgCode          图片验证码
@@ -181,21 +181,12 @@ public class BaseServiceImpl implements BaseService {
             String content = "验证码" + randomCode + ",您正在尝试变更重要信息,请妥善保管账户信息。";
             sendFlag = isBeta || remoteCallService.remoteSendSms(0, 1, mobile, content);
             codeTypeTxt = "更换联系人(旧手机号验证码)";
-        } else if (5 == activateCodeType || 11 == activateCodeType) {
+        } else if (5 == activateCodeType) {
             if (null != userId && userId > 0) {
                 return ResponseJson.error("该手机号已被使用");
             }
-            String content = "";
-            // 采美
-            if (5 == activateCodeType) {
-                // 您正在更换联系人手机号,您的验证码为:${code}。
-                content = "验证码" + randomCode + ",您正在尝试变更重要信息,请妥善保管账户信息。";
-            }
-            // 联合丽格
-            if (11 == activateCodeType){
-                // 您正在更改手机号,验证码为:{s6},5分钟内有效,请勿泄漏他人。
-                content = "【丽格集采联盟】您正在更改手机号,验证码为:" + randomCode + ",5分钟内有效,请勿泄漏他人。";
-            }
+            // 您正在更换联系人手机号,您的验证码为:${code}。
+            String content = "验证码" + randomCode + ",您正在尝试变更重要信息,请妥善保管账户信息。";
             sendFlag = isBeta || remoteCallService.remoteSendSms(0, 1, mobile, content);
             codeTypeTxt = "更换联系人(新手机号验证码)";
         } else if (6 == activateCodeType) {
@@ -229,8 +220,14 @@ public class BaseServiceImpl implements BaseService {
                 if (dbUserId == null) {
                     return ResponseJson.error("该手机号暂未注册");
                 }
-                Integer clubStatus = baseMapper.getUserIdByOrganizeStatus(4, mobile);
-                if ( null != clubStatus && 1 == clubStatus) {
+                UserLoginVo userLoginVo = baseMapper.getUserIdByOrganizeStatus(4, mobile);
+                if ( null != userLoginVo.getClubStatus()) {
+                    return ResponseJson.error(-1,"该手机号暂未注册",null);
+                }
+                if (1 == userLoginVo.getUserIdentity()) {
+                    return ResponseJson.error(-1, "该手机号,暂未注册成为机构用户", null);
+                }
+                if (1 == userLoginVo.getClubStatus()) {
                     return ResponseJson.error(-1,"账号待审核,请耐心等待",null);
                 }
                 // 欢迎登录联合丽格,您的验证码为:{s6},5分钟内有效,请勿泄漏他人。
@@ -280,6 +277,38 @@ public class BaseServiceImpl implements BaseService {
                 sendFlag = remoteCallService.remoteSendSms(0,1,mobile,content);
             }
             codeTypeTxt = "联合丽格找回密码";
+        } else if (11 == activateCodeType){
+                // 联合丽格
+                // 您正在更改手机号,验证码为:{s6},5分钟内有效,请勿泄漏他人。
+                String content = "【丽格集采联盟】您正在更改手机号,验证码为:" + randomCode + ",5分钟内有效,请勿泄漏他人。";
+
+                sendFlag = isBeta || remoteCallService.remoteSendSms(0, 1, mobile, content);
+                codeTypeTxt = "更换联系人(旧手机号验证码)";
+        } else if (12 == activateCodeType) {
+            // 联合丽格
+            if (null != userId && userId > 0) {
+                return ResponseJson.error("该手机号已被使用");
+            }
+            // 您正在更改手机号,验证码为:{s6},5分钟内有效,请勿泄漏他人。
+            String content = "【丽格集采联盟】您正在更改手机号,验证码为:" + randomCode + ",5分钟内有效,请勿泄漏他人。";
+            sendFlag = isBeta || remoteCallService.remoteSendSms(0, 1, mobile, content);
+            codeTypeTxt = "更换联系人(新手机号验证码)";
+        } else if (13 == activateCodeType) {
+            UserLoginVo loginVo = baseMapper.getServiceProvider(mobile);
+            if (null == loginVo) {
+                return ResponseJson.error(-1, "该手机号暂未添加为采购员", null);
+            }
+            if (90 != loginVo.getOperationStatus()) {
+                return ResponseJson.error(-1, "该采购员账号已下线", null);
+            }
+            // 【丽格集采联盟】您的验证码为:{s6},5分钟内有效,请勿泄漏他人。
+            String content = "【丽格集采联盟】您的验证码为:" + randomCode + ",5分钟内有效,请勿泄漏他人。";
+            sendFlag = isBeta || remoteCallService.remoteSendSms(0,1,mobile,content);
+            if (!sendFlag) {
+                // 短信发送失败重试一次
+                sendFlag = remoteCallService.remoteSendSms(0,1,mobile,content);
+            }
+            codeTypeTxt = "联合丽格采购员登录";
         } else {
             return ResponseJson.error("参数错误:activateCodeType");
         }
@@ -656,29 +685,24 @@ public class BaseServiceImpl implements BaseService {
         if (null == mobileDto.getUserId()) {
             return ResponseJson.error("参数异常:用户Id不能为空!");
         }
-        // 获取用户组织Id
-        Integer organizeId = userCenterMapper.getUserOrganizeId(mobileDto.getUserId());
-        String result = "";
-        if (0 == organizeId) {
-            if (StringUtils.isBlank(mobileDto.getMobile())) {
-                return ResponseJson.error("参数异常:旧手机号不能为空!");
-            }
-            if (StringUtils.isBlank(mobileDto.getSmsCode())) {
-                return ResponseJson.error("参数异常:旧手机号验证码不能为空!");
-            }
-            // 旧手机号与验证码校验
-            result = ValidateUtil.validateMobile(mobileDto.getMobile());
-            if (result != null) {
-                return ResponseJson.error(result);
-            }
-            String smsCode = (String) redisService.get("code:" + mobileDto.getMobile());
-            // 开发 和 测试环境 固定短信验证码 666666
-            if ("dev".equals(profile) || "beta".equals(profile)) {
-                smsCode = (null != smsCode && !"null".equals(smsCode) ? smsCode : "666666");
-            }
-            if (!mobileDto.getSmsCode().equals(smsCode)) {
-                return ResponseJson.error("旧手机验证码错误");
-            }
+        if (StringUtils.isBlank(mobileDto.getMobile())) {
+            return ResponseJson.error("参数异常:旧手机号不能为空!");
+        }
+        if (StringUtils.isBlank(mobileDto.getSmsCode())) {
+            return ResponseJson.error("参数异常:旧手机号验证码不能为空!");
+        }
+        // 旧手机号与验证码校验
+        String result = ValidateUtil.validateMobile(mobileDto.getMobile());
+        if (result != null) {
+            return ResponseJson.error(result);
+        }
+        String smsCode = (String) redisService.get("code:" + mobileDto.getMobile());
+        // 开发 和 测试环境 固定短信验证码 666666
+        if ("dev".equals(profile) || "beta".equals(profile)) {
+            smsCode = (null != smsCode && !"null".equals(smsCode) ? smsCode : "666666");
+        }
+        if (!mobileDto.getSmsCode().equals(smsCode)) {
+            return ResponseJson.error("旧手机验证码错误");
         }
         UserLoginVo user = loginMapper.getLoginUserByUserId(mobileDto.getUserId());
         if (null == user) {

+ 148 - 74
src/main/java/com/caimei365/user/service/impl/LoginServiceImpl.java

@@ -367,7 +367,6 @@ public class LoginServiceImpl implements LoginService {
                         operationVo.setAddTime(new Date());
                         operationVo.setDelFlag(0);
                         loginMapper.insertOperation(operationVo);
-                        log.info("operationVo***"+operationVo);
                     }
                     // 如果前端传入unionId,则存入返回前端
                     baseUser.setUnionId(unionId);
@@ -1113,7 +1112,7 @@ public class LoginServiceImpl implements LoginService {
         calendar.setTime(operation.getInvitationCodeTime());
         calendar.add(Calendar.DATE, validTime);
         if (1 == operation.getOperationStatus() && date.getTime() > calendar.getTime().getTime() && 0 == operation.getDelFlag()) {
-            return ResponseJson.error("邀请码已失效", null);
+            return ResponseJson.error("邀请码已过期,请联系邀请人更新邀请码", null);
         }
         if (2 == operation.getOperationStatus() && 0 == operation.getDelFlag()) {
             return ResponseJson.error("邀请码已被使用", null);
@@ -1142,87 +1141,162 @@ public class LoginServiceImpl implements LoginService {
         operationPo.setAvatarUrl(avatarUrl);
         // 绑定状态,1未绑定,2已绑定
         operationPo.setStatus(2);
+        // 采美进行消息推送
+        if (0 == operation.getOrganizeId()) {
+            if (1 == userIdentity) {
+                // 机构Id
+                operationPo.setClubId(operation.getClubId());
+                // 用户类型
+                operationPo.setUserType(1);
+
+                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                String current = dateFormat.format(new Date());
+                MessageCenter messageCenter = new MessageCenter();
+                messageCenter.setShopId(null);
+                messageCenter.setClubId(operation.getClubId());
+                messageCenter.setUserType(1);
+                messageCenter.setMessageType(2);
+                messageCenter.setAccountType(7);
+                messageCenter.setContent(nickName);
+                messageCenter.setTime(current);
+                messageCenterMapper.addMessageCenter(messageCenter);
+                //发短信
+                String message = "【采美365】恭喜您成功成为运营人员,您可通过微信直接登录采美商城进行采购。";
+                String mobile = messageCenterMapper.contractMobile(operation.getClubId());
+                if (mobile != null && mobile != "") {
+                    remoteCallService.remoteSendSms(2, 3, mobile, message);
+                }
 
-        if (1 == userIdentity) {
-            // 机构Id
-            operationPo.setClubId(operation.getClubId());
-            // 用户类型
-            operationPo.setUserType(1);
-
-            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            String current = dateFormat.format(new Date());
-            MessageCenter messageCenter = new MessageCenter();
-            messageCenter.setShopId(null);
-            messageCenter.setClubId(operation.getClubId());
-            messageCenter.setUserType(1);
-            messageCenter.setMessageType(2);
-            messageCenter.setAccountType(7);
-            messageCenter.setContent(nickName);
-            messageCenter.setTime(current);
-            messageCenterMapper.addMessageCenter(messageCenter);
-            //发短信
-            String message = "【采美365】恭喜您成功成为运营人员,您可通过微信直接登录采美商城进行采购。";
-            String mobile = messageCenterMapper.contractMobile(operation.getClubId());
-            if (mobile != null && mobile != "") {
-                remoteCallService.remoteSendSms(2, 3, mobile, message);
-            }
+                try {
+                    log.info("***********机构通过邀请码登入微信公众号推送************");
+                    String accessToken = weChatService.getAccessToken();
+                    String openid = messageCenterMapper.getOpenidListByPermission(unionId);
+                    String time = current;
+                    String remarkText = "绑定成功后,您可通过微信直接访问采美商城进行采购。";
+                    // 跳转到【小程序付款-选择支付方式页面】
+                    String pagePath = "https://www.caimei365.com/";
+                    // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
+                    log.error("获取openid>>>>>" + openid);
+                    weChatService.sendTemplateMessg(accessToken, openid, nickName, time, remarkText, pagePath);
+                } catch (Exception e) {
+                    log.error("【机构通过邀请码登入通知】获取微信公众号access_token异常!", e);
+                }
 
-            try {
-                log.info("***********机构通过邀请码登入微信公众号推送************");
-                String accessToken = weChatService.getAccessToken();
-                String openid = messageCenterMapper.getOpenidListByPermission(unionId);
-                String time = current;
-                String remarkText = "绑定成功后,您可通过微信直接访问采美商城进行采购。";
-                // 跳转到【小程序付款-选择支付方式页面】
-                String pagePath = "https://www.caimei365.com/";
-                // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
-                log.error("获取openid>>>>>" + openid);
-                weChatService.sendTemplateMessg(accessToken, openid, nickName, time, remarkText, pagePath);
-            } catch (Exception e) {
-                log.error("【机构通过邀请码登入通知】获取微信公众号access_token异常!", e);
-            }
 
+            } else {
+                // 供应商Id
+                operationPo.setShopId(operation.getShopId());
+                // 用户类型
+                operationPo.setUserType(2);
+
+                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                String current = dateFormat.format(new Date());
+                MessageCenter messageCenter = new MessageCenter();
+                messageCenter.setShopId(operation.getShopId());
+                messageCenter.setClubId(null);
+                messageCenter.setUserType(2);
+                messageCenter.setMessageType(2);
+                messageCenter.setShopMessType(2);
+                messageCenter.setContent(nickName);
+                messageCenter.setTime(current);
+                messageCenterMapper.addMessageCenter(messageCenter);
+
+                //发短信
+                String message = "【采美365】恭喜您成功成为运营人员,您可通过微信直接登录采美商城进行采购。";
+                String mobile = messageCenterMapper.contractMobiles(operation.getShopId());
+                if (mobile != null && mobile != "") {
+                    remoteCallService.remoteSendSms(2, 3, mobile, message);
+                }
+                try {
+                    log.info("***********供应商通过邀请码登入微信公众号推送************");
+                    String accessToken = weChatService.getAccessToken();
+                    String openid = messageCenterMapper.getOpenidListByPermission(unionId);
+                    String time = current;
+                    String remarkText = "绑定成功后,您可通过微信直接访问采美商城进行采购。";
+                    // 跳转到【小程序付款-选择支付方式页面】
+                    String pagePath = "https://www.caimei365.com/";
+                    // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
+                    log.error("获取openid>>>>>" + openid);
+                    weChatService.sendTemplateMessg(accessToken, openid, nickName, time, remarkText, pagePath);
+                } catch (Exception e) {
+                    log.error("【供应商通过邀请码登入通知】获取微信公众号access_token异常!", e);
+                }
 
+            }
         } else {
-            // 供应商Id
-            operationPo.setShopId(operation.getShopId());
+            // 联合丽格没有运营人员为机构运营人员
+            // 机构Id
+            operationPo.setClubId(operation.getClubId());
             // 用户类型
-            operationPo.setUserType(2);
+            operationPo.setUserType(1);
+        }
+        // 更新运营人员信息
+        operationMapper.updateOperationByInvitation(operationPo);
+        // 返回登录校验结果
+        return logonVerify(operation);
+    }
 
-            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            String current = dateFormat.format(new Date());
-            MessageCenter messageCenter = new MessageCenter();
-            messageCenter.setShopId(operation.getShopId());
-            messageCenter.setClubId(null);
-            messageCenter.setUserType(2);
-            messageCenter.setMessageType(2);
-            messageCenter.setShopMessType(2);
-            messageCenter.setContent(nickName);
-            messageCenter.setTime(current);
-            messageCenterMapper.addMessageCenter(messageCenter);
+    /**
+     * 邀请码登录
+     *
+     * @param invitationCode 邀请码
+     * @param nickName       微信昵称
+     * @param avatarUrl      微信头像(headimgurl)
+     * @param unionId        微信unionId
+     * @param organizeId     组织Id
+     * @return UserLoginVo
+     */
+    @Override
+    public ResponseJson<UserLoginVo> invitationCodeOrganizeLogin(String invitationCode, String nickName, String avatarUrl, String unionId, Integer organizeId) {
+        // 参数校验
+        if (StringUtils.isBlank(invitationCode)) {
+            return ResponseJson.error("邀请码不能为空", null);
+        }
+        UserLoginVo operation = loginMapper.getOperationOrganizeUserByInvitationCode(invitationCode, organizeId);
+        if (operation == null) {
+            return ResponseJson.error("邀请码错误", null);
+        }
+        Date date = new Date();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(operation.getInvitationCodeTime());
+        calendar.add(Calendar.DATE, validTime);
+        if (1 == operation.getOperationStatus() && date.getTime() > calendar.getTime().getTime() && 0 == operation.getDelFlag()) {
+            return ResponseJson.error("邀请码已过期,请联系邀请人更新邀请码", null);
+        }
+        if (2 == operation.getOperationStatus() && 0 == operation.getDelFlag()) {
+            return ResponseJson.error("邀请码已被使用", null);
+        }
+        // 用户身份:1机构,2供应商
+        int userIdentity = 3 == operation.getUserIdentity() ? 2 : 1;
+        if (1 == userIdentity && operation.getClubStatus() != null && 91 == operation.getClubStatus()) {
+            return ResponseJson.error("您的机构已冻结", null);
+        }
+        if (2 == userIdentity && operation.getShopStatus() != null && 91 == operation.getShopStatus()) {
+            return ResponseJson.error("您的企业账号已被冻结,请联系客服处理", null);
+        }
+        if (0 != operation.getDelFlag()) {
+            return ResponseJson.error("您的邀请码已被删除,请重新添加运营人员", null);
+        }
+        OperationPo operationPo = new OperationPo();
+        operationPo.setId(operation.getOperationId());
+        // 微信unionId
+        operationPo.setUnionId(unionId);
+        Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + unionId);
+        // 微信openId
+        operationPo.setOpenId((String) infoData.get(WeChatService.Keys.OPEN_ID));
+        // 微信昵称
+        operationPo.setNickName(nickName);
+        // 微信头像
+        operationPo.setAvatarUrl(avatarUrl);
+        // 绑定状态,1未绑定,2已绑定
+        operationPo.setStatus(2);
 
-            //发短信
-            String message = "【采美365】恭喜您成功成为运营人员,您可通过微信直接登录采美商城进行采购。";
-            String mobile = messageCenterMapper.contractMobiles(operation.getShopId());
-            if (mobile != null && mobile != "") {
-                remoteCallService.remoteSendSms(2, 3, mobile, message);
-            }
-            try {
-                log.info("***********供应商通过邀请码登入微信公众号推送************");
-                String accessToken = weChatService.getAccessToken();
-                String openid = messageCenterMapper.getOpenidListByPermission(unionId);
-                String time = current;
-                String remarkText = "绑定成功后,您可通过微信直接访问采美商城进行采购。";
-                // 跳转到【小程序付款-选择支付方式页面】
-                String pagePath = "https://www.caimei365.com/";
-                // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
-                log.error("获取openid>>>>>" + openid);
-                weChatService.sendTemplateMessg(accessToken, openid, nickName, time, remarkText, pagePath);
-            } catch (Exception e) {
-                log.error("【供应商通过邀请码登入通知】获取微信公众号access_token异常!", e);
-            }
+        // 联合丽格没有运营人员为机构运营人员
+        // 机构Id
+        operationPo.setClubId(operation.getClubId());
+        // 用户类型
+        operationPo.setUserType(1);
 
-        }
         // 更新运营人员信息
         operationMapper.updateOperationByInvitation(operationPo);
         // 返回登录校验结果

+ 34 - 5
src/main/java/com/caimei365/user/service/impl/OperationServiceImpl.java

@@ -3,6 +3,7 @@ package com.caimei365.user.service.impl;
 import com.caimei365.user.components.CommonService;
 import com.caimei365.user.mapper.MessageCenterMapper;
 import com.caimei365.user.mapper.OperationMapper;
+import com.caimei365.user.mapper.UserCenterMapper;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.OperationDto;
 import com.caimei365.user.model.po.OperationPo;
@@ -41,6 +42,8 @@ public class OperationServiceImpl implements OperationService {
     private RemoteCallService remoteCallService;
     @Resource
     private MessageCenterMapper messageCenterMapper;
+    @Resource
+    private UserCenterMapper userCenterMapper;
 
     /**
      * 添加运营人员
@@ -56,6 +59,8 @@ public class OperationServiceImpl implements OperationService {
      */
     @Override
     public ResponseJson addOperation(OperationDto operationDto) {
+        // 获取用户组织Id
+        Integer organizeId = userCenterMapper.getUserOrganizeId(operationDto.getUserId());
         // 查询使用该手机号的运营人员或用户
         String checkRust = commonService.operationBindCheck(operationDto.getMobile(), null);
         if (checkRust != null) {
@@ -102,8 +107,23 @@ public class OperationServiceImpl implements OperationService {
             }
             String mobile = operationDto.getMobile();
             if (StringUtils.isNotEmpty(mobile)) {
-                // 欢迎成为${name}的运营人员,您的邀请码为${code}。
-                String content = "欢迎成为" + name + "的运营人员,您的邀请码为" + invitationCode + "。您可使用以下两种方式激活您的身份:1. 您可在微信搜索“采美采购商城”小程序,使用邀请码登录并绑定微信;2. 进入“采美采购商城”小程序后,使用邀请码登录并绑定微信。绑定微信后,您可通过微信授权直接登录“采美采购商城”小程序或微信扫码直接登录采美365网站。";
+                String content = "";
+                if (0 == organizeId) {
+                    // 采美
+                    // 欢迎成为${name}的运营人员,您的邀请码为${code}。
+                    content = "欢迎成为" + name + "的运营人员,您的邀请码为" + invitationCode + "。您可使用以下两种方式激活您的身份:1. 您可在微信搜索“采美采购商城”小程序,使用邀请码登录并绑定微信;2. 进入“采美采购商城”小程序后,使用邀请码登录并绑定微信。绑定微信后,您可通过微信授权直接登录“采美采购商城”小程序或微信扫码直接登录采美365网站。";
+                } else {
+                    // 联合丽格
+                    OperationPo operationPo = operationMapper.getInfoByMobile(mobile, organizeId);
+                    if (null != operationPo) {
+                        if (operationPo.getClubId().equals(operationDto.getClubId())) {
+                            return ResponseJson.error(-1, "该手机号已绑定本机构运营人员", null);
+                        }
+                        return ResponseJson.error(-1, "该手机号已绑定其他机构运营人员", null);
+                    }
+                    // 您被邀请成为【机构名称】的运营人员,邀请码为:{s6},请直接使用邀请码登录“丽格集采联盟”小程序。
+                    content = "【丽格集采联盟】您被邀请成为【" + name + "】的运营人员,邀请码为:" + invitationCode + ",请直接使用邀请码登录“丽格集采联盟”小程序。";
+                }
                 remoteCallService.remoteSendSms(0, 1, mobile, content);
                 log.info("欢迎成为" + name + "的运营人员,您的邀请码为:" + invitationCode);
             }
@@ -116,7 +136,7 @@ public class OperationServiceImpl implements OperationService {
         operation.setAddTime(date);
         operation.setUpdateTime(date);
         operation.setDelFlag(0);
-        operation.setOrganizeId(0);
+        operation.setOrganizeId(organizeId);
         int flag = 0;
         if (operation.getId() == null) {
             operation.setAccount(operationDto.getMobile() + CodeUtil.generateAccount(2));
@@ -162,9 +182,18 @@ public class OperationServiceImpl implements OperationService {
                 name = operationMapper.findShopNameById(operation.getShopId());
             }
             String mobile = operation.getMobile();
+            Integer organizeId = operation.getOrganizeId();
             if (StringUtils.isNotEmpty(mobile)) {
-                // 欢迎成为${name}的运营人员,您更新的邀请码为${code}。
-                String content = "欢迎成为" + name + "的运营人员,您的邀请码为" + invitationCode + "。您可使用以下两种方式激活您的身份:1. 您可在微信搜索“采美采购商城”小程序,使用邀请码登录并绑定微信;2. 进入“采美采购商城”小程序后,使用邀请码登录并绑定微信。绑定微信后,您可通过微信授权直接登录“采美采购商城”小程序或微信扫码直接登录采美365网站。";
+                String content = "";
+                if (0 == organizeId) {
+                    // 采美
+                    // 欢迎成为${name}的运营人员,您更新的邀请码为${code}。
+                    content = "欢迎成为" + name + "的运营人员,您的邀请码为" + invitationCode + "。您可使用以下两种方式激活您的身份:1. 您可在微信搜索“采美采购商城”小程序,使用邀请码登录并绑定微信;2. 进入“采美采购商城”小程序后,使用邀请码登录并绑定微信。绑定微信后,您可通过微信授权直接登录“采美采购商城”小程序或微信扫码直接登录采美365网站。";
+                } else {
+                    // 联合丽格
+                    // 【丽格集采联盟】您被邀请成为【{s}】的运营人员,邀请码已更新为:{s6},请直接使用邀请码登录“丽格集采联盟”小程序。
+                    content = "【丽格集采联盟】您被邀请成为【" + name + "】的运营人员,邀请码已更新为:" + invitationCode + ",请直接使用邀请码登录“丽格集采联盟”小程序。";
+                }
                 remoteCallService.remoteSendSms(0, 1, mobile, content);
                 log.info("欢迎成为" + name + "的运营人员,您更新的邀请码为:" + invitationCode);
             }

+ 86 - 8
src/main/java/com/caimei365/user/service/impl/SellerServiceImpl.java

@@ -2,16 +2,15 @@ package com.caimei365.user.service.impl;
 
 import com.caimei365.user.components.RedisService;
 import com.caimei365.user.components.WeChatService;
+import com.caimei365.user.mapper.LoginMapper;
 import com.caimei365.user.mapper.SellerMapper;
 import com.caimei365.user.mapper.SuperVipMapper;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.ClubTemporaryDto;
+import com.caimei365.user.model.dto.LoginCodeDto;
 import com.caimei365.user.model.po.ServiceProviderPo;
 import com.caimei365.user.model.po.SuperVipPo;
-import com.caimei365.user.model.vo.ClubTemporaryVo;
-import com.caimei365.user.model.vo.ClubVo;
-import com.caimei365.user.model.vo.ServiceProviderVo;
-import com.caimei365.user.model.vo.UserLoginVo;
+import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.SellerService;
 import com.caimei365.user.utils.JwtUtil;
 import com.caimei365.user.utils.Md5Util;
@@ -19,13 +18,11 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * Description
@@ -45,6 +42,8 @@ public class SellerServiceImpl implements SellerService {
     private SellerMapper sellerMapper;
     @Resource
     private SuperVipMapper vipMapper;
+    @Resource
+    private LoginMapper loginMapper;
 
     /**
      * 协销机构列表
@@ -146,6 +145,85 @@ public class SellerServiceImpl implements SellerService {
         return ResponseJson.success(seller);
     }
 
+    /**
+     * 采购员验证码登录 --组织
+     *
+     * @param loginCodeDto
+     * @return
+     */
+    @Override
+    public ResponseJson<UserLoginVo> organizeCodeLogin(LoginCodeDto loginCodeDto) {
+        String mobile = loginCodeDto.getMobile();
+        String unionId = loginCodeDto.getUnionId();
+        String code = loginCodeDto.getCode();
+        if (StringUtils.isBlank(mobile)) {
+            return ResponseJson.error("请输入账号密码", null);
+        }
+        if (StringUtils.isBlank(unionId)) {
+            return ResponseJson.error("请输入微信unionId", null);
+        }
+        if (StringUtils.isBlank(code)) {
+            return ResponseJson.error("请输入验证码", null);
+        }
+        // 判断redis中是否存在
+        boolean exists = redisService.exists("code:" + mobile);
+        if (exists) {
+            // 查看验证码是否过期
+            long expireTime = redisService.getExpireTime("code:" + mobile);
+            if (expireTime < 0) {
+                return ResponseJson.error(-1, "验证码已失效,请重新获取", null);
+            }
+            // 获取redis手机短信验证码
+            Object randomCode = redisService.get("code:" + mobile);
+
+            if (!ObjectUtils.isEmpty(randomCode)) {
+                if (code.equals(randomCode.toString())) {
+                    redisService.remove("code:" + mobile);
+                    // 根据手机号获取协销
+                    UserLoginVo seller = sellerMapper.getLoginSellerByMobile(mobile);
+                    // 生成token
+                    String token = JwtUtil.createToken(seller.getUserId());
+                    // 为了过期续签,将token存入redis,并设置超时时间
+                    redisService.set(token, token, JwtUtil.getExpireTime());
+                    seller.setToken(token);
+                    Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + unionId);
+                    String openId = (String) infoData.get(WeChatService.Keys.OPEN_ID);
+                    sellerMapper.updateServiceProviderByUserId(seller.getUserId(), openId, unionId);
+                    log.info("采购员登录openid>>>>" + openId + " ,unionId>>>>>" + unionId);
+                    // seller.setManager(sellerMapper.findManager(mobile));
+
+                    // 根据手机号获取用户信息
+                    UserLoginVo baseUser = loginMapper.getLoginOrganizeUserByMobileOrEmail(mobile);
+                    // 绑定微信信息
+                    Integer operationUser = loginMapper.getOperationUser(mobile);
+                    log.info("operationUser==="+operationUser);
+                    if (null == operationUser) {
+                        // 绑定微信
+                        OperationVo operationVo = new OperationVo();
+                        operationVo.setOrganizeId(baseUser.getOrganizeId());
+                        operationVo.setUserType(1);
+                        operationVo.setUserId(baseUser.getUserId());
+                        operationVo.setClubId(baseUser.getClubId());
+                        operationVo.setMobile(baseUser.getMobile());
+                        operationVo.setLinkName(baseUser.getUserName());
+                        operationVo.setStatus(2);
+                        operationVo.setUnionId(unionId);
+                        operationVo.setBindTime(new Date());
+                        operationVo.setAddTime(new Date());
+                        operationVo.setDelFlag(0);
+                        loginMapper.insertOperation(operationVo);
+                    }
+                    return ResponseJson.success(seller);
+                } else {
+                    return ResponseJson.error(-1, "验证码错误,请确认验证码输入",null);
+                }
+            } else {
+                return ResponseJson.error(-1, "验证码错误, 请重新获取",null);
+            }
+        }
+        return ResponseJson.error();
+    }
+
     /**
      * 待注册机构列表
      *

+ 5 - 2
src/main/resources/mapper/BaseMapper.xml

@@ -82,8 +82,11 @@
           AND u.userIdentity IN (1, 2, 3, 4)
         LIMIT 1
     </select>
-    <select id="getUserIdByOrganizeStatus" resultType="java.lang.Integer">
-        SELECT clubStatus
+    <select id="getServiceProvider" resultType="com.caimei365.user.model.vo.UserLoginVo">
+        SELECT serviceProviderID as serviceProviderId, status as operationStatus FROM serviceprovider WHERE contractMobile = #{mobile}
+    </select>
+    <select id="getUserIdByOrganizeStatus" resultType="com.caimei365.user.model.vo.UserLoginVo">
+        SELECT userId, userIdentity, clubStatus
         FROM USER
         WHERE userOrganizeID = #{organizeId}
           AND bindMobile = #{mobile}

+ 26 - 1
src/main/resources/mapper/LoginMapper.xml

@@ -229,6 +229,7 @@
         u.email as email,
         u.userPermission as userPermission,
         u.userIdentity as userIdentity,
+        u.serviceProviderID as serviceProviderId,
         u.password as password,
         u.guideFlag as guideFlag,
         u.clubStatus as clubStatus,
@@ -301,6 +302,7 @@
         u.email as email,
         u.userPermission as userPermission,
         u.userIdentity as userIdentity,
+        u.serviceProviderID as serviceProviderId,
         u.password as password,
         u.guideFlag as guideFlag,
         u.clubStatus as clubStatus,
@@ -364,6 +366,7 @@
                u.shopID             as shopId,
                u.userName           as userName,
                u.name               as name,
+               ifnull(cou.userOrganizeID, 0) as organizeId,
                u.userIdentity,
                u.guideFlag          as guideFlag,
                u.clubStatus         as clubStatus,
@@ -375,7 +378,29 @@
         FROM cm_mall_operation_user cou
                  LEFT JOIN user u ON u.userID = cou.userID
         WHERE cou.invitationCode = #{invitationCode}
-          AND cou.userOrganizeID = 0
+          AND cou.userOrganizeID = #{organizeId}
+          AND u.userIdentity in (2, 3, 4)
+    </select>
+    <select id="getOperationOrganizeUserByInvitationCode" resultType="com.caimei365.user.model.vo.UserLoginVo">
+        SELECT cou.id               as operationId,
+               u.userID             as userId,
+               u.clubID             as clubId,
+               u.shopID             as shopId,
+               u.userName           as userName,
+               u.name               as name,
+               ifnull(cou.userOrganizeID, 0) as organizeId,
+               u.userIdentity,
+               u.guideFlag          as guideFlag,
+               u.clubStatus         as clubStatus,
+               u.manufacturerStatus as shopStatus,
+               cou.invitationCodeTime,
+               cou.mobile           as operationMobile,
+               cou.status           as operationStatus,
+               cou.delFlag
+        FROM cm_mall_operation_user cou
+                 LEFT JOIN user u ON u.userID = cou.userID
+        WHERE cou.invitationCode = #{invitationCode}
+          AND cou.userOrganizeID = 4
           AND u.userIdentity in (2, 3, 4)
     </select>
     <select id="getOperationUserByOperationId" resultType="com.caimei365.user.model.vo.UserLoginVo">

+ 13 - 0
src/main/resources/mapper/OperationMapper.xml

@@ -24,8 +24,21 @@
         select name from shop
         where shopID = #{shopId}
     </select>
+    <select id="getInfoByMobile" resultType="com.caimei365.user.model.po.OperationPo">
+        select id as id,
+               userID as userId,
+               mobile as mobile,
+               clubID as clubId,
+               shopID as shopId,
+               status as status,
+               nickName as nickName
+        from cm_mall_operation_user
+        where mobile = #{mobile} and userOrganizeID = #{organizeId}
+        limit 1
+    </select>
     <select id="getOperationCodeInfoById" resultType="com.caimei365.user.model.po.OperationPo">
         select o.id as id,
+               ifnull(o.userOrganizeID, 0) as organizeId,
                o.mobile as mobile,
                o.clubID as clubId,
                o.shopID as shopId,

+ 1 - 0
src/main/resources/mapper/SellerMapper.xml

@@ -13,6 +13,7 @@
                u.guideFlag      as guideFlag,
                u.userPermission as userPermission,
                u.userIdentity   as userIdentity,
+               u.serviceProviderID as serviceProviderId,
                u.password       as password
         from user u
         where u.mobile = #{mobile}