## Feat - 收益区域
This commit is contained in:
parent
783a104fcc
commit
bfd197b746
|
@ -794,7 +794,7 @@ public interface CuMemberMapper extends BaseMapper<CuMember> {
|
|||
CuMemberSettleExt getTableData(@Param("tableName") String tableName, @Param("userId") Long userId);
|
||||
|
||||
|
||||
int getSelectRegionCount(@Param("userId") Long userId, @Param("type") Integer type);
|
||||
CheckRegionDetailVO getSelectRegionDetail(@Param("userId") Long userId, @Param("type") Integer type);
|
||||
|
||||
List<BdArea> getRegionList(@Param("userId") Long userId, @Param("type") Integer type);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.hzs.member.base.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.hzs.common.core.constant.CacheConstants;
|
||||
|
@ -58,7 +59,7 @@ public class CuMemberRegionServiceImpl extends ServiceImpl<CuMemberRegionMapper,
|
|||
this.update(Wrappers.<CuMemberRegion>lambdaUpdate()
|
||||
.eq(CuMemberRegion::getPkMember, param.getPkMember())
|
||||
.eq(CuMemberRegion::getEffective, EYesNo.YES.getIntValue())
|
||||
.eq(CuMemberRegion::getSystemType, param.getSystemType())
|
||||
// .eq(CuMemberRegion::getSystemType, param.getSystemType())
|
||||
.set(CuMemberRegion::getEffective, EYesNo.NO.getIntValue())
|
||||
.set(CuMemberRegion::getPkModified, param.getPkMember())
|
||||
.set(CuMemberRegion::getModifiedTime, new Date())
|
||||
|
@ -75,7 +76,8 @@ public class CuMemberRegionServiceImpl extends ServiceImpl<CuMemberRegionMapper,
|
|||
.systemType(param.getSystemType())
|
||||
.build();
|
||||
retailRegion.setPkCreator(param.getPkMember());
|
||||
retailRegion.setRegionVertexPkId(baseMapper.getRegionVertexPkIdByPkMember(retailRegion.getPkMember()));
|
||||
Long regionVertexPkId = baseMapper.getRegionVertexPkIdByPkMember(retailRegion.getPkMember());
|
||||
retailRegion.setRegionVertexPkId(ObjectUtil.isEmpty(regionVertexPkId) ? 0L : regionVertexPkId);
|
||||
if (baseMapper.insertData(retailRegion) == 0) {
|
||||
throw new ServiceException("选择区域失败,请刷新后重试");
|
||||
}
|
||||
|
|
|
@ -3377,6 +3377,7 @@ public class CuMemberServiceImpl extends ServiceImpl<CuMemberMapper, CuMember> i
|
|||
@Override
|
||||
public CheckRegionVO getRegion() {
|
||||
CheckRegionVO checkRegionVO = new CheckRegionVO();
|
||||
checkRegionVO.setData(new CheckRegionVO.CheckRegionWrapper());
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
// 先拿用户奖衔
|
||||
// 业绩=昨天的总业绩+日结的新增
|
||||
|
@ -3391,15 +3392,14 @@ public class CuMemberServiceImpl extends ServiceImpl<CuMemberMapper, CuMember> i
|
|||
}
|
||||
|
||||
BigDecimal smallPv = getSmallPV(userId);
|
||||
List<BdAwards> resultList = new ArrayList<>();
|
||||
if(CollUtil.isNotEmpty(regionConfigList)){
|
||||
// 匹配到的区域配置
|
||||
for (BdAwardsRegionConfig config : regionConfigList) {
|
||||
bdAwards = iAwardsServiceApi.getAwardsOne(config.getPkAwards().intValue()).getData();
|
||||
// 判断业绩
|
||||
if(smallPv.compareTo(bdAwards.getSmallAssess()) >= 0){
|
||||
int count = baseMapper.getSelectRegionCount(userId, config.getAreaType());
|
||||
if(count == 0){
|
||||
CheckRegionDetailVO regionDetail = baseMapper.getSelectRegionDetail(userId, config.getAreaType());
|
||||
if(ObjectUtil.isEmpty(regionDetail)){
|
||||
if(config.getAwardsValue() == EAwards.HEADER.getValue()){
|
||||
checkRegionVO.setCounty(true);
|
||||
}else if(config.getAwardsValue() == EAwards.MANAGER.getValue()){
|
||||
|
@ -3407,10 +3407,21 @@ public class CuMemberServiceImpl extends ServiceImpl<CuMemberMapper, CuMember> i
|
|||
}else if(config.getAwardsValue() == EAwards.HIGH_MANAGER.getValue()){
|
||||
checkRegionVO.setProvince(true);
|
||||
}
|
||||
}else{
|
||||
if(config.getAwardsValue() == EAwards.HEADER.getValue()){
|
||||
checkRegionVO.getData().setCountyData(regionDetail);
|
||||
}else if(config.getAwardsValue() == EAwards.MANAGER.getValue()){
|
||||
checkRegionVO.getData().setCityData(regionDetail);
|
||||
}else if(config.getAwardsValue() == EAwards.HIGH_MANAGER.getValue()){
|
||||
checkRegionVO.getData().setProvinceData(regionDetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// checkRegionVO.setCounty(true);
|
||||
// checkRegionVO.setCity(true);
|
||||
// checkRegionVO.setProvince(true);
|
||||
return checkRegionVO;
|
||||
}
|
||||
|
||||
|
@ -3459,6 +3470,7 @@ public class CuMemberServiceImpl extends ServiceImpl<CuMemberMapper, CuMember> i
|
|||
public AjaxResult setRegion(MemberRegionParam param) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Integer systemType = SecurityUtils.getSystemType();
|
||||
param.setSystemType(systemType);
|
||||
Integer pkCountry = SecurityUtils.getPkCountry();
|
||||
CheckRegionVO checkRegionVO = this.getRegion();
|
||||
BdArea province = iAreaServiceApi.getArea(param.getProvince()).getData();
|
||||
|
@ -3467,7 +3479,8 @@ public class CuMemberServiceImpl extends ServiceImpl<CuMemberMapper, CuMember> i
|
|||
return AjaxResult.error("选择区域省不存在,请重新选择");
|
||||
}
|
||||
if(param.getType() == 1 && checkRegionVO.isProvince()){
|
||||
|
||||
param.setCity(0);
|
||||
param.setCounty(0);
|
||||
}else if(param.getType() == 2 && checkRegionVO.isCity()){
|
||||
// 校验市是否存在
|
||||
if (!param.getCity().equals(0)) {
|
||||
|
@ -3476,6 +3489,7 @@ public class CuMemberServiceImpl extends ServiceImpl<CuMemberMapper, CuMember> i
|
|||
return AjaxResult.error("选择区域市不存在,请重新选择");
|
||||
}
|
||||
}
|
||||
param.setCounty(0);
|
||||
}else if(param.getType() == 3 && checkRegionVO.isCounty()){
|
||||
// 校验区是否存在
|
||||
if (!param.getCounty().equals(0)) {
|
||||
|
@ -3485,7 +3499,9 @@ public class CuMemberServiceImpl extends ServiceImpl<CuMemberMapper, CuMember> i
|
|||
}
|
||||
}
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(cuMemberRegionExt)){
|
||||
param.setPkId(cuMemberRegionExt.getPkId());
|
||||
}
|
||||
param.setPkMember(userId);
|
||||
param.setPkCountry(pkCountry);
|
||||
param.setSource(ENoticeWebsiteType.MEMBER.getValue());
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.hzs.member.base.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class CheckRegionDetailVO implements Serializable {
|
||||
private Long provinceId;
|
||||
private String provinceName;
|
||||
private Long cityId;
|
||||
private String cityName;
|
||||
private Long countyId;
|
||||
private String countyName;
|
||||
}
|
|
@ -6,7 +6,15 @@ import java.io.Serializable;
|
|||
|
||||
@Data
|
||||
public class CheckRegionVO implements Serializable {
|
||||
boolean province = false;
|
||||
boolean city = false;
|
||||
boolean county = false;
|
||||
private boolean province = false;
|
||||
private boolean city = false;
|
||||
private boolean county = false;
|
||||
private CheckRegionWrapper data;
|
||||
|
||||
@Data
|
||||
public static class CheckRegionWrapper {
|
||||
private CheckRegionDetailVO provinceData;
|
||||
private CheckRegionDetailVO cityData;
|
||||
private CheckRegionDetailVO countyData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3161,30 +3161,38 @@
|
|||
<select id="getTableData" resultType="com.hzs.common.domain.member.ext.CuMemberSettleExt">
|
||||
select * from ${tableName} where pk_member = #{userId}
|
||||
</select>
|
||||
<select id="getSelectRegionCount" resultType="java.lang.Integer">
|
||||
<select id="getSelectRegionDetail" resultType="com.hzs.member.base.vo.CheckRegionDetailVO">
|
||||
SELECT
|
||||
count(1)
|
||||
cmrr.PROVINCE provinceId,
|
||||
cmrr.CITY cityId,
|
||||
cmrr.COUNTY countyId,
|
||||
p.name provinceName,
|
||||
c.name cityName,
|
||||
pc.name countyName
|
||||
FROM
|
||||
CU_MEMBER_RETAIL_REGION cmrr
|
||||
INNER JOIN cu_member cm ON cmrr.pk_member = cm.pk_id
|
||||
LEFT JOIN BD_VERTEX bv ON cm.PK_VERTEX = bv.PK_ID
|
||||
LEFT JOIN BD_REGION_VERTEX brv ON bv.REGION_VERTEX_PK_ID = brv.PK_ID
|
||||
LEFT JOIN BD_AREA P ON P.PK_ID = cmrr.PROVINCE AND P.DEL_FLAG = 0
|
||||
LEFT JOIN BD_AREA C ON C.PK_ID = cmrr.CITY AND C.DEL_FLAG = 0
|
||||
LEFT JOIN BD_AREA PC ON PC.PK_ID = cmrr.COUNTY AND PC.DEL_FLAG = 0
|
||||
where 1=1
|
||||
AND cmrr.PK_MEMBER IN (select pk_id from CU_MEMBER where PK_VERTEX in (select pk_id from BD_VERTEX where REGION_VERTEX_PK_ID in (select REGION_VERTEX_PK_ID from BD_VERTEX where pk_id in (select PK_VERTEX FROM cu_member WHERE PK_ID = #{userId} )) and DEL_FLAG = 0))
|
||||
AND cmrr.PK_MEMBER IN ( #{userId} )
|
||||
<if test="type != null and type == 1">
|
||||
and cmrr.PROVINCE is not null
|
||||
and cmrr.CITY is null
|
||||
and cmrr.COUNTY is null
|
||||
and cmrr.PROVINCE != 0
|
||||
and cmrr.CITY = 0
|
||||
and cmrr.COUNTY = 0
|
||||
</if>
|
||||
<if test="type != null and type == 2">
|
||||
and cmrr.PROVINCE is not null
|
||||
and cmrr.CITY is not null
|
||||
and cmrr.COUNTY is null
|
||||
and cmrr.PROVINCE != 0
|
||||
and cmrr.CITY != 0
|
||||
and cmrr.COUNTY = 0
|
||||
</if>
|
||||
<if test="type != null and type == 3">
|
||||
and cmrr.PROVINCE is not null
|
||||
and cmrr.CITY is not null
|
||||
and cmrr.COUNTY is not null
|
||||
and cmrr.PROVINCE != 0
|
||||
and cmrr.CITY != 0
|
||||
and cmrr.COUNTY != 0
|
||||
</if>
|
||||
</select>
|
||||
<select id="getRegionList" resultType="com.hzs.common.domain.system.base.BdArea"
|
||||
|
@ -3211,7 +3219,22 @@
|
|||
LEFT JOIN BD_VERTEX bv ON cm.PK_VERTEX = bv.PK_ID
|
||||
LEFT JOIN BD_REGION_VERTEX brv ON bv.REGION_VERTEX_PK_ID = brv.PK_ID
|
||||
where 1=1
|
||||
AND cmrr.PK_MEMBER IN (select pk_id from CU_MEMBER where PK_VERTEX in (select pk_id from BD_VERTEX where REGION_VERTEX_PK_ID in (select REGION_VERTEX_PK_ID from BD_VERTEX where pk_id in (select PK_VERTEX FROM cu_member WHERE PK_ID = #{userId} )) and DEL_FLAG = 0))
|
||||
AND cmrr.PK_MEMBER IN (#{userId} )
|
||||
<if test="type != null and type == 1">
|
||||
and cmrr.PROVINCE != 0
|
||||
and cmrr.CITY = 0
|
||||
and cmrr.COUNTY = 0
|
||||
</if>
|
||||
<if test="type != null and type == 2">
|
||||
and cmrr.PROVINCE != 0
|
||||
and cmrr.CITY != 0
|
||||
and cmrr.COUNTY = 0
|
||||
</if>
|
||||
<if test="type != null and type == 3">
|
||||
and cmrr.PROVINCE != 0
|
||||
and cmrr.CITY != 0
|
||||
and cmrr.COUNTY != 0
|
||||
</if>
|
||||
)
|
||||
</select>
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
on cmrr.pk_member = cm.pk_id
|
||||
and cmrr.del_flag = 0
|
||||
and cmrr.effective = 0
|
||||
and bg.del_flag = 0
|
||||
left join bd_area bap
|
||||
on bap.pk_id = cmrr.province
|
||||
and bap.del_flag = 0
|
||||
|
@ -29,19 +28,19 @@
|
|||
where cm.del_flag = 0
|
||||
and cm.pk_id = #{pkMember}
|
||||
<if test="type != null and type == 1">
|
||||
and cmrr.PROVINCE is not null
|
||||
and cmrr.CITY is null
|
||||
and cmrr.COUNTY is null
|
||||
and cmrr.PROVINCE != 0
|
||||
and cmrr.CITY = 0
|
||||
and cmrr.COUNTY = 0
|
||||
</if>
|
||||
<if test="type != null and type == 2">
|
||||
and cmrr.PROVINCE is not null
|
||||
and cmrr.CITY is not null
|
||||
and cmrr.COUNTY is null
|
||||
and cmrr.PROVINCE != 0
|
||||
and cmrr.CITY != 0
|
||||
and cmrr.COUNTY = 0
|
||||
</if>
|
||||
<if test="type != null and type == 3">
|
||||
and cmrr.PROVINCE is not null
|
||||
and cmrr.CITY is not null
|
||||
and cmrr.COUNTY is not null
|
||||
and cmrr.PROVINCE != 0
|
||||
and cmrr.CITY != 0
|
||||
and cmrr.COUNTY != 0
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
@ -73,10 +72,8 @@
|
|||
province,
|
||||
city,
|
||||
county,
|
||||
source,
|
||||
creation_time,
|
||||
pk_creator,
|
||||
system_type,
|
||||
REGION_VERTEX_PK_ID
|
||||
)
|
||||
select cu_member_retail_region_seq.nextval,
|
||||
|
@ -84,10 +81,8 @@
|
|||
#{retailRegion.province},
|
||||
#{retailRegion.city},
|
||||
#{retailRegion.county},
|
||||
#{retailRegion.source},
|
||||
sysdate,
|
||||
#{retailRegion.pkCreator},
|
||||
#{retailRegion.systemType},
|
||||
#{retailRegion.regionVertexPkId}
|
||||
from dual
|
||||
where not exists(select 1
|
||||
|
@ -100,7 +95,6 @@
|
|||
and cmrr.county = #{retailRegion.county}
|
||||
and cmrr.del_flag = 0
|
||||
and cmrr.effective = 0
|
||||
and cmrr.system_type = #{retailRegion.systemType}
|
||||
AND cm.pk_id = #{retailRegion.pkMember}
|
||||
)
|
||||
</insert>
|
||||
|
@ -123,7 +117,6 @@
|
|||
WHERE CMRR.DEL_FLAG = 0
|
||||
AND CMRR.PK_COUNTRY = #{pkCountry}
|
||||
AND CMRR.EFFECTIVE = 0
|
||||
and CMRR.SYSTEM_TYPE = #{systemType}
|
||||
)
|
||||
ORDER BY p.pk_id ASC, ct.pk_id ASC, ba.pk_id ASC
|
||||
</select>
|
||||
|
|
|
@ -21,8 +21,8 @@ import java.util.Date;
|
|||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@KeySequence("CU_MEMBER_REGION_SEQ")
|
||||
@TableName("CU_MEMBER_REGION")
|
||||
@KeySequence("CU_MEMBER_RETAIL_REGION_SEQ")
|
||||
@TableName("CU_MEMBER_RETAIL_REGION")
|
||||
public class CuMemberRegion extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
@ -98,5 +98,10 @@ insert into BD_AWARDS_REGION_CONFIG (PK_ID, AREA_TYPE, PK_AWARDS, AWARDS_VALUE,
|
|||
|
||||
|
||||
ALTER TABLE "CU_MEMBER_RETAIL_REGION"
|
||||
MODIFY ("CITY" NULL)
|
||||
MODIFY ("COUNTY" NULL);
|
||||
ADD ("SOURCE" NUMBER(1,0) DEFAULT 1 NOT NULL);
|
||||
COMMENT ON COLUMN "CLOUD_2"."CU_MEMBER_RETAIL_REGION"."SOURCE" IS '来源(1=前台,2=后台)';
|
||||
|
||||
ALTER TABLE "CU_MEMBER_RETAIL_REGION"
|
||||
ADD ("EFFECTIVE_END_DATE" DATE DEFAULT TO_DATE('2099-01-01', 'YYYY-MM-DD'));
|
||||
|
||||
COMMENT ON COLUMN "CLOUD_2"."CU_MEMBER_RETAIL_REGION"."EFFECTIVE_END_DATE" IS '生效结束时间';
|
||||
|
|
Loading…
Reference in New Issue