Sfoglia il codice sorgente

分销系统V.1.0.0

kaick 1 anno fa
parent
commit
8c45963e2b

+ 1 - 0
src/main/java/com/caimei365/user/config/ApiConfig.java

@@ -22,6 +22,7 @@ public class ApiConfig implements WebMvcConfigurer {
         //addPathPatterns 用于添加拦截规则
         //excludePathPatterns 用于排除拦截
         registry.addInterceptor(apiInterceptor)
+                .addPathPatterns("/user/distribution/**")
                 .addPathPatterns("/user/club/info/update")
                 .addPathPatterns("/user/shop/info/update")
                 .addPathPatterns("/user/club/archive/deduction");

+ 156 - 0
src/main/java/com/caimei365/user/controller/DistributionApi.java

@@ -0,0 +1,156 @@
+package com.caimei365.user.controller;
+
+import com.caimei365.user.model.ResponseJson;
+import com.caimei365.user.model.dto.ClubTemporaryDto;
+import com.caimei365.user.model.dto.OnlineDto;
+import com.caimei365.user.model.po.CmDistribution;
+import com.caimei365.user.model.po.ServiceProviderPo;
+import com.caimei365.user.model.vo.ClubTemporaryVo;
+import com.caimei365.user.model.vo.ClubVo;
+import com.caimei365.user.model.vo.CmBehaviorRecordVo;
+import com.caimei365.user.model.vo.ServiceProviderVo;
+import com.caimei365.user.service.CmDistributionService;
+import com.caimei365.user.service.SellerService;
+import com.caimei365.user.utils.RequestUtil;
+import com.caimei365.user.utils.ValidateUtil;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/3/24
+ */
+@Api(tags = "分销人员API")
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/user/distribution")
+public class DistributionApi {
+
+    private final CmDistributionService cmDistributionService;
+
+
+    /**
+     * 机构访问详情
+     */
+    @GetMapping("/getDistributionList")
+    public ResponseJson<List<CmDistribution>> getDistributionList(CmDistribution cmDistribution) {
+        if (null == cmDistribution.parentId()) {
+            return ResponseJson.error("参数异常!", null);
+        }
+        List<CmDistribution> cmDistributionList = cmDistributionService.getCmDistributionList(new CmDistribution()
+                .parentId(cmDistribution.parentId())
+        );
+        return ResponseJson.success(cmDistributionList);
+    }
+
+
+    /**
+     * 协销个人中心
+     */
+    @GetMapping("/home")
+    public ResponseJson<CmDistribution> getHome(CmDistribution cmDistribution) {
+        if (null == cmDistribution.userId() || null == cmDistribution.id()) {
+            return ResponseJson.error("参数异常:用户Id不能为空!", null);
+        }
+        return ResponseJson.success(cmDistributionService.getByCmDistribution(new CmDistribution()
+                .id(cmDistribution.id())
+                .userId(cmDistribution.userId())
+        ));
+    }
+
+    /**
+     * 更新协销信息
+     */
+    @PostMapping("/setHome")
+    public ResponseJson setHome(CmDistribution cmDistribution) {
+        if (null == cmDistribution.userId()) {
+            return ResponseJson.error("参数异常:用户Id不能为空!", null);
+        }
+        cmDistributionService.updateCmDistribution(new CmDistribution()
+                .userId(cmDistribution.userId())
+                .image(cmDistribution.image())
+                .qrCode(cmDistribution.qrCode())
+        );
+        return ResponseJson.success();
+    }
+
+    /**
+     * 更新协销信息
+     */
+    @PostMapping("/setPassword")
+    public ResponseJson setPassword(CmDistribution cmDistribution, String password, String code) {
+        if (null == code) {
+            return ResponseJson.error("验证码不能为空!", null);
+        }
+        if (!password.equals(cmDistribution.password())) {
+            return ResponseJson.error("两次输入的密码不一致!", null);
+        }
+        cmDistributionService.setPassword(new CmDistribution()
+                        .userId(cmDistribution.userId())
+                        .password(cmDistribution.password())
+                , code);
+        return ResponseJson.success();
+    }
+
+    /**
+     * 更新协销信息
+     */
+    @PostMapping("/updateStatus")
+    public ResponseJson updateStatus(CmDistribution cmDistribution) {
+        if (null == cmDistribution.userId()) {
+            return ResponseJson.error("参数异常:用户Id不能为空!!", null);
+        }
+        if (90 != cmDistribution.status()) {
+            cmDistribution.status(91);
+        }
+        cmDistributionService.updateCmDistribution(new CmDistribution()
+                        .userId(cmDistribution.userId())
+                        .status(cmDistribution.status())
+                );
+        return ResponseJson.success();
+    }
+
+    /**
+     * 更新协销信息
+     */
+    @PostMapping("/save")
+    public ResponseJson save(CmDistribution cmDistribution) {
+        if (null == cmDistribution.parentId()||cmDistribution.parentId()==0) {
+            return ResponseJson.error("管理员ID不能为空!", null);
+        }
+        if (null == cmDistribution.name() || null == cmDistribution.mobile() || null == cmDistribution.status()) {
+            return ResponseJson.error("参数异常!", null);
+        }
+        // 验证手机号
+        String result = ValidateUtil.validateMobile( cmDistribution.mobile());
+        if (result != null) {
+            return ResponseJson.error(result);
+        }
+        if (90 != cmDistribution.status()) {
+            cmDistribution.status(91);
+        }
+        CmDistribution mobile = new CmDistribution().mobile(cmDistribution.mobile());
+        if(StringUtils.isNotBlank(cmDistribution.id())){
+            mobile.id("not in=" + cmDistribution.id());
+        }
+        CmDistribution byCmDistributionMobile = cmDistributionService.getByCmDistribution(mobile);
+        if (null != byCmDistributionMobile) {
+            return ResponseJson.error("手机号码已经被使用!", null);
+        }
+        cmDistributionService.addCmDistribution(cmDistribution);
+
+        return ResponseJson.success();
+    }
+
+}

+ 32 - 0
src/main/java/com/caimei365/user/controller/LoginApi.java

@@ -5,6 +5,7 @@ import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.*;
 import com.caimei365.user.model.vo.MessageCenter;
 import com.caimei365.user.model.vo.UserLoginVo;
+import com.caimei365.user.service.CmDistributionService;
 import com.caimei365.user.service.LoginService;
 import com.caimei365.user.service.SellerService;
 import com.github.pagehelper.PageInfo;
@@ -30,6 +31,7 @@ public class LoginApi {
 
     private final LoginService loginService;
     private final SellerService sellerService;
+    private final CmDistributionService cmDistributionService;
 
     /**
      * 登录(用户名,密码)
@@ -119,6 +121,8 @@ public class LoginApi {
         String unionId = loginPasswordDto.getUnionId();
         return sellerService.passwordLogin(mobile, password, unionId);
     }
+
+
     /**
      * 采购员登录(手机号,验证码) --组织
      *
@@ -129,6 +133,34 @@ public class LoginApi {
     public ResponseJson<UserLoginVo> organizesellerLogin(LoginCodeDto loginCodeDto) {
         return sellerService.organizeCodeLogin(loginCodeDto);
     }
+
+    /**
+     * 分销人员登录(手机号,密码)
+     * @param loginPasswordDto {
+     *                         mobileOrEmail 手机号
+     *                         password 密码
+     *                         }
+     * @return UserLoginVo
+     */
+    @ApiOperation("分销人员登录(手机号,密码)")
+    @PostMapping("/distribution")
+    public ResponseJson<UserLoginVo> distributionLogin(LoginPasswordDto loginPasswordDto) {
+        String mobile = loginPasswordDto.getMobileOrEmail();
+        String password = loginPasswordDto.getPassword();
+        return cmDistributionService.passwordLogin(mobile, password);
+    }
+
+    /**
+     * 分销人员登录(手机号,验证码)
+     *
+     * @return UserLoginVo
+     */
+    @ApiOperation("分销人员登录(手机号,验证码)")
+    @PostMapping("/organizeDistribution")
+    public ResponseJson<UserLoginVo> organizeDistributionLogin(LoginCodeDto loginCodeDto) {
+        return cmDistributionService.organizeCodeLogin(loginCodeDto);
+    }
+
     /**
      * 微信授权登录(小程序),用户数据存入Redis,key前缀:wxInfo:applets:
      * <p>

+ 3 - 0
src/main/java/com/caimei365/user/controller/SellerApi.java

@@ -192,6 +192,9 @@ public class SellerApi {
      */
     @GetMapping("/setHome")
     public ResponseJson<ServiceProviderPo> setSellerHome(ServiceProviderPo serviceProviderPo) {
+        if (null == serviceProviderPo.getUserId()) {
+            return ResponseJson.error("参数异常:用户Id不能为空!", null);
+        }
         return sellerService.setSellerHome(new ServiceProviderPo()
                 .setUserId(serviceProviderPo.getUserId())
                 .setImage(serviceProviderPo.getImage())

+ 30 - 0
src/main/java/com/caimei365/user/mapper/BaseMapper.java

@@ -1,5 +1,6 @@
 package com.caimei365.user.mapper;
 
+import com.caimei365.user.model.po.CmUser;
 import com.caimei365.user.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -154,6 +155,12 @@ public interface BaseMapper {
      * @param userId   用户Id
      */
     void updateMobileByUserId(String mobile, Integer userId);
+    /**
+     * 根据用户Id修改头像
+     * @param image   头像
+     * @param userId   用户Id
+     */
+    void updateImageByUserId(String image, Integer userId);
     /**
      * 根据供应商Id修改手机号
      * @param mobile   手机号
@@ -176,4 +183,27 @@ public interface BaseMapper {
 
     Integer findBankByUserId(Integer userId);
     Integer getByUserId(@Param("userType")Integer userType,@Param("id")Integer id);
+
+    /**
+     * 新增用户信息
+     *
+     * @param user 用户信息
+     * @return 结果
+     */
+    public int addUser(CmUser user);
+
+    /**
+     * 修改用户信息
+     *
+     * @param user 用户信息
+     * @return 结果
+     */
+    public int updateUser(CmUser user);
+    /**
+     * 用户信息
+     *
+     * @param user 用户信息
+     * @return 结果
+     */
+    public CmUser getByUser(CmUser user);
 }

+ 122 - 0
src/main/java/com/caimei365/user/mapper/CmDistributionMapper.java

@@ -0,0 +1,122 @@
+package com.caimei365.user.mapper;
+
+import java.util.List;
+
+import com.caimei365.user.model.ResponseJson;
+import com.caimei365.user.model.po.CmDistribution;
+import com.caimei365.user.model.vo.UserLoginVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * distributionMapper接口
+ *
+ * @author Kaick
+ * @date 2023-09-25
+ */
+@Mapper
+public interface CmDistributionMapper
+{
+    /**
+     * 通过对象查询distribution列表
+     *
+     * @param cmDistribution distribution
+     * @return distribution集合
+     */
+    public List<CmDistribution> getCmDistributionList(CmDistribution cmDistribution);
+
+    /**
+     * 通过Id查询distribution对象
+     *
+     * @param id distribution主键
+     * @return distribution
+     */
+    public CmDistribution getCmDistributionById(String id);
+
+    /**
+     * 通过对象查询distribution对象
+     *
+     * @param cmDistribution distribution
+     * @return distribution
+     */
+    public CmDistribution getByCmDistribution(CmDistribution cmDistribution);
+
+    /**
+     * 通过对象查询distributionId
+     *
+     * @param cmDistribution distribution
+     * @return String
+     */
+    public String getById(CmDistribution cmDistribution);
+
+    /**
+     * 通过对象查询distributionIds
+     *
+     * @param cmDistribution distribution
+     * @return List<String>
+     */
+    public List<String> getByIds(CmDistribution cmDistribution);
+
+    /**
+     * 通过对象查询distribution记录总数
+     *
+     * @param cmDistribution distribution
+     * @return distributionInteger
+     */
+    public int getCmDistributionCount(CmDistribution cmDistribution);
+
+    /**
+     * 根据手机号获取协销
+     *
+     * @param mobile 手机号
+     * @return UserLoginVo
+     */
+    UserLoginVo getLoginDistributionByMobile(String mobile);
+    /**
+     * 新增distribution
+     *
+     * @param cmDistribution distribution
+     * @return 结果
+     */
+    public int addCmDistribution(CmDistribution cmDistribution);
+
+    /**
+     * 修改distribution
+     *
+     * @param cmDistribution distribution
+     * @return 结果
+     */
+    public int updateCmDistribution(CmDistribution cmDistribution);
+
+    /**
+     * 删除distribution
+     *
+     * @param id distribution主键
+     * @return 结果
+     */
+    public int delCmDistributionById(String id);
+
+    /**
+     * 批量删除distribution
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int delCmDistribution(CmDistribution cmDistribution);
+
+    /**
+     * 批量删除distribution
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int delCmDistributionByIds(@Param("ids") String[] ids);
+
+    /**
+     * 修改批量删除distribution
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int updateDelCmDistributionByIds(@Param("ids") String[] ids,@Param("delFlag") Integer delFlag);
+}

+ 227 - 0
src/main/java/com/caimei365/user/model/po/CmDistribution.java

@@ -0,0 +1,227 @@
+package com.caimei365.user.model.po;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.type.Alias;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import java.util.Date;
+
+/**
+ * distribution对象 cm_distribution
+ *
+ * @author Kaick
+ * @date 2023-09-25
+ */
+@Accessors(fluent  = true )
+@Data
+@Alias("CmDistribution")
+public class CmDistribution implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private String id;
+
+    /** 用户id */
+    private Integer userId;
+
+    /** 名称 */
+    private String name;
+
+    /** 联系人 */
+    private String linkMan;
+
+    /** 手机号 */
+    private String mobile;
+
+    /** 密码 */
+    private String password;
+
+    /** 公司名称 */
+    private String corporateName;
+
+    /** 分账号 */
+    private String splitCode;
+
+    /** 所属银行 */
+    private String bankName;
+
+    /** 银行卡号 */
+    private String bankAccount;
+
+    /** 状态:90上线,91下线 */
+    private Integer status;
+
+    /** 分销二维码 */
+    private String qrCode;
+
+    /** 头像 */
+    private String image;
+
+    /** 父级团队Id:0表示团队 */
+    private Integer parentId;
+
+    /** 父级团队Id集合 */
+    private String parentIds;
+
+    /** 修改时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    /** 添加时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date addTime;
+
+    /** 删除状态 0正常,其他删除 */
+    private Integer delFlag;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getLinkMan() {
+        return linkMan;
+    }
+
+    public void setLinkMan(String linkMan) {
+        this.linkMan = linkMan;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getCorporateName() {
+        return corporateName;
+    }
+
+    public void setCorporateName(String corporateName) {
+        this.corporateName = corporateName;
+    }
+
+    public String getSplitCode() {
+        return splitCode;
+    }
+
+    public void setSplitCode(String splitCode) {
+        this.splitCode = splitCode;
+    }
+
+    public String getBankName() {
+        return bankName;
+    }
+
+    public void setBankName(String bankName) {
+        this.bankName = bankName;
+    }
+
+    public String getBankAccount() {
+        return bankAccount;
+    }
+
+    public void setBankAccount(String bankAccount) {
+        this.bankAccount = bankAccount;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public String getQrCode() {
+        return qrCode;
+    }
+
+    public void setQrCode(String qrCode) {
+        this.qrCode = qrCode;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    public Integer getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Integer parentId) {
+        this.parentId = parentId;
+    }
+
+    public String getParentIds() {
+        return parentIds;
+    }
+
+    public void setParentIds(String parentIds) {
+        this.parentIds = parentIds;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Date getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(Date addTime) {
+        this.addTime = addTime;
+    }
+
+    public Integer getDelFlag() {
+        return delFlag;
+    }
+
+    public void setDelFlag(Integer delFlag) {
+        this.delFlag = delFlag;
+    }
+}
+

+ 488 - 0
src/main/java/com/caimei365/user/model/po/CmUser.java

@@ -0,0 +1,488 @@
+package com.caimei365.user.model.po;
+
+import java.math.BigDecimal;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.type.Alias;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import java.util.Date;
+
+/**
+ * 用户信息对象 user
+ *
+ * @author Kaick
+ * @date 2023-09-25
+ */
+@Accessors(fluent  = true )
+@Data
+@Alias("CmUser")
+public class CmUser implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private String userID;
+
+    /** 采美组织默认为0,具体对应cm_mall_organize表ID */
+    private String userOrganizeID;
+
+    /** 企业账号名【供应商,目前只存数据不能用于登录】 */
+    private String account;
+
+    /** 个人手机号码(协销) */
+    private String mobile;
+
+    /** 企业绑定手机号(机构,供应商) */
+    private String bindMobile;
+
+    /** 用户权限 0游客 1 普通用户 2 会员机构 3 供应商 4 协销 5 普通机构 6 呵呵商城用户【V6.2.0版本后0和1不存在】 */
+    private Integer userPermission;
+
+    /** 用户身份 0、个人 1、协销 2、会员机构 3、供应商 4.普通机构 6、呵呵商城用户【V6.2.0版本后0不存在】 */
+    private String userIdentity;
+
+    /** 邮箱 */
+    private String email;
+
+    /** 用户名(机构联系人,供应商简称) */
+    private String userName;
+
+    /** 真实姓名(供应商的联系人,机构不使用) */
+    private String realName;
+
+    /** 注册来源: 0网站 1小程序 */
+    private String source;
+
+    /** 头像 */
+    private String image;
+
+    /** 密码 */
+    private String password;
+
+    /** 名称(机构名称,供应商的公司名称) */
+    private String name;
+
+    /** 见枚举UserType(1供应商,2协销经理,32协销,3会员机构,4普通机构,6呵呵商城) */
+    private String registerUserTypeID;
+
+    /** 供应商状态, 3待审核, 90已上线,91已下线,92审核不通过 */
+    private Integer manufacturerStatus;
+
+    /** 供应商Id */
+    private Integer shopID;
+
+    /** 审核状态 */
+    private String auditStatus;
+
+    /** 审核时间 */
+    private String auditTime;
+
+    /** 审核备注 */
+    private String auditNote;
+
+    /** 注册时间 */
+    private String registerTime;
+
+    /** 注册ip */
+    private String registerIP;
+
+    /** 注册IP所属地 */
+    private String ipAddress;
+
+    /** 登录时间 */
+    private String loginTime;
+
+    /** 登录ip */
+    private String loginIP;
+
+    /** 用户状态,1正常,0冻结 */
+    private String validFlag;
+
+    /** 会所状态,见表c_clubstatus或枚举ClubStatus */
+    private Integer clubStatus;
+
+    /** 会所Id */
+    private Integer clubID;
+
+    /** 同意协议标志 */
+    private String agreeFlag;
+
+    /** 创客状态 */
+    private Integer serviceProviderStatus;
+
+    /** 创客Id */
+    private Integer serviceProviderID;
+
+    /** 账户线下余额 */
+    private BigDecimal userMoney;
+
+    /** 账户实际可用余额(提交订单未支付的被抵扣后的余额) */
+    private BigDecimal ableUserMoney;
+
+    /** 退出时间 */
+    private String logoffTime;
+
+    /** $column.columnComment */
+    private String appKey;
+
+    /** $column.columnComment */
+    private String appSecret;
+
+    /** 扫描标志(4 CRM拉上来的会所) 0待扫描 1 已扫描 2已上线 */
+    private Integer scanFlag;
+
+    /** 采美豆数量 */
+    private Integer userBeans;
+
+    /** 是否已经引导过(供应商首次登陆操作引导/普通机构升级引导) */
+    private Integer guideFlag;
+
+    /** $column.columnComment */
+    private Integer loginFailTime;
+
+    /** $column.columnComment */
+    private String tipStatus;
+
+    /** 账户线上余额 */
+    private BigDecimal onlineMoney;
+
+    public String getUserID() {
+        return userID;
+    }
+
+    public void setUserID(String userID) {
+        this.userID = userID;
+    }
+
+    public String getUserOrganizeID() {
+        return userOrganizeID;
+    }
+
+    public void setUserOrganizeID(String userOrganizeID) {
+        this.userOrganizeID = userOrganizeID;
+    }
+
+    public String getAccount() {
+        return account;
+    }
+
+    public void setAccount(String account) {
+        this.account = account;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getBindMobile() {
+        return bindMobile;
+    }
+
+    public void setBindMobile(String bindMobile) {
+        this.bindMobile = bindMobile;
+    }
+
+    public Integer getUserPermission() {
+        return userPermission;
+    }
+
+    public void setUserPermission(Integer userPermission) {
+        this.userPermission = userPermission;
+    }
+
+    public String getUserIdentity() {
+        return userIdentity;
+    }
+
+    public void setUserIdentity(String userIdentity) {
+        this.userIdentity = userIdentity;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getRealName() {
+        return realName;
+    }
+
+    public void setRealName(String realName) {
+        this.realName = realName;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getRegisterUserTypeID() {
+        return registerUserTypeID;
+    }
+
+    public void setRegisterUserTypeID(String registerUserTypeID) {
+        this.registerUserTypeID = registerUserTypeID;
+    }
+
+    public Integer getManufacturerStatus() {
+        return manufacturerStatus;
+    }
+
+    public void setManufacturerStatus(Integer manufacturerStatus) {
+        this.manufacturerStatus = manufacturerStatus;
+    }
+
+    public Integer getShopID() {
+        return shopID;
+    }
+
+    public void setShopID(Integer shopID) {
+        this.shopID = shopID;
+    }
+
+    public String getAuditStatus() {
+        return auditStatus;
+    }
+
+    public void setAuditStatus(String auditStatus) {
+        this.auditStatus = auditStatus;
+    }
+
+    public String getAuditTime() {
+        return auditTime;
+    }
+
+    public void setAuditTime(String auditTime) {
+        this.auditTime = auditTime;
+    }
+
+    public String getAuditNote() {
+        return auditNote;
+    }
+
+    public void setAuditNote(String auditNote) {
+        this.auditNote = auditNote;
+    }
+
+    public String getRegisterTime() {
+        return registerTime;
+    }
+
+    public void setRegisterTime(String registerTime) {
+        this.registerTime = registerTime;
+    }
+
+    public String getRegisterIP() {
+        return registerIP;
+    }
+
+    public void setRegisterIP(String registerIP) {
+        this.registerIP = registerIP;
+    }
+
+    public String getIpAddress() {
+        return ipAddress;
+    }
+
+    public void setIpAddress(String ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+
+    public String getLoginTime() {
+        return loginTime;
+    }
+
+    public void setLoginTime(String loginTime) {
+        this.loginTime = loginTime;
+    }
+
+    public String getLoginIP() {
+        return loginIP;
+    }
+
+    public void setLoginIP(String loginIP) {
+        this.loginIP = loginIP;
+    }
+
+    public String getValidFlag() {
+        return validFlag;
+    }
+
+    public void setValidFlag(String validFlag) {
+        this.validFlag = validFlag;
+    }
+
+    public Integer getClubStatus() {
+        return clubStatus;
+    }
+
+    public void setClubStatus(Integer clubStatus) {
+        this.clubStatus = clubStatus;
+    }
+
+    public Integer getClubID() {
+        return clubID;
+    }
+
+    public void setClubID(Integer clubID) {
+        this.clubID = clubID;
+    }
+
+    public String getAgreeFlag() {
+        return agreeFlag;
+    }
+
+    public void setAgreeFlag(String agreeFlag) {
+        this.agreeFlag = agreeFlag;
+    }
+
+    public Integer getServiceProviderStatus() {
+        return serviceProviderStatus;
+    }
+
+    public void setServiceProviderStatus(Integer serviceProviderStatus) {
+        this.serviceProviderStatus = serviceProviderStatus;
+    }
+
+    public Integer getServiceProviderID() {
+        return serviceProviderID;
+    }
+
+    public void setServiceProviderID(Integer serviceProviderID) {
+        this.serviceProviderID = serviceProviderID;
+    }
+
+    public BigDecimal getUserMoney() {
+        return userMoney;
+    }
+
+    public void setUserMoney(BigDecimal userMoney) {
+        this.userMoney = userMoney;
+    }
+
+    public BigDecimal getAbleUserMoney() {
+        return ableUserMoney;
+    }
+
+    public void setAbleUserMoney(BigDecimal ableUserMoney) {
+        this.ableUserMoney = ableUserMoney;
+    }
+
+    public String getLogoffTime() {
+        return logoffTime;
+    }
+
+    public void setLogoffTime(String logoffTime) {
+        this.logoffTime = logoffTime;
+    }
+
+    public String getAppKey() {
+        return appKey;
+    }
+
+    public void setAppKey(String appKey) {
+        this.appKey = appKey;
+    }
+
+    public String getAppSecret() {
+        return appSecret;
+    }
+
+    public void setAppSecret(String appSecret) {
+        this.appSecret = appSecret;
+    }
+
+    public Integer getScanFlag() {
+        return scanFlag;
+    }
+
+    public void setScanFlag(Integer scanFlag) {
+        this.scanFlag = scanFlag;
+    }
+
+    public Integer getUserBeans() {
+        return userBeans;
+    }
+
+    public void setUserBeans(Integer userBeans) {
+        this.userBeans = userBeans;
+    }
+
+    public Integer getGuideFlag() {
+        return guideFlag;
+    }
+
+    public void setGuideFlag(Integer guideFlag) {
+        this.guideFlag = guideFlag;
+    }
+
+    public Integer getLoginFailTime() {
+        return loginFailTime;
+    }
+
+    public void setLoginFailTime(Integer loginFailTime) {
+        this.loginFailTime = loginFailTime;
+    }
+
+    public String getTipStatus() {
+        return tipStatus;
+    }
+
+    public void setTipStatus(String tipStatus) {
+        this.tipStatus = tipStatus;
+    }
+
+    public BigDecimal getOnlineMoney() {
+        return onlineMoney;
+    }
+
+    public void setOnlineMoney(BigDecimal onlineMoney) {
+        this.onlineMoney = onlineMoney;
+    }
+}
+

+ 128 - 0
src/main/java/com/caimei365/user/service/CmDistributionService.java

@@ -0,0 +1,128 @@
+package com.caimei365.user.service;
+
+import com.caimei365.user.model.ResponseJson;
+import com.caimei365.user.model.dto.LoginCodeDto;
+import com.caimei365.user.model.po.CmDistribution;
+import com.caimei365.user.model.vo.UserLoginVo;
+
+import java.util.List;
+
+/**
+ * distributionService接口
+ *
+ * @author Kaick
+ * @date 2023-09-25
+ */
+public interface CmDistributionService
+{
+    /**
+     * 通过对象查询distribution列表
+     *
+     * @param cmDistribution distribution
+     * @return distribution集合
+     */
+    public List<CmDistribution> getCmDistributionList(CmDistribution cmDistribution);
+
+    /**
+     * 通过Id查询distribution
+     *
+     * @param id distribution主键
+     * @return distribution
+     */
+    public CmDistribution getCmDistributionById(String id);
+
+    /**
+     * 通过对象查询distribution
+     *
+     * @param cmDistribution distribution
+     * @return distribution
+     */
+    public CmDistribution getByCmDistribution(CmDistribution cmDistribution);
+
+    /**
+     * 通过对象查询distributionId
+     *
+     * @param cmDistribution distribution主键
+     * @return String
+     */
+    public String getById(CmDistribution cmDistribution);
+
+    /**
+     * 通过对象查询distributionIds
+     *
+     * @param cmDistribution distribution
+     * @return List<String>
+     */
+    public List<String> getByIds(CmDistribution cmDistribution);
+
+    /**
+     * 通过对象查询distribution记录总数
+     *
+     * @param cmDistribution distribution
+     * @return distributionInteger
+     */
+    public int getCmDistributionCount(CmDistribution cmDistribution);
+
+    /**
+     * 新增distribution
+     *
+     * @param cmDistribution distribution
+     * @return 结果
+     */
+    public int addCmDistribution(CmDistribution cmDistribution);
+
+    /**
+     * 修改distribution
+     *
+     * @param cmDistribution distribution
+     * @return 结果
+     */
+    public int updateCmDistribution(CmDistribution cmDistribution);
+
+    /**
+     * 删除distribution信息
+     *
+     * @param id distribution主键
+     * @return 结果
+     */
+    public int delCmDistributionById(String id);
+
+    /**
+     * 批量删除distribution
+     *
+     * @param ids 需要删除的distribution主键集合
+     * @return 结果
+     */
+    public int delCmDistributionByIds(String[] ids);
+
+    /**
+     * 批量新增distribution
+     *
+     * @param cmDistributionList distribution列表
+     * @return 结果
+     */
+    public void batchAddCmDistribution(List<CmDistribution> cmDistributionList);
+
+    /**
+     * 批量修改distribution
+     *
+     * @param cmDistributionList distribution列表
+     * @return 结果
+     */
+    public void batchUpdateCmDistribution(List<CmDistribution> cmDistributionList);
+
+    public ResponseJson<UserLoginVo> passwordLogin(String mobile, String password);
+
+    /**
+     * 分销人员登录验证码登录
+     * @param loginCodeDto
+     * @return
+     */
+    ResponseJson<UserLoginVo> organizeCodeLogin(LoginCodeDto loginCodeDto);
+    /**
+     * 修改分销人员登录密码
+     * @param cmDistribution
+     * @return
+     */
+     ResponseJson setPassword(CmDistribution cmDistribution, String code);
+}

+ 384 - 0
src/main/java/com/caimei365/user/service/impl/CmDistributionServiceImpl.java

@@ -0,0 +1,384 @@
+package com.caimei365.user.service.impl;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.caimei365.user.components.RedisService;
+import com.caimei365.user.components.WeChatService;
+import com.caimei365.user.mapper.BaseMapper;
+import com.caimei365.user.mapper.CmDistributionMapper;
+import com.caimei365.user.model.ResponseJson;
+import com.caimei365.user.model.dto.LoginCodeDto;
+import com.caimei365.user.model.po.CmDistribution;
+import com.caimei365.user.model.po.CmUser;
+import com.caimei365.user.model.vo.UserLoginVo;
+import com.caimei365.user.service.CmDistributionService;
+import com.caimei365.user.utils.DateUtil;
+import com.caimei365.user.utils.JwtUtil;
+import com.caimei365.user.utils.Md5Util;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.http.client.utils.DateUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * distributionService业务层处理
+ *
+ * @author Kaick
+ * @date 2023-09-25
+ */
+@Slf4j
+@Service
+public class CmDistributionServiceImpl implements CmDistributionService {
+    @Resource
+    private RedisService redisService;
+    @Resource
+    private BaseMapper baseMapper;
+    @Resource
+    private CmDistributionMapper cmDistributionMapper;
+
+    /**
+     * 通过对象查询distribution列表
+     *
+     * @param cmDistribution distribution
+     * @return distribution
+     */
+    @Override
+    public List<CmDistribution> getCmDistributionList(CmDistribution cmDistribution) {
+        return cmDistributionMapper.getCmDistributionList(cmDistribution);
+    }
+
+    /**
+     * 通过Id查询distribution
+     *
+     * @param id distribution主键
+     * @return distribution
+     */
+    @Override
+    public CmDistribution getCmDistributionById(String id) {
+        return cmDistributionMapper.getCmDistributionById(id);
+    }
+
+    /**
+     * 通过对象查询distribution
+     *
+     * @param cmDistribution distribution
+     * @return distribution
+     */
+    @Override
+    public CmDistribution getByCmDistribution(CmDistribution cmDistribution) {
+        return cmDistributionMapper.getByCmDistribution(cmDistribution);
+    }
+
+    /**
+     * 通过对象查询distributionId
+     *
+     * @param cmDistribution distribution
+     * @return String
+     */
+    @Override
+    public String getById(CmDistribution cmDistribution) {
+        return cmDistributionMapper.getById(cmDistribution);
+    }
+
+    /**
+     * 通过对象查询distributionIds
+     *
+     * @param cmDistribution distribution
+     * @return List<String>
+     */
+    @Override
+    public List<String> getByIds(CmDistribution cmDistribution) {
+        return cmDistributionMapper.getByIds(cmDistribution);
+    }
+
+    /**
+     * 通过对象查询distribution记录总数
+     *
+     * @param cmDistribution distribution
+     * @return int
+     */
+    @Override
+    public int getCmDistributionCount(CmDistribution cmDistribution) {
+        return cmDistributionMapper.getCmDistributionCount(cmDistribution);
+    }
+
+    /**
+     * 新增distribution
+     *
+     * @param cmDistribution distribution
+     * @return 结果
+     */
+    @Override
+    public int addCmDistribution(CmDistribution cmDistribution) {
+        cmDistribution.linkMan(cmDistribution.name());
+        CmUser cmUser = new CmUser();
+        cmUser.setMobile(cmDistribution.mobile());
+        cmUser.setBindMobile(cmDistribution.mobile());
+        cmUser.setServiceProviderStatus(cmDistribution.status());
+        cmUser.setRealName(cmDistribution.name());
+        cmUser.setUserName(cmDistribution.name());
+        cmUser.setName(cmDistribution.name());
+        cmUser.setAuditStatus("1");
+        cmUser.setAuditTime(DateUtil.formatDateTime(new Date()));
+        if (StringUtils.isBlank(cmDistribution.id())) {
+            cmUser.setUserOrganizeID("0");
+            cmUser.setMobile(cmDistribution.mobile());
+            cmUser.setBindMobile(cmDistribution.mobile());
+            cmUser.setUserIdentity("7");//外部协销
+            cmUser.setRegisterUserTypeID("32");//协销
+            cmUser.setRegisterTime(DateUtil.formatDateTime(new Date()));
+            cmUser.setServiceProviderID(Integer.valueOf(cmDistribution.id()));
+            cmUser.setValidFlag("1");
+            CmDistribution cmDistributionByParentId = cmDistributionMapper.getCmDistributionById(cmDistribution.id());
+            cmDistribution.parentIds(cmDistributionByParentId.parentIds() + "," + cmDistribution.parentId());
+            cmDistribution.corporateName(cmDistributionByParentId.corporateName());
+            cmDistribution.password(Md5Util.md5("1111aaaa"));
+            cmUser.setPassword(cmDistribution.password());
+            baseMapper.addUser(cmUser);
+            cmDistribution.userId(Integer.valueOf(cmUser.getUserID()));
+            return cmDistributionMapper.addCmDistribution(cmDistribution);
+        } else {
+            cmDistributionMapper.updateCmDistribution(cmDistribution);
+            cmUser.setUserID(String.valueOf(cmDistribution.userId()));
+            return baseMapper.updateUser(cmUser);
+        }
+    }
+
+    /**
+     * 修改distribution
+     *
+     * @param cmDistribution distribution
+     * @return 结果
+     */
+    @Override
+    public int updateCmDistribution(CmDistribution cmDistribution) {
+        cmDistribution.updateTime(new Date());
+        if (StringUtils.isNotBlank(cmDistribution.image())) {
+            baseMapper.updateImageByUserId(cmDistribution.image(), cmDistribution.userId());
+        }
+        if (StringUtils.isNotBlank(cmDistribution.password())) {
+            baseMapper.updatePasswordByUserId(cmDistribution.password(), cmDistribution.userId());
+        }
+        return cmDistributionMapper.updateCmDistribution(cmDistribution);
+    }
+
+
+    /**
+     * 删除distribution信息
+     *
+     * @param id distribution主键
+     * @return 结果
+     */
+    @Override
+    public int delCmDistributionById(String id) {
+        return cmDistributionMapper.updateCmDistribution(new CmDistribution().id(id).delFlag(1));
+        //return cmDistributionMapper.delCmDistributionById(id);
+    }
+
+    /**
+     * 批量删除distribution
+     *
+     * @param ids 需要删除的distribution主键
+     * @return 结果
+     */
+    @Override
+    public int delCmDistributionByIds(String[] ids) {
+        return cmDistributionMapper.updateDelCmDistributionByIds(ids, 1);
+        //return cmDistributionMapper.delCmDistributionByIds(ids);
+    }
+
+    /**
+     * 批量新增distribution
+     *
+     * @param cmDistributionList distribution列表
+     * @return 结果
+     */
+    @Override
+    public void batchAddCmDistribution(List<CmDistribution> cmDistributionList) {
+        for (CmDistribution cmDistribution : cmDistributionList) {
+            cmDistributionMapper.addCmDistribution(cmDistribution);
+        }
+    }
+
+    /**
+     * 批量修改distribution
+     *
+     * @param cmDistributionList distribution列表
+     * @return 结果
+     */
+    @Override
+    public void batchUpdateCmDistribution(List<CmDistribution> cmDistributionList) {
+        for (CmDistribution cmDistribution : cmDistributionList) {
+            cmDistributionMapper.updateCmDistribution(cmDistribution);
+        }
+    }
+
+    /**
+     * 协销登录(手机号,密码)
+     *
+     * @param mobile   手机号
+     * @param password 密码
+     * @return UserLoginVo
+     */
+    @Override
+    public ResponseJson<UserLoginVo> passwordLogin(String mobile, String password) {
+        if (StringUtils.isBlank(mobile) || StringUtils.isBlank(password)) {
+            return ResponseJson.error("请输入账号密码", null);
+        }
+        UserLoginVo distribution = cmDistributionMapper.getLoginDistributionByMobile(mobile);
+        if (null != distribution) {
+            String key = "login-" + distribution.getUserId();
+            boolean exists = redisService.exists(key);
+            //如果30分钟内输入错误记录>=5,return该账号暂时被冻结,请(30-最前一次时间)分钟后重试或直接修改密码
+            if (exists) {
+                String val = (String) redisService.get(key);
+                String[] split = val.split(",");
+                int count = Integer.parseInt(split[0]);
+                if (count >= 5) {
+                    long s = Long.parseLong(split[1]);
+                    int l = (int) Math.floor((System.currentTimeMillis() - s) / 1000 / 60);
+                    return ResponseJson.error("该账号暂时被冻结,请" + (30 - l) + "分钟后重试或直接修改密码", null);
+                }
+            }
+            // 比对密码
+            if (Md5Util.md5(password).equals(distribution.getPassword())) {
+                if (distribution.getServiceStatus().equals(90)) {
+                    // 生成token
+                    String token = JwtUtil.createToken(distribution.getUserId());
+                    // 为了过期续签,将token存入redis,并设置超时时间
+                    redisService.set(token, token, JwtUtil.getExpireTime());
+                    distribution.setToken(token);
+                    log.info("分销人员账号密码登录");
+                    return ResponseJson.success(distribution);
+                } else {
+                    return ResponseJson.error("登录账号已下线,请联系客服", null);
+                }
+            } else {
+                // 增加一次错误输入密码记录,30分钟内连续五次冻结
+                if (exists) {
+                    String val = (String) redisService.get(key);
+                    String[] split = val.split(",");
+                    int count = Integer.parseInt(split[0]);
+                    if (count < 5) {
+                        count++;
+                        String va = count + "," + System.currentTimeMillis();
+                        redisService.set(key, va);
+                    }
+                    if (count >= 5) {
+                        redisService.set(key, 5 + "," + System.currentTimeMillis(), 1800L);
+                    }
+                } else {
+                    String val = 1 + "," + System.currentTimeMillis();
+                    redisService.set(key, val);
+                }
+            }
+        }
+        return ResponseJson.error("账户名与密码不匹配,请重新输入", null);
+    }
+
+
+    /**
+     * 分销人员登录验证码登录
+     *
+     * @param loginCodeDto
+     * @return
+     */
+    @Override
+    public ResponseJson<UserLoginVo> organizeCodeLogin(LoginCodeDto loginCodeDto) {
+        String mobile = loginCodeDto.getMobile();
+        String code = loginCodeDto.getCode();
+        if (StringUtils.isBlank(mobile)) {
+            return ResponseJson.error("请输入手机号", null);
+        }
+        if (StringUtils.isBlank(code)) {
+            return ResponseJson.error("请输入验证码", null);
+        }
+        // 判断redis中是否存在
+        boolean exists = redisService.exists("code:" + mobile);
+        if (exists) {
+            // 查看验证码是否过期
+            long expireTime = redisService.getExpireTime("code:" + mobile);
+            if (expireTime < 0) {
+                return ResponseJson.error(-1, "验证码已失效,请重新获取", null);
+            }
+            // 获取redis手机短信验证码
+            Object randomCode = redisService.get("code:" + mobile);
+
+            if (!ObjectUtils.isEmpty(randomCode)) {
+                if (code.equals(randomCode.toString())) {
+                    redisService.remove("code:" + mobile);
+                    // 根据手机号获取分销人员
+                    UserLoginVo distribution = cmDistributionMapper.getLoginDistributionByMobile(mobile);
+                    if (distribution.getServiceStatus().equals(90)) {
+                        // 生成token
+                        String token = JwtUtil.createToken(distribution.getUserId());
+                        // 为了过期续签,将token存入redis,并设置超时时间
+                        redisService.set(token, token, JwtUtil.getExpireTime());
+                        distribution.setToken(token);
+                        log.info("分销人员账号密码登录");
+                        return ResponseJson.success(distribution);
+                    } else {
+                        return ResponseJson.error("登录账号已下线,请联系客服", null);
+                    }
+                } else {
+                    return ResponseJson.error(-1, "验证码错误,请确认验证码输入", null);
+                }
+            } else {
+                return ResponseJson.error(-1, "验证码错误, 请重新获取", null);
+            }
+        }
+        return ResponseJson.error();
+    }
+
+    /**
+     * 分销人员登录验证码登录
+     *
+     * @param cmDistribution
+     * @return
+     */
+    @Override
+    public ResponseJson setPassword(CmDistribution cmDistribution, String code) {
+        String mobile = cmDistribution.mobile();
+        if (StringUtils.isBlank(mobile)) {
+            return ResponseJson.error("请输入手机号", null);
+        }
+        if (StringUtils.isBlank(code)) {
+            return ResponseJson.error("请输入验证码", null);
+        }
+        // 判断redis中是否存在
+        boolean exists = redisService.exists("code:" + mobile);
+        if (exists) {
+            // 查看验证码是否过期
+            long expireTime = redisService.getExpireTime("code:" + mobile);
+            if (expireTime < 0) {
+                return ResponseJson.error(-1, "验证码已失效,请重新获取", null);
+            }
+            // 获取redis手机短信验证码
+            Object randomCode = redisService.get("code:" + mobile);
+
+            if (!ObjectUtils.isEmpty(randomCode)) {
+                if (code.equals(randomCode.toString())) {
+                    redisService.remove("code:" + mobile);
+                    UserLoginVo userBy = cmDistributionMapper.getLoginDistributionByMobile(mobile);
+                    updateCmDistribution(new CmDistribution()
+                            .userId(userBy.getUserId())
+                            .password(Md5Util.md5(cmDistribution.password()))
+                    );
+                    return ResponseJson.success();
+                } else {
+                    return ResponseJson.error(-1, "验证码错误,请确认验证码输入", null);
+                }
+            } else {
+                return ResponseJson.error(-1, "验证码错误, 请重新获取", null);
+            }
+        }
+        return ResponseJson.error();
+    }
+}
+
+

+ 341 - 0
src/main/resources/mapper/BaseMapper.xml

@@ -11,6 +11,14 @@
         set bindMobile = #{mobile}
         where userID = #{userId}
     </update>
+    <update id="updateImageByUserId">
+        update user
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="image != null and image != ''">image = #{image},</if>
+        </trim>
+        where userId = #{userId}
+    </update>
+
     <update id="updateShopMobileByShopId">
         update shop
         set contractMobile = #{mobile}
@@ -216,4 +224,337 @@
             </if>
         </if>
     </select>
+
+    <insert id="addUser" parameterType="CmUser" useGeneratedKeys="true" keyProperty="userID">
+        insert into user
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userID != null and userID != ''">userID,</if>
+            <if test="userOrganizeID != null">userOrganizeID,</if>
+            <if test="account != null and account != ''">account,</if>
+            <if test="mobile != null and mobile != ''">mobile,</if>
+            <if test="bindMobile != null and bindMobile != ''">bindMobile,</if>
+            <if test="userPermission != null">userPermission,</if>
+            <if test="userIdentity != null">userIdentity,</if>
+            <if test="email != null and email != ''">email,</if>
+            <if test="userName != null and userName != ''">userName,</if>
+            <if test="realName != null and realName != ''">realName,</if>
+            <if test="source != null and source != ''">source,</if>
+            <if test="image != null and image != ''">image,</if>
+            <if test="password != null and password != ''">password,</if>
+            <if test="name != null and name != ''">name,</if>
+            <if test="registerUserTypeID != null and registerUserTypeID != ''">registerUserTypeID,</if>
+            <if test="manufacturerStatus != null">manufacturerStatus,</if>
+            <if test="shopID != null">shopID,</if>
+            <if test="auditStatus != null and auditStatus != ''">auditStatus,</if>
+            <if test="auditTime != null and auditTime != ''">auditTime,</if>
+            <if test="auditNote != null and auditNote != ''">auditNote,</if>
+            <if test="registerTime != null and registerTime != ''">registerTime,</if>
+            <if test="registerIP != null and registerIP != ''">registerIP,</if>
+            <if test="ipAddress != null and ipAddress != ''">ipAddress,</if>
+            <if test="loginTime != null and loginTime != ''">loginTime,</if>
+            <if test="loginIP != null and loginIP != ''">loginIP,</if>
+            <if test="validFlag != null and validFlag != ''">validFlag,</if>
+            <if test="clubStatus != null">clubStatus,</if>
+            <if test="clubID != null">clubID,</if>
+            <if test="agreeFlag != null and agreeFlag != ''">agreeFlag,</if>
+            <if test="serviceProviderStatus != null">serviceProviderStatus,</if>
+            <if test="serviceProviderID != null">serviceProviderID,</if>
+            <if test="userMoney != null">userMoney,</if>
+            <if test="ableUserMoney != null">ableUserMoney,</if>
+            <if test="logoffTime != null and logoffTime != ''">logoffTime,</if>
+            <if test="appKey != null and appKey != ''">appKey,</if>
+            <if test="appSecret != null and appSecret != ''">appSecret,</if>
+            <if test="scanFlag != null">scanFlag,</if>
+            <if test="userBeans != null">userBeans,</if>
+            <if test="guideFlag != null">guideFlag,</if>
+            <if test="loginFailTime != null">loginFailTime,</if>
+            <if test="tipStatus != null and tipStatus != ''">tipStatus,</if>
+            <if test="onlineMoney != null">onlineMoney,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userID != null and userID != ''">#{userID},</if>
+            <if test="userOrganizeID != null">#{userOrganizeID},</if>
+            <if test="account != null and account != ''">#{account},</if>
+            <if test="mobile != null and mobile != ''">#{mobile},</if>
+            <if test="bindMobile != null and bindMobile != ''">#{bindMobile},</if>
+            <if test="userPermission != null">#{userPermission},</if>
+            <if test="userIdentity != null">#{userIdentity},</if>
+            <if test="email != null and email != ''">#{email},</if>
+            <if test="userName != null and userName != ''">#{userName},</if>
+            <if test="realName != null and realName != ''">#{realName},</if>
+            <if test="source != null and source != ''">#{source},</if>
+            <if test="image != null and image != ''">#{image},</if>
+            <if test="password != null and password != ''">#{password},</if>
+            <if test="name != null and name != ''">#{name},</if>
+            <if test="registerUserTypeID != null and registerUserTypeID != ''">#{registerUserTypeID},</if>
+            <if test="manufacturerStatus != null">#{manufacturerStatus},</if>
+            <if test="shopID != null">#{shopID},</if>
+            <if test="auditStatus != null and auditStatus != ''">#{auditStatus},</if>
+            <if test="auditTime != null and auditTime != ''">#{auditTime},</if>
+            <if test="auditNote != null and auditNote != ''">#{auditNote},</if>
+            <if test="registerTime != null and registerTime != ''">#{registerTime},</if>
+            <if test="registerIP != null and registerIP != ''">#{registerIP},</if>
+            <if test="ipAddress != null and ipAddress != ''">#{ipAddress},</if>
+            <if test="loginTime != null and loginTime != ''">#{loginTime},</if>
+            <if test="loginIP != null and loginIP != ''">#{loginIP},</if>
+            <if test="validFlag != null and validFlag != ''">#{validFlag},</if>
+            <if test="clubStatus != null">#{clubStatus},</if>
+            <if test="clubID != null">#{clubID},</if>
+            <if test="agreeFlag != null and agreeFlag != ''">#{agreeFlag},</if>
+            <if test="serviceProviderStatus != null">#{serviceProviderStatus},</if>
+            <if test="serviceProviderID != null">#{serviceProviderID},</if>
+            <if test="userMoney != null">#{userMoney},</if>
+            <if test="ableUserMoney != null">#{ableUserMoney},</if>
+            <if test="logoffTime != null and logoffTime != ''">#{logoffTime},</if>
+            <if test="appKey != null and appKey != ''">#{appKey},</if>
+            <if test="appSecret != null and appSecret != ''">#{appSecret},</if>
+            <if test="scanFlag != null">#{scanFlag},</if>
+            <if test="userBeans != null">#{userBeans},</if>
+            <if test="guideFlag != null">#{guideFlag},</if>
+            <if test="loginFailTime != null">#{loginFailTime},</if>
+            <if test="tipStatus != null and tipStatus != ''">#{tipStatus},</if>
+            <if test="onlineMoney != null">#{onlineMoney},</if>
+        </trim>
+    </insert>
+
+    <update id="updateUser" parameterType="CmUser">
+        update user
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userOrganizeID != null">userOrganizeID = #{userOrganizeID},</if>
+            <if test="account != null and account != ''">account = #{account},</if>
+            <if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
+            <if test="bindMobile != null and bindMobile != ''">bindMobile = #{bindMobile},</if>
+            <if test="userPermission != null">userPermission = #{userPermission},</if>
+            <if test="userIdentity != null">userIdentity = #{userIdentity},</if>
+            <if test="email != null and email != ''">email = #{email},</if>
+            <if test="userName != null and userName != ''">userName = #{userName},</if>
+            <if test="realName != null and realName != ''">realName = #{realName},</if>
+            <if test="source != null and source != ''">source = #{source},</if>
+            <if test="image != null and image != ''">image = #{image},</if>
+            <if test="password != null and password != ''">password = #{password},</if>
+            <if test="name != null and name != ''">name = #{name},</if>
+            <if test="registerUserTypeID != null and registerUserTypeID != ''">registerUserTypeID = #{registerUserTypeID},</if>
+            <if test="manufacturerStatus != null">manufacturerStatus = #{manufacturerStatus},</if>
+            <if test="shopID != null">shopID = #{shopID},</if>
+            <if test="auditStatus != null and auditStatus != ''">auditStatus = #{auditStatus},</if>
+            <if test="auditTime != null and auditTime != ''">auditTime = #{auditTime},</if>
+            <if test="auditNote != null and auditNote != ''">auditNote = #{auditNote},</if>
+            <if test="registerTime != null and registerTime != ''">registerTime = #{registerTime},</if>
+            <if test="registerIP != null and registerIP != ''">registerIP = #{registerIP},</if>
+            <if test="ipAddress != null and ipAddress != ''">ipAddress = #{ipAddress},</if>
+            <if test="loginTime != null and loginTime != ''">loginTime = #{loginTime},</if>
+            <if test="loginIP != null and loginIP != ''">loginIP = #{loginIP},</if>
+            <if test="validFlag != null and validFlag != ''">validFlag = #{validFlag},</if>
+            <if test="clubStatus != null">clubStatus = #{clubStatus},</if>
+            <if test="clubID != null">clubID = #{clubID},</if>
+            <if test="agreeFlag != null and agreeFlag != ''">agreeFlag = #{agreeFlag},</if>
+            <if test="serviceProviderStatus != null">serviceProviderStatus = #{serviceProviderStatus},</if>
+            <if test="serviceProviderID != null">serviceProviderID = #{serviceProviderID},</if>
+            <if test="userMoney != null">userMoney = #{userMoney},</if>
+            <if test="ableUserMoney != null">ableUserMoney = #{ableUserMoney},</if>
+            <if test="logoffTime != null and logoffTime != ''">logoffTime = #{logoffTime},</if>
+            <if test="appKey != null and appKey != ''">appKey = #{appKey},</if>
+            <if test="appSecret != null and appSecret != ''">appSecret = #{appSecret},</if>
+            <if test="scanFlag != null">scanFlag = #{scanFlag},</if>
+            <if test="userBeans != null">userBeans = #{userBeans},</if>
+            <if test="guideFlag != null">guideFlag = #{guideFlag},</if>
+            <if test="loginFailTime != null">loginFailTime = #{loginFailTime},</if>
+            <if test="tipStatus != null and tipStatus != ''">tipStatus = #{tipStatus},</if>
+            <if test="onlineMoney != null">onlineMoney = #{onlineMoney},</if>
+        </trim>
+        where userID = #{userID}
+    </update>
+
+
+    <resultMap type="CmUser" id="UserResult">
+        <result property="userID"    column="userID"    />
+        <result property="userOrganizeID"    column="userOrganizeID"    />
+        <result property="account"    column="account"    />
+        <result property="mobile"    column="mobile"    />
+        <result property="bindMobile"    column="bindMobile"    />
+        <result property="userPermission"    column="userPermission"    />
+        <result property="userIdentity"    column="userIdentity"    />
+        <result property="email"    column="email"    />
+        <result property="userName"    column="userName"    />
+        <result property="realName"    column="realName"    />
+        <result property="source"    column="source"    />
+        <result property="image"    column="image"    />
+        <result property="password"    column="password"    />
+        <result property="name"    column="name"    />
+        <result property="registerUserTypeID"    column="registerUserTypeID"    />
+        <result property="manufacturerStatus"    column="manufacturerStatus"    />
+        <result property="shopID"    column="shopID"    />
+        <result property="auditStatus"    column="auditStatus"    />
+        <result property="auditTime"    column="auditTime"    />
+        <result property="auditNote"    column="auditNote"    />
+        <result property="registerTime"    column="registerTime"    />
+        <result property="registerIP"    column="registerIP"    />
+        <result property="ipAddress"    column="ipAddress"    />
+        <result property="loginTime"    column="loginTime"    />
+        <result property="loginIP"    column="loginIP"    />
+        <result property="validFlag"    column="validFlag"    />
+        <result property="clubStatus"    column="clubStatus"    />
+        <result property="clubID"    column="clubID"    />
+        <result property="agreeFlag"    column="agreeFlag"    />
+        <result property="serviceProviderStatus"    column="serviceProviderStatus"    />
+        <result property="serviceProviderID"    column="serviceProviderID"    />
+        <result property="userMoney"    column="userMoney"    />
+        <result property="ableUserMoney"    column="ableUserMoney"    />
+        <result property="logoffTime"    column="logoffTime"    />
+        <result property="appKey"    column="appKey"    />
+        <result property="appSecret"    column="appSecret"    />
+        <result property="scanFlag"    column="scanFlag"    />
+        <result property="userBeans"    column="userBeans"    />
+        <result property="guideFlag"    column="guideFlag"    />
+        <result property="loginFailTime"    column="loginFailTime"    />
+        <result property="tipStatus"    column="tipStatus"    />
+        <result property="onlineMoney"    column="onlineMoney"    />
+    </resultMap>
+
+    <sql id="selectUserVo">
+        select
+            user.userID,
+            user.userOrganizeID,
+            user.account,
+            user.mobile,
+            user.bindMobile,
+            user.userPermission,
+            user.userIdentity,
+            user.email,
+            user.userName,
+            user.realName,
+            user.source,
+            user.image,
+            user.password,
+            user.name,
+            user.registerUserTypeID,
+            user.manufacturerStatus,
+            user.shopID,
+            user.auditStatus,
+            user.auditTime,
+            user.auditNote,
+            user.registerTime,
+            user.registerIP,
+            user.ipAddress,
+            user.loginTime,
+            user.loginIP,
+            user.validFlag,
+            user.clubStatus,
+            user.clubID,
+            user.agreeFlag,
+            user.serviceProviderStatus,
+            user.serviceProviderID,
+            ifnull(user.userMoney,0) AS userMoney,
+            ifnull(user.ableUserMoney,0) AS ableUserMoney,
+            user.logoffTime,
+            user.appKey,
+            user.appSecret,
+            user.scanFlag,
+            user.userBeans,
+            user.guideFlag,
+            user.loginFailTime,
+            user.tipStatus,
+            ifnull(user.onlineMoney,0) AS onlineMoney
+    </sql>
+
+    <select id="getByUser" parameterType="CmUser" resultMap="UserResult">
+        <include refid="selectUserVo"/>
+        from user AS user
+        <where>  user.delFlag = 0
+            <if test="userID != null  and userID != ''">
+                and user.userID
+                <if test="userID.toUpperCase().indexOf('=')==-1">
+                    = #{userID}
+                </if>
+                <if test="userID.toUpperCase().indexOf('=')!=-1">
+                    <if test="userID.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="userID.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="userIDIn" collection="userID.substring(userID.toUpperCase().indexOf('=')+1,userID.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{userIDIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="userOrganizeID != null  and userOrganizeID != ''">
+                and user.userOrganizeID
+                <if test="userOrganizeID.toUpperCase().indexOf('=')==-1">
+                    = #{userOrganizeID}
+                </if>
+                <if test="userOrganizeID.toUpperCase().indexOf('=')!=-1">
+                    <if test="userOrganizeID.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="userOrganizeID.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="typeIn" collection="userOrganizeID.substring(userOrganizeID.toUpperCase().indexOf('=')+1,userOrganizeID.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{typeIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="account != null  and account != ''"> and user.account = #{account}</if>
+            <if test="mobile != null  and mobile != ''"> and user.mobile = #{mobile}</if>
+            <if test="bindMobile != null  and bindMobile != ''"> and user.bindMobile = #{bindMobile}</if>
+            <if test="userPermission != null "> and user.userPermission = #{userPermission}</if>
+            <if test="userIdentity != null  and userIdentity != ''">
+                and user.userIdentity
+                <if test="userIdentity.toUpperCase().indexOf('=')==-1">
+                    = #{userIdentity}
+                </if>
+                <if test="userIdentity.toUpperCase().indexOf('=')!=-1">
+                    <if test="userIdentity.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="userIdentity.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="typeIn" collection="userIdentity.substring(userIdentity.toUpperCase().indexOf('=')+1,userIdentity.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{typeIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="email != null  and email != ''"> and user.email = #{email}</if>
+            <if test="userName != null  and userName != ''"> and user.userName like concat('%', #{userName}, '%')</if>
+            <if test="realName != null  and realName != ''"> and user.realName like concat('%', #{realName}, '%')</if>
+            <if test="source != null  and source != ''"> and user.source = #{source}</if>
+            <if test="image != null  and image != ''"> and user.image = #{image}</if>
+            <if test="password != null  and password != ''"> and user.password = #{password}</if>
+            <if test="name != null  and name != ''"> and user.name like concat('%', #{name}, '%')</if>
+            <if test="registerUserTypeID != null  and registerUserTypeID != ''">
+                and user.registerUserTypeID
+                <if test="registerUserTypeID.toUpperCase().indexOf('=')==-1">
+                    = #{registerUserTypeID}
+                </if>
+                <if test="registerUserTypeID.toUpperCase().indexOf('=')!=-1">
+                    <if test="registerUserTypeID.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="registerUserTypeID.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="typeIn" collection="registerUserTypeID.substring(registerUserTypeID.toUpperCase().indexOf('=')+1,registerUserTypeID.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{typeIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="manufacturerStatus != null "> and user.manufacturerStatus = #{manufacturerStatus}</if>
+            <if test="shopID != null "> and user.shopID = #{shopID}</if>
+            <if test="auditStatus != null  and auditStatus != ''"> and user.auditStatus = #{auditStatus}</if>
+            <if test="auditTime != null  and auditTime != ''"> and user.auditTime = #{auditTime}</if>
+            <if test="auditNote != null  and auditNote != ''"> and user.auditNote = #{auditNote}</if>
+            <if test="registerTime != null  and registerTime != ''"> and user.registerTime = #{registerTime}</if>
+            <if test="registerIP != null  and registerIP != ''"> and user.registerIP = #{registerIP}</if>
+            <if test="ipAddress != null  and ipAddress != ''"> and user.ipAddress = #{ipAddress}</if>
+            <if test="loginTime != null  and loginTime != ''"> and user.loginTime = #{loginTime}</if>
+            <if test="loginIP != null  and loginIP != ''"> and user.loginIP = #{loginIP}</if>
+            <if test="validFlag != null  and validFlag != ''"> and user.validFlag = #{validFlag}</if>
+            <if test="clubStatus != null "> and user.clubStatus = #{clubStatus}</if>
+            <if test="clubID != null "> and user.clubID = #{clubID}</if>
+            <if test="agreeFlag != null  and agreeFlag != ''"> and user.agreeFlag = #{agreeFlag}</if>
+            <if test="serviceProviderStatus != null "> and user.serviceProviderStatus = #{serviceProviderStatus}</if>
+            <if test="serviceProviderID != null "> and user.serviceProviderID = #{serviceProviderID}</if>
+            <if test="userMoney != null "> and user.userMoney = #{userMoney}</if>
+            <if test="ableUserMoney != null "> and user.ableUserMoney = #{ableUserMoney}</if>
+            <if test="logoffTime != null  and logoffTime != ''"> and user.logoffTime = #{logoffTime}</if>
+            <if test="appKey != null  and appKey != ''"> and user.appKey = #{appKey}</if>
+            <if test="appSecret != null  and appSecret != ''"> and user.appSecret = #{appSecret}</if>
+            <if test="scanFlag != null "> and user.scanFlag = #{scanFlag}</if>
+            <if test="userBeans != null "> and user.userBeans = #{userBeans}</if>
+            <if test="guideFlag != null "> and user.guideFlag = #{guideFlag}</if>
+            <if test="loginFailTime != null "> and user.loginFailTime = #{loginFailTime}</if>
+            <if test="tipStatus != null  and tipStatus != ''"> and user.tipStatus = #{tipStatus}</if>
+            <if test="onlineMoney != null "> and user.onlineMoney = #{onlineMoney}</if>
+        </where>
+        group by user.userID
+        order by user.loginTime desc
+        limit 0,1
+    </select>
+
 </mapper>

+ 391 - 0
src/main/resources/mapper/CmDistributionMapper.xml

@@ -0,0 +1,391 @@
+<?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">
+<mapper namespace="com.caimei365.user.mapper.CmDistributionMapper">
+
+    <resultMap type="CmDistribution" id="CmDistributionResult">
+        <result property="id"    column="id"    />
+        <result property="userId"    column="userId"    />
+        <result property="name"    column="name"    />
+        <result property="linkMan"    column="linkMan"    />
+        <result property="mobile"    column="mobile"    />
+        <result property="password"    column="password"    />
+        <result property="corporateName"    column="corporateName"    />
+        <result property="splitCode"    column="splitCode"    />
+        <result property="bankName"    column="bankName"    />
+        <result property="bankAccount"    column="bankAccount"    />
+        <result property="status"    column="status"    />
+        <result property="qrCode"    column="qrCode"    />
+        <result property="parentId"    column="parentId"    />
+        <result property="parentIds"    column="parentIds"    />
+        <result property="updateTime"    column="updateTime"    />
+        <result property="addTime"    column="addTime"    />
+        <result property="delFlag"    column="delFlag"    />
+        <result property="image"    column="image"    />
+    </resultMap>
+
+    <sql id="selectCmDistributionVo">
+         select
+         cm_distribution.id,
+         cm_distribution.userId,
+         cm_distribution.name,
+         cm_distribution.linkMan,
+         cm_distribution.mobile,
+         cm_distribution.password,
+         cm_distribution.corporateName,
+         cm_distribution.splitCode,
+         cm_distribution.bankName,
+         cm_distribution.bankAccount,
+         cm_distribution.status,
+         cm_distribution.qrCode,
+         cm_distribution.parentId,
+         cm_distribution.parentIds,
+         cm_distribution.updateTime,
+         cm_distribution.addTime,
+         cm_distribution.delFlag,
+         u.image
+    </sql>
+
+    <select id="getByCmDistribution" parameterType="CmDistribution" resultMap="CmDistributionResult">
+        <include refid="selectCmDistributionVo"/>
+        from cm_distribution AS cm_distribution
+        left join user u on u.userId=cm_distribution.userId
+        <where>  cm_distribution.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_distribution.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="userId != null "> and cm_distribution.userId = #{userId}</if>
+            <if test="name != null  and name != ''"> and cm_distribution.name like concat('%', #{name}, '%')</if>
+            <if test="linkMan != null  and linkMan != ''"> and cm_distribution.linkMan = #{linkMan}</if>
+            <if test="mobile != null  and mobile != ''"> and cm_distribution.mobile = #{mobile}</if>
+            <if test="password != null  and password != ''"> and cm_distribution.password = #{password}</if>
+            <if test="corporateName != null  and corporateName != ''"> and cm_distribution.corporateName like concat('%', #{corporateName}, '%')</if>
+            <if test="splitCode != null  and splitCode != ''"> and cm_distribution.splitCode = #{splitCode}</if>
+            <if test="bankName != null  and bankName != ''"> and cm_distribution.bankName like concat('%', #{bankName}, '%')</if>
+            <if test="bankAccount != null  and bankAccount != ''"> and cm_distribution.bankAccount = #{bankAccount}</if>
+            <if test="status != null "> and cm_distribution.status = #{status}</if>
+            <if test="qrCode != null  and qrCode != ''"> and cm_distribution.qrCode = #{qrCode}</if>
+            <if test="parentId != null "> and cm_distribution.parentId = #{parentId}</if>
+            <if test="parentIds != null  and parentIds != ''"> and cm_distribution.parentIds = #{parentIds}</if>
+            <if test="updateTime != null "> and cm_distribution.updateTime = #{updateTime}</if>
+            <if test="addTime != null "> and cm_distribution.addTime = #{addTime}</if>
+        </where>
+        group by cm_distribution.id
+        order by cm_distribution.addTime desc
+        limit 0,1
+    </select>
+
+    <select id="getCmDistributionList" parameterType="CmDistribution" resultMap="CmDistributionResult">
+        <include refid="selectCmDistributionVo"/>
+        from cm_distribution AS cm_distribution
+        left join user u on u.userId=cm_distribution.userId
+        <where>  cm_distribution.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_distribution.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="userId != null "> and cm_distribution.userId = #{userId}</if>
+            <if test="name != null  and name != ''"> and cm_distribution.name like concat('%', #{name}, '%')</if>
+            <if test="linkMan != null  and linkMan != ''"> and cm_distribution.linkMan = #{linkMan}</if>
+            <if test="mobile != null  and mobile != ''"> and cm_distribution.mobile = #{mobile}</if>
+            <if test="password != null  and password != ''"> and cm_distribution.password = #{password}</if>
+            <if test="corporateName != null  and corporateName != ''"> and cm_distribution.corporateName like concat('%', #{corporateName}, '%')</if>
+            <if test="splitCode != null  and splitCode != ''"> and cm_distribution.splitCode = #{splitCode}</if>
+            <if test="bankName != null  and bankName != ''"> and cm_distribution.bankName like concat('%', #{bankName}, '%')</if>
+            <if test="bankAccount != null  and bankAccount != ''"> and cm_distribution.bankAccount = #{bankAccount}</if>
+            <if test="status != null "> and cm_distribution.status = #{status}</if>
+            <if test="qrCode != null  and qrCode != ''"> and cm_distribution.qrCode = #{qrCode}</if>
+            <if test="parentId != null "> and cm_distribution.parentId = #{parentId}</if>
+            <if test="parentIds != null  and parentIds != ''"> and cm_distribution.parentIds = #{parentIds}</if>
+            <if test="updateTime != null "> and cm_distribution.updateTime = #{updateTime}</if>
+            <if test="addTime != null "> and cm_distribution.addTime = #{addTime}</if>
+        </where>
+        group by cm_distribution.id
+        order by cm_distribution.addTime desc
+    </select>
+
+    <select id="getCmDistributionCount" parameterType="CmDistribution" resultType="int">
+       select count(1)
+        from cm_distribution AS cm_distribution
+        left join user u on u.userId=cm_distribution.userId
+        <where>  cm_distribution.delFlag = 0
+            <if test="id != null  and  id != ''">
+                    and cm_distribution.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                        = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                            #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="userId != null "> and cm_distribution.userId = #{userId}</if>
+            <if test="name != null  and name != ''"> and cm_distribution.name like concat('%', #{name}, '%')</if>
+            <if test="linkMan != null  and linkMan != ''"> and cm_distribution.linkMan = #{linkMan}</if>
+            <if test="mobile != null  and mobile != ''"> and cm_distribution.mobile = #{mobile}</if>
+            <if test="password != null  and password != ''"> and cm_distribution.password = #{password}</if>
+            <if test="corporateName != null  and corporateName != ''"> and cm_distribution.corporateName like concat('%', #{corporateName}, '%')</if>
+            <if test="splitCode != null  and splitCode != ''"> and cm_distribution.splitCode = #{splitCode}</if>
+            <if test="bankName != null  and bankName != ''"> and cm_distribution.bankName like concat('%', #{bankName}, '%')</if>
+            <if test="bankAccount != null  and bankAccount != ''"> and cm_distribution.bankAccount = #{bankAccount}</if>
+            <if test="status != null "> and cm_distribution.status = #{status}</if>
+            <if test="qrCode != null  and qrCode != ''"> and cm_distribution.qrCode = #{qrCode}</if>
+            <if test="parentId != null "> and cm_distribution.parentId = #{parentId}</if>
+            <if test="parentIds != null  and parentIds != ''"> and cm_distribution.parentIds = #{parentIds}</if>
+            <if test="updateTime != null "> and cm_distribution.updateTime = #{updateTime}</if>
+            <if test="addTime != null "> and cm_distribution.addTime = #{addTime}</if>
+        </where>
+        group by cm_distribution.id
+    </select>
+
+    <select id="getCmDistributionById" parameterType="String" resultMap="CmDistributionResult">
+        <include refid="selectCmDistributionVo"/>
+        from cm_distribution AS cm_distribution
+        left join user u on u.userId=cm_distribution.userId
+        where  cm_distribution.delFlag = 0 and cm_distribution.id = #{id}
+    </select>
+
+    <select id="getByIds" parameterType="CmDistribution" resultType="String">
+        select id
+        from cm_distribution AS cm_distribution
+        left join user u on u.userId=cm_distribution.userId
+        <where>  cm_distribution.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_distribution.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+                <if test="userId != null "> and cm_distribution.userId = #{userId}</if>
+            <if test="name != null  and name != ''"> and cm_distribution.name like concat('%', #{name}, '%')</if>
+            <if test="linkMan != null  and linkMan != ''"> and cm_distribution.linkMan = #{linkMan}</if>
+            <if test="mobile != null  and mobile != ''"> and cm_distribution.mobile = #{mobile}</if>
+            <if test="password != null  and password != ''"> and cm_distribution.password = #{password}</if>
+            <if test="corporateName != null  and corporateName != ''"> and cm_distribution.corporateName like concat('%', #{corporateName}, '%')</if>
+            <if test="splitCode != null  and splitCode != ''"> and cm_distribution.splitCode = #{splitCode}</if>
+            <if test="bankName != null  and bankName != ''"> and cm_distribution.bankName like concat('%', #{bankName}, '%')</if>
+            <if test="bankAccount != null  and bankAccount != ''"> and cm_distribution.bankAccount = #{bankAccount}</if>
+            <if test="status != null "> and cm_distribution.status = #{status}</if>
+            <if test="qrCode != null  and qrCode != ''"> and cm_distribution.qrCode = #{qrCode}</if>
+            <if test="parentId != null "> and cm_distribution.parentId = #{parentId}</if>
+            <if test="parentIds != null  and parentIds != ''"> and cm_distribution.parentIds = #{parentIds}</if>
+            <if test="updateTime != null "> and cm_distribution.updateTime = #{updateTime}</if>
+            <if test="addTime != null "> and cm_distribution.addTime = #{addTime}</if>
+        </where>
+        group by cm_distribution.id
+    </select>
+
+    <select id="getById" parameterType="CmDistribution" resultType="String">
+        select id
+        from cm_distribution AS cm_distribution
+        left join user u on u.userId=cm_distribution.userId
+        <where>  cm_distribution.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_distribution.id
+                <if test="id.toString().toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toString().toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toString().toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toString().toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.toString().substring(id.toString().toUpperCase().indexOf('=')+1,id.toString().length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+                <if test="userId != null "> and cm_distribution.userId = #{userId}</if>
+            <if test="name != null  and name != ''"> and cm_distribution.name like concat('%', #{name}, '%')</if>
+            <if test="linkMan != null  and linkMan != ''"> and cm_distribution.linkMan = #{linkMan}</if>
+            <if test="mobile != null  and mobile != ''"> and cm_distribution.mobile = #{mobile}</if>
+            <if test="password != null  and password != ''"> and cm_distribution.password = #{password}</if>
+            <if test="corporateName != null  and corporateName != ''"> and cm_distribution.corporateName like concat('%', #{corporateName}, '%')</if>
+            <if test="splitCode != null  and splitCode != ''"> and cm_distribution.splitCode = #{splitCode}</if>
+            <if test="bankName != null  and bankName != ''"> and cm_distribution.bankName like concat('%', #{bankName}, '%')</if>
+            <if test="bankAccount != null  and bankAccount != ''"> and cm_distribution.bankAccount = #{bankAccount}</if>
+            <if test="status != null "> and cm_distribution.status = #{status}</if>
+            <if test="qrCode != null  and qrCode != ''"> and cm_distribution.qrCode = #{qrCode}</if>
+            <if test="parentId != null "> and cm_distribution.parentId = #{parentId}</if>
+            <if test="parentIds != null  and parentIds != ''"> and cm_distribution.parentIds = #{parentIds}</if>
+            <if test="updateTime != null "> and cm_distribution.updateTime = #{updateTime}</if>
+            <if test="addTime != null "> and cm_distribution.addTime = #{addTime}</if>
+        </where>
+        group by cm_distribution.id
+        limit 0,1
+    </select>
+
+    <select id="getLoginDistributionByMobile" resultType="com.caimei365.user.model.vo.UserLoginVo">
+        select u.userID         as userId,
+               u.clubID         as clubId,
+               u.shopID         as shopId,
+               u.userName       as userName,
+               u.name           as name,
+               u.mobile         as mobile,
+               u.bindMobile     as bindMobile,
+               u.email          as email,
+               u.image          as image,
+               u.guideFlag      as guideFlag,
+               u.userPermission as userPermission,
+               u.userIdentity   as userIdentity,
+               u.serviceProviderID as serviceProviderId,
+               u.serviceProviderStatus as serviceStatus,
+               u.password       as password
+        from user u
+        where u.bindMobile = #{mobile}
+          and u.userIdentity = 7
+          and u.validFlag = 1
+    </select>
+
+    <insert id="addCmDistribution" parameterType="CmDistribution" useGeneratedKeys="true" keyProperty="id">
+        insert into cm_distribution
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null and id != ''">id,</if>
+            <if test="userId != null">userId,</if>
+            <if test="name != null and name != ''">name,</if>
+            <if test="linkMan != null and linkMan != ''">linkMan,</if>
+            <if test="mobile != null and mobile != ''">mobile,</if>
+            <if test="password != null and password != ''">password,</if>
+            <if test="corporateName != null and corporateName != ''">corporateName,</if>
+            <if test="splitCode != null and splitCode != ''">splitCode,</if>
+            <if test="bankName != null and bankName != ''">bankName,</if>
+            <if test="bankAccount != null and bankAccount != ''">bankAccount,</if>
+            <if test="status != null">status,</if>
+            <if test="qrCode != null and qrCode != ''">qrCode,</if>
+            <if test="parentId != null">parentId,</if>
+            <if test="parentIds != null and parentIds != ''">parentIds,</if>
+            <if test="updateTime != null">updateTime,</if>
+            <if test="addTime != null">addTime,</if>
+            <if test="delFlag != null">delFlag,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null and id != ''">#{id},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="name != null and name != ''">#{name},</if>
+            <if test="linkMan != null and linkMan != ''">#{linkMan},</if>
+            <if test="mobile != null and mobile != ''">#{mobile},</if>
+            <if test="password != null and password != ''">#{password},</if>
+            <if test="corporateName != null and corporateName != ''">#{corporateName},</if>
+            <if test="splitCode != null and splitCode != ''">#{splitCode},</if>
+            <if test="bankName != null and bankName != ''">#{bankName},</if>
+            <if test="bankAccount != null and bankAccount != ''">#{bankAccount},</if>
+            <if test="status != null">#{status},</if>
+            <if test="qrCode != null and qrCode != ''">#{qrCode},</if>
+            <if test="parentId != null">#{parentId},</if>
+            <if test="parentIds != null and parentIds != ''">#{parentIds},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="addTime != null">#{addTime},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+         </trim>
+    </insert>
+
+    <update id="updateCmDistribution" parameterType="CmDistribution">
+        update cm_distribution
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userId != null">userId = #{userId},</if>
+            <if test="name != null and name != ''">name = #{name},</if>
+            <if test="linkMan != null and linkMan != ''">linkMan = #{linkMan},</if>
+            <if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
+            <if test="password != null and password != ''">password = #{password},</if>
+            <if test="corporateName != null and corporateName != ''">corporateName = #{corporateName},</if>
+            <if test="splitCode != null and splitCode != ''">splitCode = #{splitCode},</if>
+            <if test="bankName != null and bankName != ''">bankName = #{bankName},</if>
+            <if test="bankAccount != null and bankAccount != ''">bankAccount = #{bankAccount},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="qrCode != null and qrCode != ''">qrCode = #{qrCode},</if>
+            <if test="parentId != null">parentId = #{parentId},</if>
+            <if test="parentIds != null and parentIds != ''">parentIds = #{parentIds},</if>
+            <if test="updateTime != null">updateTime = #{updateTime},</if>
+            <if test="addTime != null">addTime = #{addTime},</if>
+            <if test="delFlag != null">delFlag = #{delFlag},</if>
+        </trim>
+        where 1=1
+        <if test="id != null">and id = #{id}</if>
+        <if test="userId != null">and userId = #{userId}</if>
+    </update>
+
+    <update id="updateDelCmDistributionByIds" parameterType="String">
+        update cm_distribution set delFlag=#{delFlag} where id in
+        <foreach item="id" collection="ids" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+
+    <delete id="delCmDistributionById" parameterType="String">
+        delete
+        from cm_distribution where id = #{id}
+    </delete>
+
+    <delete id="delCmDistribution" parameterType="CmDistribution">
+        delete
+        from cm_distribution AS cm_distribution
+        left join user u on u.userId=cm_distribution.userId
+        <where>
+            <if test="id != null  and id != ''">
+                and cm_distribution.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="userId != null "> and cm_distribution.userId = #{userId}</if>
+            <if test="name != null  and name != ''"> and cm_distribution.name like concat('%', #{name}, '%')</if>
+            <if test="linkMan != null  and linkMan != ''"> and cm_distribution.linkMan = #{linkMan}</if>
+            <if test="mobile != null  and mobile != ''"> and cm_distribution.mobile = #{mobile}</if>
+            <if test="password != null  and password != ''"> and cm_distribution.password = #{password}</if>
+            <if test="corporateName != null  and corporateName != ''"> and cm_distribution.corporateName like concat('%', #{corporateName}, '%')</if>
+            <if test="splitCode != null  and splitCode != ''"> and cm_distribution.splitCode = #{splitCode}</if>
+            <if test="bankName != null  and bankName != ''"> and cm_distribution.bankName like concat('%', #{bankName}, '%')</if>
+            <if test="bankAccount != null  and bankAccount != ''"> and cm_distribution.bankAccount = #{bankAccount}</if>
+            <if test="status != null "> and cm_distribution.status = #{status}</if>
+            <if test="qrCode != null  and qrCode != ''"> and cm_distribution.qrCode = #{qrCode}</if>
+            <if test="parentId != null "> and cm_distribution.parentId = #{parentId}</if>
+            <if test="parentIds != null  and parentIds != ''"> and cm_distribution.parentIds = #{parentIds}</if>
+            <if test="updateTime != null "> and cm_distribution.updateTime = #{updateTime}</if>
+            <if test="addTime != null "> and cm_distribution.addTime = #{addTime}</if>
+            <if test="delFlag != null "> and cm_distribution.delFlag = #{delFlag}</if>
+        </where>
+    </delete>
+
+    <delete id="delCmDistributionByIds" parameterType="String">
+        delete from cm_distribution where id in
+        <foreach item="id" collection="ids" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+</mapper>