|
|
@@ -9,7 +9,6 @@ import com.gree.mall.manager.bean.goods.GoodsPriceChangeBean;
|
|
|
import com.gree.mall.manager.bean.goods.GoodsPriceChangeVO;
|
|
|
import com.gree.mall.manager.bean.listvo.UserCustomerVO;
|
|
|
import com.gree.mall.manager.commonmapper.CommonMapper;
|
|
|
-import com.gree.mall.manager.constant.Constant;
|
|
|
import com.gree.mall.manager.enums.ExamineStatusEnum;
|
|
|
import com.gree.mall.manager.exception.RemoteServiceException;
|
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
|
@@ -28,10 +27,7 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -167,6 +163,30 @@ public class GoodsPriceChangeLogic {
|
|
|
goodsSpecService.saveOrUpdateBatch(goodsSpecList);
|
|
|
|
|
|
goodsPriceChangeService.saveOrUpdateBatch(changeList);
|
|
|
+
|
|
|
+ // 更新商品表最低价
|
|
|
+ final List<String> goodsIds = changeList.stream().map(GoodsPriceChange::getGoodsId).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Goods> updateGoodsList = new ArrayList<>();
|
|
|
+ final List<Goods> goodsList = goodsService.lambdaQuery()
|
|
|
+ .in(Goods::getGoodsId, goodsIds)
|
|
|
+ .list();
|
|
|
+
|
|
|
+ List<GoodsSpec> specList = goodsSpecService.lambdaQuery()
|
|
|
+ .in(GoodsSpec::getGoodsId, goodsIds)
|
|
|
+ .list();
|
|
|
+
|
|
|
+ Map<String, List<GoodsSpec>> groupSpec = specList.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
+ List<GoodsSpec> goodsSpecs = groupSpec.get(goods.getGoodsId());
|
|
|
+ goodsSpecs.sort(Comparator.comparing(GoodsSpec::getPrice));
|
|
|
+ Goods updateGoods = new Goods();
|
|
|
+ updateGoods.setGoodsId(goods.getGoodsId())
|
|
|
+ .setGoodsPrice(goodsSpecs.get(0).getPrice());
|
|
|
+ updateGoodsList.add(updateGoods);
|
|
|
+ }
|
|
|
+
|
|
|
+ goodsService.saveOrUpdateBatch(updateGoodsList);
|
|
|
}
|
|
|
|
|
|
@Transactional
|