From c54fb6a88876be994906d57d2d18e844686964d0 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 01 七月 2020 14:16:13 +0800 Subject: [PATCH] rcoketmq集中管理 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserAccountControllerV2.java | 459 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 353 insertions(+), 106 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserAccountControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserAccountControllerV2.java index 8f06530..0a7b98d 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserAccountControllerV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserAccountControllerV2.java @@ -6,6 +6,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; import java.util.List; @@ -25,14 +26,17 @@ import com.google.gson.JsonSerializer; import com.yeshi.fanli.dto.user.UserInviteLevelEnum; import com.yeshi.fanli.entity.accept.AcceptData; -import com.yeshi.fanli.entity.bus.user.HongBaoV2; import com.yeshi.fanli.entity.bus.user.SMSHistory; import com.yeshi.fanli.entity.bus.user.ThreeSale; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.entity.bus.user.UserInviteValidNum; +import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo; +import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo; +import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo; import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum; +import com.yeshi.fanli.entity.order.OrderMoneyDailyCount; import com.yeshi.fanli.entity.push.DeviceActive; import com.yeshi.fanli.entity.shop.BanLiShopOrder; import com.yeshi.fanli.entity.system.BusinessSystem; @@ -46,7 +50,10 @@ import com.yeshi.fanli.service.inter.homemodule.HomeNavbarUserService; import com.yeshi.fanli.service.inter.money.UserMoneyDetailService; import com.yeshi.fanli.service.inter.money.UserMoneyService; +import com.yeshi.fanli.service.inter.order.CommonOrderService; +import com.yeshi.fanli.service.inter.order.HongBaoV2Service; import com.yeshi.fanli.service.inter.order.LostOrderService; +import com.yeshi.fanli.service.inter.order.OrderMoneyDailyCountService; import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; import com.yeshi.fanli.service.inter.push.DeviceActiveService; import com.yeshi.fanli.service.inter.push.DeviceTokenHWService; @@ -73,7 +80,9 @@ import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; import com.yeshi.fanli.service.inter.user.invite.UserInviteService; import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService; +import com.yeshi.fanli.service.inter.user.vip.TearcherService; import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; +import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService; import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; @@ -83,6 +92,7 @@ import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.account.UserUtil; import com.yeshi.fanli.util.annotation.RequestSerializableByKey; +import com.yeshi.fanli.util.user.UserLevelUtil; import com.yeshi.fanli.vo.user.UserVipRateVO; import net.sf.json.JSONObject; @@ -201,10 +211,26 @@ @Resource private UserInviteService userInviteService; - + @Resource private UserInviteValidNumService userInviteValidNumService; + + @Resource + private CommonOrderService commonOrderService; + + @Resource + private TearcherService tearcherService; + + @Resource + private UserVIPPreInfoService userVIPPreInfoService; + + @Resource + private HongBaoV2Service hongBaoV2Service; + + @Resource + private OrderMoneyDailyCountService orderMoneyDailyCountService; + /** * 鏂扮増鐧诲綍 V1.5.3 @@ -273,6 +299,13 @@ } catch (UserAccountException e) { int errorCode = e.getCode(); if (errorCode == 101) { // 闇�瑕佺粦瀹氭墜鏈哄彿 + JSONObject data = new JSONObject(); + data.put("key", e.getMsg()); + JSONObject object = new JSONObject(); + object.put("code", errorCode); + object.put("data", data); + out.print(object.toString()); + } else if (errorCode == 102) { // 闇�瑕佺粦瀹氬井淇″彿 JSONObject data = new JSONObject(); data.put("key", e.getMsg()); JSONObject object = new JSONObject(); @@ -356,6 +389,50 @@ } } + + + /** + * 缁戝畾寰俊V2.1.3 鐢佃瘽鍙风爜 鐧诲綍 + * + * @param acceptData + * @param vcode + * @param phone + * @param out + */ + @RequestSerializableByKey(key = "'bindWXLogin-'+#code") + @RequestMapping(value = "bindWXLogin") + public void bindWXLogin(AcceptData acceptData, Long uid, String code, String key, HttpServletRequest request, + PrintWriter out) { + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages()); + if (system == null) { + out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); + return; + } + + if (StringUtil.isNullOrEmpty(code)) { + out.print(JsonUtil.loadFalseResult("璇蜂笂浼燾ode")); + return; + } + + if (StringUtil.isNullOrEmpty(key)) { + out.print(JsonUtil.loadFalseResult("key鍊间笉鑳戒负绌�")); + return; + } + + try { + UserInfo userInfo = userAccountService.bindWXToLogin(request, acceptData, code, system.getAppid(), key); + JSONObject data = new JSONObject(); + data.put("userInfo", UserUtil.filterForClientUser(userInfo)); + out.print(JsonUtil.loadTrueResult(data)); + } catch (UserAccountException e) { + out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); + } + + } + + + /** * 缁戝畾鐢佃瘽鍙风爜 V2.0.1 寰俊鐧诲綍 * @@ -460,23 +537,23 @@ BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay")); vo.setFinishGoldCoin(Long.parseLong(integralDetailService.getCumulativeMoney(uid).setScale(0).toString())); - -// vo.setFinishTeam(hongBaoV2CountService.countValidOrderTeamUserByUid(uid, -// , payMoney)); - + + // vo.setFinishTeam(hongBaoV2CountService.countValidOrderTeamUserByUid(uid, + // , payMoney)); + int finishTeam = 0; long vipBegin = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME); List<ThreeSale> listThreeSale = threeSaleSerivce.getValidWorkerIdsByTime(uid, vipBegin); if (listThreeSale != null && listThreeSale.size() > 0) { - for (ThreeSale three: listThreeSale) { + for (ThreeSale three : listThreeSale) { UserInfo worker = three.getWorker(); if (worker == null || worker.getId() == null) { continue; } // 1銆侀個璇峰叧绯绘垚鍔熷悗锛�2銆佸崟锛堝垎浜� + 鑷喘锛夊疄浠樻澶т簬1鍏� - long countValid = hongBaoV2CountService.countValidOrderByUidAndTime(worker.getId(), three.getSucceedTime(), payMoney); + long countValid = commonOrderService.countOrderByUidAndSettled(worker.getId(), payMoney); if (countValid > 0) { - finishTeam ++; + finishTeam++; } } } @@ -539,7 +616,7 @@ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); return; } - + try { userVIPInfoService.applyVIP(uid); } catch (UserVIPInfoException e) { @@ -558,8 +635,6 @@ } } - - /** * 鑾峰彇vip淇℃伅 * @@ -582,37 +657,15 @@ } // 鑾峰彇绛夌骇 UserInviteLevelEnum level = userInviteService.getUserInviteLevelNew(uid); - + // 杈句汉 - long limitZiGou = 0; - long limitShare = 0; + long limitOrder = 0; long limitFirst = 0; long limitSecond = 0; - if (level == UserInviteLevelEnum.actived || level == UserInviteLevelEnum.noActive) { - String zigou = userVipConfigService.getValueByKey("vip_pre_3_zigou_order_count"); - if (!StringUtil.isNullOrEmpty(zigou)) { - limitZiGou = Long.parseLong(zigou); - } - String share = userVipConfigService.getValueByKey("vip_pre_3_share_order_count"); - if (!StringUtil.isNullOrEmpty(share)) { - limitShare = Long.parseLong(share); - } - String first = userVipConfigService.getValueByKey("vip_pre_3_first_level_team_count"); - if (!StringUtil.isNullOrEmpty(first)) { - limitFirst = Long.parseLong(first); - } - String second = userVipConfigService.getValueByKey("vip_pre_3_second_level_team_count"); - if (!StringUtil.isNullOrEmpty(second)) { - limitSecond = Long.parseLong(second); - } - } else if (level == UserInviteLevelEnum.vipPre1) { - String zigou = userVipConfigService.getValueByKey("vip_pre_7_zigou_order_count"); - if (!StringUtil.isNullOrEmpty(zigou)) { - limitZiGou = Long.parseLong(zigou); - } - String share = userVipConfigService.getValueByKey("vip_pre_7_share_order_count"); - if (!StringUtil.isNullOrEmpty(share)) { - limitShare = Long.parseLong(share); + if (level == UserInviteLevelEnum.actived || level == UserInviteLevelEnum.noActive) { + String orderCount = userVipConfigService.getValueByKey("vip_pre_7_order_count"); + if (!StringUtil.isNullOrEmpty(orderCount)) { + limitOrder = Long.parseLong(orderCount); } String first = userVipConfigService.getValueByKey("vip_pre_7_first_level_team_count"); if (!StringUtil.isNullOrEmpty(first)) { @@ -622,14 +675,10 @@ if (!StringUtil.isNullOrEmpty(second)) { limitSecond = Long.parseLong(second); } - } else if (level == UserInviteLevelEnum.vipPre2 || level == UserInviteLevelEnum.vipApply) { - String zigou = userVipConfigService.getValueByKey("vip_pre_10_zigou_order_count"); - if (!StringUtil.isNullOrEmpty(zigou)) { - limitZiGou = Long.parseLong(zigou); - } - String share = userVipConfigService.getValueByKey("vip_pre_10_share_order_count"); - if (!StringUtil.isNullOrEmpty(share)) { - limitShare = Long.parseLong(share); + } else if (level == UserInviteLevelEnum.highVIP || level == UserInviteLevelEnum.vipApply) { + String orderCount = userVipConfigService.getValueByKey("vip_pre_10_order_count"); + if (!StringUtil.isNullOrEmpty(orderCount)) { + limitOrder = Long.parseLong(orderCount); } String first = userVipConfigService.getValueByKey("vip_pre_10_first_level_team_count"); if (!StringUtil.isNullOrEmpty(first)) { @@ -641,22 +690,13 @@ } } else if (level == UserInviteLevelEnum.vip || level == UserInviteLevelEnum.tearcherApply) { // TODO 姣斾緥 - + } else if (level == UserInviteLevelEnum.tearcher) { // TODO } - + // 鑷喘璁㈠崟 - long doneZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, - HongBaoV2.TYPE_ZIGOU); - // 鍒嗕韩璁㈠崟 - long doneShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, - HongBaoV2.TYPE_SHARE_GOODS); - - - Date now = new Date(); - Date start = new Date(0); - + long doneOrder = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY); // 鏈夋晥绮変笣 int doneFirst = 0; int doneSecond = 0; @@ -665,13 +705,15 @@ doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst(); doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond(); } - + + Date now = new Date(); + Date start = new Date(0); // 鐪侀挶锛� ---杩斿埄璁㈠崟銆佸鍔卞埜鎻愭垚 List<UserMoneyDetailTypeEnum> typeFanli = new ArrayList<>(); typeFanli.add(UserMoneyDetailTypeEnum.fanli); typeFanli.add(UserMoneyDetailTypeEnum.orderReward); BigDecimal saveMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeFanli, start, now).abs(); - + // 璧氶挶锛� 閭�璇疯鍗曘�佸垎浜鍗曘�佽ˉ璐� List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>(); typeList.add(UserMoneyDetailTypeEnum.share); @@ -685,41 +727,27 @@ saveMoney = MoneyBigDecimalUtil.mul2(saveMoney, rate); earnMoney = MoneyBigDecimalUtil.mul2(earnMoney, rate); } - - String school = "鏉挎牀瀛﹂櫌"; - String platformSubsidy = "琛ヨ创杩斾剑 "; - String teamSubsidy = "浼氬憳涓撳睘"; - String teamReward = "瓒呯骇浼氬憳涓撳睘"; - + + String shareRate = "鍙韩浣i噾鐨�<label style=\"color:#E5005C;\">%s</label>"; + String teamRate = "鏈�楂樹剑閲戠殑<label style=\"color:#E5005C;\">%s</label>"; // 杈句汉鐗� JSONObject jsonrRed1 = new JSONObject(); - jsonrRed1.put("platformSubsidy", platformSubsidy + "<label style=\"color:#E5005C;\">52.5%</label>"); - jsonrRed1.put("school", school + "<label style=\"color:#E5005C;\">杈句汉鐝�</label>"); - jsonrRed1.put("teamSubsidy", teamSubsidy); - jsonrRed1.put("teamReward", teamReward); - - + jsonrRed1.put("enjoyRate", String.format(shareRate, "145%")); + jsonrRed1.put("teamRate", String.format(teamRate, "25%")); + jsonrRed1.put("teamIncome", "楂樼骇浼氬憳浠ヤ笂涓撳睘"); + + // 楂樼骇浼氬憳 JSONObject jsonrRed2 = new JSONObject(); - jsonrRed2.put("platformSubsidy", platformSubsidy + "<label style=\"color:#E5005C;\">60%</label>"); - jsonrRed2.put("school", school + "<label style=\"color:#E5005C;\">鏅�氱彮</label>"); - jsonrRed2.put("teamSubsidy", teamSubsidy + "鏈�楂�<label style=\"color:#E5005C;\">7.5%</label>"); - jsonrRed2.put("teamReward", teamReward); - + jsonrRed2.put("enjoyRate", String.format(shareRate, "195%")); + jsonrRed2.put("teamRate", String.format(teamRate, "50%")); + jsonrRed2.put("teamIncome", "浜珮绾у洟闃熸敹鐩�"); + // 瓒呯骇浼氬憳 JSONObject jsonrRed3 = new JSONObject(); - jsonrRed3.put("platformSubsidy", platformSubsidy + "<label style=\"color:#E5005C;\">70%</label>"); - jsonrRed3.put("school", school + "<label style=\"color:#E5005C;\">楂樼骇鐝�</label>"); - jsonrRed3.put("teamSubsidy", teamSubsidy + "鏈�楂�<label style=\"color:#E5005C;\">15%</label>"); - jsonrRed3.put("teamReward", teamReward); - + jsonrRed3.put("enjoyRate", String.format(shareRate, "210%")); + jsonrRed3.put("teamRate", String.format(teamRate, "110%")); + jsonrRed3.put("teamIncome", "浜秴绾у洟闃熸敹鐩�"); - JSONObject jsonrRed4 = new JSONObject(); - jsonrRed4.put("platformSubsidy", platformSubsidy + "<label style=\"color:#E5005C;\">115%</label>"); - jsonrRed4.put("school", school + "<label style=\"color:#E5005C;\">瓒呯骇鐝�</label>"); - jsonrRed4.put("teamSubsidy", teamSubsidy + "鏈�楂�<label style=\"color:#E5005C;\">22.5%</label>"); - jsonrRed4.put("teamReward", teamReward + "鏈�楂�<label style=\"color:#E5005C;\">40%</label>"); - - JSONObject json = new JSONObject(); json.put("level", level.name()); json.put("nickName", userInfo.getNickName()); @@ -727,32 +755,53 @@ json.put("ruleLink", userVipConfigService.getValueByKey("help_link_vip_h5")); json.put("saveMoney", saveMoney); json.put("earnMoney", earnMoney); - + + String tearcherWX = ""; + TearcherInfo tearcherInfo = tearcherService.selectByUid(uid); + if (tearcherInfo != null && !StringUtil.isNullOrEmpty(tearcherInfo.getWxID())) { + tearcherWX = tearcherInfo.getWxID(); + } + json.put("tearcherWX", tearcherWX); json.put("tearcherTip", "鎴戞槸浣犵殑瀵煎笀锛屼负浣犲湪鐪佽禋杩囩▼涓В闅剧瓟鐤戯紝瀵逛綘涓�瀵逛竴杈呭锛屽�惧惉浣犵殑闇�姹傛�荤粨骞跺弽棣堢粰鏉挎牀蹇渷瀹樻柟杩愯惀鍥㈤槦锛屽揩鏉ユ坊鍔犳垜鍚с��"); - json.put("tearcherWX", userVipConfigService.getValueByKey("tearcher_weixin_num")); json.put("newerGongLue", configService.get(ConfigKeyEnum.newerGonglue.getKey())); - + // 宸插畬鎴� - json.put("doneZiGou", doneZiGou); - json.put("doneShare", doneShare); + json.put("doneOrder", doneOrder); json.put("doneFirst", doneFirst); json.put("doneSecond", doneSecond); - + // 鏍囧噯 - json.put("limitZiGou", limitZiGou); - json.put("limitShare", limitShare); + json.put("limitOrder", limitOrder); json.put("limitFirst", limitFirst); json.put("limitSecond", limitSecond); - + // 宸插畬鎴� - json.put("master", jsonrRed1); - json.put("vip1", jsonrRed2); - json.put("vip2", jsonrRed3); - json.put("vip3", jsonrRed4); - + json.put("daRen", jsonrRed1); + json.put("highVIP", jsonrRed2); + json.put("superVIP", jsonrRed3); + // 浜哄伐瀹㈡湇閾炬帴 json.put("csdLink", configService.get(ConfigKeyEnum.customerServiceLink.getKey())); - + + UserVIPInfo userVIPInfo = userVIPInfoService.selectByUid(uid); + String leftTime = ""; + if (userVIPInfo != null && userVIPInfo.getState() == UserVIPInfo.STATE_VERIFING + && userVIPInfo.getApplyTime() != null) { + long s = 48 * 60 * 60 - ((System.currentTimeMillis() - userVIPInfo.getApplyTime().getTime()) / 1000); + if (s > 3600) { + leftTime = s / 3600 + "灏忔椂"; + leftTime = "杩樺墿" + leftTime; + } else if (s >= 60) { + leftTime = s / 60 + "鍒嗛挓"; + leftTime = "杩樺墿" + leftTime; + } else if (s > 0) { + leftTime = s + "绉�"; + leftTime = "杩樺墿" + leftTime; + } else { + leftTime = "杩樺墿0绉�"; + } + } + json.put("leftTime", leftTime); if (!StringUtil.isNullOrEmpty(callback)) { out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(json))); } else { @@ -760,4 +809,202 @@ } } + /** + * 鑾峰彇vip淇℃伅 + * + * @param acceptData + * @param uid + * @param out + */ + @RequestMapping(value = "getVIPSuccessInfo") + public void getVIPSuccessInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) { + if (uid == null || uid <= 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); + return; + } + + UserVIPPreInfo vipInfo = userVIPPreInfoService.getLatestProcessInfo(uid); + if (vipInfo == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "杩樻湭鍗囩骇鎴愪负浼氬憳")); + return; + } + + UserLevelEnum level = UserLevelUtil.getByLevel(vipInfo.getProcess()); + if (level == null) { + level = UserLevelEnum.daRen; + } + UserLevelEnum showLevel = UserLevelUtil.getShowLevel(level); + + String desc = "浣犱簬" + TimeUtil.formatDateDot(vipInfo.getCreateTime()) + "鍗囩骇涓�" + showLevel.getName(); + + JSONObject json = new JSONObject(); + json.put("desc", desc); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json)); + } + + @RequestMapping(value = "getTearcherWX") + public void getTearcherWX(String callback, AcceptData acceptData, Long uid, PrintWriter out) { + if (uid == null || uid <= 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); + return; + } + TearcherInfo tearcher = tearcherService.selectByUid(uid); + if (tearcher == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏃犲甯�")); + return; + } else { + JSONObject data = new JSONObject(); + data.put("wx", tearcher.getWxID()); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + return; + } + } + + //鑾峰彇鐢佃瘽鍙风爜 + @RequestMapping(value = "getPhone") + public void getPhone(String callback, AcceptData acceptData, Long uid, PrintWriter out) { + if (uid == null || uid <= 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); + return; + } + UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid); + if(user==null){ + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "鐢ㄦ埛涓嶅瓨鍦�")); + return; + } + + JSONObject data=new JSONObject(); + data.put("phone", user.getPhone()); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } + + + /** + * 璐︽埛娉ㄩ攢 + * @param acceptData + * @param callback + * @param uid + * @param out + */ + @RequestMapping("accountRemove") + public void accountRemove(AcceptData acceptData, String callback, Long uid, String vcode, PrintWriter out) { + if (uid == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + + if (StringUtil.isNullOrEmpty(vcode)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇疯緭鍏ラ獙璇佺爜")); + return; + } + + UserInfo userInfo = userInfoService.selectByPKey(uid); + if (userInfo == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�")); + return; + } + + if (userInfo.getState() == UserInfo.STATE_FORBIDDEN) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC)); + return; + } + + if (userInfo.getState() == UserInfo.STATE_DELETE || userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, "甯愭埛宸茶娉ㄩ攢锛岃閲嶆柊鐧诲綍")); + return; + } + + String phone = userInfo.getPhone(); + if (StringUtil.isNullOrEmpty(phone)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈粦瀹氭湁鏁堢數璇濆彿鐮�")); + return; + } + + if (!Constant.IS_TEST) { + String oldVcode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_REMVOE); + if (StringUtil.isNullOrEmpty(oldVcode) || !oldVcode.equalsIgnoreCase(vcode)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("楠岃瘉鐮侀敊璇紝閲嶆柊杈撳叆")); + return; + } + redisManager.clearSMSVCode(phone, SMSHistory.TYPE_REMVOE); + } + + UserInfo user = new UserInfo(uid); + user.setState(UserInfo.STATE_DELETE); + user.setStateDesc("鐢ㄦ埛涓诲姩娉ㄩ攢璐︽埛"); + userInfoService.updateByPrimaryKeySelective(user); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("娉ㄩ攢鎴愬姛")); + } + + + /** + * 娉ㄩ攢璐︽埛鏁版嵁 + * @param acceptData + * @param callback + * @param uid + * @param out + */ + @RequestMapping("getAccountData") + public void getAccountData(AcceptData acceptData, String callback, Long uid, PrintWriter out) { + if (uid == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + + UserInfo user = userInfoService.getUserById(uid); + if (user == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�")); + return; + } + + Date minDate = null; + Date maxDate = null; + long timeStamp = System.currentTimeMillis(); + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(timeStamp); + + // 鍏ㄩ儴鏈埌璐� + minDate = new Date(0); + maxDate = new Date(timeStamp); + BigDecimal totalMoney = hongBaoV2Service.getUnRecievedMoneyWithCreateTime(uid, minDate, maxDate); + if (totalMoney == null) + totalMoney = BigDecimal.ZERO; + totalMoney = totalMoney.add(user.getMyHongBao()); + + // 鏈湀棰勪及 + 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); + BigDecimal monthMoney = getMoney(orderMoneyDailyCountService.query(uid, minDate, maxDate)); + + // 涓婃湀棰勪及 + maxDate = new Date(TimeUtil + .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M")); + calendar.add(Calendar.MONTH, -1); + minDate = new Date(TimeUtil + .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M")); + BigDecimal lastMoney = getMoney(orderMoneyDailyCountService.query(uid, minDate, maxDate)); + + JSONObject data = new JSONObject(); + data.put("totalMoney", totalMoney.setScale(2, BigDecimal.ROUND_DOWN)); + data.put("monthMoney", monthMoney.setScale(2, BigDecimal.ROUND_DOWN)); + data.put("lastMoney", lastMoney.setScale(2, BigDecimal.ROUND_DOWN)); + data.put("link", configService.get(ConfigKeyEnum.accountLogoutProtocolLink.getKey())); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } + + private BigDecimal getMoney(List<OrderMoneyDailyCount> list) { + BigDecimal money = BigDecimal.ZERO; + BigDecimal hundred = BigDecimal.valueOf(100); + if (list != null && list.size() > 0) { + for (OrderMoneyDailyCount dailyCount : list) { + if (dailyCount.getIncome() != null) + money = money.add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncome()), hundred)); + if (dailyCount.getIncomeTeam() != null) + money = money.add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncomeTeam()), hundred)); + } + } + return money; + } } -- Gitblit v1.8.0