From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java | 666 +++++++++++++++++++++++++++--------------------------- 1 files changed, 334 insertions(+), 332 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java index 3d8e25a..b08b3b4 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java @@ -1,332 +1,334 @@ -package com.yeshi.fanli.service.impl.brand; - -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; - -import com.yeshi.fanli.entity.SystemEnum; -import org.springframework.stereotype.Service; - -import com.yeshi.fanli.dao.brand.BrandGoodsCaheDao; -import com.yeshi.fanli.dto.jd.JDFilter; -import com.yeshi.fanli.dto.jd.JDSearchFilter; -import com.yeshi.fanli.dto.jd.JDSearchResult; -import com.yeshi.fanli.dto.jd.JDShopInfo; -import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; -import com.yeshi.fanli.dto.pdd.PDDGoodsResult; -import com.yeshi.fanli.dto.pdd.PDDSearchFilter; -import com.yeshi.fanli.entity.brand.BrandGoodsCahe; -import com.yeshi.fanli.entity.brand.BrandInfo; -import com.yeshi.fanli.entity.jd.JDGoods; -import com.yeshi.fanli.entity.system.ConfigKeyEnum; -import com.yeshi.fanli.entity.taobao.SearchFilter; -import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; -import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; -import com.yeshi.fanli.log.LogHelper; -import com.yeshi.fanli.service.inter.brand.BrandGoodsCaheService; -import com.yeshi.fanli.service.inter.brand.BrandShopCaheService; -import com.yeshi.fanli.service.inter.config.ConfigService; -import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; -import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.jd.JDApiUtil; -import com.yeshi.fanli.util.jd.JDUtil; -import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; -import com.yeshi.fanli.util.taobao.SearchFilterUtil; -import com.yeshi.fanli.util.taobao.TaoBaoUtil; -import com.yeshi.fanli.util.taobao.TaoKeApiUtil; - -@Service -public class BrandGoodsCaheServiceImpl implements BrandGoodsCaheService { - @Resource - private HongBaoManageService hongBaoManageService; - - @Resource - private ConfigService configService; - - @Resource - private BrandGoodsCaheDao brandGoodsCaheDao; - - @Resource - private BrandShopCaheService brandShopCaheService; - - @Override - public BrandInfo addBrandGoods(BrandInfo brandInfo, SystemEnum system) { - // 娣樺疂 - BrandInfo goodsTB = addBrandGoodsTB(brandInfo); - // 浜笢 - BrandInfo goodsJD = addBrandGoodsJD(brandInfo,system); - // 鎷煎澶� - BrandInfo goodsPDD = addBrandGoodsPDD(brandInfo); - - int goodsTotal = goodsTB.getGoodsTotal() + goodsJD.getGoodsTotal() + goodsPDD.getGoodsTotal(); - int shopTotal = goodsTB.getShopTotal() + goodsJD.getShopTotal() + goodsPDD.getShopTotal(); - goodsTB.setGoodsTotal(goodsTotal); - goodsTB.setShopTotal(shopTotal); - return goodsTB; - } - - /** - * 娣樺疂鍟嗗搧 - * - * @param brandInfo - * @return - */ - private BrandInfo addBrandGoodsTB(BrandInfo brandInfo) { - Date date = new Date(); - BrandInfo numInfo = new BrandInfo(); - numInfo.setShopTotal(0); - numInfo.setGoodsTotal(0); - try { - String shopKey = brandInfo.getShopKey(); - if (StringUtil.isNullOrEmpty(shopKey)) { - // 鍒犻櫎涔嬪墠鐨� - brandGoodsCaheDao.removeByDate(brandInfo.getId(), 1, date); - // 鍒犻櫎搴楅摵 - brandShopCaheService.removeByDateAndType(brandInfo.getId(), 11, date); - - return numInfo; - } - - String searchKey = brandInfo.getSearchKey(); - if (StringUtil.isNullOrEmpty(searchKey)) - searchKey = brandInfo.getName(); - - SearchFilter filter = new SearchFilter(); - filter.setKey(searchKey); - filter.setPage(1); - filter.setPageSize(100); - filter.setTmall(true); - filter.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); - TaoBaoSearchResult searchResult = TaoKeApiUtil.searchWuLiao(filter); - - // 鍒犻櫎搴楅摵 - brandShopCaheService.removeByDateAndType(brandInfo.getId(), 11, date); - - // 缁勭粐鍟嗗搧 + 娣诲姞搴楅摵 - int count = 0; - int countShop = 0; - if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null - && searchResult.getTaoBaoGoodsBriefs().size() > 0) { - boolean addShop = true; - List<TaoBaoGoodsBrief> listGoods = searchResult.getTaoBaoGoodsBriefs(); - for (TaoBaoGoodsBrief goods : listGoods) { - // 娣诲姞搴楅摵 - String shopTitle = goods.getShopTitle(); - if (addShop && !StringUtil.isNullOrEmpty(shopTitle) && shopTitle.contains("鏃楄埌搴�") - && shopTitle.toLowerCase().contains(shopKey.toLowerCase())) { - addShop = brandShopCaheService.addBrandShopTB(brandInfo, goods.getAuctionId(), - goods.getSellerId()); - - if (!addShop) - countShop = 1; - } - - // 娣诲姞鍟嗗搧 - if (count < 50) { - BrandGoodsCahe brandGoods = new BrandGoodsCahe(); - brandGoods.setBrandId(brandInfo.getId()); - brandGoods.setWeight((int) (Math.random() * 1000)); - brandGoods.setGoodsType(1); - brandGoods.setGoodsTB(goods); - brandGoods.setCreateTime(new Date()); - brandGoodsCaheDao.insert(brandGoods); - count++; - } else if (!addShop) { - break; - } - } - } - - // 鍒犻櫎涔嬪墠鐨� - brandGoodsCaheDao.removeByDate(brandInfo.getId(), 1, date); - numInfo.setShopTotal(countShop); - numInfo.setGoodsTotal(count); - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - } - return numInfo; - } - - /** - * 浜笢鍟嗗搧 - * - * @param brandInfo - * @return - */ - private BrandInfo addBrandGoodsJD(BrandInfo brandInfo, SystemEnum system) { - Date date = new Date(); - BrandInfo numInfo = new BrandInfo(); - numInfo.setShopTotal(0); - numInfo.setGoodsTotal(0); - - try { - String shopKey = brandInfo.getShopKeyJD(); - if (StringUtil.isNullOrEmpty(shopKey)) { - // 鍒犻櫎搴楅摵 - brandShopCaheService.removeByDateAndType(brandInfo.getId(), 20, date); - // 鍒犻櫎涔嬪墠 - brandGoodsCaheDao.removeByDate(brandInfo.getId(), 2, date); - return numInfo; - } - - String searchKey = brandInfo.getSearchKeyJD(); - if (StringUtil.isNullOrEmpty(searchKey)) - searchKey = brandInfo.getName(); - - int count = 0; - int countShop = 0; - JDSearchResult result = null; - String way = configService.getValue(ConfigKeyEnum.jdApiSearchKey.getKey(),system); - - // 鍒犻櫎搴楅摵 - brandShopCaheService.removeByDateAndType(brandInfo.getId(), 20, date); - - boolean addShop = true; - for (int i = 0; i < 2; i++) { - if ("1".equals(way)) { - JDFilter filterAPI = new JDFilter(); - filterAPI.setKeyword(SearchFilterUtil.filterSearchContent(searchKey)); - filterAPI.setPageIndex(1); - filterAPI.setPageSize(30); - filterAPI.setSort(JDFilter.SORT_DESC); - filterAPI.setSortName(JDFilter.SORTNAME_ORDER_COUNT_30DAYS); - result = JDApiUtil.queryByKey(filterAPI); - } else { - // 缃戦〉鐖彇 - JDSearchFilter jdfilter = new JDSearchFilter(); - jdfilter.setKey(SearchFilterUtil.filterSearchContent(searchKey)); - jdfilter.setPageNo(1); - jdfilter.setPageSize(30); - jdfilter.setSort(JDSearchFilter.SORT_DESC); - jdfilter.setSortName(JDSearchFilter.SORTNAME_ORDER_COUNT_30DAYS); - result = JDUtil.searchByKey(jdfilter); - } - - if (result != null && result.getGoodsList() != null && result.getGoodsList().size() > 0) { - List<JDGoods> goodsList = result.getGoodsList(); - for (JDGoods goods : goodsList) { - BrandGoodsCahe brandGoods = new BrandGoodsCahe(); - brandGoods.setBrandId(brandInfo.getId()); - brandGoods.setWeight((int) (Math.random() * 1000)); - brandGoods.setGoodsJD(goods); - brandGoods.setGoodsType(2); - brandGoods.setCreateTime(new Date()); - brandGoodsCaheDao.insert(brandGoods); - - JDShopInfo shopInfo = goods.getShopInfo(); - if (addShop && shopInfo != null) { - // 鍖呭惈璇ュ搧鐗屽悕绉� - String shopName = shopInfo.getShopName(); - if (!StringUtil.isNullOrEmpty(shopName) - && shopName.toLowerCase().contains(shopKey.toLowerCase())) { - addShop = false; - brandShopCaheService.addBrandShopJD(brandInfo, shopInfo); - countShop = 1; - } - } - - count++; - if (count >= 50) { - break; - } - } - } - } - // 鍒犻櫎涔嬪墠 - brandGoodsCaheDao.removeByDate(brandInfo.getId(), 2, date); - numInfo.setShopTotal(countShop); - numInfo.setGoodsTotal(count); - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - } - return numInfo; - } - - /** - * 鎷煎澶氬晢鍝� - * - * @param brandInfo - * @return - */ - private BrandInfo addBrandGoodsPDD(BrandInfo brandInfo) { - Date date = new Date(); - BrandInfo numInfo = new BrandInfo(); - numInfo.setShopTotal(0); - numInfo.setGoodsTotal(0); - try { - String shopKey = brandInfo.getShopKeyPDD(); - if (StringUtil.isNullOrEmpty(shopKey)) { - // 鍒犻櫎涔嬪墠 - brandGoodsCaheDao.removeByDate(brandInfo.getId(), 3, date); - // 鍒犻櫎涔嬪墠搴楅摵 - brandShopCaheService.removeByDateAndType(brandInfo.getId(), 30, date); - return numInfo; - } - - String searchKey = brandInfo.getSearchKeyPDD(); - if (StringUtil.isNullOrEmpty(searchKey)) - searchKey = brandInfo.getName(); - - PDDSearchFilter pddfilter = new PDDSearchFilter(); - pddfilter.setKw(searchKey); - pddfilter.setPage(1); - pddfilter.setPageSize(100); - pddfilter.setSortType(6); - PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter); - - int count = 0; - - if (result != null) { - List<PDDGoodsDetail> goodsList = result.getGoodsList(); - if (goodsList != null && goodsList.size() > 0) { - for (PDDGoodsDetail goods : goodsList) { - BrandGoodsCahe brandGoods = new BrandGoodsCahe(); - brandGoods.setBrandId(brandInfo.getId()); - brandGoods.setWeight((int) (Math.random() * 1000)); - brandGoods.setGoodsType(3); - brandGoods.setGoodsPDD(goods); - brandGoods.setCreateTime(new Date()); - brandGoodsCaheDao.insert(brandGoods); - count++; - if (count >= 50) { - break; - } - } - } - } - // 鍒犻櫎涔嬪墠 - brandGoodsCaheDao.removeByDate(brandInfo.getId(), 3, date); - // 鍒犻櫎涔嬪墠搴楅摵 - brandShopCaheService.removeByDateAndType(brandInfo.getId(), 30, date); - // 娣诲姞搴楅摵 - int countShop = brandShopCaheService.addBrandShopPDD(brandInfo); - - numInfo.setShopTotal(countShop); - numInfo.setGoodsTotal(count); - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - } - return numInfo; - } - - @Override - public List<BrandGoodsCahe> getByBrandId(int start, int count, Long brandId) { - return brandGoodsCaheDao.getByBrandId(start, count, brandId); - } - - @Override - public long countByBrandId(Long brandId) { - return brandGoodsCaheDao.countByBrandId(brandId); - } - - @Override - public void removeAgoByDate(Date createTime) { - brandGoodsCaheDao.removeAgoByDate(createTime); - } - - @Override - public void removeByBrandId(Long brandId) { - brandGoodsCaheDao.removeByBrandId(brandId); - } -} +package com.yeshi.fanli.service.impl.brand; + +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + +import com.yeshi.fanli.entity.SystemEnum; +import com.yeshi.fanli.util.Constant; +import org.springframework.stereotype.Service; + +import com.yeshi.fanli.dao.brand.BrandGoodsCaheDao; +import com.yeshi.fanli.dto.jd.JDFilter; +import com.yeshi.fanli.dto.jd.JDSearchFilter; +import com.yeshi.fanli.dto.jd.JDSearchResult; +import com.yeshi.fanli.dto.jd.JDShopInfo; +import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; +import com.yeshi.fanli.dto.pdd.PDDGoodsResult; +import com.yeshi.fanli.dto.pdd.PDDSearchFilter; +import com.yeshi.fanli.entity.brand.BrandGoodsCahe; +import com.yeshi.fanli.entity.brand.BrandInfo; +import com.yeshi.fanli.entity.jd.JDGoods; +import com.yeshi.fanli.entity.system.ConfigKeyEnum; +import com.yeshi.fanli.entity.taobao.SearchFilter; +import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; +import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.inter.brand.BrandGoodsCaheService; +import com.yeshi.fanli.service.inter.brand.BrandShopCaheService; +import com.yeshi.fanli.service.inter.config.ConfigService; +import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; +import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.jd.JDApiUtil; +import com.yeshi.fanli.util.jd.JDUtil; +import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; +import com.yeshi.fanli.util.taobao.SearchFilterUtil; +import com.yeshi.fanli.util.taobao.TaoBaoUtil; +import com.yeshi.fanli.util.taobao.TaoKeApiUtil; + +@Service +public class BrandGoodsCaheServiceImpl implements BrandGoodsCaheService { + @Resource + private HongBaoManageService hongBaoManageService; + + @Resource + private ConfigService configService; + + @Resource + private BrandGoodsCaheDao brandGoodsCaheDao; + + @Resource + private BrandShopCaheService brandShopCaheService; + + @Override + public BrandInfo addBrandGoods(BrandInfo brandInfo, SystemEnum system) { + // 娣樺疂 + BrandInfo goodsTB = addBrandGoodsTB(brandInfo); + // 浜笢 + BrandInfo goodsJD = addBrandGoodsJD(brandInfo,system); + // 鎷煎澶� + BrandInfo goodsPDD = addBrandGoodsPDD(brandInfo); + + int goodsTotal = goodsTB.getGoodsTotal() + goodsJD.getGoodsTotal() + goodsPDD.getGoodsTotal(); + int shopTotal = goodsTB.getShopTotal() + goodsJD.getShopTotal() + goodsPDD.getShopTotal(); + goodsTB.setGoodsTotal(goodsTotal); + goodsTB.setShopTotal(shopTotal); + return goodsTB; + } + + /** + * 娣樺疂鍟嗗搧 + * + * @param brandInfo + * @return + */ + private BrandInfo addBrandGoodsTB(BrandInfo brandInfo) { + Date date = new Date(); + BrandInfo numInfo = new BrandInfo(); + numInfo.setShopTotal(0); + numInfo.setGoodsTotal(0); + try { + String shopKey = brandInfo.getShopKey(); + if (StringUtil.isNullOrEmpty(shopKey)) { + // 鍒犻櫎涔嬪墠鐨� + brandGoodsCaheDao.removeByDate(brandInfo.getId(), 1, date); + // 鍒犻櫎搴楅摵 + brandShopCaheService.removeByDateAndType(brandInfo.getId(), 11, date); + + return numInfo; + } + + String searchKey = brandInfo.getSearchKey(); + if (StringUtil.isNullOrEmpty(searchKey)) + searchKey = brandInfo.getName(); + + SearchFilter filter = new SearchFilter(); + filter.setKey(searchKey); + filter.setPage(1); + filter.setPageSize(100); + filter.setTmall(true); + filter.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); + TaoBaoSearchResult searchResult = TaoKeApiUtil.searchWuLiaoNew(filter,null,null); + + // 鍒犻櫎搴楅摵 + brandShopCaheService.removeByDateAndType(brandInfo.getId(), 11, date); + + // 缁勭粐鍟嗗搧 + 娣诲姞搴楅摵 + int count = 0; + int countShop = 0; + if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null + && searchResult.getTaoBaoGoodsBriefs().size() > 0) { + boolean addShop = true; + List<TaoBaoGoodsBrief> listGoods = searchResult.getTaoBaoGoodsBriefs(); + for (TaoBaoGoodsBrief goods : listGoods) { + // 娣诲姞搴楅摵 + String shopTitle = goods.getShopTitle(); + if (addShop && !StringUtil.isNullOrEmpty(shopTitle) && shopTitle.contains("鏃楄埌搴�") + && shopTitle.toLowerCase().contains(shopKey.toLowerCase())) { + addShop = brandShopCaheService.addBrandShopTB(brandInfo, goods.getAuctionId(), + goods.getSellerId()); + + if (!addShop) + countShop = 1; + } + + // 娣诲姞鍟嗗搧 + if (count < 50) { + BrandGoodsCahe brandGoods = new BrandGoodsCahe(); + brandGoods.setBrandId(brandInfo.getId()); + brandGoods.setWeight((int) (Math.random() * 1000)); + brandGoods.setGoodsType(1); + brandGoods.setGoodsTB(goods); + brandGoods.setCreateTime(new Date()); + brandGoodsCaheDao.insert(brandGoods); + count++; + } else if (!addShop) { + break; + } + } + } + + // 鍒犻櫎涔嬪墠鐨� + brandGoodsCaheDao.removeByDate(brandInfo.getId(), 1, date); + numInfo.setShopTotal(countShop); + numInfo.setGoodsTotal(count); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + return numInfo; + } + + /** + * 浜笢鍟嗗搧 + * + * @param brandInfo + * @return + */ + private BrandInfo addBrandGoodsJD(BrandInfo brandInfo, SystemEnum system) { + Date date = new Date(); + BrandInfo numInfo = new BrandInfo(); + numInfo.setShopTotal(0); + numInfo.setGoodsTotal(0); + + try { + String shopKey = brandInfo.getShopKeyJD(); + if (StringUtil.isNullOrEmpty(shopKey)) { + // 鍒犻櫎搴楅摵 + brandShopCaheService.removeByDateAndType(brandInfo.getId(), 20, date); + // 鍒犻櫎涔嬪墠 + brandGoodsCaheDao.removeByDate(brandInfo.getId(), 2, date); + return numInfo; + } + + String searchKey = brandInfo.getSearchKeyJD(); + if (StringUtil.isNullOrEmpty(searchKey)) + searchKey = brandInfo.getName(); + + int count = 0; + int countShop = 0; + JDSearchResult result = null; + String way = configService.getValue(ConfigKeyEnum.jdApiSearchKey.getKey(),system); + + // 鍒犻櫎搴楅摵 + brandShopCaheService.removeByDateAndType(brandInfo.getId(), 20, date); + + boolean addShop = true; + for (int i = 0; i < 2; i++) { + if ("1".equals(way)&&false) { + // 浜笢鎼滅储涓嶈兘杩囧害娑堣�� + JDFilter filterAPI = new JDFilter(); + filterAPI.setKeyword(SearchFilterUtil.filterSearchContent(searchKey)); + filterAPI.setPageIndex(1); + filterAPI.setPageSize(30); + filterAPI.setSort(JDFilter.SORT_DESC); + filterAPI.setSortName(JDFilter.SORTNAME_ORDER_COUNT_30DAYS); + result = JDApiUtil.queryByKey(filterAPI); + } else { + // 缃戦〉鐖彇 + JDSearchFilter jdfilter = new JDSearchFilter(); + jdfilter.setKey(SearchFilterUtil.filterSearchContent(searchKey)); + jdfilter.setPageNo(1); + jdfilter.setPageSize(30); + jdfilter.setSort(JDSearchFilter.SORT_DESC); + jdfilter.setSortName(JDSearchFilter.SORTNAME_ORDER_COUNT_30DAYS); + result = JDUtil.searchByKey(jdfilter); + } + + if (result != null && result.getGoodsList() != null && result.getGoodsList().size() > 0) { + List<JDGoods> goodsList = result.getGoodsList(); + for (JDGoods goods : goodsList) { + BrandGoodsCahe brandGoods = new BrandGoodsCahe(); + brandGoods.setBrandId(brandInfo.getId()); + brandGoods.setWeight((int) (Math.random() * 1000)); + brandGoods.setGoodsJD(goods); + brandGoods.setGoodsType(2); + brandGoods.setCreateTime(new Date()); + brandGoodsCaheDao.insert(brandGoods); + + JDShopInfo shopInfo = goods.getShopInfo(); + if (addShop && shopInfo != null) { + // 鍖呭惈璇ュ搧鐗屽悕绉� + String shopName = shopInfo.getShopName(); + if (!StringUtil.isNullOrEmpty(shopName) + && shopName.toLowerCase().contains(shopKey.toLowerCase())) { + addShop = false; + brandShopCaheService.addBrandShopJD(brandInfo, shopInfo); + countShop = 1; + } + } + + count++; + if (count >= 50) { + break; + } + } + } + } + // 鍒犻櫎涔嬪墠 + brandGoodsCaheDao.removeByDate(brandInfo.getId(), 2, date); + numInfo.setShopTotal(countShop); + numInfo.setGoodsTotal(count); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + return numInfo; + } + + /** + * 鎷煎澶氬晢鍝� + * + * @param brandInfo + * @return + */ + private BrandInfo addBrandGoodsPDD(BrandInfo brandInfo) { + Date date = new Date(); + BrandInfo numInfo = new BrandInfo(); + numInfo.setShopTotal(0); + numInfo.setGoodsTotal(0); + try { + String shopKey = brandInfo.getShopKeyPDD(); + if (StringUtil.isNullOrEmpty(shopKey)) { + // 鍒犻櫎涔嬪墠 + brandGoodsCaheDao.removeByDate(brandInfo.getId(), 3, date); + // 鍒犻櫎涔嬪墠搴楅摵 + brandShopCaheService.removeByDateAndType(brandInfo.getId(), 30, date); + return numInfo; + } + + String searchKey = brandInfo.getSearchKeyPDD(); + if (StringUtil.isNullOrEmpty(searchKey)) + searchKey = brandInfo.getName(); + + PDDSearchFilter pddfilter = new PDDSearchFilter(); + pddfilter.setKw(searchKey); + pddfilter.setPage(1); + pddfilter.setPageSize(100); + pddfilter.setSortType(6); + PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter, Constant.PDD_SEARCH_CUSTOMER_PARAMS); + + int count = 0; + + if (result != null) { + List<PDDGoodsDetail> goodsList = result.getGoodsList(); + if (goodsList != null && goodsList.size() > 0) { + for (PDDGoodsDetail goods : goodsList) { + BrandGoodsCahe brandGoods = new BrandGoodsCahe(); + brandGoods.setBrandId(brandInfo.getId()); + brandGoods.setWeight((int) (Math.random() * 1000)); + brandGoods.setGoodsType(3); + brandGoods.setGoodsPDD(goods); + brandGoods.setCreateTime(new Date()); + brandGoodsCaheDao.insert(brandGoods); + count++; + if (count >= 50) { + break; + } + } + } + } + // 鍒犻櫎涔嬪墠 + brandGoodsCaheDao.removeByDate(brandInfo.getId(), 3, date); + // 鍒犻櫎涔嬪墠搴楅摵 + brandShopCaheService.removeByDateAndType(brandInfo.getId(), 30, date); + // 娣诲姞搴楅摵 + int countShop = brandShopCaheService.addBrandShopPDD(brandInfo); + + numInfo.setShopTotal(countShop); + numInfo.setGoodsTotal(count); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + return numInfo; + } + + @Override + public List<BrandGoodsCahe> getByBrandId(int start, int count, Long brandId) { + return brandGoodsCaheDao.getByBrandId(start, count, brandId); + } + + @Override + public long countByBrandId(Long brandId) { + return brandGoodsCaheDao.countByBrandId(brandId); + } + + @Override + public void removeAgoByDate(Date createTime) { + brandGoodsCaheDao.removeAgoByDate(createTime); + } + + @Override + public void removeByBrandId(Long brandId) { + brandGoodsCaheDao.removeByBrandId(brandId); + } +} -- Gitblit v1.8.0