Authored by Zhang

Merge branch 'dev_0426_总成本报表需求' of http://git.yoho.cn/yoho30/yohobuy-union into dev_0426_总成本报表需求

package com.yoho.unions.channel.restapi;
import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.yoho.service.model.union.request.ChannelBlackListRequestBO;
import com.yoho.service.model.union.request.ChannelGroupRequestBO;
import com.yoho.service.model.union.request.MktReportFormReqVO;
import com.yoho.service.model.union.response.MktReportFormRspBO;
import com.yoho.service.model.union.response.PageBlackListRspBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
import com.yoho.service.model.union.response.PageMktReportFormRspBO;
import com.yoho.unions.channel.service.IChannelBlackListService;
import com.yoho.unions.channel.service.IMktCostReportFormService;
import com.yoho.unions.common.ApiResponse;
import com.yoho.unions.common.utils.PhoneUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
... ... @@ -47,7 +36,6 @@ public class MktCostReportFormController {
try {
// PageMktReportFormRspBO result = mktCostReportFormService.getMktReportForm(mktReportFormReqVO);
Gson result = new Gson();
MktReportFormRspBO mktReportFormRspBO = new MktReportFormRspBO();
List<String> dateIdStrList = Lists.newArrayList();
List<BigDecimal> totalActuralCostList = Lists.newArrayList();
... ... @@ -62,6 +50,15 @@ public class MktCostReportFormController {
List<Integer> totalNewUdidList = Lists.newArrayList();
List<Integer> iosNewUdidList = Lists.newArrayList();
List<Integer> androidNewUdidList = Lists.newArrayList();
List<BigDecimal> totalActiveRatio = Lists.newArrayList();
List<BigDecimal> iosActiveRatio = Lists.newArrayList();
List<BigDecimal> androidActiveRatio = Lists.newArrayList();
List<BigDecimal> totalExpoureRatio = Lists.newArrayList();
List<BigDecimal> iosExpoureRatio = Lists.newArrayList();
List<BigDecimal> androidExpoureRatio = Lists.newArrayList();
List<BigDecimal> totalNewUdidRatio = Lists.newArrayList();
List<BigDecimal> iosNewUdidRatio = Lists.newArrayList();
List<BigDecimal> androidNewUdidRatio = Lists.newArrayList();
for (Integer i = 6; i >=0; i--){
dateIdStrList.add("2017042" + i.toString());
... ... @@ -77,6 +74,16 @@ public class MktCostReportFormController {
totalNewUdidList.add(100 - i * 10);
iosNewUdidList.add(70 - i * 7);
androidNewUdidList.add(30 - i * 3);
totalActiveRatio.add(getDivideData(totalActuralCostList.get(i), new BigDecimal(totalActiveList.get(i))));
iosActiveRatio.add(getDivideData(iosActualCostList.get(i), new BigDecimal(iosActiveList.get(i))));
androidActiveRatio.add(getDivideData(androidActualCostList.get(i), new BigDecimal(androidActiveList.get(i))));
totalExpoureRatio.add(getDivideData(totalActuralCostList.get(i), new BigDecimal(totalExpoureNumList.get(i))));
iosExpoureRatio.add(getDivideData(iosActualCostList.get(i), new BigDecimal(iosExpoureNumList.get(i))));
androidExpoureRatio.add(getDivideData(androidActualCostList.get(i), new BigDecimal(androidExpoureNumList.get(i))));
totalNewUdidRatio.add(getDivideData(totalActuralCostList.get(i), new BigDecimal(totalNewUdidList.get(i))));
iosNewUdidRatio.add(getDivideData(iosActualCostList.get(i), new BigDecimal(iosNewUdidList.get(i))));
androidActiveRatio.add(getDivideData(androidActualCostList.get(i), new BigDecimal(androidNewUdidList.get(i))));
}
mktReportFormRspBO.setDateIdStrList(dateIdStrList);
... ... @@ -92,19 +99,24 @@ public class MktCostReportFormController {
mktReportFormRspBO.setTotalNewUserList(totalNewUdidList);
mktReportFormRspBO.setIosNewUserList(iosNewUdidList);
mktReportFormRspBO.setAndroidNewUserList(androidNewUdidList);
mktReportFormRspBO.setMaxActualCost(500);
mktReportFormRspBO.setMaxAppActive(400);
mktReportFormRspBO.setMaxExpoureNum(300);
mktReportFormRspBO.setMaxNewUdid(200);
mktReportFormRspBO.setTopActualCost(5000);
mktReportFormRspBO.setTopAppActive(1000);
mktReportFormRspBO.setTopExpoureNum(2000);
mktReportFormRspBO.setTopNewUdid(100);
result.toJson(mktReportFormRspBO);
return new ApiResponse.ApiResponseBuilder().code(200).data(result).message("success").build();
return new ApiResponse.ApiResponseBuilder().code(200).data(mktReportFormRspBO).message("success").build();
} catch (Exception e){
logger.warn("getMktReportForm occurs Exception e {}",e.getMessage());
return new ApiResponse.ApiResponseBuilder().code(500).message("失败").build();
}
}
private BigDecimal getDivideData(BigDecimal d1,BigDecimal d2){
if(d2.compareTo(new BigDecimal(0)) == 0){
return new BigDecimal(0);
}
return d1.divide(d2,2,BigDecimal.ROUND_HALF_UP);
}
}
... ...
... ... @@ -63,6 +63,7 @@
<value>/LoginController/loginForPid.do</value>
<value>/batch/export.do</value>
<value>/batch/import</value>
<value>/mktReportForm/getMktReportForm</value>
</list>
</property>
<property name="excludeMethods">
... ...
... ... @@ -48,51 +48,49 @@
</table>
<script type="text/javascript">
$(function(){
// $.ajax({
// type: "POST",
// url: contextPath + "/mktReportForm/followPriceOperate",
$.ajax({
type: "POST",
url: contextPath + "/mktReportForm/getMktReportForm",
// data: JSON.stringify(json),
// dataType: "json",
// contentType: "application/json; charset=utf-8",
// success: function(data){
// if (data.code == CODE_SUCCESS) {
//
// } else {
// window.self.$.messager.alert("失败", data.message, "error");
// }
// }
// });
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(data){
if (data.code == 200) {
debugger;
// 曝光量
var exposureOption = getEchartOption("市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],data.data.dateIdStrList,data.data.totalActualCostList,data.data.totalExpoureNumList,[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('exposure',exposureOption);
var exposureIosOption = getEchartOption("ios端市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],data.data.dateIdStrList,data.data.iosActualCostList,data.data.iosExpoureNumList,[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('exposure_ios',exposureIosOption);
// 曝光量
var exposureOption = getEchartOption("市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('exposure',exposureOption);
var exposureAndroidOption = getEchartOption("android市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],data.data.dateIdStrList,data.data.androidActualCost,[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('exposure_android',exposureAndroidOption);
var exposureIosOption = getEchartOption("ios端市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('exposure_ios',exposureIosOption);
// 激活
var activeOption = getEchartOption("市场费用/激活量",['实际费用','激活量','市场费用/激活量'],data.data.dateIdStrList,data.data.totalActualCostList,[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('active',activeOption);
var exposureAndroidOption = getEchartOption("android市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('exposure_android',exposureAndroidOption);
var activeIosOption = getEchartOption("ios端市场费用/激活量",['实际费用','激活量','市场费用/激活量'],data.data.dateIdStrList,data.data.iosActualCostList,[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('active_ios',activeIosOption);
// 激活
var activeOption = getEchartOption("市场费用/激活量",['实际费用','激活量','市场费用/激活量'],['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('active',activeOption);
var activeAndroidOption = getEchartOption("android端市场费用/激活量",['实际费用','激活量','市场费用/激活量'],data.data.dateIdStrList,data.data.androidActualCost,[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('active_android',activeAndroidOption);
var activeIosOption = getEchartOption("ios端市场费用/激活量",['实际费用','激活量','市场费用/激活量'],['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('active_ios',activeIosOption);
// 新客
var newuserOption = getEchartOption("市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],data.data.dateIdStrList,data.data.androidActualCost,data.data.totalActualCostList,[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('newuser',newuserOption);
var activeAndroidOption = getEchartOption("android端市场费用/激活量",['实际费用','激活量','市场费用/激活量'],['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('active_android',activeAndroidOption);
var newuserIosOption = getEchartOption("市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],data.data.dateIdStrList,data.data.iosActualCostList,[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('newuser_ios',newuserIosOption);
// 新客
var newuserOption = getEchartOption("市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('newuser',newuserOption);
var newuserIosOption = getEchartOption("市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('newuser_ios',newuserIosOption);
var newuserAndroidOption = getEchartOption("市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('newuser_android',newuserAndroidOption);
var newuserAndroidOption = getEchartOption("市场费用/曝光量",['实际费用','曝光量','市场费用/曝光量'],data.data.dateIdStrList,data.data.androidActualCost,[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]);
drawEchart('newuser_android',newuserAndroidOption);
} else {
window.self.$.messager.alert("失败", data.message, "error");
}
}
});
});
function drawEchart(ele, option){
... ...