From 88b54772dbcf5ecab1e2316e4e4626ac901b8908 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 22 一月 2019 15:58:24 +0800 Subject: [PATCH] 邀请码添加返回状态 --- fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java | 654 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 554 insertions(+), 100 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 089bf1a..5b2d0c0 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,22 +1,21 @@ 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.Map; import java.util.UUID; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; import org.apache.commons.beanutils.PropertyUtils; import org.springframework.stereotype.Controller; @@ -26,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; @@ -34,42 +34,55 @@ import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; +import com.yeshi.fanli.dto.HongBaoDTO; 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.CollectionGoods; 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.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.goods.CommonGoods; +import com.yeshi.fanli.entity.money.UserMoneyDetail; +import com.yeshi.fanli.entity.order.HongBaoOrder; import com.yeshi.fanli.entity.system.System; 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.ConfigService; import com.yeshi.fanli.service.inter.config.SystemService; -import com.yeshi.fanli.service.inter.goods.CollectionGoodsService; +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; @@ -77,10 +90,16 @@ 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.UserMoneyDetailService; +import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService; import com.yeshi.fanli.service.inter.user.WxDownService; +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 +109,18 @@ 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; @Controller @RequestMapping("api/v1/customer") @@ -125,13 +154,13 @@ private SystemService systemService; @Resource - private HongBaoMessageService hongBaoMessageService; - - @Resource private ShamUserService shamUserService; @Resource private ThreeSaleSerivce threeSaleSerivce; + + @Resource + private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce; @Resource private LostOrderService lostOrderService; @@ -140,13 +169,8 @@ private OrderItemServcie orderItemServcie; @Resource - private AccountDetailsService accountDetailsService; - - @Resource private AccountMessageService accountMessageService; - @Resource - private CollectionGoodsService collectionGoodsService; @Resource private HongBaoManageService hongBaoManageService; @@ -164,6 +188,34 @@ @Resource private UserActiveLogService userActiveLogService; + + @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; + private static final String PASSWORD_MAX_ERROR = "password_max_error"; private static final String EXTRACT_MIN_MONEY = "extract_min_money"; @@ -459,12 +511,54 @@ data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create() .toJson(UserUtil.filterForClientUser(user))); 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); + out.print(JsonUtil.loadTrueResult(data)); final UserInfo uuser = user; ThreadUtil.run(new Runnable() { @@ -687,16 +781,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")); @@ -716,6 +803,7 @@ data.put("minMoney", minMoney); data.put("maxMoney", maxMoney); + data.put("maxDayCount", maxDayCount); data.put("bindingAccountList", gson.toJson(filterBindingAccount(bindingAccountList))); JSONObject alipayVerify = new JSONObject(); @@ -764,7 +852,7 @@ ExtractRecord extractRecord = extractRecordService.getExtractRecordByUid(uid); boolean canExtract = true; String errorMsg = ""; - if (extractRecord != null && extractRecord.getCount() + 1 >= maxDayCount) { + if (extractRecord != null && extractRecord.getCount() + 1 > maxDayCount) { canExtract = false; errorMsg = String.format("姣忔棩鏈�澶氭彁鐜�%s娆�", maxDayCount + ""); } else if (extractRecord != null @@ -1227,6 +1315,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("宸茶秴杩囧綋鏃ユ彁鐜版鏁�")); @@ -1294,14 +1406,6 @@ 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; @@ -1338,15 +1442,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)); } @@ -1361,8 +1470,13 @@ */ @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(); @@ -1413,24 +1527,32 @@ @RequestMapping("collectionGoods") public void collectionGoods(AcceptData acceptData, long uid, long auctionId, int type, PrintWriter out) { - CollectionGoods find = collectionGoodsService.findByUidAndAuctionId(uid, auctionId); + CollectionGoodsV2 find = collectionGoodsV2Service.findByUidAndAuctionId(uid, auctionId); if (type == 1) { if (find != null) { out.print(JsonUtil.loadFalseResult("")); return; } - CollectionGoods cg = TaoBaoUtil.getCollectionGoods(auctionId, new UserInfo(uid)); - collectionGoodsService.save(cg); - out.print(JsonUtil.loadTrueResult("鏀惰棌鎴愬姛")); - return; + try { + TaoBaoGoodsBrief taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId); + collectionGoodsV2Service.addCollection(uid, taoBaoGoodsBrief); + out.print(JsonUtil.loadTrueResult("鏀惰棌鎴愬姛")); + } catch (TaobaoGoodsDownException e) { + out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧宸蹭笅鏋�")); + } catch (CollectionGoodsException e1) { + out.print(JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg())); + } } else { if (find == null) { out.print(JsonUtil.loadTrueResult("鍙栨秷鏀惰棌鎴愬姛")); return; } else { - collectionGoodsService.delete(find); - out.print(JsonUtil.loadTrueResult("鍙栨秷鏀惰棌鎴愬姛")); - return; + try { + collectionGoodsV2Service.cancelCollectionByAuctionId(uid, auctionId); + out.print(JsonUtil.loadTrueResult("鍙栨秷鏀惰棌鎴愬姛")); + } catch (CollectionGoodsException e) { + out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); + } } } @@ -1453,39 +1575,97 @@ return; } - CollectionGoods find = collectionGoodsService.findByUidAndAuctionId(uid, auctionId); + CollectionGoodsV2 find = collectionGoodsV2Service.findByUidAndAuctionId(uid, auctionId); if (find == null) { // 娣诲姞鏀惰棌 - CollectionGoods cg = TaoBaoUtil.getCollectionGoods(auctionId, new UserInfo(uid)); - collectionGoodsService.save(cg); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(1)); + try { + TaoBaoGoodsBrief taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId); + collectionGoodsV2Service.addCollection(uid, taoBaoGoodsBrief); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(1)); + } catch (TaobaoGoodsDownException e) { + JsonUtil.printMode(out, callback, (JsonUtil.loadFalseResult(1, "鍟嗗搧宸蹭笅鏋�"))); + } catch (CollectionGoodsException e1) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg())); + } } else { // 鍙栨秷鏀惰棌 - collectionGoodsService.delete(find); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(0)); + try { + collectionGoodsV2Service.cancelCollectionByAuctionId(uid, auctionId); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鍙栨秷鏀惰棌鎴愬姛")); + } catch (CollectionGoodsException e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); + } } } @RequestMapping("collectionGoodsList") public void collectionGoodsList(AcceptData acceptData, long uid, int page, PrintWriter out) { - List<CollectionGoods> coList = collectionGoodsService.findCollectionGoods(uid, page + 1); - int count = collectionGoodsService.getCount(uid); - JSONObject data = new JSONObject(); - Map<String, String> map = hongBaoManageService.convertMap(); - String proportion = map.get("hongbao_goods_proportion"); - String fcRate = map.get("hongbao_fc_ratio"); - List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>(); - coList.parallelStream().forEachOrdered(cg -> { - TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.getTaoBaoGoodsBrief(cg); - goodsBrief.setSalesCount(TaoBaoUtil.getSaleCount(goodsBrief.getBiz30day())); - TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, - fcRate, ""); - taoBaoGoodsBriefExtra.setCreatetime(new Date(cg.getCreateTime())); - list.add(taoBaoGoodsBriefExtra); - }); + List<CollectionGoodsV2> collectionGoodsList = collectionGoodsV2Service.getCollectionGoodsList(uid, page + 1, + Constant.PAGE_SIZE); + + List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>(); + + long count = collectionGoodsV2Service.getCollectionGoodsCount(uid); + JSONObject data = new JSONObject(); + + 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) { @@ -1511,7 +1691,11 @@ } else { if (!StringUtil.isNullOrEmpty(ids)) { Arrays.asList(ids.split(",")).parallelStream().forEach(auctionIdStr -> { - collectionGoodsService.delete(Long.parseLong(auctionIdStr), uid); + try { + collectionGoodsV2Service.cancelCollectionByAuctionId(uid, Long.parseLong(auctionIdStr)); + } catch (Exception e) { + e.printStackTrace(); + } }); } } @@ -1520,7 +1704,12 @@ @RequestMapping("clearConllectionGoods") public void clearConllectionGoods(AcceptData acceptData, long uid, PrintWriter out) { - collectionGoodsService.clear(uid); + try { + collectionGoodsV2Service.cancelCollectionByUid(uid); + } catch (CollectionGoodsException e) { + e.printStackTrace(); + out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage())); + } out.print(JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛")); } @@ -1538,8 +1727,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); @@ -1547,9 +1739,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) { @@ -1584,67 +1788,317 @@ .loadTrueResult(String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl()))); } - /** * 鐢ㄦ埛闃熷憳鍒楄〃鏌ヨ 1.4.1 + * * @param acceptData * @param id * @param out */ - @RequestMapping(value = "getMyTeam") + @RequestMapping(value = "getMyTeam", method = RequestMethod.POST) public void getMyTeam(AcceptData acceptData, long page, long uid, long type, PrintWriter out) { - + 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); - } else if (type == 3) { - + } + + // 瀹夊崜绯荤粺杩斿洖鎵�鏈夋暟鎹� + 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) { - resultData.put("nickName", boss.getNickName()); - resultData.put("portrait", boss.getPortrait()); + bossData.put("nickName", boss.getNickName()); + bossData.put("portrait", boss.getPortrait()); } - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); Long createTime = threeSale.getCreateTime(); Date inviteTime = new Date(createTime); - resultData.put("inviteTime", "閭�璇锋椂闂�:" + sdf.format(inviteTime)); + bossData.put("inviteTime", "閭�璇锋椂闂�: " + sdf.format(inviteTime)); } + + 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)); } - + /** * 鐢ㄦ埛闃熷憳缁熻 1.4.1 + * * @param acceptData * @param id * @param out */ - @RequestMapping(value = "countMyTeam") + @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()); + } + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); + Long createTime = threeSale.getCreateTime(); + Date inviteTime = new Date(createTime); + bossData.put("inviteTime", "閭�璇锋椂闂�: " + sdf.format(inviteTime)); + } + 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)); } + + /** + * 鐢ㄦ埛闃熷憳淇℃伅淇濆瓨 1.4.1 + * + * @param acceptData + * @param uid + * @param inviteId + * 閭�璇穒d + * @param nickname + * @param out + */ + @RequestMapping(value = "setextrainfo", method = RequestMethod.POST) + public void setExtraInfo(AcceptData acceptData, long uid, long inviteId, String memoName, PrintWriter out) { + + try { + List<ThreeSale> listThreeSale = threeSaleSerivce.listbyIdAndBossId(inviteId, uid, null); + if (listThreeSale == null || listThreeSale.size() == 0) { + out.print(JsonUtil.loadFalseResult("璇ヨ褰曚笉瀛樺湪")); + return; + } + + UserInfo worker = listThreeSale.get(0).getWorker(); + if (worker == null) { + out.print(JsonUtil.loadFalseResult("璇ヨ褰曚笉瀛樺湪")); + return; + } + + List<ThreeSaleExtraInfo> list = threeSaleExtraInfoSerivce.listbyBossIdAndWorkerId(uid, worker.getId()); + if (list == null || list.size() == 0) { + + ThreeSaleExtraInfo extraInfo = new ThreeSaleExtraInfo(); + extraInfo.setWorker(worker); + extraInfo.setNickname(memoName); + extraInfo.setCreateTime(new Date()); + extraInfo.setUpdateTime(new Date()); + + UserInfo boss = new UserInfo(uid); + extraInfo.setBoss(boss); + + threeSaleExtraInfoSerivce.insert(extraInfo); + + } else { + ThreeSaleExtraInfo extraInfo = list.get(0); + extraInfo.setNickname(memoName); + extraInfo.setUpdateTime(new Date()); + threeSaleExtraInfoSerivce.updateByPrimaryKey(extraInfo); + } + + out.print(JsonUtil.loadTrueResult("淇濆瓨鎴愬姛")); + + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("淇濆瓨澶辫触")); + e.printStackTrace(); + } + + } + + /** + * 鍒犻櫎闃熷憳鍏崇郴 + * + * @param acceptData + * @param uid + * @param inviteId + * 閭�璇穒d + * @param out + */ + @RequestMapping(value = "removethreesale", method = RequestMethod.POST) + public void removethreesale(AcceptData acceptData, long uid, long inviteId, PrintWriter out) { + try { + List<ThreeSale> listThreeSale = threeSaleSerivce.listbyIdAndBossId(inviteId, uid, 1); + if (listThreeSale == null || listThreeSale.size() == 0) { + out.print(JsonUtil.loadFalseResult("鎿嶄綔鏁版嵁鏃犳晥")); + return; + } + + UserInfo worker = listThreeSale.get(0).getWorker(); + if (worker == null) { + out.print(JsonUtil.loadFalseResult("鎿嶄綔鏁版嵁鏃犳晥")); + return; + } + + // 鍒犻櫎鍏崇郴 + threeSaleSerivce.deleteByPrimaryKey(inviteId); + // 鍒犻櫎澶囨敞 + threeSaleExtraInfoSerivce.deleteByBossIdAndWorkerId(uid, worker.getId()); + + out.print(JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛")); + } catch (Exception e) { + 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