| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.text.DecimalFormat;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | |
| | |
|
| | | @Override
|
| | | public UserActiveLog getUserLatestActiveInfo(Long uid) {
|
| | |
|
| | | return userActiveLogMapper.selectLatestByUid(uid);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<Object> countSameDayByChannel(String channel, Integer type, String years,
|
| | | public List<Map<String, Object>> countSameDayByChannel(String channel, Integer type, String years,
|
| | | String startTime, String endTime) throws Exception{
|
| | | List<Map<String, Object>> list = userActiveLogMapper.countSameDayByChannel(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;
|
| | | }
|
| | | return userActiveLogMapper.countSameDayByChannel(channel, type, years, startTime, endTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | @Override
|
| | | public List<Object> getBuyProportion(String channel, Integer type, String years,
|
| | | String startTime, String endTime, Integer orderNum) throws Exception{
|
| | | |
| | | // 统计渠道当日新增用户
|
| | | List<Object> countList = countSameDayByChannel(channel, type, years, startTime, endTime);
|
| | | |
| | | if (countList == null || countList.size() == 0) {
|
| | | return null;
|
| | | } |
| | | |
| | | // 统计渠道当日新增用户存在下单的用户数量
|
| | | List<Object> countListBuy= null;
|
| | | if (orderNum <= 1){
|
| | | countListBuy = countSameDayAndBuyGoodsByChannel(channel, type, years, startTime, endTime);
|
| | | } |
| | | |
| | | if (countListBuy == null){
|
| | | new ArrayList<Object>();
|
| | | }
|
| | | |
| | | 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("showDate");
|
| | | Object sameDayNum = map.get("showValue");
|
| | | |
| | | 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("showDate");
|
| | | if (createDate.toString().equals(createDate2.toString())) {
|
| | | Object buyNum = mapBuy.get("showValue");
|
| | | long totleBuy = Long.parseLong(buyNum.toString());
|
| | | rate = (float)totleBuy/totle;
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | DecimalFormat df = new DecimalFormat("0.00");//格式化小数
|
| | | mapObject.put("showValue", df.format(rate*100));
|
| | | mapObject.put("showDate", createDate);
|
| | | listObject.add(mapObject);
|
| | | }
|
| | | |
| | | return listObject;
|
| | | // |
| | | // // 统计渠道当日新增用户
|
| | | // List<Object> countList = countSameDayByChannel(channel, type, years, startTime, endTime);
|
| | | // |
| | | // if (countList == null || countList.size() == 0) {
|
| | | // return null;
|
| | | // } |
| | | // |
| | | // // 统计渠道当日新增用户存在下单的用户数量
|
| | | // List<Object> countListBuy= null;
|
| | | // if (orderNum <= 1){
|
| | | // countListBuy = countSameDayAndBuyGoodsByChannel(channel, type, years, startTime, endTime);
|
| | | // } |
| | | // |
| | | // if (countListBuy == null){
|
| | | // new ArrayList<Object>();
|
| | | // }
|
| | | // |
| | | // 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("showDate");
|
| | | // Object sameDayNum = map.get("showValue");
|
| | | // |
| | | // 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("showDate");
|
| | | // if (createDate.toString().equals(createDate2.toString())) {
|
| | | // Object buyNum = mapBuy.get("showValue");
|
| | | // long totleBuy = Long.parseLong(buyNum.toString());
|
| | | // rate = (float)totleBuy/totle;
|
| | | // break;
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | // |
| | | // DecimalFormat df = new DecimalFormat("0.00");//格式化小数
|
| | | // mapObject.put("showValue", df.format(rate*100));
|
| | | // mapObject.put("showDate", createDate);
|
| | | // listObject.add(mapObject);
|
| | | // }
|
| | | // |
| | | // return listObject;
|
| | | return null;
|
| | | }
|
| | |
|
| | |
|