From 6b9219eb620f58af063b32be1d9f47cfd62b1c5f Mon Sep 17 00:00:00 2001 From: peng <peng.com> Date: 星期四, 31 七月 2025 17:27:35 +0800 Subject: [PATCH] 解决商品移除视频视频还在问题 --- framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 81 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 78 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index b71b1ea..63f3d6c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -37,6 +37,11 @@ import cn.lili.modules.goods.service.WholesaleService; import cn.lili.modules.goods.sku.GoodsSkuBuilder; import cn.lili.modules.goods.sku.render.SalesModelRender; +import cn.lili.modules.lmk.domain.entity.PriceChange; +import cn.lili.modules.lmk.enums.general.ChangePriceAudioStatusEnum; +import cn.lili.modules.lmk.enums.general.ChangePriceOperationTypeEnum; +import cn.lili.modules.lmk.enums.general.ViewTypeEnum; +import cn.lili.modules.lmk.service.PriceChangeService; import cn.lili.modules.member.entity.dos.FootPrint; import cn.lili.modules.promotion.entity.dos.Coupon; import cn.lili.modules.promotion.entity.dos.PromotionGoods; @@ -55,8 +60,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddressList; @@ -72,8 +79,10 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.net.URLEncoder; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -83,6 +92,7 @@ * @since 2020-02-23 15:18:56 */ @Service +@Slf4j public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> implements GoodsSkuService { /** @@ -136,6 +146,9 @@ @Autowired private List<SalesModelRender> salesModelRenders; + @Autowired + private PriceChangeService priceChangeService; + @Override @Transactional(rollbackFor = Exception.class) public void add(Goods goods, GoodsOperationDTO goodsOperationDTO) { @@ -150,12 +163,29 @@ if (!goodsSkus.isEmpty()) { this.saveOrUpdateBatch(goodsSkus); this.updateGoodsStock(goodsSkus); + //璁板綍浠锋牸鍙樺姩 + List<PriceChange> priceChangeList = goodsSkus.stream().map(item -> { + PriceChange priceChange = new PriceChange(); + priceChange.setCurrentPrice(BigDecimal.valueOf(item.getPrice())); + priceChange.setSkuId(item.getId()); + priceChange.setGoodsId(item.getGoodsId()); + priceChange.setPreviousPrice(BigDecimal.ZERO); + priceChange.setPreviousCommission(BigDecimal.ZERO); + priceChange.setCurrentCommission(goods.getCommission()); + priceChange.setOperatorType(ChangePriceOperationTypeEnum.STORE.name()); + priceChange.setExamineStatus(ChangePriceAudioStatusEnum.APPLY.name()); + priceChange.setOperatorId(UserContext.getCurrentUser().getId()); + priceChange.setOperatorName(UserContext.getCurrentUser().getNickName()); + priceChange.setStoreId(item.getStoreId()); + return priceChange; + }).collect(Collectors.toList()); + priceChangeService.saveBatch(priceChangeList); } } @Override @Transactional(rollbackFor = Exception.class) - public void update(Goods goods, GoodsOperationDTO goodsOperationDTO) { + public void update(Goods goods, GoodsOperationDTO goodsOperationDTO,Goods previousGoods) { // 鏄惁瀛樺湪瑙勬牸 if (goodsOperationDTO.getSkuList() == null || goodsOperationDTO.getSkuList().isEmpty()) { throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU); @@ -198,9 +228,41 @@ unnecessarySkuIdsQuery.eq(GoodsSku::getGoodsId, goods.getId()); unnecessarySkuIdsQuery.notIn(GoodsSku::getId, skuList.stream().map(BaseEntity::getId).collect(Collectors.toList())); + LambdaQueryWrapper<GoodsSku> skuIdsQuery = new LambdaQueryWrapper<>(); + skuIdsQuery.eq(GoodsSku::getGoodsId, goods.getId()); + skuIdsQuery.in(GoodsSku::getId, + skuList.stream().map(BaseEntity::getId).collect(Collectors.toList())); + Map<String, GoodsSku> skuMap = this.list(skuIdsQuery).stream().collect(Collectors.toMap(GoodsSku::getId, Function.identity())); this.remove(unnecessarySkuIdsQuery); this.saveOrUpdateBatch(skuList); this.updateGoodsStock(skuList); + //璁板綍浠锋牸鍙樺姩 + //鍒犻櫎褰撳墠瀹℃牳鐘舵�佷负鐢宠鐨勬敼浠风殑鍟嗗搧 搴楅摵id涓�鑷村晢鍝乮d涓�鑷翠笖涓虹敵璇风姸鎬佺殑绉婚櫎 + LambdaQueryWrapper<PriceChange> needRemove = Wrappers.<PriceChange>lambdaQuery() + .eq(PriceChange::getGoodsId, goods.getId()) + .eq(PriceChange::getStoreId, goods.getStoreId()) + .eq(PriceChange::getExamineStatus, ChangePriceAudioStatusEnum.APPLY.name()); + priceChangeService.remove(needRemove); + //閲嶆柊娣诲姞鏀逛环鍟嗗搧 + List<PriceChange> priceChangeList = skuList.stream().map(item -> { + PriceChange priceChange = new PriceChange(); + priceChange.setCurrentPrice(BigDecimal.valueOf(item.getPrice())); + GoodsSku goodsSku = skuMap.get(item.getId()); + priceChange.setSkuId(item.getId()); + priceChange.setGoodsId(item.getGoodsId()); + if (Objects.nonNull(goodsSku)) { + priceChange.setPreviousPrice(BigDecimal.valueOf(goodsSku.getPrice())); + } + priceChange.setPreviousCommission(previousGoods.getCommission()); + priceChange.setCurrentCommission(goods.getCommission()); + priceChange.setOperatorType(ChangePriceOperationTypeEnum.STORE.name()); + priceChange.setExamineStatus(ChangePriceAudioStatusEnum.APPLY.name()); + priceChange.setOperatorId(UserContext.getCurrentUser().getId()); + priceChange.setOperatorName(UserContext.getCurrentUser().getNickName()); + priceChange.setStoreId(item.getStoreId()); + return priceChange; + }).collect(Collectors.toList()); + priceChangeService.saveBatch(priceChangeList); } } @@ -295,11 +357,13 @@ if (goodsIndex == null) { goodsIndex = goodsIndexService.getResetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList()); } - + log.info("鑾峰彇鍒板晢鍝佷俊鎭�----------------->{}",JSONUtil.toJsonStr(goodsIndex)); //鍟嗗搧瑙勬牸 GoodsSkuVO goodsSkuDetail = this.getGoodsSkuVO(goodsSku); Map<String, Object> promotionMap = goodsIndex.getPromotionMap(); + log.info("鑾峰彇淇冮攢娲诲姩淇℃伅----------------->{}",JSONUtil.toJsonStr(promotionMap)); + AuthUser currentUser = UserContext.getCurrentUser(); //璁剧疆褰撳墠鍟嗗搧鐨勪績閿�浠锋牸 if (promotionMap != null && !promotionMap.isEmpty()) { @@ -365,7 +429,7 @@ //璁板綍鐢ㄦ埛瓒宠抗 if (currentUser != null) { - FootPrint footPrint = new FootPrint(currentUser.getId(), goodsIndex.getStoreId(), goodsId, skuId); + FootPrint footPrint = new FootPrint(currentUser.getId(), goodsIndex.getStoreId(), goodsId, skuId, ViewTypeEnum.GOODS.getValue(), null, null); String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.VIEW_GOODS.name(); rocketMQTemplate.asyncSend(destination, footPrint, RocketmqSendCallbackBuilder.commonCallback()); } @@ -388,6 +452,17 @@ updateWrapper.set(GoodsSku::getDeleteFlag, goods.getDeleteFlag()); boolean update = this.update(updateWrapper); if (Boolean.TRUE.equals(update)) { + //淇敼璁㈠崟鏀逛环鐘舵�佷负閫氳繃鎴栬�呭け璐� + LambdaUpdateWrapper<PriceChange> updatePriceChange = Wrappers.<PriceChange>lambdaUpdate() + .eq(PriceChange::getGoodsId, goods.getId()) + .eq(PriceChange::getStoreId, goods.getStoreId()) + .eq(PriceChange::getExamineStatus, ChangePriceAudioStatusEnum.APPLY.name()); + if (GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) { + updatePriceChange.set(PriceChange::getExamineStatus, ChangePriceAudioStatusEnum.PASS.name()); + }else { + updatePriceChange.set(PriceChange::getExamineStatus, ChangePriceAudioStatusEnum.REFUSE.name()); + } + priceChangeService.update(updatePriceChange); List<GoodsSku> goodsSkus = this.getGoodsSkuListByGoodsId(goods.getId()); for (GoodsSku sku : goodsSkus) { cache.remove(GoodsSkuService.getCacheKeys(sku.getId())); -- Gitblit v1.8.0