|
@@ -2,10 +2,14 @@ package cn.com.ctop.bytedance.service.impl;
|
|
|
|
|
|
import cn.com.ctop.bytedance.entity.BytedanceAdvertiserDailyReport;
|
|
import cn.com.ctop.bytedance.entity.BytedanceAdvertiserDailyReport;
|
|
import cn.com.ctop.bytedance.mapper.BytedanceAdvertiserDailyReportMapper;
|
|
import cn.com.ctop.bytedance.mapper.BytedanceAdvertiserDailyReportMapper;
|
|
|
|
+import cn.com.ctop.bytedance.mapper.BytedanceReportMapper;
|
|
import cn.com.ctop.bytedance.service.IBytedanceReportService;
|
|
import cn.com.ctop.bytedance.service.IBytedanceReportService;
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -22,25 +26,28 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
@Autowired
|
|
@Autowired
|
|
private BytedanceAdvertiserDailyReportMapper bytedanceAdvertiserDailyReportMapper;
|
|
private BytedanceAdvertiserDailyReportMapper bytedanceAdvertiserDailyReportMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private BytedanceReportMapper bytedanceReportMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private KuaishouReportDailyAccountMapper kuaishouReportDailyAccountMapper;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 获取 媒体昨日总消耗
|
|
|
|
|
|
+ * 媒体昨日总消耗
|
|
*
|
|
*
|
|
* @param loginId
|
|
* @param loginId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public JSONObject getCost(String loginId) {
|
|
|
|
-
|
|
|
|
|
|
+ public JSONObject getAccountReport(String loginId) {
|
|
JSONObject returnJson = new JSONObject();
|
|
JSONObject returnJson = new JSONObject();
|
|
-
|
|
|
|
-
|
|
|
|
QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
|
|
queryWrapper.eq("user_id", loginId);
|
|
queryWrapper.eq("user_id", loginId);
|
|
- queryWrapper.eq("media_id", 1);
|
|
|
|
queryWrapper.isNotNull("account_id");
|
|
queryWrapper.isNotNull("account_id");
|
|
queryWrapper.groupBy("account_id");
|
|
queryWrapper.groupBy("account_id");
|
|
List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
|
|
List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
|
|
if (!Check.isNull(userAllocations)) {
|
|
if (!Check.isNull(userAllocations)) {
|
|
|
|
+ // 头条相关
|
|
JSONObject bytedanceJson = new JSONObject();
|
|
JSONObject bytedanceJson = new JSONObject();
|
|
BigDecimal byteDanceCost = new BigDecimal(0);
|
|
BigDecimal byteDanceCost = new BigDecimal(0);
|
|
Long byteDanceClick = 0L;
|
|
Long byteDanceClick = 0L;
|
|
@@ -49,26 +56,105 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
Long byteDanceForm = 0L;
|
|
Long byteDanceForm = 0L;
|
|
Long byteDanceNextDayOpen = 0L;
|
|
Long byteDanceNextDayOpen = 0L;
|
|
Long byteDanceActive = 0L;
|
|
Long byteDanceActive = 0L;
|
|
|
|
+ JSONArray bytedanceDetail = new JSONArray();
|
|
|
|
+
|
|
|
|
+ // 快手相关
|
|
|
|
+ JSONArray kuaishouDetail = new JSONArray();
|
|
|
|
+ JSONObject kuaishouJson = new JSONObject();
|
|
|
|
+ BigDecimal kuaishouCost = new BigDecimal(0);
|
|
|
|
+
|
|
|
|
+ Long kuaishouClick = 0L;
|
|
|
|
+ Long kuaishouShow = 0L;
|
|
|
|
+ Long kuaishouConvert = 0L;
|
|
|
|
+ Long kuaishouForm = 0L;
|
|
|
|
+ Long kuaishouNextDayOpen = 0L;
|
|
|
|
+ Long kuaishouActive = 0L;
|
|
|
|
+
|
|
|
|
+
|
|
for (UserAllocation userAllocation : userAllocations) {
|
|
for (UserAllocation userAllocation : userAllocations) {
|
|
- QueryWrapper<BytedanceAdvertiserDailyReport> bytedanceAdvertiserDailyReportQueryWrapper = new QueryWrapper<>();
|
|
|
|
- bytedanceAdvertiserDailyReportQueryWrapper.eq("advertiser_id", userAllocation.getAccountId());
|
|
|
|
- // Map<String, Object> beforeDate = DateUtils.getBeforeDate();
|
|
|
|
- // bytedanceAdvertiserDailyReportQueryWrapper.between("stat_datetime", beforeDate.get("startDate"), beforeDate.get("endDate"));
|
|
|
|
- bytedanceAdvertiserDailyReportQueryWrapper.between("stat_datetime", "2019-07-01 00:00:00", "2019-07-01 23:59:59");
|
|
|
|
- bytedanceAdvertiserDailyReportQueryWrapper.orderByDesc("create_time");
|
|
|
|
- bytedanceAdvertiserDailyReportQueryWrapper.last("limit 1");
|
|
|
|
- BytedanceAdvertiserDailyReport bytedanceAdvertiserDailyReport = bytedanceAdvertiserDailyReportMapper.selectOne(bytedanceAdvertiserDailyReportQueryWrapper);
|
|
|
|
-
|
|
|
|
- if (!Check.isNull(bytedanceAdvertiserDailyReport)) {
|
|
|
|
- byteDanceCost = byteDanceCost.add(bytedanceAdvertiserDailyReport.getCost());
|
|
|
|
- byteDanceClick += bytedanceAdvertiserDailyReport.getClick();
|
|
|
|
- byteDanceShow += bytedanceAdvertiserDailyReport.getShowNum();
|
|
|
|
- byteDanceConvert += bytedanceAdvertiserDailyReport.getConvertNum();
|
|
|
|
- byteDanceForm += bytedanceAdvertiserDailyReport.getForm();
|
|
|
|
- byteDanceNextDayOpen += bytedanceAdvertiserDailyReport.getNextDayOpen();
|
|
|
|
- byteDanceActive += bytedanceAdvertiserDailyReport.getActive();
|
|
|
|
- }
|
|
|
|
|
|
+ if ("1".equals(userAllocation.getMediaId())) {
|
|
|
|
+ QueryWrapper<BytedanceAdvertiserDailyReport> bytedanceAdvertiserDailyReportQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ bytedanceAdvertiserDailyReportQueryWrapper.eq("advertiser_id", userAllocation.getAccountId());
|
|
|
|
+ // Map<String, Object> beforeDate = DateUtils.getBeforeDate();
|
|
|
|
+ // bytedanceAdvertiserDailyReportQueryWrapper.between("stat_datetime", beforeDate.get("startDate"), beforeDate.get("endDate"));
|
|
|
|
+ bytedanceAdvertiserDailyReportQueryWrapper.between("stat_datetime", "2019-07-01 00:00:00", "2019-07-01 23:59:59");
|
|
|
|
+ bytedanceAdvertiserDailyReportQueryWrapper.orderByDesc("create_time");
|
|
|
|
+ bytedanceAdvertiserDailyReportQueryWrapper.last("limit 1");
|
|
|
|
+ BytedanceAdvertiserDailyReport bytedanceAdvertiserDailyReport = bytedanceAdvertiserDailyReportMapper.selectOne(bytedanceAdvertiserDailyReportQueryWrapper);
|
|
|
|
+ if (!Check.isNull(bytedanceAdvertiserDailyReport)) {
|
|
|
|
+ JSONObject bytedanceDetailJson = new JSONObject();
|
|
|
|
+ BigDecimal cost = bytedanceAdvertiserDailyReport.getCost();
|
|
|
|
+ bytedanceDetailJson.put("cost", cost); // 账号总消耗
|
|
|
|
+ byteDanceCost = byteDanceCost.add(cost);
|
|
|
|
+ Long click = bytedanceAdvertiserDailyReport.getClick();
|
|
|
|
+ bytedanceDetailJson.put("click", click); // 账号总点击
|
|
|
|
+ byteDanceClick += click;
|
|
|
|
+ Long showNum = bytedanceAdvertiserDailyReport.getShowNum();
|
|
|
|
+ bytedanceDetailJson.put("show", showNum); // 账号总展示
|
|
|
|
+ byteDanceShow += showNum;
|
|
|
|
+ Long convertNum = bytedanceAdvertiserDailyReport.getConvertNum();
|
|
|
|
+ bytedanceDetailJson.put("convert", convertNum); // 账号总转化
|
|
|
|
+ byteDanceConvert += convertNum;
|
|
|
|
+ Long form = bytedanceAdvertiserDailyReport.getForm();
|
|
|
|
+ bytedanceDetailJson.put("form", form); // 账号总表单提交
|
|
|
|
+ byteDanceForm += form;
|
|
|
|
+ Long nextDayOpen = bytedanceAdvertiserDailyReport.getNextDayOpen();
|
|
|
|
+ bytedanceDetailJson.put("nextDayOpen", nextDayOpen); // 账号总次日留存
|
|
|
|
+ byteDanceNextDayOpen += nextDayOpen;
|
|
|
|
+ Long active = bytedanceAdvertiserDailyReport.getActive();
|
|
|
|
+ bytedanceDetailJson.put("active", active); // 账号总激活
|
|
|
|
+ byteDanceActive += active;
|
|
|
|
+ bytedanceDetailJson.put("accountId", userAllocation.getAccountId()); // 账号
|
|
|
|
+ bytedanceDetailJson.put("accountName", userAllocation.getAuthName()); // 账号 名称
|
|
|
|
+ bytedanceDetail.add(bytedanceDetailJson);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else if ("2".equals(userAllocation.getMediaId())) {
|
|
|
|
+ // 查询快手相关报表数据
|
|
|
|
+
|
|
|
|
+ QueryWrapper<KuaishouReportDailyAccount> kuaishouReportDailyAccountQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ kuaishouReportDailyAccountQueryWrapper.eq("account_id", userAllocation.getAccountId());
|
|
|
|
+ // Map<String, Object> beforeDate = DateUtils.getBeforeDate();
|
|
|
|
+ // kuaishouReportDailyAccountQueryWrapper.between("stat_datetime", beforeDate.get("startDate"), beforeDate.get("endDate"));
|
|
|
|
+ kuaishouReportDailyAccountQueryWrapper.between("stat_date", "2019-10-08 00:00:00", "2019-10-08 23:59:59");
|
|
|
|
+ kuaishouReportDailyAccountQueryWrapper.orderByDesc("create_time");
|
|
|
|
+ kuaishouReportDailyAccountQueryWrapper.last("limit 1");
|
|
|
|
+ KuaishouReportDailyAccount reportDailyAccount = kuaishouReportDailyAccountMapper.selectOne(kuaishouReportDailyAccountQueryWrapper);
|
|
|
|
+ if (!Check.isNull(reportDailyAccount)) {
|
|
|
|
+ JSONObject kuaishouDetailJson = new JSONObject();
|
|
|
|
+ kuaishouDetailJson.put("accountId", userAllocation.getAccountId());
|
|
|
|
+ kuaishouDetailJson.put("accountName", userAllocation.getAuthName());
|
|
|
|
+
|
|
|
|
+ BigDecimal cost = reportDailyAccount.getCharge();// 花费
|
|
|
|
+ kuaishouDetailJson.put("cost", cost);
|
|
|
|
+ kuaishouCost = kuaishouCost.add(cost);
|
|
|
|
+
|
|
|
|
+ Long click = reportDailyAccount.getAclick();
|
|
|
|
+ kuaishouDetailJson.put("click", click);
|
|
|
|
+ kuaishouClick += click;
|
|
|
|
+
|
|
|
|
+ Long show = reportDailyAccount.getShow();
|
|
|
|
+ kuaishouDetailJson.put("show", show);
|
|
|
|
+ kuaishouShow += show;
|
|
|
|
+
|
|
|
|
+ Long convert = reportDailyAccount.getBclick();
|
|
|
|
+ kuaishouDetailJson.put("convert", convert);
|
|
|
|
+ kuaishouConvert += convert;
|
|
|
|
+
|
|
|
|
+ Long form = reportDailyAccount.getSubmit();
|
|
|
|
+ kuaishouDetailJson.put("form", form);
|
|
|
|
+ kuaishouForm += form;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Long active = reportDailyAccount.getActivation();
|
|
|
|
+ kuaishouDetailJson.put("active", active);
|
|
|
|
+ kuaishouActive += active;
|
|
|
|
+
|
|
|
|
+ kuaishouDetail.add(kuaishouDetailJson);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
bytedanceJson.put("cost", byteDanceCost); // 总消耗
|
|
bytedanceJson.put("cost", byteDanceCost); // 总消耗
|
|
bytedanceJson.put("click", byteDanceClick); // 总点击
|
|
bytedanceJson.put("click", byteDanceClick); // 总点击
|
|
@@ -78,14 +164,25 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
bytedanceJson.put("nextDayOpen", byteDanceNextDayOpen); // 总次留数
|
|
bytedanceJson.put("nextDayOpen", byteDanceNextDayOpen); // 总次留数
|
|
bytedanceJson.put("active", byteDanceActive); // 总激活
|
|
bytedanceJson.put("active", byteDanceActive); // 总激活
|
|
|
|
|
|
-
|
|
|
|
returnJson.put("bytedance", bytedanceJson);
|
|
returnJson.put("bytedance", bytedanceJson);
|
|
|
|
+ returnJson.put("bytedanceDetail", bytedanceDetail);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ kuaishouJson.put("cost", kuaishouCost);
|
|
|
|
+ kuaishouJson.put("click", kuaishouClick);
|
|
|
|
+ kuaishouJson.put("show", kuaishouShow);
|
|
|
|
+ kuaishouJson.put("convert", kuaishouConvert);
|
|
|
|
+ kuaishouJson.put("form", kuaishouForm);
|
|
|
|
+ kuaishouJson.put("nextDayOpen", 0);
|
|
|
|
+ kuaishouJson.put("active", kuaishouActive);
|
|
|
|
+ returnJson.put("kuaishou", kuaishouJson);
|
|
|
|
+ returnJson.put("kuaishouDetail", kuaishouDetail);
|
|
System.err.println(returnJson);
|
|
System.err.println(returnJson);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
+ return returnJson;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|