| | |
| | | year, startTime, endTime);
|
| | |
|
| | | if (dateType != 3) {
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType,dateList, list)));
|
| | | } else {
|
| | | // 年视图
|
| | | Map<String, Object> map = AdminUtils.yearsDataFactory(list);
|
| | |
| | | year, startTime, endTime);
|
| | |
|
| | | if (dateType != 3) {
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
|
| | | } else {
|
| | | // 年视图
|
| | | Map<String, Object> map = AdminUtils.yearsDataFactory(list);
|
| | |
| | | year, startTime, endTime);
|
| | |
|
| | | if (dateType != 3) {
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
|
| | | } else {
|
| | | // 年视图
|
| | | Map<String, Object> map = AdminUtils.yearsDataFactory(list);
|
| | |
| | | * 2018-12-01
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getOderChannelCharts")
|
| | | public void getOderChannelCharts(String callback, String channelArray, Integer dateType, Integer type,
|
| | | @RequestMapping(value = "get24HOderChannelCharts")
|
| | | public void get24HOderChannelCharts(String callback, String channelArray, Integer dateType,
|
| | | String year, String startTime, String endTime, PrintWriter out) {
|
| | |
|
| | | String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
|
| | |
| | | List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
|
| | |
|
| | | JSONArray line_list = new JSONArray();
|
| | | |
| | | for (String channel : channelList) {
|
| | | List<Map<String, Object>> list = null;
|
| | | if (type == 1) {
|
| | | list = hongBaoService.count24HOderByChannel(channel, dateType, year, startTime, endTime);
|
| | | List<Map<String, Object>> list = hongBaoV2CountService.count24HOderByChannel(channel, dateType, year, startTime, endTime);
|
| | |
|
| | | } else if (type == 2) {
|
| | | list = hongBaoService.countHistoryOderByChannel(channel, dateType, year, startTime, endTime);
|
| | | }
|
| | |
|
| | | if ("all".equalsIgnoreCase(channel)) {
|
| | | channel = "总计";
|
| | |
| | | innerList.put("name", channel);
|
| | |
|
| | | if (dateType != 3) {
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
|
| | | } else {
|
| | | // 年视图
|
| | | Map<String, Object> map = AdminUtils.yearsDataFactory(list);
|
| | |
| | |
|
| | | try {
|
| | |
|
| | | JSONObject data = countHistoryHongBao(channelArray, dateType, state, year, startTime, endTime, 1);
|
| | | JSONObject data = countHistoryHongBao(channelArray, dateType, state, year, startTime, endTime, 2);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
|
| | |
| | | innerList.put("name", channel);
|
| | |
|
| | | if (dateType != 3) {
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
|
| | | } else {
|
| | | // 年视图
|
| | | Map<String, Object> map = AdminUtils.yearsDataFactory(list);
|
| | |
| | | * @param endTime
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getTypeRate")
|
| | | public void getTypeRate(String callback, Integer dateType, Integer type, String year,
|
| | | @RequestMapping(value = "getTypeNumber")
|
| | | public void getTypeNumber(String callback, Integer dateType, String typeArray, String year,
|
| | | String startTime, String endTime, PrintWriter out) {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确时间区间"));
|
| | | String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
|
| | | if (validateMsg != null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (type == null || dateType ==null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("视图类型、订单类型不能为空"));
|
| | | if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
|
| | | startTime = null;
|
| | | endTime = null;
|
| | | }
|
| | |
|
| | | |
| | | List<Integer> channelList = null;
|
| | | if (typeArray != null && typeArray.trim().length() > 0) {
|
| | | Gson gson = new Gson();
|
| | | channelList = gson.fromJson(typeArray, new TypeToken<ArrayList<Integer>>() {}.getType());
|
| | | }
|
| | |
|
| | | if (channelList == null || channelList.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("订单类型不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | if (dateType == 1 && year != null) {
|
| | | year = null; // 设置为空
|
| | | } else if (dateType == 2) {
|
| | | if (startTime != null) |
| | | startTime = null; |
| | | |
| | | if (endTime != null) |
| | | endTime = null; |
| | | |
| | | } else if (dateType == 3) {
|
| | | if (year != null)
|
| | | year = null; |
| | | |
| | | if (startTime != null) |
| | | startTime = null; |
| | | |
| | | if (endTime != null) |
| | | endTime = null; |
| | | }
|
| | | |
| | | Gson gson = new Gson();
|
| | | Object objectDate = null;
|
| | | List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
|
| | |
|
| | | try {
|
| | |
|
| | | List<Map<String, Object>> resultList = hongBaoV2CountService.getProportionByType(dateType,
|
| | | type, year, startTime, endTime);
|
| | |
|
| | | if (resultList == null) {
|
| | | resultList = new ArrayList<Map<String, Object>>();
|
| | | JSONArray line_list = new JSONArray();
|
| | | for (Integer type : channelList) {
|
| | | |
| | | List<Map<String, Object>> list = hongBaoV2CountService.countHongBaoType(dateType,
|
| | | type, year, startTime, endTime);
|
| | | |
| | | |
| | | JSONObject innerList = new JSONObject();
|
| | | if (type == 1) {
|
| | | innerList.put("name", "返利订单");
|
| | | } else if (type == 2) {
|
| | | innerList.put("name", "分享订单");
|
| | | } else if (type == 3) {
|
| | | innerList.put("name", "邀请订单");
|
| | | }
|
| | |
|
| | | if (dateType != 3) {
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
|
| | | } else {
|
| | | // 年视图
|
| | | Map<String, Object> map = AdminUtils.yearsDataFactory(list);
|
| | |
|
| | | if (objectDate == null) {
|
| | | objectDate = map.get("date");
|
| | | }
|
| | | innerList.put("data", gson.toJson(map.get("value")));
|
| | | }
|
| | | |
| | | line_list.add(innerList);
|
| | | }
|
| | |
|
| | | JSONObject innerList = new JSONObject();
|
| | | if (type == 1) {
|
| | | innerList.put("name", "返利订单");
|
| | | } else if (type == 2) {
|
| | | innerList.put("name", "分享订单");
|
| | | } else if (type == 3) {
|
| | | innerList.put("name", "邀请订单");
|
| | | }
|
| | | innerList.put("data_list", resultList);
|
| | | |
| | | JSONArray outList = new JSONArray();
|
| | | outList.add(innerList);
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("result_list", outList);
|
| | | if (objectDate != null) {
|
| | | data.put("xAxis_list", gson.toJson(objectDate));
|
| | | } else {
|
| | | data.put("xAxis_list", gson.toJson(dateList));
|
| | | }
|
| | | |
| | | data.put("line_list", line_list);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | |
| | | * @param endTime 2018-12-01
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getSameDayUserByChannel")
|
| | | public void getSameDayUserByChannel(String callback, String channelArray, Integer dateType, |
| | | @RequestMapping(value = "getNewUserCharts")
|
| | | public void getNewUserCharts(String callback, String channelArray, Integer dateType, |
| | | String year, String startTime, String endTime, PrintWriter out) {
|
| | |
|
| | |
|
| | |
| | | JSONArray line_list = new JSONArray();
|
| | | for (String channel : channelList) {
|
| | |
|
| | | List<Map<String, Object>> list = userActiveLogService.countSameDayByChannel(channel, |
| | | List<Map<String, Object>> list = userInfoCountService.countNewUserByDate(channel, |
| | | dateType, year, startTime, endTime);
|
| | |
|
| | | if ("all".equalsIgnoreCase(channel)) {
|
| | |
| | | innerList.put("name", channel);
|
| | |
|
| | | if (dateType != 3) {
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
|
| | | } else {
|
| | | // 年视图
|
| | | Map<String, Object> map = AdminUtils.yearsDataFactory(list);
|
| | |
| | | * @param endTime 2018-12-01
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getBuyProportion")
|
| | | public void getBuyProportion(String callback, String channelArray, Integer dateType, |
| | | @RequestMapping(value = "getTodayBuyRate")
|
| | | public void getTodayBuyRate(String callback, String channelArray, Integer dateType, |
| | | String year, String startTime, String endTime, Integer orderNum, PrintWriter out) {
|
| | |
|
| | | if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
|
| | |
| | |
|
| | | for (String channel: list) {
|
| | | JSONObject channelData = new JSONObject();
|
| | | List<Object> resultList = userActiveLogService.getBuyProportion(channel, dateType, year, startTime, endTime, orderNum);
|
| | | List<Object> resultList = null;
|
| | | |
| | | //userActiveLogService.getBuyProportion(channel, dateType, year, startTime, endTime, orderNum);
|
| | | if (resultList == null) {
|
| | | resultList = new ArrayList<Object>();
|
| | | }
|
| | |
| | | JSONObject channelData = new JSONObject();
|
| | |
|
| | |
|
| | | List<Map<String, Object>> resultList = userActiveLogService.countOneWeekUserInfo(channel, |
| | | startTime, endTime, orderNum);
|
| | | List<Map<String, Object>> resultList = null;
|
| | | //userActiveLogService.countOneWeekUserInfo(channel, startTime, endTime, orderNum);
|
| | |
|
| | | if (resultList == null) {
|
| | | resultList = new ArrayList<Map<String, Object>>();
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("统计异常"));
|
| | | }
|
| | |
|
| | | }
|
| | | |
| | | /**
|
| | | * 统计历史新增用户
|
| | | * @param callback
|
| | | * @param dateType 类型 1日 2月 3年
|
| | | * @param year 2018
|
| | | * @param startTime 2018-12-01 |
| | | * @param endTime 2018-12-01 |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getNewUserCharts")
|
| | | public void getNewUserCharts(String callback, Integer dateType, String year, String startTime,
|
| | | String endTime, PrintWriter out) {
|
| | |
|
| | | String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
|
| | | if (validateMsg != null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
|
| | | startTime = null;
|
| | | endTime = null;
|
| | | }
|
| | |
|
| | | if (dateType == 1 && year != null) {
|
| | | year = null; // 设置为空
|
| | | } else if (dateType == 2) {
|
| | | if (startTime != null)
|
| | | startTime = null;
|
| | |
|
| | | if (endTime != null)
|
| | | endTime = null;
|
| | |
|
| | | } else if (dateType == 3) {
|
| | | if (year != null)
|
| | | year = null;
|
| | |
|
| | | if (startTime != null)
|
| | | startTime = null;
|
| | |
|
| | | if (endTime != null)
|
| | | endTime = null;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | Gson gson = new Gson();
|
| | | Object objectDate = null;
|
| | | List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
|
| | |
|
| | | JSONArray line_list = new JSONArray();
|
| | |
|
| | | List<Map<String, Object>> list = userInfoCountService
|
| | | .countNewUserByDate(dateType, year, startTime, endTime);
|
| | |
|
| | | JSONObject innerList = new JSONObject();
|
| | | innerList.put("name", "总计");
|
| | |
|
| | | if (dateType != 3) {
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
|
| | | } else {
|
| | | // 年视图
|
| | | Map<String, Object> map = AdminUtils.yearsDataFactory(list);
|
| | |
|
| | | if (objectDate == null) {
|
| | | objectDate = map.get("date");
|
| | | }
|
| | | innerList.put("data", gson.toJson(map.get("value")));
|
| | | }
|
| | |
|
| | | line_list.add(innerList);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | if (objectDate != null) {
|
| | | data.put("xAxis_list", gson.toJson(objectDate));
|
| | | } else {
|
| | | data.put("xAxis_list", gson.toJson(dateList));
|
| | | }
|
| | |
|
| | | data.put("line_list", line_list);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | |
|
| | |
|
| | | public static List<Object> dayOrMonthDataFactory(List<String> listDate , List<Map<String, Object>> list) throws Exception {
|
| | | public static List<Object> dayOrMonthDataFactory(Integer dateType, List<String> listDate , |
| | | List<Map<String, Object>> list) throws Exception {
|
| | |
|
| | | List<Object> resultList = new ArrayList<Object>();
|
| | |
|
| | | if (list != null && list.size() > 0) {
|
| | | for (int i = 0; i < listDate.size(); i++) {
|
| | | |
| | | Object showValue = null;
|
| | | if (list != null && list.size() > 0) {
|
| | | // 日期匹配赋值
|
| | |
| | | Map<String, Object> map = list.get(j);
|
| | |
|
| | | String showDate = listDate.get(i);
|
| | | Object reslutDate = map.get("showDate");
|
| | | String month = reslutDate.toString();
|
| | | if (dateType == 2 && Integer.parseInt(showDate) < 10 ) {
|
| | | showDate = "0" + showDate;
|
| | | }
|
| | |
|
| | | if (showDate.equalsIgnoreCase(month)) {
|
| | | Object reslutDate = map.get("showDate");
|
| | | String reslutTime = reslutDate.toString();
|
| | | |
| | | if (showDate.equalsIgnoreCase(reslutTime)) {
|
| | | showValue = map.get("showValue");
|
| | | break;
|
| | | }
|
| | | |
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (showValue == null) {
|
| | | showValue = 0;
|
| | |
| | | innerList.put("name", "总计");
|
| | |
|
| | | if (dateType != 3) {
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
|
| | | innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
|
| | | } else {
|
| | | // 年视图
|
| | | Map<String, Object> map = yearsDataFactory(list);
|
| | |
| | | |
| | | Date getLastHongBaoTime(@Param("uid") Long uid); |
| | | |
| | | |
| | | /** |
| | | * 根据渠道 统计新增用户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); |
| | | |
| | | } |
| | |
| | | * 统计新增用户 |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> countNewUserByDate(@Param("type")Integer type, @Param("years") String years, |
| | | List<Map<String, Object>> countNewUserByDate(@Param("channel")String channel,@Param("type")Integer type, @Param("years") String years, |
| | | @Param("startTime")String startTime, @Param("endTime")String endTime); |
| | | |
| | | |
| | | /** |
| | | * 统计新增用户 |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> getTodayHasOrder(@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.math.BigDecimal; |
| | | 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); |
| | | |
| | | /** |
| | | * 根据渠道 统计当日新增用户有购买行为的数量 |
| | | * @param channel |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> countSameDayAndBuyGoodsByChannel(@Param("channel")String channel, |
| | | @Param("type")Integer type, @Param("years") String years, |
| | | @Param("startTime")String startTime, @Param("endTime")String endTime); |
| | | |
| | | /** |
| | | * 统计 |
| | | * @param channel |
| | | * @return |
| | | */ |
| | | Map<String, BigDecimal> countOneWeekUserInfo(@Param("channel")String channel, |
| | | @Param("startTime")String startTime, @Param("endTime")String endTime, |
| | | @Param("orderNumber")Integer orderNumber); |
| | | } |
| | |
| | | </select> |
| | | |
| | | <select id="countHasOrderUser" resultType="java.lang.Long"> |
| | | SELECT COUNT(DISTINCT h.`uid`) FROM yeshi_ec_hongbao_v2 h |
| | | SELECT COUNT(DISTINCT h.`hb_uid`) FROM yeshi_ec_hongbao_v2 h |
| | | WHERE h.`hb_type`=1 or h.`hb_type`=2 |
| | | </select> |
| | | |
| | | |
| | | <select id="countNewUserByDate" resultType="java.util.HashMap"> |
| | | SELECT COUNT(h.`id`) AS total, |
| | | SELECT COUNT(h.`id`) AS showValue, |
| | | <if test="type == 1"> |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') AS 'createDate' |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') AS 'showDate' |
| | | </if> |
| | | <if test="type == 2"> |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%m') AS 'createDate' |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%m') AS 'showDate' |
| | | </if> |
| | | <if test="type == 3"> |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%Y') AS 'createDate' |
| | | FROM_UNIXTIME(h.`createtime`/1000,'%Y') AS 'showDate' |
| | | </if> |
| | | FROM yeshi_ec_user h |
| | | <if test="channel != null and channel != 'all' "> |
| | | 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.`id`=a.uid |
| | | </if> |
| | | WHERE 1=1 |
| | | <if test="channel != null and channel != 'all' "> |
| | | AND a.uid is not null |
| | | </if> |
| | | <if test="startTime != null and startTime != '' "> |
| | | AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${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> |
| | | ORDER BY h.`createtime` |
| | | </select> |
| | | |
| | | <select id="getTodayHasOrder" resultType="java.util.HashMap"> |
| | | SELECT COALESCE(COUNT(u.`id`),0) AS 'showValue', |
| | | <if test="type == 1"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate' |
| | | </if> |
| | | <if test="type == 2"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate' |
| | | </if> |
| | | <if test="type == 3"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate' |
| | | </if> |
| | | |
| | | FROM yeshi_ec_user u |
| | | <if test="channel != null and channel != 'all' "> |
| | | 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 u.`id`=a.uid |
| | | </if> |
| | | LEFT JOIN `yeshi_ec_hongbao_v2` h ON h.`hb_uid`= u.`id` |
| | | WHERE (h.`hb_type`=1 OR h.`hb_type`=20) |
| | | <if test="channel != null and channel != 'all' "> |
| | | AND a.uid is not null |
| | | </if> |
| | | <!-- 当日下单 --> |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = FROM_UNIXTIME(h.hb_create_time/1000,'%Y-%m-%d') |
| | | |
| | | <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="countWeekUserInfo" resultType="java.util.HashMap"> |
| | | SELECT COALESCE(SUM(w.total),0) AS totalUser,COALESCE(SUM(w.orderUser),0)AS orderUser FROM |
| | | ( |
| | | <!-- 统计总当日总数量 --> |
| | | SELECT COUNT(u.`id`)AS total,0 AS orderUser |
| | | FROM yeshi_ec_user u |
| | | <if test="channel != null and channel != 'all' "> |
| | | 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 u.`id`=a.uid |
| | | </if> |
| | | WHERE FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = '${startTime}' |
| | | <if test="channel != null and channel != 'all' "> |
| | | AND a.uid is not null |
| | | </if> |
| | | UNION |
| | | |
| | | SELECT 0 AS total, COUNT(u.`id`) AS orderUser |
| | | FROM yeshi_ec_user u |
| | | <if test="channel != null and channel != 'all' "> |
| | | 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 u.`id`=a.uid |
| | | </if> |
| | | WHERE FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = '${startTime}' |
| | | AND u.id = ANY(SELECT hh.hb_uid FROM (SELECT COUNT(t.`hb_id`) AS num,t.hb_uid |
| | | FROM yeshi_ec_hongbao_v2 t |
| | | WHERE <![CDATA[DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') >= '${startTime}']]> |
| | | AND <![CDATA[DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') < '${endTime}']]> |
| | | GROUP BY t.hb_uid HAVING num >= ${orderNumber} |
| | | )hh |
| | | ) |
| | | |
| | | <if test="channel != null and channel != 'all' "> |
| | | AND a.uid is not null |
| | | </if> |
| | | )w |
| | | |
| | | </select> |
| | | </mapper> |
| | |
| | | </sql> |
| | | <sql id="Count_Select_State"> |
| | | <if test="state != null and state == 1"> <!-- 未到账 --> |
| | | AND (th.hb_state = 1 or th.hb_state = 2) |
| | | AND (t.hb_state = 1 or t.hb_state = 2) |
| | | </if> |
| | | <if test="state != null and state == 2"> <!-- 已到账 --> |
| | | AND th.hb_state = 3 |
| | | AND t.hb_state = 3 |
| | | </if> |
| | | <if test="state != null and state == 3"> <!-- 红包已失效 --> |
| | | AND th.hb_state =4 |
| | | AND t.hb_state =4 |
| | | </if> |
| | | </sql> |
| | | |
| | |
| | | <if test="channel != null and channel != 'all' "> |
| | | 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 t.`hb_uid`=a.uid |
| | | </if> |
| | | WHERE t.`hb_uid` IS NOT NULL AND (t.`hb_type`=1 OR t.`hb_type`=20) <include refid="Count_Select_DateType"/> |
| | | WHERE t.`hb_uid` IS NOT NULL AND (t.`hb_type`=1 OR t.`hb_type`=20) |
| | | <include refid="Count_Select_DateType"/> |
| | | <include refid="Count_Select_State"/> |
| | | <if test="channel != null and channel != 'all' "> |
| | | AND a.uid is not null |
| | | </if> |
| | | |
| | | <include refid="Count_Group_DateType"/> |
| | | ORDER BY t.`hb_create_time` |
| | | </select> |
| | |
| | | <if test="channel != null and channel != 'all' "> |
| | | 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 t.`hb_uid`=a.uid |
| | | </if> |
| | | WHERE t.`hb_uid` IS NOT NULL AND (t.`hb_type`=1 OR h.`hb_type`=20) <include refid="Count_Select_DateType"/> |
| | | WHERE t.`hb_uid` IS NOT NULL AND (t.`hb_type`=1 OR t.`hb_type`=20) |
| | | |
| | | <include refid="Count_Select_DateType"/> |
| | | <include refid="Count_Select_State"/> |
| | | <if test="channel != null and channel != 'all' "> |
| | | AND a.uid is not null |
| | | </if> |
| | | |
| | | <include refid="Count_Group_DateType"/> |
| | | ORDER BY t.`hb_create_time` |
| | | </select> |
| | |
| | | ORDER BY t.`hb_create_time` |
| | | </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_v2 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> |
| | | |
| | | <select id="countMoneyByUidAndState" resultType="java.math.BigDecimal"> |
| | | SELECT CAST(SUM(hb.`hb_money`)AS DECIMAL(19,2)) |
| | |
| | | LIMIT 1; |
| | | </select> |
| | | |
| | | |
| | | <select id="count24HOderByChannel" resultType="java.util.HashMap"> |
| | | SELECT <!-- COALESCE(SUM(b.money*2),0) AS 'commision', --> |
| | | COALESCE(COUNT(b.hb_id),0) AS 'showValue', |
| | | <!-- COALESCE(SUM(b.payMoney),0) AS 'payMoney', --> |
| | | <if test="type == 1"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate' |
| | | </if> |
| | | <if test="type == 2"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate' |
| | | </if> |
| | | <if test="type == 3"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate' |
| | | </if> |
| | | FROM |
| | | ( |
| | | SELECT h.* FROM yeshi_ec_hongbao_v2 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.`hb_uid` WHERE a.uid IS NOT NULL AND (h.`hb_type`=1 OR h.`hb_type`=20) |
| | | ) b |
| | | LEFT JOIN yeshi_ec_user u ON u.`id`=b.hb_uid |
| | | WHERE <![CDATA[ b.hb_create_time<FROM_UNIXTIME((u.`createtime`+1000*60*60*24)/1000,'%Y-%m-%d %h:%m:%s')]]> |
| | | <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> |
| | |
| | | |
| | | <if test="key != null and key != '' "> |
| | | <if test="keyType == 1 "> |
| | | AND co.co_order_no like '%${key}%' |
| | | AND co.co_order_no = ${key} |
| | | </if> |
| | | <if test="keyType == 1 "> |
| | | AND hb.hb_uid like '%${key}%' |
| | | <if test="keyType == 2 "> |
| | | AND hb.hb_uid like = ${key} |
| | | </if> |
| | | </if> |
| | | |
| | |
| | | |
| | | <if test="key != null and key != '' "> |
| | | <if test="keyType == 1 "> |
| | | AND co.co_order_no like '%${key}%' |
| | | AND co.co_order_no = ${key} |
| | | </if> |
| | | <if test="keyType == 1 "> |
| | | AND hb.hb_uid like '%${key}%' |
| | | <if test="keyType == 2 "> |
| | | AND hb.hb_uid like = ${key} |
| | | </if> |
| | | </if> |
| | | </select> |
| | |
| | | </set> |
| | | where lua_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="countSameDayByChannel" resultType="java.util.HashMap"> |
| | | SELECT COALESCE(COUNT(*),0) AS 'showValue', |
| | | <if test="type == 1"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate' |
| | | </if> |
| | | <if test="type == 2"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate' |
| | | </if> |
| | | <if test="type == 3"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate' |
| | | </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> |
| | | |
| | | <select id="countSameDayAndBuyGoodsByChannel" resultType="java.util.HashMap"> |
| | | SELECT COALESCE(COUNT(DISTINCT u.`id`),0) AS 'showValue', |
| | | <if test="type == 1"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate' |
| | | </if> |
| | | <if test="type == 2"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate' |
| | | </if> |
| | | <if test="type == 3"> |
| | | FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate' |
| | | </if> |
| | | |
| | | FROM |
| | | <if test="channel != null and channel != 'all' "> |
| | | (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a |
| | | WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a |
| | | </if> |
| | | LEFT JOIN yeshi_ec_user u <if test="channel != null and channel != 'all' ">ON u.`id`=a.uid</if> |
| | | LEFT JOIN `yeshi_ec_hongbao_v2` h ON h.`hb_uid`= u.`id` |
| | | WHERE (h.`hb_type`=1 OR h.`hb_type`=20) |
| | | <!-- 当日下单 --> |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = FROM_UNIXTIME(h.hb_create_time/1000,'%Y-%m-%d') |
| | | |
| | | <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="countOneWeekUserInfo" resultType="java.util.HashMap"> |
| | | SELECT COALESCE(SUM(w.total),0) AS totalUser,COALESCE(SUM(w.orderUser),0)AS orderUser FROM |
| | | (SELECT COUNT(u.`id`)AS total,0 AS orderUser |
| | | FROM |
| | | <if test="channel != null and channel != 'all' "> |
| | | (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 |
| | | </if> |
| | | yeshi_ec_user u <if test="channel != null and channel != 'all' "> ON u.`id`=a.uid </if> |
| | | |
| | | WHERE FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = '2018-11-01' |
| | | |
| | | UNION |
| | | |
| | | SELECT 0 AS total, COUNT(u.`id`) AS orderUser |
| | | FROM |
| | | <if test="channel != null and channel != 'all' "> |
| | | (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 |
| | | </if> |
| | | yeshi_ec_user u <if test="channel != null and channel != 'all' "> ON u.`id`=a.uid </if> |
| | | WHERE FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = '2018-01-11' |
| | | AND u.id = ANY(SELECT hh.hb_uid FROM (SELECT COUNT(t.`hb_id`) AS num,t.hb_uid |
| | | FROM yeshi_ec_hongbao_v2 t |
| | | WHERE <![CDATA[DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') >= '${startTime}']]> |
| | | AND <![CDATA[DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') < '${endTime}']]> |
| | | GROUP BY t.hb_uid HAVING num >= ${orderNumber} |
| | | )hh |
| | | ) |
| | | )w |
| | | |
| | | </select> |
| | | </mapper> |
| | |
| | | String year, String startTime, String endTime) throws Exception {
|
| | | return hongBaoV2CountMapper.countHongBaoNum(channel, dateType, state, year, startTime, endTime);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public List<Map<String, Object>> countHongBaoType(Integer dateType, Integer type, String year,
|
| | | String startTime, String endTime) throws Exception {
|
| | | return hongBaoV2CountMapper.countHongBaoType(dateType, type, year, startTime, endTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Map<String, Object>> getProportionByType(Integer dateType, Integer type, String year,
|
| | |
| | | public Date getLastHongBaoTime(Long uid) {
|
| | | return hongBaoV2CountMapper.getLastHongBaoTime(uid);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<Map<String, Object>> count24HOderByChannel(String channel, Integer type, String years,
|
| | | String startTime, String endTime) throws Exception{
|
| | | return hongBaoV2CountMapper.count24HOderByChannel(channel, type, years, startTime, endTime);
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | |
| | | return userInfoMapper.countHasOrderUser();
|
| | | }
|
| | |
|
| | | public List<Map<String, Object>> countNewUserByDate(Integer type,String years, String startTime, |
| | | @Override
|
| | | public List<Map<String, Object>> countNewUserByDate(String channel,Integer type,String years, String startTime, |
| | | String endTime) throws Exception {
|
| | | return userInfoMapper.countNewUserByDate(type, years, startTime, endTime);
|
| | | return userInfoMapper.countNewUserByDate(channel, type, years, startTime, endTime);
|
| | |
|
| | | }
|
| | |
|
| | | |
| | | 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 total = map.get("total");
|
| | | if (total == null) {
|
| | | map.put("payMoney", 0);
|
| | | }
|
| | | listObject.add(map);
|
| | | return listObject;
|
| | | }
|
| | | @Override
|
| | | public List<Map<String, Object>> getTodayBuyRate(String channel,Integer type,String years, String startTime, |
| | | String endTime) throws Exception {
|
| | | |
| | | List<Map<String, Object>> todayNum = |
| | | userInfoMapper.getTodayHasOrder(channel, type, years, startTime, endTime);
|
| | |
|
| | |
|
| | | 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 total = 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)) {
|
| | | total = map.get("total");
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (total == null) {
|
| | | total = 0;
|
| | | }
|
| | | mapObject.put("total", total);
|
| | | |
| | | 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;
|
| | | return todayNum;
|
| | | |
| | | |
| | | |
| | | |
| | | }
|
| | |
|
| | |
|
| | | 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 total = 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)) {
|
| | | total = map.get("total");
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (total == null) {
|
| | | total = 0;
|
| | | }
|
| | | mapObject.put("total", total);
|
| | | |
| | | 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 total = map.get("total");
|
| | | |
| | | if (total == null) {
|
| | | total = 0;
|
| | | }
|
| | | map.put("total", total);
|
| | | |
| | | listObject.add(map);
|
| | | }
|
| | | |
| | | return listObject;
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | 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 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;
|
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
|
| | | @Service
|
| | | public class UserActiveLogServiceImpl implements UserActiveLogService {
|
| | |
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<Map<String, Object>> countSameDayByChannel(String channel, Integer type, String years,
|
| | | String startTime, String endTime) throws Exception{
|
| | | return userActiveLogMapper.countSameDayByChannel(channel, type, years, startTime, endTime);
|
| | | }
|
| | | |
| | | @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<Map<String, Object>> countOneWeekUserInfo(String channel, String startTime, String endTime, |
| | | Integer orderNumber) throws Exception {
|
| | | |
| | | // 时间列表
|
| | | List<String> dateList = new ArrayList<String>();
|
| | | // 结果列表
|
| | | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>();
|
| | | |
| | | String middleDay = "";
|
| | | for (int i = 0; i < 100 ; i++) {
|
| | | if (i == 0) {
|
| | | middleDay = startTime;
|
| | | } else {
|
| | | middleDay = DateUtil.plusDay(i, startTime);
|
| | | }
|
| | | |
| | | dateList.add(middleDay);
|
| | | |
| | | if (middleDay.equals(endTime)) {
|
| | | break; // 时间结束
|
| | | }
|
| | | }
|
| | | |
| | | for (String nowDate: dateList) {
|
| | | // 加入7天
|
| | | String plusDay = DateUtil.plusDay(7, nowDate);
|
| | | |
| | | // 执行查询 并返回结果
|
| | | Map<String, BigDecimal> map= userActiveLogMapper.countOneWeekUserInfo(channel, nowDate, plusDay, orderNumber);
|
| | | |
| | | // 比例
|
| | | BigDecimal proportion = null;
|
| | | |
| | | if (map != null) {
|
| | | // 新增用户
|
| | | BigDecimal totalUser = map.get("totalUser");
|
| | | // 存在订单的新增用户
|
| | | BigDecimal orderUser = map.get("orderUser");
|
| | | |
| | | try {
|
| | | proportion = MoneyBigDecimalUtil.sub(orderUser, totalUser);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | if (proportion == null) {
|
| | | proportion = new BigDecimal(0);
|
| | | }
|
| | | |
| | | Map<String, Object> result = new HashMap<String, Object>();
|
| | | result.put("showValue", MoneyBigDecimalUtil.mul(proportion, new BigDecimal(100)));
|
| | | result.put("showDate", nowDate);
|
| | | |
| | | resultList.add(result);
|
| | | }
|
| | | |
| | | return resultList;
|
| | | |
| | | }
|
| | |
|
| | |
|
| | | @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;
|
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 天数格式
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @param list
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | 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("showValue");
|
| | | |
| | | if (sameDayNum == null) {
|
| | | map.put("showValue", 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("showDate");
|
| | | String month = createDate.toString();
|
| | | if (plusDay.equalsIgnoreCase(month)) {
|
| | | sameDayNum = map.get("showValue");
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (sameDayNum == null) {
|
| | | sameDayNum = 0;
|
| | | }
|
| | | mapObject.put("showValue", sameDayNum);
|
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
|
| | | Date parseDate = sdf.parse(plusDay.toString());
|
| | | |
| | | mapObject.put("showDate", sdf2.format(parseDate));
|
| | | |
| | | listObject.add(mapObject);
|
| | | |
| | | if (plusDay.equals(endTime)) {
|
| | | break; // 时间结束
|
| | | }
|
| | | }
|
| | | |
| | | return listObject;
|
| | | }
|
| | | |
| | | /**
|
| | | * 月份格式
|
| | | * @param list
|
| | | * @return
|
| | | */
|
| | | 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("showDate");
|
| | | String month = createDate.toString();
|
| | | if ((i+"").equalsIgnoreCase(month) || i == Integer.parseInt(month)) {
|
| | | sameDayNum = map.get("showValue"); |
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (sameDayNum == null) {
|
| | | sameDayNum = 0;
|
| | | }
|
| | | mapObject.put("showValue", sameDayNum);
|
| | | |
| | | mapObject.put("showDate", i + "月");
|
| | | |
| | | listObject.add(mapObject);
|
| | | }
|
| | | return listObject;
|
| | | }
|
| | | |
| | | /**
|
| | | * 年份格式
|
| | | * @param list
|
| | | * @return
|
| | | */
|
| | | 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("showValue"); |
| | | Object createDate = map.get("showDate"); |
| | | |
| | | if (sameDayNum == null) {
|
| | | sameDayNum = 0;
|
| | | }
|
| | | map.put("showValue", sameDayNum);
|
| | | map.put("showDate", createDate + "年");
|
| | | |
| | | listObject.add(map);
|
| | | }
|
| | | |
| | | return listObject;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | * @return
|
| | | */
|
| | | public Date getLastHongBaoTime(Long uid);
|
| | |
|
| | | public List<Map<String, Object>> count24HOderByChannel(String channel, Integer type, String years, String startTime,
|
| | | String endTime) throws Exception;
|
| | |
|
| | | /**
|
| | | * 统计所有类型订单数量
|
| | | * @param dateType
|
| | | * @param type
|
| | | * @param year
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public List<Map<String, Object>> countHongBaoType(Integer dateType, Integer type, String year, String startTime,
|
| | | String endTime) throws Exception;
|
| | |
|
| | | }
|
| | |
| | | * 统计新增用户
|
| | | * @return
|
| | | */
|
| | | public List<Map<String, Object>> countNewUserByDate(Integer type,String years, String startTime, String endTime) throws Exception;
|
| | | public List<Map<String, Object>> countNewUserByDate(String channel,Integer type,String years, String startTime, String endTime) throws Exception;
|
| | |
|
| | | |
| | | public List<Map<String, Object>> getTodayBuyRate(String channel, Integer type, String years, String startTime,
|
| | | String endTime) throws Exception;
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.user;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog;
|
| | |
|
| | | /**
|
| | |
| | | * @return
|
| | | */
|
| | | public UserActiveLog getUserLatestActiveInfo(Long uid);
|
| | |
|
| | | /**
|
| | | * 根据渠道 统计当日新增用户数量
|
| | | * @param channel
|
| | | * @return
|
| | | */
|
| | | public List<Map<String, Object>> countSameDayByChannel(String channel, Integer type, String years, |
| | | String startTime, String endTime) throws Exception;
|
| | | /**
|
| | | * 根据渠道 统计当日新增用户有购买行为的数量
|
| | | * @param channel
|
| | | * @return
|
| | | */
|
| | | public List<Object> countSameDayAndBuyGoodsByChannel(String channel, Integer type, String years, String startTime,
|
| | | String endTime) throws Exception;
|
| | |
|
| | | /**
|
| | | * 当日产生订单的新增用户 与 当日总新增用户比例
|
| | | * @param channel
|
| | | * @param type
|
| | | * @param years
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public List<Object> getBuyProportion(String channel, Integer type, String years, String startTime, String endTime,Integer orderNum)
|
| | | throws Exception;
|
| | |
|
| | |
|
| | | public List<Map<String, Object>> countOneWeekUserInfo(String channel, String startTime, String endTime, Integer orderNumber)
|
| | | throws Exception;
|
| | |
|
| | | }
|