|
|
@@ -243,7 +243,9 @@ public class KwpGoodsService {
|
|
|
List<KwpGoodsPriceRange> priceRanges = kwpGoodsPriceRangeService.getByGoodsId(id);
|
|
|
List<GoodsPriceRangesDetail> ranges = BeanUtils.copyToList(priceRanges, GoodsPriceRangesDetail.class);
|
|
|
ranges.stream().filter(r -> r.getEndAmount().compareTo(new BigDecimal("-1.00")) == 0)
|
|
|
- .forEach(r -> {r.setEndAmountLabel("不限");});
|
|
|
+ .forEach(r -> {
|
|
|
+ r.setEndAmountLabel("不限");
|
|
|
+ });
|
|
|
//商品属性信息
|
|
|
List<KwpGoodsAttribute> attributesList = kwpGoodsAttributeService.getByGoodsId(id);
|
|
|
List<GoodsAttributesDetail> attributes = BeanUtils.copyToList(attributesList, GoodsAttributesDetail.class);
|
|
|
@@ -1018,8 +1020,39 @@ public class KwpGoodsService {
|
|
|
*/
|
|
|
public Long getCountBySupplyEnt(Long supplyEntId) {
|
|
|
LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(KwpGoods::getSupplyEntId,supplyEntId).eq(KwpGoods::getDelFlag, Global.NO).
|
|
|
+ wrapper.eq(KwpGoods::getSupplyEntId, supplyEntId).eq(KwpGoods::getDelFlag, Global.NO).
|
|
|
ne(KwpGoods::getStatus, GoodsStatusEnum.SAVED.getCode());
|
|
|
return kwpGoodsMapper.selectCount(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc: 获取商品价格
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-09-05 10:54
|
|
|
+ * @Param param:
|
|
|
+ * @return: java.math.BigDecimal
|
|
|
+ */
|
|
|
+ public BigDecimal getPrice(GetPriceParam param) {
|
|
|
+ List<KwpGoodsPriceRange> priceRanges = kwpGoodsPriceRangeService.getByGoodsId(param.getGoodsId());
|
|
|
+ if (CollectionUtils.isEmpty(priceRanges)) {
|
|
|
+ throw new BusinessException("商品价格信息异常!");
|
|
|
+ }
|
|
|
+ //价格区间空挡四舍五入取整,保证数量在价格区间段
|
|
|
+ BigDecimal num = param.getNum().setScale(0, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal notLimit = null;
|
|
|
+ BigDecimal price = null;
|
|
|
+ for (KwpGoodsPriceRange e : priceRanges) {
|
|
|
+ if (num.compareTo(e.getStartAmount()) >= 0) {
|
|
|
+ BigDecimal endAmount = e.getEndAmount();
|
|
|
+ if (num.compareTo(endAmount) <= 0) {
|
|
|
+ price = e.getPrice();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (endAmount.compareTo(new BigDecimal("-1.00")) == 0) {
|
|
|
+ notLimit = e.getPrice();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Objects.nonNull(price) ? price : notLimit;
|
|
|
+ }
|
|
|
}
|