Commit bf45530c authored by hezhen's avatar hezhen

添加上下级关系绑定

parent 21da8be3
package com.github.wxiaoqi.security.admin.constant;
public enum MemberRightType {
DISCOUNT(0, "折扣"),
COUNPON(1, "优惠券"),
FREE_SHIPPING(2, "包邮");
private Integer type;
private String name;
MemberRightType(Integer type, String name) {
this.type = type;
this.name = name;
}
public Integer getType() {
return type;
}
public String getName() {
return name;
}
}
package com.github.wxiaoqi.security.admin.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/6/24 9:18
*/
@Data
public class BaseMemberLevelFindDTO extends PageParam {
String appId;
List<Integer> levelIds;
}
package com.github.wxiaoqi.security.admin.dto;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import lombok.Data;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/6/24 9:21
*/
@Data
public class BaseMemberLevelPageDTO {
private Integer maxLevel;
private Integer specificTime;
private PageDataVO<BaseUserMemberLevel> memberLevels;
private List<MemberLevelRightsDTO> memberLevelRightsModel;
}
package com.github.wxiaoqi.security.admin.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/6/24 10:25
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MemberLevelRightsDTO {
private Integer type;
private MemberRights rights;
private String name;
private Integer status;
private Boolean sysn;
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class MemberRights {
private Integer discount;
private List<Coupon> coupons;
private Boolean isFreeShipping;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Coupon{
private Long id;
private String name;
}
}
......@@ -41,6 +41,11 @@ public class AppUserRelation implements Serializable {
@ApiModelProperty(value = "父id")
private Integer parentId;
@Column(name = "company_id")
@ApiModelProperty(value = "店铺id")
private Integer companyId;
/**
* 绑定的来源:1-app;2-小程序
*/
......
package com.github.wxiaoqi.security.admin.entity;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.github.wxiaoqi.security.admin.dto.MemberLevelRightsDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* 会员等级设置
*
* @author hezhen
* @email 18178966185@163.com
* @date 2020-06-24 09:12:21
*/
@Data
@Table(name = "base_member_level")
public class BaseMemberLevel implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键(也等值level级别(因级别变动))
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键(也等值level级别(因级别变动))")
private Integer id;
/**
* 等级名称(VIP1,VIP2,VIP3........),展示使用
*/
@Column(name = "level")
@ApiModelProperty(value = "等级名称(VIP1,VIP2,VIP3........),展示使用")
private Integer level;
/**
* 升级条件 0:充值 1:积分 2:注册自动升级
*/
@Column(name = "up_condition_type")
@ApiModelProperty(value = "升级条件 0:充值 1:积分 2:注册自动升级 ")
private Integer upConditionType;
/**
* 充值类型 0:一次性充值 1:累计充值
*/
@Column(name = "recharge_type")
@ApiModelProperty(value = "充值类型 0:一次性充值 1:累计充值")
private Integer rechargeType;
/**
* 一次性充值|累积充值
*/
@Column(name = "money")
@ApiModelProperty(value = "一次性充值|累积充值")
private BigDecimal money;
/**
* 积分
*/
@Column(name = "points")
@ApiModelProperty(value = "积分")
private Integer points;
/**
*
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "", hidden = true )
private Long crtTime;
/**
*
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "", hidden = true )
private Long updTime;
/**
* 会员名称
*/
@Column(name = "member_name")
@ApiModelProperty(value = "会员名称")
private String memberName;
/**
* 是否删除 0:未删除 1:已删除
*/
@Column(name = "is_del")
@ApiModelProperty(value = "是否删除 0:未删除 1:已删除")
private Integer isDel;
/**
* 图标
*/
@Column(name = "icon")
@ApiModelProperty(value = "图标")
private String icon;
/**
* 有效数;-1是永久有效
*/
@Column(name = "end_date")
@ApiModelProperty(value = "有效数;-1是永久有效")
private Long endDate;
/**
* 描述
*/
@Column(name = "describes")
@ApiModelProperty(value = "描述")
private String describes;
/**
* 权益
*/
@Column(name = "rights")
@ApiModelProperty(value = "权益")
@JsonIgnore
private String rights;
@Transient
private Integer maxLevel;
@Transient
private List<MemberLevelRightsDTO> memberRights;
@ApiModelProperty(value = "升级条件")
@Transient
private String upConditionStr;
@ApiModelProperty(value = "折扣")
@Transient
private Integer discount;
public List<MemberLevelRightsDTO> getMemberRights() {
if(StringUtils.hasText(getRights())){
List<MemberLevelRightsDTO> rightsDTOS= JSON.parseObject(getRights(),new TypeReference<List<MemberLevelRightsDTO>>(){});
rightsDTOS=rightsDTOS.stream().sorted(Comparator.comparing(MemberLevelRightsDTO::getType)).collect(Collectors.toList());
return rightsDTOS;
}
return memberRights;
}
public Integer getDiscount(){
discount=0;
List<MemberLevelRightsDTO> rightsDTOS=getMemberRights();
if (rightsDTOS != null && rightsDTOS.size() > 0){
List<MemberLevelRightsDTO> rightsDTOList = rightsDTOS.stream().filter(x -> x.getType() == 0 && x.getStatus() == 1).collect(Collectors.toList());
if (rightsDTOList != null && rightsDTOList.size() > 0){
MemberLevelRightsDTO memberLevelRightsDTO = rightsDTOList.get(0);
MemberLevelRightsDTO.MemberRights rights = memberLevelRightsDTO.getRights();
if (rights != null ){
discount=rights.getDiscount();
}
}
}
return discount;
}
public String getUpConditionStr(){
upConditionStr="";
if (getUpConditionType() != null){
if (getUpConditionType() == 0){
if (getRechargeType() != null && getRechargeType() == 0){
upConditionStr="一次性充值"+getMoney();
}else if (getRechargeType() != null && getRechargeType() == 1){
upConditionStr="累计充值"+getMoney();
}
}else if (getUpConditionType() == 1){
upConditionStr="积分满"+getPoints();
}else if (getUpConditionType() == 2){
upConditionStr="注册自动升级";
}else if (getUpConditionType() == 3){
upConditionStr="累计消费满"+getMoney();
}
}
return upConditionStr;
}
public static void main(String[] args) {
BaseUserMemberLevel memberLevel = new BaseUserMemberLevel();
System.out.println(JSONUtil.wrap(memberLevel,false));
}
}
......@@ -119,6 +119,18 @@ public class BranchCompany {
*/
@ApiModelProperty("负责人联系方式")
private String leaderContactInfo;
@ApiModelProperty("邀请码")
private String code;
@ApiModelProperty("邀请人id")
@Column(name = "inviter_account")
private Integer inviterAccount;
/**
* 分公司状态
*/
......
......@@ -54,6 +54,12 @@ public class CompanyInfoApply {
private String mobile;
@ApiModelProperty("邀请人id")
@Column(name = "inviter_account")
private Integer inviterAccount;
@ApiModelProperty("状态:0-待审核;1-审核成功;2-驳回")
private Integer status;
......
......@@ -66,6 +66,9 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
@Autowired
private AppStaffUserBiz staffUserBiz;
@Autowired
private BranchCompanyBiz companyBiz;
private static final HashMap<Integer, Boolean> map = new HashMap<>();
private static final HashMap<Integer, Boolean> parentMap = new HashMap<>();
......@@ -115,54 +118,53 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
* @param parentId
*/
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public void bindRelation(Integer userId,Integer parentId,Integer type){
public void bindRelation(Integer userId,Integer parentId,Integer companyId,Integer type){
try {
if (userId.equals(parentId)){
log.info("----userId==="+userId+"----parentId===="+parentId+"----自己不能成为自己的上线");
return;
}
/* AppUserVo appUserVo=userDetailBiz.getUserInfoById(userId);
if (appUserVo==null){
log.info("----userId==="+userId+"----parentId===="+parentId+"----该用户不存在");
return;
}*/
if (parentId > 0){
AppUserVo appUserVo=userDetailBiz.getUserInfoById(parentId);
if (appUserVo==null){
log.info("----userId==="+userId+"----parentId===="+parentId+"----该上线用户不存在");
return;
}
AppUserRelation relation=getMyBiz().getRelationByUserId(parentId);
Long time=System.currentTimeMillis();
if(relation==null){
relation=new AppUserRelation();
relation.setUserId(parentId);
relation.setBindType(type);
insertSelective(relation);
}
}
Long time=System.currentTimeMillis();
Long bindTime=time-validTime;
//判断用户是否有有效的下线
if (getCountByParentId(userId,bindTime)==0L){
relation=getMyBiz().getRelationByUserId(userId);
AppUserRelation relation=getMyBiz().getRelationByUserId(userId);
if(relation==null){
relation=new AppUserRelation();
relation.setUserId(userId);
relation.setParentId(parentId);
relation.setCompanyId(companyId);
relation.setBindType(type);
relation.setBindTime(time);
insertSelective(relation);
}else {
//判断用户是否有有效的上线
Integer parentId1=relation.getParentId() == null ? 0 : relation.getParentId();
Integer companyId1=relation.getCompanyId() == null ? 0 : relation.getCompanyId();
log.info("----userId==="+userId+"----bindTime===="+bindTime+"----relation.getBindTime()==="+relation.getBindTime());
if(relation.getParentId()==null||relation.getParentId()==0||(relation.getIsForever()!=1&&validTime>0&&relation.getBindTime()<bindTime)){
if((parentId1 == 0 && companyId1 == 0)||(relation.getIsForever()!=1&&validTime>0&&relation.getBindTime()<bindTime)){
relation.setParentId(parentId);
relation.setCompanyId(companyId);
relation.setBindType(type);
relation.setBindTime(time);
getMyBiz().updRelation(relation);
}
}
if (relation != null){
if (relation != null && parentId > 0){
AppStaffUserDTO staffUserDTO=new AppStaffUserDTO();
staffUserDTO.setSuId(relation.getParentId());
staffUserDTO.setUid(relation.getUserId());
......@@ -178,16 +180,21 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
//首页关系绑定
public ObjectRestResponse appBindRelation(Integer userId, String code) {
Integer parentId = 0;
Integer companyId = 0;
if (StringUtils.isNotBlank(code)) {
//判断处理活动关键字
String[] codes = code.split("_");
if (codes.length > 1) {
code = codes[0];
}
parentId = appUserDetailBiz.getUserByCode(code);
if (code.contains(CompanyInfoBiz.CODE)){
companyId=companyBiz.getCompanyByCode(code);
}else {
parentId=appUserDetailBiz.getUserByCode(code);
}
}
if (parentId != null && parentId > 0 && userId != null && userId > 0) {
getMyBiz().bindRelation(userId, parentId, 1);
getMyBiz().bindRelation(userId, parentId, companyId,1);
}
return ObjectRestResponse.succ();
}
......@@ -204,7 +211,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "该上级不存在");
}
Integer parentId = userLogin.getId();
getMyBiz().bindRelation(userId, parentId, 1);
getMyBiz().bindRelation(userId, parentId,0, 1);
return ObjectRestResponse.succ();
}
......@@ -236,7 +243,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
if (userVo == null) {
upRelationTemp(pid, userid);
} else {
bindRelation(platform_userid, pid, 2);
bindRelation(platform_userid, pid,0, 2);
}
}
return ObjectRestResponse.succ();
......@@ -283,7 +290,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
return;
}
Integer parentId = relationTemp.getUserId();
bindRelation(platform_userid, parentId, 2);
bindRelation(platform_userid, parentId, 0,2);
}
......
package com.github.wxiaoqi.security.admin.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.constant.MemberRightType;
import com.github.wxiaoqi.security.admin.dto.MemberLevelRightsDTO;
import com.github.wxiaoqi.security.admin.dto.BaseMemberLevelFindDTO;
import com.github.wxiaoqi.security.admin.dto.BaseMemberLevelPageDTO;
import com.github.wxiaoqi.security.admin.entity.BaseMemberLevel;
import com.github.wxiaoqi.security.admin.mapper.BaseMemberLevelMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.universal.feign.ThirdFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
/**
* 会员等级设置
*
* @author hezhen
* @email 18178966185@163.com
* @date 2020-06-24 09:12:21
*/
@Service
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class BaseMemberLevelBiz extends BaseBiz<BaseMemberLevelMapper, BaseMemberLevel> {
@Autowired
private BaseUserMemberBiz baseUserMemberBiz;
@Autowired
private ThirdFeign thirdFeign;
@Autowired
private ActivityFeign activityFeign;
private static final String MEMBERMODEL_TYPE = "MEMBER_RIGHTS";
private static final String MEMBERMODEL_CODE = "DA_YUN";
public ObjectRestResponse<PageDataVO> selectList(BaseMemberLevelFindDTO userMemberLevelDTO) {
Integer page=userMemberLevelDTO.getPage()==null?1:userMemberLevelDTO.getPage();
Integer limit=userMemberLevelDTO.getLimit()==null?10:userMemberLevelDTO.getLimit();
return ObjectRestResponse.succ(PageDataVO.pageInfo(page, limit, ()->getList(userMemberLevelDTO)));
}
public List<BaseMemberLevel> getList(BaseMemberLevelFindDTO userMemberLevelDTO){
Example memberLevelExample = new Example(BaseMemberLevel.class);
memberLevelExample.setOrderByClause("level asc");
Example.Criteria criteria = memberLevelExample.createCriteria();
criteria.andEqualTo("isDel", 0);
if (userMemberLevelDTO.getLevelIds() != null && userMemberLevelDTO.getLevelIds().size() > 0){
criteria.andIn("id",userMemberLevelDTO.getLevelIds());
}
return mapper.selectByExample(memberLevelExample);
}
public BaseMemberLevel getMinDiscount(String appId){
BaseMemberLevelFindDTO userMemberLevelDTO =new BaseMemberLevelFindDTO();
userMemberLevelDTO.setAppId(appId);
List<BaseMemberLevel> list=getList(userMemberLevelDTO);
BaseMemberLevel baseUserMemberLevel=new BaseMemberLevel();
if (list.size() > 0){
baseUserMemberLevel=list.stream().filter(o -> o.getDiscount() > 0).min(Comparator.comparing(BaseMemberLevel::getDiscount)).get();
}
return baseUserMemberLevel;
}
public BaseMemberLevel getUserMemberLevelDetailById(Integer id) {
BaseMemberLevel userMemberLevel = mapper.selectByPrimaryKey(id);
Integer maxLevel = getMaxLevel();
userMemberLevel.setMaxLevel(maxLevel);
return userMemberLevel;
}
private List<Long> getCouponIds(List<BaseMemberLevel> memberLevels) {
return memberLevels.stream()
.map(BaseMemberLevel::getMemberRights)
.flatMap(List::stream)
.filter(x -> Objects.equals(x.getType(), MemberRightType.COUNPON.getType()))
.map(MemberLevelRightsDTO::getRights)
.map(MemberLevelRightsDTO.MemberRights::getCoupons)
.flatMap(List::stream)
.filter(Objects::nonNull)
.map(MemberLevelRightsDTO.Coupon::getId).collect(Collectors.toList());
}
public void saveOrUpdateBaseUserMemberLevel(BaseMemberLevel baseMemberLevel) {
List<MemberLevelRightsDTO> memberRights = baseMemberLevel.getMemberRights();
for (MemberLevelRightsDTO memberRight : memberRights) {
//同步会员权益
if (Objects.nonNull(baseMemberLevel.getId())) {
if (Objects.nonNull(memberRight.getSysn()) && memberRight.getSysn()) {
//baseUserMemberBiz.sysnUserMemberLevelRights(baseMemberLevel.getId(), memberRight, baseMemberLevel.getAppId());
}
}
memberRight.setSysn(null);
}
baseMemberLevel.setRights(JSON.toJSONString(memberRights));
if (Objects.nonNull(baseMemberLevel.getId())) {
baseMemberLevel.setUpdTime(Instant.now().toEpochMilli());
mapper.updateByPrimaryKeySelective(baseMemberLevel);
} else {
baseMemberLevel.setCrtTime(Instant.now().toEpochMilli());
mapper.insertSelective(baseMemberLevel);
}
}
public void deleteUserMemberLevelById(Integer id, Integer changeLevel) {
//1.根据id删除
//1.1 根据id查询
BaseMemberLevel baseUserMemberLevel = mapper.selectByPrimaryKey(id);
//1.2 删除
baseUserMemberLevel.setIsDel(1);
mapper.updateByPrimaryKeySelective(baseUserMemberLevel);
//2.同步会员等级操作
changeLevel = baseUserMemberLevel.getLevel() + changeLevel;
if (changeLevel == 0 ){
//baseUserMemberBiz.sysnBaseUserMember(baseUserMemberLevel.getLevel() ,0,"",changeLevel,appId);
}else {
//2.1 根据level查询
BaseMemberLevel memberLevel = mapper.selectByLevel(changeLevel);
//2.2 同步会员
//baseUserMemberBiz.sysnBaseUserMember(baseUserMemberLevel.getId(),memberLevel);
}
//3.更改比当前数据level大的数据,-1
mapper.updateUserMemberLevel(baseUserMemberLevel.getLevel());
}
public Integer getMaxLevel() {
Integer maxLevel = mapper.selectMaxLevel();
maxLevel = maxLevel == null ? 0 : maxLevel;
return maxLevel;
}
/*public JSONObject getLevelInfo(BaseUserMember userMember){
BaseUserMemberVo userMemberVo = baseUserMemberBiz.getUserMemberByUserId(userMember.getUserId());
JSONObject jsonObject=new JSONObject();
Integer level=0;
if (userMemberVo != null){
BaseMemberLevel memberLevel = selectById(userMemberVo.getMemberLevel());
Integer levelId=0;
if (memberLevel != null ){
levelId=memberLevel.getLevel()==null?0:memberLevel.getLevel();
}
jsonObject.put("currentMember",memberLevel);
level=levelId+1;
}else {
level=1;
}
BaseMemberLevel nextMember=mapper.selectByLevel(level);
BaseMemberLevel maxMember=mapper.selectByLevel(getMaxLevel());
if (nextMember == null){
nextMember=maxMember;
}
jsonObject.put("nextMember",nextMember);
jsonObject.put("maxMember",maxMember);
UsersPurse usersPurse = usersPurseBiz.getUserPurseByUserId(userMember.getUserId());
BigDecimal totalBuy=BigDecimal.ZERO;
if (usersPurse != null ){
totalBuy=usersPurse.getTotalBuy();
}
jsonObject.put("totalBuy",totalBuy);
jsonObject.put("percentage",totalBuy.divide(nextMember.getMoney(),2).multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_HALF_UP));
return jsonObject;
}*/
public List<BaseMemberLevel> getAll(BaseMemberLevel baseUserMemberLevel){
return selectList(baseUserMemberLevel);
}
public BaseMemberLevel getNextLevel(BaseMemberLevel baseUserMemberLevel){
return mapper.getNextLevel(baseUserMemberLevel.getMoney(),baseUserMemberLevel.getLevel());
}
public BaseMemberLevel getMemberLevel(Integer levelId, String levelIds){
if (org.apache.commons.lang3.StringUtils.isNotBlank(levelIds)){
BaseMemberLevel userMemberLevel=selectById(levelId);
if (userMemberLevel != null ){
int[] ints = Arrays.stream(levelIds.split(",")).mapToInt(s -> Integer.parseInt(s)).toArray();
Arrays.sort(ints);
List<Integer> aList =Arrays.stream(ints).boxed().collect(Collectors.toList());
BaseMemberLevelFindDTO userMemberLevelDTO =new BaseMemberLevelFindDTO();
userMemberLevelDTO.setLevelIds(aList);
List<BaseMemberLevel> list = getList(userMemberLevelDTO);
if (list != null && list .size() >0){
BaseMemberLevel userMemberLevel1=null;
for (BaseMemberLevel baseUserMemberLevel:list){
if (baseUserMemberLevel.getLevel() > userMemberLevel.getLevel()){
userMemberLevel1=baseUserMemberLevel;
break;
}
}
return userMemberLevel1;
}
}
}
return null;
}
public List<BaseMemberLevel> getListByLevelId(Integer levelId){
return mapper.getListByLevelId(levelId);
}
}
\ No newline at end of file
......@@ -45,6 +45,16 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
return ObjectRestResponse.succ();
}
public Integer getCompanyByCode(String code) {
Example example = new Example(BranchCompany.class);
example.createCriteria().andEqualTo("code", code).andEqualTo("isDel", 0);
List<BranchCompany> list = mapper.selectByExample(example);
if (list != null && list.size() != 0) {
return list.get(0).getId();
}
return 0;
}
public void sendQueue(BranchCompany branchCompany) {
......
......@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.admin.mapper.CompanyInfoMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.ReferralCodeUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.app.entity.Cofig;
......@@ -49,6 +50,8 @@ public class CompanyInfoBiz extends BaseBiz<CompanyInfoMapper, CompanyInfo>{
@Autowired
BranchCompanyBiz branchCompanyBiz;
public static final String CODE="SHOP-";
......@@ -71,6 +74,8 @@ public class CompanyInfoBiz extends BaseBiz<CompanyInfoMapper, CompanyInfo>{
//初始化店铺
BranchCompany branchCompany = getBranchCompanyInfo();
branchCompany.setCompanyId(id);
branchCompany.setInviterAccount(companyInfoApply.getInviterAccount());
branchCompany.setCode(CODE+ReferralCodeUtil.encode(companyInfoApply.getId().intValue()));
branchCompanyBiz.addOrUpd(branchCompany);
}
sendQueue(companyInfo);
......
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.BaseMemberLevel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;
import java.math.BigDecimal;
import java.util.List;
/**
* 会员等级设置
*
* @author hezhen
* @email 18178966185@163.com
* @date 2020-06-24 09:12:21
*/
public interface BaseMemberLevelMapper extends Mapper<BaseMemberLevel> {
@Select("select max(`level`) from `base_member_level` where `is_del`=0 ")
Integer selectMaxLevel();
@Update("update `base_member_level` set `level`=`level`-1 where `is_del`=0 and `level`>#{level}")
int updateUserMemberLevel(@Param("level") Integer level);
@Select("select * from `base_member_level` as `buml` where buml.`level`=#{level} and buml.is_del=0")
BaseMemberLevel selectByLevel(@Param("level") Integer changeLevel);
@Select("select * from `base_member_level` as `buml` where buml.`level`> #{level} and buml.`money` <= #{money} and buml.is_del=0 ORDER BY buml.`level` DESC LIMIT 1 ")
BaseMemberLevel getNextLevel(@Param("money") BigDecimal money, @Param("level") Integer Level);
@Select("SELECT * FROM base_member_level WHERE is_del = 0 AND `level` >= \n" +
"(SELECT `level` FROM base_member_level WHERE id=#{levelId} LIMIT 1 ) ORDER BY `level` ASC")
List<BaseMemberLevel> getListByLevelId(@Param("levelId") Integer levelId);
}
package com.github.wxiaoqi.security.admin.rest.admin;
import com.github.wxiaoqi.security.admin.biz.BaseMemberLevelBiz;
import com.github.wxiaoqi.security.admin.dto.BaseMemberLevelFindDTO;
import com.github.wxiaoqi.security.admin.entity.BaseMemberLevel;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import org.springframework.web.bind.annotation.*;
/**
* @author libin
* @version 1.0
* @description
* @data 2020/6/24 16:11
*/
@RestController
@RequestMapping("/backstage/baseMemberLevel")
public class AdminBaseMemberLevelController extends BaseController<BaseMemberLevelBiz, BaseMemberLevel> {
@GetMapping("/selectList")
public ObjectRestResponse selectList(BaseMemberLevelFindDTO userMemberLevelFindDTO) {
return baseBiz.selectList(userMemberLevelFindDTO);
}
@PostMapping("/save")
public ObjectRestResponse<Void> saveUserMemberLevel(@RequestBody BaseMemberLevel baseMemberLevel) {
baseBiz.saveOrUpdateBaseUserMemberLevel(baseMemberLevel);
return ObjectRestResponse.succ();
}
@DeleteMapping("/delete/{id}/{changeLevel}")
public ObjectRestResponse<Void> deleteUserMemberLevel(@PathVariable(value = "id") Integer id,
@PathVariable(value = "changeLevel") Integer changeLevel) {
baseBiz.deleteUserMemberLevelById(id, changeLevel);
return ObjectRestResponse.succ();
}
@GetMapping("/detail/{id}")
public ObjectRestResponse<BaseMemberLevel> findUserMemberLevelDetail(@PathVariable(value = "id") Integer id) {
BaseMemberLevel userMemberLevel = baseBiz.getUserMemberLevelDetailById(id);
return ObjectRestResponse.succ(userMemberLevel);
}
@GetMapping("/maxLevel")
public ObjectRestResponse getMaxLevel() {
return ObjectRestResponse.succ(baseBiz.getMaxLevel());
}
@GetMapping("/getAll")
public ObjectRestResponse getAll(BaseMemberLevelFindDTO userMemberLevelFindDTO) {
return ObjectRestResponse.succ(baseBiz.getList(userMemberLevelFindDTO));
}
}
\ No newline at end of file
......@@ -117,6 +117,10 @@ public class AppPermissionService {
private AppUserAlipayBiz alipayBiz;
@Autowired
private BranchCompanyBiz companyBiz;
private static final Integer maxNumber=5;
......@@ -266,11 +270,17 @@ public class AppPermissionService {
String[] codes = code.split("_");
if(codes.length > 0) {
String userCode = codes[0];
if(appUserDetailBiz.getUserByCode(userCode)==0) {
if (userCode.contains(CompanyInfoBiz.CODE)){
if(companyBiz.getCompanyByCode(code) == 0 ) {
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "邀请店铺不存在");
}
}else {
if( appUserDetailBiz.getUserByCode(userCode) == 0) {
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "邀请人不存在");
}
}
}
}
/*if (checkErrorNum(username)){
return JsonResultUtil.createFailedResult(ResultCode.FAILED_CODE, "验证码超过错误次数");
}*/
......@@ -326,6 +336,7 @@ public class AppPermissionService {
log.info("注册:解析地址后: " + userid+"---time===="+System.currentTimeMillis()/1000L);
//邀请人id关系绑定
Integer parentId=0;
Integer companyId=0;
if (StringUtils.isNotBlank(code)){
//判断处理活动关键字
String[] codes = code.split("_");
......@@ -333,11 +344,16 @@ public class AppPermissionService {
code = codes[0];
activityCode = codes[1];
}
if (code.contains(CompanyInfoBiz.CODE)){
companyId=companyBiz.getCompanyByCode(code);
}else {
parentId=appUserDetailBiz.getUserByCode(code);
}
if(parentId!=null&&parentId>0){
}
if(parentId>0 ||companyId > 0){
rsUserDetail.setSource(1);
relationBiz.bindRelation(userid, parentId, 1);
relationBiz.bindRelation(userid, parentId, companyId,1);
if(StringUtils.isNotBlank(activityCode)){
rsUserDetail.setInviterAccount(parentId);
}
......@@ -1276,11 +1292,17 @@ public class AppPermissionService {
String[] codes = code.split("_");
if(codes.length > 0) {
String userCode = codes[0];
if(appUserDetailBiz.getUserByCode(userCode)==0) {
if (userCode.contains(CompanyInfoBiz.CODE)){
if(companyBiz.getCompanyByCode(code) == 0 ) {
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "邀请店铺不存在");
}
}else {
if( appUserDetailBiz.getUserByCode(userCode) == 0) {
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "邀请人不存在");
}
}
}
}
// 是否已存在
AppUserLogin user = appUserLoginBiz.checkeUserLogin(username);
if (null != user) {
......@@ -1317,6 +1339,7 @@ public class AppPermissionService {
log.info("注册:解析地址后: " + userid+"---time===="+System.currentTimeMillis()/1000L);
//邀请人id关系绑定
Integer parentId=0;
Integer companyId=0;
if (StringUtils.isNotBlank(code)){
//判断处理活动关键字
String[] codes = code.split("_");
......@@ -1324,11 +1347,15 @@ public class AppPermissionService {
code = codes[0];
activityCode = codes[1];
}
if (code.contains(CompanyInfoBiz.CODE)){
companyId=companyBiz.getCompanyByCode(code);
}else {
parentId=appUserDetailBiz.getUserByCode(code);
}
if(parentId!=null&&parentId>0){
}
if( parentId>0 || companyId > 0){
rsUserDetail.setSource(1);
relationBiz.bindRelation(userid, parentId, 1);
relationBiz.bindRelation(userid, parentId, companyId,1);
if(StringUtils.isNotBlank(activityCode)){
rsUserDetail.setInviterAccount(parentId);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment