From aa552facf6d833acab0d3e3e29bda2a0fb826ffe Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期一, 25 十一月 2019 16:14:13 +0800 Subject: [PATCH] 品牌缓存生效 --- fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java | 49 +++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 39 insertions(+), 10 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 6153184..ede5a43 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 @@ -68,11 +68,21 @@ * @return */ private int addBrandGoodsTB(BrandInfo brandInfo) { + Date date = new Date(); + String shopKey = brandInfo.getShopKey(); + if (StringUtil.isNullOrEmpty(shopKey)) { + // 鍒犻櫎涔嬪墠鐨� + brandGoodsCaheDao.removeByDate(brandInfo.getId(), 1 , date); + + // 鍒犻櫎搴楅摵 + brandShopCaheService.removeByDateAndType(brandInfo.getId(), 11, date); + return 0; + } + String searchKey = brandInfo.getSearchKey(); if (StringUtil.isNullOrEmpty(searchKey)) searchKey = brandInfo.getName(); - Date date = new Date(); SearchFilter filter = new SearchFilter(); filter.setKey(searchKey); filter.setPage(1); @@ -94,8 +104,8 @@ // 娣诲姞搴楅摵 String shopTitle = goods.getShopTitle(); if (addShop && !StringUtil.isNullOrEmpty(shopTitle) && shopTitle.contains("鏃楄埌搴�") - && shopTitle.contains(brandInfo.getName())) { - addShop = brandShopCaheService.addBrandShopTB(brandInfo.getId(), goods.getAuctionId(), + && shopTitle.toLowerCase().contains(shopKey.toLowerCase())) { + addShop = brandShopCaheService.addBrandShopTB(brandInfo, goods.getAuctionId(), goods.getSellerId()); } @@ -129,17 +139,28 @@ * @return */ private int addBrandGoodsJD(BrandInfo brandInfo) { - String searchKey = brandInfo.getSearchKey(); + Date date = new Date(); + String shopKey = brandInfo.getShopKeyJD(); + if (StringUtil.isNullOrEmpty(shopKey)) { + // 鍒犻櫎搴楅摵 + brandShopCaheService.removeByDateAndType(brandInfo.getId(), 20, date); + // 鍒犻櫎涔嬪墠 + brandGoodsCaheDao.removeByDate(brandInfo.getId(), 2 , date); + return 0; + } + + String searchKey = brandInfo.getSearchKeyJD(); if (StringUtil.isNullOrEmpty(searchKey)) searchKey = brandInfo.getName(); int count = 0; JDSearchResult result = null; String way = configService.get("jd_api_search_key"); - Date date = new Date(); // 鍒犻櫎搴楅摵 brandShopCaheService.removeByDateAndType(brandInfo.getId(), 20, date); + + boolean addShop = true; for (int i=0; i < 2;i ++) { if ("1".equals(way)) { @@ -162,7 +183,6 @@ } if (result != null && result.getGoodsList() != null && result.getGoodsList().size() > 0) { - boolean addShop = true; List<JDGoods> goodsList = result.getGoodsList(); for (JDGoods goods : goodsList) { BrandGoodsCahe brandGoods = new BrandGoodsCahe(); @@ -177,9 +197,9 @@ if (addShop && shopInfo != null) { // 鍖呭惈璇ュ搧鐗屽悕绉� String shopName = shopInfo.getShopName(); - if (!StringUtil.isNullOrEmpty(shopName) && shopName.contains(brandInfo.getName())) { - brandShopCaheService.addBrandShopJD(brandInfo, shopInfo); + if (!StringUtil.isNullOrEmpty(shopName) && shopName.toLowerCase().contains(shopKey.toLowerCase())) { addShop = false; + brandShopCaheService.addBrandShopJD(brandInfo, shopInfo); } } @@ -204,7 +224,17 @@ * @return */ private int addBrandGoodsPDD(BrandInfo brandInfo) { - String searchKey = brandInfo.getSearchKey(); + Date date = new Date(); + String shopKey = brandInfo.getShopKeyPDD(); + if (StringUtil.isNullOrEmpty(shopKey)) { + // 鍒犻櫎涔嬪墠 + brandGoodsCaheDao.removeByDate(brandInfo.getId(), 3, date); + // 鍒犻櫎涔嬪墠搴楅摵 + brandShopCaheService.removeByDateAndType(brandInfo.getId(), 30, date); + return 0; + } + + String searchKey = brandInfo.getSearchKeyPDD(); if (StringUtil.isNullOrEmpty(searchKey)) searchKey = brandInfo.getName(); @@ -216,7 +246,6 @@ PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter); int count = 0; - Date date = new Date(); if (result != null) { List<PDDGoodsDetail> goodsList = result.getGoodsList(); -- Gitblit v1.8.0