| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.text.DecimalFormat;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Object> countSameDayAndBuyGoodsByChannel(String channel, Integer type, String years,
|
| | | String startTime, String endTime) throws Exception {
|
| | | List<Map<String, Object>> list = userActiveLogMapper.countSameDayAndBuyGoodsByChannel(channel, type, years, |
| | | startTime, endTime);
|
| | | |
| | | if (list == null || list.size() == 0) {
|
| | | return null;
|
| | | } |
| | | |
| | | switch (type){
|
| | | case 1: // 按天处理
|
| | | return dayFactory(startTime, endTime, list);
|
| | | case 2: // 按月处理
|
| | | return monthFactory(list);
|
| | | case 3: |
| | | return yearFactory(list);
|
| | | default: |
| | | return null;
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<Object> getBuyProportion(String channel, Integer type, String years,
|
| | | String startTime, String endTime) throws Exception{
|
| | | |
| | | List<Object> countList = countSameDayByChannel(channel, type, years, startTime, endTime);
|
| | | |
| | | if (countList == null || countList.size() == 0) {
|
| | | return null;
|
| | | } |
| | | |
| | | List<Object> countListBuy= countSameDayAndBuyGoodsByChannel(channel, type, years, startTime, endTime);
|
| | | |
| | | List<Object> listObject = new ArrayList<Object>();
|
| | | |
| | | for (Object object: countList) {
|
| | | |
| | | float rate = 0;
|
| | | |
| | | Map<String, Object> mapObject = new HashMap<String, Object>();
|
| | | |
| | | Map<String, Object> map = (Map<String, Object>) object;
|
| | | Object createDate = map.get("createDate");
|
| | | Object sameDayNum = map.get("sameDayNum");
|
| | | |
| | | long totle = Long.parseLong(sameDayNum.toString());
|
| | | if (totle > 0 && countListBuy != null && countListBuy.size() > 0) {
|
| | | for (int j = 0; j < countListBuy.size(); j++) {
|
| | | Map<String, Object> mapBuy = (Map<String, Object>) countListBuy.get(j);
|
| | | Object createDate2 = mapBuy.get("createDate");
|
| | | if (createDate.toString().equals(createDate2.toString())) {
|
| | | Object buyNum = mapBuy.get("sameDayNum");
|
| | | long totleBuy = Long.parseLong(buyNum.toString());
|
| | | rate = (float)totleBuy/totle;
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | DecimalFormat df = new DecimalFormat("0.00");//格式化小数
|
| | | mapObject.put("sameDayNum", df.format(rate*100));
|
| | | mapObject.put("createDate", createDate);
|
| | | listObject.add(mapObject);
|
| | | }
|
| | | |
| | | return listObject;
|
| | | }
|
| | |
|
| | | |
| | | |
| | | public List<Object> dayFactory(String startTime, String endTime, List<Map<String, Object>> list) throws Exception {
|
| | |
|
| | | List<Object> listObject = new ArrayList<Object>();
|
| | |
| | |
|
| | | return listObject;
|
| | | }
|
| | | |
| | | }
|