From 28cf328a098334b51a3e9d2d56f983fb8c862211 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 23 五月 2020 09:54:38 +0800 Subject: [PATCH] 足迹、收藏订单兼容新需求 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java | 499 +++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 391 insertions(+), 108 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java index acdc267..6844eb2 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java @@ -25,6 +25,7 @@ import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum; import com.yeshi.fanli.entity.bus.user.TeamFansInfo; import com.yeshi.fanli.entity.bus.user.ThreeSale; +import com.yeshi.fanli.entity.bus.user.ThreeSaleDetail; import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo; import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; @@ -32,7 +33,7 @@ import com.yeshi.fanli.entity.bus.user.UserInviteValidNum; import com.yeshi.fanli.entity.bus.user.UserInviteValidRecord; import com.yeshi.fanli.entity.bus.user.WeiXinUser; -import com.yeshi.fanli.entity.bus.user.vip.TeamDailyRecord; +import com.yeshi.fanli.entity.bus.user.invite.TeamDailyRecord; import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic; import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo; import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; @@ -55,6 +56,7 @@ import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.invite.TeamDailyRecordService; import com.yeshi.fanli.service.inter.user.invite.TeamFansInfoService; +import com.yeshi.fanli.service.inter.user.invite.ThreeSaleDetailService; import com.yeshi.fanli.service.inter.user.invite.ThreeSaleExtraInfoSerivce; import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; import com.yeshi.fanli.service.inter.user.invite.UserInviteService; @@ -74,6 +76,7 @@ import com.yeshi.fanli.util.annotation.RequestSerializableByKey; import com.yeshi.fanli.util.user.UserLevelUtil; import com.yeshi.fanli.util.wx.WXLoginUtil; +import com.yeshi.fanli.vo.order.OrderRankingVO; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -150,8 +153,9 @@ @Resource private TeamDailyRecordService teamDailyRecordService; - - + + @Resource + private ThreeSaleDetailService threeSaleDetailService; /** * 閭�璇风爜楠岃瘉 @@ -477,7 +481,7 @@ object.put("level", level.name()); object.put("validFans", validFans); - if (wxtip && type == 1 && threeSale.getState() != null && threeSale.getState()) { + if (wxtip) { // 涓�绾ч槦鍛� 鏌ヨ鏄电О澶囨敞 String memoName = null; ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo(); @@ -488,7 +492,7 @@ } object.put("memoName", memoName); - if (!VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) { + if (type == 1 && !VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) { // 娣诲姞寰俊淇℃伅 if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) { object.put("weiXin", userInfoExtra.getWeiXin()); @@ -867,7 +871,7 @@ listId.add(focusInfo.getWorkerId()); } } - + if (listId != null && listId.size() > 0) { if (type == 1) { listTeam = threeSaleSerivce.listFirstTeam(0, Constant.PAGE_SIZE, uid, listId); @@ -879,34 +883,36 @@ countSecond = teamFansInfoService.count(2, uid, focus); } JSONArray array = organizeTeamNew(acceptData, listTeam, uid, type, true); - + long count = (type == 1) ? firstTeam : countSecond; - + JSONObject result = new JSONObject(); result.put("firstTeam", firstTeam); result.put("secondTeam", countSecond); result.put("count", count); result.put("list", array); - + // 缁熻H5閾炬帴 if (page == 1) { result.put("link", configService.get(ConfigKeyEnum.teamStatisticsLink.getKey())); } out.print(JsonUtil.loadTrueResult(result)); } - + /** * 楠岃瘉鏄惁瀛樺湪绛涢�夋潯浠� + * * @param focus * @return */ private boolean existScreen(ThreeSaleFocusDTO focus) { if (focus.getStateValid() != null || focus.getTaobaoBind() != null || focus.getWeixinBind() != null - || focus.getMinFansNum() != null || focus.getMinFansNum() != null - || focus.getMinActiveTime() != null || focus.getMaxActiveTime() != null - || focus.getMinIncome() != null || focus.getMaxIncome() != null || !StringUtil.isNullOrEmpty(focus.getKey())) - return true; - + || focus.getMinFansNum() != null || focus.getMinFansNum() != null || focus.getMinActiveTime() != null + || focus.getMaxActiveTime() != null || focus.getMinIncome() != null || focus.getMaxIncome() != null + || focus.getMinJoinTime() != null || focus.getMaxJoinTime() != null + || !StringUtil.isNullOrEmpty(focus.getKey()) || !StringUtil.isNullOrEmpty(focus.getLevel())) + return true; + return false; } @@ -995,32 +1001,74 @@ highVIP.put("total", statistic.getHighFirstCount() + statistic.getHighSecondCount()); superVIP.put("total", statistic.getSuperFirstCount() + statistic.getSuperSecondCount()); } - // 缁熻杈句汉 - long darenToday = threeSaleSerivce.countFirstTeamByDate(uid, 1) + threeSaleSerivce.countSecondTeamByDate(uid, 1); - long darenMonth = threeSaleSerivce.countFirstTeamByDate(uid, 2) + threeSaleSerivce.countSecondTeamByDate(uid, 2); + + int darenToday = 0; + int highVIPToday = 0; + int superVIPToday = 0; + String createId = teamDailyRecordService.createId(uid, new Date()); + TeamDailyRecord record = teamDailyRecordService.getById(createId); + if (record != null) { + if (record.getFirstDaRen() != null) + darenToday += record.getFirstDaRen(); + if (record.getSecondDaRen() != null) + darenToday += record.getSecondDaRen(); + if (record.getFirstHighVIP() != null) + highVIPToday += record.getFirstHighVIP(); + if (record.getSecondHighVIP() != null) + highVIPToday += record.getSecondHighVIP(); + if (record.getFirstSuperVIP() != null) + superVIPToday += record.getFirstSuperVIP(); + if (record.getSecondSuperVIP() != null) + superVIPToday += record.getSecondSuperVIP(); + } + + // 鑾峰彇褰撴湀绗竴澶╁拰鏈�鍚庝竴澶� + Calendar cale = Calendar.getInstance(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String firstday, lastday; + // 鑾峰彇鍓嶆湀鐨勭涓�澶� + cale = Calendar.getInstance(); + cale.add(Calendar.MONTH, 0); + cale.set(Calendar.DAY_OF_MONTH, 1); + firstday = format.format(cale.getTime()); + // 鑾峰彇鍓嶆湀鐨勬渶鍚庝竴澶� + cale = Calendar.getInstance(); + cale.add(Calendar.MONTH, 1); + cale.set(Calendar.DAY_OF_MONTH, 0); + lastday = format.format(cale.getTime()); + + int darenMonth = 0; + int highVIPMonth = 0; + int superVIPMonth = 0; + Date date = new Date(); + Date minTime = TimeUtil.parseYYYYMMDD(firstday); + Date maxTime = TimeUtil.parseYYYYMMDD_HHMMSS(lastday + " 23:59:59"); + List<TeamDailyRecord> listMonth = teamDailyRecordService.sumGroupByYearMonth(uid, minTime, maxTime); + if (listMonth != null && listMonth.size() > 0) { + TeamDailyRecord teamRecord = listMonth.get(0); + if (teamRecord.getFirstDaRen() != null) + darenMonth += teamRecord.getFirstDaRen(); + if (teamRecord.getSecondDaRen() != null) + darenMonth += teamRecord.getSecondDaRen(); + if (teamRecord.getFirstHighVIP() != null) + highVIPMonth += teamRecord.getFirstHighVIP(); + if (teamRecord.getSecondHighVIP() != null) + highVIPMonth += teamRecord.getSecondHighVIP(); + if (teamRecord.getFirstSuperVIP() != null) + superVIPMonth += teamRecord.getFirstSuperVIP(); + if (teamRecord.getSecondSuperVIP() != null) + superVIPMonth += teamRecord.getSecondSuperVIP(); + } + // 杈句汉 daren.put("today", darenToday); daren.put("month", darenMonth); - - SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); - String today = sd.format(new Date()); - // 褰撴湀1鍙� - Calendar calendar1 = Calendar.getInstance(); - calendar1.set(Calendar.DAY_OF_MONTH, 1); - Date minTime = sd.parse(sd.format(calendar1.getTime())); - - int highVIPToday = 0; - int highVIPMonth = 0; - // TODO 缁熻楂樼骇浼氬憳鏁伴噺 + // 楂樼骇浼氫細鍛� highVIP.put("today", highVIPToday); highVIP.put("month", highVIPMonth); - - - int superVIPToday = 0; - int superVIPMonth = 0; - // 缁熻瓒呯骇浼氬憳鏁伴噺 + // 缁熻瓒呯骇浼氬憳鏁伴噺 superVIP.put("today", superVIPToday); superVIP.put("month", superVIPMonth); - + json.put("daren", daren); json.put("highVIP", highVIP); json.put("superVIP", superVIP); @@ -1059,10 +1107,15 @@ return; } - // 涓婄骇 - UserInfo boss = userInfoService.selectByPKey(threeSale.getBoss().getId()); - - + // 闈炵洿鎺ラ個璇峰叧绯� + String bossNickName = null; + if (uid.longValue() != threeSale.getBoss().getId().longValue()) { + UserInfo boss = userInfoService.selectByPKey(threeSale.getBoss().getId()); + if (boss != null) { + bossNickName = boss.getNickName(); + } + } + JSONArray tagArray = new JSONArray(); String memoName = user.getNickName(); Long succeedTime = threeSale.getSucceedTime(); @@ -1079,7 +1132,7 @@ } } - data.put("bossNickName", boss.getNickName()); + data.put("bossNickName", bossNickName); data.put("nickName", user.getNickName()); data.put("phone", phone); data.put("phoneCopy", phoneCopy); @@ -1105,11 +1158,11 @@ weixin = userInfoExtra.getWeiXin(); activeTime = userInfoExtra.getActiveTime(); } - + if (activeTime == null) { activeTime = new Date(user.getCreatetime()); } - + data.put("weixin", StringUtil.isNullOrEmpty(weixin) ? "" : weixin); data.put("loginTime", TimeUtil.formatDate(activeTime)); @@ -1121,13 +1174,11 @@ data.put("taobao", false); } - String levelName = null; UserVIPPreInfo userVIPPreInfo = userVIPPreInfoService.getLatestProcessInfo(workerId); if (userVIPPreInfo != null) { + String levelName = null; Integer process = userVIPPreInfo.getProcess(); - if (process == UserVIPPreInfo.PROCESS_1) { - levelName = "蹇渷杈句汉"; - } else if (process == UserVIPPreInfo.PROCESS_2) { + if (process == UserVIPPreInfo.PROCESS_2) { levelName = "楂樼骇浼氬憳"; } else if (process == UserVIPPreInfo.PROCESS_3) { levelName = "瓒呯骇浼氬憳"; @@ -1136,18 +1187,14 @@ } Integer sourceType = userVIPPreInfo.getSourceType(); - if (sourceType != null) { + if (sourceType != null && levelName != null) { if (sourceType == UserVIPPreInfo.SOURCE_TYPE_ORDER) { - levelName += "(鑷喘鍒嗕韩鍨�)"; - } else { - levelName += "(閭�璇峰洟闃熷瀷)"; + data.put("level", levelName += "(鑷喘鍒嗕韩鍨�)"); + } else if (sourceType == UserVIPPreInfo.SOURCE_TYPE_TEAM) { + data.put("level", levelName += "(閭�璇峰洟闃熷瀷)"); } } } - if (StringUtil.isNullOrEmpty(levelName)) { - levelName = "蹇渷杈句汉"; - } - data.put("level", levelName); // 绮変笣缁熻 long indirectNum = 0; @@ -1155,18 +1202,193 @@ if (directNum > 0) { indirectNum = threeSaleSerivce.countSecondTeam(workerId); } + // 璁㈠崟缁熻 long countTB = commonOrderCountService.countOrderBySourceAndNearDay(workerId, Constant.SOURCE_TYPE_TAOBAO, 60); long countJD = commonOrderCountService.countOrderBySourceAndNearDay(workerId, Constant.SOURCE_TYPE_JD, 60); long countPDD = commonOrderCountService.countOrderBySourceAndNearDay(workerId, Constant.SOURCE_TYPE_PDD, 60); - data.put("fansNum", "鐩存帴绮変笣锛� "+directNum+"浜篭n" + "闂存帴绮変笣锛� "+indirectNum+"浜�"); - data.put("orderInfo", "娣樺疂 ("+countTB+"绗�)\n" + "浜笢 ("+countJD+"绗�)\n" + "鎷煎澶� ("+countPDD+"绗�)"); + data.put("fansNum", "鐩存帴绮変笣锛� " + directNum + "浜篭n" + "闂存帴绮変笣锛� " + indirectNum + "浜�"); + data.put("orderInfo", "娣樺疂 (" + countTB + "绗�)\n" + "浜笢 (" + countJD + "绗�)\n" + "鎷煎澶� (" + countPDD + "绗�)"); out.print(JsonUtil.loadTrueResult(data)); } /** * 鑾峰彇绮変笣淇℃伅 + * + * @param acceptData + * @param uid + * @param workerId + * @param out + */ + @RequestMapping(value = "fansSearch") + public void fansSearch(String callback, AcceptData acceptData, Long uid, String key, PrintWriter out) { + if (uid == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + + if (StringUtil.isNullOrEmpty(key)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇疯緭鍏ョ瓫閫変俊鎭�")); + return; + } + + List<TeamFansInfo> listfocus = teamFansInfoService.queryByUserInfo(key); + if (listfocus == null || listfocus.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "鏆傛棤鐩稿叧淇℃伅")); + return; + } + + Long fansId = null; + for (TeamFansInfo teamFansInfo : listfocus) { + Long workerId = teamFansInfo.getWorkerId(); + ThreeSaleDetail threeDetail = threeSaleDetailService.getByBossUidAndWorkerUid(uid, workerId); + if (threeDetail != null) { + fansId = workerId; + break; + } + } + + if (fansId == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "鏆傛棤鐩稿叧淇℃伅")); + return; + } + + ThreeSale threeSale = threeSaleSerivce.getByWorkerId(fansId); + if (threeSale == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "鏆傛棤鐩稿叧淇℃伅")); + return; + } + + UserInfo user = userInfoService.selectByPKey(fansId); + if (user == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "鏆傛棤鐩稿叧淇℃伅")); + return; + } + + JSONObject data = new JSONObject(); + JSONObject inviteBoss = getInviteBoss(threeSale.getBoss().getId()); + data.put("boss", inviteBoss); + + String phone = user.getPhone(); + boolean phoneCopy = true; + if (StringUtil.isNullOrEmpty(phone)) { + phone = ""; + } else { + if (!userCustomSettingsService.validateDisplayPhoneByUid(fansId)) { + phoneCopy = false; + phone = phone.substring(0, 7) + "****"; + } + } + + data.put("fansId", fansId); + data.put("nickName", user.getNickName()); + data.put("portrait", user.getPortrait()); + data.put("phone", phone); + data.put("phoneCopy", phoneCopy); + data.put("joinTime", TimeUtil.formatDate(threeSale.getSucceedTime() == null ? threeSale.getCreateTime() : threeSale.getSucceedTime())); + + Date activeTime = null; + String weixin = null; + UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(fansId); + if (userInfoExtra != null) { + weixin = userInfoExtra.getWeiXin(); + activeTime = userInfoExtra.getActiveTime(); + } + + if (activeTime == null) { + activeTime = new Date(user.getCreatetime()); + } + + String inviteCode = ""; + if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) + inviteCode = userInfoExtra.getInviteCode(); + if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip())) + inviteCode = userInfoExtra.getInviteCodeVip(); + + data.put("inviteCode", inviteCode); + data.put("weixin", StringUtil.isNullOrEmpty(weixin) ? "" : weixin); + data.put("loginTime", TimeUtil.formatDate(activeTime)); + + UserExtraTaoBaoInfo userExtraTaoBaoInfo = userExtraTaoBaoInfoService.getByUid(fansId); + if (userExtraTaoBaoInfo != null && !StringUtil.isNullOrEmpty(userExtraTaoBaoInfo.getRelationId()) + && !StringUtil.isNullOrEmpty(userExtraTaoBaoInfo.getSpecialId())) { + data.put("taobao", true); + } else { + data.put("taobao", false); + } + + // 褰撳墠绛夌骇 + UserLevelEnum level = null; + UserVIPLevel vipLevel = userInviteService.getVIPLevelByUid(fansId); + if (vipLevel != null && vipLevel.getLevel() != null) { + level = UserLevelUtil.getByLevel(vipLevel.getLevel()); + } + if (level == null) { + level = UserLevelEnum.daRen; + } + data.put("level", UserLevelUtil.getShowLevel(level)); + + // 绮変笣缁熻 + long indirectNum = 0; + long directNum = threeSaleSerivce.countFirstTeam(fansId); + if (directNum > 0) { + indirectNum = threeSaleSerivce.countSecondTeam(fansId); + } + + // 璁㈠崟缁熻 + long countTB = commonOrderCountService.countOrderBySourceAndNearDay(fansId, Constant.SOURCE_TYPE_TAOBAO, 60); + long countJD = commonOrderCountService.countOrderBySourceAndNearDay(fansId, Constant.SOURCE_TYPE_JD, 60); + long countPDD = commonOrderCountService.countOrderBySourceAndNearDay(fansId, Constant.SOURCE_TYPE_PDD, 60); + + data.put("fansNum", "鐩存帴绮変笣锛� " + directNum + "浜篭n" + "闂存帴绮変笣锛� " + indirectNum + "浜�"); + data.put("orderInfo", "娣樺疂 (" + countTB + "绗�)\n" + "浜笢 (" + countJD + "绗�)\n" + "鎷煎澶� (" + countPDD + "绗�)"); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } + + private JSONObject getInviteBoss(Long bossId) { + UserInfo userInfo = userInfoService.selectByPKey(bossId); + boolean phoneCopy = true; + String phone = userInfo.getPhone(); + if (StringUtil.isNullOrEmpty(phone)) { + phone = ""; + } else { + if (!userCustomSettingsService.validateDisplayPhoneByUid(bossId)) { + phoneCopy = false; + phone = phone.substring(0, 7) + "****"; + } + } + + // 寰俊鍙� + String weixin = ""; + UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(bossId); + if (extra != null) { + weixin = StringUtil.isNullOrEmpty(extra.getWeiXin()) ? "" : extra.getWeiXin(); + } + + // 褰撳墠绛夌骇 + UserLevelEnum level = null; + UserVIPLevel vipLevel = userInviteService.getVIPLevelByUid(bossId); + if (vipLevel != null && vipLevel.getLevel() != null) { + level = UserLevelUtil.getByLevel(vipLevel.getLevel()); + } + if (level == null) { + level = UserLevelEnum.daRen; + } + level = UserLevelUtil.getShowLevel(level); + + JSONObject bossObject = new JSONObject(); + bossObject.put("nickName", userInfo.getNickName()); + bossObject.put("portrait", userInfo.getPortrait()); + bossObject.put("phone", phone); + bossObject.put("phoneCopy", phoneCopy); + bossObject.put("weixin", weixin); + bossObject.put("level", level.name()); + return bossObject; + } + + /** + * 淇濆瓨绮変笣淇℃伅 * * @param acceptData * @param uid @@ -1182,7 +1404,7 @@ int type = 1; ThreeSale threeSale = threeSaleSerivce.getByWorkerId(workerId); - if (threeSale == null) { + if (threeSale != null && threeSale.getBoss().getId() != uid) { type = 2; } @@ -1203,83 +1425,73 @@ threeSaleExtraInfoSerivce.insertSelective(saleExtraInfo); } + // 鏇存柊绮変笣璁板綍淇℃伅 teamFansInfoService.updateTags(workerId, type, tags); out.print(JsonUtil.loadTrueResult("淇濆瓨鎴愬姛")); } - - /** - * 鐢ㄦ埛闃熷憳缁熻-h5 + * 闃熷憳鏁伴噺缁熻 * * @param acceptData * @param id * @param out */ - @RequestMapping(value = "countTeamH5") - public void countTeamH5(String callback, AcceptData acceptData, Long uid, PrintWriter out) { + @RequestMapping(value = "countTeamNum") + public void countTeamNum(String callback, AcceptData acceptData, Long uid, PrintWriter out) { try { - Date now = new Date(); - SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM"); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - // 浠婃棩 - String todayStr = sdf.format(now); - // 鏄ㄦ棩 - Date reduceDay = DateUtil.reduceDay(1, now); - // 鏈湀 - String monthStr = sdf1.format(now); - - TeamDailyRecord todayRecord = new TeamDailyRecord(0,0,0); - TeamDailyRecord yesterdayRecord = new TeamDailyRecord(0,0,0); - TeamDailyRecord monthRecord = new TeamDailyRecord(0,0,0); - TeamDailyRecord totalityRecord = new TeamDailyRecord(0,0,0); - - List<TeamDailyRecord> list = teamDailyRecordService.getbyUid(uid); - if (list != null && list.size() > 0) { - for (TeamDailyRecord record: list) { - Date statisticDay = record.getCountDay(); - if (todayStr.equals(sdf.format(statisticDay))) { - todayRecord = record; - } - - if (sdf.format(reduceDay).equals(sdf.format(statisticDay))) { - yesterdayRecord = record; - } - - if (monthStr.equals(sdf1.format(statisticDay))) { - monthRecord.setFirstNum(monthRecord.getFirstNum() + record.getFirstNum()); - monthRecord.setSecondNum(monthRecord.getSecondNum() + record.getSecondNum()); - monthRecord.setBeyondNum(monthRecord.getBeyondNum() + record.getBeyondNum()); - } - - totalityRecord.setFirstNum(totalityRecord.getFirstNum() + record.getFirstNum()); - totalityRecord.setSecondNum(totalityRecord.getSecondNum() + record.getSecondNum()); - totalityRecord.setBeyondNum(totalityRecord.getBeyondNum() + record.getBeyondNum()); - } - } - - + Date minDate = null; + Date maxDate = null; + long timeStamp = System.currentTimeMillis(); + + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(timeStamp); + + // 浠婃棩棰勪及 + calendar.add(Calendar.DAY_OF_YEAR, -1); + minDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp))); + TeamDailyRecord todayRecord = createVO( + teamDailyRecordService.sumTeamNumGroupByCountDay(uid, minDate, null)); + + // 鏄ㄦ棩棰勪及 + calendar.add(Calendar.DAY_OF_YEAR, -1); + maxDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp))); + minDate = DateUtil.reduceDay(1, maxDate); + TeamDailyRecord yesterdayRecord = createVO( + teamDailyRecordService.sumTeamNumGroupByCountDay(uid, minDate, maxDate)); + + // 鏈湀棰勪及 + maxDate = new Date(timeStamp); + calendar = Calendar.getInstance(); + minDate = new Date(TimeUtil.convertToTimeTemp( + calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M")); + calendar.add(Calendar.MONTH, -1); + TeamDailyRecord monthRecord = createVO( + teamDailyRecordService.sumTeamNumGroupByYearMonth(uid, minDate, maxDate)); + + // 绱 + TeamDailyRecord totalityRecord = createVO(teamDailyRecordService.sumTeamNumGroupByUid(uid, null, null)); + JSONObject today = new JSONObject(); today.put("direct", todayRecord.getFirstNum()); today.put("indirect", todayRecord.getSecondNum()); today.put("beyond", todayRecord.getBeyondNum()); - + JSONObject yesterday = new JSONObject(); yesterday.put("direct", yesterdayRecord.getFirstNum()); yesterday.put("indirect", yesterdayRecord.getSecondNum()); yesterday.put("beyond", yesterdayRecord.getBeyondNum()); - + JSONObject month = new JSONObject(); month.put("direct", monthRecord.getFirstNum()); month.put("indirect", monthRecord.getSecondNum()); month.put("beyond", monthRecord.getBeyondNum()); - + JSONObject totality = new JSONObject(); totality.put("direct", totalityRecord.getFirstNum()); totality.put("indirect", totalityRecord.getSecondNum()); totality.put("beyond", totalityRecord.getBeyondNum()); - - + JSONObject json = new JSONObject(); json.put("today", today); json.put("yesterday", yesterday); @@ -1290,6 +1502,77 @@ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("缁熻澶辫触")); e.printStackTrace(); } - } + + private TeamDailyRecord createVO(List<TeamDailyRecord> list) { + TeamDailyRecord totalityRecord = new TeamDailyRecord(0, 0, 0); + if (list != null && list.size() > 0) { + for (TeamDailyRecord record : list) { + totalityRecord.setFirstNum(totalityRecord.getFirstNum() + record.getFirstNum()); + totalityRecord.setSecondNum(totalityRecord.getSecondNum() + record.getSecondNum()); + totalityRecord.setBeyondNum(totalityRecord.getBeyondNum() + record.getBeyondNum()); + } + } + return totalityRecord; + } + + /** + * 閭�璇锋帓琛屾 + * + * @param callback + * @param acceptData + * @param uid + * @param dateType + * @param out + */ + @RequestMapping(value = "getRanking") + public void getRanking(String callback, AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) { + if (uid == null || dateType == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍙傛暟缂哄け")); + return; + } + + try { + Date minDate = null; + Date maxDate = null; + long timeStamp = System.currentTimeMillis(); + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(timeStamp); + + if (dateType == 1) { + // 浠婃棩 + calendar.add(Calendar.DAY_OF_YEAR, -1); + minDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp))); + } else if (dateType == 2) { + // 鏄ㄦ棩 + calendar.add(Calendar.DAY_OF_YEAR, -1); + maxDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp))); + minDate = DateUtil.reduceDay(1, maxDate); + } else { + // 鏈湀 + maxDate = new Date(timeStamp); + calendar = Calendar.getInstance(); + minDate = new Date(TimeUtil.convertToTimeTemp( + calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M")); + calendar.add(Calendar.MONTH, -1); + } + + List<OrderRankingVO> list = teamDailyRecordService.getRankingByFirstNum(uid, minDate, maxDate); + if (list.size() > 0) { + for (OrderRankingVO vo : list) { + UserInfo user = userInfoService.getUserByIdWithMybatis(vo.getUid()); + vo.setNickName(user.getNickName()); + vo.setPortrait(user.getPortrait()); + } + } + + JSONObject json = new JSONObject(); + json.put("list", list); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json)); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("缁熻澶辫触")); + e.printStackTrace(); + } + } + } -- Gitblit v1.8.0