| | |
| | | import java.io.InputStream;
|
| | | import java.io.PrintWriter;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | |
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
| | |
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.admin.UserInfoAdmin;
|
| | | import com.yeshi.fanli.entity.bus.user.AccountDetails;
|
| | | import com.yeshi.fanli.entity.bus.user.Extract;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.ExtractService;
|
| | | import com.yeshi.fanli.service.inter.user.MoneyRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.ScanHistoryService;
|
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | import com.yeshi.fanli.util.HongBaoUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/user")
|
| | |
| | |
|
| | | @Resource
|
| | | private UserInfoCountService userInfoCountService;
|
| | | |
| | | @Resource
|
| | | private UserActiveLogService userActiveLogService;
|
| | |
|
| | |
|
| | | @RequestMapping(value = "getUserList", method = RequestMethod.POST)
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public static void main(String[] args) {
|
| | | java.lang.System.out.println(java.lang.System.currentTimeMillis());
|
| | | /**
|
| | | * 根据渠道 统计当日新增用户数量
|
| | | * @param channelArray 名字数组
|
| | | * @param dateType 类型 1日 2月 3年
|
| | | * @param year 2018
|
| | | * @param startTime 2018-12-01 |
| | | * @param endTime 2018-12-01 |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getSameDayUserByChannel")
|
| | | public void getSameDayUserByChannel(String callback, String channelArray, Integer dateType, |
| | | String year, String startTime, String endTime, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(channelArray)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择统计对应名称"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (dateType == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择排列方式"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (dateType == 1 && (StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime))) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择时间区间"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选结束日期"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (StringUtil.isNullOrEmpty(startTime) && !StringUtil.isNullOrEmpty(endTime)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选起始日期"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
|
| | | startTime = null;
|
| | | endTime = null;
|
| | | }
|
| | | |
| | | try {
|
| | |
|
| | | Gson gson = new Gson();
|
| | | List<String> list = gson.fromJson(channelArray, new TypeToken<ArrayList<String>>() {}.getType());
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数格式不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | | JSONArray array = new JSONArray();
|
| | |
|
| | | for (String channel: list) {
|
| | | JSONObject channelData = new JSONObject();
|
| | | List<Object> resultList = userActiveLogService.countSameDayByChannel(channel, dateType, year, startTime, endTime);
|
| | | if (resultList == null) {
|
| | | resultList = new ArrayList<Object>();
|
| | | }
|
| | | channelData.put("name", channel);
|
| | | channelData.put("infos", resultList);
|
| | | array.add(channelData);
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("result_list", array);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | | |
| | | |
| | | } |
| | | }
|
| | |
| | | page = 1;
|
| | | }
|
| | |
|
| | | if (state !=null && state == 0) {
|
| | | state = null;
|
| | | if (state != null && state == 0) {
|
| | | state = null;// 所有状态
|
| | | }
|
| | |
|
| | | if (type != null && type == 0 ) {
|
| | | type = null; // 查询所有类型订单
|
| | | type = null; // 所有类型订单
|
| | | }
|
| | |
|
| | | try {
|
| | | if (slotTime != null) {
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
| | | startTime = sd.format(new Date());
|
| | | endTime = convertDate(slotTime, startTime);
|
| | | endTime= sd.format(new Date());
|
| | | startTime = convertDate(slotTime, endTime);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | long count = 0;
|
| | |
| | | data.put("helpUrl", helpUrl);
|
| | |
|
| | | if (type != null && type == 1) {
|
| | | data.put("todayMoney", "今日预估返利总额 ¥" + todayMoney);
|
| | | data.put("todayMoney", "今日预估返利总额 ¥" + todayMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | } else {
|
| | | data.put("todayMoney", "预估奖金总额 ¥" + todayMoney);
|
| | | data.put("todayMoney", "今日预估奖金总额 ¥" + todayMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | }
|
| | | data.put("todayTotal", "共"+ todayTotal+ "笔");
|
| | | data.put("totalValid", totalValid); // 有效数量
|
| | |
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public String convertDate (Integer slotTime, String startTime) throws Exception {
|
| | | String endTime = null;
|
| | | public String convertDate (Integer slotTime, String endTime) throws Exception {
|
| | | String startTime = null;
|
| | |
|
| | | switch (slotTime) {
|
| | | case 1: // 最近三天
|
| | | endTime = DateUtil.plusDay(3, startTime);
|
| | | startTime = DateUtil.reduceDay(3, endTime);
|
| | | break;
|
| | | case 2: // 最近七天
|
| | | endTime = DateUtil.plusDay(7, startTime);
|
| | | startTime = DateUtil.reduceDay(7, endTime);
|
| | | break;
|
| | | case 3: // 最近15天 (半月)
|
| | | endTime = DateUtil.plusDay(15, startTime);
|
| | | startTime = DateUtil.reduceDay(15, endTime);
|
| | | break;
|
| | | case 4: // 最近三十天 (本月)
|
| | | endTime = DateUtil.plusDay(30, startTime);
|
| | | startTime = DateUtil.reduceDay(30, endTime);
|
| | | break;
|
| | | case 5: // 最近九十天(近三月)
|
| | | endTime = DateUtil.plusDay(3*30, startTime);
|
| | | startTime = DateUtil.reduceDay(3*30, endTime);
|
| | | break;
|
| | | case 6: // 最近一百八十天(近半年)
|
| | | endTime = DateUtil.plusDay(6*30, startTime);
|
| | | startTime = DateUtil.reduceDay(6*30, endTime);
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | |
|
| | | return endTime;
|
| | | return startTime;
|
| | | }
|
| | | }
|
| | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | long selectCountByTypeAndStateAndCreateTime(@Param("uid") Long uid, @Param("type") List<Integer> type, |
| | | @Param("state") List<Integer> state, @Param("minTime") Date minTime, @Param("maxTime") Date maxTime); |
| | | |
| | | |
| | | /** |
| | | * 根据渠道 统计新增用户24小时内产生的订单数量 |
| | | * @param channel |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> count24HOderByChannel(@Param("channel")String channel, |
| | | @Param("type")Integer type, @Param("years") String years, |
| | | @Param("startTime")String startTime, @Param("endTime")String endTime); |
| | | |
| | | |
| | | /** |
| | | * 根据渠道 统计历史产生的订单数量 |
| | | * @param channel |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> countHistoryOderByChannel(@Param("channel")String channel, |
| | | @Param("type")Integer type, @Param("years") String years, |
| | | @Param("startTime")String startTime, @Param("endTime")String endTime); |
| | | |
| | | } |
| | |
| | | package com.yeshi.fanli.dao.mybatis.user; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog; |
| | | |
| | | public interface UserActiveLogMapper { |
| | |
| | | int updateByPrimaryKeySelective(UserActiveLog record); |
| | | |
| | | int updateByPrimaryKey(UserActiveLog record); |
| | | |
| | | /** |
| | | * 根据渠道 统计当日新增用户数量 |
| | | * @param channel |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> countSameDayByChannel(@Param("channel")String channel, |
| | | @Param("type")Integer type, @Param("years") String years, |
| | | @Param("startTime")String startTime, @Param("endTime")String endTime); |
| | | } |
| | |
| | | ]]> |
| | | #{maxTime}; |
| | | </select> |
| | | |
| | | <select id="count24HOderByChannel" resultType="java.util.HashMap"> |
| | | SELECT COALESCE(SUM(b.money*2),0) AS 'commision', COALESCE(COUNT(b.id),0) AS'countOrder', |
| | | COALESCE(SUM(b.payMoney),0) AS 'payMoney', |
| | | <if test="type == 1"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'createDate' |
| | | </if> |
| | | <if test="type == 2"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'createDate' |
| | | </if> |
| | | <if test="type == 3"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'createDate' |
| | | </if> |
| | | FROM |
| | | ( |
| | | SELECT h.* FROM yeshi_ec_hongbao h |
| | | LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a |
| | | WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a |
| | | ON a.uid=h.`uid` WHERE a.uid IS NOT NULL AND (h.`type`=1 OR h.`type`=20) |
| | | ) b |
| | | LEFT JOIN yeshi_ec_user u ON u.`id`=b.uid |
| | | WHERE <![CDATA[b.createtime<u.`createtime`+1000*60*60*24 ]]> |
| | | <if test="startTime != null and startTime != '' "> |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}' |
| | | </if> |
| | | <if test="endTime != null and endTime != '' "> |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}' |
| | | </if> |
| | | <if test="years != null and years != '' "> |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}' |
| | | </if> |
| | | <if test="type == 1"> |
| | | GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') |
| | | </if> |
| | | <if test="type == 2"> |
| | | GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m') |
| | | </if> |
| | | <if test="type == 3"> |
| | | GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y') |
| | | </if> |
| | | ORDER BY u.`createtime` |
| | | |
| | | </select> |
| | | |
| | | <select id="countHistoryOderByChannel" resultType="java.util.HashMap"> |
| | | |
| | | SELECT COALESCE(SUM(h.`money`)*2,0) AS 'commision', COALESCE(COUNT(h.id),0) AS 'countOrder', |
| | | COALESCE(SUM(h.payMoney),0) AS 'payMoney', |
| | | <if test="type == 1"> |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') AS 'createDate' |
| | | </if> |
| | | <if test="type == 2"> |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%m') AS 'createDate' |
| | | </if> |
| | | <if test="type == 3"> |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%Y') AS 'createDate' |
| | | </if> |
| | | FROM yeshi_ec_hongbao h |
| | | LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a |
| | | WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON h.`uid`=a.uid |
| | | WHERE (h.`type`=1 OR h.`type`=20) AND a.uid IS NOT NULL |
| | | <if test="startTime != null and startTime != '' "> |
| | | AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}' |
| | | </if> |
| | | <if test="endTime != null and endTime != '' "> |
| | | AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}' |
| | | </if> |
| | | <if test="years != null and years != '' "> |
| | | AND FROM_UNIXTIME(h.`createtime`/1000,'%Y') = '${years}' |
| | | </if> |
| | | <if test="type == 1"> |
| | | GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') |
| | | </if> |
| | | <if test="type == 2"> |
| | | GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m') |
| | | </if> |
| | | <if test="type == 3"> |
| | | GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y') |
| | | </if> |
| | | ORDER BY h.`createtime` |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | </set> |
| | | where lua_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="countSameDayByChannel" resultType="java.util.HashMap"> |
| | | SELECT COALESCE(COUNT(*),0) AS 'sameDayNum', |
| | | <if test="type == 1"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'createDate' |
| | | </if> |
| | | <if test="type == 2"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'createDate' |
| | | </if> |
| | | <if test="type == 3"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'createDate' |
| | | </if> |
| | | FROM (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a |
| | | WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a |
| | | LEFT JOIN yeshi_ec_user u ON u.`id`=a.uid |
| | | WHERE 1=1 |
| | | <if test="startTime != null and startTime != '' "> |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}' |
| | | </if> |
| | | <if test="endTime != null and endTime != '' "> |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}' |
| | | </if> |
| | | <if test="years != null and years != '' "> |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}' |
| | | </if> |
| | | <if test="type == 1"> |
| | | GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') |
| | | </if> |
| | | <if test="type == 2"> |
| | | GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m') |
| | | </if> |
| | | <if test="type == 3"> |
| | | GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y') |
| | | </if> |
| | | |
| | | ORDER BY u.`createtime` |
| | | </select> |
| | | </mapper> |
| | |
| | |
|
| | | import java.io.Serializable;
|
| | | import java.math.BigDecimal;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.hibernate.HibernateException;
|
| | | import org.hibernate.Query;
|
| | |
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.web.context.request.RequestContextHolder;
|
| | | import org.springframework.web.context.request.ServletRequestAttributes;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.hongbao.HongBaoDao;
|
| | | import com.yeshi.fanli.dao.mybatis.AccountDetailsMapper;
|
| | |
| | | import com.yeshi.fanli.util.push.XiaoMiPushUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Service
|
| | | public class HongBaoServiceImpl implements HongBaoService {
|
| | |
| | |
|
| | | @Override
|
| | | public int getTotalTiChengCount(Long uid) {
|
| | |
|
| | | return hongBaoMapper.getTotalTiChengCount(uid);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public List<Object> count24HOderByChannel(String channel, Integer type, String years,
|
| | | String startTime, String endTime) throws Exception{
|
| | | List<Map<String, Object>> list = hongBaoMapper.count24HOderByChannel(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> countHistoryOderByChannel(String channel, Integer type, String years,
|
| | | String startTime, String endTime) throws Exception{
|
| | | |
| | | List<Map<String, Object>> list = hongBaoMapper.countHistoryOderByChannel(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;
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | |
| | | public List<Object> dayFactory(String startTime, String endTime, List<Map<String, Object>> list) throws Exception {
|
| | | |
| | | List<Object> listObject = new ArrayList<Object>();
|
| | | |
| | | if (startTime.equals(endTime)) {
|
| | | |
| | | Map<String, Object> map = list.get(0);
|
| | | Object payMoney = map.get("payMoney");
|
| | | Object countOrder = map.get("countOrder");
|
| | | Object commision = map.get("commision");
|
| | | |
| | | if (payMoney == null) {
|
| | | map.put("payMoney", 0);
|
| | | }
|
| | | if (countOrder == null) {
|
| | | map.put("countOrder", 0);
|
| | | }
|
| | | if (commision == null) {
|
| | | map.put("commision", 0);
|
| | | }
|
| | | listObject.add(map);
|
| | | return listObject;
|
| | | }
|
| | | |
| | | |
| | | String plusDay = "";
|
| | | for (int i = 0; i < 1000 ; i++) {
|
| | | if (i == 0) {
|
| | | plusDay = startTime;
|
| | | } else {
|
| | | plusDay = DateUtil.plusDay(i, startTime);
|
| | | }
|
| | | |
| | | Map<String, Object> mapObject = new HashMap<String, Object>();
|
| | | Object payMoney = null;
|
| | | Object countOrder = null;
|
| | | Object commision = null; |
| | | |
| | | for (int j = 0; j < list.size(); j++) {
|
| | | Map<String, Object> map = list.get(j);
|
| | | Object createDate = map.get("createDate");
|
| | | String month = createDate.toString();
|
| | | if (plusDay.equalsIgnoreCase(month)) {
|
| | | payMoney = map.get("payMoney");
|
| | | countOrder = map.get("countOrder");
|
| | | commision = map.get("commision");
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (payMoney == null) {
|
| | | payMoney = 0;
|
| | | }
|
| | | mapObject.put("payMoney", payMoney);
|
| | | |
| | | if (countOrder == null) {
|
| | | countOrder = 0;
|
| | | }
|
| | | mapObject.put("countOrder", countOrder);
|
| | | |
| | | if (commision == null) {
|
| | | commision = 0;
|
| | | }
|
| | | mapObject.put("commision", commision);
|
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
|
| | | Date parseDate = sdf.parse(plusDay.toString());
|
| | | |
| | | mapObject.put("createDate", sdf2.format(parseDate));
|
| | | |
| | | listObject.add(mapObject);
|
| | | |
| | | if (plusDay.equals(endTime)) {
|
| | | break; // 时间结束
|
| | | }
|
| | | }
|
| | | |
| | | return listObject;
|
| | | }
|
| | | |
| | | |
| | | public List<Object> monthFactory(List<Map<String, Object>> list) {
|
| | | |
| | | List<Object> listObject = new ArrayList<Object>();
|
| | | // 12 个月处理
|
| | | for (int i = 1; i <= 12; i++) {
|
| | | Map<String, Object> mapObject = new HashMap<String, Object>();
|
| | | Object payMoney = null;
|
| | | Object countOrder = null;
|
| | | Object commision = null; |
| | | |
| | | for (int j = 0; j < list.size(); j++) {
|
| | | Map<String, Object> map = list.get(j);
|
| | | Object createDate = map.get("createDate");
|
| | | String month = createDate.toString();
|
| | | if ((i+"").equalsIgnoreCase(month) || i == Integer.parseInt(month)) {
|
| | | payMoney = map.get("payMoney");
|
| | | countOrder = map.get("countOrder");
|
| | | commision = map.get("commision");
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (payMoney == null) {
|
| | | payMoney = 0;
|
| | | }
|
| | | mapObject.put("payMoney", payMoney);
|
| | | |
| | | if (countOrder == null) {
|
| | | countOrder = 0;
|
| | | }
|
| | | mapObject.put("countOrder", countOrder);
|
| | | |
| | | if (commision == null) {
|
| | | commision = 0;
|
| | | }
|
| | | mapObject.put("commision", commision);
|
| | | |
| | | mapObject.put("createDate", i + "月");
|
| | | |
| | | listObject.add(mapObject);
|
| | | }
|
| | | return listObject;
|
| | | }
|
| | | |
| | | public List<Object> yearFactory(List<Map<String, Object>> list) {
|
| | | |
| | | List<Object> listObject = new ArrayList<Object>();
|
| | | |
| | | for (int i = 0; i < list.size(); i++) {
|
| | | Map<String, Object> map = list.get(i);
|
| | | Object payMoney = map.get("payMoney");
|
| | | Object countOrder = map.get("countOrder");
|
| | | Object commision = map.get("commision"); |
| | | |
| | | if (payMoney == null) {
|
| | | payMoney = 0;
|
| | | }
|
| | | map.put("payMoney", payMoney);
|
| | | |
| | | if (countOrder == null) {
|
| | | countOrder = 0;
|
| | | }
|
| | | map.put("countOrder", countOrder);
|
| | | |
| | | if (commision == null) {
|
| | | commision = 0;
|
| | | }
|
| | | map.put("commision", commision + "年");
|
| | | |
| | | |
| | | listObject.add(map);
|
| | | }
|
| | | |
| | | return listObject;
|
| | | }
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserActiveLogMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog;
|
| | |
| | | return userActiveLogMapper.selectLatestByUid(uid);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public List<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;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | public List<Object> dayFactory(String startTime, String endTime, List<Map<String, Object>> list) throws Exception {
|
| | | |
| | | List<Object> listObject = new ArrayList<Object>();
|
| | | |
| | | if (startTime.equals(endTime)) {
|
| | | |
| | | Map<String, Object> map = list.get(0);
|
| | | Object sameDayNum = map.get("sameDayNum");
|
| | | |
| | | if (sameDayNum == null) {
|
| | | map.put("sameDayNum", 0);
|
| | | }
|
| | | listObject.add(map);
|
| | | |
| | | return listObject;
|
| | | }
|
| | | |
| | | |
| | | String plusDay = "";
|
| | | for (int i = 0; i < 1000 ; i++) {
|
| | | if (i == 0) {
|
| | | plusDay = startTime;
|
| | | } else {
|
| | | plusDay = DateUtil.plusDay(i, startTime);
|
| | | }
|
| | | |
| | | Map<String, Object> mapObject = new HashMap<String, Object>();
|
| | | Object sameDayNum = null; |
| | | |
| | | for (int j = 0; j < list.size(); j++) {
|
| | | Map<String, Object> map = list.get(j);
|
| | | Object createDate = map.get("createDate");
|
| | | String month = createDate.toString();
|
| | | if (plusDay.equalsIgnoreCase(month)) {
|
| | | sameDayNum = map.get("sameDayNum");
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (sameDayNum == null) {
|
| | | sameDayNum = 0;
|
| | | }
|
| | | mapObject.put("sameDayNum", sameDayNum);
|
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
|
| | | Date parseDate = sdf.parse(plusDay.toString());
|
| | | |
| | | mapObject.put("createDate", sdf2.format(parseDate));
|
| | | |
| | | listObject.add(mapObject);
|
| | | |
| | | if (plusDay.equals(endTime)) {
|
| | | break; // 时间结束
|
| | | }
|
| | | }
|
| | | |
| | | return listObject;
|
| | | }
|
| | | |
| | | |
| | | public List<Object> monthFactory(List<Map<String, Object>> list) {
|
| | | |
| | | List<Object> listObject = new ArrayList<Object>();
|
| | | // 12 个月处理
|
| | | for (int i = 1; i <= 12; i++) {
|
| | | Map<String, Object> mapObject = new HashMap<String, Object>();
|
| | | Object sameDayNum = null;
|
| | | for (int j = 0; j < list.size(); j++) {
|
| | | Map<String, Object> map = list.get(j);
|
| | | Object createDate = map.get("createDate");
|
| | | String month = createDate.toString();
|
| | | if ((i+"").equalsIgnoreCase(month) || i == Integer.parseInt(month)) {
|
| | | sameDayNum = map.get("sameDayNum"); |
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (sameDayNum == null) {
|
| | | sameDayNum = 0;
|
| | | }
|
| | | mapObject.put("sameDayNum", sameDayNum);
|
| | | |
| | | mapObject.put("createDate", i + "月");
|
| | | |
| | | listObject.add(mapObject);
|
| | | }
|
| | | return listObject;
|
| | | }
|
| | | |
| | | public List<Object> yearFactory(List<Map<String, Object>> list) {
|
| | | |
| | | List<Object> listObject = new ArrayList<Object>();
|
| | | |
| | | for (int i = 0; i < list.size(); i++) {
|
| | | Map<String, Object> map = list.get(i);
|
| | | Object sameDayNum = map.get("sameDayNum"); |
| | | Object createDate = map.get("createDate"); |
| | | |
| | | if (sameDayNum == null) {
|
| | | sameDayNum = 0;
|
| | | }
|
| | | map.put("sameDayNum", sameDayNum);
|
| | | map.put("createDate", createDate + "年");
|
| | | |
| | | listObject.add(map);
|
| | | }
|
| | | |
| | | return listObject;
|
| | | }
|
| | | }
|
| | |
| | | */
|
| | | public List<HongBao> listShareAndInviteMoney(long start, int count, String date);
|
| | |
|
| | | /**
|
| | | * 根据渠道 统计历史产生的订单数量
|
| | | * @param channel
|
| | | * @return
|
| | | */
|
| | | public List<Object> countHistoryOderByChannel(String channelArray, Integer type, String year,
|
| | | String startTime, String endTime) throws Exception;
|
| | |
|
| | | /**
|
| | | * 根据渠道 统计新增用户24小时内产生的订单数量
|
| | | * @param channel
|
| | | * @return
|
| | | */
|
| | | public List<Object> count24HOderByChannel(String channel, Integer type, String years,
|
| | | String startTime, String endTime) throws Exception;
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.user;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog;
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | public UserActiveLog getUserLatestActiveInfo(Long uid);
|
| | |
|
| | |
|
| | | public List<Object> countSameDayByChannel(String channel, Integer type, String years, String startTime, String endTime)
|
| | | throws Exception;
|
| | |
|
| | | }
|