| | |
| | | package com.yeshi.fanli.controller.client.v1;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | 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);
|
| | | 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 淘客佣金比率高到低: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 = "";
|
| | | // 查询是否有淘宝分类ID
|
| | | 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);
|
| | | JSONObject result = taoKeGoodsService.searchWuLiao(searchfilter);
|
| | | long count = result.optLong("count");
|
| | | JSONArray resultArray = result.getJSONArray("result");
|
| | | // 查询是否超过了最大的商品数
|
| | | if (resultArray == null || resultArray.size() < 20) {
|
| | | // 需要根据关键字查询
|
| | | searchfilter.setCateIds(null);
|
| | | searchfilter.setPage((int) (count % 20 == 0 ? count / 20 - 1 : count / 20));
|
| | | searchfilter.setPageSize(20);
|
| | | searchfilter.setKey(goodsSubClass.getKey());
|
| | | result = taoKeGoodsService.searchWuLiao(searchfilter);
|
| | | if (resultArray != null)
|
| | | result.optJSONArray("result").addAll(0, resultArray);
|
| | | 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 淘客佣金比率高到低: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 = ""; |
| | | // 查询是否有淘宝分类ID |
| | | 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.searchWuLiaoNew(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.searchWuLiaoNew(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.searchWuLiaoNew(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(); |
| | | } |
| | | } |
| | | } |
| | | } |