Browse Source

快手-代理商数据查询

yangzian 3 năm trước cách đây
mục cha
commit
2e1f30fe07

+ 2 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java

@@ -34,6 +34,8 @@ public interface ReportSettlementMapper {
     List<SettlementReportKuaiShouVo> getAccountTransactionDayKuaiShou(SettlementFileParamsVo paramsVo);
     //获取快手 账户 日流水信息  代理商维度
     List<SettlementReportKuaiShouVo> getAccountTransactionDayKuaiShouAgent(SettlementFileParamsVo paramsVo);
+    // 获取快手 结算单 账户 和 代理商 维度
+    List<SettlementReportKuaiShouVo> getTransactionDayKuaiShouAgentAndAccount(SettlementFileParamsVo paramsVo);
 
 
     /**

+ 96 - 23
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml

@@ -104,6 +104,72 @@
 
 
 
+    <!-- 获取快手 账户 日流水信息  代理商 和 账户 维度-->
+    <select id="getTransactionDayKuaiShouAgentAndAccount" resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
+        SELECT
+            *
+        FROM
+            (
+                SELECT
+                    t.*
+                FROM
+                    (
+                        SELECT
+                            date_time as date,
+                            account_id AS accountId,
+                            total_charged_in_yuan as dailyCharge,
+                            contract_rebate_real_charged_in_yuan as contractRebateRealCharged,
+                            direct_rebate_real_charged_in_yuan as directRebateRealCharged,
+                            ( real_charged_in_yuan + total_rebate_real_charged_in_yuan + credit_real_charged_in_yuan ) realCharged,
+                            account_name AS accountName,
+                            user_id AS ksId
+                        FROM
+                            ctop_kuaishou_daily_agent
+                        WHERE
+                            account_id = #{accountId}
+                    ) t
+                WHERE
+                    DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
+                ORDER BY
+                    t.date
+                    LIMIT 31
+            ) a
+                LEFT JOIN (
+                SELECT
+                    t.*,
+                    c.auth_name AS accountNameF,
+                    base.user_id AS ksIdF
+                FROM
+                    (
+                        SELECT
+                            account_id AS accountIdF,
+                            date,
+                            daily_transfer_in as dailyTransferIn,
+                            daily_transfer_out as dailyTransferOut,
+                            balance as balance,
+                            real_recharged as realRecharged,
+                            contract_rebate_real_recharged as contractRebateRealRecharged,
+                            direct_rebate_real_recharged as directRebateRealRecharged
+                        FROM
+                            ctop_kuaishou_daily_flows
+                        WHERE
+                            account_id = #{accountId}
+                    ) t
+                        LEFT JOIN ctop_user_allocation c ON t.accountIdF = c.account_id
+                        LEFT JOIN ctop_kuaishou_advertiser_base_info base ON base.account_id = t.accountIdF
+                WHERE
+                    DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
+                ORDER BY
+                    date
+                    LIMIT 31
+            ) b ON a.accountId = b.accountIdF
+                AND a.date = b.date
+            LIMIT 31
+
+    </select>
+
+
+
 
 
     <!-- 查询 头条利润表 所用账户-->
@@ -188,13 +254,13 @@
         <if test="productName !=null and productName != ''">
             AND pp.policy_product_name = #{productName}
         </if>
-        <if test="startTime !=null and startTime != ''">
+      <!--  <if test="startTime !=null and startTime != ''">
             AND  cp.policy_start_date &gt;= #{startTime}
         </if>
         <if test="endTime !=null and endTime != ''">
             AND cp.policy_end_date &lt;= #{endTime}
         </if>
-
+-->
     </select>
 
 
@@ -292,26 +358,30 @@
             d.account_id;-->
 
         SELECT
-        d.account_id,
+        d.account_id as accountId,
         d.user_id AS ksId,
         SUM(d.total_charged_in_yuan) AS cost,
         SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)) as cashCost,
         c.product_id as productId,
-        (SELECT p.product_name from ctop_product p where p.id = c.product_id) AS productName
+        (SELECT p.product_name from ctop_product p where p.id = c.product_id) AS productName,
+        (SELECT d.name as advertiserName from ctop_advertiser d where d.id = c.advertiser_id) advertiserName
         FROM
         ctop_kuaishou_daily_agent d
         RIGHT JOIN	ctop_cwjs_settlement_info c
         on d.account_id = c.account_id
         and c.kuai_shou_id = d.user_id
-        <if test="accountId !=null and accountId != ''">
-            AND d.account_id = #{accountId}
-        </if>
-        <if test="startTime !=null and startTime != ''">
-            AND d.date_time &gt;= #{startTime}
-        </if>
-        <if test="endTime !=null and endTime != ''">
-            AND d.date_time &lt;= #{endTime}
-        </if>
+        <where>
+            <if test="accountId !=null and accountId != ''">
+                AND d.account_id = #{accountId}
+            </if>
+            <if test="startTime !=null and startTime != ''">
+                AND d.date_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND d.date_time &lt;= #{endTime}
+            </if>
+        </where>
+
         GROUP BY d.account_id
     </select>
 
@@ -346,15 +416,18 @@
         SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)) as cashCost
         FROM
         ctop_kuaishou_daily_agent d
-        <if test="accountId !=null and accountId != ''">
-            AND d.account_id = #{accountId}
-        </if>
-        <if test="startTime !=null and startTime != ''">
-            AND d.date &gt;= #{startTime}
-        </if>
-        <if test="endTime !=null and endTime != ''">
-            AND d.date &lt;= #{endTime}
-        </if>
+        <where>
+            <if test="accountId !=null and accountId != ''">
+                AND d.account_id = #{accountId}
+            </if>
+            <if test="startTime !=null and startTime != ''">
+                AND d.date_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND d.date_time &lt;= #{endTime}
+            </if>
+        </where>
+
 
     </select>
 
@@ -393,7 +466,7 @@
         LEFT JOIN ctop_advertiser d on d.id = c.advertiser_id
         where c.del_flag = 0
             <if test="accountId !=null and accountId != ''">
-                AND u.account_id = #{accountId}
+                AND c.account_id = #{accountId}
             </if>
     </select>
 

+ 8 - 7
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java

@@ -293,14 +293,15 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 paramsVo.setAccountId(accountId);
 
                 //获取账户 日流水数据  根据账户id 和 年月 查询数据
-                List<SettlementReportKuaiShouVo> settlementList = new ArrayList<>();
+               /* List<SettlementReportKuaiShouVo> settlementList = new ArrayList<>();
                 //查询账户维度
                 settlementList = reportSettlementMapper.getAccountTransactionDayKuaiShou(paramsVo);
                 if (Check.isNull(settlementList)){
                     //查询代理商维度
                     settlementList = reportSettlementMapper.getAccountTransactionDayKuaiShouAgent(paramsVo);
                 }
-
+*/
+                List<SettlementReportKuaiShouVo> settlementList = reportSettlementMapper.getTransactionDayKuaiShouAgentAndAccount(paramsVo);
                 if (Check.isNull(settlementList)){
                     num++;
                     continue;
@@ -631,17 +632,17 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 */
                 ProfitReportKuaiShouVo voSource = new ProfitReportKuaiShouVo();
 
+                voSource.setAccountId(map.getOrDefault("accountId","")+"");//账户id
+                voSource.setProductName(map.getOrDefault("productName","")+"");//产品名称
+                voSource.setKsId(map.getOrDefault("ksId","")+"");//快手id
+                voSource.setAdvertiserName(map.getOrDefault("advertiserName","")+"");//广告主名称
+
                 //查询销售
                 Map<String,Object> slaeMap = reportSettlementMapper.getProfitBytedanceSale(map.get("accountId")+"");
                 voSource.setSaleName(Check.isNull(slaeMap) ? "" : slaeMap.getOrDefault("saleName","")+"");//销售
 
-                voSource.setAccountId(map.getOrDefault("accountId","")+"");//账户id
-                voSource.setProductName(map.getOrDefault("productName","")+"");//产品名称
-
                 Map<String,Object> operateMap = reportSettlementMapper.getProfitKuaiShouOperate(map.get("accountId")+"");
                 if (!Check.isNull(operateMap)){
-                    voSource.setKsId(map.getOrDefault("ksId","")+"");//快手id
-                    voSource.setAdvertiserName(operateMap.getOrDefault("advertiserName","")+"");//广告主名称
                     voSource.setOperateName(operateMap.getOrDefault("operateName","")+"");//运营
                     voSource.setOperateArea(operateMap.getOrDefault("operateArea","")+"");//运营所属区域
                 }