|
|
@@ -283,4 +283,61 @@
|
|
|
</foreach>
|
|
|
</insert>
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <insert id="runCPSIapSettlementData">
|
|
|
+ replace into deepthink.distribution_iap_settlement
|
|
|
+ (stat_date, link_id, app_id, person_id, person_pid, company_id,
|
|
|
+ all_pay_amount, all_refund_amount, all_settlement_amount,
|
|
|
+ virtual_pay_amount, virtual_commission_amount, virtual_refund_amount, virtual_settlement_amount,
|
|
|
+ un_virtual_pay_amount, un_virtual_commission_amount, un_virtual_refund_amount, un_virtual_settlement_amount
|
|
|
+ )
|
|
|
+
|
|
|
+ select #{dateLong} as stat_date,
|
|
|
+ ifnull(t1.link_id, 0) as link_id,
|
|
|
+ ifnull(t2.person_id, 0) as person_id,
|
|
|
+ ifnull(t2.person_pid, 0) as person_pid,
|
|
|
+ ifnull(t2.company_id, 0) as company_id,
|
|
|
+ ifnull(t2.app_id, '') as app_id,
|
|
|
+ ifnull(all_pay_amount, 0) as all_pay_amount,
|
|
|
+ ifnull(refund_amount, 0) as refund_amount
|
|
|
+ from (
|
|
|
+ select consume_date stat_date,link_id
|
|
|
+ from thirtpart.ly_pay_record p
|
|
|
+ where consume_date=#{dateLong} and status=1
|
|
|
+ group by 1,2
|
|
|
+
|
|
|
+ union
|
|
|
+
|
|
|
+ select date_format(refund_time,'%Y%m%d') stat_date,link_id
|
|
|
+ from thirtpart.ly_refund_record lrr
|
|
|
+ where refund_time >= concat(#{dateStr}, ' 00:00:00') and refund_time <= concat(#{dateStr}, ' 23:59:59')
|
|
|
+ and status = 1
|
|
|
+ group by 1,2
|
|
|
+ )t1
|
|
|
+ join (
|
|
|
+ select l.id link_id,l.responsibility_person_id person_id,p.pid person_pid,p.company_id,la.app_id
|
|
|
+ from thirtpart.ly_link l
|
|
|
+ join thirtpart.ly_responsibility_person p on l.responsibility_person_id = p.id
|
|
|
+ left join thirtpart.ly_official_accounts a on l.official_account_id = a.id
|
|
|
+ left join thirtpart.ly_applet la on a.applet_id = la.id
|
|
|
+ where p.is_distributor = 1
|
|
|
+ )t2 on t1.link_id = t2.link_id
|
|
|
+ left join
|
|
|
+ (
|
|
|
+ select consume_date,link_id,ifnull(sum(total_fee), 0) all_pay_amount
|
|
|
+ from thirtpart.ly_pay_record p
|
|
|
+ where consume_date=#{dateLong} and status=1
|
|
|
+ group by 1,2
|
|
|
+ )t3 on t1.stat_date = t3.consume_date and t1.link_id = t3.link_id
|
|
|
+ left join
|
|
|
+ (
|
|
|
+ select date_format(refund_time,'%Y%m%d') refund_date,link_id,ifnull(sum(refund_price), 0) refund_amount
|
|
|
+ from thirtpart.ly_refund_record r
|
|
|
+ where refund_time >= concat(#{dateStr}, ' 00:00:00') and refund_time <= concat(#{dateStr}, ' 23:59:59')
|
|
|
+ and status = 1
|
|
|
+ group by 1,2
|
|
|
+ )t4 on t1.stat_date = t4.refund_date and t1.link_id = t4.link_id
|
|
|
+ </insert>
|
|
|
</mapper>
|