|
@@ -3,7 +3,9 @@ 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.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
|
+import org.jeecg.modules.bytedance.common.utils.Check;
|
|
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.entity.vo.ReportCostVo;
|
|
import org.jeecg.modules.bytedance.report.mapper.BytedanceReportMaterialDailyMapper;
|
|
import org.jeecg.modules.bytedance.report.mapper.BytedanceReportMaterialDailyMapper;
|
|
@@ -43,26 +45,36 @@ public class BytedanceReportMaterialDailyServiceImpl extends ServiceImpl<Bytedan
|
|
dailyReportMap.put("count",0);
|
|
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);
|
|
|
|
-
|
|
|
|
|
|
+ BigDecimal cost = new BigDecimal(Check.isNull(dailyReportMap.get("cost")) ? "0" : dailyReportMap.get("cost").toString());
|
|
|
|
+ BigDecimal click = new BigDecimal(Check.isNull(dailyReportMap.get("click")) ? "0" : dailyReportMap.get("click").toString());
|
|
|
|
+ BigDecimal showMaterial = new BigDecimal(Check.isNull(dailyReportMap.get("showMaterial")) ? "0" : dailyReportMap.get("showMaterial").toString());
|
|
|
|
+ BigDecimal convertMaterial = new BigDecimal(Check.isNull(dailyReportMap.get("convertMaterial")) ? "0" : dailyReportMap.get("convertMaterial").toString());
|
|
|
|
+
|
|
|
|
+ //被除数不能为0
|
|
|
|
+ if (StringUtils.equals("0",showMaterial.toString())){
|
|
|
|
+ dailyReportMap.put("costPerThousandShow", 0);
|
|
|
|
+ dailyReportMap.put("clickRate", 0);
|
|
|
|
+ }else {
|
|
|
|
+ BigDecimal costPerThousandShow = cost.multiply(new BigDecimal(1000)).divide(showMaterial, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ dailyReportMap.put("costPerThousandShow", costPerThousandShow);
|
|
|
|
+ BigDecimal clickRate = click.multiply(new BigDecimal(100)).divide(showMaterial, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ dailyReportMap.put("clickRate", clickRate);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.equals("0", convertMaterial.toString())) {
|
|
|
|
+ dailyReportMap.put("costConvert", 0);
|
|
|
|
+ }else {
|
|
|
|
+ BigDecimal costConvert = cost.divide(convertMaterial, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ dailyReportMap.put("costConvert", costConvert);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.equals("0", click.toString())) {
|
|
|
|
+ dailyReportMap.put("costPerClick", 0);
|
|
|
|
+ dailyReportMap.put("convertRate", 0);
|
|
|
|
+ }else {
|
|
|
|
+ BigDecimal costPerClick = cost.divide(click, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ dailyReportMap.put("costPerClick", costPerClick);
|
|
|
|
+ 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);
|
|
PageInfo<Map<String, Object>> pageInfo = new PageInfo<Map<String, Object>>(dailyReportList);
|