From 190d6bc6aa7e4ca33c281bd9785339f3bddaf11e Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 08 五月 2021 12:43:37 +0800
Subject: [PATCH] bug修复
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsClassController.java | 1827 +++++++++++++++++++++++++++++-----------------------------
1 files changed, 913 insertions(+), 914 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 90a18d8..36262a7 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
@@ -1,914 +1,913 @@
-package com.yeshi.fanli.controller.client.v1;
-
-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;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-
-import org.springframework.core.task.TaskExecutor;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.yeshi.utils.JsonUtil;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.yeshi.fanli.entity.accept.AcceptData;
-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;
-import com.yeshi.fanli.entity.taobao.SearchFilter;
-import com.yeshi.fanli.entity.taobao.TaoBaoCoupon;
-import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
-import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
-import com.yeshi.fanli.entity.taobao.TaoBaoSearchNav;
-import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
-import com.yeshi.fanli.log.LogHelper;
-import com.yeshi.fanli.service.inter.config.BusinessSystemService;
-import com.yeshi.fanli.service.inter.goods.GoodsClassService;
-import com.yeshi.fanli.service.inter.goods.GoodsSecondClassService;
-import com.yeshi.fanli.service.inter.goods.GoodsSubClassService;
-import com.yeshi.fanli.service.inter.goods.SuperGoodsClassService;
-import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
-import com.yeshi.fanli.service.inter.goods.TaoBaoCouponService;
-import com.yeshi.fanli.service.inter.homemodule.HomeNavbarService;
-import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
-import com.yeshi.fanli.service.inter.lable.LabelClassService;
-import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
-import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
-import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
-import com.yeshi.fanli.service.inter.monitor.MonitorService;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.RedisManager;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.TimeUtil;
-import com.yeshi.fanli.util.Utils;
-import com.yeshi.fanli.util.factory.MonitorFactory;
-import com.yeshi.fanli.util.taobao.TaoBaoUtil;
-import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
-
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
-@Controller
-@RequestMapping("api/v1/class")
-public class GoodsClassController<E> {
-
- @Resource
- private SuperGoodsClassService superGoodsClassService;
-
- @Resource
- private GoodsSecondClassService goodsSecondClassService;
-
- @Resource
- private GoodsClassService goodsClassService;
-
- @Resource
- private SearchController searchController;
-
- @Resource
- private TaoBaoCouponService taoBaoCouponService;
-
- @Resource
- private HongBaoManageService hongBaoManageService;
-
- @Resource
- private HongBaoManageService manageService;
-
- @Resource
- private BusinessSystemService businessSystemService;
-
- @Resource
- private RedisManager redisManager;
-
- @Resource
- private QualityFactoryService selectionGoodsService;
- @Resource
- private TaoKeGoodsService taoKeGoodsService;
- @Resource
- private GoodsSubClassService goodsSubClassService;
- @Resource
- private TaoBaoClassService taoBaoClassService;
- @Resource
- private LabelClassService labelClassService;
-
- @Resource
- private QualityGoodsService qualityGoodsService;
-
- @Resource
- private MonitorService monitorService;
-
- @Resource
- private HomeNavbarService homeNavbarService;
- @Resource
- private SwiperPictureService swiperPictureService;
-
- @Resource(name = "taskExecutor")
- private TaskExecutor executor;
-
- /**
- * 鑾峰彇涓荤被鐩�
- *
- * @param acceptData
- * @param out
- */
- @RequestMapping(value = "getgoodsclass", method = RequestMethod.POST)
- public void getGoodsClass(AcceptData acceptData, PrintWriter out) {
-
- try {
- List<GoodsClass> goodsClassList = goodsClassService.getEffectiveClassCache();
- if (goodsClassList == null || goodsClassList.size() == 0) {
- out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- return;
- }
-
- JSONObject data = new JSONObject();
- data.put("count", goodsClassList.size());
- data.put("goodsClassList", JsonUtil.getApiCommonGson().toJson(goodsClassList));
-
- out.print(JsonUtil.loadTrueResult(data));
- } catch (Exception e) {
- out.print(JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
-
- }
-
- /**
- * 鑾峰彇浜岀骇瀛愮被鐩�
- *
- * @param acceptData
- * @param gcid
- * @param out
- */
- @RequestMapping(value = "getgoodssecondclass", method = RequestMethod.POST)
- public void getGoodsSecondClass(AcceptData acceptData, long gcid, Long swpid, PrintWriter out) {
- try {
- GoodsClass goodsClass = goodsClassService.getGoodsClassCache(gcid);
- if (goodsClass == null) {
- out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- return;
- }
-
- // 杞挱鍥�
- List<SwiperPicture> picList = null;
- if (swpid != null) {
- picList = swiperPictureService.getByBannerId(swpid);
- }
- if (picList == null) {
- picList = new ArrayList<SwiperPicture>();
- }
-
- 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) {
- changePicture = true;
- }
-
- // 1.5.3鏂扮増鍥剧墖鏇挎崲
- if (changePicture) {
- 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());
- data.put("goodsSecondClassList", JsonUtil.getApiCommonGson().toJson(goodsSubClassList));
- out.print(JsonUtil.loadTrueResult(data));
-
- // 鏇存柊鍒嗙被鐐瑰嚮娆℃暟
- executor.execute(new Runnable() {
- @Override
- public void run() {
- if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
- Long androidClick = goodsClass.getAndroidClick();
- if (androidClick != null) {
- goodsClass.setAndroidClick(androidClick + 1);
- } else {
- goodsClass.setAndroidClick(1L);
- }
- } else if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
- Long iosClick = goodsClass.getIosClick();
- if (iosClick != null) {
- goodsClass.setIosClick(iosClick + 1);
- } else {
- goodsClass.setIosClick(1L);
- }
- }
-
- GoodsClass gc = new GoodsClass();
- gc.setId(goodsClass.getId());
- gc.setIosClick(goodsClass.getIosClick());
- gc.setAndroidClick(goodsClass.getAndroidClick());
- goodsClassService.updateByPrimaryKeySelective(gc);
- }
- });
-
- } catch (Exception e) {
- out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
-
- }
-
- @RequestMapping(value = "getCouponGoods", method = RequestMethod.POST)
- public void getCouponGoods(AcceptData acceptData, int page, long gcid, PrintWriter out) {
- // GoodsClass goodsClass = goodsClassService.getGoodsClass(gcid);
-
- List<GoodsSecondClass> secondClassList = goodsSecondClassService.getGoodsSecondClassByGoodsClassId(gcid);
- List<String> searchKeys = new ArrayList<String>();
- for (GoodsSecondClass secondClass : secondClassList) {
- String key = secondClass.getKey();
- if (key == null || "".equals(key.trim())) {
- searchKeys.add(secondClass.getName());
- } else {
- searchKeys.add(secondClass.getKey());
- }
- }
- List<TaoBaoCoupon> taoBaoCoupons = taoBaoCouponService.getTaoBaoCouponListBykeys(searchKeys, page);
- int count = taoBaoCouponService.getCount(searchKeys);
- setTaoBaoCouponHongBao(taoBaoCoupons);
- JSONObject data = new JSONObject();
- long currentTimeMillis = java.lang.System.currentTimeMillis();
- String time = TimeUtil.getGernalTime(currentTimeMillis);
- data.put("time", time);
- data.put("count", count);
- data.put("taoBaoCoupons", Utils.imgListSize(
- JsonUtil.getApiCommonGson().toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtraList(taoBaoCoupons))));
- out.print(JsonUtil.loadTrueResult(data));
- }
-
- /**
- * 鑾峰彇瀛愮被鐩晢鍝�
- *
- * @param acceptData
- * @param page
- * @param scid
- * @param filter
- * @param order
- * 閿�閲忕敱楂樺埌浣�:0 浠锋牸浠庨珮鍒颁綆:2 浠锋牸浠庝綆鍒伴珮:3 娣樺浣i噾姣旂巼楂樺埌浣�:4 鍏朵粬锛氶粯璁�1
- * @param startprice
- * 璧峰浠锋牸
- * @param endprice
- * 缁撴潫浠锋牸
- * @param fastFilter
- * fastFilter 鏈夊埜 [{"type":"quantype"}] 澶╃尗鍟嗗搧 [{"type":"shoptype"}]
- * @param totalSales
- * 閿�閲忎互涓�
- * @param out
- */
- @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());
- if (system == null) {
- out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
- return;
- }
- GoodsSubClass goodsSubClass = goodsSubClassService.selectByPrimaryKey(scid);
- String name2 = goodsSubClass.getName();
- String name1 = goodsSubClass.getKey();
- if (name1 != null && !"".equals(name1.trim())) {
- name2 = name1;
- }
- if (!StringUtil.isNullOrEmpty(fastFilter)) {
- if (!StringUtil.isNullOrEmpty(filter)) {
- JSONArray filterArray = JSONArray.fromObject(filter);
- JSONArray fastFilterArray = JSONArray.fromObject(fastFilter);
- filterArray.addAll(fastFilterArray);
- filter = filterArray.toString();
- } else {
- filter = fastFilter;
- }
- }
-
- SearchFilter sf = new SearchFilter();
- if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) {
- if (Integer.parseInt(order) == 1) {
- sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
- } else if (Integer.parseInt(order) == 2) {
- sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW);
- } else if (Integer.parseInt(order) == 3) {
- sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH);
- }
- } else {
- // 榛樿閿�閲忎粠楂樺埌浣庢帓搴�
- sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
- }
-
- sf.setKey(name2);
- sf.setBaoYou(true);
- /* 璧峰浠锋牸 */
- Integer start_price = null;
- if (!StringUtil.isNullOrEmpty(startprice)) {
- start_price = Integer.parseInt(startprice);
- sf.setStartPrice(new BigDecimal(start_price));
- }
-
- sf.setQuan(1);
-
- if (fastFilter != null && fastFilter.contains("shoptype")) {
- sf.setTmall(true);
- }
-
- /* 缁撴潫浠锋牸 */
- Integer end_price = null;
- if (!StringUtil.isNullOrEmpty(endprice)) {
- end_price = Integer.parseInt(endprice);
- sf.setEndPrice(new BigDecimal(end_price));
- }
- sf.setPageSize(20);
- sf.setPage(page + 1);
- sf.setMaterialId("6707");
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
- JSONArray array = new JSONArray();
- List<TaoBaoGoodsBrief> taobaoList = taoKeGoodsService.searchWuLiaoList(sf);
- BigDecimal proportion = manageService.getFanLiRate();
- for (TaoBaoGoodsBrief taoBaoGoodsBrief : taobaoList) {
- int biz30day = taoBaoGoodsBrief.getBiz30day();
- if (biz30day >= 10000) {
- double sales = biz30day;
- String salesCountMidea = String.format("%.1f", sales / 10000);
- taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
- } else {
- taoBaoGoodsBrief.setSalesCount(biz30day + "");
- }
- array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
- }
- JSONObject data = new JSONObject();
- data.put("nav", new JSONArray());
- data.put("count", 1000);
- data.put("result", array);
- out.print(JsonUtil.loadTrueResult(data));
- }
-
- /**
- * 鑾峰彇浜岀骇鍒嗙被鍟嗗搧
- *
- * @param acceptData
- * @param page
- * @param scid
- * @param filter
- * @param order
- * 鏉ユ簮锛氥�愭帹鑽愶細0 | 缁煎悎锛�4 銆佺患鍚堝彧鐪嬫湁鍒� 1 銆佺患鍚堝彧鐪嬪ぉ鐚� 1 | 浠锋牸锛氫綆鍒伴珮3 楂樺埌浣�2 | 閿�閲忥細1銆�
- * 鎺掑簭鍊硷細銆愰攢閲忕敱楂樺埌浣�: 1 锛� 閿�閲忕敱浣庡埌楂� 5锛� 浠锋牸浠庨珮鍒颁綆: 2 锛� 浠锋牸浠庝綆鍒伴珮:3 锛� 鎺ㄥ箍閲忛珮鍒颁綆:4 锛�
- * 鍏朵粬榛樿锛� 閿�閲忕敱楂樺埌浣庛��
- *
- * @param startprice
- * 璧峰浠锋牸
- * @param endprice
- * 缁撴潫浠锋牸
- * @param fastFilter
- * fastFilter 鏈夊埜 [{"type":"quantype"}] 澶╃尗鍟嗗搧 [{"type":"shoptype"}]
- * @param totalSales
- * 閿�閲忎互涓�
- * @param out
- */
- @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());
- if (system == null) {
- out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
- return;
- }
-
- try {
-
- GoodsSubClass goodsSubClass = goodsSubClassService.getSubClassByPrimaryKeyCache(scid);
- if (goodsSubClass == null) {
- out.print(JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ鍒嗙被"));
- return;
- }
-
- if (page == 0) {
- // 缁熻鐐瑰嚮閲�
- 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();
- if (key != null && !"".equals(key.trim())) {
- searchKey = key;
- }
-
- /* 鍟嗗搧绯荤粺鍒嗙被id */
- Long systemCid = null;
- GoodsClass rootClass = goodsSubClass.getRootClass();
- if (rootClass != null) {
- systemCid = rootClass.getId();
- }
-
- // page浠�1寮�濮�
- page += 1;
- // 璇锋眰娣樺疂鎺ュ彛椤电爜
- int pageNo = page;
-
- int pageSize = Constant.PAGE_SIZE;
-
- /* 鏌ヨ鎺ㄨ崘妯″潡 娓呯┖鍏朵粬闈炲繀瑕佺瓫閫夐」鍜屾帓搴忛」 */
- if (!StringUtil.isNullOrEmpty(order) && Integer.parseInt(order) == 0) {
-
- // 鍒嗙被鍏宠仈鏍囩id闆嗗悎
- List<Long> listLabId = labelClassService.getRelationLabIds((page - 1) * pageSize, pageSize,
- goodsSubClass.getId());
-
- /* 璁$畻绮鹃�夊簱鏁版嵁 鎬婚〉鏁� */
- long incount = taoKeGoodsService.countByQuality(searchKey, systemCid, listLabId);
-
- int totalPage = (int) (incount % pageSize == 0 ? incount / pageSize : incount / pageSize + 1);
-
- pageNo = page - totalPage;
-
- /* 鏌ヨ绮鹃�夊簱鏁版嵁 */
- if (pageNo <= 0) {
-
- List<QualityFactory> listQuality = taoKeGoodsService.queryByQuality((page - 1) * pageSize, pageSize,
- searchKey, systemCid, listLabId);
-
- List<TaoBaoGoodsBrief> searchWuLiaoList = null;
-
- /* 绮鹃�夊簱鏁版嵁涓嶈冻10鏉� */
- if (listQuality != null && listQuality.size() != 0 && listQuality.size() < 10) {
-
- String searchParam = goodsSubClass.getSearchJson();
-
- Gson gs = new Gson();
- SearchFilter searchfilter = gs.fromJson(searchParam, SearchFilter.class);
-
- int quanfilter = searchfilter.getQuan();
- if (quanfilter != 1) {
- searchfilter.setQuan(1);
- }
-
- BigDecimal endPricefilter = searchfilter.getEndPrice();
- if (endPricefilter == null) {
- searchfilter.setEndPrice(new BigDecimal(220));
- }
-
- boolean includeGoodRate = searchfilter.isIncludeGoodRate();
- if (!includeGoodRate) {
- searchfilter.setIncludeGoodRate(true);
- }
-
- // 璇锋眰绗竴椤垫暟鎹�
- searchfilter.setPage(1);
- searchfilter.setPageSize(pageSize);
- searchfilter.setKey(searchKey);
- searchfilter.setMaterialId("6707");
-
- searchWuLiaoList = taoKeGoodsService.searchWuLiaoList(searchfilter);
- }
-
- Map<String, String> map = manageService.convertMap();
-
- JSONObject data = taoKeGoodsService.listQualityGoods(listQuality, searchWuLiaoList, map);
-
- out.print(JsonUtil.loadTrueResult(data));
-
- return;
- }
-
- if (pageNo > 0 && totalPage > 0) {
- List<QualityFactory> list = taoKeGoodsService.queryByQuality((totalPage - 1) * pageSize, pageSize,
- searchKey, systemCid, listLabId);
-
- if (list != null && list.size() != 0 && list.size() < 10) {
- // 椤电爜+ 1 宸茶姹備竴娆℃窐瀹濇帴鍙�
- pageNo += 1;
- }
- }
- }
-
- /* 缃戠粶璇锋眰 */
- SearchFilter searchfilter = null;
- String searchParam = goodsSubClass.getSearchJson();
-
- if (!StringUtil.isNullOrEmpty(searchParam) && !StringUtil.isNullOrEmpty(order)
- && Integer.parseInt(order) == 0) {
- // 鎺ㄨ崘 浣跨敤瀛愬垎绫婚粯璁ゆ煡璇㈡潯浠�
- Gson gs = new Gson();
- searchfilter = gs.fromJson(searchParam, SearchFilter.class);
-
- int quanfilter = searchfilter.getQuan();
- if (quanfilter != 1) {
- searchfilter.setQuan(1);
- }
-
- BigDecimal endPricefilter = searchfilter.getEndPrice();
- if (endPricefilter == null) {
- searchfilter.setEndPrice(new BigDecimal(220));
- }
-
- boolean includeGoodRate = searchfilter.isIncludeGoodRate();
- if (!includeGoodRate) {
- searchfilter.setIncludeGoodRate(true);
- }
-
- } else {
- searchfilter = new SearchFilter();
- // 璁剧疆SearchFilter
- taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter,
- totalSales);
-
- // 鐢ㄦ埛鏈緭鍏ユ渶楂樹环鏍兼椂 鏈�楂樹环鏍奸檺鍒�99999
- if (searchfilter.getEndPrice() == null) {
- searchfilter.setEndPrice(new BigDecimal(99999));
- }
- }
-
- searchfilter.setPage(pageNo);
- searchfilter.setPageSize(pageSize);
- searchfilter.setKey(searchKey);
-
- if (!StringUtil.isNullOrEmpty(order) && Integer.parseInt(order) != 4) {
- searchfilter.setMaterialId("6707");
- }
-
- // 鏌ヨ鐗╂枡鎺ュ彛
- JSONObject result = taoKeGoodsService.searchWuLiao(searchfilter);
- out.print(JsonUtil.loadTrueResult(result));
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * 鍒嗙被涓嬬殑绮鹃�夊晢鍝�
- */
- @RequestMapping("choiceGoods")
- public void choiceGoods(AcceptData acceptData, long gcid, int page, PrintWriter out) {
-
- BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
- acceptData.getPackages());
- if (system == null) {
- out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
- return;
- }
-
- GoodsClass goodsClass = goodsClassService.getGoodsClassCache(gcid);
- if (goodsClass == null) {
- out.print(JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ鍒嗙被"));
- }
-
- if (page < 1)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- List<QualityFactory> listQuery = qualityGoodsService.listQueryByClassId((page - 1) * pageSize, pageSize, gcid);
- // 鎬绘潯鏁�
- long counttotal = 5000;
-
- // 绮鹃�夊簱鏁版嵁涓虹┖鏃讹紝缃戠粶杩涜鏌ヨ
- if (listQuery == null || listQuery.size() == 0) {
- long count = qualityGoodsService.countQueryClassId(gcid);
- int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
- page = page - totalPage;
- if (page < 1)
- page = 1;
-
- // 娣樺疂绫荤洰id
- String taoBaoCatIds = taoBaoClassService.getTaoBaoCatIds(gcid);
-
- SearchFilter filter = null;
-
- String searchParam = goodsClass.getSearchParam();
- if (!StringUtil.isNullOrEmpty(searchParam)) {
- Gson gs = new Gson();
- filter = gs.fromJson(searchParam, SearchFilter.class);
- } else {
- filter = new SearchFilter();
- }
-
- filter.setMaterialId("6707");
- filter.setPage(page);
- filter.setPageSize(pageSize);
- filter.setCateIds(taoBaoCatIds);
-
- JSONObject result = taoKeGoodsService.searchWuLiao(filter);
- out.print(JsonUtil.loadTrueResult(result));
-
- return;
- }
-
- // 绮鹃�夊簱鏁版嵁澶勭悊杩斿洖 鍓嶇
- JSONArray array = new JSONArray();
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
-
- BigDecimal proportion = manageService.getFanLiRate();
-
- // 閬嶅巻鍒楄〃鏁版嵁
- for (QualityFactory selectionGoods : listQuery) {
-
- TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
-
- if (taoBaoGoodsBrief == null) {
- continue;
- }
-
- int biz30day = taoBaoGoodsBrief.getBiz30day();
- if (biz30day >= 10000) {
- double sales = biz30day;
- String salesCountMidea = String.format("%.1f", sales / 10000);
- taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
- } else {
- taoBaoGoodsBrief.setSalesCount(biz30day + "");
- }
-
- // 鐧藉簳鍥炬祴璇�
- // if
- // (!StringUtil.isNullOrEmpty(taoBaoGoodsBrief.getPictUrlWhite()))
- // taoBaoGoodsBrief.setPictUrl(taoBaoGoodsBrief.getPictUrlWhite());
-
- array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
- }
-
- JSONObject data = new JSONObject();
- data.put("nav", null);
- data.put("count", counttotal);
- data.put("result", array);
- out.print(JsonUtil.loadTrueResult(data));
-
- }
-
- @RequestMapping("getCouponList")
- public void getCouponList(AcceptData acceptData, int page, HttpServletRequest request, PrintWriter out) {
- page = page > 0 ? page : 1;
- List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = taoBaoCouponService.getTaoBaoCouponList(page);
- BigDecimal proportion = manageService.getFanLiRate();
- JSONArray array = new JSONArray();
- TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
-
- for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
- taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "");
- array.add(gson.toJson(taoBaoGoodsBriefExtra));
- }
- int count = 10000;
- JSONObject data = new JSONObject();
- data.put("taoBaoCoupons", array);
- data.put("count", count);
- out.print(JsonUtil.loadTrueResult(data));
-
- try {
- monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, null));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * 閫氳繃鍒嗙被鑾峰彇鍒�
- *
- * @param acceptData
- * @param page
- * @param out
- */
- @RequestMapping("getCouponListByClass")
- public void getCouponListByClass(AcceptData acceptData, Long id, int page, PrintWriter out) {
-
- // SearchFilter sf = new SearchFilter();
- // sf.setQuan(1);
- // sf.setPage(page);
- // TaoKeApiUtil.getMaterialByMaterialId(3786, page, 20);
- if (id == null)
- return;
- page = page < 1 ? 1 : page;
- String key = String.format("getCouponListByClass-%s-%s", id + "", page + "");
- String resultStr = "";
-
- if (Constant.IS_OUTNET)
- resultStr = redisManager.getCommonString(key);
- if (!StringUtil.isNullOrEmpty(resultStr)) {
- out.print(resultStr);
- return;
- }
-
- int meterialId = 0;
- Map<Long, Integer> paramMap = new HashMap<>();
- paramMap.put(10L, 3767);// 濂宠
- paramMap.put(11L, 3760);// 姣嶅┐
- paramMap.put(28L, 3764);// 鐢疯
- paramMap.put(27L, 3758);// 瀹跺眳瀹惰
- paramMap.put(1L, 3759);// 瀹剁數鏁扮爜
- paramMap.put(6L, 3765);// 鍐呰。
- paramMap.put(30L, 3763);// 缇庡
-
- paramMap.put(31L, 3766);// 杩愬姩鎴峰
-
- paramMap.put(32L, 3761);// 缇庨
-
- if (paramMap.get(id) != null)
- meterialId = paramMap.get(id);
-
- TaoBaoSearchResult result = null;
-
- // 涓嶇敓鏁�
- meterialId = 0;
- if (meterialId > 0)
- result = TaoKeApiUtil.getMaterialByMaterialId(meterialId, page, 20);
- else
- result = TaoKeApiUtil.searchCouple(goodsClassService.getKeysById(id), null, page, 20);
-
- List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav();
- if (result != null && result.getNavList() != null)
- navList.addAll(result.getNavList());
-
- if (navList == null)
- navList = new ArrayList<>();
-
- Gson gson = new GsonBuilder().create();
- JSONObject data = new JSONObject();
- data.put("nav", gson.toJson(navList));
- List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>();
- List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
- BigDecimal proportion = manageService.getFanLiRate();
- TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
- for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
- taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "");
- re.add(taoBaoGoodsBriefExtra);
- }
-
- Gson gson2 = JsonUtil.getConvertBigDecimalToStringBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().create();
- data.put("result", gson2.toJson(re));
- data.put("count", result.getTaoBaoHead().getDocsfound());
- resultStr = JsonUtil.loadTrueResult(0, data);
- try {
- if (Constant.IS_OUTNET)
- redisManager.cacheCommonString(key, resultStr, 120);
- } catch (Exception e) {
- }
-
- out.print(resultStr);
- }
-
- /**
- * 璁剧疆绾㈠寘杩涘幓
- *
- * @param taoBaoCoupons
- */
- private void setTaoBaoCouponHongBao(List<TaoBaoCoupon> taoBaoCoupons) {
- if (taoBaoCoupons.size() > 0) {
- BigDecimal proportion = hongBaoManageService.getFanLiRate();
-
- for (TaoBaoCoupon taoBaoCoupon : taoBaoCoupons) {
- BigDecimal hb = TaoBaoUtil.getCouponHongBaoInfo(taoBaoCoupon, proportion);
- taoBaoCoupon.setHongbao(hb);
- }
- }
- }
-
- @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) {
- changePicture = true;
- }
-
- List<Map<String, Object>> listCache = goodsClassService.getClassListAllCache(changePicture);
- if (listCache == null) {
- listCache = new ArrayList<Map<String, Object>>();
- }
-
- JSONObject data = new JSONObject();
- data.put("categoryList", listCache);
-
- out.print(JsonUtil.loadTrueResult(data));
-
- } catch (Exception e) {
- out.print(JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
-}
+package com.yeshi.fanli.controller.client.v1;
+
+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;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.core.task.TaskExecutor;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.yeshi.utils.JsonUtil;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.yeshi.fanli.entity.accept.AcceptData;
+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.lable.QualityFactory;
+import com.yeshi.fanli.entity.system.BusinessSystem;
+import com.yeshi.fanli.entity.taobao.SearchFilter;
+import com.yeshi.fanli.entity.taobao.TaoBaoCoupon;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra;
+import com.yeshi.fanli.entity.taobao.TaoBaoSearchNav;
+import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
+import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.config.BusinessSystemService;
+import com.yeshi.fanli.service.inter.goods.GoodsClassService;
+import com.yeshi.fanli.service.inter.goods.GoodsSecondClassService;
+import com.yeshi.fanli.service.inter.goods.GoodsSubClassService;
+import com.yeshi.fanli.service.inter.goods.SuperGoodsClassService;
+import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
+import com.yeshi.fanli.service.inter.goods.TaoBaoCouponService;
+import com.yeshi.fanli.service.inter.homemodule.HomeNavbarService;
+import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
+import com.yeshi.fanli.service.inter.lable.LabelClassService;
+import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
+import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
+import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
+import com.yeshi.fanli.service.inter.monitor.MonitorService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.RedisKeyEnum;
+import com.yeshi.fanli.util.RedisManager;
+import com.yeshi.fanli.util.StringUtil;
+import org.yeshi.utils.TimeUtil;
+import com.yeshi.fanli.util.Utils;
+import com.yeshi.fanli.util.factory.MonitorFactory;
+import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
+import com.yeshi.fanli.vo.homemodule.BannerVO;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+@Controller
+@RequestMapping("api/v1/class")
+public class GoodsClassController<E> {
+
+ @Resource
+ private SuperGoodsClassService superGoodsClassService;
+
+ @Resource
+ private GoodsSecondClassService goodsSecondClassService;
+
+ @Resource
+ private GoodsClassService goodsClassService;
+
+ @Resource
+ private SearchController searchController;
+
+ @Resource
+ private TaoBaoCouponService taoBaoCouponService;
+
+ @Resource
+ private HongBaoManageService hongBaoManageService;
+
+ @Resource
+ private HongBaoManageService manageService;
+
+ @Resource
+ private BusinessSystemService businessSystemService;
+
+ @Resource
+ private RedisManager redisManager;
+
+ @Resource
+ private QualityFactoryService selectionGoodsService;
+ @Resource
+ private TaoKeGoodsService taoKeGoodsService;
+ @Resource
+ private GoodsSubClassService goodsSubClassService;
+ @Resource
+ private TaoBaoClassService taoBaoClassService;
+ @Resource
+ private LabelClassService labelClassService;
+
+ @Resource
+ private QualityGoodsService qualityGoodsService;
+
+ @Resource
+ private MonitorService monitorService;
+
+ @Resource
+ private HomeNavbarService homeNavbarService;
+ @Resource
+ private SwiperPictureService swiperPictureService;
+
+ @Resource(name = "taskExecutor")
+ private TaskExecutor executor;
+
+ /**
+ * 鑾峰彇涓荤被鐩�
+ *
+ * @param acceptData
+ * @param out
+ */
+ @RequestMapping(value = "getgoodsclass", method = RequestMethod.POST)
+ public void getGoodsClass(AcceptData acceptData, PrintWriter out) {
+
+ try {
+ List<GoodsClass> goodsClassList = goodsClassService.getEffectiveClassCache();
+ if (goodsClassList == null || goodsClassList.size() == 0) {
+ out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+ return;
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("count", goodsClassList.size());
+ data.put("goodsClassList", JsonUtil.getApiCommonGson().toJson(goodsClassList));
+
+ out.print(JsonUtil.loadTrueResult(data));
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ }
+
+ /**
+ * 鑾峰彇浜岀骇瀛愮被鐩�
+ *
+ * @param acceptData
+ * @param gcid
+ * @param out
+ */
+ @RequestMapping(value = "getgoodssecondclass", method = RequestMethod.POST)
+ public void getGoodsSecondClass(AcceptData acceptData, long gcid, Long swpid, PrintWriter out) {
+ try {
+ GoodsClass goodsClass = goodsClassService.getGoodsClassCache(gcid);
+ if (goodsClass == null) {
+ out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+ return;
+ }
+
+ // 杞挱鍥�
+ List<BannerVO> picList = null;
+ if (swpid != null) {
+ picList = swiperPictureService.getByBannerId(swpid, acceptData.getPlatform(),
+ Integer.parseInt(acceptData.getVersion()), acceptData.getSystem());
+ }
+ if (picList == null) {
+ picList = new ArrayList<BannerVO>();
+ }
+
+ 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) {
+ changePicture = true;
+ }
+
+ // 1.5.3鏂扮増鍥剧墖鏇挎崲
+ if (changePicture) {
+ 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());
+ data.put("goodsSecondClassList", JsonUtil.getApiCommonGson().toJson(goodsSubClassList));
+ out.print(JsonUtil.loadTrueResult(data));
+
+ // 鏇存柊鍒嗙被鐐瑰嚮娆℃暟
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
+ Long androidClick = goodsClass.getAndroidClick();
+ if (androidClick != null) {
+ goodsClass.setAndroidClick(androidClick + 1);
+ } else {
+ goodsClass.setAndroidClick(1L);
+ }
+ } else if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
+ Long iosClick = goodsClass.getIosClick();
+ if (iosClick != null) {
+ goodsClass.setIosClick(iosClick + 1);
+ } else {
+ goodsClass.setIosClick(1L);
+ }
+ }
+
+ GoodsClass gc = new GoodsClass();
+ gc.setId(goodsClass.getId());
+ gc.setIosClick(goodsClass.getIosClick());
+ gc.setAndroidClick(goodsClass.getAndroidClick());
+ goodsClassService.updateByPrimaryKeySelective(gc);
+ }
+ });
+
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ }
+
+ @RequestMapping(value = "getCouponGoods", method = RequestMethod.POST)
+ public void getCouponGoods(AcceptData acceptData, int page, long gcid, PrintWriter out) {
+ // GoodsClass goodsClass = goodsClassService.getGoodsClass(gcid);
+
+ List<GoodsSecondClass> secondClassList = goodsSecondClassService.getGoodsSecondClassByGoodsClassId(gcid);
+ List<String> searchKeys = new ArrayList<String>();
+ for (GoodsSecondClass secondClass : secondClassList) {
+ String key = secondClass.getKey();
+ if (key == null || "".equals(key.trim())) {
+ searchKeys.add(secondClass.getName());
+ } else {
+ searchKeys.add(secondClass.getKey());
+ }
+ }
+ List<TaoBaoCoupon> taoBaoCoupons = taoBaoCouponService.getTaoBaoCouponListBykeys(searchKeys, page);
+ int count = taoBaoCouponService.getCount(searchKeys);
+ setTaoBaoCouponHongBao(acceptData, taoBaoCoupons);
+ JSONObject data = new JSONObject();
+ long currentTimeMillis = java.lang.System.currentTimeMillis();
+ String time = TimeUtil.getGernalTime(currentTimeMillis);
+ data.put("time", time);
+ data.put("count", count);
+ data.put("taoBaoCoupons", Utils.imgListSize(
+ JsonUtil.getApiCommonGson().toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtraList(taoBaoCoupons))));
+ out.print(JsonUtil.loadTrueResult(data));
+ }
+
+ /**
+ * 鑾峰彇瀛愮被鐩晢鍝�
+ *
+ * @param acceptData
+ * @param page
+ * @param scid
+ * @param filter
+ * @param order 閿�閲忕敱楂樺埌浣�:0 浠锋牸浠庨珮鍒颁綆:2 浠锋牸浠庝綆鍒伴珮:3 娣樺浣i噾姣旂巼楂樺埌浣�:4 鍏朵粬锛氶粯璁�1
+ * @param startprice 璧峰浠锋牸
+ * @param endprice 缁撴潫浠锋牸
+ * @param fastFilter fastFilter 鏈夊埜 [{"type":"quantype"}] 澶╃尗鍟嗗搧 [{"type":"shoptype"}]
+ * @param totalSales 閿�閲忎互涓�
+ * @param out
+ */
+ @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(), acceptData.getSystem());
+ if (system == null) {
+ out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
+ return;
+ }
+ GoodsSubClass goodsSubClass = goodsSubClassService.selectByPrimaryKey(scid);
+ String name2 = goodsSubClass.getName();
+ String name1 = goodsSubClass.getKey();
+ if (name1 != null && !"".equals(name1.trim())) {
+ name2 = name1;
+ }
+ if (!StringUtil.isNullOrEmpty(fastFilter)) {
+ if (!StringUtil.isNullOrEmpty(filter)) {
+ JSONArray filterArray = JSONArray.fromObject(filter);
+ JSONArray fastFilterArray = JSONArray.fromObject(fastFilter);
+ filterArray.addAll(fastFilterArray);
+ filter = filterArray.toString();
+ } else {
+ filter = fastFilter;
+ }
+ }
+
+ SearchFilter sf = new SearchFilter();
+ if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) {
+ if (Integer.parseInt(order) == 1) {
+ sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
+ } else if (Integer.parseInt(order) == 2) {
+ sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW);
+ } else if (Integer.parseInt(order) == 3) {
+ sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH);
+ }
+ } else {
+ // 榛樿閿�閲忎粠楂樺埌浣庢帓搴�
+ sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
+ }
+
+ sf.setKey(name2);
+ sf.setBaoYou(true);
+ /* 璧峰浠锋牸 */
+ Integer start_price = null;
+ if (!StringUtil.isNullOrEmpty(startprice)) {
+ start_price = Integer.parseInt(startprice);
+ sf.setStartPrice(new BigDecimal(start_price));
+ }
+
+ sf.setQuan(1);
+
+ if (fastFilter != null && fastFilter.contains("shoptype")) {
+ sf.setTmall(true);
+ }
+
+ /* 缁撴潫浠锋牸 */
+ Integer end_price = null;
+ if (!StringUtil.isNullOrEmpty(endprice)) {
+ end_price = Integer.parseInt(endprice);
+ sf.setEndPrice(new BigDecimal(end_price));
+ }
+ sf.setPageSize(20);
+ sf.setPage(page + 1);
+ sf.setMaterialId("6707");
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+ JSONArray array = new JSONArray();
+ List<TaoBaoGoodsBrief> taobaoList = taoKeGoodsService.searchWuLiaoList(sf,acceptData.getSystem());
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+ for (TaoBaoGoodsBrief taoBaoGoodsBrief : taobaoList) {
+ int biz30day = taoBaoGoodsBrief.getBiz30day();
+ if (biz30day >= 10000) {
+ double sales = biz30day;
+ String salesCountMidea = String.format("%.1f", sales / 10000);
+ taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
+ } else {
+ taoBaoGoodsBrief.setSalesCount(biz30day + "");
+ }
+ array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
+ }
+ JSONObject data = new JSONObject();
+ data.put("nav", new JSONArray());
+ data.put("count", 1000);
+ data.put("result", array);
+ out.print(JsonUtil.loadTrueResult(data));
+ }
+
+ /**
+ * 鑾峰彇浜岀骇鍒嗙被鍟嗗搧
+ *
+ * @param acceptData
+ * @param page
+ * @param scid
+ * @param filter
+ * @param order 鏉ユ簮锛氥�愭帹鑽愶細0 | 缁煎悎锛�4 銆佺患鍚堝彧鐪嬫湁鍒� 1 銆佺患鍚堝彧鐪嬪ぉ鐚� 1 | 浠锋牸锛氫綆鍒伴珮3 楂樺埌浣�2 | 閿�閲忥細1銆�
+ * 鎺掑簭鍊硷細銆愰攢閲忕敱楂樺埌浣�: 1 锛� 閿�閲忕敱浣庡埌楂� 5锛� 浠锋牸浠庨珮鍒颁綆: 2 锛� 浠锋牸浠庝綆鍒伴珮:3 锛� 鎺ㄥ箍閲忛珮鍒颁綆:4 锛�
+ * 鍏朵粬榛樿锛� 閿�閲忕敱楂樺埌浣庛��
+ * @param startprice 璧峰浠锋牸
+ * @param endprice 缁撴潫浠锋牸
+ * @param fastFilter fastFilter 鏈夊埜 [{"type":"quantype"}] 澶╃尗鍟嗗搧 [{"type":"shoptype"}]
+ * @param totalSales 閿�閲忎互涓�
+ * @param out
+ */
+ @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(), acceptData.getSystem());
+ if (system == null) {
+ out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
+ return;
+ }
+
+ try {
+
+ GoodsSubClass goodsSubClass = goodsSubClassService.getSubClassByPrimaryKeyCache(scid);
+ if (goodsSubClass == null) {
+ out.print(JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ鍒嗙被"));
+ return;
+ }
+
+ if (page == 0) {
+ // 缁熻鐐瑰嚮閲�
+ 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,null,null);
+ long count = searchResult.getPageEntity().getTotalCount();
+
+ JSONObject result = new JSONObject();
+
+ BigDecimal rate = hongBaoManageService.getFanLiRate(acceptData.getSystem());
+
+ 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,null,null);
+ 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,acceptData.getSystem());
+ if (1 > 0) {
+ out.print(JsonUtil.loadTrueResult(result));
+ return;
+ }
+ }
+ /* 鎼滅储鍏抽敭璇� */
+ String searchKey = goodsSubClass.getName();
+ String key = goodsSubClass.getKey();
+ if (key != null && !"".equals(key.trim())) {
+ searchKey = key;
+ }
+
+ /* 鍟嗗搧绯荤粺鍒嗙被id */
+ Long systemCid = null;
+ GoodsClass rootClass = goodsSubClass.getRootClass();
+ if (rootClass != null) {
+ systemCid = rootClass.getId();
+ }
+
+ // page浠�1寮�濮�
+ page += 1;
+ // 璇锋眰娣樺疂鎺ュ彛椤电爜
+ int pageNo = page;
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ /* 鏌ヨ鎺ㄨ崘妯″潡 娓呯┖鍏朵粬闈炲繀瑕佺瓫閫夐」鍜屾帓搴忛」 */
+ if (!StringUtil.isNullOrEmpty(order) && Integer.parseInt(order) == 0) {
+
+ // 鍒嗙被鍏宠仈鏍囩id闆嗗悎
+ List<Long> listLabId = labelClassService.getRelationLabIds((page - 1) * pageSize, pageSize,
+ goodsSubClass.getId());
+
+ /* 璁$畻绮鹃�夊簱鏁版嵁 鎬婚〉鏁� */
+ long incount = taoKeGoodsService.countByQuality(searchKey, systemCid, listLabId);
+
+ int totalPage = (int) (incount % pageSize == 0 ? incount / pageSize : incount / pageSize + 1);
+
+ pageNo = page - totalPage;
+
+ /* 鏌ヨ绮鹃�夊簱鏁版嵁 */
+ if (pageNo <= 0) {
+
+ List<QualityFactory> listQuality = taoKeGoodsService.queryByQuality((page - 1) * pageSize, pageSize,
+ searchKey, systemCid, listLabId);
+
+ List<TaoBaoGoodsBrief> searchWuLiaoList = null;
+
+ /* 绮鹃�夊簱鏁版嵁涓嶈冻10鏉� */
+ if (listQuality != null && listQuality.size() != 0 && listQuality.size() < 10) {
+
+ String searchParam = goodsSubClass.getSearchJson();
+
+ Gson gs = new Gson();
+ SearchFilter searchfilter = gs.fromJson(searchParam, SearchFilter.class);
+
+ int quanfilter = searchfilter.getQuan();
+ if (quanfilter != 1) {
+ searchfilter.setQuan(1);
+ }
+
+ BigDecimal endPricefilter = searchfilter.getEndPrice();
+ if (endPricefilter == null) {
+ searchfilter.setEndPrice(new BigDecimal(220));
+ }
+
+ boolean includeGoodRate = searchfilter.isIncludeGoodRate();
+ if (!includeGoodRate) {
+ searchfilter.setIncludeGoodRate(true);
+ }
+
+ // 璇锋眰绗竴椤垫暟鎹�
+ searchfilter.setPage(1);
+ searchfilter.setPageSize(pageSize);
+ searchfilter.setKey(searchKey);
+ searchfilter.setMaterialId("6707");
+
+ searchWuLiaoList = taoKeGoodsService.searchWuLiaoList(searchfilter,acceptData.getSystem());
+ }
+
+ Map<String, String> map = manageService.convertMap(acceptData.getSystem());
+
+ JSONObject data = taoKeGoodsService.listQualityGoods(listQuality, searchWuLiaoList, map,acceptData.getSystem());
+
+ out.print(JsonUtil.loadTrueResult(data));
+
+ return;
+ }
+
+ if (pageNo > 0 && totalPage > 0) {
+ List<QualityFactory> list = taoKeGoodsService.queryByQuality((totalPage - 1) * pageSize, pageSize,
+ searchKey, systemCid, listLabId);
+
+ if (list != null && list.size() != 0 && list.size() < 10) {
+ // 椤电爜+ 1 宸茶姹備竴娆℃窐瀹濇帴鍙�
+ pageNo += 1;
+ }
+ }
+ }
+
+ /* 缃戠粶璇锋眰 */
+ SearchFilter searchfilter = null;
+ String searchParam = goodsSubClass.getSearchJson();
+
+ if (!StringUtil.isNullOrEmpty(searchParam) && !StringUtil.isNullOrEmpty(order)
+ && Integer.parseInt(order) == 0) {
+ // 鎺ㄨ崘 浣跨敤瀛愬垎绫婚粯璁ゆ煡璇㈡潯浠�
+ Gson gs = new Gson();
+ searchfilter = gs.fromJson(searchParam, SearchFilter.class);
+
+ int quanfilter = searchfilter.getQuan();
+ if (quanfilter != 1) {
+ searchfilter.setQuan(1);
+ }
+
+ BigDecimal endPricefilter = searchfilter.getEndPrice();
+ if (endPricefilter == null) {
+ searchfilter.setEndPrice(new BigDecimal(220));
+ }
+
+ boolean includeGoodRate = searchfilter.isIncludeGoodRate();
+ if (!includeGoodRate) {
+ searchfilter.setIncludeGoodRate(true);
+ }
+
+ } else {
+ searchfilter = new SearchFilter();
+ // 璁剧疆SearchFilter
+ taoKeGoodsService.setSearchFilter(searchfilter, filter, order, startprice, endprice, fastFilter,
+ totalSales);
+
+ // 鐢ㄦ埛鏈緭鍏ユ渶楂樹环鏍兼椂 鏈�楂樹环鏍奸檺鍒�99999
+ if (searchfilter.getEndPrice() == null) {
+ searchfilter.setEndPrice(new BigDecimal(99999));
+ }
+ }
+
+ searchfilter.setPage(pageNo);
+ searchfilter.setPageSize(pageSize);
+ searchfilter.setKey(searchKey);
+
+ if (!StringUtil.isNullOrEmpty(order) && Integer.parseInt(order) != 4) {
+ searchfilter.setMaterialId("6707");
+ }
+
+ // 鏌ヨ鐗╂枡鎺ュ彛
+ JSONObject result = taoKeGoodsService.searchWuLiao(searchfilter,acceptData.getSystem());
+ out.print(JsonUtil.loadTrueResult(result));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 鍒嗙被涓嬬殑绮鹃�夊晢鍝�
+ */
+ @RequestMapping("choiceGoods")
+ public void choiceGoods(AcceptData acceptData, long gcid, int page, PrintWriter out) {
+
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages(), acceptData.getSystem());
+ if (system == null) {
+ out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
+ return;
+ }
+
+ GoodsClass goodsClass = goodsClassService.getGoodsClassCache(gcid);
+ if (goodsClass == null) {
+ out.print(JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ鍒嗙被"));
+ return;
+ }
+
+ if (page < 1)
+ page = 1;
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ List<QualityFactory> listQuery = qualityGoodsService.listQueryByClassId((page - 1) * pageSize, pageSize, gcid);
+ // 鎬绘潯鏁�
+ long counttotal = 5000;
+
+ // 绮鹃�夊簱鏁版嵁涓虹┖鏃讹紝缃戠粶杩涜鏌ヨ
+ 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;
+ if (page < 1)
+ page = 1;
+
+ // 娣樺疂绫荤洰id
+ String taoBaoCatIds = taoBaoClassService.getTaoBaoCatIds(gcid);
+
+ SearchFilter filter = null;
+
+ String searchParam = goodsClass.getSearchParam();
+ if (!StringUtil.isNullOrEmpty(searchParam)) {
+ Gson gs = new Gson();
+ filter = gs.fromJson(searchParam, SearchFilter.class);
+ } else {
+ filter = new SearchFilter();
+ }
+
+ filter.setMaterialId("6707");
+ filter.setPage(page);
+ filter.setPageSize(pageSize);
+ filter.setCateIds(taoBaoCatIds);
+
+ JSONObject result = taoKeGoodsService.searchWuLiao(filter,acceptData.getSystem());
+ out.print(JsonUtil.loadTrueResult(result));
+
+ return;
+ }
+
+ // 绮鹃�夊簱鏁版嵁澶勭悊杩斿洖 鍓嶇
+ JSONArray array = new JSONArray();
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+
+ // 閬嶅巻鍒楄〃鏁版嵁
+ for (QualityFactory selectionGoods : listQuery) {
+
+ TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
+
+ if (taoBaoGoodsBrief == null) {
+ continue;
+ }
+
+ int biz30day = taoBaoGoodsBrief.getBiz30day();
+ if (biz30day >= 10000) {
+ double sales = biz30day;
+ String salesCountMidea = String.format("%.1f", sales / 10000);
+ taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
+ } else {
+ taoBaoGoodsBrief.setSalesCount(biz30day + "");
+ }
+
+ // 鐧藉簳鍥炬祴璇�
+ // if
+ // (!StringUtil.isNullOrEmpty(taoBaoGoodsBrief.getPictUrlWhite()))
+ // taoBaoGoodsBrief.setPictUrl(taoBaoGoodsBrief.getPictUrlWhite());
+
+ array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("nav", null);
+ data.put("count", counttotal);
+ data.put("result", array);
+ out.print(JsonUtil.loadTrueResult(data));
+
+ }
+
+ @RequestMapping("getCouponList")
+ public void getCouponList(AcceptData acceptData, int page, HttpServletRequest request, PrintWriter out) {
+ page = page > 0 ? page : 1;
+ List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = taoBaoCouponService.getTaoBaoCouponList(page);
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+ JSONArray array = new JSONArray();
+ TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
+
+ for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
+ taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "");
+ array.add(gson.toJson(taoBaoGoodsBriefExtra));
+ }
+ int count = 10000;
+ JSONObject data = new JSONObject();
+ data.put("taoBaoCoupons", array);
+ data.put("count", count);
+ out.print(JsonUtil.loadTrueResult(data));
+
+ try {
+ monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, null));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 閫氳繃鍒嗙被鑾峰彇鍒�
+ *
+ * @param acceptData
+ * @param page
+ * @param out
+ */
+ @RequestMapping("getCouponListByClass")
+ public void getCouponListByClass(AcceptData acceptData, Long id, int page, PrintWriter out) {
+
+ // SearchFilter sf = new SearchFilter();
+ // sf.setQuan(1);
+ // sf.setPage(page);
+ // TaoKeApiUtil.getMaterialByMaterialId(3786, page, 20);
+ if (id == null)
+ return;
+ page = page < 1 ? 1 : page;
+ String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.couponByClass, id + "-" + page);
+ String resultStr = "";
+
+ if (Constant.IS_OUTNET)
+ resultStr = redisManager.getCommonString(key);
+ if (!StringUtil.isNullOrEmpty(resultStr)) {
+ out.print(resultStr);
+ return;
+ }
+
+ int meterialId = 0;
+ Map<Long, Integer> paramMap = new HashMap<>();
+ paramMap.put(10L, 3767);// 濂宠
+ paramMap.put(11L, 3760);// 姣嶅┐
+ paramMap.put(28L, 3764);// 鐢疯
+ paramMap.put(27L, 3758);// 瀹跺眳瀹惰
+ paramMap.put(1L, 3759);// 瀹剁數鏁扮爜
+ paramMap.put(6L, 3765);// 鍐呰。
+ paramMap.put(30L, 3763);// 缇庡
+
+ paramMap.put(31L, 3766);// 杩愬姩鎴峰
+
+ paramMap.put(32L, 3761);// 缇庨
+
+ if (paramMap.get(id) != null)
+ meterialId = paramMap.get(id);
+
+ TaoBaoSearchResult result = null;
+
+ // 涓嶇敓鏁�
+ meterialId = 0;
+ if (meterialId > 0)
+ result = TaoKeApiUtil.getMaterialByMaterialId(meterialId, page, 20);
+ else {
+ SearchFilter sf = new SearchFilter();
+ sf.setPage(page);
+ sf.setPageSize(20);
+ sf.setQuan(1);
+ sf.setKey(goodsClassService.getKeysById(id));
+
+ result = TaoKeApiUtil.searchWuLiao(sf,null,null);
+
+ }
+ List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav();
+ if (result != null && result.getNavList() != null)
+ navList.addAll(result.getNavList());
+
+ if (navList == null)
+ navList = new ArrayList<>();
+
+ Gson gson = new GsonBuilder().create();
+ JSONObject data = new JSONObject();
+ data.put("nav", gson.toJson(navList));
+ List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>();
+ List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+ TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
+ for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
+ taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "");
+ re.add(taoBaoGoodsBriefExtra);
+ }
+
+ Gson gson2 = JsonUtil.getConvertBigDecimalToStringBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().create();
+ data.put("result", gson2.toJson(re));
+ data.put("count", result.getTaoBaoHead().getDocsfound());
+ resultStr = JsonUtil.loadTrueResult(0, data);
+ try {
+ if (Constant.IS_OUTNET)
+ redisManager.cacheCommonString(key, resultStr, 120);
+ } catch (Exception e) {
+ }
+
+ out.print(resultStr);
+ }
+
+ /**
+ * 璁剧疆绾㈠寘杩涘幓
+ *
+ * @param taoBaoCoupons
+ */
+ private void setTaoBaoCouponHongBao(AcceptData acceptData, List<TaoBaoCoupon> taoBaoCoupons) {
+ if (taoBaoCoupons.size() > 0) {
+ BigDecimal proportion = hongBaoManageService.getFanLiRate(acceptData.getSystem());
+
+ for (TaoBaoCoupon taoBaoCoupon : taoBaoCoupons) {
+ BigDecimal hb = TaoBaoUtil.getCouponHongBaoInfo(taoBaoCoupon, proportion);
+ taoBaoCoupon.setHongbao(hb);
+ }
+ }
+ }
+
+ @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) {
+ changePicture = true;
+ }
+
+ List<Map<String, Object>> listCache = goodsClassService.getClassListAllCache(changePicture);
+ if (listCache == null) {
+ listCache = new ArrayList<Map<String, Object>>();
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("categoryList", listCache);
+
+ out.print(JsonUtil.loadTrueResult(data));
+
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+}
--
Gitblit v1.8.0