From 573c491b4a1ba60e12a5678a01c1546c0077c1ee Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 30 七月 2019 09:07:42 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsClassController.java | 123 ++++++++++++++++++++++++++++++++++------- 1 files changed, 102 insertions(+), 21 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsClassController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsClassController.java index 89e981f..1034e13 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsClassController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsClassController.java @@ -3,6 +3,7 @@ import java.io.PrintWriter; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -22,6 +23,7 @@ import com.yeshi.fanli.entity.bus.clazz.GoodsClass; import com.yeshi.fanli.entity.bus.clazz.GoodsSecondClass; import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass; +import com.yeshi.fanli.entity.bus.clazz.TaoBaoClass; import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture; import com.yeshi.fanli.entity.bus.lable.QualityFactory; import com.yeshi.fanli.entity.system.BusinessSystem; @@ -106,12 +108,11 @@ @Resource private MonitorService monitorService; - + @Resource private HomeNavbarService homeNavbarService; @Resource private SwiperPictureService swiperPictureService; - @Resource(name = "taskExecutor") private TaskExecutor executor; @@ -172,32 +173,33 @@ if (picList == null) { picList = new ArrayList<SwiperPicture>(); } - - List<GoodsSubClass> goodsSubClassList = goodsSubClassService.getSubClassCache(gcid, 1); + + List<GoodsSubClass> goodsSubClassList = goodsSubClassService.getSubClassCache(gcid, 1, + Calendar.getInstance().get(Calendar.MONTH) + 1); if (goodsSubClassList == null) { goodsSubClassList = new ArrayList<GoodsSubClass>(); } - + boolean changePicture = false; String version = acceptData.getVersion(); int tversion = Integer.parseInt(version); String platform = acceptData.getPlatform(); if ("android".equalsIgnoreCase(platform) && tversion > 38) { changePicture = true; - } else if (tversion > 47){ + } else if (tversion > 47) { changePicture = true; } - + // 1.5.3鏂扮増鍥剧墖鏇挎崲 if (changePicture) { - for (GoodsSubClass goodsSubClass: goodsSubClassList) { + for (GoodsSubClass goodsSubClass : goodsSubClassList) { String pictureSecond = goodsSubClass.getPictureSecond(); if (pictureSecond != null && pictureSecond.trim().length() > 0) { goodsSubClass.setPicture(pictureSecond); } } } - + JSONObject data = new JSONObject(); data.put("picList", JsonUtil.getApiCommonGson().toJson(picList)); data.put("count", goodsSubClassList.size()); @@ -223,7 +225,7 @@ goodsClass.setIosClick(1L); } } - + GoodsClass gc = new GoodsClass(); gc.setId(goodsClass.getId()); gc.setIosClick(goodsClass.getIosClick()); @@ -242,7 +244,6 @@ } } - @RequestMapping(value = "getCouponGoods", method = RequestMethod.POST) public void getCouponGoods(AcceptData acceptData, int page, long gcid, PrintWriter out) { @@ -293,7 +294,8 @@ @RequestMapping(value = "getgoods", method = RequestMethod.POST) public void getGoods(AcceptData acceptData, int page, long scid, String filter, String order, String startprice, String endprice, String fastFilter, PrintWriter out) { - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages()); + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); return; @@ -401,7 +403,8 @@ @RequestMapping(value = "getsecondclassgoods", method = RequestMethod.POST) public void getSecondClassGoods(AcceptData acceptData, int page, long scid, String filter, String order, String startprice, String endprice, String fastFilter, Integer totalSales, PrintWriter out) { - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages()); + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); return; @@ -420,6 +423,84 @@ goodsSubClassService.countClick(acceptData, goodsSubClass); } + SearchFilter sf = new SearchFilter(); + String catesId = ""; + // 鏌ヨ鏄惁鏈夋窐瀹濆垎绫籌D + List<TaoBaoClass> tbClassList = taoBaoClassService.listBySystemSubCid(0, 10, goodsSubClass.getId()); + if (tbClassList != null && tbClassList.size() > 0) + for (TaoBaoClass tbc : tbClassList) { + catesId += tbc.getCategoryId() + ","; + } + if (catesId.endsWith(",")) + catesId = catesId.substring(0, catesId.length() - 1); + sf.setCateIds(catesId); + if (!StringUtil.isNullOrEmpty(catesId))// 鎸夊垎绫诲悕绉版悳绱� + { + String searchParam = goodsSubClass.getSearchJson(); + Gson gs = new Gson(); + SearchFilter searchfilter = gs.fromJson(searchParam, SearchFilter.class); + searchfilter.setCateIds(catesId); + searchfilter.setPage(page); + searchfilter.setPageSize(20); + if (Integer.parseInt(order) == 0) + searchfilter.setMaterialId("6707"); + taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter, + totalSales); + TaoBaoSearchResult searchResult = TaoKeApiUtil.searchWuLiao(searchfilter); + long count = searchResult.getPageEntity().getTotalCount(); + + JSONObject result = new JSONObject(); + + BigDecimal rate = hongBaoManageService.getFanLiRate(); + + List<TaoBaoGoodsBrief> resultGoodsList = searchResult.getTaoBaoGoodsBriefs(); + // 鏌ヨ鏄惁瓒呰繃浜嗘渶澶х殑鍟嗗搧鏁� + if ((resultGoodsList == null || resultGoodsList.size() < 20) + && !StringUtil.isNullOrEmpty(goodsSubClass.getKey())) { + if (resultGoodsList == null) + resultGoodsList = new ArrayList<>(); + + // 闇�瑕佹牴鎹叧閿瓧鏌ヨ + searchfilter.setCateIds(null); + searchfilter.setPage((int) (count % 20 == 0 ? count / 20 - 1 : count / 20)); + searchfilter.setPageSize(20); + searchfilter.setKey(goodsSubClass.getKey()); + TaoBaoSearchResult searchResult2 = TaoKeApiUtil.searchWuLiao(searchfilter); + if (searchResult2 != null) { + List<TaoBaoGoodsBrief> resultListTemp = searchResult2.getTaoBaoGoodsBriefs(); + if (resultListTemp != null) + resultGoodsList.addAll(resultListTemp); + } + } + JSONArray array = new JSONArray(); + Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) + .excludeFieldsWithoutExposeAnnotation().create(); + if (resultGoodsList != null) + for (TaoBaoGoodsBrief goods : resultGoodsList) { + array.add(gson2.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, rate + "", null))); + } + result.put("result", array); + result.put("count", result.optLong("count") + count); + out.print(JsonUtil.loadTrueResult(result)); + return; + } else { + String searchParam = goodsSubClass.getSearchJson(); + Gson gs = new Gson(); + SearchFilter searchfilter = gs.fromJson(searchParam, SearchFilter.class); + searchfilter.setCateIds(catesId); + searchfilter.setPage(page); + searchfilter.setPageSize(20); + if (Integer.parseInt(order) == 0) + searchfilter.setMaterialId("6707"); + searchfilter.setKey(goodsSubClass.getKey()); + taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter, + totalSales); + JSONObject result = taoKeGoodsService.searchWuLiao(searchfilter); + if (1 > 0) { + out.print(JsonUtil.loadTrueResult(result)); + return; + } + } /* 鎼滅储鍏抽敭璇� */ String searchKey = goodsSubClass.getName(); String key = goodsSubClass.getKey(); @@ -575,7 +656,8 @@ @RequestMapping("choiceGoods") public void choiceGoods(AcceptData acceptData, long gcid, int page, PrintWriter out) { - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages()); + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�")); return; @@ -584,6 +666,7 @@ GoodsClass goodsClass = goodsClassService.getGoodsClassCache(gcid); if (goodsClass == null) { out.print(JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ鍒嗙被")); + return; } if (page < 1) @@ -596,7 +679,7 @@ long counttotal = 5000; // 绮鹃�夊簱鏁版嵁涓虹┖鏃讹紝缃戠粶杩涜鏌ヨ - if (listQuery == null || listQuery.size() == 0) { + if (listQuery == null || listQuery.size() == 0||listQuery.size()<10) { long count = qualityGoodsService.countQueryClassId(gcid); int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); page = page - totalPage; @@ -665,7 +748,6 @@ data.put("count", counttotal); data.put("result", array); out.print(JsonUtil.loadTrueResult(data)); - } @@ -749,7 +831,7 @@ result = TaoKeApiUtil.searchCouple(goodsClassService.getKeysById(id), null, page, 20); List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav(); - if (result.getNavList() != null) + if (result != null && result.getNavList() != null) navList.addAll(result.getNavList()); if (navList == null) @@ -800,18 +882,17 @@ @RequestMapping(value = { "getcategory" }, method = { org.springframework.web.bind.annotation.RequestMethod.POST }) public void getcategory(AcceptData acceptData, PrintWriter out) { try { - + boolean changePicture = false; String version = acceptData.getVersion(); int tversion = Integer.parseInt(version); String platform = acceptData.getPlatform(); if ("android".equalsIgnoreCase(platform) && tversion > 38) { changePicture = true; - } else if (tversion > 47){ + } else if (tversion > 47) { changePicture = true; } - - + List<Map<String, Object>> listCache = goodsClassService.getClassListAllCache(changePicture); if (listCache == null) { listCache = new ArrayList<Map<String, Object>>(); -- Gitblit v1.8.0