## 调整4-N拨比入库处理;

This commit is contained in:
cabbage 2025-05-16 13:45:28 +08:00
parent 2af9edf053
commit 7c47611567
5 changed files with 95 additions and 109 deletions

View File

@ -10,9 +10,6 @@ import java.util.List;
/** /**
* Mapper 接口 * Mapper 接口
*
* @author hzs
* @since 2024-07-19
*/ */
public interface CuBonusExpandMapper extends BaseMapper<CuBonusExpand> { public interface CuBonusExpandMapper extends BaseMapper<CuBonusExpand> {
@ -26,49 +23,31 @@ public interface CuBonusExpandMapper extends BaseMapper<CuBonusExpand> {
/* /*
* @description: 查询日期是否标红 * @description: 查询日期是否标红
* @author: sui q
* @date: 2024/7/24 10:59
* @param: null null
**/ **/
List<CuBonusExpandExt> queryBonusExpandDis(BonusExpandParam bonusExpandParam); List<CuBonusExpandExt> queryBonusExpandDis(BonusExpandParam bonusExpandParam);
/* /*
* @description: 查询所有零线会员 * @description: 查询所有零线会员
* @author: sui q
* @date: 2024/7/22 16:16
* @param: null null
**/ **/
List<CuBonusExpand> queryZeroMemberByVertex(); List<CuBonusExpand> queryZeroMemberByVertex();
/* /*
* @description: 根基时间期间计算波比 * @description: 时间期间计算波比 -- 首购
* @author: sui q
* @date: 2024/7/22 13:42
* @param: null null
**/ **/
List<CuBonusExpand> calculateDayRatioByBonusExpandParam(@Param("bonusExpandParam") BonusExpandParam bonusExpandParam, @Param("tableName") String tableName); List<CuBonusExpand> calculateDayRatioByBonusExpandParam(@Param("bonusExpandParam") BonusExpandParam bonusExpandParam, @Param("tableName") String tableName);
/* /*
* @description: 根基时间期间计算波比 * @description: 时间期间计算波比 -- 复购
* @author: sui q
* @date: 2024/7/22 13:42
* @param: null null
**/ **/
List<CuBonusExpand> calculateDayRepRatioByBonusExpandParam(@Param("bonusExpandParam") BonusExpandParam bonusExpandParam, @Param("tableName") String tableName); List<CuBonusExpand> calculateDayRepRatioByBonusExpandParam(@Param("bonusExpandParam") BonusExpandParam bonusExpandParam, @Param("tableName") String tableName);
/* /*
* @description: 删除临时表 * @description: 删除临时表
* @author: sui q
* @date: 2024/7/30 13:49
* @param: null null
**/ **/
void truncateTable(); void truncateTable();
/* /*
* @description: 批量更新4-n配置 * @description: 批量更新4-n配置
* @author: sui q
* @date: 2024/7/22 14:22
* @param: null null
**/ **/
void mergeBonusExpandByList(@Param("cuBonusExpandList") List<CuBonusExpand> cuBonusExpandList); void mergeBonusExpandByList(@Param("cuBonusExpandList") List<CuBonusExpand> cuBonusExpandList);
} }

View File

@ -11,12 +11,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* @description: 4-n 增加碰次 * 4-n 增加碰次
* @author: sui q
* @time: 2024/7/19 14:21
* @classname: BonusExpandParam
* @package_name: com.hzs.bonus.bonus.param
* version 1.0.0
*/ */
@Data @Data
@Builder @Builder

View File

@ -57,7 +57,7 @@ public class CuBonusExpandServiceImpl extends ServiceImpl<CuBonusExpandMapper, C
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void firstSaveCuBonusExpand(BonusExpandParam bonusExpandParam) { public void firstSaveCuBonusExpand(BonusExpandParam bonusExpandParam) {
List<CuBonusExpand> bonusExpandList = queryCuBonusExpand(bonusExpandParam.getSettleDate(), bonusExpandParam.getPkCountry()); List<CuBonusExpand> bonusExpandList = queryCuBonusExpand(bonusExpandParam.getSettleDate(), bonusExpandParam.getPkCountry());
if (bonusExpandList == null || bonusExpandList.size() == 0) { if (CollectionUtil.isEmpty(bonusExpandList)) {
// 查询 // 查询
List<CuBonusExpand> cuBonusExpandList = queryCuBonusExpand(DateUtils.beforeDate(1, ChronoUnit.DAYS, bonusExpandParam.getSettleDate()), bonusExpandParam.getPkCountry()); List<CuBonusExpand> cuBonusExpandList = queryCuBonusExpand(DateUtils.beforeDate(1, ChronoUnit.DAYS, bonusExpandParam.getSettleDate()), bonusExpandParam.getPkCountry());
Map<Long, CuBonusExpand> cuBonusExpandMap = new HashMap<>(); Map<Long, CuBonusExpand> cuBonusExpandMap = new HashMap<>();
@ -99,6 +99,8 @@ public class CuBonusExpandServiceImpl extends ServiceImpl<CuBonusExpandMapper, C
bonusExpandParam.setMemberIdList(memberIdList); bonusExpandParam.setMemberIdList(memberIdList);
// 计算所有体系日波比 // 计算所有体系日波比
packageBonusExpandParam(bonusExpandParam, settleDate, settleDate); packageBonusExpandParam(bonusExpandParam, settleDate, settleDate);
// TODO new 当日首购拨比奖金 订单金额
List<CuBonusExpand> dayBonusExpandList = baseMapper.calculateDayRatioByBonusExpandParam(bonusExpandParam, tableName); List<CuBonusExpand> dayBonusExpandList = baseMapper.calculateDayRatioByBonusExpandParam(bonusExpandParam, tableName);
if (CollectionUtil.isNotEmpty(dayBonusExpandList)) { if (CollectionUtil.isNotEmpty(dayBonusExpandList)) {
for (CuBonusExpand cuBonusExpand : dayBonusExpandList) { for (CuBonusExpand cuBonusExpand : dayBonusExpandList) {
@ -113,6 +115,7 @@ public class CuBonusExpandServiceImpl extends ServiceImpl<CuBonusExpandMapper, C
} }
} }
} }
// TODO new 当日复购拨比奖金 订单金额
List<CuBonusExpand> dayRepBonusExpandList = baseMapper.calculateDayRepRatioByBonusExpandParam(bonusExpandParam, tableName); List<CuBonusExpand> dayRepBonusExpandList = baseMapper.calculateDayRepRatioByBonusExpandParam(bonusExpandParam, tableName);
if (CollectionUtil.isNotEmpty(dayRepBonusExpandList)) { if (CollectionUtil.isNotEmpty(dayRepBonusExpandList)) {
for (CuBonusExpand cuBonusExpand : dayRepBonusExpandList) { for (CuBonusExpand cuBonusExpand : dayRepBonusExpandList) {
@ -124,9 +127,11 @@ public class CuBonusExpandServiceImpl extends ServiceImpl<CuBonusExpandMapper, C
} }
} }
} }
// 计算所有体系月波比 // 计算所有体系月波比
// 获得当前月第一天获得当前月最后一天 // 获得当前月第一天获得当前月最后一天
packageBonusExpandParam(bonusExpandParam, DateUtils.currentMonthFirstDate(settleDate), settleDate); packageBonusExpandParam(bonusExpandParam, DateUtils.currentMonthFirstDate(settleDate), settleDate);
// TODO new 当月首购拨比奖金 订单金额
List<CuBonusExpand> monthBonusExpandList = baseMapper.calculateDayRatioByBonusExpandParam(bonusExpandParam, tableName); List<CuBonusExpand> monthBonusExpandList = baseMapper.calculateDayRatioByBonusExpandParam(bonusExpandParam, tableName);
if (CollectionUtil.isNotEmpty(monthBonusExpandList)) { if (CollectionUtil.isNotEmpty(monthBonusExpandList)) {
for (CuBonusExpand cuBonusExpand : monthBonusExpandList) { for (CuBonusExpand cuBonusExpand : monthBonusExpandList) {

View File

@ -34,100 +34,110 @@
using ( using (
select * from( select * from(
<foreach collection="cuBonusExpandList" item="item" index="index" separator=" union "> <foreach collection="cuBonusExpandList" item="item" index="index" separator=" union ">
select #{item.pkId} pk_id,#{item.dayAchieve,jdbcType=NUMERIC} day_achieve,#{item.dayBonus,jdbcType=NUMERIC} select
day_bonus, #{item.pkId} pk_id, #{item.dayAchieve,jdbcType=NUMERIC} day_achieve, #{item.dayBonus,jdbcType=NUMERIC} day_bonus,
#{item.yesDayRatio,jdbcType=NUMERIC} yes_day_ratio,#{item.curDayRatio,jdbcType=NUMERIC} cur_day_ratio, #{item.yesDayRatio,jdbcType=NUMERIC} yes_day_ratio, #{item.curDayRatio,jdbcType=NUMERIC} cur_day_ratio,
#{item.monthAchieve,jdbcType=NUMERIC} month_achieve,#{item.monthBonus,jdbcType=NUMERIC} month_bonus, #{item.monthAchieve,jdbcType=NUMERIC} month_achieve, #{item.monthBonus,jdbcType=NUMERIC} month_bonus,
#{item.monthRatio,jdbcType=NUMERIC} month_ratio,#{item.dayRepAchieve,jdbcType=NUMERIC} day_rep_achieve, #{item.monthRatio,jdbcType=NUMERIC} month_ratio, #{item.dayRepAchieve,jdbcType=NUMERIC} day_rep_achieve,
#{item.dayRepBonus,jdbcType=NUMERIC} day_rep_bonus,#{item.curDayRepRatio,jdbcType=NUMERIC} cur_day_rep_ratio #{item.dayRepBonus,jdbcType=NUMERIC} day_rep_bonus, #{item.curDayRepRatio,jdbcType=NUMERIC} cur_day_rep_ratio
from dual from dual
</foreach>) </foreach>)
) b ) b
on (ce.pk_id=b.pk_id) on (ce.pk_id = b.pk_id)
when matched then when matched then
update set ce.day_achieve=b.day_achieve,ce.day_bonus=b.day_bonus,ce.yes_day_ratio=b.yes_day_ratio, update set ce.day_achieve = b.day_achieve, ce.day_bonus = b.day_bonus, ce.yes_day_ratio = b.yes_day_ratio,
ce.cur_day_ratio=b.cur_day_ratio,ce.month_achieve=b.month_achieve, ce.cur_day_ratio = b.cur_day_ratio, ce.month_achieve = b.month_achieve,
ce.month_bonus=b.month_bonus,ce.month_ratio=b.month_ratio, ce.month_bonus = b.month_bonus, ce.month_ratio = b.month_ratio,
ce.day_rep_achieve=b.day_rep_achieve,ce.day_rep_bonus=b.day_rep_bonus, ce.day_rep_achieve = b.day_rep_achieve, ce.day_rep_bonus = b.day_rep_bonus,
ce.cur_day_rep_ratio=b.cur_day_rep_ratio ce.cur_day_rep_ratio = b.cur_day_rep_ratio
</update> </update>
<update id="truncateTable"> <update id="truncateTable">
truncate table cu_member_repeat_bonus truncate table cu_member_repeat_bonus
</update> </update>
<select id="calculateDayRepRatioByBonusExpandParam" resultMap="CuBonusExpandExt"> <!-- 时间、期间计算波比 首购 -->
<select id="calculateDayRatioByBonusExpandParam" resultMap="CuBonusExpandExt">
<foreach collection="bonusExpandParam.memberIdList" item="item" index="index" separator=" union "> <foreach collection="bonusExpandParam.memberIdList" item="item" index="index" separator=" union ">
select a.pk_member,COALESCE(a.order_amount,0) day_rep_achieve, select a.pk_member,
COALESCE(b.pur_real_subtotal*bc.out_exchange_rate,0) day_rep_bonus, COALESCE(a.order_amount, 0) day_achieve,
COALESCE(ROUND(b.pur_real_subtotal*bc.out_exchange_rate/a.order_amount*100, 2),0) cur_day_rep_ratio from( COALESCE(b.pur_real_subtotal, 0) day_bonus,
select #{item} pk_member,sum(order_amount) order_amount from( COALESCE(ROUND(b.pur_real_subtotal / a.order_amount * 100, 2), 0) yes_day_ratio
select so.pk_member,order_achieve,(case when order_amount>=198000 then 49500 else order_amount end) from (
order_amount from sa_order so select #{item} pk_member, sum(order_amount) order_amount
inner join( from (
select * from cu_member select so.pk_member, order_achieve, order_amount
from sa_order so
inner join (
select pk_id, del_flag from cu_member
start with pk_id= #{item} start with pk_id= #{item}
connect by pk_place_parent =prior pk_id connect by pk_place_parent = prior pk_id
) cu ) cu
on cu.pk_id=so.pk_member on cu.pk_id = so.pk_member
where so.order_status = 1 and so.del_flag=0 and so.order_achieve>0 and so.pk_country=1 where so.del_flag = 0 and so.order_status = 1
and so.order_type in(3,23,26) and so.order_type in (1, 2, 24, 25) and so.pk_country = 1
and so.pay_time >= #{bonusExpandParam.startDate,jdbcType=DATE} and so.pay_time >= #{bonusExpandParam.startDate, jdbcType = DATE}
and so.pay_time &lt; #{bonusExpandParam.endDate,jdbcType=DATE})) a and so.pay_time &lt; #{bonusExpandParam.endDate, jdbcType = DATE} )
inner join( ) a
select #{item} pk_member,nvl(sum(repur_real_subtotal),0) pur_real_subtotal from ${tableName} cb inner join (
inner join( select #{item} pk_member, nvl(sum(pur_real_subtotal), 0) pur_real_subtotal
from ${tableName} cb
inner join (
select * from cu_member select * from cu_member
start with pk_id=#{item} start with pk_id = #{item}
connect by pk_place_parent =prior pk_id connect by pk_place_parent =prior pk_id
) cu ) cu
on cu.pk_id = cb.pk_member on cu.pk_id = cb.pk_member
where period between #{bonusExpandParam.startPeriod} and #{bonusExpandParam.endPeriod} and cb.del_flag=0 and where
cb.pk_country=1 period between #{bonusExpandParam.startPeriod} and #{bonusExpandParam.endPeriod}
and cb.del_flag = 0
and cb.pk_country = 1
) b ) b
on a.pk_member=b.pk_member on a.pk_member = b.pk_member
join cu_member cm join cu_member cm
on cm.pk_id=a.pk_member on cm.pk_id = a.pk_member
join bd_currency bc
on bc.pk_country=cm.pk_settle_country and bc.del_flag=0
</foreach> </foreach>
</select> </select>
<select id="calculateDayRatioByBonusExpandParam" resultMap="CuBonusExpandExt"> <!-- 时间、期间计算波比 复购 -->
<select id="calculateDayRepRatioByBonusExpandParam" resultMap="CuBonusExpandExt">
<foreach collection="bonusExpandParam.memberIdList" item="item" index="index" separator=" union "> <foreach collection="bonusExpandParam.memberIdList" item="item" index="index" separator=" union ">
select a.pk_member,COALESCE(a.order_amount,0) day_achieve, select a.pk_member,
COALESCE(b.pur_real_subtotal*bc.out_exchange_rate,0) day_bonus, COALESCE(a.order_amount, 0) day_rep_achieve,
COALESCE(ROUND(b.pur_real_subtotal*bc.out_exchange_rate/a.order_amount*100, 2),0) yes_day_ratio from( COALESCE(b.pur_real_subtotal, 0) day_rep_bonus,
select #{item} pk_member,sum(order_amount) order_amount from( COALESCE(ROUND(b.pur_real_subtotal / a.order_amount * 100, 2), 0) cur_day_rep_ratio
select so.pk_member,order_achieve,(case when order_amount>=198000 then 49500 else order_amount end) from(
order_amount from sa_order so select #{item} pk_member, sum(order_amount) order_amount
inner join( from (
select so.pk_member, order_achieve, order_amount from sa_order so
inner join (
select * from cu_member select * from cu_member
start with pk_id= #{item} start with pk_id = #{item}
connect by pk_place_parent =prior pk_id connect by pk_place_parent = prior pk_id
) cu ) cu
on cu.pk_id=so.pk_member on cu.pk_id = so.pk_member
where so.order_status = 1 and so.del_flag=0 where so.del_flag = 0 and so.order_status = 1
and so.order_type in(1,2,24,25) and so.pk_country=1 and so.order_achieve > 0
and so.order_type in (3, 26) and so.pk_country = 1
and so.pay_time >= #{bonusExpandParam.startDate,jdbcType=DATE} and so.pay_time >= #{bonusExpandParam.startDate,jdbcType=DATE}
and so.pay_time &lt; #{bonusExpandParam.endDate,jdbcType=DATE})) a and so.pay_time &lt; #{bonusExpandParam.endDate,jdbcType=DATE} )
inner join( ) a
select #{item} pk_member,nvl(sum(pur_real_subtotal+maker_real_subtotal),0) pur_real_subtotal from
${tableName} cb
inner join( inner join(
select #{item} pk_member, nvl(sum(repur_real_subtotal), 0) pur_real_subtotal
from ${tableName} cb
inner join (
select * from cu_member select * from cu_member
start with pk_id=#{item} start with pk_i = #{item}
connect by pk_place_parent =prior pk_id connect by pk_place_parent =prior pk_id
) cu ) cu
on cu.pk_id = cb.pk_member on cu.pk_id = cb.pk_member
where period between #{bonusExpandParam.startPeriod} and #{bonusExpandParam.endPeriod} and cb.del_flag=0 and where period between #{bonusExpandParam.startPeriod} and #{bonusExpandParam.endPeriod}
cb.pk_country=1 and cb.del_flag = 0
and cb.pk_country = 1
) b ) b
on a.pk_member=b.pk_member on a.pk_member = b.pk_member
join cu_member cm join cu_member cm
on cm.pk_id=a.pk_member on cm.pk_id = a.pk_member
join bd_currency bc
on bc.pk_country=cm.pk_settle_country and bc.del_flag=0
</foreach> </foreach>
</select> </select>
@ -144,21 +154,21 @@
</select> </select>
<select id="queryBonusExpand" resultMap="CuBonusExpandExt"> <select id="queryBonusExpand" resultMap="CuBonusExpandExt">
select ce.*,cm.member_code,cm.member_name,bv.vertex_name select ce.*, cm.member_code, cm.member_name, bv.vertex_name
from cu_bonus_expand ce from cu_bonus_expand ce
inner join cu_member cm inner join cu_member cm
on ce.pk_member = cm.pk_id on ce.pk_member = cm.pk_id
left join bd_vertex bv left join bd_vertex bv
on ce.pk_vertex=bv.pk_id and bv.del_flag=0 on ce.pk_vertex = bv.pk_id and bv.del_flag = 0
where ce.del_flag=0 and cm.del_flag=0 where ce.del_flag = 0 and cm.del_flag = 0
<if test="pkCountry != null"> <if test="pkCountry != null">
and ce.pk_country = #{pkCountry} and ce.pk_country = #{pkCountry}
</if> </if>
<if test="settleDate != null"> <if test="settleDate != null">
and ce.settle_date=#{settleDate,jdbcType=DATE} and ce.settle_date = #{settleDate,jdbcType=DATE}
</if> </if>
<choose> <choose>
<when test="pkParent != null">and ce.pk_parent=#{pkParent}</when> <when test="pkParent != null">and ce.pk_parent = #{pkParent}</when>
<otherwise>and ce.pk_parent is null</otherwise> <otherwise>and ce.pk_parent is null</otherwise>
</choose> </choose>
<if test="memberCode != null and memberCode != ''"> <if test="memberCode != null and memberCode != ''">

View File

@ -16,9 +16,6 @@ import lombok.experimental.Accessors;
/** /**
* 4-n增加碰次设置 * 4-n增加碰次设置
*
* @author hzs
* @since 2024-07-19
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ -70,61 +67,61 @@ public class CuBonusExpand extends BaseEntity {
private Integer sort; private Integer sort;
/** /**
* 昨日业绩 * 当日业绩目前取的订单金额
*/ */
@TableField("DAY_ACHIEVE") @TableField("DAY_ACHIEVE")
private BigDecimal dayAchieve; private BigDecimal dayAchieve;
/** /**
* 日奖金 * 日奖金
*/ */
@TableField("DAY_BONUS") @TableField("DAY_BONUS")
private BigDecimal dayBonus; private BigDecimal dayBonus;
/** /**
* 日波比 * 日波比
*/ */
@TableField("YES_DAY_RATIO") @TableField("YES_DAY_RATIO")
private BigDecimal yesDayRatio; private BigDecimal yesDayRatio;
/** /**
* 当前波比 * 重算波比默认当日波比
*/ */
@TableField("CUR_DAY_RATIO") @TableField("CUR_DAY_RATIO")
private BigDecimal curDayRatio; private BigDecimal curDayRatio;
/** /**
* 昨日复购业绩 * 当日复购业绩目前取的订单金额
*/ */
@TableField("DAY_REP_ACHIEVE") @TableField("DAY_REP_ACHIEVE")
private BigDecimal dayRepAchieve; private BigDecimal dayRepAchieve;
/** /**
* 日复购奖金 * 日复购奖金
*/ */
@TableField("DAY_REP_BONUS") @TableField("DAY_REP_BONUS")
private BigDecimal dayRepBonus; private BigDecimal dayRepBonus;
/** /**
* 复购波比 * 复购波比
*/ */
@TableField("CUR_DAY_REP_RATIO") @TableField("CUR_DAY_REP_RATIO")
private BigDecimal curDayRepRatio; private BigDecimal curDayRepRatio;
/** /**
* 当月业绩 * 当月业绩首购
*/ */
@TableField("MONTH_ACHIEVE") @TableField("MONTH_ACHIEVE")
private BigDecimal monthAchieve; private BigDecimal monthAchieve;
/** /**
* 当月奖金 * 当月奖金首购
*/ */
@TableField("MONTH_BONUS") @TableField("MONTH_BONUS")
private BigDecimal monthBonus; private BigDecimal monthBonus;
/** /**
* 当月波比 * 当月波比首购
*/ */
@TableField("MONTH_RATIO") @TableField("MONTH_RATIO")
private BigDecimal monthRatio; private BigDecimal monthRatio;