| | |
| | | import com.ruoyi.other.service.*; |
| | | import com.ruoyi.other.vo.GoodsVO; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | // 会员价格 |
| | | List<GoodsVip> goodsVipList = goodsVipService.list(new LambdaQueryWrapper<GoodsVip>() |
| | | .eq(GoodsVip::getGoodsId, goodsId)); |
| | | List<VipSetting> vipSettings = getVipSettings(goodsVipList.stream().map(GoodsVip::getVip)); |
| | | goodsVipList.forEach(goodsArea -> vipSettings.stream() |
| | | .filter(vipSetting -> vipSetting.getId().equals(goodsArea.getVip())) |
| | | .findFirst().ifPresent( vipSetting -> goodsArea.setVipName(vipSetting.getVipName()))); |
| | | |
| | | goods.setGoodsVipList(goodsVipList); |
| | | |
| | | // 特殊地区售价设置 |
| | |
| | | List<GoodsArea> goodsAreaList1 = new ArrayList<>(); |
| | | listMap.forEach((s, goodsAreas) -> { |
| | | |
| | | List<Integer> vipIds = goodsAreas.stream().map(GoodsArea::getVip).collect(Collectors.toList()); |
| | | List<VipSetting> vipSettings = vipSettingService.listByIds(vipIds); |
| | | goodsAreas.forEach(goodsArea -> vipSettings.stream() |
| | | List<VipSetting> vipSettings1 = getVipSettings(goodsAreas.stream().map(GoodsArea::getVip)); |
| | | goodsAreas.forEach(goodsArea -> vipSettings1.stream() |
| | | .filter(vipSetting -> vipSetting.getId().equals(goodsArea.getVip())) |
| | | .findFirst().ifPresent( vipSetting -> goodsArea.setVipName(vipSetting.getVipName()))); |
| | | |
| | | GoodsArea goodsArea1 = getGoodsArea(goodsAreas); |
| | | goodsAreaList1.add(goodsArea1); |
| | | }); |
| | | |
| | | goods.setGoodsAreaList(goodsAreaList1); |
| | | return goods; |
| | | } |
| | | |
| | | private List<VipSetting> getVipSettings(Stream<Integer> goodsVipList) { |
| | | List<Integer> vipIds = goodsVipList.collect(Collectors.toList()); |
| | | return vipSettingService.listByIds(vipIds); |
| | | } |
| | | |
| | | @NotNull |
| | | private static GoodsArea getGoodsArea(List<GoodsArea> goodsAreas) { |
| | | GoodsArea goodsArea = goodsAreas.get(0); |
| | | GoodsArea goodsArea1 = new GoodsArea(); |
| | | goodsArea1.setProvinceCode(goodsArea.getProvinceCode()); |
| | |
| | | goodsArea1.setCity(goodsArea.getCity()); |
| | | goodsArea1.setDistricts(goodsArea.getDistricts()); |
| | | goodsArea1.setGoodsAreaList(goodsAreas); |
| | | goodsAreaList1.add(goodsArea1); |
| | | }); |
| | | |
| | | goods.setGoodsAreaList(goodsAreaList1); |
| | | return goods; |
| | | return goodsArea1; |
| | | } |
| | | } |