2025-03-23 08:39:16 +08:00
|
|
|
<?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.hzs.bonus.achieve.mapper.CuMemberMonthAchieveMapper">
|
|
|
|
|
|
|
|
|
|
<!-- 通用查询映射结果 -->
|
|
|
|
|
<resultMap id="CuMemberMonthAchieve" type="com.hzs.common.domain.member.ext.CuMemberMonthAchieveExt">
|
2025-04-01 14:33:10 +08:00
|
|
|
<id column="PK_ID" property="pkId"/>
|
|
|
|
|
<result column="DEL_FLAG" property="delFlag"/>
|
|
|
|
|
<result column="CREATION_TIME" property="creationTime"/>
|
|
|
|
|
<result column="MODIFIED_TIME" property="modifiedTime"/>
|
|
|
|
|
<result column="PK_COUNTRY" property="pkCountry"/>
|
|
|
|
|
<result column="PK_CREATOR" property="pkCreator"/>
|
|
|
|
|
<result column="PK_MODIFIED" property="pkModified"/>
|
|
|
|
|
<result column="PK_MEMBER" property="pkMember"/>
|
|
|
|
|
<result column="PERIOD" property="period"/>
|
|
|
|
|
<result column="SETTLE_MONTH" property="settleMonth"/>
|
|
|
|
|
<result column="RECOMMEND_MONEY" property="recommendMoney"/>
|
|
|
|
|
<result column="RECOMMEND_ACHIEVE" property="recommendAchieve"/>
|
|
|
|
|
<result column="REPURCHASE_MONEY" property="repurchaseMoney"/>
|
|
|
|
|
<result column="REPURCHASE_ACHIEVE" property="repurchaseAchieve"/>
|
|
|
|
|
<result column="WALL_TYPE" property="wallType"/>
|
|
|
|
|
<result column="MONEY" property="money"/>
|
|
|
|
|
<result column="MEMBER_NAME" property="memberName"/>
|
|
|
|
|
<result column="HEAD_PATH" property="headPath"/>
|
2025-03-23 08:39:16 +08:00
|
|
|
</resultMap>
|
2025-04-01 14:33:10 +08:00
|
|
|
|
2025-03-23 08:39:16 +08:00
|
|
|
<insert id="insertCuMemberMonthAchieve">
|
|
|
|
|
merge into CU_MEMBER_MONTH_ACHIEVE a
|
2025-04-01 14:33:10 +08:00
|
|
|
using (
|
|
|
|
|
select pk_member, #{period} period, RECOMMEND_MONEY, RECOMMEND_ACHIEVE, REPURCHASE_MONEY, REPURCHASE_ACHIEVE, pk_country
|
|
|
|
|
from (
|
|
|
|
|
select pk_member,
|
|
|
|
|
pk_country,
|
|
|
|
|
sum(REGISTER_NEW_AMOUNT + UPGRADE_NEW_AMOUNT) RECOMMEND_MONEY,
|
|
|
|
|
sum(REGISTER_NEW_PV + UPGRADE_NEW_PV) RECOMMEND_ACHIEVE,
|
|
|
|
|
sum(REPURCHASE_NEW_AMOUNT + HI_FUN_NEW_AMOUNT + MALL_NEW_AMOUNT) REPURCHASE_MONEY,
|
|
|
|
|
sum(REPURCHASE_PV + HI_FUN_NEW_PV + MALL_NEW_PV) REPURCHASE_ACHIEVE
|
|
|
|
|
from ${tableName}
|
|
|
|
|
where REGISTER_NEW_AMOUNT + UPGRADE_NEW_AMOUNT > 0
|
|
|
|
|
or REPURCHASE_NEW_AMOUNT + HI_FUN_NEW_AMOUNT + MALL_NEW_AMOUNT > 0
|
|
|
|
|
group by pk_member, pk_country)
|
2025-03-23 08:39:16 +08:00
|
|
|
) b
|
2025-04-01 14:33:10 +08:00
|
|
|
on (a.pk_member = b.pk_member and a.period = b.period)
|
2025-03-23 08:39:16 +08:00
|
|
|
when matched then
|
2025-04-01 14:33:10 +08:00
|
|
|
update set a.RECOMMEND_MONEY = b.RECOMMEND_MONEY, a.RECOMMEND_ACHIEVE = b.RECOMMEND_ACHIEVE,
|
|
|
|
|
a.REPURCHASE_MONEY = b.REPURCHASE_MONEY,a.REPURCHASE_ACHIEVE = b.REPURCHASE_ACHIEVE
|
2025-03-23 08:39:16 +08:00
|
|
|
WHEN NOT MATCHED THEN
|
2025-04-01 14:33:10 +08:00
|
|
|
insert (PK_ID, PK_MEMBER, PERIOD, SETTLE_MONTH, RECOMMEND_MONEY, RECOMMEND_ACHIEVE, REPURCHASE_MONEY,
|
|
|
|
|
REPURCHASE_ACHIEVE, PK_COUNTRY, PK_CREATOR)
|
2025-03-23 08:39:16 +08:00
|
|
|
values (CU_MEMBER_MONTH_ACHIEVE_SEQ.NEXTVAL,
|
2025-04-01 14:33:10 +08:00
|
|
|
b.pk_member, b.period, #{month}, b.RECOMMEND_MONEY, b.RECOMMEND_ACHIEVE, b.REPURCHASE_MONEY,
|
|
|
|
|
b.REPURCHASE_ACHIEVE, b.PK_COUNTRY, 1)
|
2025-03-23 08:39:16 +08:00
|
|
|
</insert>
|
2025-04-01 14:33:10 +08:00
|
|
|
|
2025-03-23 08:39:16 +08:00
|
|
|
<select id="queryCuMemberMonthAchieveByDate" resultMap="CuMemberMonthAchieve">
|
2025-04-01 14:33:10 +08:00
|
|
|
select *
|
|
|
|
|
from (
|
|
|
|
|
select *
|
|
|
|
|
from (
|
|
|
|
|
select pk_member, pk_country, ${recommend} wall_type, sum(recommend_money) money
|
|
|
|
|
from CU_MEMBER_MONTH_ACHIEVE
|
|
|
|
|
where del_flag = 0
|
|
|
|
|
and period >= #{startPeriod}
|
|
|
|
|
and period < #{endPeriod}
|
|
|
|
|
group by pk_member, pk_country
|
|
|
|
|
order by sum(recommend_money) desc
|
|
|
|
|
)
|
|
|
|
|
where rownum <= 3
|
|
|
|
|
union
|
|
|
|
|
select *
|
|
|
|
|
from (
|
|
|
|
|
select pk_member, pk_country, ${repurchase} wall_type, sum(repurchase_money) money
|
|
|
|
|
from CU_MEMBER_MONTH_ACHIEVE
|
|
|
|
|
where del_flag = 0
|
|
|
|
|
and period >= #{startPeriod}
|
|
|
|
|
and period < #{endPeriod}
|
|
|
|
|
group by pk_member, pk_country
|
|
|
|
|
order by sum(repurchase_money) desc
|
|
|
|
|
)
|
|
|
|
|
where rownum <= 3) a
|
|
|
|
|
order by wall_type, a.money desc
|
2025-03-23 08:39:16 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
</mapper>
|