|
@@ -3,22 +3,11 @@ package com.caimei365.user.service.impl;
|
|
import com.caimei365.user.components.RedisService;
|
|
import com.caimei365.user.components.RedisService;
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
import com.caimei365.user.mapper.RegisterMapper;
|
|
import com.caimei365.user.mapper.RegisterMapper;
|
|
-import com.caimei365.user.model.ResponseJson;
|
|
|
|
-import com.caimei365.user.model.po.ShopPo;
|
|
|
|
-import com.caimei365.user.model.po.UserPo;
|
|
|
|
import com.caimei365.user.service.ShopService;
|
|
import com.caimei365.user.service.ShopService;
|
|
-import com.caimei365.user.utils.Md5Util;
|
|
|
|
-import com.caimei365.user.utils.RequestUtil;
|
|
|
|
-import com.caimei365.user.utils.ValidateUtil;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
-import org.springframework.web.server.ServerWebExchange;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
-import java.util.Date;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Description
|
|
* Description
|
|
@@ -37,232 +26,4 @@ public class ShopServiceImpl implements ShopService {
|
|
@Resource
|
|
@Resource
|
|
private RegisterMapper registerMapper;
|
|
private RegisterMapper registerMapper;
|
|
|
|
|
|
- /**
|
|
|
|
- * PC端供应商注册
|
|
|
|
- *
|
|
|
|
- * @param source 注册来源: 0网站 1小程序
|
|
|
|
- * @param name 组织名称
|
|
|
|
- * @param sName 供应商公司简称(旧:sname)
|
|
|
|
- * @param bindMobile 企业绑定手机号
|
|
|
|
- * @param email 邮箱
|
|
|
|
- * @param smsCode 手机验证码(旧:mobileCode)
|
|
|
|
- * @param password 密码
|
|
|
|
- * @param passWordConfirm 用户确认密码
|
|
|
|
- * @param linkMan 联系人
|
|
|
|
- * @param provinceId 省(旧:provinceID)
|
|
|
|
- * @param cityId 市(旧:cityID)
|
|
|
|
- * @param townId 所在县区Id(旧:townID)
|
|
|
|
- * @param address 地址
|
|
|
|
- * @param socialCreditCode 统一社会信用代码
|
|
|
|
- * @param businessLicenseImage 营业执照
|
|
|
|
- * @param firstShopType 医疗=1和非医疗=2
|
|
|
|
- * @param secondShopType 医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
|
|
|
|
- * @param mainPro 主打项目(旧:mainpro)
|
|
|
|
- * @param isAgreed 是否同意勾选同意协议,1是,其他否
|
|
|
|
- * @param serverWebExchange ServerWebExchange(新参数)
|
|
|
|
- * @return BaseUser
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public ResponseJson register(Integer source, String name, String sName, String bindMobile, String email, String smsCode, String password, String passWordConfirm, String linkMan, Integer provinceId, Integer cityId, Integer townId, String address, String socialCreditCode, String businessLicenseImage, String firstShopType, String secondShopType, String mainPro, Integer isAgreed, HttpHeaders headers) {
|
|
|
|
- // 打印IP
|
|
|
|
- String ip = headers.getFirst("X-CLIENT-IP");
|
|
|
|
- log.info("X-Forwarded-For:" + ip);
|
|
|
|
- // 参数校验
|
|
|
|
- if (StringUtils.isBlank(name) || StringUtils.isBlank(bindMobile)
|
|
|
|
- || StringUtils.isBlank(password) || StringUtils.isBlank(passWordConfirm)
|
|
|
|
- || StringUtils.isBlank(smsCode) || StringUtils.isBlank(linkMan)) {
|
|
|
|
- return ResponseJson.error("参数异常", null);
|
|
|
|
- }
|
|
|
|
- ResponseJson model = ValidateUtil.validateMobile(bindMobile);
|
|
|
|
- if (model.getCode() == -1) {
|
|
|
|
- return model;
|
|
|
|
- }
|
|
|
|
- if (!password.equals(passWordConfirm)) {
|
|
|
|
- return ResponseJson.error("输入的密码不一致", null);
|
|
|
|
- }
|
|
|
|
- if (1 != isAgreed) {
|
|
|
|
- return ResponseJson.error("请勾选同意协议", null);
|
|
|
|
- }
|
|
|
|
- // 查找用户表是否存在
|
|
|
|
- Integer dbUserId = baseMapper.getUserIdByMobile(bindMobile);
|
|
|
|
- if (null != dbUserId && dbUserId > 0) {
|
|
|
|
- return ResponseJson.error("该手机号已被使用", null);
|
|
|
|
- }
|
|
|
|
- // 查找运营人员表是否存在
|
|
|
|
- Integer dbOperationId = baseMapper.getOperationIdByMobile(bindMobile);
|
|
|
|
- if (null != dbOperationId && dbOperationId > 0) {
|
|
|
|
- return ResponseJson.error("您已是机构运营人员,无需再注册机构", null);
|
|
|
|
- }
|
|
|
|
- String redisSmsCode = (String) redisService.get("code:" + bindMobile);
|
|
|
|
- if (redisSmsCode.equals(smsCode)) {
|
|
|
|
- return ResponseJson.error("手机验证码错误", null);
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(email)) {
|
|
|
|
- dbUserId = baseMapper.getUserIdByEmail(email);
|
|
|
|
- if (null != dbUserId && dbUserId > 0) {
|
|
|
|
- return ResponseJson.error("该邮箱已被使用", null);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- /*
|
|
|
|
- 组装用户数据 user
|
|
|
|
- */
|
|
|
|
- UserPo user = new UserPo();
|
|
|
|
- // 设置日期时间格式
|
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
- String current = dateFormat.format(new Date());
|
|
|
|
- // 注册时间
|
|
|
|
- user.setRegisterTime(current);
|
|
|
|
- // 注册IP
|
|
|
|
- user.setRegisterIp(ip);
|
|
|
|
- // 注册来源: 0网站 1小程序
|
|
|
|
- user.setSource(source);
|
|
|
|
- // 密码
|
|
|
|
- user.setPassword(Md5Util.md5(password));
|
|
|
|
- // 用户类型,供应商1,会员机构3,普通机构4
|
|
|
|
- user.setRegisterUserTypeId(1);
|
|
|
|
- // 组织名称
|
|
|
|
- user.setName(name);
|
|
|
|
- user.setUserName(sName);
|
|
|
|
- // 绑定手机号
|
|
|
|
- user.setBindMobile(bindMobile);
|
|
|
|
- // 绑定邮箱
|
|
|
|
- user.setEmail(email);
|
|
|
|
- // 用户身份: 1协销 2会员机构 3供应商 4普通机构
|
|
|
|
- user.setUserIdentity(3);
|
|
|
|
- // 用户权限: 2会员机构 3供应商 4协销 5普通机构
|
|
|
|
- user.setUserPermission(3);
|
|
|
|
- // 供应商状态:90:已上线,91:已下线,92:审核不通过,3:待审核
|
|
|
|
- user.setManufacturerStatus(3);
|
|
|
|
- // 用户状态,1正常,0冻结
|
|
|
|
- user.setValidFlag(1);
|
|
|
|
- // 同意协议
|
|
|
|
- user.setAgreeFlag(isAgreed);
|
|
|
|
- registerMapper.insertShopUser(user);
|
|
|
|
- /*
|
|
|
|
- 组装供应商数据 shop
|
|
|
|
- */
|
|
|
|
- ShopPo shop = new ShopPo();
|
|
|
|
- // 绑定用户ID
|
|
|
|
- shop.setUserId(user.getUserId());
|
|
|
|
- // 供应商公司名称
|
|
|
|
- shop.setName(name);
|
|
|
|
- // 供应商公司简称
|
|
|
|
- shop.setSName(sName);
|
|
|
|
- // 联系人
|
|
|
|
- shop.setLinkMan(linkMan);
|
|
|
|
- shop.setLinkMan1(linkMan);
|
|
|
|
- shop.setLinkMan2(linkMan);
|
|
|
|
- // 绑定手机号
|
|
|
|
- shop.setContractMobile(bindMobile);
|
|
|
|
- shop.setContractMobile1(bindMobile);
|
|
|
|
- shop.setContractMobile2(bindMobile);
|
|
|
|
- // 绑定邮箱
|
|
|
|
- shop.setContractEmail1(email);
|
|
|
|
- shop.setContractEmail2(email);
|
|
|
|
- // 绑定地址
|
|
|
|
- shop.setProvinceId(provinceId);
|
|
|
|
- shop.setCityId(cityId);
|
|
|
|
- shop.setTownId(townId);
|
|
|
|
- shop.setAddress(address);
|
|
|
|
- // 统一社会信用代码
|
|
|
|
- shop.setSocialCreditCode(socialCreditCode);
|
|
|
|
- // 营业执照
|
|
|
|
- shop.setBusinessLicenseImage(businessLicenseImage);
|
|
|
|
- // 医疗=1和非医疗=2
|
|
|
|
- shop.setFirstShopType(firstShopType);
|
|
|
|
- // 医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
|
|
|
|
- shop.setSecondShopType(secondShopType);
|
|
|
|
- // 主打项目
|
|
|
|
- shop.setMainPro(mainPro);
|
|
|
|
- // 添加时间
|
|
|
|
- shop.setAddTime(current);
|
|
|
|
- // 是否可用,1可用
|
|
|
|
- shop.setValidFlag("1");
|
|
|
|
- // 供应商:90:已上线,91:已下线,92:审核不通过,3:待审核
|
|
|
|
- shop.setStatus(3);
|
|
|
|
- /*
|
|
|
|
- 保存数据库 shop
|
|
|
|
- */
|
|
|
|
- int insertShopFlag = registerMapper.insertShop(shop);
|
|
|
|
- if (insertShopFlag < 1) {
|
|
|
|
- log.info(shop.getUserId() + " 插入数据库异常shop:" + shop.toString());
|
|
|
|
- return ResponseJson.error("插入数据库异常", null);
|
|
|
|
- }
|
|
|
|
- // user更新shopId
|
|
|
|
- user.setShopId(shop.getShopId());
|
|
|
|
- registerMapper.updateUserShopId(user.getUserId(), shop.getShopId());
|
|
|
|
- log.info("注册供应商---------userID:" + user.getUserId());
|
|
|
|
- return ResponseJson.success();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 小程序端分步供应商注册
|
|
|
|
- *
|
|
|
|
- * @param source 注册来源: 0网站 1小程序
|
|
|
|
- * @param name 组织名称
|
|
|
|
- * @param sName 供应商公司简称(旧:sname)
|
|
|
|
- * @param bindMobile 企业绑定手机号
|
|
|
|
- * @param email 邮箱
|
|
|
|
- * @param smsCode 手机验证码(旧:mobileCode)
|
|
|
|
- * @param password 密码
|
|
|
|
- * @param passWordConfirm 用户确认密码
|
|
|
|
- * @param linkMan 联系人
|
|
|
|
- * @param provinceId 省(旧:provinceID)
|
|
|
|
- * @param cityId 市(旧:cityID)
|
|
|
|
- * @param townId 所在县区Id(旧:townID)
|
|
|
|
- * @param address 地址
|
|
|
|
- * @param socialCreditCode 统一社会信用代码
|
|
|
|
- * @param businessLicenseImage 营业执照
|
|
|
|
- * @param firstShopType 医疗=1和非医疗=2
|
|
|
|
- * @param secondShopType 医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
|
|
|
|
- * @param mainPro 主打项目(旧:mainpro)
|
|
|
|
- * @param isAgreed 是否同意勾选同意协议,1是,其他否
|
|
|
|
- * @param serverWebExchange ServerWebExchange(新参数)
|
|
|
|
- * @param whichStep 注册步数
|
|
|
|
- * @return BaseUser
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public ResponseJson appletsRegister(Integer source, String name, String sName, String bindMobile, String email, String smsCode, String password, String passWordConfirm, String linkMan, Integer provinceId, Integer cityId, Integer townId, String address, String socialCreditCode, String businessLicenseImage, String firstShopType, String secondShopType, String mainPro, Integer isAgreed, Integer whichStep, HttpHeaders headers) {
|
|
|
|
- // 参数校验
|
|
|
|
- if (1 == whichStep) {
|
|
|
|
- if (StringUtils.isBlank(bindMobile) || StringUtils.isBlank(password)
|
|
|
|
- || StringUtils.isBlank(smsCode) || StringUtils.isBlank(password)
|
|
|
|
- || StringUtils.isBlank(passWordConfirm)) {
|
|
|
|
- return ResponseJson.error("参数异常");
|
|
|
|
- }
|
|
|
|
- if (!password.equals(passWordConfirm)) {
|
|
|
|
- return ResponseJson.error("两次输入的密码不一致");
|
|
|
|
- }
|
|
|
|
- // 查找用户表是否存在
|
|
|
|
- Integer dbUserId = baseMapper.getUserIdByMobile(bindMobile);
|
|
|
|
- if (null != dbUserId && dbUserId > 0) {
|
|
|
|
- return ResponseJson.error("该手机号已被使用", null);
|
|
|
|
- }
|
|
|
|
- // 查找运营人员表是否存在
|
|
|
|
- Integer dbOperationId = baseMapper.getOperationIdByMobile(bindMobile);
|
|
|
|
- if (null != dbOperationId && dbOperationId > 0) {
|
|
|
|
- return ResponseJson.error("您已是机构运营人员,无需再注册机构", null);
|
|
|
|
- }
|
|
|
|
- String redisSmsCode = (String) redisService.get("code:" + bindMobile);
|
|
|
|
- if (redisSmsCode.equals(smsCode)) {
|
|
|
|
- return ResponseJson.error("手机验证码错误", null);
|
|
|
|
- }
|
|
|
|
- return ResponseJson.success();
|
|
|
|
- } else if (2 == whichStep) {
|
|
|
|
- if (StringUtils.isBlank(name) || StringUtils.isBlank(linkMan)) {
|
|
|
|
- return ResponseJson.error("参数异常");
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(email)) {
|
|
|
|
- // 查找用户表是否存在相同邮箱
|
|
|
|
- Integer dbUserId = baseMapper.getUserIdByEmail(email);
|
|
|
|
- if (null != dbUserId && dbUserId > 0) {
|
|
|
|
- return ResponseJson.error("该邮箱已被使用", null);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return ResponseJson.success();
|
|
|
|
- } else if (1 != isAgreed) {
|
|
|
|
- return ResponseJson.error("请勾选同意协议");
|
|
|
|
- }
|
|
|
|
- return register(source, name, sName, bindMobile, email, smsCode, password, passWordConfirm, linkMan, provinceId, cityId, townId, address, socialCreditCode, businessLicenseImage, firstShopType, secondShopType, mainPro, isAgreed, headers);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|