From fe879975a3e8a0a1aa280fb839e02d159bfbcff8 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 27 八月 2019 18:04:38 +0800 Subject: [PATCH] 金币任务多次获取bug修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java | 62 ++++++++++++++++++++++++------- 1 files changed, 48 insertions(+), 14 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java index 566f3bb..dff37a4 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java @@ -3,7 +3,9 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.annotation.Resource; @@ -29,6 +31,7 @@ import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.lable.QualityGoodsService; +import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; @@ -63,6 +66,9 @@ @Resource private TaoBaoGoodsBriefService taoBaoGoodsBriefService; + + @Resource + private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; @Override public List<BrandClassShop> getExistByShopIds(List<Long> list) { @@ -128,8 +134,8 @@ @Override @Transactional - public void changeShopInfo(MultipartFile file, Long id, Long cid, String shopName, Integer state, Integer top,String key) - throws BrandClassShopException { + public void changeShopInfo(MultipartFile file, Long id, Long cid, String shopName, Integer state, Integer top, + String key) throws BrandClassShopException { if (id == null) { throw new BrandClassShopException(1, "鏁版嵁涓虹┖锛氳閫夋嫨搴楅摵"); @@ -150,7 +156,7 @@ } // 鑷畾涔夊浘鐗� - taoBaoShopService.changeInfo(file, shop.getId(), shopName,key); + taoBaoShopService.changeInfo(file, shop.getId(), shopName, key); BrandClassShop updateshop = new BrandClassShop(); updateshop.setState(state); @@ -170,7 +176,8 @@ for (BrandClassShop brandClassShop : listQuery) { TaoBaoShop shop = brandClassShop.getShop(); if (shop != null) { - long couponNum = commonGoodsService.countBySellerIdAndHasCoupon(shop.getId(), Constant.SOURCE_TYPE_TAOBAO); + long couponNum = commonGoodsService.countBySellerIdAndHasCoupon(shop.getId(), + Constant.SOURCE_TYPE_TAOBAO); brandClassShop.setCouponNum(couponNum); String shopLink = shop.getShopLink(); @@ -306,6 +313,9 @@ count = taoBaoShopService.countBrandShopinfo(cid); } + // 娣樺疂鍟嗗搧淇℃伅杩囨护 + Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo); + BigDecimal proportion = hongBaoManageService.getFanLiRate(); for (TaoBaoShopVO taoBaoShopVO : listInfo) { @@ -327,7 +337,8 @@ List<TaoBaoGoodsBriefExtra> listGoods = new ArrayList<TaoBaoGoodsBriefExtra>(); List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief(); for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) { - listGoods.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)); + listGoods.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsMap.get(taoBaoGoodsBrief.getAuctionId()), + proportion.toString(), null)); } taoBaoShopVO.setListGoods(listGoods); } @@ -337,8 +348,25 @@ return data; } - - + /** + * 鑾峰彇杩囨护鍟嗗搧 + * + * @param listInfo + * @return + */ + private Map<Long, TaoBaoGoodsBrief> getFilterTaoBaoGoods(List<TaoBaoShopVO> listInfo) { + // 杩囨护鍟嗗搧 + List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); + for (TaoBaoShopVO taoBaoShopVO : listInfo) { + goodsList.addAll(taoBaoShopVO.getListGoodsBrief()); + } + goodsList = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(goodsList); + Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>(); + for (TaoBaoGoodsBrief goods : goodsList) + goodsMap.put(goods.getAuctionId(), goods); + return goodsMap; + } + @Override @Cacheable(value = "brandCache", key = "'listEffectiveCacheV2-'+#page+'-'+#cid") public JSONObject listEffectiveCacheV2(int page, Long cid) { @@ -361,14 +389,14 @@ for (BrandClassShop brandClassShop : list) { TaoBaoShop shop = brandClassShop.getShop(); if (shop != null) { - + Integer userType = shop.getUserType(); if (userType == null || userType == 0) { shop.setUserType(10); } else { shop.setUserType(11); } - + String shopLink = shop.getShopLink(); if (StringUtil.isNullOrEmpty(shopLink)) { shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); @@ -404,6 +432,10 @@ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); + + // 娣樺疂鍟嗗搧淇℃伅杩囨护 + Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo); + for (TaoBaoShopVO taoBaoShopVO : listInfo) { Integer userType = taoBaoShopVO.getUserType(); @@ -412,7 +444,7 @@ } else { taoBaoShopVO.setUserType(11); } - + String shopLink = taoBaoShopVO.getShopLink(); if (StringUtil.isNullOrEmpty(shopLink)) { taoBaoShopVO.setShopLink(TaoBaoUtil.getShopLink(taoBaoShopVO.getId())); @@ -430,8 +462,12 @@ List<GoodsDetailVO> listGoods = new ArrayList<GoodsDetailVO>(); List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief(); + + // 鍟嗗搧娣诲姞鍒版洿鏂伴槦鍒� + taoBaoGoodsUpdateService.addUpdateQueueAsync(listGoodsBrief); for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) { - GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate); + GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory + .convertTaoBao(goodsMap.get(taoBaoGoodsBrief.getAuctionId()), null, fanLiRate, shareRate); listGoods.add(goodsDetailVO); } taoBaoShopVO.setListGoodsVO(listGoods); @@ -441,9 +477,7 @@ return data; } - - - + @Override public void addClick(Long shopId) { BrandClassShop brandClassShop = brandClassShopMapper.getByShopId(shopId); -- Gitblit v1.8.0