## 调整4-N拨比入库处理;
This commit is contained in:
parent
94ec7831e3
commit
ba992616d8
|
@ -10,9 +10,6 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author hzs
|
||||
* @since 2024-07-19
|
||||
*/
|
||||
public interface CuBonusExpandMapper extends BaseMapper<CuBonusExpand> {
|
||||
|
||||
|
@ -26,49 +23,31 @@ public interface CuBonusExpandMapper extends BaseMapper<CuBonusExpand> {
|
|||
|
||||
/*
|
||||
* @description: 查询日期是否标红
|
||||
* @author: sui q
|
||||
* @date: 2024/7/24 10:59
|
||||
* @param: null null
|
||||
**/
|
||||
List<CuBonusExpandExt> queryBonusExpandDis(BonusExpandParam bonusExpandParam);
|
||||
|
||||
/*
|
||||
* @description: 查询所有零线会员
|
||||
* @author: sui q
|
||||
* @date: 2024/7/22 16:16
|
||||
* @param: null null
|
||||
**/
|
||||
List<CuBonusExpand> queryZeroMemberByVertex();
|
||||
|
||||
/*
|
||||
* @description: 根基时间、期间计算波比
|
||||
* @author: sui q
|
||||
* @date: 2024/7/22 13:42
|
||||
* @param: null null
|
||||
* @description: 时间、期间计算波比 -- 首购
|
||||
**/
|
||||
List<CuBonusExpand> calculateDayRatioByBonusExpandParam(@Param("bonusExpandParam") BonusExpandParam bonusExpandParam, @Param("tableName") String tableName);
|
||||
|
||||
/*
|
||||
* @description: 根基时间、期间计算波比
|
||||
* @author: sui q
|
||||
* @date: 2024/7/22 13:42
|
||||
* @param: null null
|
||||
* @description: 时间、期间计算波比 -- 复购
|
||||
**/
|
||||
List<CuBonusExpand> calculateDayRepRatioByBonusExpandParam(@Param("bonusExpandParam") BonusExpandParam bonusExpandParam, @Param("tableName") String tableName);
|
||||
|
||||
/*
|
||||
* @description: 删除临时表
|
||||
* @author: sui q
|
||||
* @date: 2024/7/30 13:49
|
||||
* @param: null null
|
||||
**/
|
||||
void truncateTable();
|
||||
|
||||
/*
|
||||
* @description: 批量更新4-n配置
|
||||
* @author: sui q
|
||||
* @date: 2024/7/22 14:22
|
||||
* @param: null null
|
||||
**/
|
||||
void mergeBonusExpandByList(@Param("cuBonusExpandList") List<CuBonusExpand> cuBonusExpandList);
|
||||
}
|
||||
|
|
|
@ -11,12 +11,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description: 4-n 增加碰次
|
||||
* @author: sui q
|
||||
* @time: 2024/7/19 14:21
|
||||
* @classname: BonusExpandParam
|
||||
* @package_name: com.hzs.bonus.bonus.param
|
||||
* version 1.0.0
|
||||
* 4-n 增加碰次
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
|
|
@ -57,7 +57,7 @@ public class CuBonusExpandServiceImpl extends ServiceImpl<CuBonusExpandMapper, C
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void firstSaveCuBonusExpand(BonusExpandParam bonusExpandParam) {
|
||||
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());
|
||||
Map<Long, CuBonusExpand> cuBonusExpandMap = new HashMap<>();
|
||||
|
@ -99,6 +99,8 @@ public class CuBonusExpandServiceImpl extends ServiceImpl<CuBonusExpandMapper, C
|
|||
bonusExpandParam.setMemberIdList(memberIdList);
|
||||
// 计算所有体系日波比
|
||||
packageBonusExpandParam(bonusExpandParam, settleDate, settleDate);
|
||||
|
||||
// TODO new 当日首购拨比:奖金 除 订单金额
|
||||
List<CuBonusExpand> dayBonusExpandList = baseMapper.calculateDayRatioByBonusExpandParam(bonusExpandParam, tableName);
|
||||
if (CollectionUtil.isNotEmpty(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);
|
||||
if (CollectionUtil.isNotEmpty(dayRepBonusExpandList)) {
|
||||
for (CuBonusExpand cuBonusExpand : dayRepBonusExpandList) {
|
||||
|
@ -124,9 +127,11 @@ public class CuBonusExpandServiceImpl extends ServiceImpl<CuBonusExpandMapper, C
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计算所有体系月波比
|
||||
// 获得当前月第一天,获得当前月最后一天
|
||||
packageBonusExpandParam(bonusExpandParam, DateUtils.currentMonthFirstDate(settleDate), settleDate);
|
||||
// TODO new 当月首购拨比:奖金 除 订单金额
|
||||
List<CuBonusExpand> monthBonusExpandList = baseMapper.calculateDayRatioByBonusExpandParam(bonusExpandParam, tableName);
|
||||
if (CollectionUtil.isNotEmpty(monthBonusExpandList)) {
|
||||
for (CuBonusExpand cuBonusExpand : monthBonusExpandList) {
|
||||
|
|
|
@ -34,100 +34,110 @@
|
|||
using (
|
||||
select * from(
|
||||
<foreach collection="cuBonusExpandList" item="item" index="index" separator=" union ">
|
||||
select #{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.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.dayRepBonus,jdbcType=NUMERIC} day_rep_bonus,#{item.curDayRepRatio,jdbcType=NUMERIC} cur_day_rep_ratio
|
||||
select
|
||||
#{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.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.dayRepBonus,jdbcType=NUMERIC} day_rep_bonus, #{item.curDayRepRatio,jdbcType=NUMERIC} cur_day_rep_ratio
|
||||
from dual
|
||||
</foreach>)
|
||||
) b
|
||||
on (ce.pk_id=b.pk_id)
|
||||
on (ce.pk_id = b.pk_id)
|
||||
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,
|
||||
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.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
|
||||
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.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.cur_day_rep_ratio = b.cur_day_rep_ratio
|
||||
</update>
|
||||
|
||||
<update id="truncateTable">
|
||||
truncate table cu_member_repeat_bonus
|
||||
</update>
|
||||
|
||||
<select id="calculateDayRepRatioByBonusExpandParam" resultMap="CuBonusExpandExt">
|
||||
<!-- 时间、期间计算波比 首购 -->
|
||||
<select id="calculateDayRatioByBonusExpandParam" resultMap="CuBonusExpandExt">
|
||||
<foreach collection="bonusExpandParam.memberIdList" item="item" index="index" separator=" union ">
|
||||
select a.pk_member,COALESCE(a.order_amount,0) day_rep_achieve,
|
||||
COALESCE(b.pur_real_subtotal*bc.out_exchange_rate,0) day_rep_bonus,
|
||||
COALESCE(ROUND(b.pur_real_subtotal*bc.out_exchange_rate/a.order_amount*100, 2),0) cur_day_rep_ratio from(
|
||||
select #{item} pk_member,sum(order_amount) order_amount from(
|
||||
select so.pk_member,order_achieve,(case when order_amount>=198000 then 49500 else order_amount end)
|
||||
order_amount from sa_order so
|
||||
inner join(
|
||||
select * from cu_member
|
||||
select a.pk_member,
|
||||
COALESCE(a.order_amount, 0) day_achieve,
|
||||
COALESCE(b.pur_real_subtotal, 0) day_bonus,
|
||||
COALESCE(ROUND(b.pur_real_subtotal / a.order_amount * 100, 2), 0) yes_day_ratio
|
||||
from (
|
||||
select #{item} pk_member, sum(order_amount) order_amount
|
||||
from (
|
||||
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}
|
||||
connect by pk_place_parent =prior pk_id
|
||||
connect by pk_place_parent = prior pk_id
|
||||
) cu
|
||||
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
|
||||
and so.order_type in(3,23,26)
|
||||
and so.pay_time >= #{bonusExpandParam.startDate,jdbcType=DATE}
|
||||
and so.pay_time < #{bonusExpandParam.endDate,jdbcType=DATE})) a
|
||||
inner join(
|
||||
select #{item} pk_member,nvl(sum(repur_real_subtotal),0) pur_real_subtotal from ${tableName} cb
|
||||
inner join(
|
||||
on cu.pk_id = so.pk_member
|
||||
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.pay_time >= #{bonusExpandParam.startDate, jdbcType = DATE}
|
||||
and so.pay_time < #{bonusExpandParam.endDate, jdbcType = DATE} )
|
||||
) a
|
||||
inner join (
|
||||
select #{item} pk_member, nvl(sum(pur_real_subtotal), 0) pur_real_subtotal
|
||||
from ${tableName} cb
|
||||
inner join (
|
||||
select * from cu_member
|
||||
start with pk_id=#{item}
|
||||
start with pk_id = #{item}
|
||||
connect by pk_place_parent =prior pk_id
|
||||
) cu
|
||||
on cu.pk_id = cb.pk_member
|
||||
where period between #{bonusExpandParam.startPeriod} and #{bonusExpandParam.endPeriod} and cb.del_flag=0 and
|
||||
cb.pk_country=1
|
||||
where
|
||||
period between #{bonusExpandParam.startPeriod} and #{bonusExpandParam.endPeriod}
|
||||
and cb.del_flag = 0
|
||||
and cb.pk_country = 1
|
||||
) b
|
||||
on a.pk_member=b.pk_member
|
||||
on a.pk_member = b.pk_member
|
||||
join cu_member cm
|
||||
on cm.pk_id=a.pk_member
|
||||
join bd_currency bc
|
||||
on bc.pk_country=cm.pk_settle_country and bc.del_flag=0
|
||||
on cm.pk_id = a.pk_member
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="calculateDayRatioByBonusExpandParam" resultMap="CuBonusExpandExt">
|
||||
<!-- 时间、期间计算波比 复购 -->
|
||||
<select id="calculateDayRepRatioByBonusExpandParam" resultMap="CuBonusExpandExt">
|
||||
<foreach collection="bonusExpandParam.memberIdList" item="item" index="index" separator=" union ">
|
||||
select a.pk_member,COALESCE(a.order_amount,0) day_achieve,
|
||||
COALESCE(b.pur_real_subtotal*bc.out_exchange_rate,0) day_bonus,
|
||||
COALESCE(ROUND(b.pur_real_subtotal*bc.out_exchange_rate/a.order_amount*100, 2),0) yes_day_ratio from(
|
||||
select #{item} pk_member,sum(order_amount) order_amount from(
|
||||
select so.pk_member,order_achieve,(case when order_amount>=198000 then 49500 else order_amount end)
|
||||
order_amount from sa_order so
|
||||
inner join(
|
||||
select a.pk_member,
|
||||
COALESCE(a.order_amount, 0) day_rep_achieve,
|
||||
COALESCE(b.pur_real_subtotal, 0) day_rep_bonus,
|
||||
COALESCE(ROUND(b.pur_real_subtotal / a.order_amount * 100, 2), 0) cur_day_rep_ratio
|
||||
from(
|
||||
select #{item} pk_member, sum(order_amount) order_amount
|
||||
from (
|
||||
select so.pk_member, order_achieve, order_amount from sa_order so
|
||||
inner join (
|
||||
select * from cu_member
|
||||
start with pk_id= #{item}
|
||||
connect by pk_place_parent =prior pk_id
|
||||
start with pk_id = #{item}
|
||||
connect by pk_place_parent = prior pk_id
|
||||
) cu
|
||||
on cu.pk_id=so.pk_member
|
||||
where so.order_status = 1 and so.del_flag=0
|
||||
and so.order_type in(1,2,24,25) and so.pk_country=1
|
||||
on cu.pk_id = so.pk_member
|
||||
where so.del_flag = 0 and so.order_status = 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.endDate,jdbcType=DATE})) a
|
||||
inner join(
|
||||
select #{item} pk_member,nvl(sum(pur_real_subtotal+maker_real_subtotal),0) pur_real_subtotal from
|
||||
${tableName} cb
|
||||
and so.pay_time < #{bonusExpandParam.endDate,jdbcType=DATE} )
|
||||
) a
|
||||
inner join(
|
||||
select #{item} pk_member, nvl(sum(repur_real_subtotal), 0) pur_real_subtotal
|
||||
from ${tableName} cb
|
||||
inner join (
|
||||
select * from cu_member
|
||||
start with pk_id=#{item}
|
||||
start with pk_i = #{item}
|
||||
connect by pk_place_parent =prior pk_id
|
||||
) cu
|
||||
on cu.pk_id = cb.pk_member
|
||||
where period between #{bonusExpandParam.startPeriod} and #{bonusExpandParam.endPeriod} and cb.del_flag=0 and
|
||||
cb.pk_country=1
|
||||
where period between #{bonusExpandParam.startPeriod} and #{bonusExpandParam.endPeriod}
|
||||
and cb.del_flag = 0
|
||||
and cb.pk_country = 1
|
||||
) b
|
||||
on a.pk_member=b.pk_member
|
||||
on a.pk_member = b.pk_member
|
||||
join cu_member cm
|
||||
on cm.pk_id=a.pk_member
|
||||
join bd_currency bc
|
||||
on bc.pk_country=cm.pk_settle_country and bc.del_flag=0
|
||||
on cm.pk_id = a.pk_member
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
@ -144,21 +154,21 @@
|
|||
</select>
|
||||
|
||||
<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
|
||||
inner join cu_member cm
|
||||
on ce.pk_member = cm.pk_id
|
||||
left join bd_vertex bv
|
||||
on ce.pk_vertex=bv.pk_id and bv.del_flag=0
|
||||
where ce.del_flag=0 and cm.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
|
||||
<if test="pkCountry != null">
|
||||
and ce.pk_country = #{pkCountry}
|
||||
</if>
|
||||
<if test="settleDate != null">
|
||||
and ce.settle_date=#{settleDate,jdbcType=DATE}
|
||||
and ce.settle_date = #{settleDate,jdbcType=DATE}
|
||||
</if>
|
||||
<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>
|
||||
</choose>
|
||||
<if test="memberCode != null and memberCode != ''">
|
||||
|
|
|
@ -16,9 +16,6 @@ import lombok.experimental.Accessors;
|
|||
|
||||
/**
|
||||
* 4-n增加碰次设置
|
||||
*
|
||||
* @author hzs
|
||||
* @since 2024-07-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
@ -70,61 +67,61 @@ public class CuBonusExpand extends BaseEntity {
|
|||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 昨日业绩
|
||||
* 当日业绩(目前取的订单金额)
|
||||
*/
|
||||
@TableField("DAY_ACHIEVE")
|
||||
private BigDecimal dayAchieve;
|
||||
|
||||
/**
|
||||
* 昨日奖金
|
||||
* 当日奖金
|
||||
*/
|
||||
@TableField("DAY_BONUS")
|
||||
private BigDecimal dayBonus;
|
||||
|
||||
/**
|
||||
* 昨日波比
|
||||
* 当日波比
|
||||
*/
|
||||
@TableField("YES_DAY_RATIO")
|
||||
private BigDecimal yesDayRatio;
|
||||
|
||||
/**
|
||||
* 当前波比
|
||||
* 重算波比(默认当日波比)
|
||||
*/
|
||||
@TableField("CUR_DAY_RATIO")
|
||||
private BigDecimal curDayRatio;
|
||||
|
||||
/**
|
||||
* 昨日复购业绩
|
||||
* 当日复购业绩(目前取的订单金额)
|
||||
*/
|
||||
@TableField("DAY_REP_ACHIEVE")
|
||||
private BigDecimal dayRepAchieve;
|
||||
|
||||
/**
|
||||
* 昨日复购奖金
|
||||
* 当日复购奖金
|
||||
*/
|
||||
@TableField("DAY_REP_BONUS")
|
||||
private BigDecimal dayRepBonus;
|
||||
|
||||
/**
|
||||
* 当前复购波比
|
||||
* 当日复购波比
|
||||
*/
|
||||
@TableField("CUR_DAY_REP_RATIO")
|
||||
private BigDecimal curDayRepRatio;
|
||||
|
||||
/**
|
||||
* 当月业绩
|
||||
* 当月业绩(首购)
|
||||
*/
|
||||
@TableField("MONTH_ACHIEVE")
|
||||
private BigDecimal monthAchieve;
|
||||
|
||||
/**
|
||||
* 当月奖金
|
||||
* 当月奖金(首购)
|
||||
*/
|
||||
@TableField("MONTH_BONUS")
|
||||
private BigDecimal monthBonus;
|
||||
|
||||
/**
|
||||
* 当月波比
|
||||
* 当月波比(首购)
|
||||
*/
|
||||
@TableField("MONTH_RATIO")
|
||||
private BigDecimal monthRatio;
|
||||
|
|
Loading…
Reference in New Issue