|
@@ -0,0 +1,92 @@
|
|
|
|
+package cn.com.ctop.bytedance.service.impl;
|
|
|
|
+
|
|
|
|
+import cn.com.ctop.bytedance.entity.BytedanceAdvertiserDailyReport;
|
|
|
|
+import cn.com.ctop.bytedance.mapper.BytedanceAdvertiserDailyReportMapper;
|
|
|
|
+import cn.com.ctop.bytedance.service.IBytedanceReportService;
|
|
|
|
+import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
|
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserAllocationMapper userAllocationMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private BytedanceAdvertiserDailyReportMapper bytedanceAdvertiserDailyReportMapper;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取 媒体昨日总消耗
|
|
|
|
+ *
|
|
|
|
+ * @param loginId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public JSONObject getCost(String loginId) {
|
|
|
|
+
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("user_id", loginId);
|
|
|
|
+ queryWrapper.eq("media_id", 1);
|
|
|
|
+ queryWrapper.isNotNull("account_id");
|
|
|
|
+ queryWrapper.groupBy("account_id");
|
|
|
|
+ List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
|
|
|
|
+ if (!Check.isNull(userAllocations)) {
|
|
|
|
+ JSONObject bytedanceJson = new JSONObject();
|
|
|
|
+ BigDecimal byteDanceCost = new BigDecimal(0);
|
|
|
|
+ Long byteDanceClick = 0L;
|
|
|
|
+ Long byteDanceShow = 0L;
|
|
|
|
+ Long byteDanceConvert = 0L;
|
|
|
|
+ Long byteDanceForm = 0L;
|
|
|
|
+ Long byteDanceNextDayOpen = 0L;
|
|
|
|
+ Long byteDanceActive = 0L;
|
|
|
|
+ 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();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ bytedanceJson.put("cost", byteDanceCost); // 总消耗
|
|
|
|
+ bytedanceJson.put("click", byteDanceClick); // 总点击
|
|
|
|
+ bytedanceJson.put("show", byteDanceShow); // 总展示
|
|
|
|
+ bytedanceJson.put("convert", byteDanceConvert); // 总转化
|
|
|
|
+ bytedanceJson.put("form", byteDanceForm); // 总表单提交
|
|
|
|
+ bytedanceJson.put("nextDayOpen", byteDanceNextDayOpen); // 总次留数
|
|
|
|
+ bytedanceJson.put("active", byteDanceActive); // 总激活
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ returnJson.put("bytedance", bytedanceJson);
|
|
|
|
+ System.err.println(returnJson);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|