From c6232cfc36e373f83f45c95d400e09466cc2a7d3 Mon Sep 17 00:00:00 2001 From: yanghui <2536613402@qq.com> Date: 星期五, 14 十月 2022 17:41:45 +0800 Subject: [PATCH] #feat 修改运营平台统计登录人数和新增人员 --- springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java | 68 ++++++++++++++++++++++++++-------- 1 files changed, 52 insertions(+), 16 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java index dabbc24..1897a3e 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java @@ -141,13 +141,17 @@ // String encode = new BCryptPasswordEncoder().encode("lbsq123456"); // System.out.println(encode); - List<String> dates = new ArrayList<>(); +// List<String> dates = new ArrayList<>(); +// Date date = new Date(); +// for (int i = 19; i >= 0; i--) { +// Date date1 = DateUtils.addDays(date, -i); +// dates.add(DateFormatUtils.format(date1, "MM-dd")); +// } +// System.out.println(dates); + Date date = new Date(); - for (int i = 19; i >= 0; i--) { - Date date1 = DateUtils.addDays(date, -i); - dates.add(DateFormatUtils.format(date1, "MM-dd")); - } - System.out.println(dates); + Long offset = DateUtil.between(new Date(), DateUtil.beginOfMonth(date), DateUnit.DAY); + System.out.println(offset); // BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); // boolean matches = encoder.matches("admin1234567", encode); @@ -3180,7 +3184,7 @@ } else if ("wx98d62711dfbd8425".equals(uuLoginVO.getAppid())) { appId = "10001"; secret = "d89f3a35931c386956c1a402a8e09941"; - }else { + } else { return R.fail("appid未传"); } uuLoginVO.setAppid(appId); @@ -3193,7 +3197,7 @@ } Map<String, String> headerMap = new HashMap<>(); headerMap.put("appid", appId); - String resultJson = HttpClientUtil.get("https://api.uucsh.cn/member/wx/get-access?province=" + uuLoginVO.getProvince() + "&city=" + uuLoginVO.getCity() + "&area=" + uuLoginVO.getArea() + "&appid="+appId+"×tamp=" + uuLoginVO.getTimestamp() + "&sign=" + uuLoginVO.getSign() + "&mobile=" + uuLoginVO.getMobile() + "&couponId=" + uuLoginVO.getCouponId(), headerMap, null); + String resultJson = HttpClientUtil.get("https://api.uucsh.cn/member/wx/get-access?province=" + uuLoginVO.getProvince() + "&city=" + uuLoginVO.getCity() + "&area=" + uuLoginVO.getArea() + "&appid=" + appId + "×tamp=" + uuLoginVO.getTimestamp() + "&sign=" + uuLoginVO.getSign() + "&mobile=" + uuLoginVO.getMobile() + "&couponId=" + uuLoginVO.getCouponId(), headerMap, null); JSONObject result = JSON.parseObject(resultJson); if (result.get("status").equals(1)) { return R.ok(result.get("data")); @@ -3420,25 +3424,56 @@ return R.ok(realUserVO); } +// @Override +// public R userActivity(Integer type, Long streetId, Long areaCode, Integer range, String appId) { +// UserActivityAnalysisVO vo = new UserActivityAnalysisVO(); +// List<Date> activeX = getTwentyDays(); +// List<String> activeY = new ArrayList<>(); +// List<String> adY = new ArrayList<>(); +// if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(range)) { +// if (range.equals(1)) { +// //本月数据 +// activeX = getMonthTwentyDays(); +// } +// } +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// for (Date date : activeX) { +// Map<String, Long> map = userDao.getDailyAddAndActive(DateUtil.parse(sdf.format(date)), streetId, areaCode, appId); +// adY.add(map.get("addUser").toString()); +// activeY.add(map.get("activeUser").toString()); +// } +// vo.setUserX(getMAndD(activeX)); +// vo.setAddUserY(adY); +// vo.setActiveUserY(activeY); +// return R.ok(vo); +// } + @Override public R userActivity(Integer type, Long streetId, Long areaCode, Integer range, String appId) { UserActivityAnalysisVO vo = new UserActivityAnalysisVO(); - List<Date> activeX = getTwentyDays(); + String activeX = com.panzhihua.common.utlis.DateUtils.getTwentyDay(); + List<Date> activeDate = getTwentyDays(); List<String> activeY = new ArrayList<>(); List<String> adY = new ArrayList<>(); if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(range)) { if (range.equals(1)) { //本月数据 - activeX = getMonthTwentyDays(); + activeX = com.panzhihua.common.utlis.DateUtils.getMonthTwentyDay(); + activeDate = getMonthTwentyDays(); } } - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - for (Date date : activeX) { - Map<String, Long> map = userDao.getDailyAddAndActive(DateUtil.parse(sdf.format(date)), streetId, areaCode, appId); - adY.add(map.get("addUser").toString()); - activeY.add(map.get("activeUser").toString()); + + //获取最近活跃人数 + Map<String, Long> active = userDao.getActive(activeX, streetId, areaCode, appId); + //获取最近注册人数 + Map<String, Long> dailyAdd = userDao.getDailyAdd(activeX, streetId, areaCode, appId); + for (Date date : activeDate) { + String dateStr = DateUtil.format(date, "yyyy-MM-dd"); + activeY.add(active.containsKey(dateStr) ? active.get("activeUser").toString() : "0"); + adY.add(dailyAdd.containsKey(dateStr) ? dailyAdd.get("addUser").toString() : "0"); + } - vo.setUserX(getMAndD(activeX)); + vo.setUserX(getMAndD(activeDate)); vo.setAddUserY(adY); vo.setActiveUserY(activeY); return R.ok(vo); @@ -3683,6 +3718,7 @@ return dates; } + /** * 获取最近本月20天数据 * -- Gitblit v1.7.1