浏览代码

快手-代理商数据

yangzian 3 年之前
父节点
当前提交
ff268239cd

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

@@ -86,8 +86,10 @@
 		DATE_FORMAT( date_time, '%Y-%m' ) AS uploadYears,
 		user_id AS ksId,
 		total_charged_in_yuan AS dailyCharge,
-		credit_real_charged_in_yuan AS realCharged,
-		account_name,
+		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) as realCharged,
+		account_name as accountName,
 		create_time
                 FROM
                     ctop_kuaishou_daily_agent
@@ -98,8 +100,6 @@
             t.uploadYears = #{uploadYears}
         ORDER BY
             t.date
-
-
     </select>
 
 
@@ -267,7 +267,7 @@
 
 <!-- 查询 快手 利润表 总花费-->
     <select id="getProfitKuaiShouAccountCost" resultType="java.util.LinkedHashMap">
-        SELECT
+        <!--SELECT
             d.account_id AS accountId,
             SUM( d.daily_charge ) AS cost,
             SUM( d.real_charged ) AS cashCost,
@@ -289,13 +289,36 @@
             AND d.date &lt;= #{endTime}
         </if>
         GROUP BY
-            d.account_id;
+            d.account_id;-->
+
+        SELECT
+        d.account_id,
+        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
+        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 &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            AND d.date &lt;= #{endTime}
+        </if>
+        GROUP BY d.account_id
     </select>
 
 
 <!-- 查询 快手 利润表 总花费-->
     <select id="getProfitKuaiShouCost" resultType="java.util.LinkedHashMap">
-        SELECT
+        <!--SELECT
         d.account_id AS accountId,
         SUM( d.daily_charge ) AS cost,
         SUM( d.real_charged ) AS cashCost,
@@ -315,14 +338,31 @@
         </if>
         <if test="endTime !=null and endTime != ''">
             AND d.date &lt;= #{endTime}
+        </if>-->
+        SELECT
+        d.account_id,
+        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
+        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>
+
     </select>
 
 
 
     <!-- 查询 快手 利润表  广告主和运营和运营所属区域-->
     <select id="getProfitKuaiShouOperate" resultType="java.util.LinkedHashMap">
-        select
+       <!-- select
         u.advertiser_id,
         u.account_id,
         b.user_id as ksId,
@@ -340,7 +380,21 @@
         <if test="accountId !=null and accountId != ''">
             AND u.account_id = #{accountId}
         </if>
-    </where>
+    </where>-->
+
+        SELECT
+        c.create_user_id AS operateUserId,
+        p.user_name AS operateName,
+        IFNULL( p.nick_name, '' ) AS operateArea,
+        d.NAME AS advertiserName
+        FROM
+        ctop_cwjs_settlement_file_info c
+        LEFT JOIN user_company p on c.create_user_id = p.user_id
+        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}
+            </if>
     </select>
 
 

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

@@ -278,7 +278,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             font.setFontHeightInPoints((short) 12);//设置字体大小
             style.setFont(font);
 
-            //查询 账户id
+            //查询 需要导出的数据的账户id
             List<String> accountIdList = reportSettlementMapper.getAccountIdBytedance(paramsVo);
 
             if (Check.isNull(accountIdList)){
@@ -617,7 +617,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-关
@@ -628,23 +628,19 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 if (Check.isNull(settlementAccountList)){
                     continue;
                 }
-
+*/
                 ProfitReportKuaiShouVo voSource = new ProfitReportKuaiShouVo();
 
                 //查询销售
                 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(operateMap.getOrDefault("ksId","")+"");//快手id
+                    voSource.setKsId(map.getOrDefault("ksId","")+"");//快手id
                     voSource.setAdvertiserName(operateMap.getOrDefault("advertiserName","")+"");//广告主名称
                     voSource.setOperateName(operateMap.getOrDefault("operateName","")+"");//运营
                     voSource.setOperateArea(operateMap.getOrDefault("operateArea","")+"");//运营所属区域
@@ -686,10 +682,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                         vo.setRebateType("");
                     }
 
-
-
-
-
                     vo.setRebateRate(policyRateMap.getOrDefault("rebateRate","")+"");//返点比列
                     // 时间段内 账户流水 信息
                     List<Map<String,Object>> listAccount = reportSettlementMapper.getProfitKuaiShouCost(map.get("accountId")+"",stringMap.get("startDate"),stringMap.get("endDate"));

+ 4 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementInfoServiceImpl.java

@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import io.lettuce.core.dynamic.annotation.Param;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
@@ -206,6 +207,9 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
                 }
 
                 for (AccountImportVo importVo : importResult.getList()) {
+                    if (Check.isNull(importVo.getAccountId())){
+                        continue;
+                    }
                     BeanUtils.copyProperties(importVo,settlementInfo);
                     //根据账户id 查看
                     CtopCwjsSettlementInfo cwjs = settlementInfoMapper.getSettlementByAccountId(importVo.getAccountId());