|
@@ -2,12 +2,23 @@ package com.caimei365.user.service.impl;
|
|
|
|
|
|
import com.caimei365.user.mapper.BaseUserDao;
|
|
|
import com.caimei365.user.mapper.RegisterUserDao;
|
|
|
+import com.caimei365.user.model.BaseUser;
|
|
|
+import com.caimei365.user.model.JsonModel;
|
|
|
+import com.caimei365.user.model.OperationVo;
|
|
|
+import com.caimei365.user.model.UserPo;
|
|
|
import com.caimei365.user.service.RedisService;
|
|
|
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 org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.server.ServerWebExchange;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -26,7 +37,96 @@ public class ShopServiceImpl implements ShopService {
|
|
|
@Resource
|
|
|
private RegisterUserDao registerUserDao;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ /**
|
|
|
+ * PC端供应商注册
|
|
|
+ *
|
|
|
+ * @param source 注册来源: 0网站 1小程序
|
|
|
+ * @param name 供应商公司名称
|
|
|
+ * @param sname 供应商公司简称
|
|
|
+ * @param bindMobile 企业绑定手机号
|
|
|
+ * @param email 邮箱
|
|
|
+ * @param smsCode 手机验证码(旧:mobileCode)
|
|
|
+ * @param password 密码
|
|
|
+ * @param passWordConfirm 用户确认密码
|
|
|
+ * @param linkMan 联系人
|
|
|
+ * @param provinceID 省
|
|
|
+ * @param cityID 市
|
|
|
+ * @param townID 所在县区Id
|
|
|
+ * @param address 地址
|
|
|
+ * @param socialCreditCode 统一社会信用代码
|
|
|
+ * @param businessLicenseImage 营业执照
|
|
|
+ * @param firstShopType 医疗=1和非医疗=2
|
|
|
+ * @param secondShopType 医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
|
|
|
+ * @param mainpro 主打项目
|
|
|
+ * @param isAgreed 是否同意勾选同意协议,1是,其他否
|
|
|
+ * @param serverWebExchange ServerWebExchange(新参数)
|
|
|
+ * @return BaseUser
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public JsonModel<BaseUser> pcRegister(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, ServerWebExchange serverWebExchange) {
|
|
|
+ // 打印IP
|
|
|
+ String ip = RequestUtil.getIp(serverWebExchange);
|
|
|
+ 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 JsonModel.error("参数异常", null);
|
|
|
+ }
|
|
|
+ JsonModel model = ValidateUtil.validateMobile(bindMobile);
|
|
|
+ if (model.getCode() == -1) {
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+ if (!password.equals(passWordConfirm)) {
|
|
|
+ return JsonModel.error("输入的密码不一致", null);
|
|
|
+ }
|
|
|
+ if (1 != isAgreed) {
|
|
|
+ return JsonModel.error("请勾选同意协议", null);
|
|
|
+ }
|
|
|
+ // 查找用户表是否存在
|
|
|
+ Integer dbUserId = baseUserDao.getUserIdByMobile(bindMobile);
|
|
|
+ if (dbUserId > 0) {
|
|
|
+ return JsonModel.error("该手机号已被使用", null);
|
|
|
+ }
|
|
|
+ // 查找运营人员表是否存在
|
|
|
+ Integer dbOperationId = baseUserDao.getOperationIdByMobile(bindMobile);
|
|
|
+ if (dbOperationId > 0) {
|
|
|
+ return JsonModel.error("您已是机构运营人员,无需再注册机构", null);
|
|
|
+ }
|
|
|
+ String redisSmsCode = (String) redisService.get("code:" + bindMobile);
|
|
|
+ if (redisSmsCode.equals(smsCode)) {
|
|
|
+ return JsonModel.error("手机验证码错误", null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(email)) {
|
|
|
+ dbUserId = baseUserDao.getUserIdByEmail(email);
|
|
|
+ if (dbUserId > 0) {
|
|
|
+ return JsonModel.error("该邮箱已被使用", null);
|
|
|
+ }
|
|
|
+/* shop.setContractEmail1(user.getEmail());
|
|
|
+ shop.setContractEmail2(user.getEmail());*/
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ 组装用户数据 user
|
|
|
+ */
|
|
|
+ UserPo user = new UserPo();
|
|
|
+ // 设置日期时间格式
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String current = dateFormat.format(new Date());
|
|
|
+ // 密码
|
|
|
+ user.setPassword(Md5Util.md5(password));
|
|
|
+ // 注册IP
|
|
|
+ user.setRegisterIp(ip);
|
|
|
+ // 用户类型,供应商1,会员机构3,普通机构4
|
|
|
+ user.setRegisterUserTypeId(1);
|
|
|
+ user.setUserIdentity(3);
|
|
|
+ user.setUserPermission(3);
|
|
|
+ user.setRegisterTime(current);
|
|
|
+ user.setUserName(sname);
|
|
|
+ //待审查资料
|
|
|
+ user.setManufacturerStatus(3);
|
|
|
+ user.setValidFlag(1);
|
|
|
+ user.setAgreeFlag(1);
|
|
|
+ registerUserDao.insertShopUser(user);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|