From d8359ddb48dab5cc797a9d552e11fde571f4920c Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 27 八月 2019 12:32:46 +0800 Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div --- fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java | 252 +++++++++++++++++++++++++++---------------------- 1 files changed, 139 insertions(+), 113 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java index df5a248..5cf5c24 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java @@ -1190,9 +1190,9 @@ } // 鑾峰彇娴忚璁板綍 - @RequestMapping(value = "getscanhistory", method = RequestMethod.POST) - public void getScanHistory(AcceptData acceptData, String uid, int page, Integer goodsType, PrintWriter out) { - + @RequestMapping(value = "getscanhistory", method = RequestMethod.POST) + public void getScanHistory(AcceptData acceptData, String uid, int page, PrintWriter out) { + if (page < 0) { out.print(JsonUtil.loadFalseResult(1, "page涓嶅皬浜�0")); return; @@ -1204,50 +1204,59 @@ out.print(JsonUtil.loadFalseResult(1, "涓嶅瓨鍦ㄨ绯荤粺")); return; } - List<ScanHistoryV2> list = scanHistoryV2Service.getScanHistoryByDeviceOrUid( - StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), page, 20, goodsType); - long count = scanHistoryV2Service.getCountByDeviceOrUid( - StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), goodsType); + try { + List<ScanHistoryV2> list = scanHistoryV2Service.getScanHistoryByDeviceOrUid( + StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), page, 20, + Constant.SOURCE_TYPE_TAOBAO); + long count = scanHistoryV2Service.getCountByDeviceOrUid( + StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), + Constant.SOURCE_TYPE_TAOBAO); - - JSONObject data = new JSONObject(); - data.put("count", count); - JSONArray array = new JSONArray(); + JSONObject data = new JSONObject(); + data.put("count", count); + JSONArray array = new JSONArray(); - GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()); - gsonBuilder.excludeFieldsWithoutExposeAnnotation(); - gsonBuilder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() { - @Override - public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { - if (value == null) { - return new JsonPrimitive(""); - } else { - return new JsonPrimitive(value.getTime() + ""); + GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()); + gsonBuilder.excludeFieldsWithoutExposeAnnotation(); + gsonBuilder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() { + @Override + public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { + if (value == null) { + return new JsonPrimitive(""); + } else { + return new JsonPrimitive(value.getTime() + ""); + } + } + }); + + Gson gson = gsonBuilder.create(); + + if (list != null) { + BigDecimal proportion = manageService.getFanLiRate(); + for (ScanHistoryV2 sh : list) { + TaoBaoGoodsBrief goods = TaoBaoUtil.convert(sh.getCommonGoods()); + goods.setId(sh.getId()); + TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion.toString(), ""); + extra.setCreatetime(sh.getCreateTime()); + array.add(gson.toJson(extra)); } } - }); - - Gson gson = gsonBuilder.create(); - - if (list != null) { - BigDecimal proportion = manageService.getFanLiRate(); - for (ScanHistoryV2 sh : list) { - TaoBaoGoodsBrief goods = TaoBaoUtil.convert(sh.getCommonGoods()); - goods.setId(sh.getId()); - TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion.toString(), ""); - extra.setCreatetime(sh.getCreateTime()); - array.add(gson.toJson(extra)); - } + data.put("data", array); + out.print(JsonUtil.loadTrueResult(data)); + return; + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + JSONObject data = new JSONObject(); + data.put("data", new JSONArray()); + data.put("count", 0); + out.print(JsonUtil.loadTrueResult(data)); } - data.put("data", array); - out.print(JsonUtil.loadTrueResult(data)); - return; + } @RequestMapping(value = "deletescanhistory", method = RequestMethod.POST) - public void deleteScanHistory(AcceptData acceptData, String type, String uid, String ids, - Integer goodsType, PrintWriter out) { + public void deleteScanHistory(AcceptData acceptData, String type, String uid, String ids, PrintWriter out) { BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(), acceptData.getPackages()); if (sys == null) { @@ -1260,11 +1269,11 @@ for (String auctionIdStr : idStr) { scanHistoryV2Service.deleteByAuctionIdAndDeviceOrUid( StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), - Long.parseLong(auctionIdStr), goodsType); + Long.parseLong(auctionIdStr)); } } else { scanHistoryV2Service.deleteByDeviceOrUid(StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), - acceptData.getDevice(), goodsType); + acceptData.getDevice()); } out.print(JsonUtil.loadTrueResult("")); @@ -1342,10 +1351,18 @@ HttpServletRequest request, PrintWriter out) { int pageSize = Constant.PAGE_SIZE; JSONArray array = new JSONArray(); + Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); if (VersionUtil.greaterThan_1_5_70(acceptData.getPlatform(), acceptData.getVersion())) { List<TaoBaoGoodsBrief> goodsList = homeRecommendGoodsService.listGoodsByPage(null, acceptData.getDevice(), imei, idfa, page); + + if (page < 4) {// 鍓嶄笁椤靛姞鍏ユ洿鏂� + try { + taoBaoGoodsUpdateService.addUpdateQueueAsync(goodsList); + } catch (Exception e) { + } + } BigDecimal rate = hongBaoManageService.getFanLiRate(); for (TaoBaoGoodsBrief goods : goodsList) { @@ -1362,7 +1379,11 @@ } if (page == 1) { - List<TLJBuyGoods> list = homeRecommendGoodsService.getZiGouLiJianHotGoods(acceptData.getDevice()); + List<TLJBuyGoods> list = null; + try { + list = homeRecommendGoodsService.getZiGouLiJianHotGoods(acceptData.getDevice()); + } catch (Exception e) { + } if (list != null && list.size() > 0) for (int i = list.size() - 1; i >= 0; i--) { TLJBuyGoods goods = list.get(i); @@ -2083,7 +2104,8 @@ if (uid == null) { data.put("collected", false); } else { - CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id, Constant.SOURCE_TYPE_TAOBAO); + CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id, + Constant.SOURCE_TYPE_TAOBAO); data.put("collected", collectionGoods != null ? true : false); } @@ -2122,7 +2144,8 @@ } String token = ""; - if (!StringUtil.isNullOrEmpty(tb.getCouponLink())) { + if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) + && VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) { token = redisManager.getCommonTaoToken(tb.getAuctionId()); if (StringUtil.isNullOrEmpty(token)) { token = TaoKeApiUtil.getTKToken(tb.getPictUrl(), tb.getTitle(), tb.getCouponLink()); @@ -2162,6 +2185,8 @@ // 绾㈠寘 if (hongBao == null) { BigDecimal proportion = manageService.getFanLiRate(); + if ("taolijin".equalsIgnoreCase(from)) + proportion = manageService.getTLJShareRate(System.currentTimeMillis()); hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion); } goodsJson.put("hongBao", hongBao); @@ -2250,7 +2275,7 @@ // 鎺ㄥ箍绾㈠寘 if (from != null && from.equals("taolijin")) { // 璁$畻鎺ㄥ箍绾㈠寘 - String warningRate = configTaoLiJinService.getValueByKey("warning_value"); + String warningRate = configTaoLiJinService.getValueByKey("warning_value", null); BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); // 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1 @@ -2309,7 +2334,7 @@ data.put("userHongbao", userMoneyExtra.getTlj().setScale(2).toString()); } - noRebateHelpLink = configTaoLiJinService.getValueByKey("share_goods_help_link"); + noRebateHelpLink = configTaoLiJinService.getValueByKey("share_goods_help_link", null); if (Constant.IS_TEST) { fanliValid = true; @@ -2444,82 +2469,83 @@ @RequestMapping(value = "getgoodsderivation", method = RequestMethod.POST) public void getRecommendGoods(AcceptData acceptData, long id, PrintWriter out) { - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), - acceptData.getPackages()); - if (system == null) { - out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); - return; - } - - List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10); - // 鍒濆鍖� - if (goodsList == null) { - goodsList = new ArrayList<TaoBaoGoodsBrief>(); - } - - BigDecimal proportion = manageService.getFanLiRate(); - - List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>(); - - TaoKeAppInfo app = new TaoKeAppInfo(); - app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); - app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); - app.setAdzoneId(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]); - app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT); - - List<Long> ids = new ArrayList<>(); - for (TaoBaoGoodsBrief goods : goodsList) - ids.add(goods.getAuctionId()); - try { - goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids); - } catch (TaoKeApiException e1) { - e1.printStackTrace(); - } catch (TaobaoGoodsDownException e1) { - e1.printStackTrace(); - } - if (goodsList != null && goodsList.size() > 0) - goodsList.parallelStream().forEach(goods -> { - if (goods != null) { - // 鑾峰彇璇︽儏 - TaoBaoGoodsBrief taoBaoGoodsBrief = null; - try { - taoBaoGoodsBrief = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goods.getAuctionId()); - } catch (Exception e) { - e.printStackTrace(); + List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10); + // 鍒濆鍖� + if (goodsList == null) { + goodsList = new ArrayList<TaoBaoGoodsBrief>(); + } + + BigDecimal proportion = manageService.getFanLiRate(); + + List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>(); + + TaoKeAppInfo app = new TaoKeAppInfo(); + app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); + app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + app.setAdzoneId(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]); + app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT); + + List<Long> ids = new ArrayList<>(); + for (TaoBaoGoodsBrief goods : goodsList) + ids.add(goods.getAuctionId()); + + try { + goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids); + } catch (TaoKeApiException e1) { + e1.printStackTrace(); + } catch (TaobaoGoodsDownException e1) { + e1.printStackTrace(); + } + + if (goodsList != null && goodsList.size() > 0) + goodsList.parallelStream().forEach(goods -> { + if (goods != null) { + // 鑾峰彇璇︽儏 + TaoBaoGoodsBrief taoBaoGoodsBrief = null; + try { + taoBaoGoodsBrief = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goods.getAuctionId()); + } catch (Exception e) { + e.printStackTrace(); + } + + if (taoBaoGoodsBrief == null) { + TaoBaoGoodsBrief newGoods = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app); + goods.setCouponInfo(newGoods.getCouponInfo()); + goods.setCouponLink(newGoods.getCouponLink()); + goods.setTkRate(newGoods.getTkRate()); + taoBaoGoodsBrief = goods; + } + + if (taoBaoGoodsBrief != null) { + listExtra.add( + TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "")); + } } + }); - if (taoBaoGoodsBrief == null) { - TaoBaoGoodsBrief newGoods = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app); - goods.setCouponInfo(newGoods.getCouponInfo()); - goods.setCouponLink(newGoods.getCouponLink()); - goods.setTkRate(newGoods.getTkRate()); - taoBaoGoodsBrief = goods; - } + List<TaoBaoGoodsBrief> listQuality = new ArrayList<TaoBaoGoodsBrief>(); - if (taoBaoGoodsBrief != null) { - listExtra.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "")); - } - } - }); + // 鍙栧伓鏁颁釜鏁版嵁 + if (listExtra.size() % 2 != 0) { + listExtra.remove(listExtra.size() - 1); + } - List<TaoBaoGoodsBrief> listQuality = new ArrayList<TaoBaoGoodsBrief>(); + if (listQuality.size() % 2 != 0) { + listQuality.remove(listQuality.size() - 1); + } - // 鍙栧伓鏁颁釜鏁版嵁 - if (listExtra.size() % 2 != 0) { - listExtra.remove(listExtra.size() - 1); + JSONObject data = new JSONObject(); + data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra)); + data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality)); + out.print(JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + JSONObject data = new JSONObject(); + data.put("listQuality", new JSONArray()); + data.put("listGuess", new JSONArray()); + out.print(JsonUtil.loadTrueResult(data)); } - - if (listQuality.size() % 2 != 0) { - listQuality.remove(listQuality.size() - 1); - } - - JSONObject data = new JSONObject(); - data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra)); - data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality)); - - out.print(JsonUtil.loadTrueResult(data)); } /** -- Gitblit v1.8.0