|
@@ -1,12 +1,21 @@
|
|
package org.jeecg.modules.bytedance.report.service.impl;
|
|
package org.jeecg.modules.bytedance.report.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.modules.bytedance.report.entity.BytedanceReportMaterialDaily;
|
|
import org.jeecg.modules.bytedance.report.entity.BytedanceReportMaterialDaily;
|
|
|
|
+import org.jeecg.modules.bytedance.report.entity.vo.ReportCostVo;
|
|
import org.jeecg.modules.bytedance.report.mapper.BytedanceReportMaterialDailyMapper;
|
|
import org.jeecg.modules.bytedance.report.mapper.BytedanceReportMaterialDailyMapper;
|
|
import org.jeecg.modules.bytedance.report.service.IBytedanceReportMaterialDailyService;
|
|
import org.jeecg.modules.bytedance.report.service.IBytedanceReportMaterialDailyService;
|
|
import org.springframework.context.annotation.Primary;
|
|
import org.springframework.context.annotation.Primary;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 素材报表
|
|
* 素材报表
|
|
* @author jeecg-boot
|
|
* @author jeecg-boot
|
|
@@ -15,8 +24,49 @@ import org.springframework.stereotype.Service;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
@Primary
|
|
@Primary
|
|
-
|
|
|
|
public class BytedanceReportMaterialDailyServiceImpl extends ServiceImpl<BytedanceReportMaterialDailyMapper, BytedanceReportMaterialDaily> implements IBytedanceReportMaterialDailyService {
|
|
public class BytedanceReportMaterialDailyServiceImpl extends ServiceImpl<BytedanceReportMaterialDailyMapper, BytedanceReportMaterialDaily> implements IBytedanceReportMaterialDailyService {
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private BytedanceReportMaterialDailyMapper bytedanceReportMaterialDailyMapper;
|
|
|
|
+
|
|
|
|
+ public Result getMaterialDailyReportByAccountId(String accountId, String startTime, String endTime,Integer pageNum,Integer pageSize){
|
|
|
|
+ PageHelper.startPage(pageNum,pageSize);
|
|
|
|
+ List<Map<String, Object>> dailyReportList = bytedanceReportMaterialDailyMapper.selectMaterialDailyReportByAccountId(accountId, startTime, endTime);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (Map<String, Object> dailyReportMap: dailyReportList) {
|
|
|
|
+ if(dailyReportMap == null || dailyReportMap.isEmpty()){
|
|
|
|
+ return Result.error("头条视频日报数据为空。");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(dailyReportMap.get("count") == null){
|
|
|
|
+ dailyReportMap.put("count",0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BigDecimal cost = new BigDecimal(dailyReportMap.get("cost").toString());
|
|
|
|
+ BigDecimal click = new BigDecimal(dailyReportMap.get("click").toString());
|
|
|
|
+ BigDecimal showMaterial = new BigDecimal(dailyReportMap.get("showMaterial").toString());
|
|
|
|
+ BigDecimal convertMaterial = new BigDecimal(dailyReportMap.get("convertMaterial").toString());
|
|
|
|
+
|
|
|
|
+ BigDecimal costPerThousandShow = cost.multiply(new BigDecimal(1000)).divide(showMaterial, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ dailyReportMap.put("costPerThousandShow", costPerThousandShow);
|
|
|
|
+
|
|
|
|
+ BigDecimal costPerClick = cost.divide(click, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ dailyReportMap.put("costPerClick", costPerClick);
|
|
|
|
+
|
|
|
|
+ BigDecimal clickRate = click.multiply(new BigDecimal(100)).divide(showMaterial, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ dailyReportMap.put("clickRate", clickRate);
|
|
|
|
+
|
|
|
|
+ BigDecimal costConvert = cost.divide(convertMaterial, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ dailyReportMap.put("costConvert", costConvert);
|
|
|
|
+
|
|
|
|
+ BigDecimal convertRate = convertMaterial.multiply(new BigDecimal(100)).divide(click,2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ dailyReportMap.put("convertRate", convertRate);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ PageInfo<Map<String, Object>> pageInfo = new PageInfo<Map<String, Object>>(dailyReportList);
|
|
|
|
|
|
|
|
+ return Result.successMsg("数据加载成功。",dailyReportList);
|
|
|
|
+ }
|
|
}
|
|
}
|