SELECT
cbs.LENJOY_AMOUNT lenjoyAmount,
cbs.LENJOY_PV lenjoyPv,
cbs.CLOUD_REAL_SUBTOTAL cloudRealSubtotal,
cbs.PK_BD_VERTEX pkVertex,
cbs.PK_TEAM_CODE pkTeamCode,
cm.MEMBER_CODE as memberCode,
cm.MEMBER_NAME as memberName,
cbs.PK_ID pkId,
cbs.PERIOD period,
cbs.CREATION_TIME creationTime,
cbs.PK_COUNTRY pkCountry,
CASE WHEN (cbs.LENJOY_AMOUNT)=0 THEN 0 ELSE
ROUND(#{perCent}*cbs.CLOUD_REAL_SUBTOTAL/(cbs.LENJOY_AMOUNT),4) end as lenjoyRate
FROM
CU_BONUS_VERTEX_STATIS cbs
LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX AND cm.DEL_FLAG = 0 and cm.SYSTEM_TYPE=1
WHERE 1=1
and cbs.PK_COUNTRY=#{pkCountry}
and cbs.PK_BD_VERTEX =#{pkVertex}
and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
and cbs.CREATION_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
ORDER BY cbs.CREATION_TIME asc
SELECT
SUM(cbs.LENJOY_AMOUNT) lenjoyAmount,
SUM(cbs.LENJOY_PV*#{rate}) lenjoyPv,
SUM(cbs.CLOUD_REAL_SUBTOTAL*#{rate}) cloudRealSubtotal,
CASE WHEN (SUM(cbs.LENJOY_AMOUNT))=0 THEN 0 ELSE
ROUND(#{perCent}*SUM(cbs.CLOUD_REAL_SUBTOTAL)/(SUM(cbs.LENJOY_AMOUNT)),4) end as lenjoyRate
FROM
CU_BONUS_VERTEX_STATIS cbs
LEFT JOIN CU_MEMBER cm ON cm.PK_ID = cbs.PK_BD_VERTEX AND cm.DEL_FLAG = 0 and cm.SYSTEM_TYPE=1
WHERE 1=1
and cbs.PK_COUNTRY=#{pkCountry}
and cbs.PK_BD_VERTEX =#{pkVertex}
and cbs.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
and cbs.CREATION_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
select * from (
select
cm.pk_Member pkMember,
#{pkVertex} pkVertex,
so.PK_COUNTRY pkCountry,
so.ORDER_TYPE orderType,
so.ORDER_AMOUNT orderAmount,
so.ORDER_ACHIEVE orderAchieve,
to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime
from (
SELECT
pk_member
FROM
${settleTableName}
WHERE category=0
start with PK_PARENT = #{pkVertex}
connect by PK_PARENT = prior pk_member
) cm
INNER JOIN SA_ORDER so on so.pk_member=cm.pk_member
where so.ORDER_TYPE in (40)
and so.pk_country=#{pkCountry}
AND so.DEL_FLAG=#{delFlag}
AND so.order_status=#{orderStatus}
and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
)
delete from CU_BONUS_VERTEX_STATIS
where 1=1
and PK_BD_VERTEX in
#{item}
and CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
and CREATION_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
SELECT
pk_id as pkVertex,
MEMBER_CODE as memberCode,
MEMBER_NAME as memberName
FROM
cu_member m
WHERE
m.pk_place_parent = 2
AND m.del_flag = 0
AND m.pk_country = 1
AND m.category = 0
AND m.pay_status =1
AND m.SYSTEM_TYPE =1
AND m.pk_id=#{pkVertex}
select
#{pkCountry} pkCountry,sum(mbp.REAL_INCOME) realIncome,
mbp.PK_COUNTRY con,
bbi.BONUS_VALUE bonusType,
#{pkVertex} pkVertex,
to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime
from cu_member_bonus_push mbp
INNER JOIN CU_MEMBER_BONUS cmb on mbp.PK_BONUS=cmb.pk_id
INNER join ( SELECT cm.pk_id FROM cu_member cm WHERE del_flag = 0 AND category = 0 START WITH PK_PARENT =#{pkVertex} CONNECT BY
pk_place_parent = PRIOR pk_id ) cm
on cm.pk_id = cmb.pk_member
inner join BD_BONUS_ITEMS bbi on bbi.pk_id=mbp.PK_BONUS_ITEMS
INNER JOIN sa_order so on so.pk_id=mbp.pk_order and so.PK_COUNTRY=#{pkCountry} and so.del_flag=0
where mbp.DEL_FLAG=0
and mbp.INCOME_STATUS=0
and bbi.BONUS_VALUE in (3,4,5,7,8,9,12,24,20,21,14,15,16,1)
and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
GROUP BY mbp.PK_COUNTRY,
bbi.BONUS_VALUE,
to_char(so.PAY_TIME, 'yyyy-mm-dd')
UNION ALL
select
#{pkCountry} pkCountry,sum(mbe.REAL_INCOME) realIncome,
mbe.PK_COUNTRY con,
bbi.BONUS_VALUE bonusType,
#{pkVertex} pkVertex,
to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime
from CU_MEMBER_BONUS_EXPAND mbe
INNER JOIN CU_MEMBER_BONUS cmb on mbe.PK_BONUS=cmb.pk_id
INNER join ( SELECT cm.pk_id FROM cu_member cm WHERE del_flag = 0 AND category = 0 START WITH PK_PARENT =#{pkVertex} CONNECT BY
pk_place_parent = PRIOR pk_id ) cm
on cm.pk_id = cmb.pk_member
inner join BD_BONUS_ITEMS bbi on bbi.pk_id=mbe.PK_BONUS_ITEMS
INNER JOIN sa_order so on so.pk_id=mbe.pk_order and so.PK_COUNTRY=#{pkCountry} and so.del_flag=0
where mbe.DEL_FLAG=0
and mbe.INCOME_STATUS=0
and bbi.BONUS_VALUE in (3,4,5,7,8,9,12,24,20,21,14,15,16,1)
and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
GROUP BY mbe.PK_COUNTRY,
bbi.BONUS_VALUE,
to_char(so.PAY_TIME, 'yyyy-mm-dd')
UNION ALL
select
#{pkCountry} pkCountry,sum(mbc.REAL_INCOME) realIncome,
mbc.PK_COUNTRY con,
bbi.BONUS_VALUE bonusType,
#{pkVertex} pkVertex,
to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime
from CU_MEMBER_BONUS_COACH mbc
INNER JOIN CU_MEMBER_BONUS cmb on mbc.PK_BONUS=cmb.pk_id
INNER join ( SELECT cm.pk_id FROM cu_member cm WHERE del_flag = 0 AND category = 0 START WITH PK_PARENT =#{pkVertex} CONNECT BY
pk_place_parent = PRIOR pk_id ) cm
on cm.pk_id = cmb.pk_member
inner join BD_BONUS_ITEMS bbi on bbi.pk_id=mbc.PK_BONUS_ITEMS
INNER JOIN sa_order so on so.pk_id=mbc.pk_order and so.PK_COUNTRY=#{pkCountry} and so.del_flag=0
where mbc.DEL_FLAG=0
and mbc.INCOME_STATUS=0
and bbi.BONUS_VALUE in (3,4,5,7,8,9,12,24,20,21,14,15,16,1)
and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
GROUP BY mbc.PK_COUNTRY,
bbi.BONUS_VALUE,
to_char(so.PAY_TIME, 'yyyy-mm-dd')
UNION ALL
select
#{pkCountry} pkCountry,sum(mbr.REAL_INCOME) realIncome,
mbr.PK_COUNTRY con,
bbi.BONUS_VALUE bonusType,
#{pkVertex} pkVertex,
to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime
from cu_member_bonus_range mbr
INNER JOIN CU_MEMBER_BONUS cmb on mbr.PK_BONUS=cmb.pk_id
INNER join ( SELECT cm.pk_id FROM cu_member cm WHERE del_flag = 0 AND category = 0 START WITH PK_PARENT =#{pkVertex} CONNECT BY
pk_place_parent = PRIOR pk_id ) cm
on cm.pk_id = cmb.pk_member
inner join BD_BONUS_ITEMS bbi on bbi.pk_id=mbr.PK_BONUS_ITEMS
INNER JOIN sa_order so on so.pk_id=mbr.pk_order and so.PK_COUNTRY=#{pkCountry} and so.del_flag=0
where mbr.DEL_FLAG=0
and mbr.INCOME_STATUS=0
and bbi.BONUS_VALUE in (3,4,5,7,8,9,12,24,20,21,14,15,16,1)
and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
GROUP BY bbi.BONUS_VALUE,
mbr.PK_COUNTRY,
to_char(so.PAY_TIME, 'yyyy-mm-dd')
UNION ALL
select
#{pkCountry} pkCountry,sum(mbd.REAL_INCOME) realIncome,
mbd.PK_COUNTRY con,
bbi.BONUS_VALUE bonusType,
#{pkVertex} pkVertex,
to_date(to_char(so.PAY_TIME, 'yyyy-mm-dd'),'yyyy-mm-dd') AS creationTime
from cu_member_bonus_detail mbd
INNER JOIN CU_MEMBER_BONUS cmb on mbd.PK_BONUS=cmb.pk_id
INNER join ( SELECT cm.pk_id FROM cu_member cm WHERE del_flag = 0 AND category = 0 START WITH PK_PARENT =#{pkVertex} CONNECT BY
pk_place_parent = PRIOR pk_id ) cm
on cm.pk_id = cmb.pk_member
inner join BD_BONUS_ITEMS bbi on bbi.pk_id=mbd.PK_BONUS_ITEMS
INNER JOIN sa_order so on so.pk_id=mbd.pk_order and so.PK_COUNTRY=#{pkCountry} and so.del_flag=0
where mbd.DEL_FLAG=0
and mbd.INCOME_STATUS=0
and bbi.BONUS_VALUE in (3,4,5,7,8,9,12,24,20,21,14,15,16,1)
and so.PAY_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
and so.PAY_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
GROUP BY bbi.BONUS_VALUE,
mbd.PK_COUNTRY,
to_char(so.PAY_TIME, 'yyyy-mm-dd')
select 1 pkCountry,
sum(cmb.CLOUD_REAL_SUBTOTAL) realIncome,
#{pkVertex} pkVertex,
to_date(to_char(cmsp.SETTLE_DATE, 'yyyy-mm-dd'), 'yyyy-mm-dd') AS creationTime
from CU_MEMBER_BONUS cmb
INNER join (SELECT pk_member
FROM ${settleTableName}
WHERE category = 0
start
with pk_member = #{pkVertex}
connect by PK_PARENT = prior pk_member) cm
on cm.pk_member = cmb.pk_member
INNER JOIN CU_MEMBER_SETTLE_PERIOD cmsp on cmsp.pk_id = cmb.PERIOD
where cmb.DEL_FLAG = 0
and cmb.PERIOD = #{period}
GROUP BY to_char(cmsp.SETTLE_DATE, 'yyyy-mm-dd')
SELECT *
FROM
CU_BONUS_VERTEX_STATIS a
WHERE
1=1
AND a.PK_BD_VERTEX = #{pkBdVertex}
AND a.PK_COUNTRY = #{pkCountry}
and to_char(a.CREATION_TIME, 'yyyy-mm-dd') = to_char(#{creationTime}, 'yyyy-mm-dd')