yanghui
2022-10-17 6b5816393c74dc6b518e67db8b8693aee61ffec4
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java
@@ -46,6 +46,7 @@
import com.panzhihua.service_user.entity.SysTemplateConfig;
import com.panzhihua.service_user.model.dos.*;
import com.panzhihua.service_user.model.dtos.DataKanbanDTO;
import com.panzhihua.service_user.model.dtos.UsersStatisticsDTO;
import com.panzhihua.service_user.service.EventGridMemberBuildingRelationService;
import com.panzhihua.service_user.service.UserService;
import lombok.extern.slf4j.Slf4j;
@@ -141,13 +142,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 +3185,7 @@
        } else if ("wx98d62711dfbd8425".equals(uuLoginVO.getAppid())) {
            appId = "10001";
            secret = "d89f3a35931c386956c1a402a8e09941";
        }else {
        } else {
            return R.fail("appid未传");
        }
        uuLoginVO.setAppid(appId);
@@ -3193,7 +3198,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+"&timestamp=" + 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 + "&timestamp=" + 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 +3425,59 @@
        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());
        //获取最近活跃人数
        List<UsersStatisticsDTO> actives = userDao.getActive(activeX, streetId, areaCode, appId);
        //获取最近注册人数
        List<UsersStatisticsDTO> dailyAdds = userDao.getDailyAdd(activeX, streetId, areaCode, appId);
        Map<String, String> activeMap = actives.stream().collect(Collectors.toMap(UsersStatisticsDTO::getSpecificDate, UsersStatisticsDTO::getTotal));
        Map<String, String> dailyAddMap = dailyAdds.stream().collect(Collectors.toMap(UsersStatisticsDTO::getSpecificDate, UsersStatisticsDTO::getTotal));
        for (Date date : activeDate) {
            String dateStr = DateUtil.format(date, "yyyy-MM-dd");
            activeY.add(activeMap.containsKey(dateStr) ? activeMap.get(dateStr) : "0");
            adY.add(dailyAddMap.containsKey(dateStr) ? dailyAddMap.get(dateStr) : "0");
        }
        vo.setUserX(getMAndD(activeX));
        vo.setUserX(getMAndD(activeDate));
        vo.setAddUserY(adY);
        vo.setActiveUserY(activeY);
        return R.ok(vo);
@@ -3496,19 +3535,19 @@
                switch (orderStatus) {
                    case 3:
                        status = "已分配车美";
                        WxUtil.sendUuWash3(sysUserDO.getOpenid(), accessToken, status, washName, washPhone, phone, "sNj6m-JBvW6rOokKGDX9X3-XH1AD0GY5_X0jA9JSLwc");
                        WxUtil.sendWsWash3(sysUserDO.getOpenid(), accessToken, status, washName, washPhone, phone, "sNj6m-JBvW6rOokKGDX9X3-XH1AD0GY5_X0jA9JSLwc");
                        break;
                    case 4:
                        status = "车美已开始服务";
                        WxUtil.sendUuWash4(sysUserDO.getOpenid(), accessToken, status, washName, washPhone, phone, "Eft5ksvsnOQANy2uNOGY43CC3pb33eDGA_lgCEoxuiw");
                        WxUtil.sendWsWash4(sysUserDO.getOpenid(), accessToken, status, washName, washPhone, phone, "Eft5ksvsnOQANy2uNOGY43CC3pb33eDGA_lgCEoxuiw");
                        break;
                    case 6:
                        status = "订单确认完成";
                        WxUtil.sendUuWash6(sysUserDO.getOpenid(), accessToken, status, washName, washPhone, phone, "iPS8yrsGDqy76hiP8bIbxkosveoX1xTFhdusSiGp-XM");
                        WxUtil.sendWsWash6(sysUserDO.getOpenid(), accessToken, status, washName, washPhone, phone, "iPS8yrsGDqy76hiP8bIbxkosveoX1xTFhdusSiGp-XM");
                        break;
                    case 9:
                        status = "订单已取消";
                        WxUtil.sendUuWash(sysUserDO.getOpenid(), accessToken, status, washName, washPhone, phone, "z_ysGXz9JWBc2rXuYZzVCXKJTyLf0w0WerrohuNoEng");
                        WxUtil.sendWsWash(sysUserDO.getOpenid(), accessToken, status, washName, washPhone, phone, "z_ysGXz9JWBc2rXuYZzVCXKJTyLf0w0WerrohuNoEng");
                        break;
                }
            }
@@ -3683,6 +3722,7 @@
        return dates;
    }
    /**
     * 获取最近本月20天数据
     *