1
phpcjl
2024-12-17 08ee411b1f9a02d487ca3190b44d29ea08bde824
1
2个文件已修改
37 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsVip.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsVip.java
@@ -104,5 +104,9 @@
    @TableField("bound_shop_superiors_points")
    private Integer boundShopSuperiorsPoints;
    @ApiModelProperty(value = "vip名子")
    @TableField(exist = false)
    private String vipName;
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -21,6 +21,7 @@
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;
@@ -29,6 +30,7 @@
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
 * <p>
@@ -287,6 +289,11 @@
        // 会员价格
        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);
        // 特殊地区售价设置
@@ -300,12 +307,26 @@
        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());
@@ -315,10 +336,6 @@
            goodsArea1.setCity(goodsArea.getCity());
            goodsArea1.setDistricts(goodsArea.getDistricts());
            goodsArea1.setGoodsAreaList(goodsAreas);
            goodsAreaList1.add(goodsArea1);
        });
        goods.setGoodsAreaList(goodsAreaList1);
        return goods;
        return goodsArea1;
    }
}