|
@@ -5,16 +5,19 @@ import com.caimei365.user.mapper.RegisterUserDao;
|
|
|
import com.caimei365.user.model.*;
|
|
|
import com.caimei365.user.service.ClubService;
|
|
|
import com.caimei365.user.service.RedisService;
|
|
|
+import com.caimei365.user.utils.AliyunSmsUtil;
|
|
|
import com.caimei365.user.utils.Md5Util;
|
|
|
import com.caimei365.user.utils.ReduestUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -49,6 +52,7 @@ public class ClubServiceImpl implements ClubService {
|
|
|
* @return BaseUser
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public JsonModel<BaseUser> register(Integer source, String userName, String bindMobile, String password, String passWordConfirm, String smsCode, Integer isAgreed, String nickName, String avatarUrl, ServerWebExchange serverWebExchange) {
|
|
|
// 打印IP
|
|
|
String ip = ReduestUtil.getIp(serverWebExchange);
|
|
@@ -70,13 +74,13 @@ public class ClubServiceImpl implements ClubService {
|
|
|
return JsonModel.error("请勾选同意协议", null);
|
|
|
}
|
|
|
// 查找用户表是否存在
|
|
|
- BaseUser dbUser = baseUserDao.getBaseUserByMobile(bindMobile);
|
|
|
- if (dbUser != null) {
|
|
|
+ Integer dbUserId = baseUserDao.getUserIdByMobile(bindMobile);
|
|
|
+ if (dbUserId > 0) {
|
|
|
return JsonModel.error("该手机号已被使用", null);
|
|
|
}
|
|
|
// 查找运营人员表是否存在
|
|
|
- OperationVo operation = baseUserDao.getOperationByMobile(bindMobile);
|
|
|
- if (null != operation) {
|
|
|
+ Integer dbOperationId = baseUserDao.getOperationIdByMobile(bindMobile);
|
|
|
+ if (dbOperationId > 0) {
|
|
|
return JsonModel.error("您已是机构运营人员,无需再注册机构", null);
|
|
|
}
|
|
|
/*
|
|
@@ -103,7 +107,7 @@ public class ClubServiceImpl implements ClubService {
|
|
|
user.setUserIdentity(4);
|
|
|
// 用户权限: 2会员机构 3供应商 4协销 5普通机构
|
|
|
user.setUserPermission(5);
|
|
|
- //设置机构上线
|
|
|
+ // 设置机构上线
|
|
|
user.setClubStatus(90);
|
|
|
// 设置密码
|
|
|
user.setPassword(Md5Util.md5(user.getPassword()));
|
|
@@ -151,9 +155,51 @@ public class ClubServiceImpl implements ClubService {
|
|
|
log.info(club.getUserId() + " 插入数据库异常club:" + club.toString());
|
|
|
return JsonModel.error("插入数据库异常", null);
|
|
|
}
|
|
|
-// //更新clubID
|
|
|
-// userVo.setClubID(club.getClubID());
|
|
|
-// loginDao.updateUser(userVo);
|
|
|
+ // user更新clubId
|
|
|
+ user.setClubId(club.getClubId());
|
|
|
+ registerUserDao.updateUserClubId(user.getUserId(), club.getClubId());
|
|
|
+ // 注册成功短信
|
|
|
+ boolean smsFlag = AliyunSmsUtil.sendSms(bindMobile, 7, "{name:"+ bindMobile +",password:"+ password +"}");
|
|
|
+ if (!smsFlag) {
|
|
|
+ // 短信发送失败重试一次
|
|
|
+ AliyunSmsUtil.sendSms(bindMobile, 7, "{name:"+ bindMobile +",password:"+ password +"}");
|
|
|
+ }
|
|
|
+ log.info("注册普通机构成功,手机号>>>" + bindMobile);
|
|
|
+ /*
|
|
|
+ 绑定微信,成为机构运营人员
|
|
|
+ */
|
|
|
+ if (StringUtils.isNotBlank(nickName)) {
|
|
|
+ OperationPo operation = new OperationPo();
|
|
|
+ // 用户ID
|
|
|
+ operation.setUserId(user.getUserId());
|
|
|
+ // 机构ID
|
|
|
+ operation.setClubId(club.getClubId());
|
|
|
+ // 微信昵称
|
|
|
+ operation.setNickName(nickName);
|
|
|
+ // 微信头像
|
|
|
+ operation.setAvatarUrl(avatarUrl);
|
|
|
+ // 用户类型,1:机构类型,2供应商类型
|
|
|
+ operation.setUserType(1);
|
|
|
+ // 运营人员手机号
|
|
|
+ operation.setMobile(bindMobile);
|
|
|
+ // 联系人
|
|
|
+ operation.setLinkName(userName);
|
|
|
+ // 运营人员状态:1未绑定,2已绑定
|
|
|
+ operation.setStatus(2);
|
|
|
+
|
|
|
+// Map<String, String> wxInfo = (Map<String, String>) request.getSession().getAttribute("wxInfo");
|
|
|
+// String openid = wxInfo.get("openid");
|
|
|
+// String unionid = wxInfo.get("unionid");
|
|
|
+// operation.setOpenid(openid);
|
|
|
+// operation.setUnionId(unionid);
|
|
|
+// operation.setBindTime(time);
|
|
|
+// operation.setUpdateTime(time);
|
|
|
+// operation.setAddTime(time);
|
|
|
+// operation.setDelFlag("0");
|
|
|
+// loginDao.saveOperationUser(operation);
|
|
|
+// log.info("注册普通机构,默认绑定为机构运营人员");
|
|
|
+ }
|
|
|
+ //return model.success(clubVo);
|
|
|
|
|
|
|
|
|
return null;
|