Browse Source

dto调整

chao 4 years ago
parent
commit
fd1623e7bb

+ 1 - 7
src/main/java/com/caimei365/user/configuration/SwaggerConfig.java → src/main/java/com/caimei365/user/config/SwaggerConfig.java

@@ -1,6 +1,5 @@
-package com.caimei365.user.configuration;
+package com.caimei365.user.config;
 
 
-import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
@@ -9,12 +8,7 @@ import springfox.documentation.builders.PathSelectors;
 import springfox.documentation.builders.RequestHandlerSelectors;
 import springfox.documentation.builders.RequestHandlerSelectors;
 import springfox.documentation.service.*;
 import springfox.documentation.service.*;
 import springfox.documentation.spi.DocumentationType;
 import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spi.service.contexts.SecurityContext;
 import springfox.documentation.spring.web.plugins.Docket;
 import springfox.documentation.spring.web.plugins.Docket;
-import static com.google.common.collect.Lists.newArrayList;
-
-import java.util.ArrayList;
-import java.util.List;
 
 
 /**
 /**
  * @author Aslee
  * @author Aslee

+ 43 - 0
src/main/java/com/caimei365/user/config/WebConfiguration.java

@@ -0,0 +1,43 @@
+package com.caimei365.user.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.stereotype.Component;
+import org.springframework.web.reactive.config.WebFluxConfigurer;
+import org.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.WebFilter;
+import org.springframework.web.server.WebFilterChain;
+import reactor.core.publisher.Mono;
+
+import java.net.InetSocketAddress;
+import java.util.Objects;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/3/11
+ */
+@Configuration
+public class WebConfiguration implements WebFluxConfigurer {
+
+    /**
+     * https://stackoverflow.com/questions/51192630/how-do-you-get-clients-ip-address-spring-webflux-websocket?rq=1
+     * https://stackoverflow.com/questions/50981136/how-to-get-client-ip-in-webflux
+     * https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-filters
+     * 由于在低版本的 spring-webflux 中不支持直接获得请求 IP(https://jira.spring.io/browse/SPR-16681),
+     * 因此从org.springframework.web.server.ServerWebExchange中获得 IP 后,在放到 header 里
+     */
+    @Component
+    public static class RetrieveClientIpWebFilter implements WebFilter {
+        @Override
+        public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
+            InetSocketAddress remoteAddress = exchange.getRequest().getRemoteAddress();
+            String clientIp = Objects.requireNonNull(remoteAddress).getAddress().getHostAddress();
+            ServerHttpRequest mutatedServerHttpRequest = exchange.getRequest().mutate().header("X-CLIENT-IP", clientIp).build();
+            ServerWebExchange mutatedServerWebExchange = exchange.mutate().request(mutatedServerHttpRequest).build();
+            return chain.filter(mutatedServerWebExchange);
+        }
+    }
+}
+

+ 63 - 21
src/main/java/com/caimei365/user/controller/RegisterApi.java

@@ -2,13 +2,18 @@ package com.caimei365.user.controller;
 
 
 import com.caimei365.user.idempotent.Idempotent;
 import com.caimei365.user.idempotent.Idempotent;
 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.ClubUpgradeDto;
 import com.caimei365.user.model.po.ClubPo;
 import com.caimei365.user.model.po.ClubPo;
 import com.caimei365.user.service.RegisterService;
 import com.caimei365.user.service.RegisterService;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.server.reactive.ServerHttpRequest;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.server.ServerWebExchange;
+
 
 
 /**
 /**
  * 注册Api
  * 注册Api
@@ -25,33 +30,70 @@ public class RegisterApi {
     /**
     /**
      * 普通机构入驻(注册)
      * 普通机构入驻(注册)
      *
      *
-     * spi旧接口:club/common
+     * spi旧接口:/club/common
      *
      *
-     * @param source            注册来源: 0网站 1小程序
-     * @param userName          用户名
-     * @param bindMobile        企业绑定手机号
-     * @param password          密码
-     * @param passWordConfirm   用户确认密码
-     * @param smsCode           短信验证码(旧:activationCode)
-     * @param isAgreed          是否同意勾选同意协议,1是,其他否
-     * @param unionId           微信unionId
-     * @param nickName          微信昵称
-     * @param avatarUrl         微信头像(旧:headimgurl)
+     * @param clubRegisterDto ClubRegisterDto{
+     *                          source            注册来源: 0网站 1小程序
+     *                          userName          用户名
+     *                          bindMobile        企业绑定手机号
+     *                          password          密码
+     *                          unionId           微信unionId
+     *                          nickName          微信昵称
+     *                          avatarUrl         微信头像(旧:headimgurl)
+     *                        }
+     * @param passWordConfirm 用户确认密码
+     * @param smsCode         短信验证码(旧:activationCode)
+     * @param isAgreed        是否同意勾选同意协议,1是,其他否
+     * @param headers         HttpHeaders
+     * @return ClubPo
      */
      */
     @Idempotent(prefix="idempotent_club", keys={"#baseUser"}, expire=5)
     @Idempotent(prefix="idempotent_club", keys={"#baseUser"}, expire=5)
     @PostMapping("/club")
     @PostMapping("/club")
-    public ResponseJson<ClubPo> clubRegister(Integer source,
-                                             String userName,
-                                             String bindMobile,
-                                             String password,
+    public ResponseJson<ClubPo> clubRegister(ClubRegisterDto clubRegisterDto,
                                              String passWordConfirm,
                                              String passWordConfirm,
                                              String smsCode,
                                              String smsCode,
                                              Integer isAgreed,
                                              Integer isAgreed,
-                                             String unionId,
-                                             String nickName,
-                                             String avatarUrl,
-                                             ServerWebExchange serverWebExchange) {
-        return registerService.clubRegister(source, userName, bindMobile, password, passWordConfirm, smsCode, isAgreed, unionId, nickName, avatarUrl, serverWebExchange);
+                                             @RequestHeader HttpHeaders headers) {
+        return registerService.clubRegister(clubRegisterDto, passWordConfirm, smsCode, isAgreed, headers);
+    }
+
+    /**
+     * 普通机构升级会员机构
+     *
+     * spi旧接口:/club/upgrade
+     *
+     * @param upgradeDto ClubUpgradeDto:{
+     *                      clubId                 机构ID
+     *                      userId                 用户ID
+     *                      name                   机构名称
+     *                      sName                  机构简称
+     *                      contractEmail          邮箱(contractEmail1)
+     *                      contractPhone          固定电话
+     *                      linkMan                联系人(linkMan1)
+     *                      provinceId             省Id
+     *                      cityId                 市Id
+     *                      townId                 县区Id
+     *                      address                地址
+     *                      shopPhoto              门头照(headpic)
+     *                      businessLicense        营业执照(businessLicenseImage)
+     *                      socialCreditCode       统一社会信用代码(socialCreditCode)
+     *                      firstClubType          一级分类:医美=1和生美=2
+     *                      secondClubType         医美的二级分类:诊所=1、门诊=2、医院=3。  生美没有二级分类
+     *                      department             医美分类下的门诊和医院则需要填写科室
+     *                      medicalPracticeLicense 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
+     *                      mainProduct            主打项目(mainpro)
+     *                      fax                    传真
+     *                      profile                公司简介
+     *                  }
+     * @param headers   HttpHeaders
+     * @return ClubPo
+     */
+    @PostMapping("/club/upgrade")
+    public ResponseJson<ClubPo> clubUpgrade(ClubUpgradeDto upgradeDto, @RequestHeader HttpHeaders headers){
+        return registerService.clubUpgrade(upgradeDto, headers);
     }
     }
 
 
 }
 }
+
+
+

+ 6 - 6
src/main/java/com/caimei365/user/controller/ShopApi.java

@@ -6,8 +6,8 @@ import com.caimei365.user.service.ShopService;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpHeaders;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.server.ServerWebExchange;
 
 
 /**
 /**
  * Description
  * Description
@@ -69,8 +69,8 @@ public class ShopApi {
                                    String secondShopType,
                                    String secondShopType,
                                    String mainPro,
                                    String mainPro,
                                    Integer isAgreed,
                                    Integer isAgreed,
-                                   ServerWebExchange serverWebExchange) {
-        return shopService.register(source, name, sName, bindMobile, email, smsCode, password, passWordConfirm, linkMan, provinceId, cityId, townId, address, socialCreditCode, businessLicenseImage, firstShopType, secondShopType, mainPro, isAgreed, serverWebExchange);
+                                   @RequestHeader HttpHeaders headers) {
+        return shopService.register(source, name, sName, bindMobile, email, smsCode, password, passWordConfirm, linkMan, provinceId, cityId, townId, address, socialCreditCode, businessLicenseImage, firstShopType, secondShopType, mainPro, isAgreed, headers);
     }
     }
 
 
     /**
     /**
@@ -121,9 +121,9 @@ public class ShopApi {
                                         String secondShopType,
                                         String secondShopType,
                                         String mainPro,
                                         String mainPro,
                                         Integer isAgreed,
                                         Integer isAgreed,
-                                        ServerWebExchange serverWebExchange,
-                                        Integer whichStep) {
-        return shopService.appletsRegister(source, name, sName, bindMobile, email, smsCode, password, passWordConfirm, linkMan, provinceId, cityId, townId, address, socialCreditCode, businessLicenseImage, firstShopType, secondShopType, mainPro, isAgreed, serverWebExchange, whichStep);
+                                        Integer whichStep,
+                                        @RequestHeader HttpHeaders headers) {
+        return shopService.appletsRegister(source, name, sName, bindMobile, email, smsCode, password, passWordConfirm, linkMan, provinceId, cityId, townId, address, socialCreditCode, businessLicenseImage, firstShopType, secondShopType, mainPro, isAgreed, whichStep, headers);
     }
     }
 
 
     @GetMapping("/hello")
     @GetMapping("/hello")

+ 6 - 7
src/main/java/com/caimei365/user/mapper/LoginMapper.java

@@ -1,6 +1,7 @@
 package com.caimei365.user.mapper;
 package com.caimei365.user.mapper;
 
 
 import com.caimei365.user.model.po.OperationPo;
 import com.caimei365.user.model.po.OperationPo;
+import com.caimei365.user.model.po.UserPo;
 import com.caimei365.user.model.vo.UserLoginVo;
 import com.caimei365.user.model.vo.UserLoginVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
@@ -13,13 +14,6 @@ import org.apache.ibatis.annotations.Param;
  */
  */
 @Mapper
 @Mapper
 public interface LoginMapper {
 public interface LoginMapper {
-    /**
-     * 根据手机号获取用户
-     *
-     * @param mobile 手机号
-     * @return BaseUser
-     */
-    //BaseUser getBaseUserByMobile(@Param("mobile") String mobile);
     /**
     /**
      * 根据用户id获取用户
      * 根据用户id获取用户
      *
      *
@@ -34,6 +28,11 @@ public interface LoginMapper {
      * @return BaseUser
      * @return BaseUser
      */
      */
     UserLoginVo getLoginUserByMobileOrEmail(@Param("mobileOrEmail") String mobileOrEmail);
     UserLoginVo getLoginUserByMobileOrEmail(@Param("mobileOrEmail") String mobileOrEmail);
+    /**
+     * 根据用户Id查找用户
+     * @return
+     */
+    UserPo getUserByUserId(Integer userId);
     /**
     /**
      * 根据手机号获取运营人员
      * 根据手机号获取运营人员
      *
      *

+ 17 - 7
src/main/java/com/caimei365/user/mapper/RegisterMapper.java

@@ -32,13 +32,6 @@ public interface RegisterMapper {
      * @return
      * @return
      */
      */
     int insertOperation(OperationPo operation);
     int insertOperation(OperationPo operation);
-    /**
-     * 根据用户ID更新机构ID
-     *
-     * @param userId
-     * @param clubId
-     */
-    void updateUserClubId(Integer userId, Integer clubId);
     /**
     /**
      * 保存(供应商)用户(user)
      * 保存(供应商)用户(user)
      * @param user
      * @param user
@@ -51,6 +44,13 @@ public interface RegisterMapper {
      * @return
      * @return
      */
      */
     int insertShop(ShopPo shop);
     int insertShop(ShopPo shop);
+    /**
+     * 根据用户ID更新机构ID
+     *
+     * @param userId
+     * @param clubId
+     */
+    void updateUserClubId(Integer userId, Integer clubId);
     /**
     /**
      * 根据用户ID更新供应商ID
      * 根据用户ID更新供应商ID
      *
      *
@@ -58,4 +58,14 @@ public interface RegisterMapper {
      * @param shopId
      * @param shopId
      */
      */
     void updateUserShopId(Integer userId, Integer shopId);
     void updateUserShopId(Integer userId, Integer shopId);
+    /**
+     * 升级机构 更新user
+     * @param user
+     */
+    void updateClubUserByUpgrade(UserPo user);
+    /**
+     * 升级机构 更新club
+     * @param club
+     */
+    void updateClubByUpgrade(ClubPo club);
 }
 }

+ 43 - 0
src/main/java/com/caimei365/user/model/dto/ClubRegisterDto.java

@@ -0,0 +1,43 @@
+package com.caimei365.user.model.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/3/11
+ */
+@Data
+public class ClubRegisterDto implements Serializable {
+    /**
+     * 注册来源: 0网站 1小程序
+     */
+    private Integer source;
+    /**
+     * 用户名
+     */
+    private String userName;
+    /**
+     * 企业绑定手机号
+     */
+    private String bindMobile;
+    /**
+     * 密码
+     */
+    private String password;
+    /**
+     * 微信unionId
+     */
+    private String unionId;
+    /**
+     * 微信昵称
+     */
+    private String nickName;
+    /**
+     * 微信头像(headimgurl)
+     */
+    private String avatarUrl;
+}

+ 100 - 0
src/main/java/com/caimei365/user/model/dto/ClubUpgradeDto.java

@@ -0,0 +1,100 @@
+package com.caimei365.user.model.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/3/11
+ */
+@Data
+public class ClubUpgradeDto implements Serializable {
+    /**
+     * 机构ID
+     */
+    private Integer clubId;
+    /**
+     * 用户ID
+     */
+    private Integer userId;
+    /**
+     * 机构名称
+     */
+    private String name;
+    /**
+     * 机构简称
+     */
+    private String sName;
+    /**
+     * 联系邮箱
+     */
+    private String contractEmail;
+    /**
+     * 固定电话
+     */
+    private String contractPhone;
+    /**
+     * 联系人
+     */
+    private String linkMan;
+    /**
+     * 省
+     */
+    private Integer provinceId;
+    /**
+     * 市
+     */
+    private Integer cityId;
+    /**
+     * 地址ID
+     */
+    private Integer townId;
+    /**
+     * 地址
+     */
+    private String address;
+    /**
+     * 门头照
+     */
+    private String shopPhoto;
+    /**
+     * 营业执照(businessLicenseImage)
+     */
+    private String businessLicense;
+    /**
+     * 统一社会信用代码
+     */
+    private String socialCreditCode;
+    /**
+     * 一级分类为医美=1和生美=2
+     */
+    private Integer firstClubType;
+    /**
+     * 医美的二级分类为诊所=1、门诊=2、医院=3。  生美没有二级分类
+     */
+    private Integer secondClubType;
+    /**
+     * 若为医美分类下的门诊和医院则需要填写科室。
+     */
+    private String department;
+    /**
+     * 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
+     */
+    private String medicalPracticeLicense;
+    /**
+     * 主打项目(mainpro)
+     */
+    private String mainProduct;
+    /**
+     * 传真
+     */
+    private String fax;
+    /**
+     * 公司简介(info)
+     */
+    private String profile;
+
+}

+ 65 - 41
src/main/java/com/caimei365/user/model/po/ClubPo.java

@@ -33,10 +33,74 @@ public class ClubPo implements Serializable {
      * 联系手机
      * 联系手机
      */
      */
     private String contractMobile;
     private String contractMobile;
+    /**
+     * 联系邮箱
+     */
+    private String contractEmail;
+    /**
+     * 固定电话
+     */
+    private String contractPhone;
     /**
     /**
      * 联系人
      * 联系人
      */
      */
     private String linkMan;
     private String linkMan;
+    /**
+     * 省
+     */
+    private Integer provinceId;
+    /**
+     * 市
+     */
+    private Integer cityId;
+    /**
+     * 地址ID
+     */
+    private Integer townId;
+    /**
+     * 地址
+     */
+    private String address;
+    /**
+     * 门头照
+     */
+    private String shopPhoto;
+    /**
+     * 营业执照
+     */
+    private String businessLicense;
+    /**
+     * 统一社会信用代码
+     */
+    private String socialCreditCode;
+    /**
+     * 一级分类为医美=1和生美=2
+     */
+    private Integer firstClubType;
+    /**
+     * 医美的二级分类为诊所=1、门诊=2、医院=3。  生美没有二级分类
+     */
+    private Integer secondClubType;
+    /**
+     * 若为医美分类下的门诊和医院则需要填写科室。
+     */
+    private String department;
+    /**
+     * 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
+     */
+    private String medicalPracticeLicense;
+    /**
+     * 主打项目(mainpro)
+     */
+    private String mainProduct;
+    /**
+     * 传真
+     */
+    private String fax;
+    /**
+     * 公司简介(info)
+     */
+    private String profile;
     /**
     /**
      * 协销ID
      * 协销ID
      */
      */
@@ -49,45 +113,5 @@ public class ClubPo implements Serializable {
      * 状态:90:已上线,91:已冻结,92:审查资料未通过,待补充资料,1:待审查资料,2:电话预约,3:已预约,20:待确认,21:待拜访,30:待员工推荐,40:已完成第一次采购
      * 状态:90:已上线,91:已冻结,92:审查资料未通过,待补充资料,1:待审查资料,2:电话预约,3:已预约,20:待确认,21:待拜访,30:待员工推荐,40:已完成第一次采购
      */
      */
     private Integer status;
     private Integer status;
-
-
 }
 }
-//`clubID` int NOT NULL AUTO_INCREMENT COMMENT '会所ID',
-//  `userID` int DEFAULT NULL COMMENT '用户ID',
-//  `name` varchar(50) DEFAULT NULL COMMENT '机构名称',
-//  `sname` varchar(20) DEFAULT NULL COMMENT '机构简称',
-//  `logo` varchar(200) DEFAULT NULL COMMENT 'logo',
-//  `legalPerson` varchar(20) DEFAULT NULL COMMENT '法人',
-//  `provinceID` int DEFAULT NULL COMMENT '省',
-//  `cityID` int DEFAULT NULL COMMENT '市',
-//  `townID` int DEFAULT NULL COMMENT '地址ID',
-//  `flag` varchar(100) DEFAULT NULL COMMENT '拉会所上线的用户的cmBindId,以逗号结尾',
-//  `inviterBindID` int DEFAULT NULL COMMENT '邀请者cmBindId',
-//  `inviterName` varchar(255) DEFAULT NULL COMMENT '邀请者名称',
-//  `spID` int DEFAULT NULL COMMENT '协销Id',
-//  `mainServiceProviderID` int DEFAULT NULL COMMENT '协销经理Id',
-//  `scanTime` varchar(19) DEFAULT NULL COMMENT '扫描时间',
-//  `address` varchar(100) DEFAULT NULL COMMENT '详细地址',
-//  `linkMan` varchar(50) DEFAULT NULL COMMENT '联系人',
-//  `contractPhone` varchar(50) DEFAULT NULL COMMENT '联系电话',
-//  `contractMobile` varchar(20) DEFAULT NULL COMMENT '联系手机',
-//  `fax` varchar(50) DEFAULT NULL COMMENT '传真',
-//  `duty1` varchar(50) DEFAULT NULL COMMENT '职务',
-//  `info` varchar(500) DEFAULT NULL COMMENT '公司简介',
-//  `addTime` varchar(19) DEFAULT NULL COMMENT '注册时间',
-//  `auditTime` varchar(19) DEFAULT NULL COMMENT '审核时间',
-//  `auditNote` varchar(100) DEFAULT NULL COMMENT '审核备注',
-//  `status` int DEFAULT NULL COMMENT '状态',
-//  `businessLicenseImage` varchar(200) DEFAULT NULL COMMENT '营业执照',
-//  `defaultServiceProviderID` int DEFAULT NULL COMMENT '默认的创客',
-//  `defaultServiceProviderUpdTime` varchar(19) DEFAULT NULL COMMENT '创客更新时间',
-//  `mainpro` varchar(200) DEFAULT NULL COMMENT '主打项目',
-//  `scanFlag` char(2) DEFAULT '0' COMMENT '扫描状态 0待扫描 1 已扫描 2已上线',
-//  `headpic` varchar(200) DEFAULT NULL COMMENT '门头照',
-//  `lastModify` varchar(19) DEFAULT NULL COMMENT '最后更新时间',
-//  `lastCheckOrderDate` datetime DEFAULT NULL COMMENT '最后查看订单时间(用于协销统计历史订单未查看数量)',
-//  `socialCreditCode` varchar(18) DEFAULT NULL COMMENT '统一社会信用代码',
-//  `firstClubType` char(10) DEFAULT NULL COMMENT '一级分类为医美=1和生美=2',
-//  `secondClubType` char(10) DEFAULT NULL COMMENT '医美的二级分类为诊所=1、门诊=2、医院=3。  生美没有二级分类',
-//  `department` varchar(200) DEFAULT NULL COMMENT '若为医美分类下的门诊和医院则需要填写科室。',
-//  `medicalPracticeLicenseImg` varchar(200) DEFAULT NULL COMMENT '医美分类必须上传医疗执业许可证',
+

+ 50 - 14
src/main/java/com/caimei365/user/service/RegisterService.java

@@ -1,8 +1,10 @@
 package com.caimei365.user.service;
 package com.caimei365.user.service;
 
 
 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.ClubUpgradeDto;
 import com.caimei365.user.model.po.ClubPo;
 import com.caimei365.user.model.po.ClubPo;
-import org.springframework.web.server.ServerWebExchange;
+import org.springframework.http.HttpHeaders;
 
 
 /**
 /**
  * Description
  * Description
@@ -14,19 +16,53 @@ public interface RegisterService {
     /**
     /**
      * 普通机构入驻(注册)
      * 普通机构入驻(注册)
      *
      *
-     * @param source            注册来源: 0网站 1小程序
-     * @param userName          用户名
-     * @param bindMobile        企业绑定手机号
-     * @param password          密码
-     * @param passWordConfirm   用户确认密码
-     * @param smsCode           短信验证码
-     * @param isAgreed          是否同意勾选同意协议,1是,其他否
-     * @param unionId           微信unionId
-     * @param nickName          微信昵称
-     * @param avatarUrl         微信头像
-     * @param serverWebExchange ServerWebExchange
-     * @return BaseUser
+     * @param clubRegisterDto ClubRegisterDto{
+     *                          source            注册来源: 0网站 1小程序
+     *                          userName          用户名
+     *                          bindMobile        企业绑定手机号
+     *                          password          密码
+     *                          unionId           微信unionId
+     *                          nickName          微信昵称
+     *                          avatarUrl         微信头像(旧:headimgurl)
+     *                        }
+     * @param passWordConfirm 用户确认密码
+     * @param smsCode         短信验证码(旧:activationCode)
+     * @param isAgreed        是否同意勾选同意协议,1是,其他否
+     * @param headers         HttpHeaders
+     * @return ClubPo
      */
      */
-    ResponseJson<ClubPo> clubRegister(Integer source, String userName, String bindMobile, String password, String passWordConfirm, String smsCode, Integer isAgreed, String unionId, String nickName, String avatarUrl, ServerWebExchange serverWebExchange);
+    ResponseJson<ClubPo> clubRegister(ClubRegisterDto clubRegisterDto, String passWordConfirm, String smsCode, Integer isAgreed, HttpHeaders headers);
+
+    /**
+     * 普通机构升级会员机构
+     *
+     * @param upgradeDto ClubUpgradeDto:{
+     *                      clubId                 机构ID
+     *                      userId                 用户ID
+     *                      name                   机构名称
+     *                      sName                  机构简称
+     *                      contractEmail          邮箱(contractEmail1)
+     *                      contractPhone          固定电话
+     *                      linkMan                联系人(linkMan1)
+     *                      provinceId             省Id
+     *                      cityId                 市Id
+     *                      townId                 县区Id
+     *                      address                地址
+     *                      shopPhoto              门头照(headpic)
+     *                      businessLicense        营业执照(businessLicenseImage)
+     *                      socialCreditCode       统一社会信用代码(socialCreditCode)
+     *                      firstClubType          一级分类:医美=1和生美=2
+     *                      secondClubType         医美的二级分类:诊所=1、门诊=2、医院=3。  生美没有二级分类
+     *                      department             医美分类下的门诊和医院则需要填写科室
+     *                      medicalPracticeLicense 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
+     *                      mainProduct            主打项目(mainpro)
+     *                      fax                    传真
+     *                      profile                公司简介
+     *                  }
+     * @param headers   HttpHeaders
+     * @return ClubPo
+     */
+    ResponseJson<ClubPo> clubUpgrade(ClubUpgradeDto upgradeDto, HttpHeaders headers);
+
 
 
 }
 }

+ 3 - 2
src/main/java/com/caimei365/user/service/ShopService.java

@@ -1,6 +1,7 @@
 package com.caimei365.user.service;
 package com.caimei365.user.service;
 
 
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.ResponseJson;
+import org.springframework.http.HttpHeaders;
 import org.springframework.web.server.ServerWebExchange;
 import org.springframework.web.server.ServerWebExchange;
 
 
 /**
 /**
@@ -35,7 +36,7 @@ public interface ShopService {
      * @param serverWebExchange     ServerWebExchange(新参数)
      * @param serverWebExchange     ServerWebExchange(新参数)
      * @return BaseUser
      * @return BaseUser
      */
      */
-    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, ServerWebExchange serverWebExchange);
+    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);
 
 
     /**
     /**
      * 小程序端分步供应商注册
      * 小程序端分步供应商注册
@@ -63,5 +64,5 @@ public interface ShopService {
      * @param whichStep             注册步数
      * @param whichStep             注册步数
      * @return BaseUser
      * @return BaseUser
      */
      */
-    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, ServerWebExchange serverWebExchange, Integer whichStep);
+    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);
 }
 }

+ 165 - 43
src/main/java/com/caimei365/user/service/impl/RegisterServiceImpl.java

@@ -1,8 +1,11 @@
 package com.caimei365.user.service.impl;
 package com.caimei365.user.service.impl;
 
 
 import com.caimei365.user.mapper.BaseMapper;
 import com.caimei365.user.mapper.BaseMapper;
+import com.caimei365.user.mapper.LoginMapper;
 import com.caimei365.user.mapper.RegisterMapper;
 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.ClubUpgradeDto;
 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.UserPo;
 import com.caimei365.user.model.po.UserPo;
@@ -10,12 +13,11 @@ 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.RequestUtil;
 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.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.server.ServerWebExchange;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
@@ -37,40 +39,43 @@ public class RegisterServiceImpl implements RegisterService {
     @Resource
     @Resource
     private BaseMapper baseMapper;
     private BaseMapper baseMapper;
     @Resource
     @Resource
+    private LoginMapper loginMapper;
+    @Resource
     private RegisterMapper registerMapper;
     private RegisterMapper registerMapper;
 
 
     /**
     /**
      * 普通机构入驻(注册)
      * 普通机构入驻(注册)
      *
      *
-     * @param source            注册来源: 0网站 1小程序
-     * @param userName          用户名
-     * @param bindMobile        企业绑定手机号
-     * @param password          密码
-     * @param passWordConfirm   用户确认密码
-     * @param smsCode           短信验证码
-     * @param isAgreed          是否同意勾选同意协议,1是,其他否
-     * @param unionId           微信unionId
-     * @param nickName          微信昵称
-     * @param avatarUrl         微信头像
-     * @param serverWebExchange ServerWebExchange
-     * @return BaseUser
+     * @param clubRegisterDto ClubRegisterDto{
+     *                        source            注册来源: 0网站 1小程序
+     *                        userName          用户名
+     *                        bindMobile        企业绑定手机号
+     *                        password          密码
+     *                        unionId           微信unionId
+     *                        nickName          微信昵称
+     *                        avatarUrl         微信头像(旧:headimgurl)
+     *                        }
+     * @param passWordConfirm 用户确认密码
+     * @param smsCode         短信验证码(旧:activationCode)
+     * @param isAgreed        是否同意勾选同意协议,1是,其他否
+     * @param headers         HttpHeaders
+     * @return ClubPo
      */
      */
     @Override
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public ResponseJson<ClubPo> clubRegister(Integer source, String userName, String bindMobile, String password, String passWordConfirm, String smsCode, Integer isAgreed, String unionId, String nickName, String avatarUrl, ServerWebExchange serverWebExchange) {
+    public ResponseJson<ClubPo> clubRegister(ClubRegisterDto clubRegisterDto, String passWordConfirm, String smsCode, Integer isAgreed, HttpHeaders headers) {
         // 打印IP
         // 打印IP
-        String ip = RequestUtil.getIp(serverWebExchange);
-        log.info("X-Forwarded-For:" + ip);
+        String ip = headers.getFirst("X-CLIENT-IP");
+        log.info("机构注册 X-CLIENT-IP : " + ip);
         // 参数校验
         // 参数校验
-        if (StringUtils.isBlank(userName) || StringUtils.isBlank(bindMobile)
-            || StringUtils.isBlank(password) || StringUtils.isBlank(passWordConfirm) ||
+        if (StringUtils.isBlank(clubRegisterDto.getUserName()) || StringUtils.isBlank(clubRegisterDto.getBindMobile())
+            || StringUtils.isBlank(clubRegisterDto.getPassword()) || StringUtils.isBlank(passWordConfirm) ||
             StringUtils.isBlank(smsCode)) {
             StringUtils.isBlank(smsCode)) {
             return ResponseJson.error("参数异常", null);
             return ResponseJson.error("参数异常", null);
         }
         }
-        if (!password.equals(passWordConfirm)) {
+        if (!clubRegisterDto.getPassword().equals(passWordConfirm)) {
             return ResponseJson.error("输入的密码不一致", null);
             return ResponseJson.error("输入的密码不一致", null);
         }
         }
-        String redisSmsCode = (String) redisService.get("code:" + bindMobile);
+        String redisSmsCode = (String) redisService.get("code:" + clubRegisterDto.getBindMobile());
         if (redisSmsCode.equals(smsCode)) {
         if (redisSmsCode.equals(smsCode)) {
             return ResponseJson.error("手机验证码错误", null);
             return ResponseJson.error("手机验证码错误", null);
         }
         }
@@ -78,12 +83,12 @@ public class RegisterServiceImpl implements RegisterService {
             return ResponseJson.error("请勾选同意协议", null);
             return ResponseJson.error("请勾选同意协议", null);
         }
         }
         // 查找用户表是否存在
         // 查找用户表是否存在
-        Integer dbUserId = baseMapper.getUserIdByMobile(bindMobile);
+        Integer dbUserId = baseMapper.getUserIdByMobile(clubRegisterDto.getBindMobile());
         if (dbUserId > 0) {
         if (dbUserId > 0) {
             return ResponseJson.error("该手机号已被使用", null);
             return ResponseJson.error("该手机号已被使用", null);
         }
         }
         // 查找运营人员表是否存在
         // 查找运营人员表是否存在
-        Integer dbOperationId = baseMapper.getOperationIdByMobile(bindMobile);
+        Integer dbOperationId = baseMapper.getOperationIdByMobile(clubRegisterDto.getBindMobile());
         if (dbOperationId > 0) {
         if (dbOperationId > 0) {
             return ResponseJson.error("您已是机构运营人员,无需再注册机构", null);
             return ResponseJson.error("您已是机构运营人员,无需再注册机构", null);
         }
         }
@@ -100,14 +105,14 @@ public class RegisterServiceImpl implements RegisterService {
         // 注册IP
         // 注册IP
         user.setRegisterIp(ip);
         user.setRegisterIp(ip);
         // 注册来源: 0网站 1小程序
         // 注册来源: 0网站 1小程序
-        user.setSource(source);
+        user.setSource(clubRegisterDto.getSource());
         // 用户类型,供应商1,会员机构3,普通机构4
         // 用户类型,供应商1,会员机构3,普通机构4
         user.setRegisterUserTypeId(4);
         user.setRegisterUserTypeId(4);
         // 组织名称
         // 组织名称
-        user.setName(userName);
-        user.setUserName(userName);
+        user.setName(clubRegisterDto.getUserName());
+        user.setUserName(clubRegisterDto.getUserName());
         // 绑定手机号
         // 绑定手机号
-        user.setBindMobile(bindMobile);
+        user.setBindMobile(clubRegisterDto.getBindMobile());
         // 用户身份: 1协销 2会员机构 3供应商 4普通机构
         // 用户身份: 1协销 2会员机构 3供应商 4普通机构
         user.setUserIdentity(4);
         user.setUserIdentity(4);
         // 用户权限: 2会员机构 3供应商 4协销 5普通机构
         // 用户权限: 2会员机构 3供应商 4协销 5普通机构
@@ -115,7 +120,7 @@ public class RegisterServiceImpl implements RegisterService {
         // 设置机构上线
         // 设置机构上线
         user.setClubStatus(90);
         user.setClubStatus(90);
         // 设置密码
         // 设置密码
-        user.setPassword(Md5Util.md5(password));
+        user.setPassword(Md5Util.md5(clubRegisterDto.getPassword()));
         // 同意协议
         // 同意协议
         user.setAgreeFlag(isAgreed);
         user.setAgreeFlag(isAgreed);
         // 用户状态,1正常,0冻结
         // 用户状态,1正常,0冻结
@@ -128,6 +133,7 @@ public class RegisterServiceImpl implements RegisterService {
             保存数据库 user
             保存数据库 user
          */
          */
         int insertFlag = registerMapper.insertClubUser(user);
         int insertFlag = registerMapper.insertClubUser(user);
+        log.info("插入数据库User表,获得userId:"+user.getUserId());
         if (insertFlag < 1) {
         if (insertFlag < 1) {
             throw new RuntimeException("插入数据库异常user:" + user.toString());
             throw new RuntimeException("插入数据库异常user:" + user.toString());
         }
         }
@@ -143,9 +149,9 @@ public class RegisterServiceImpl implements RegisterService {
         club.setContractMobile(user.getBindMobile());
         club.setContractMobile(user.getBindMobile());
         // 联系人
         // 联系人
         club.setLinkMan(user.getUserName());
         club.setLinkMan(user.getUserName());
-        // 用户ID
+        // 用户Id
         club.setUserId(user.getUserId());
         club.setUserId(user.getUserId());
-        // 协销ID(spID)
+        // 协销Id(spId)
         club.setServiceProviderId(1342);
         club.setServiceProviderId(1342);
         // 注册时间
         // 注册时间
         club.setAddTime(current);
         club.setAddTime(current);
@@ -155,6 +161,7 @@ public class RegisterServiceImpl implements RegisterService {
             保存数据库 club
             保存数据库 club
          */
          */
         int insertClubFlag = registerMapper.insertClub(club);
         int insertClubFlag = registerMapper.insertClub(club);
+        log.info("插入数据库club表,获得clubId:"+club.getClubId());
         if (insertClubFlag < 1) {
         if (insertClubFlag < 1) {
             throw new RuntimeException("插入数据库异常club:" + club.toString());
             throw new RuntimeException("插入数据库异常club:" + club.toString());
         }
         }
@@ -162,36 +169,36 @@ public class RegisterServiceImpl implements RegisterService {
         user.setClubId(club.getClubId());
         user.setClubId(club.getClubId());
         registerMapper.updateUserClubId(user.getUserId(), club.getClubId());
         registerMapper.updateUserClubId(user.getUserId(), club.getClubId());
         // 注册成功短信
         // 注册成功短信
-        boolean smsFlag = AliyunSmsUtil.sendSms(bindMobile, 7, "{name:"+ bindMobile +",password:"+ password +"}");
+        boolean smsFlag = AliyunSmsUtil.sendSms(clubRegisterDto.getBindMobile(), 7, "{name:"+ clubRegisterDto.getBindMobile() +",password:"+ clubRegisterDto.getPassword() +"}");
         if (!smsFlag) {
         if (!smsFlag) {
             // 短信发送失败重试一次
             // 短信发送失败重试一次
-            AliyunSmsUtil.sendSms(bindMobile, 7, "{name:"+ bindMobile +",password:"+ password +"}");
+            AliyunSmsUtil.sendSms(clubRegisterDto.getBindMobile(), 7, "{name:"+ clubRegisterDto.getBindMobile() +",password:"+ clubRegisterDto.getPassword() +"}");
         }
         }
-        log.info("注册普通机构成功,手机号>>>" + bindMobile);
+        log.info("注册普通机构成功,手机号>>>" + clubRegisterDto.getBindMobile());
         /*
         /*
             绑定微信,成为机构运营人员
             绑定微信,成为机构运营人员
          */
          */
-        if (StringUtils.isNotBlank(nickName)) {
+        if (StringUtils.isNotBlank(clubRegisterDto.getNickName())) {
             OperationPo operation = new OperationPo();
             OperationPo operation = new OperationPo();
-            // 用户ID
+            // 用户Id
             operation.setUserId(user.getUserId());
             operation.setUserId(user.getUserId());
-            // 机构ID
+            // 机构Id
             operation.setClubId(club.getClubId());
             operation.setClubId(club.getClubId());
             // 微信昵称
             // 微信昵称
-            operation.setNickName(nickName);
+            operation.setNickName(clubRegisterDto.getNickName());
             // 微信头像
             // 微信头像
-            operation.setAvatarUrl(avatarUrl);
+            operation.setAvatarUrl(clubRegisterDto.getAvatarUrl());
             // 用户类型,1:机构类型,2供应商类型
             // 用户类型,1:机构类型,2供应商类型
             operation.setUserType(1);
             operation.setUserType(1);
             // 运营人员手机号
             // 运营人员手机号
-            operation.setMobile(bindMobile);
+            operation.setMobile(clubRegisterDto.getBindMobile());
             // 联系人
             // 联系人
-            operation.setLinkName(userName);
+            operation.setLinkName(clubRegisterDto.getUserName());
             // 运营人员状态:1未绑定,2已绑定
             // 运营人员状态:1未绑定,2已绑定
             operation.setStatus(2);
             operation.setStatus(2);
             // 微信unionId
             // 微信unionId
-            operation.setUnionId(unionId);
-            Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + unionId);
+            operation.setUnionId(clubRegisterDto.getUnionId());
+            Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + clubRegisterDto.getUnionId());
             String openId = (String) infoData.get("openId");
             String openId = (String) infoData.get("openId");
             // 微信openId
             // 微信openId
             operation.setOpenId(openId);
             operation.setOpenId(openId);
@@ -207,6 +214,7 @@ public class RegisterServiceImpl implements RegisterService {
                 保存数据库 operation
                 保存数据库 operation
              */
              */
             int insertOperationFlag = registerMapper.insertOperation(operation);
             int insertOperationFlag = registerMapper.insertOperation(operation);
+            log.info("插入数据库cm_mall_operation_user表,获得id:"+operation.getId());
             if (insertOperationFlag < 1) {
             if (insertOperationFlag < 1) {
                 log.info(operation.getUserId() + " 插入数据库异常operation:" + operation.toString());
                 log.info(operation.getUserId() + " 插入数据库异常operation:" + operation.toString());
             }
             }
@@ -214,5 +222,119 @@ public class RegisterServiceImpl implements RegisterService {
         }
         }
         return ResponseJson.success(club);
         return ResponseJson.success(club);
     }
     }
+
+    /**
+     * 普通机构升级会员机构
+     *
+     * @param upgradeDto ClubUpgradeDto:{
+     *                      clubId                 机构ID
+     *                      userId                 用户ID
+     *                      name                   机构名称
+     *                      sName                  机构简称
+     *                      contractEmail          邮箱(contractEmail1)
+     *                      contractPhone          固定电话
+     *                      linkMan                联系人(linkMan1)
+     *                      provinceId             省Id
+     *                      cityId                 市Id
+     *                      townId                 县区Id
+     *                      address                地址
+     *                      shopPhoto              门头照(headpic)
+     *                      businessLicense        营业执照(businessLicenseImage)
+     *                      socialCreditCode       统一社会信用代码(socialCreditCode)
+     *                      firstClubType          一级分类:医美=1和生美=2
+     *                      secondClubType         医美的二级分类:诊所=1、门诊=2、医院=3。  生美没有二级分类
+     *                      department             医美分类下的门诊和医院则需要填写科室
+     *                      medicalPracticeLicense 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
+     *                      mainProduct            主打项目(mainpro)
+     *                      fax                    传真
+     *                      profile                公司简介
+     *                  }
+     * @param headers   HttpHeaders
+     * @return ClubPo
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public ResponseJson<ClubPo> clubUpgrade(ClubUpgradeDto upgradeDto, HttpHeaders headers) {
+        // 打印IP
+        String ip = headers.getFirst("X-CLIENT-IP");
+        log.info("机构升级 X-CLIENT-IP : " + ip);
+        // 参数校验
+        if (upgradeDto.getUserId() == null || upgradeDto.getClubId() == null || StringUtils.isBlank(upgradeDto.getContractEmail()) || StringUtils.isBlank(upgradeDto.getName())
+                || StringUtils.isBlank(upgradeDto.getBusinessLicense()) || upgradeDto.getTownId() == null || upgradeDto.getFirstClubType() == null) {
+            return ResponseJson.error("参数异常", null);
+        }
+        if (upgradeDto.getFirstClubType() == 1){
+            if (upgradeDto.getSecondClubType() == null || StringUtils.isBlank(upgradeDto.getDepartment()) || StringUtils.isBlank(upgradeDto.getMedicalPracticeLicense())) {
+                return ResponseJson.error("医美分类下参数异常", null);
+            }
+        }
+        Integer userIdByEmail = baseMapper.getUserIdByEmail(upgradeDto.getContractEmail());
+        if (null != userIdByEmail && userIdByEmail > 0 ) {
+            return ResponseJson.error("该邮箱已被使用", null);
+        }
+        // 获取用户数据 user
+        UserPo user = loginMapper.getUserByUserId(upgradeDto.getUserId());
+        // 客户IP
+        user.setRegisterIp(ip);
+        // 联系邮箱
+        user.setEmail(upgradeDto.getContractEmail());
+        // 机构名称
+        user.setName(upgradeDto.getName());
+        // 待审核资料
+        user.setClubStatus(1);
+        // 更新机构用户
+        registerMapper.updateClubUserByUpgrade(user);
+        /*
+            组装机构数据
+         */
+        ClubPo club = new ClubPo();
+        // 机构Id
+        club.setClubId(upgradeDto.getClubId());
+        // 用户Id
+        club.setUserId(upgradeDto.getUserId());
+        // 机构名称
+        club.setName(upgradeDto.getName());
+        // 机构简称
+        club.setSName(upgradeDto.getSName());
+        // 联系邮箱
+        club.setContractEmail(upgradeDto.getContractEmail());
+        // 固定电话
+        club.setContractPhone(upgradeDto.getContractPhone());
+        // 联系人
+        club.setLinkMan(upgradeDto.getLinkMan());
+        // 地址
+        club.setProvinceId(upgradeDto.getProvinceId());
+        club.setCityId(upgradeDto.getCityId());
+        club.setTownId(upgradeDto.getTownId());
+        club.setAddress(upgradeDto.getAddress());
+        // 门头照
+        club.setShopPhoto(upgradeDto.getShopPhoto());
+        // 营业执照
+        club.setBusinessLicense(upgradeDto.getBusinessLicense());
+        // 统一社会信用代码
+        club.setSocialCreditCode(upgradeDto.getSocialCreditCode());
+        // 分类: 1医美, 2生美
+        club.setFirstClubType(upgradeDto.getFirstClubType());
+        if (upgradeDto.getFirstClubType() == 1){
+            // 医美二级分类: 1诊所、2门诊、3医院
+            club.setSecondClubType(upgradeDto.getSecondClubType());
+            // 门诊和医院则需要填写科室
+            club.setDepartment(upgradeDto.getDepartment());
+            // 医美分类必须上传医疗执业许可证
+            club.setMedicalPracticeLicense(upgradeDto.getMedicalPracticeLicense());
+        }
+        // 主打项目(mainpro)
+        club.setMainProduct(upgradeDto.getMainProduct());
+        // 传真
+        club.setFax(upgradeDto.getFax());
+        // 公司简介(info)
+        club.setProfile(upgradeDto.getProfile());
+        /*
+         * 待审核资料
+         */
+        club.setStatus(1);
+        registerMapper.updateClubByUpgrade(club);
+        return ResponseJson.success(club);
+    }
 }
 }
 
 

+ 5 - 4
src/main/java/com/caimei365/user/service/impl/ShopServiceImpl.java

@@ -12,6 +12,7 @@ import com.caimei365.user.utils.RequestUtil;
 import com.caimei365.user.utils.ValidateUtil;
 import com.caimei365.user.utils.ValidateUtil;
 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.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.web.server.ServerWebExchange;
 import org.springframework.web.server.ServerWebExchange;
 
 
@@ -62,9 +63,9 @@ public class ShopServiceImpl implements ShopService {
      * @return BaseUser
      * @return BaseUser
      */
      */
     @Override
     @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, ServerWebExchange serverWebExchange) {
+    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
         // 打印IP
-        String ip = RequestUtil.getIp(serverWebExchange);
+        String ip = headers.getFirst("X-CLIENT-IP");
         log.info("X-Forwarded-For:" + ip);
         log.info("X-Forwarded-For:" + ip);
         // 参数校验
         // 参数校验
         if (StringUtils.isBlank(name) || StringUtils.isBlank(bindMobile)
         if (StringUtils.isBlank(name) || StringUtils.isBlank(bindMobile)
@@ -221,7 +222,7 @@ public class ShopServiceImpl implements ShopService {
      * @return BaseUser
      * @return BaseUser
      */
      */
     @Override
     @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, ServerWebExchange serverWebExchange, Integer whichStep) {
+    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 (1 == whichStep) {
             if (StringUtils.isBlank(bindMobile) || StringUtils.isBlank(password)
             if (StringUtils.isBlank(bindMobile) || StringUtils.isBlank(password)
@@ -262,6 +263,6 @@ public class ShopServiceImpl implements ShopService {
         } else if (1 != isAgreed) {
         } else if (1 != isAgreed) {
             return ResponseJson.error("请勾选同意协议");
             return ResponseJson.error("请勾选同意协议");
         }
         }
-        return register(source, name, sName, bindMobile, email, smsCode, password, passWordConfirm, linkMan, provinceId, cityId, townId, address, socialCreditCode, businessLicenseImage, firstShopType, secondShopType, mainPro, isAgreed, serverWebExchange);
+        return register(source, name, sName, bindMobile, email, smsCode, password, passWordConfirm, linkMan, provinceId, cityId, townId, address, socialCreditCode, businessLicenseImage, firstShopType, secondShopType, mainPro, isAgreed, headers);
     }
     }
 }
 }

+ 1 - 31
src/main/java/com/caimei365/user/utils/RequestUtil.java

@@ -22,37 +22,6 @@ import java.util.Objects;
  */
  */
 public class RequestUtil {
 public class RequestUtil {
 
 
-    public static String getIp(ServerWebExchange serverWebExchange){
-        ServerHttpRequest request = serverWebExchange.getRequest();
-        HttpHeaders headers = request.getHeaders();
-        String ip = headers.getFirst("x-forwarded-for");
-        if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {
-            // 多次反向代理后会有多个ip值,第一个ip才是真实ip
-            if (ip.contains(",")) {
-                ip = ip.split(",")[0];
-            }
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = headers.getFirst("Proxy-Client-IP");
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = headers.getFirst("WL-Proxy-Client-IP");
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = headers.getFirst("HTTP_CLIENT_IP");
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = headers.getFirst("HTTP_X_FORWARDED_FOR");
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = headers.getFirst("X-Real-IP");
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = Objects.requireNonNull(request.getRemoteAddress()).getAddress().getHostAddress();
-        }
-        return ip.replaceAll(":", ".");
-    }
-
     /**
     /**
      * 向指定URL发送GET方法的请求
      * 向指定URL发送GET方法的请求
      *
      *
@@ -93,6 +62,7 @@ public class RequestUtil {
         }
         }
         return result.toString();
         return result.toString();
     }
     }
+
     /**
     /**
      * 向指定 URL 发送POST方法的请求
      * 向指定 URL 发送POST方法的请求
      *
      *

+ 2 - 0
src/main/resources/application.yml

@@ -61,3 +61,5 @@ wx:
 swagger:
 swagger:
   # swagger开启状态,true开启,false关闭
   # swagger开启状态,true开启,false关闭
   enabled: true
   enabled: true
+  ui-config:
+    operations-sorter: method

+ 1 - 1
src/main/resources/mapper/BaseMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="com.caimei365.user.mapper.BaseMapper">
 <mapper namespace="com.caimei365.user.mapper.BaseMapper">
     <select id="getUserIdByEmail" resultType="java.lang.Integer">
     <select id="getUserIdByEmail" resultType="java.lang.Integer">
         select userID from user
         select userID from user
-        where email = #{mobile} and userIdentity in (1,2,3,4)
+        where email = #{email} and userIdentity in (1,2,3,4)
         limit 1
         limit 1
     </select>
     </select>
     <select id="getUserIdByMobile" resultType="java.lang.Integer">
     <select id="getUserIdByMobile" resultType="java.lang.Integer">

+ 7 - 18
src/main/resources/mapper/LoginMapper.xml

@@ -1,24 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.user.mapper.LoginMapper">
 <mapper namespace="com.caimei365.user.mapper.LoginMapper">
-
-
-    <!--<select id="getBaseUserByMobile" resultType="com.caimei365.user.model.BaseUser">
-        select u.userID as userId,
-               u.userName as userName,
-               u.mobile as mobile,
-               u.bindMobile as bindMobile,
-               u.email as email,
-               u.userPermission as userPermission,
-               u.userIdentity as userIdentity,
-               u.password as password
-        from user u
-        left join cm_mall_operation_user cu on cu.userID = u.userID
-        where (u.bindMobile = #{mobile}
-                or (cu.mobile = #{mobile} and cu.delFlag != 1)
-        ) and u.userIdentity in (1,2,3,4)
-        limit 1
-    </select>-->
     <select id="getLoginUserByUserId" resultType="com.caimei365.user.model.vo.UserLoginVo">
     <select id="getLoginUserByUserId" resultType="com.caimei365.user.model.vo.UserLoginVo">
         select u.userID as userId,
         select u.userID as userId,
                u.userName as userName,
                u.userName as userName,
@@ -54,6 +36,13 @@
         ) and u.userIdentity in (1,2,3,4)
         ) and u.userIdentity in (1,2,3,4)
         limit 1
         limit 1
     </select>
     </select>
+    <select id="getUserByUserId" resultType="com.caimei365.user.model.po.UserPo">
+
+    </select>
+
+
+
+
     <select id="getOperationByMobile" resultType="com.caimei365.user.model.po.OperationPo">
     <select id="getOperationByMobile" resultType="com.caimei365.user.model.po.OperationPo">
         select o.userID as userId,
         select o.userID as userId,
                o.mobile as mobile,
                o.mobile as mobile,

+ 37 - 3
src/main/resources/mapper/RegisterMapper.xml

@@ -13,9 +13,6 @@
         insert into cm_mall_operation_user(`userID`, `clubID`, `nickName`, `headimgurl`, `userType`, `mobile`, `linkName`, `status`, `unionId`, `openid`, `addTime`, `updateTime`, `bindTime`, `delFlag`)
         insert into cm_mall_operation_user(`userID`, `clubID`, `nickName`, `headimgurl`, `userType`, `mobile`, `linkName`, `status`, `unionId`, `openid`, `addTime`, `updateTime`, `bindTime`, `delFlag`)
                                     values(#{userId},#{clubId},#{nickName},#{avatarUrl},#{UserType},#{mobile},#{linkName},#{status},#{unionId},#{openid},#{addTime},#{updateTime},#{bindTime},#{delFlag})
                                     values(#{userId},#{clubId},#{nickName},#{avatarUrl},#{UserType},#{mobile},#{linkName},#{status},#{unionId},#{openid},#{addTime},#{updateTime},#{bindTime},#{delFlag})
     </insert>
     </insert>
-    <update id="updateUserClubId">
-        update user set clubID = #{clubId} where userID = #{userId}
-    </update>
     <insert id="insertShopUser" parameterType="com.caimei365.user.model.po.UserPo" keyProperty="userId" useGeneratedKeys="true">
     <insert id="insertShopUser" parameterType="com.caimei365.user.model.po.UserPo" keyProperty="userId" useGeneratedKeys="true">
         insert into user(`registerTime`, `registerIP`, `source`, `registerUserTypeID`, `name`, `userName`, `bindMobile`, `email`, `userIdentity`, `userPermission`, `manufacturerStatus` , `password`, `agreeFlag`, `validFlag`)
         insert into user(`registerTime`, `registerIP`, `source`, `registerUserTypeID`, `name`, `userName`, `bindMobile`, `email`, `userIdentity`, `userPermission`, `manufacturerStatus` , `password`, `agreeFlag`, `validFlag`)
         values(#{registerTime},#{registerIp},#{source},#{registerUserTypeID},#{name},#{userName},#{bindMobile},#{email},#{userIdentity},#{userPermission},#{manufacturerStatus},#{password},#{agreeFlag},#{validFlag})
         values(#{registerTime},#{registerIp},#{source},#{registerUserTypeID},#{name},#{userName},#{bindMobile},#{email},#{userIdentity},#{userPermission},#{manufacturerStatus},#{password},#{agreeFlag},#{validFlag})
@@ -24,7 +21,44 @@
         insert into shop(`userID`, `name`, `sname`, `linkMan`, `linkMan1`, `linkMan2`, `contractMobile`, `contractMobile1`, `contractMobile2`, `contractEmail1`, `contractEmail2`, `provinceID`, `cityID`, `townID`, `address`, `socialCreditCode`, `businessLicenseImage`, `firstShopType`, `secondShopType`, `mainpro`, `addTime`, `validFlag`, `status`)
         insert into shop(`userID`, `name`, `sname`, `linkMan`, `linkMan1`, `linkMan2`, `contractMobile`, `contractMobile1`, `contractMobile2`, `contractEmail1`, `contractEmail2`, `provinceID`, `cityID`, `townID`, `address`, `socialCreditCode`, `businessLicenseImage`, `firstShopType`, `secondShopType`, `mainpro`, `addTime`, `validFlag`, `status`)
         values(#{userId},#{name},#{sName},#{linkMan},#{linkMan1},#{linkMan2},#{contractMobile},#{contractMobile1},#{contractMobile2},#{contractEmail1},#{contractEmail2},#{provinceId},#{cityId},#{townId},#{address},#{socialCreditCode},#{businessLicenseImage},#{firstShopType},#{secondShopType},#{mainPro},#{addTime},#{validFlag},#{status})
         values(#{userId},#{name},#{sName},#{linkMan},#{linkMan1},#{linkMan2},#{contractMobile},#{contractMobile1},#{contractMobile2},#{contractEmail1},#{contractEmail2},#{provinceId},#{cityId},#{townId},#{address},#{socialCreditCode},#{businessLicenseImage},#{firstShopType},#{secondShopType},#{mainPro},#{addTime},#{validFlag},#{status})
     </insert>
     </insert>
+    <update id="updateUserClubId">
+        update user set clubID = #{clubId} where userID = #{userId}
+    </update>
     <update id="updateUserShopId">
     <update id="updateUserShopId">
         update user set shopID = #{shopId} where userID = #{userId}
         update user set shopID = #{shopId} where userID = #{userId}
     </update>
     </update>
+    <update id="updateClubUserByUpgrade">
+        update user set registerIP = #{registerIp},
+                        email = #{contractEmail},
+                        name = #{name},
+                        clubStatus = #{clubStatus}
+        where userID = #{userId}
+    </update>
+    <update id="updateClubByUpgrade">
+        update club set userID = #{userId}, name = #{name}, sname = #{sName}, contractEmail1 = #{contractEmail},
+                        <if test="contractPhone != null">
+                            contractPhone = #{contractPhone},
+                        </if>
+                        <if test="linkMan != null">
+                            linkMan = #{linkMan},
+                        </if>
+                        provinceID = #{provinceId}, cityID = #{cityId}, townID = #{townId}, address = #{address},
+                        <if test="shopPhoto != null  and shopPhoto != 'null'  and shopPhoto != ''">
+                            headpic = #{shopPhoto},
+                        </if>
+                        businessLicenseImage = #{businessLicense}, socialCreditCode = #{socialCreditCode}, firstClubType = #{firstClubType},
+                        <if test="firstClubType == 1">
+                            secondClubType = #{secondClubType}, department = #{department}, medicalPracticeLicenseImg = #{medicalPracticeLicense},
+                        </if>
+                        <if test="mainProduct != null">
+                            mainpro = #{mainProduct},
+                        </if>
+                        <if test="fax != null">
+                            fax = #{fax},
+                        </if>
+                        <if test="profile != null">
+                            info = #{profile},
+                        </if>
+        where clubID = #{clubId}
+    </update>
 </mapper>
 </mapper>