|
@@ -4,6 +4,7 @@ import com.caimei365.user.mapper.BaseMapper;
|
|
|
import com.caimei365.user.mapper.LoginMapper;
|
|
|
import com.caimei365.user.mapper.RegisterMapper;
|
|
|
import com.caimei365.user.model.ResponseJson;
|
|
|
+import com.caimei365.user.model.dto.ClubOnlineDto;
|
|
|
import com.caimei365.user.model.dto.ClubRegisterDto;
|
|
|
import com.caimei365.user.model.dto.ClubUpgradeDto;
|
|
|
import com.caimei365.user.model.dto.ShopRegisterDto;
|
|
@@ -11,6 +12,8 @@ import com.caimei365.user.model.po.ClubPo;
|
|
|
import com.caimei365.user.model.po.OperationPo;
|
|
|
import com.caimei365.user.model.po.ShopPo;
|
|
|
import com.caimei365.user.model.po.UserPo;
|
|
|
+import com.caimei365.user.model.vo.ServiceProviderVo;
|
|
|
+import com.caimei365.user.model.vo.UserLoginVo;
|
|
|
import com.caimei365.user.service.RegisterService;
|
|
|
import com.caimei365.user.components.RedisService;
|
|
|
import com.caimei365.user.utils.AliyunSmsUtil;
|
|
@@ -25,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -46,6 +50,13 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
@Resource
|
|
|
private RegisterMapper registerMapper;
|
|
|
|
|
|
+ /**
|
|
|
+ * 短信模板
|
|
|
+ */
|
|
|
+ private String mailTxt = "欢迎成为采美普通机构用户,您的登录账号为:%s,初始密码为:%s,您可使用该账号密码登录采美365网和【采美采购商城】小程序。登录后可升级为会员机构,享受更多更好的服务。";
|
|
|
+ private String memberMailTxt = "欢迎成为采美会员机构用户,您的登录账号为:%s,初始密码为:%s,您可使用该账号密码登录采美365网和【采美采购商城】小程序享受会员专属服务。";
|
|
|
+ private String initPassword = "caimei123";
|
|
|
+
|
|
|
/**
|
|
|
* 普通机构入驻(注册)
|
|
|
*
|
|
@@ -331,6 +342,165 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
return ResponseJson.success(club);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<ClubPo> clubOnline(ClubOnlineDto onlineDto, Integer isAgreed, HttpHeaders headers) {
|
|
|
+ // 打印IP
|
|
|
+ String ip = headers.getFirst("X-CLIENT-IP");
|
|
|
+ log.info("协销拉机构上线 X-CLIENT-IP : " + ip);
|
|
|
+ // 手机号
|
|
|
+ String mobile = onlineDto.getBindMobile();
|
|
|
+ // 参数校验
|
|
|
+ if (onlineDto.getUserId() == null || StringUtils.isBlank(onlineDto.getLinkMan()) || StringUtils.isBlank(mobile)
|
|
|
+ || isAgreed == null) {
|
|
|
+ return ResponseJson.error("参数异常", null);
|
|
|
+ }
|
|
|
+ if (1 != isAgreed) {
|
|
|
+ return ResponseJson.error("请勾选同意协议", null);
|
|
|
+ }
|
|
|
+ // 是否填写升级资料
|
|
|
+ if (!StringUtils.isBlank(onlineDto.getContractEmail())) {
|
|
|
+ // 邮箱验证
|
|
|
+ if (ValidateUtil.validateEmail(onlineDto.getContractEmail())) {
|
|
|
+ return ResponseJson.error("邮箱格式不正确", null);
|
|
|
+ }
|
|
|
+ Integer userIdByEmail = baseMapper.getUserIdByEmail(onlineDto.getContractEmail());
|
|
|
+ if (null != userIdByEmail && userIdByEmail > 0 ) {
|
|
|
+ return ResponseJson.error("该邮箱已被使用", null);
|
|
|
+ }
|
|
|
+ // 机构名称检查
|
|
|
+ ResponseJson responseJson = ValidateUtil.validateClubName(onlineDto.getName());
|
|
|
+ if (0 != responseJson.getCode()) {
|
|
|
+ return ResponseJson.error(responseJson.getMsg(), null);
|
|
|
+ }
|
|
|
+ Integer clubCount = loginMapper.getClubCountByClubName(onlineDto.getName());
|
|
|
+ if (clubCount != null && clubCount > 0) {
|
|
|
+ return ResponseJson.error("该名称已存在,请拨打电话:0755-22907771,联系采美客服", null);
|
|
|
+ }
|
|
|
+ if (onlineDto.getFirstClubType() == 1){
|
|
|
+ if (onlineDto.getSecondClubType() == null || StringUtils.isBlank(onlineDto.getDepartment()) || StringUtils.isBlank(onlineDto.getMedicalPracticeLicense())) {
|
|
|
+ return ResponseJson.error("医美分类下参数异常", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 手机号验证
|
|
|
+ UserLoginVo userByMobile = loginMapper.getLoginUserByMobileOrEmail(mobile);
|
|
|
+ if (userByMobile != null) {
|
|
|
+ ResponseJson validReason = ValidateUtil.getMobileValidateReason(mobile, userByMobile);
|
|
|
+ return ResponseJson.error(validReason.getMsg(), null);
|
|
|
+ }
|
|
|
+ // 协销信息
|
|
|
+ Integer userId = onlineDto.getUserId();
|
|
|
+ ServiceProviderVo serviceProvider = loginMapper.getServiceProviderByUserId(userId);
|
|
|
+ // 设置日期时间格式
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String current = dateFormat.format(new Date());
|
|
|
+
|
|
|
+ /*
|
|
|
+ 组装用户数据 user
|
|
|
+ */
|
|
|
+ UserPo user = new UserPo();
|
|
|
+ /*
|
|
|
+ 组装用户数据 club
|
|
|
+ */
|
|
|
+ ClubPo club = new ClubPo();
|
|
|
+
|
|
|
+ // 是否填写升级资料
|
|
|
+ if (StringUtils.isBlank(onlineDto.getContractEmail())) {
|
|
|
+ // 状态: 已上线
|
|
|
+ user.setClubStatus(90);
|
|
|
+ // 组织名称
|
|
|
+ user.setName(onlineDto.getLinkMan());
|
|
|
+ // 状态: 已上线
|
|
|
+ club.setStatus(90);
|
|
|
+ // 机构名称
|
|
|
+ club.setName(onlineDto.getLinkMan());
|
|
|
+ // 机构简称
|
|
|
+ club.setSName(onlineDto.getLinkMan());
|
|
|
+ } else {
|
|
|
+ // 状态:待审查资料
|
|
|
+ user.setClubStatus(1);
|
|
|
+ // 组织名称
|
|
|
+ user.setName(onlineDto.getName());
|
|
|
+ // 邮箱
|
|
|
+ user.setEmail(onlineDto.getContractEmail());
|
|
|
+ // 邮箱
|
|
|
+ club.setContractEmail(onlineDto.getContractEmail());
|
|
|
+ // 待审查资料
|
|
|
+ club.setStatus(1);
|
|
|
+ }
|
|
|
+ // 协销Id
|
|
|
+ user.setServiceProviderId(serviceProvider.getServiceProviderId());
|
|
|
+ // 协销状态
|
|
|
+ user.setServiceProviderStatus(serviceProvider.getStatus());
|
|
|
+ // 小程序注册
|
|
|
+ user.setSource(1);
|
|
|
+ // 用户身份 0、个人 1、协销 2、会员机构 3、供应商 4,普通机构
|
|
|
+ user.setUserIdentity(4);
|
|
|
+ // 设置为机构( 供应商1,会员机构3,普通机构4)
|
|
|
+ user.setRegisterUserTypeId(4);
|
|
|
+ // 状态: 已上线
|
|
|
+ user.setUserPermission(5);
|
|
|
+ // 手机号
|
|
|
+ user.setBindMobile(mobile);
|
|
|
+ // 默认密码
|
|
|
+ user.setPassword(Md5Util.md5(initPassword));
|
|
|
+ user.setRegisterTime(current);
|
|
|
+ // 机构拉上线统称为此IP方便后面直接标记为协销代注册
|
|
|
+ user.setRegisterIp("192.168.1.10");
|
|
|
+ // 用户名
|
|
|
+ user.setUserName(onlineDto.getLinkMan());
|
|
|
+ // 同意协议标志
|
|
|
+ user.setAgreeFlag(1);
|
|
|
+ // 用户状态,1正常,0冻结
|
|
|
+ user.setValidFlag(1);
|
|
|
+ /*
|
|
|
+ 保存数据库 user
|
|
|
+ */
|
|
|
+ registerMapper.insertClubUser(user);
|
|
|
+ /*
|
|
|
+ * 注册机构信息
|
|
|
+ */
|
|
|
+ // 设置club信息 并保存
|
|
|
+ club.setUserId(user.getUserId());
|
|
|
+ club.setContractMobile(mobile);
|
|
|
+ club.setLinkMan(onlineDto.getLinkMan());
|
|
|
+ // 设置协销ID
|
|
|
+ club.setServiceProviderId(serviceProvider.getServiceProviderId());
|
|
|
+ // 待扫描
|
|
|
+ club.setAddTime(current);
|
|
|
+ /*
|
|
|
+ 保存数据库 club
|
|
|
+ */
|
|
|
+ registerMapper.insertClub(club);
|
|
|
+ /*
|
|
|
+ * 操作成功,推送短信给机构,获取账号密码。
|
|
|
+ * 协销去后台审核,机构用账号密码登录绑定微信
|
|
|
+ */
|
|
|
+ // 发送短信
|
|
|
+ if (StringUtils.isBlank(onlineDto.getContractEmail())) {
|
|
|
+ //普通机构
|
|
|
+ boolean smsFlag = AliyunSmsUtil.sendSms(mobile, 7, "{name:"+ mobile +",password:"+ initPassword +"}");
|
|
|
+ if (!smsFlag) {
|
|
|
+ // 短信发送失败重试一次
|
|
|
+ AliyunSmsUtil.sendSms(mobile, 7, "{name:"+ mobile +",password:"+ initPassword +"}");
|
|
|
+ }
|
|
|
+ // 打印短信内容
|
|
|
+ log.info(">>>短信内容:" + String.format(mailTxt, mobile, initPassword));
|
|
|
+ } else {
|
|
|
+ // 会员机构
|
|
|
+ boolean smsFlag = AliyunSmsUtil.sendSms(mobile, 6, "{name:"+ mobile +",password:"+ initPassword +"}");
|
|
|
+ if (!smsFlag) {
|
|
|
+ // 短信发送失败重试一次
|
|
|
+ AliyunSmsUtil.sendSms(mobile, 6, "{name:"+ mobile +",password:"+ initPassword +"}");
|
|
|
+ }
|
|
|
+ // 打印短信内容
|
|
|
+ log.info(">>>短信内容:" + String.format(memberMailTxt, mobile, initPassword));
|
|
|
+ }
|
|
|
+ // 返回状态
|
|
|
+ return ResponseJson.success(club);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 供应商注册
|
|
|
*
|
|
@@ -447,7 +617,7 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
// 绑定手机号
|
|
|
shop.setContractMobile(shopRegisterDto.getBindMobile());
|
|
|
// 绑定邮箱
|
|
|
- shop.setContractEmail1(shopRegisterDto.getEmail());
|
|
|
+ shop.setContractEmail(shopRegisterDto.getEmail());
|
|
|
// 绑定地址
|
|
|
shop.setProvinceId(shopRegisterDto.getProvinceId());
|
|
|
shop.setCityId(shopRegisterDto.getCityId());
|