zhaotx 1 rok temu
rodzic
commit
f461a8a295

+ 3 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/CPSReportMapper.java

@@ -16,4 +16,7 @@ public interface CPSReportMapper {
     boolean cleanCPSIaaDailyReportsDS(@Param("list") List<JSONObject> list);
 
 
+    int runCPSIapSettlementData(@Param("dateStr") String dateStr, @Param("dateLong") String dateLong);
+
+
 }

+ 57 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/CPSReportMapper.xml

@@ -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 &gt;= concat(#{dateStr}, ' 00:00:00') and refund_time &lt;= 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 &gt;= concat(#{dateStr}, ' 00:00:00') and refund_time &lt;= 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>

+ 3 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/ICPSReportService.java

@@ -3,4 +3,7 @@ package cn.com.ctop.job.bytedance.data.service;
 public interface ICPSReportService {
 
     void cleanCPSDailyReports(String nowDate);
+
+
+    void runCPSIapSettlementData(String nowDate);
 }

+ 12 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/CPSReportServiceImpl.java

@@ -23,4 +23,16 @@ public class CPSReportServiceImpl implements ICPSReportService {
             log.error("CPS数据清洗异常");
         }
     }
+
+    @Override
+    public void runCPSIapSettlementData(String nowDate) {
+        try {
+            String dateLong = nowDate.replaceAll("-", "");
+            int count = cpsReportMapper.runCPSIapSettlementData(nowDate, dateLong);
+            log.info("CPSIAP结算数据处理完成,影响行数:{}", count);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("CPSIAP结算数据处理异常");
+        }
+    }
 }

+ 14 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/CPSReportJob.java

@@ -51,4 +51,18 @@ public class CPSReportJob {
         }
     }
 
+
+    @XxlJob("runCPSIapSettlementData")
+    public void runCPSIapSettlementData() throws Exception {
+        log.info("[runCPSIapSettlementData] 任务启动...");
+        try {
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            cpsReportService.runCPSIapSettlementData(nowDate);
+            log.info("[runCPSIapSettlementData] 任务完成");
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+    }
+
 }