|
@@ -16,6 +16,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -39,47 +40,47 @@ public class ByteDanceGeneralCopywriterServiceImpl extends ServiceImpl<ByteDance
|
|
|
return Result.successMsg("还没有此文案报表数据,请将此文案投放跑量!",generalCopywriteReportList);
|
|
|
}
|
|
|
|
|
|
- for (Map<String, Object> videoSlogenReportMap: generalCopywriteReportList) {
|
|
|
+ for (Map<String, Object> generalCopywriteReportMap: generalCopywriteReportList) {
|
|
|
|
|
|
- if(videoSlogenReportMap.get("count") == null){
|
|
|
- videoSlogenReportMap.put("count",0);
|
|
|
+ if(generalCopywriteReportMap.get("count") == null){
|
|
|
+ generalCopywriteReportMap.put("count",0);
|
|
|
}
|
|
|
|
|
|
- BigDecimal cost = new BigDecimal(Check.isNull(videoSlogenReportMap.get("cost")) ? "0" : videoSlogenReportMap.get("cost").toString());
|
|
|
- BigDecimal click = new BigDecimal(Check.isNull(videoSlogenReportMap.get("click")) ? "0" : videoSlogenReportMap.get("click").toString());
|
|
|
- BigDecimal showNum = new BigDecimal(Check.isNull(videoSlogenReportMap.get("showNum")) ? "0" : videoSlogenReportMap.get("showNum").toString());
|
|
|
- BigDecimal convertNum = new BigDecimal(Check.isNull(videoSlogenReportMap.get("convertNum")) ? "0" : videoSlogenReportMap.get("convertNum").toString());
|
|
|
+ BigDecimal cost = new BigDecimal(Check.isNull(generalCopywriteReportMap.get("cost")) ? "0" : generalCopywriteReportMap.get("cost").toString());
|
|
|
+ BigDecimal click = new BigDecimal(Check.isNull(generalCopywriteReportMap.get("click")) ? "0" : generalCopywriteReportMap.get("click").toString());
|
|
|
+ BigDecimal showNum = new BigDecimal(Check.isNull(generalCopywriteReportMap.get("showNum")) ? "0" : generalCopywriteReportMap.get("showNum").toString());
|
|
|
+ BigDecimal convertNum = new BigDecimal(Check.isNull(generalCopywriteReportMap.get("convertNum")) ? "0" : generalCopywriteReportMap.get("convertNum").toString());
|
|
|
|
|
|
-
|
|
|
- videoSlogenReportMap.put("cost", cost);
|
|
|
- videoSlogenReportMap.put("click", click);
|
|
|
- videoSlogenReportMap.put("showNum", showNum);
|
|
|
- videoSlogenReportMap.put("convertNum", convertNum);
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0.00#");
|
|
|
+ generalCopywriteReportMap.put("cost", decimalFormat.format(cost));
|
|
|
+ generalCopywriteReportMap.put("click", click);
|
|
|
+ generalCopywriteReportMap.put("showNum", showNum);
|
|
|
+ generalCopywriteReportMap.put("convertNum", convertNum);
|
|
|
|
|
|
//被除数不能为0
|
|
|
if (StringUtils.equals("0",showNum.toString())){
|
|
|
- videoSlogenReportMap.put("costPerThousandShow", 0);
|
|
|
- videoSlogenReportMap.put("clickRate", 0);
|
|
|
+ generalCopywriteReportMap.put("costPerThousandShow", 0);
|
|
|
+ generalCopywriteReportMap.put("clickRate", 0);
|
|
|
}else {
|
|
|
BigDecimal costPerThousandShow = cost.multiply(new BigDecimal(1000)).divide(showNum, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- videoSlogenReportMap.put("costPerThousandShow", costPerThousandShow);
|
|
|
+ generalCopywriteReportMap.put("costPerThousandShow", decimalFormat.format(costPerThousandShow));
|
|
|
BigDecimal clickRate = click.multiply(new BigDecimal(100)).divide(showNum, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- videoSlogenReportMap.put("clickRate", clickRate);
|
|
|
+ generalCopywriteReportMap.put("clickRate", decimalFormat.format(clickRate));
|
|
|
}
|
|
|
if (StringUtils.equals("0", convertNum.toString())) {
|
|
|
- videoSlogenReportMap.put("costConvert", 0);
|
|
|
+ generalCopywriteReportMap.put("costConvert", 0);
|
|
|
}else {
|
|
|
BigDecimal costConvert = cost.divide(convertNum, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- videoSlogenReportMap.put("costConvert", costConvert);
|
|
|
+ generalCopywriteReportMap.put("costConvert", decimalFormat.format(costConvert));
|
|
|
}
|
|
|
if (StringUtils.equals("0", click.toString())) {
|
|
|
- videoSlogenReportMap.put("costPerClick", 0);
|
|
|
- videoSlogenReportMap.put("convertRate", 0);
|
|
|
+ generalCopywriteReportMap.put("costPerClick", 0);
|
|
|
+ generalCopywriteReportMap.put("convertRate", 0);
|
|
|
}else {
|
|
|
BigDecimal costPerClick = cost.divide(click, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- videoSlogenReportMap.put("costPerClick", costPerClick);
|
|
|
+ generalCopywriteReportMap.put("costPerClick", decimalFormat.format(costPerClick));
|
|
|
BigDecimal convertRate = convertNum.multiply(new BigDecimal(100)).divide(click,2,BigDecimal.ROUND_HALF_UP);
|
|
|
- videoSlogenReportMap.put("convertRate", convertRate);
|
|
|
+ generalCopywriteReportMap.put("convertRate", decimalFormat.format(convertRate));
|
|
|
}
|
|
|
}
|
|
|
|