yumeng 4 年 前
コミット
0af6880ace

+ 8 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -52,6 +52,7 @@ import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.ExecutorService;
@@ -325,7 +326,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             log.info("快手广告主报表信息为空=》accountId:{}", token.getAccountId());
             return;
         }
-
         List<KuaishouReportDailyAccount> addList = new ArrayList<>();
         for (int i = 0; i < details.size(); i++) {
             JSONObject detailJson = details.getJSONObject(i);
@@ -336,11 +336,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 detailJson.put("photo_show", detailJson.getString("show"));
                 KuaishouReportDailyAccount KuaishouReportDailyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportDailyAccount.class);
                 KuaishouReportDailyAccount.setAccountId(token.getAccountId());
-                //      dailyAccountMapper.insertSelective(KuaishouReportDailyAccount);
+                if (Check.isNull(reportDims)) {
+                    BigDecimal totalCharge = KuaishouReportDailyAccount.getCharge();
+                    BigDecimal sumCharge = dailyAccountMapper.getSumChargeByAccountIdAndStatDate(KuaishouReportDailyAccount.getAccountId(), KuaishouReportDailyAccount.getStatDate());
+                    BigDecimal lianMengCharge = BigDecimalUtil.subtractBigDecimal(totalCharge, sumCharge);
+                    KuaishouReportDailyAccount.setCharge(lianMengCharge);
+                    KuaishouReportDailyAccount.setAdScene("广告联盟");
+                }
                 addList.add(KuaishouReportDailyAccount);
             }
         }
-
         dailyAccountMapper.replaceBatch(addList);
         getAccountDailyReportByPage(token, startDate, endDate, page + 1, reportDims);
     }

+ 3 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java

@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouReportDailyAccount> {
@@ -53,4 +54,6 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
     void replaceBatch(@Param("addList") List<KuaishouReportDailyAccount> addList);
 
     List<EtlKuaishouReportAccountDaily> queryEveryDayDataForAccount();
+
+    BigDecimal getSumChargeByAccountIdAndStatDate(@Param("accountId") Long accountId,@Param("statDate") String statDate);
 }

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml

@@ -1368,5 +1368,10 @@
     WHERE stat_date = DATE_FORMAT(date_sub(now(), interval 1 day), '%Y-%m-%d')
     GROUP BY account_id
     </select>
+    <select id="getSumChargeByAccountIdAndStatDate" resultType="java.math.BigDecimal">
+        select  sum(charge)  from  ctop_kuaishou_report_daily_account
+        where account_id = #{accountId}
+        and stat_date = #{statDate}
+    </select>
 
 </mapper>