|
@@ -6,18 +6,25 @@ import com.caimei365.user.mapper.RegisterMapper;
|
|
import com.caimei365.user.model.ResponseJson;
|
|
import com.caimei365.user.model.ResponseJson;
|
|
import com.caimei365.user.model.dto.ClubRegisterDto;
|
|
import com.caimei365.user.model.dto.ClubRegisterDto;
|
|
import com.caimei365.user.model.dto.ClubUpgradeDto;
|
|
import com.caimei365.user.model.dto.ClubUpgradeDto;
|
|
|
|
+import com.caimei365.user.model.dto.ShopRegisterDto;
|
|
import com.caimei365.user.model.po.ClubPo;
|
|
import com.caimei365.user.model.po.ClubPo;
|
|
import com.caimei365.user.model.po.OperationPo;
|
|
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.po.UserPo;
|
|
import com.caimei365.user.service.RegisterService;
|
|
import com.caimei365.user.service.RegisterService;
|
|
import com.caimei365.user.components.RedisService;
|
|
import com.caimei365.user.components.RedisService;
|
|
import com.caimei365.user.utils.AliyunSmsUtil;
|
|
import com.caimei365.user.utils.AliyunSmsUtil;
|
|
import com.caimei365.user.utils.Md5Util;
|
|
import com.caimei365.user.utils.Md5Util;
|
|
|
|
+import com.caimei365.user.utils.ValidateUtil;
|
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
@@ -337,5 +344,240 @@ public class RegisterServiceImpl implements RegisterService {
|
|
registerMapper.updateClubByUpgrade(club);
|
|
registerMapper.updateClubByUpgrade(club);
|
|
return ResponseJson.success(club);
|
|
return ResponseJson.success(club);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * PC端供应商注册
|
|
|
|
+ *
|
|
|
|
+ * @param shopRegisterDto ShopRegisterDto{
|
|
|
|
+ * source 注册来源: 0网站 1小程序
|
|
|
|
+ * name 组织名称
|
|
|
|
+ * sName 供应商公司简称(sname)
|
|
|
|
+ * bindMobile 企业绑定手机号
|
|
|
|
+ * email 邮箱
|
|
|
|
+ * password 密码
|
|
|
|
+ * linkMan 联系人
|
|
|
|
+ * provinceId 省(provinceID)
|
|
|
|
+ * cityId 市(cityID)
|
|
|
|
+ * townId 所在县区Id(townID)
|
|
|
|
+ * address 地址
|
|
|
|
+ * socialCreditCode 统一社会信用代码
|
|
|
|
+ * businessLicenseImage 营业执照
|
|
|
|
+ * firstShopType 医疗=1和非医疗=2
|
|
|
|
+ * secondShopType 医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
|
|
|
|
+ * mainPro 主打项目(mainpro)
|
|
|
|
+ * }
|
|
|
|
+ * @param passWordConfirm 用户确认密码
|
|
|
|
+ * @param smsCode 短信验证码(旧:activationCode)
|
|
|
|
+ * @param isAgreed 是否同意勾选同意协议,1是,其他否
|
|
|
|
+ * @param headers HttpHeaders
|
|
|
|
+ * @return ShopPo
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<ShopPo> shopRegister(ShopRegisterDto shopRegisterDto, String passWordConfirm, String smsCode, Integer isAgreed, HttpHeaders headers) {
|
|
|
|
+ // 打印IP
|
|
|
|
+ String ip = headers.getFirst("X-CLIENT-IP");
|
|
|
|
+ log.info("X-Forwarded-For:" + ip);
|
|
|
|
+ // 参数校验
|
|
|
|
+ if (StringUtils.isBlank(shopRegisterDto.getName()) || StringUtils.isBlank(shopRegisterDto.getBindMobile())
|
|
|
|
+ || StringUtils.isBlank(shopRegisterDto.getPassword()) || StringUtils.isBlank(passWordConfirm)
|
|
|
|
+ || StringUtils.isBlank(smsCode) || StringUtils.isBlank(shopRegisterDto.getLinkMan())) {
|
|
|
|
+ return ResponseJson.error("参数异常", null);
|
|
|
|
+ }
|
|
|
|
+ ResponseJson model = ValidateUtil.validateMobile(shopRegisterDto.getBindMobile());
|
|
|
|
+ if (model.getCode() == -1) {
|
|
|
|
+ return model;
|
|
|
|
+ }
|
|
|
|
+ if (!shopRegisterDto.getPassword().equals(passWordConfirm)) {
|
|
|
|
+ return ResponseJson.error("输入的密码不一致", null);
|
|
|
|
+ }
|
|
|
|
+ if (1 != isAgreed) {
|
|
|
|
+ return ResponseJson.error("请勾选同意协议", null);
|
|
|
|
+ }
|
|
|
|
+ // 查找用户表是否存在
|
|
|
|
+ Integer dbUserId = baseMapper.getUserIdByMobile(shopRegisterDto.getBindMobile());
|
|
|
|
+ if (null != dbUserId && dbUserId > 0) {
|
|
|
|
+ return ResponseJson.error("该手机号已被使用", null);
|
|
|
|
+ }
|
|
|
|
+ // 查找运营人员表是否存在
|
|
|
|
+ Integer dbOperationId = baseMapper.getOperationIdByMobile(shopRegisterDto.getBindMobile());
|
|
|
|
+ if (null != dbOperationId && dbOperationId > 0) {
|
|
|
|
+ return ResponseJson.error("您已是机构运营人员,无需再注册机构", null);
|
|
|
|
+ }
|
|
|
|
+ String redisSmsCode = (String) redisService.get("code:" + shopRegisterDto.getBindMobile());
|
|
|
|
+ if (!redisSmsCode.equals(smsCode)) {
|
|
|
|
+ return ResponseJson.error("手机验证码错误", null);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(shopRegisterDto.getEmail())) {
|
|
|
|
+ dbUserId = baseMapper.getUserIdByEmail(shopRegisterDto.getEmail());
|
|
|
|
+ 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(shopRegisterDto.getSource());
|
|
|
|
+ // 密码
|
|
|
|
+ user.setPassword(Md5Util.md5(shopRegisterDto.getPassword()));
|
|
|
|
+ // 用户类型,供应商1,会员机构3,普通机构4
|
|
|
|
+ user.setRegisterUserTypeId(1);
|
|
|
|
+ // 组织名称
|
|
|
|
+ user.setName(shopRegisterDto.getName());
|
|
|
|
+ user.setUserName(shopRegisterDto.getSName());
|
|
|
|
+ // 绑定手机号
|
|
|
|
+ user.setBindMobile(shopRegisterDto.getBindMobile());
|
|
|
|
+ // 绑定邮箱
|
|
|
|
+ user.setEmail(shopRegisterDto.getEmail());
|
|
|
|
+ // 用户身份: 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(shopRegisterDto.getName());
|
|
|
|
+ // 供应商公司简称
|
|
|
|
+ shop.setSName(shopRegisterDto.getSName());
|
|
|
|
+ // 联系人
|
|
|
|
+ shop.setLinkMan(shopRegisterDto.getLinkMan());
|
|
|
|
+ shop.setLinkMan1(shopRegisterDto.getLinkMan());
|
|
|
|
+ shop.setLinkMan2(shopRegisterDto.getLinkMan());
|
|
|
|
+ // 绑定手机号
|
|
|
|
+ shop.setContractMobile(shopRegisterDto.getBindMobile());
|
|
|
|
+ shop.setContractMobile1(shopRegisterDto.getBindMobile());
|
|
|
|
+ shop.setContractMobile2(shopRegisterDto.getBindMobile());
|
|
|
|
+ // 绑定邮箱
|
|
|
|
+ shop.setContractEmail1(shopRegisterDto.getEmail());
|
|
|
|
+ shop.setContractEmail2(shopRegisterDto.getEmail());
|
|
|
|
+ // 绑定地址
|
|
|
|
+ shop.setProvinceId(shopRegisterDto.getProvinceId());
|
|
|
|
+ shop.setCityId(shopRegisterDto.getCityId());
|
|
|
|
+ shop.setTownId(shopRegisterDto.getTownId());
|
|
|
|
+ shop.setAddress(shopRegisterDto.getAddress());
|
|
|
|
+ // 统一社会信用代码
|
|
|
|
+ shop.setSocialCreditCode(shopRegisterDto.getSocialCreditCode());
|
|
|
|
+ // 营业执照
|
|
|
|
+ shop.setBusinessLicenseImage(shopRegisterDto.getBusinessLicenseImage());
|
|
|
|
+ // 医疗=1和非医疗=2
|
|
|
|
+ shop.setFirstShopType(shopRegisterDto.getFirstShopType());
|
|
|
|
+ // 医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
|
|
|
|
+ shop.setSecondShopType(shopRegisterDto.getSecondShopType());
|
|
|
|
+ // 主打项目
|
|
|
|
+ shop.setMainPro(shopRegisterDto.getMainPro());
|
|
|
|
+ // 添加时间
|
|
|
|
+ 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(shop);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 小程序端分步供应商注册
|
|
|
|
+ *
|
|
|
|
+ * @param shopRegisterDto ShopRegisterDto{
|
|
|
|
+ * source 注册来源: 0网站 1小程序
|
|
|
|
+ * name 组织名称
|
|
|
|
+ * sName 供应商公司简称(sname)
|
|
|
|
+ * bindMobile 企业绑定手机号
|
|
|
|
+ * email 邮箱
|
|
|
|
+ * password 密码
|
|
|
|
+ * linkMan 联系人
|
|
|
|
+ * provinceId 省(provinceID)
|
|
|
|
+ * cityId 市(cityID)
|
|
|
|
+ * townId 所在县区Id(townID)
|
|
|
|
+ * address 地址
|
|
|
|
+ * socialCreditCode 统一社会信用代码
|
|
|
|
+ * businessLicenseImage 营业执照
|
|
|
|
+ * firstShopType 医疗=1和非医疗=2
|
|
|
|
+ * secondShopType 医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
|
|
|
|
+ * mainPro 主打项目(mainpro)
|
|
|
|
+ * }
|
|
|
|
+ * @param passWordConfirm 用户确认密码
|
|
|
|
+ * @param smsCode 短信验证码(旧:activationCode)
|
|
|
|
+ * @param isAgreed 是否同意勾选同意协议,1是,其他否
|
|
|
|
+ * @param whichStep 注册步数
|
|
|
|
+ * @param headers HttpHeaders
|
|
|
|
+ * @return ShopPo
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<ShopPo> shopAppletsRegister(ShopRegisterDto shopRegisterDto, String passWordConfirm, String smsCode, Integer isAgreed, Integer whichStep, HttpHeaders headers) {
|
|
|
|
+ // 参数校验
|
|
|
|
+ if (1 == whichStep) {
|
|
|
|
+ if (StringUtils.isBlank(shopRegisterDto.getBindMobile()) || StringUtils.isBlank(shopRegisterDto.getPassword())
|
|
|
|
+ || StringUtils.isBlank(smsCode) || StringUtils.isBlank(shopRegisterDto.getPassword())
|
|
|
|
+ || StringUtils.isBlank(passWordConfirm)) {
|
|
|
|
+ return ResponseJson.error("参数异常");
|
|
|
|
+ }
|
|
|
|
+ if (!shopRegisterDto.getPassword() .equals(passWordConfirm)) {
|
|
|
|
+ return ResponseJson.error("两次输入的密码不一致");
|
|
|
|
+ }
|
|
|
|
+ // 查找用户表是否存在
|
|
|
|
+ Integer dbUserId = baseMapper.getUserIdByMobile(shopRegisterDto.getBindMobile());
|
|
|
|
+ if (null != dbUserId && dbUserId > 0) {
|
|
|
|
+ return ResponseJson.error("该手机号已被使用", null);
|
|
|
|
+ }
|
|
|
|
+ // 查找运营人员表是否存在
|
|
|
|
+ Integer dbOperationId = baseMapper.getOperationIdByMobile(shopRegisterDto.getBindMobile());
|
|
|
|
+ if (null != dbOperationId && dbOperationId > 0) {
|
|
|
|
+ return ResponseJson.error("您已是机构运营人员,无需再注册机构", null);
|
|
|
|
+ }
|
|
|
|
+ String redisSmsCode = (String) redisService.get("code:" + shopRegisterDto.getBindMobile());
|
|
|
|
+ if (!redisSmsCode.equals(smsCode)) {
|
|
|
|
+ return ResponseJson.error("手机验证码错误", null);
|
|
|
|
+ }
|
|
|
|
+ return ResponseJson.success();
|
|
|
|
+ } else if (2 == whichStep) {
|
|
|
|
+ if (StringUtils.isBlank(shopRegisterDto.getName()) || StringUtils.isBlank(shopRegisterDto.getLinkMan())) {
|
|
|
|
+ return ResponseJson.error("参数异常");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(shopRegisterDto.getEmail())) {
|
|
|
|
+ // 查找用户表是否存在相同邮箱
|
|
|
|
+ Integer dbUserId = baseMapper.getUserIdByEmail(shopRegisterDto.getEmail());
|
|
|
|
+ if (null != dbUserId && dbUserId > 0) {
|
|
|
|
+ return ResponseJson.error("该邮箱已被使用", null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return ResponseJson.success();
|
|
|
|
+ } else if (1 != isAgreed) {
|
|
|
|
+ return ResponseJson.error("请勾选同意协议");
|
|
|
|
+ }
|
|
|
|
+ return shopRegister(shopRegisterDto, passWordConfirm, smsCode, isAgreed, headers);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|