| | |
| | |
|
| | |
|
| | | /**
|
| | | * 统计当天新增用户24小时内产生的订单
|
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param channel 渠道名称 如:VIVO
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "get24HOderByChannel")
|
| | | public void get24HOderByChannel(String callback, Integer pageIndex, Integer pageSize, |
| | | String channelArray, PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | try {
|
| | | |
| | | if (StringUtil.isNullOrEmpty(channelArray)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Gson gson = new Gson();
|
| | | List<String> list = gson.fromJson(channelArray, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | |
| | | // List<Map<String, Object>> list = hongBaoService.count24HOderByChannel((pageIndex - 1) * pageSize, pageSize, channel);
|
| | | //
|
| | | // if (list == null || list.size() == 0) {
|
| | | // JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | // return;
|
| | | // }
|
| | | // |
| | | // JSONObject data = new JSONObject();
|
| | | // data.put("pe", pe);
|
| | | // data.put("result_list", list);
|
| | |
|
| | | // JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | |
| | | /**
|
| | | * 统计历史渠道产生订单的金额
|
| | | * @param callback
|
| | | * @param channelArray 名字数组
|
| | |
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | |
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestNoLogin;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | |
|
| | | import freemarker.core.ArithmeticEngine.ConservativeEngine;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/upload")
|
| | |
| | | */
|
| | | @RequestNoLogin()
|
| | | @RequestMapping(value = "uploadPicture")
|
| | | public void uploadPicture(@RequestParam("file") CommonsMultipartFile file, Long uid, HttpServletResponse response,
|
| | | public void uploadPicture(@RequestParam("file") CommonsMultipartFile file, HttpServletResponse response,
|
| | | PrintWriter out) {
|
| | |
|
| | | response.setHeader("Access-Control-Allow-Origin", "*");
|
| | | response.setHeader("Access-Control-Allow-Methods", "*");
|
| | |
|
| | | AdminUser admin = adminUserService.selectByPrimaryKey(uid);
|
| | | if (admin == null) {
|
| | | out.print(JsonUtil.loadFalseResult("当前账户验证失败"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (file == null) {
|
| | | out.print(JsonUtil.loadFalseResult("上传文件为空"));
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 上传文件相对位置
|
| | | String fileUrl="/img/admin/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String fileUrl="/img/admin/test/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | |
|
| | | String uploadPath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
|
| | |
|
| | |
| | | @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;
|
| | | }
|
| | | validateParams(callback, channelArray, dateType,year,startTime,endTime,out);
|
| | |
|
| | | if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
|
| | | startTime = null;
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 根据渠道 统计当日新增用户数量
|
| | | * @param channelArray 名字数组
|
| | | * @param dateType 类型 1日 2月 3年
|
| | | * @param year 2018
|
| | | * @param startTime 2018-12-01 |
| | | * @param endTime 2018-12-01 |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getBuyProportion")
|
| | | public void getBuyProportion(String callback, String channelArray, Integer dateType, |
| | | String year, String startTime, String endTime, PrintWriter out) {
|
| | | |
| | | validateParams(callback, channelArray, dateType,year,startTime,endTime,out);
|
| | | |
| | | 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.getBuyProportion(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();
|
| | | }
|
| | | }
|
| | | |
| | | @RequestMapping(value = "countUser")
|
| | | public void countUser(String callback, PrintWriter out) {
|
| | | try {
|
| | | // 总用户
|
| | | long totalUser = userInfoCountService.countNewUser(null, null);
|
| | | // 流失用户数量(180天未使用登录并且无任何资金流动的账号数量)
|
| | | long loseUser = userInfoCountService.countLoseUser(180);
|
| | | // 累计有购买用户数
|
| | | long orderUser = userInfoCountService.countHasOrderUser();
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("totalUser", totalUser);
|
| | | data.put("loseUser", loseUser);
|
| | | data.put("orderUser", orderUser);
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | 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 = "getHistoryNewUser")
|
| | | public void getHistoryNewUser(String callback, Integer dateType, String year, String startTime,
|
| | | String endTime, PrintWriter out) {
|
| | | |
| | | 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 {
|
| | |
|
| | | List<Object> resultList = userInfoCountService.countNewUserByDate(dateType, year, startTime, endTime);
|
| | |
|
| | | if (resultList == null) {
|
| | | resultList = new ArrayList<Object>();
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("result_list", resultList);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | public void validateParams(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;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | */ |
| | | List<Long> longTimeNoLogin(@Param("daysNum") int daysNum, @Param("list") List<Long> list); |
| | | |
| | | /** |
| | | * 统计流失用户数量:( num 天未使用登录并且无任何资金流动的账号数量) |
| | | * @param num 180 |
| | | * @return |
| | | */ |
| | | long countLoseUser(@Param("num") int num); |
| | | |
| | | |
| | | /** |
| | | * 累计有购买用户数 |
| | | * @return |
| | | */ |
| | | long countHasOrderUser(); |
| | | |
| | | |
| | | /** |
| | | * 统计新增用户 |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> countNewUserByDate(@Param("type")Integer type, @Param("years") String years, |
| | | @Param("startTime")String startTime, @Param("endTime")String endTime); |
| | | } |
| | |
| | | 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); |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.interceptor;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | |
|
| | | import javax.servlet.http.Cookie;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.web.servlet.ModelAndView;
|
| | | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
| | |
|
| | | public class CommonInterceptor extends HandlerInterceptorAdapter {
|
| | |
|
| | |
|
| | | /**
|
| | | * 在业务处理器处理请求之前被调用 如果返回false 从当前的拦截器往回执行所有拦截器的afterCompletion(),再退出拦截器链
|
| | | * |
| | | * 如果返回true 执行下一个拦截器,直到所有的拦截器都执行完毕 再执行被拦截的Controller 然后进入拦截器链, 从最后一个拦截器往回执行所有的postHandle()
|
| | | * 接着再从最后一个拦截器往回执行所有的afterCompletion()
|
| | | */
|
| | | @Override
|
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) |
| | | throws Exception {
|
| | |
|
| | | String id = request.getSession().getId();
|
| | | System.out.println("------start:" + id);
|
| | | |
| | | |
| | | String origin = request.getHeader("Origin");
|
| | | response.setHeader("Access-Control-Allow-Origin", origin);
|
| | | response.setHeader("Access-Control-Allow-Methods", "*");
|
| | | response.setHeader("Access-Control-Allow-Credentials","true");
|
| | | response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
| | | |
| | | String method = request.getMethod();
|
| | | System.out.println("-----method--------" + method);
|
| | | if ("OPTIONS".equalsIgnoreCase(method)) {
|
| | | |
| | | System.out.println("------OPTIONS:");
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("code", 200);
|
| | | object.put("msg", "OPTIONS成功");
|
| | | |
| | | PrintWriter writer = response.getWriter();
|
| | | writer.print(object);
|
| | | return false;
|
| | | }
|
| | | |
| | | return true;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 在业务处理器处理请求执行完成后,生成视图之前执行的动作 可在modelAndView中加入数据,比如当前时间
|
| | | */
|
| | | @Override
|
| | | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
|
| | | ModelAndView modelAndView) throws Exception {
|
| | | }
|
| | |
|
| | | /**
|
| | | * 在DispatcherServlet完全处理完请求后被调用,可用于清理资源等 当有拦截器抛出异常时,会从当前拦截器往回执行所有的拦截器的afterCompletion()
|
| | | */
|
| | | @Override
|
| | | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, |
| | | Exception ex)
|
| | | throws Exception {
|
| | | }
|
| | | }
|
| | |
| | | </select> |
| | | |
| | | |
| | | <select id="countLoseUser" resultType="java.lang.Long"> |
| | | SELECT COUNT(DISTINCT t.`id` ) FROM `yeshi_ec_user` t |
| | | LEFT JOIN `yeshi_ec_user_money_detail` d ON d.`umd_uid` = t.`id` |
| | | WHERE DATE_SUB(CURDATE(), INTERVAL ${num} DAY) > DATE(FROM_UNIXTIME( t.`last_logintime`/1000)) |
| | | AND DATE_SUB(CURDATE(), INTERVAL ${num} DAY) > DATE(d.`umd_createtime`) |
| | | </select> |
| | | |
| | | <select id="countHasOrderUser" resultType="java.lang.Long"> |
| | | SELECT COUNT(DISTINCT h.`uid`) FROM yeshi_ec_hongbao h |
| | | WHERE h.`type`=1 OR h.`type`=20 |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="countNewUserByDate" resultType="java.util.HashMap"> |
| | | SELECT COUNT(h.`id`) AS total, |
| | | <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_user h |
| | | WHERE 1=1 |
| | | <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> |
| | |
| | | |
| | | ORDER BY u.`createtime` |
| | | </select> |
| | | |
| | | <select id="countSameDayAndBuyGoodsByChannel" resultType="java.util.HashMap"> |
| | | SELECT COALESCE(COUNT(DISTINCT u.`id`),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 |
| | | LEFT JOIN `yeshi_ec_hongbao` h ON h.`uid`= u.`id` |
| | | WHERE (h.`type`=1 OR h.`type`=20) |
| | | AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = FROM_UNIXTIME(h.createtime/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> |
| | | </mapper> |
| | |
| | | package com.yeshi.fanli.service.impl.count;
|
| | |
|
| | |
|
| | | 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.UserInfoMapper;
|
| | | import com.yeshi.fanli.service.inter.count.UserInfoCountService;
|
| | |
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public long countLoseUser(int daysNum) {
|
| | | return userInfoMapper.countLoseUser(daysNum);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countHasOrderUser() {
|
| | | return userInfoMapper.countHasOrderUser();
|
| | | }
|
| | | |
| | | public List<Object> countNewUserByDate(Integer type,String years, String startTime, |
| | | String endTime) throws Exception {
|
| | | List<Map<String, Object>> list = userInfoMapper.countNewUserByDate(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 total = map.get("total");
|
| | | if (total == null) {
|
| | | map.put("payMoney", 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 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;
|
| | | }
|
| | | |
| | | |
| | | 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;
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
| | | if (commision == null) {
|
| | | commision = 0;
|
| | | }
|
| | | map.put("commision", commision + "年");
|
| | | |
| | | map.put("commision", commision);
|
| | |
|
| | | listObject.add(map);
|
| | | }
|
| | |
| | | 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;
|
| | | }
|
| | | |
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.count;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | |
|
| | |
|
| | | public interface UserInfoCountService {
|
| | |
| | | */
|
| | | public double countAllMoney(Double minMoney);
|
| | |
|
| | | /**
|
| | | * 统计流失用户数量:( num 天未使用登录并且无任何资金流动的账号数量)
|
| | | * @param num 180
|
| | | * @return
|
| | | */
|
| | | public long countLoseUser(int daysNum);
|
| | |
|
| | | /**
|
| | | * 累计有购买用户数
|
| | | * @return
|
| | | */
|
| | | public long countHasOrderUser();
|
| | |
|
| | |
|
| | | /**
|
| | | * 统计新增用户
|
| | | * @return
|
| | | */
|
| | | public List<Object> countNewUserByDate(Integer type,String years, String startTime, String endTime) throws Exception;
|
| | | }
|
| | |
| | | */
|
| | | public UserActiveLog getUserLatestActiveInfo(Long uid);
|
| | |
|
| | |
|
| | | /**
|
| | | * 根据渠道 统计当日新增用户数量
|
| | | * @param channel
|
| | | * @return
|
| | | */
|
| | | public List<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)
|
| | | throws Exception;
|
| | |
|
| | | }
|
| | |
| | | <mvc:interceptors>
|
| | | <!-- 使用bean定义一个Interceptor,直接定义在mvc:interceptors根下面的Interceptor将拦截所有的请求 -->
|
| | | <bean class="com.yeshi.fanli.interceptor.EncodingInterceptor" />
|
| | | <bean class="com.yeshi.fanli.interceptor.CommonInterceptor" />
|
| | | </mvc:interceptors>
|
| | |
|
| | | <task:annotation-driven scheduler="qbScheduler"
|