From 01407e36f8a1d46e065cdcfe14629540dbd6b921 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期一, 04 十一月 2019 09:41:37 +0800 Subject: [PATCH] 红包 --- fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java | 36 ++++++++++++++++++++++++++++++++---- 1 files changed, 32 insertions(+), 4 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java index 48c7fdb..057259e 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java @@ -17,6 +17,7 @@ import com.yeshi.fanli.dao.brand.BrandShopCaheDao; import com.yeshi.fanli.dao.mybatis.brand.BrandInfoMapper; +import com.yeshi.fanli.dto.ConfigParamsDTO; import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; import com.yeshi.fanli.entity.brand.BrandGoodsCahe; import com.yeshi.fanli.entity.brand.BrandInfo; @@ -254,8 +255,35 @@ // 鍒犻櫎搴楅摵 brandShopCaheService.removeAgoByDate(date); + + long count = brandInfoMapper.countValidByCid(null); + if (count == 0) + return; + + for (int page = 1; page < (count / 100) + 1; page++) { + updateTotalGoods((page - 1) * 100, 100); + } } + /** + * 鏇存柊鍟嗗搧鏁伴噺 + * @param start + * @param count + */ + private void updateTotalGoods(long start, int count) { + List<BrandInfo> list = brandInfoMapper.listValidAll(start, count); + if (list == null || list.size() == 0) + return; + + for (BrandInfo brandInfo : list) { + long goodsTotal = brandGoodsCaheService.countByBrandId(brandInfo.getId()); + + BrandInfo updateInfo = new BrandInfo(); + updateInfo.setId(brandInfo.getId()); + updateInfo.setGoodsTotal((int)goodsTotal); + brandInfoMapper.updateByPrimaryKeySelective(updateInfo); + } + } @Override @@ -306,7 +334,7 @@ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); - + ConfigParamsDTO configParamsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE); List<BrandInfoVO> listInfo = new ArrayList<BrandInfoVO>(); for (int i = 0; i < list.size(); i++) { BrandInfoVO brand = list.get(i); @@ -321,19 +349,19 @@ for (BrandGoodsCahe brandGoods : listGoods) { JDGoods goodsJD = brandGoods.getGoodsJD(); if (goodsJD != null) { - listGoodsVO.add(GoodsDetailVOFactory.convertJDGoods(goodsJD, fanLiRate, shareRate)); + listGoodsVO.add(GoodsDetailVOFactory.convertJDGoods(goodsJD, configParamsDTO)); continue; } TaoBaoGoodsBrief goodsTB = brandGoods.getGoodsTB(); if (goodsTB != null) { - listGoodsVO.add(GoodsDetailVOFactory.convertTaoBao(goodsTB, null, fanLiRate, shareRate)); + listGoodsVO.add(GoodsDetailVOFactory.convertTaoBao(goodsTB, configParamsDTO)); continue; } PDDGoodsDetail goodsPDD = brandGoods.getGoodsPDD(); if (goodsPDD != null) { - listGoodsVO.add(GoodsDetailVOFactory.convertPDDGoods(goodsPDD, fanLiRate, shareRate)); + listGoodsVO.add(GoodsDetailVOFactory.convertPDDGoods(goodsPDD, configParamsDTO)); continue; } } -- Gitblit v1.8.0