Jelajahi Sumber

利润单-查全部账户

yangzian 4 tahun lalu
induk
melakukan
9324ef0d5e

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

@@ -199,6 +199,7 @@
         GROUP BY
             d.advertiser_id;
 -->
+<!--
 
         SELECT
         d.advertiser_id AS accountId,
@@ -214,19 +215,38 @@
         WHERE
         d.advertiser_id = c.account_id
         AND c.product_id = p.id
-        <if test="accountId !=null and accountId != ''">
-            AND d.advertiser_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>
+
+-->
+
+        SELECT
+        d.advertiser_id as accountId,
+        SUM( d.cost ) AS cost,
+        SUM( d.cash_cost ) AS cashCost,
+        SUM( d.reward_cost ) rewardCost,
+        IFNULL((SELECT a.name from ctop_user_allocation u,ctop_advertiser a where d.advertiser_id = u.account_id and u.advertiser_id = a.id),(SELECT a.name
+        from ctop_cwjs_settlement_info c ,ctop_advertiser a where c.account_id = d.advertiser_id and c.advertiser_id = a.id)) as advertiserName,
+        IFNULL((SELECT
+        p.product_name
+        FROM ctop_user_allocation u,ctop_project pj,ctop_product p where d.advertiser_id = u.account_id and u.project_id = pj.id and pj.product_id = p.id
+        ),(SELECT p.product_name
+        FROM ctop_cwjs_settlement_info c,ctop_product p where d.advertiser_id = c.account_id and c.product_id = p.id)) productName
+        FROM
+        ctop_account_transaction_day d
+<where>
+    <if test="accountId !=null and accountId != ''">
+        AND d.advertiser_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>
         GROUP BY
         d.advertiser_id;
 
-    </select>
+</select>
 
 
     <!-- 查询 头条利润表 总花费-->
@@ -452,7 +472,7 @@
         GROUP BY
             d.account_id;-->
 
-        SELECT
+     <!--   SELECT
         d.account_id as accountId,
         d.user_id AS ksId,
         SUM(d.total_charged_in_yuan) AS cost,
@@ -477,7 +497,35 @@
             </if>
         </where>
 
+        GROUP BY d.account_id-->
+
+        SELECT
+        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,
+        IFNULL((SELECT a.name from ctop_user_allocation u,ctop_advertiser a where d.account_id = u.account_id and u.advertiser_id = a.id),(SELECT a.name
+        from ctop_cwjs_settlement_info c ,ctop_advertiser a where c.account_id = d.account_id and c.advertiser_id = a.id)) as advertiserName,
+        IFNULL((SELECT
+        p.product_name
+        FROM ctop_user_allocation u,ctop_project pj,ctop_product p where d.account_id = u.account_id and u.project_id = pj.id and pj.product_id = p.id
+        ),(SELECT p.product_name
+        FROM ctop_cwjs_settlement_info c,ctop_product p where d.account_id = c.account_id and c.product_id = p.id)) productName
+        FROM
+        ctop_kuaishou_daily_agent d
+        <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>
 
 

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

@@ -619,7 +619,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             }
             List<ProfitReportKuaiShouVo> resultList = new ArrayList<>(list.size());
             for (Map<String, Object> map : list) {
-              /*  //查看该账户 状态信息
+                //查看该账户 状态信息
                 QueryWrapper<CtopCwjsSettlementInfo> settlementAccountQw = new QueryWrapper<>();
                 settlementAccountQw.eq("account_id",map.get("accountId"));
                 //账户状态 0-开 1-关
@@ -630,7 +630,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 if (Check.isNull(settlementAccountList)){
                     continue;
                 }
-*/
                 ProfitReportKuaiShouVo voSource = new ProfitReportKuaiShouVo();
 
                 voSource.setAccountId(map.getOrDefault("accountId","")+"");//账户id