From cdcbed9af813b2a02cdc01eefa24db8bec6b51a9 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期三, 27 三月 2019 12:17:33 +0800 Subject: [PATCH] 主分类 + 子分类 DAO改造 --- fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java | 941 ++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 516 insertions(+), 425 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java index f77013a..a85d7f9 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java @@ -1,13 +1,16 @@ package com.yeshi.fanli.controller.client; import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Type; import java.math.BigDecimal; +import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; +import java.util.Iterator; import java.util.List; import java.util.UUID; @@ -22,6 +25,7 @@ import org.yeshi.utils.IPUtil; import org.yeshi.utils.JsonUtil; import org.yeshi.utils.NumberUtil; +import org.yeshi.utils.taobao.TbImgUtil; import org.yeshi.utils.tencentcloud.COSManager; import com.google.gson.Gson; @@ -30,57 +34,67 @@ import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; +import com.yeshi.fanli.dto.HongBao; +import com.yeshi.fanli.dto.HongBaoDTO; +import com.yeshi.fanli.dto.money.AccountDetails; +import com.yeshi.fanli.dto.order.OrderItem; +import com.yeshi.fanli.entity.AppVersionInfo; import com.yeshi.fanli.entity.accept.AcceptData; -import com.yeshi.fanli.entity.bus.user.AccountDetails; import com.yeshi.fanli.entity.bus.user.AccountMessage; import com.yeshi.fanli.entity.bus.user.BindingAccount; import com.yeshi.fanli.entity.bus.user.Extract; import com.yeshi.fanli.entity.bus.user.ExtractRecord; -import com.yeshi.fanli.entity.bus.user.HongBao; -import com.yeshi.fanli.entity.bus.user.HongBaoExtra; -import com.yeshi.fanli.entity.bus.user.HongBaoMessage; import com.yeshi.fanli.entity.bus.user.LostOrder; -import com.yeshi.fanli.entity.bus.user.MoneyRecord; -import com.yeshi.fanli.entity.bus.user.OrderItem; -import com.yeshi.fanli.entity.bus.user.PassWordErrorRecord; import com.yeshi.fanli.entity.bus.user.SMSHistory; import com.yeshi.fanli.entity.bus.user.ThreeSale; import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo; import com.yeshi.fanli.entity.bus.user.UserActiveLog; import com.yeshi.fanli.entity.bus.user.UserInfo; +import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.entity.bus.user.WeiXinUser; +import com.yeshi.fanli.entity.common.AdminUser; +import com.yeshi.fanli.entity.common.Config; import com.yeshi.fanli.entity.goods.CollectionGoodsV2; -import com.yeshi.fanli.entity.system.System; +import com.yeshi.fanli.entity.goods.CommonGoods; +import com.yeshi.fanli.entity.money.UserMoneyDetail; +import com.yeshi.fanli.entity.order.HongBaoOrder; +import com.yeshi.fanli.entity.system.BusinessSystem; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra; import com.yeshi.fanli.exception.BindingAccountException; -import com.yeshi.fanli.exception.ObjectStateException; import com.yeshi.fanli.exception.goods.CollectionGoodsException; +import com.yeshi.fanli.exception.taobao.TaoKeApiException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; +import com.yeshi.fanli.exception.user.UserCustomSettingsException; +import com.yeshi.fanli.exception.user.UserInfoExtraException; import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.AdminUserService; +import com.yeshi.fanli.service.inter.config.AppVersionService; +import com.yeshi.fanli.service.inter.config.BusinessSystemService; import com.yeshi.fanli.service.inter.config.ConfigService; -import com.yeshi.fanli.service.inter.config.SystemService; +import com.yeshi.fanli.service.inter.count.HongBaoV2CountService; import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service; import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; -import com.yeshi.fanli.service.inter.hongbao.HongBaoMessageService; -import com.yeshi.fanli.service.inter.hongbao.HongBaoService; +import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service; import com.yeshi.fanli.service.inter.hongbao.ThreeSaleExtraInfoSerivce; import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce; +import com.yeshi.fanli.service.inter.order.HongBaoOrderService; import com.yeshi.fanli.service.inter.order.LostOrderService; -import com.yeshi.fanli.service.inter.order.OrderItemServcie; import com.yeshi.fanli.service.inter.order.OrderService; -import com.yeshi.fanli.service.inter.user.AccountDetailsService; import com.yeshi.fanli.service.inter.user.AccountMessageService; import com.yeshi.fanli.service.inter.user.BindingAccountService; import com.yeshi.fanli.service.inter.user.ExtractRecordService; import com.yeshi.fanli.service.inter.user.ExtractService; -import com.yeshi.fanli.service.inter.user.MoneyRecordService; -import com.yeshi.fanli.service.inter.user.PassWordErrorRecordService; import com.yeshi.fanli.service.inter.user.ShamUserService; +import com.yeshi.fanli.service.inter.user.SpreadUserImgService; import com.yeshi.fanli.service.inter.user.UserAccountService; import com.yeshi.fanli.service.inter.user.UserActiveLogService; +import com.yeshi.fanli.service.inter.user.UserCustomSettingsService; +import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.service.inter.user.UserInfoService; -import com.yeshi.fanli.service.inter.user.WxDownService; +import com.yeshi.fanli.service.inter.user.UserMoneyDetailService; +import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService; +import com.yeshi.fanli.util.AESUtil; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.GsonUtil; import com.yeshi.fanli.util.HongBaoUtil; @@ -90,8 +104,15 @@ import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.Utils; import com.yeshi.fanli.util.account.UserUtil; +import com.yeshi.fanli.util.email.MailSenderUtil; +import com.yeshi.fanli.util.factory.AccountDetailsFactory; +import com.yeshi.fanli.util.factory.HongBaoFactory; +import com.yeshi.fanli.util.factory.OrderItemFactory; import com.yeshi.fanli.util.taobao.TaoBaoUtil; +import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import com.yeshi.fanli.util.wx.WXLoginUtil; +import com.yeshi.fanli.vo.user.UserInfoExtraVO; +import com.yeshi.fanli.vo.user.UserSettingsVO; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -107,28 +128,16 @@ private OrderService orderService; @Resource - private HongBaoService hongBaoService; - - @Resource - private MoneyRecordService moneyRecordService; - - @Resource private BindingAccountService bindingAccountService; @Resource private ExtractService extractService; @Resource - private PassWordErrorRecordService passWordErrorRecordService; - - @Resource private ConfigService configService; @Resource - private SystemService systemService; - - @Resource - private HongBaoMessageService hongBaoMessageService; + private BusinessSystemService businessSystemService; @Resource private ShamUserService shamUserService; @@ -143,19 +152,7 @@ private LostOrderService lostOrderService; @Resource - private OrderItemServcie orderItemServcie; - - @Resource - private AccountDetailsService accountDetailsService; - - @Resource - private AccountMessageService accountMessageService; - - @Resource private HongBaoManageService hongBaoManageService; - - @Resource - private WxDownService wxDownService; @Resource private UserAccountService loginService; @@ -171,6 +168,39 @@ @Resource private CollectionGoodsV2Service collectionGoodsV2Service; + + @Resource + private AdminUserService adminUserService; + + @Resource + private UserMoneyDetailService userMoneyDetailService; + + @Resource + private HongBaoOrderService hongBaoOrderService; + + @Resource + private HongBaoV2Service hongBaoV2Service; + + @Resource + private SpreadUserImgService spreadUserImgService; + + @Resource + private UserShareGoodsRecordService userShareGoodsRecordService; + + @Resource + private UserCustomSettingsService userCustomSettingsService; + + @Resource + private UserInfoExtraService userInfoExtraService; + + @Resource + private AppVersionService appVersionService; + + @Resource + private HongBaoV2CountService hongBaoV2CountService; + + @Resource + private AccountMessageService accountMessageService; private static final String PASSWORD_MAX_ERROR = "password_max_error"; private static final String EXTRACT_MIN_MONEY = "extract_min_money"; @@ -199,10 +229,14 @@ // } // }); if (find != null) { + if (find.getState() != UserInfo.STATE_NORMAL) { + out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, + Constant.FORBIDDEN_USER_REASON_DESC)); + return; + } + // 閭�璇峰叧绯荤敓鏁� threeSaleSerivce.effective(find); - // 閲嶆柊璁$畻鐢ㄦ埛绛夌骇 - threeSaleSerivce.reComputeUserRank(id); // 娣诲姞鐢ㄦ埛娲昏穬璁板綍 UserActiveLog userActiveLog = new UserActiveLog(); @@ -222,7 +256,8 @@ } } // 涓嶆槸鐢↖D鐨勭櫥闄嗙殑浜嬪氨澶氫簡 - System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages()); + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); return; @@ -408,7 +443,8 @@ } } // 涓嶆槸鐢↖D鐨勭櫥闄嗙殑浜嬪氨澶氫簡 - System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages()); + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); return; @@ -447,10 +483,9 @@ } private void outUserInfo(AcceptData acceptData, PrintWriter out, String remotIP, UserInfo user, String device) { - BigDecimal MyTotalMoney = hongBaoService.getMyTotalHongBaoByUid(user.getId()); - user.setTotalHongBao(MyTotalMoney); - BigDecimal unOpenmoney = hongBaoService.getUnOpenHongBaoByUid(user.getId()); - BigDecimal canOpenMoney = hongBaoService.getCanOpenHongBaoByUid(user.getId()); + user.setTotalHongBao(new BigDecimal(0)); + BigDecimal unOpenmoney = new BigDecimal(0); + BigDecimal canOpenMoney = new BigDecimal(0); user.setNoOpenHongBao(unOpenmoney); user.setCanOpenHongBao(canOpenMoney); @@ -460,27 +495,114 @@ BigDecimal fanliHB = user.getTotalHongBao(); user.setTotalHongBao(fanliHB); + UserInfo filterForClientUser = UserUtil.filterForClientUser(user); + + // 1.5.0 鐗堟湰涔嬪悗杩斿洖鏂扮殑绛夌骇 + String version = acceptData.getVersion(); + if (version != null && version.trim().length() > 0) { + int versionCode = Integer.parseInt(version); + String platform = acceptData.getPlatform(); + + AppVersionInfo versionInfo = appVersionService.getByPlatformAndVersion(platform, "1.5.0"); + if (versionInfo != null) { + int versionCode150 = versionInfo.getVersionCode(); + if (versionCode >= versionCode150) { + UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId()); + if (userInfoExtra != null && userInfoExtra.getUserRank() != null) { + String picture = userInfoExtra.getUserRank().getPicture(); + String icon = userInfoExtra.getUserRank().getIcon(); + filterForClientUser.setRankNamePicture(picture); + filterForClientUser.setRankIcon(icon); + } + } + } + } + GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); JSONObject data = new JSONObject(); - data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create() - .toJson(UserUtil.filterForClientUser(user))); + data.put("user", + JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(filterForClientUser)); data.put("first", 0); + int spreadImgCount = spreadUserImgService.countUserSpreadImg(user.getId()); + long shareCount = userShareGoodsRecordService.countShareRecordByUid(user.getId()); + + int showTiCheng = 1; // 涓嶆樉绀� + if ("ios".equalsIgnoreCase(acceptData.getPlatform()) + && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) + data.put("showTiCheng", false); + else { + data.put("showTiCheng", spreadImgCount + shareCount > 0); + if (spreadImgCount + shareCount > 0) { + showTiCheng = 0; + } + } + if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) data.put("inviteList", String.format("http://%s/%s/client/share/friends_new_online.html", Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName())); else data.put("inviteList", configService.get("team_list")); + + // 鐣岄潰鐘舵�� + UserSettingsVO mySettings = null; + try { + mySettings = userCustomSettingsService.getMySettings(user.getId()); + } catch (UserCustomSettingsException e) { + mySettings = new UserSettingsVO(); + e.printStackTrace(); + } + + if (mySettings.getCancelNotice() == null) { + mySettings.setCancelNotice(0); + } + if (mySettings.getNoBonusCount() == null) { + mySettings.setNoBonusCount(showTiCheng); // 鏍规嵁showTiCheng鏉ュ垽鏂� + } + if (mySettings.getNoNewsRedDot() == null) { + mySettings.setNoNewsRedDot(0); + } + if (mySettings.getNoShareRecordAndStorage() == null) { + mySettings.setNoShareRecordAndStorage(showTiCheng); // 鏍规嵁showTiCheng鏉ュ垽鏂� + } + if (mySettings.getNoInvitationBonus() == null) { + mySettings.setNoInvitationBonus(0); + } + + data.put("moduleState", mySettings); + + int welfareCenterNews = 0; + UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(user.getId()); + if (userInfoExtra != null && userInfoExtra.getCouponNews() != null) { + welfareCenterNews = userInfoExtra.getCouponNews(); + } + data.put("welfareCenterNews", welfareCenterNews); + out.print(JsonUtil.loadTrueResult(data)); + final UserInfo uuser = user; ThreadUtil.run(new Runnable() { public void run() { + + try { + // 鑾峰彇閭�璇风爜锛氳嫢鏃犻個璇风爜涓斿瓨鍦ㄦ湁鏁堢殑闃熷憳鍏崇郴 鍒欒嚜鍔ㄧ敓鎴愰個璇风爜 + userInfoExtraService.getUserInviteCode(uuser.getId()); + } catch (UserInfoExtraException e) { + e.printStackTrace(); + } + LogHelper.userInfo(GsonUtil.toJsonExpose(uuser)); uuser.setLastLoginIp(remotIP); uuser.setLastLoginTime(java.lang.System.currentTimeMillis()); userInfoService.updateLoginInfo(uuser); - wxDownService.save(device); + // 鏇存柊鐢ㄦ埛闄勫姞淇℃伅锛岃�佺敤鎴蜂笉瀛樺湪鐨勯渶瑕佹坊鍔� + try { + userInfoExtraService.updateUserRankByUid(uuser.getId()); + } catch (UserInfoExtraException e) { + e.printStackTrace(); + } + } }); } @@ -578,98 +700,6 @@ } /** - * 鑾峰彇鎻愮幇璁板綍 - * - * @param acceptData - * @param uid - * 鐢ㄦ埛id - * @param page - * 椤垫暟锛堜粠0寮�濮嬶級 - * @param out - */ - @RequestMapping(value = "getmoneyrecord", method = RequestMethod.POST) - public void getMoneyRecord(AcceptData acceptData, long uid, int page, PrintWriter out) { - UserInfo user = userInfoService.getUserById(uid); - if (user == null) { - out.print(JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�")); - return; - } - if (page < 0) { - page = 0; - } - - List<MoneyRecord> moneyRecordList = moneyRecordService.getMoneyRecord(uid, page); - int count = moneyRecordService.getCount(uid); - JSONObject data = new JSONObject(); - if (moneyRecordList == null || moneyRecordList.size() == 0) { - data.put("count", 0); - data.put("moneyRecordList", new ArrayList()); - out.print(JsonUtil.loadTrueResult(data)); - return; - } - data.put("count", count); - Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); - data.put("moneyRecordList", gson.toJson(moneyRecordList)); - out.print(JsonUtil.loadTrueResult(data)); - } - - /** - * 鑾峰彇褰撳墠鐢ㄦ埛绾㈠寘 - * - * @param acceptData - * @param uid - * 鐢ㄦ埛id - * @param out - * @throws ObjectStateException - */ - @RequestMapping(value = "gethongbao", method = RequestMethod.POST) - public void getHongBao(AcceptData acceptData, long uid, PrintWriter out) { - UserInfo user = userInfoService.getUserById(uid); - JSONObject data = new JSONObject(); - if (user == null) { - data.put("count", 0); - data.put("hongBaoList", new ArrayList()); - data.put("error", "鐢ㄦ埛涓嶅瓨鍦�"); - out.print(JsonUtil.loadTrueResult(data)); - return; - } - List<HongBaoExtra> hongBaoList = hongBaoService.getHongBao(uid); - - if (hongBaoList.size() == 0) { - data.put("count", 0); - data.put("hongBaoList", hongBaoList); - out.print(JsonUtil.loadTrueResult(data)); - return; - } - data.put("count", hongBaoList.size()); - data.put("hongBaoList", GsonUtil.toJsonExpose(hongBaoList)); - out.print(JsonUtil.loadTrueResult(data)); - return; - } - - /** - * 璁剧疆鎻愮幇瀵嗙爜 - * - * @param acceptData - * @param payPassword - * 鎻愮幇瀵嗙爜锛堣缁忚繃md5鍔犲瘑锛� - * @param uid - * 鐢ㄦ埛id - * @param out - */ - @RequestMapping(value = "setpaypassword", method = RequestMethod.POST) - public void setPayPassword(AcceptData acceptData, String payPassword, long uid, PrintWriter out) { - UserInfo user = userInfoService.getUserById(uid); - if (user == null) { - out.print(JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�")); - return; - } - user.setPayPassword(payPassword); - userInfoService.update(user); - out.print(JsonUtil.loadTrueResult("璁剧疆鎴愬姛")); - } - - /** * 鑾峰彇鐢ㄦ埛鎻愮幇璐﹀彿 * * @param acceptData @@ -694,16 +724,9 @@ JSONObject data = new JSONObject(); data.put("user", user); Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); - String maxError = "5"; - maxError = configService.get(PASSWORD_MAX_ERROR); // 褰撴棩杈撻敊瀵嗙爜鏈�澶氭鏁� - PassWordErrorRecord record = passWordErrorRecordService.getRecord(uid); - int max = Integer.parseInt(maxError); - if (record.getCount() >= max) { - data.put("error", "1"); // 杈惧埌鏈�澶氶檺鍒� - } else { - data.put("error", "0"); - } - data.put("maxError", maxError); + + data.put("error", "0"); + data.put("maxError", 1); String minMoney = configService.get(EXTRACT_MIN_MONEY); // 鍗曠瑪鎻愮幇鐨勬渶灏忛噾棰� String maxMoney = configService.get(EXTRACT_MAX_MONEY); // 鍗曠瑪鎻愮幇鐨勬渶澶ч噾棰� int maxDayCount = Integer.parseInt(configService.get("extract_count_day")); @@ -767,7 +790,7 @@ } String minMoney = configService.get(EXTRACT_MIN_MONEY); // 鍗曠瑪鎻愮幇鐨勬渶灏忛噾棰� - String maxMoney = configService.get(EXTRACT_MAX_MONEY); // 鍗曠瑪鎻愮幇鐨勬渶澶ч噾棰� + String maxDayMoney = configService.get("extract_money_day"); // 姣忔棩鏈�澶ф彁鐜伴噾棰� int maxDayCount = Integer.parseInt(configService.get("extract_count_day")); ExtractRecord extractRecord = extractRecordService.getExtractRecordByUid(uid); boolean canExtract = true; @@ -776,9 +799,9 @@ canExtract = false; errorMsg = String.format("姣忔棩鏈�澶氭彁鐜�%s娆�", maxDayCount + ""); } else if (extractRecord != null - && extractRecord.getMoney().add(money).compareTo(new BigDecimal(maxMoney)) > 0) { + && extractRecord.getMoney().add(money).compareTo(new BigDecimal(maxDayMoney)) > 0) { canExtract = false; - errorMsg = String.format("姣忔棩鏈�澶氭彁鐜�%s鍏�", maxMoney); + errorMsg = String.format("姣忔棩鏈�澶氭彁鐜�%s鍏�", maxDayMoney); } else if (new BigDecimal(minMoney).compareTo(money) > 0) { canExtract = false; errorMsg = String.format("姣忔鏈�浣庢彁鐜�%s鍏�", minMoney); @@ -943,39 +966,6 @@ } /** - * 瀹㈡埛绔彁鐜板瘑鐮佽緭鍏ラ敊璇椂璋冪敤 - * - * @param acceptData - * @param uid - * 鐢ㄦ埛id - * @param out - */ - @RequestMapping(value = "errormax", method = RequestMethod.POST) - public void errorMax(AcceptData acceptData, long uid, PrintWriter out) { - UserInfo user = userInfoService.getUserById(uid); - if (user == null) { - out.print(JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�")); - return; - } - PassWordErrorRecord record = passWordErrorRecordService.getRecord(user.getId()); - record.setUserInfo(user); - String maxErrorStr = "5"; - maxErrorStr = configService.get(PASSWORD_MAX_ERROR); // 褰撴棩杈撻敊瀵嗙爜鏈�澶氭鏁� - int maxError = Integer.parseInt(maxErrorStr); - int count = passWordErrorRecordService.setRecord(record); - JSONObject data = new JSONObject(); - int c = maxError - count; - if (c <= 0) { // 褰撻敊璇鏁拌繕鏈秴杩囧綋鏃ヨ緭閿欐渶澶氭鏁版椂锛宻tate涓�1锛屼唬琛ㄨ繕鑳界户缁緭鍏ワ紝little涓哄墿浣欐鏁般�俿tate涓�2鍒欎笉鑳界户缁緭鍏ワ紝鎻愮幇瀹㈡埛绔��鍑鸿緭鍏ュ瘑鐮佺晫闈� - data.put("state", "2"); - data.put("little", 0); - } else { - data.put("state", "1"); - data.put("little", c); - } - out.print(JsonUtil.loadTrueResult(data)); - } - - /** * 娣诲姞鐢ㄦ埛鎻愮幇璐﹀彿 * * @param acceptData @@ -1050,107 +1040,6 @@ return; } - /** - * 鎻愮幇 - * - * @param acceptData - * @param uid - * 鐢ㄦ埛id - * @param money - * 鎻愮幇閲戦 - * @param pwd - * 瀵嗙爜 - * @param request - * @param type - * 鎻愮幇璐︽埛绫诲瀷 - * @param out - */ - @RequestMapping(value = "extractmoney", method = RequestMethod.POST) - public void extractMoney(AcceptData acceptData, long uid, double money, String pwd, HttpServletRequest request, - int type, PrintWriter out) { - UserInfo user = userInfoService.getUserById(uid); - LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "]"); - if (user == null) { - LogHelper.userInfo("涓嶅瓨鍦ㄨ鐢ㄦ埛:uid=" + uid); - out.print(JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�")); - return; - } - System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages()); - if (system == null) { - LogHelper.userInfo("鎻愮幇鏃讹紝涓嶅瓨鍦ㄨ绯荤粺"); - out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); - return; - } - PassWordErrorRecord record = passWordErrorRecordService.getRecord(user.getId()); - int errorcount = record.getCount(); - String maxStr = "5"; - maxStr = configService.get(PASSWORD_MAX_ERROR); - int max = Integer.parseInt(maxStr); - if (max <= errorcount) { - LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "]鐢ㄦ埛[" + GsonUtil.toJson(user) + "]:鎻愮幇瀵嗙爜閿欒宸茶揪涓婇檺锛�"); - out.print(JsonUtil.loadFalseResult("鎻愮幇瀵嗙爜宸茶揪鍒版瘡鏃ラ敊璇鏁颁笂闄愶紝璇锋槑鏃ュ啀璇曪紒")); - return; - } - - if (pwd == null || !pwd.equals(user.getPayPassword())) { - passWordErrorRecordService.setRecord(record); - out.print(JsonUtil.loadFalseResult("鏀粯瀵嗙爜閿欒")); - return; - } - - passWordErrorRecordService.deleteRecord(uid);// 褰撴彁鐜板瘑鐮佽緭鍏ユ纭椂锛屾竻闄ゅ綋鍓嶇敤鎴风殑瀵嗙爜閿欒杈撳叆璁板綍 - - String minMoney = configService.get(EXTRACT_MIN_MONEY); // 鍗曠瑪鎻愮幇鏈�灏忛噾棰� - - if (money < 0.1) { // 杞笎鍒版敮浠樺疂鐨勬渶灏忛噾棰� - out.print(JsonUtil.loadFalseResult("鍗曠瑪鎻愮幇閲戦闇�瑕佸ぇ浜庯細" + 0.1 + "鍏�")); - return; - } - - double dminMoney = Double.parseDouble(minMoney); - if (money < dminMoney) { // 鍚庡彴璁剧疆鐨勫崟绗旇浆璐︾殑鏈�灏忛噾棰� - out.print(JsonUtil.loadFalseResult("鍗曠瑪鎻愮幇閲戦闇�瑕佸ぇ浜庯細" + dminMoney + "鍏�")); - return; - } - String maxMoney = configService.get(EXTRACT_MAX_MONEY); // 鍗曠瑪鎻愮幇鏈�澶ч噾棰� - double dmaxMoney = Double.parseDouble(maxMoney); - if (dmaxMoney < money) { // 鍚庡彴璁剧疆鐨勫崟绗旇浆璐︾殑鏈�澶ч噾棰� - out.print(JsonUtil.loadFalseResult("鍗曠瑪鎻愮幇閲戦澶氫负锛�" + dmaxMoney + "鍏�")); - return; - } - - if (type != Constant.ZHIFUBAO && type != Constant.WEIXIN) { // 鎻愮幇绫诲瀷蹇呴』鏄敮浠樺疂绫诲瀷鎴栬�呭井淇$被鍨嬶紝鐩墠锛�20170506锛変粎鏀寔鏀粯瀹� - out.print(JsonUtil.loadFalseResult(Constant.NOTYPE)); - return; - } - - BindingAccount bindingAccount = bindingAccountService.getBindingAccountByUidAndType(uid, type); - if (bindingAccount == null) { - out.print(JsonUtil.loadFalseResult(Constant.NOACCOUNT)); - return; - } - - Extract extract = new Extract(); - extract.setIp(IPUtil.getRemotIP(request)); - extract.setAccount(bindingAccount.getAccount()); - extract.setName(bindingAccount.getName()); - extract.setMoney(new BigDecimal(String.valueOf(money))); - extract.setUserInfo(user); - extract.setExtractTime(java.lang.System.currentTimeMillis()); - extract.setType(type); - extract.setState(0); - extract.setSystem(system); - Integer etype = extractService.addExtract(extract); - if (etype == null) { - out.print(JsonUtil.loadTrueResult("鎿嶄綔鎴愬姛")); - return; - } else if (etype == 1 || etype == 2) { - out.print(JsonUtil.loadFalseResult("宸茶秴杩囧綋鏃ユ彁鐜版鏁版垨鎻愮幇閲戦")); - } else if (etype == 3) { - out.print(JsonUtil.loadFalseResult("鎻愮幇閲戦澶т簬鎴戠殑绾㈠寘")); - } - - } /** * 鏂扮増鎻愮幇 @@ -1169,6 +1058,12 @@ HttpServletRequest request, int type, PrintWriter out) { UserInfo user = userInfoService.getUserById(uid); if (user == null) { + user = userInfoService.getUserByIdWithMybatis(uid); + if (user != null && user.getState() != UserInfo.STATE_NORMAL) { + out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC)); + return; + } + out.print(JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�")); return; } @@ -1185,7 +1080,8 @@ return; } - System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages()); + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages()); if (system == null) { LogHelper.userInfo("鎻愮幇鏃讹紝涓嶅瓨鍦ㄨ绯荤粺"); out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); @@ -1235,6 +1131,30 @@ JSONObject data = new JSONObject(); data.put("id", extract.getId()); out.print(JsonUtil.loadTrueResult(data)); + ThreadUtil.run(new Runnable() { + + @Override + public void run() { + JSONObject json = new JSONObject(); + json.put("timeStamp", java.lang.System.currentTimeMillis()); + json.put("adminId", 4L); + String sign = AESUtil.encrypt(json.toString(), Constant.ADMINH5_AESKEY); + String url = ""; + try { + url = String.format("%s?from=emailh5&sign=%s", + Constant.systemCommonConfig.getExtractNotifyUrl(), URLEncoder.encode(sign, "UTF-8")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + AdminUser adminUser = adminUserService.selectByPrimaryKey(4L); + Config config = configService.getConfig("extract_code_email_from"); + String[] sts = config.getValue().split(","); + String account = sts[0]; + String pwd = sts[1]; + String msg = "鎻愮幇瀹℃牳閾炬帴:" + url; + boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "鏈夋柊鐨勬彁鐜板鏍�", msg); + } + }); return; } else if (etype == 1) { out.print(JsonUtil.loadFalseResult("宸茶秴杩囧綋鏃ユ彁鐜版鏁�")); @@ -1287,29 +1207,6 @@ out.print(JsonUtil.loadTrueResult(data)); } - @RequestMapping(value = "openhongbao") - public void openHongBao(AcceptData acceptData, long hid, HttpServletRequest request, PrintWriter out) { - String ip = IPUtil.getRemotIP(request); - HongBaoExtra hbx = hongBaoService.open(hid, ip); - if (hbx == null) { - out.print(JsonUtil.loadFalseResult("绾㈠寘寮傚父")); - LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "] 鎵撳紑绾㈠寘[id=" + hid + "]澶辫触锛�"); - return; - } - JSONObject data = new JSONObject(); - data.put("hongBao", GsonUtil.toJsonExpose(hbx)); - out.print(JsonUtil.loadTrueResult(data)); - LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "] 鎵撳紑绾㈠寘[id=" + hid + "]鎴愬姛锛�"); - } - - @RequestMapping(value = "getHongBaoMessages", method = RequestMethod.POST) - public void getHongBaoMessages(AcceptData acceptData, PrintWriter out) { - List<HongBaoMessage> list = shamUserService.getManyData(); - JSONObject data = new JSONObject(); - data.put("list", list); - out.print(JsonUtil.loadTrueResult(data)); - } - @RequestMapping("findLostOrder") public void findLostOrder(AcceptData acceptData, LostOrder lostOrder, PrintWriter out) { boolean orderNum = true; @@ -1346,15 +1243,20 @@ @RequestMapping("findOrderItemList") public void findOrderItemList(AcceptData acceptData, long uid, int page, PrintWriter out) { - List<OrderItem> list = orderItemServcie.findOrderItemList(uid, page); - list.parallelStream().forEach(oi -> { - oi.setDesc(); - }); - int count = orderItemServcie.getCount(uid); + List<HongBaoOrder> list = hongBaoOrderService.listFanLiOrder(uid, page, Constant.PAGE_SIZE); + + List<OrderItem> orderList = new ArrayList<>(); + for (HongBaoOrder oi : list) { + OrderItem orderItem = OrderItemFactory.create(oi); + orderItem.setDesc(); + orderItem.setPicture(TbImgUtil.getTBSize220Img(orderItem.getPicture())); + orderList.add(orderItem); + } + long count = hongBaoOrderService.countFanLiOrder(uid); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().create(); JSONObject data = new JSONObject(); - data.put("list", gson.toJson(list)); + data.put("list", gson.toJson(orderList)); data.put("count", count); out.print(JsonUtil.loadTrueResult(data)); } @@ -1369,28 +1271,18 @@ */ @RequestMapping("getTiChengOrderList") public void getTiChengOrderList(AcceptData acceptData, long uid, int page, PrintWriter out) { - List<HongBao> list = hongBaoService.getTiChengHongBaoList(uid, page); - long count = hongBaoService.getTiChengHongBaoListCount(uid); + List<HongBaoDTO> hongBaoDTOList = hongBaoV2Service.listJiangJinByUid(uid, page, Constant.PAGE_SIZE); + List<HongBao> list = new ArrayList<>(); + if (hongBaoDTOList != null) + for (HongBaoDTO dto : hongBaoDTOList) { + list.add(HongBaoFactory.createHongBao(dto)); + } + long count = hongBaoV2Service.countJiangJinByUid(uid); List<OrderItem> orderItemList = HongBaoUtil.convertToTiChengOrder(list); Gson gson = JsonUtil.getApiCommonGson(); JSONObject data = new JSONObject(); data.put("list", gson.toJson(orderItemList)); data.put("count", count); - out.print(JsonUtil.loadTrueResult(data)); - } - - @RequestMapping("getOrderItem") - public void getOrderItem(AcceptData acceptData, long id, PrintWriter out) { - OrderItem orderItem = orderItemServcie.getOne(id); - if (orderItem == null) { - out.print(JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ璁㈠崟")); - return; - } - orderItem.setDesc(); - JSONObject data = new JSONObject(); - GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()); - Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - data.put("orderItem", gson.toJson(orderItem)); out.print(JsonUtil.loadTrueResult(data)); } @@ -1500,20 +1392,66 @@ List<CollectionGoodsV2> collectionGoodsList = collectionGoodsV2Service.getCollectionGoodsList(uid, page + 1, Constant.PAGE_SIZE); - // List<CollectionGoods> coList = - // collectionGoodsService.findCollectionGoods(uid, page + 1); + List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>(); + long count = collectionGoodsV2Service.getCollectionGoodsCount(uid); JSONObject data = new JSONObject(); - BigDecimal proportion = hongBaoManageService.getFanLiRate(); - List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>(); - collectionGoodsList.parallelStream().forEachOrdered(cg -> { - TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(cg.getCommonGoods()); - goodsBrief.setSalesCount(TaoBaoUtil.getSaleCount(goodsBrief.getBiz30day())); - TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, - proportion.toString(), ""); - taoBaoGoodsBriefExtra.setCreatetime(cg.getCreateTime()); - list.add(taoBaoGoodsBriefExtra); - }); + + List<TaoBaoGoodsBrief> listTaoKeGoods = new ArrayList<TaoBaoGoodsBrief>(); + if (collectionGoodsList != null && collectionGoodsList.size() > 0) { + + BigDecimal proportion = hongBaoManageService.getFanLiRate(); + + List<Long> listGid = new ArrayList<Long>(); + for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) { + CommonGoods commonGoods = collectionGoodsV2.getCommonGoods(); + if (commonGoods == null) { + continue; + } + listGid.add(commonGoods.getGoodsId()); + } + + try { + // API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭 + listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid); + } catch (TaoKeApiException e) { + e.printStackTrace(); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) { + CommonGoods commonGoods = collectionGoodsV2.getCommonGoods(); + if (commonGoods == null) { + continue; + } + + if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) { + int state = 1; // 榛樿鍋滃敭 + Long goodsId = commonGoods.getGoodsId(); + for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) { + Long auctionId = taoKeGoods.getAuctionId(); + if (goodsId == auctionId || goodsId.equals(auctionId)) { + state = 0; // 鍦ㄥ敭 + break; + } + } + commonGoods.setState(state); + } + + TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods); + goodsBrief.setSalesCount(TaoBaoUtil.getSaleCount(goodsBrief.getBiz30day())); + TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, + proportion.toString(), ""); + taoBaoGoodsBriefExtra.setCreatetime(collectionGoodsV2.getCreateTime()); + + list.add(taoBaoGoodsBriefExtra); + } + + } + GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { @Override public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { @@ -1575,8 +1513,11 @@ @RequestMapping("findAccountDetailsList") public void findAccountDetailsList(AcceptData acceptData, long uid, int page, PrintWriter out) { - List<AccountDetails> list = accountDetailsService.findAccountDetailsList(uid, page); - int count = accountDetailsService.getCount(uid); + List<UserMoneyDetail> detailList = userMoneyDetailService.listByUidWithState(uid, page, Constant.PAGE_SIZE); + List<AccountDetails> list = new ArrayList<>(); + for (UserMoneyDetail detail : detailList) + list.add(AccountDetailsFactory.create(detail)); + long count = userMoneyDetailService.countByUidWithState(uid); JSONObject data = new JSONObject(); data.put("list", GsonUtil.toJsonExpose(list)); data.put("count", count); @@ -1584,9 +1525,21 @@ } @RequestMapping("findAccountDetailsListV2") - public void findAccountDetailsListNew(AcceptData acceptData, long uid, int page, PrintWriter out) { - List<AccountDetails> list = accountDetailsService.findAccountDetailsListWithState(uid, page); - long count = accountDetailsService.getCountWithState(uid); + public void findAccountDetailsListNew(AcceptData acceptData, Long uid, int page, PrintWriter out) { + + if (uid == null) { + out.print(JsonUtil.loadFalseResult(1, "UID涓虹┖")); + return; + } + + List<UserMoneyDetail> detailList = userMoneyDetailService.listByUidWithState(uid, page, Constant.PAGE_SIZE); + + List<AccountDetails> list = new ArrayList<>(); + for (UserMoneyDetail detail : detailList) + list.add(AccountDetailsFactory.create(detail)); + + long count = userMoneyDetailService.countByUidWithState(uid); + JSONObject data = new JSONObject(); JSONArray array = new JSONArray(); for (AccountDetails ad : list) { @@ -1598,19 +1551,6 @@ } data.put("list", array); data.put("count", count); - out.print(JsonUtil.loadTrueResult(data)); - } - - @RequestMapping(value = "isWxDown") - - public void isWxDown(AcceptData acceptData, PrintWriter out) { - boolean b = wxDownService.isWxDownFirstLogin(acceptData.getDevice()); - // IOS涓婄嚎娴嬭瘯 - if (Integer.parseInt(acceptData.getVersion()) >= 22 - && acceptData.getPackages().equalsIgnoreCase(Constant.systemCommonConfig.getIosBundleId())) - b = false; - JSONObject data = new JSONObject(); - data.put("isFirst", b); out.print(JsonUtil.loadTrueResult(data)); } @@ -1631,28 +1571,91 @@ @RequestMapping(value = "getMyTeam", method = RequestMethod.POST) public void getMyTeam(AcceptData acceptData, long page, long uid, long type, PrintWriter out) { - int pageSize = Constant.PAGE_SIZE; + try { + int pageSize = Constant.PAGE_SIZE; - JSONObject resultData = new JSONObject(); - if (type == 1) { - resultData = threeSaleSerivce.getMyFirstTeam((page - 1) * pageSize, pageSize, uid); - } else if (type == 2) { - resultData = threeSaleSerivce.getMySecondTeam((page - 1) * pageSize, pageSize, uid); + JSONObject resultData = new JSONObject(); + if (type == 1) { + resultData = threeSaleSerivce.getMyFirstTeam((page - 1) * pageSize, pageSize, uid); + } else if (type == 2) { + resultData = threeSaleSerivce.getMySecondTeam((page - 1) * pageSize, pageSize, uid); + } + + // 瀹夊崜绯荤粺杩斿洖鎵�鏈夋暟鎹� + String platform = acceptData.getPlatform(); + if ("android".equalsIgnoreCase(platform)) { + long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1); + long firstTeamTotal = threeSaleSerivce.countFirstTeam(uid, null); + + long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1); + long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null); + + JSONObject bossData = null; + ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); + if (threeSale != null) { + bossData = new JSONObject(); + UserInfo boss = threeSale.getBoss(); + if (boss != null) { + bossData.put("nickName", boss.getNickName()); + bossData.put("portrait", boss.getPortrait()); + } + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); + Long createTime = threeSale.getCreateTime(); + Date inviteTime = new Date(createTime); + bossData.put("inviteTime", "閭�璇锋椂闂�: " + sdf.format(inviteTime)); + } + + String helpLink = configService.get("team_help_url"); + if (helpLink == null) { + helpLink = ""; + } + + boolean hasCode = false; + String inviteCode = userInfoExtraService.getUserInviteCode(uid); + if (inviteCode != null && inviteCode.trim().length() > 0) { + hasCode = true; // 宸叉湁閭�璇风爜 + } else { + // 閭�璇锋縺娲婚摼鎺� + resultData.put("activationlink", configService.get("invite_activation_url")); + } + resultData.put("hasCode", hasCode); + + resultData.put("helpLink", helpLink); + resultData.put("firstTeam", firstTeam); + resultData.put("firstTeamTotal", firstTeamTotal); + resultData.put("secondTeam", secondTeam); + resultData.put("secondTeamTotal", secondTeamTotal); + resultData.put("boss", bossData); + } + out.print(JsonUtil.loadTrueResult(resultData)); + } catch (UserInfoExtraException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("缁熻澶辫触")); + e.printStackTrace(); } - // 瀹夊崜绯荤粺杩斿洖鎵�鏈夋暟鎹� - String platform = acceptData.getPlatform(); - if ("android".equalsIgnoreCase(platform)) { + } + + /** + * 鐢ㄦ埛闃熷憳缁熻 1.4.1 + * + * @param acceptData + * @param id + * @param out + */ + @RequestMapping(value = "countMyTeam", method = RequestMethod.POST) + public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) { + try { long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1); long firstTeamTotal = threeSaleSerivce.countFirstTeam(uid, null); long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1); long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null); - - JSONObject bossData = null; + JSONObject bossData = new JSONObject(); ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); if (threeSale != null) { - bossData = new JSONObject(); UserInfo boss = threeSale.getBoss(); if (boss != null) { bossData.put("nickName", boss.getNickName()); @@ -1665,6 +1668,8 @@ bossData.put("inviteTime", "閭�璇锋椂闂�: " + sdf.format(inviteTime)); } + JSONObject resultData = new JSONObject(); + String helpLink = configService.get("team_help_url"); if (helpLink == null) { helpLink = ""; @@ -1675,54 +1680,26 @@ resultData.put("secondTeam", secondTeam); resultData.put("secondTeamTotal", secondTeamTotal); resultData.put("boss", bossData); - } - out.print(JsonUtil.loadTrueResult(resultData)); - } - /** - * 鐢ㄦ埛闃熷憳缁熻 1.4.1 - * - * @param acceptData - * @param id - * @param out - */ - @RequestMapping(value = "countMyTeam", method = RequestMethod.POST) - public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) { - - long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1); - long firstTeamTotal = threeSaleSerivce.countFirstTeam(uid, null); - - long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1); - long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null); - JSONObject bossData = new JSONObject(); - ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); - if (threeSale != null) { - UserInfo boss = threeSale.getBoss(); - if (boss != null) { - bossData.put("nickName", boss.getNickName()); - bossData.put("portrait", boss.getPortrait()); + boolean hasCode = false; + String inviteCode = userInfoExtraService.getUserInviteCode(uid); + if (inviteCode != null && inviteCode.trim().length() > 0) { + hasCode = true; // 宸叉湁閭�璇风爜 + } else { + // 閭�璇锋縺娲婚摼鎺� + resultData.put("activationlink", configService.get("invite_activation_url")); } + resultData.put("hasCode", hasCode); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); - Long createTime = threeSale.getCreateTime(); - Date inviteTime = new Date(createTime); - bossData.put("inviteTime", "閭�璇锋椂闂�: " + sdf.format(inviteTime)); + out.print(JsonUtil.loadTrueResult(resultData)); + + } catch (UserInfoExtraException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("缁熻澶辫触")); + e.printStackTrace(); } - JSONObject resultData = new JSONObject(); - - String helpLink = configService.get("team_help_url"); - if (helpLink == null) { - helpLink = ""; - } - resultData.put("helpLink", helpLink); - resultData.put("firstTeam", firstTeam); - resultData.put("firstTeamTotal", firstTeamTotal); - resultData.put("secondTeam", secondTeam); - resultData.put("secondTeamTotal", secondTeamTotal); - resultData.put("boss", bossData); - - out.print(JsonUtil.loadTrueResult(resultData)); } /** @@ -1815,7 +1792,121 @@ out.print(JsonUtil.loadFalseResult("鍒犻櫎澶辫触")); e.printStackTrace(); } - } + /** + * 璁剧疆鐣岄潰寮�鍏崇姸鎬� + * + * @param acceptData + * @param uid + * @param params + * @param out + */ + @RequestMapping(value = "setModuleState", method = RequestMethod.POST) + public void setModuleState(AcceptData acceptData, Long uid, String params, PrintWriter out) { + + if (uid == null) { + out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + + try { + if (params == null || params.trim().length() == 0) { + out.print(JsonUtil.loadFalseResult("浼犻�掑弬鏁颁负绌�")); + return; + } + + JSONObject json = JSONObject.fromObject(params); + Iterator<String> iterator = json.keys(); + while (iterator.hasNext()) { + String type = (String) iterator.next(); + int state = json.getInt(type); + userCustomSettingsService.saveModuleState(uid, type, state); + } + out.print(JsonUtil.loadTrueResult("璁剧疆鎴愬姛")); + + } catch (UserCustomSettingsException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("璁剧疆澶辫触")); + e.printStackTrace(); + } + } + + /** + * 鑾峰彇绛夌骇淇℃伅 + * + * @param acceptData + * @param uid + * @param out + */ + @RequestMapping(value = "getRankInfo", method = RequestMethod.POST) + public void getRankInfo(AcceptData acceptData, Long uid, PrintWriter out) { + + if (uid == null) { + out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + + try { + UserInfoExtraVO rankInfo = userInfoExtraService.getRankInfo(uid); + GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()); + gsonBuilder.excludeFieldsWithoutExposeAnnotation(); + Gson gson = gsonBuilder.setDateFormat("yyyy.MM.dd").create(); + + JSONObject resultData = new JSONObject(); + resultData.put("rankInfo", gson.toJson(rankInfo)); + + out.print(JsonUtil.loadTrueResult(resultData)); + + } catch (UserInfoExtraException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("鑾峰彇澶辫触")); + e.printStackTrace(); + } + } + + /** + * 鑾峰彇绛夌骇淇℃伅 + * + * @param acceptData + * @param uid + * @param out + */ + @RequestMapping(value = "getUserConfig", method = RequestMethod.POST) + public void getUserConfig(AcceptData acceptData, Long uid, PrintWriter out) { + + if (uid == null) { + out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + + try { + + String inviteCode = userInfoExtraService.getUserInviteCode(uid); + + JSONObject inviteData = new JSONObject(); + if (inviteCode == null || inviteCode.trim().length() == 0) { + // 鏃犻個璇风爜 + inviteData.put("content", "閭�璇锋縺娲�"); + inviteData.put("link", configService.get("invite_activation_url")); + } else { + // 宸叉湁閭�璇风爜 + inviteData.put("content", "閭�璇风爜"); + inviteData.put("link", configService.get("invite_activation_success_url")); + } + + JSONObject data = new JSONObject(); + data.put("invite", inviteData); + + out.print(JsonUtil.loadTrueResult(data)); + + } catch (UserInfoExtraException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("鑾峰彇澶辫触")); + e.printStackTrace(); + } + } } -- Gitblit v1.8.0