|
|
@@ -2689,6 +2689,40 @@ public class ProductServiceImpl implements ProductService {
|
|
|
goods.setProductid(productInfo.getId());
|
|
|
}
|
|
|
}
|
|
|
+ final Double minBuyQty = goods.getMinBuyQty();
|
|
|
+ // 判断前端传入的分段价格是默认的值还是填写错误
|
|
|
+ int size = goods.getOriginalPrices().size();
|
|
|
+ if (size == 1) {
|
|
|
+ GoodsQtyPrice qtyPrice = goods.getOriginalPrices().get(0);
|
|
|
+ // 前端设置的默认值,不用保存
|
|
|
+ if (null == qtyPrice.getPrice()) {
|
|
|
+ goods.setQtyPrice("");
|
|
|
+ }
|
|
|
+ } else if (size > 1) {
|
|
|
+ StringBuffer errMsg = new StringBuffer();
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
+ if (null == goods.getOriginalPrices().get(i).getPrice()) {
|
|
|
+ jointErrMsg(errMsg, String.valueOf(i + 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(errMsg.toString())) {
|
|
|
+ throw new IllegalOperatorException("第" + errMsg.toString() + "价格未填写");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(goods.getQtyPrice())) {
|
|
|
+ if (CollectionUtils.isNotEmpty(goods.getOriginalPrices())) {
|
|
|
+ goods.getOriginalPrices().forEach(subPrice -> {
|
|
|
+ // 分段数量不能超过最大数量
|
|
|
+ Double endQty = NumberUtil.compare(subPrice.getEnd(), DoubleConstant.maxReserve) == 1 ? DoubleConstant.maxReserve : subPrice.getEnd();
|
|
|
+ subPrice.setEnd(endQty);
|
|
|
+
|
|
|
+ // 起始数量不能大于最小订购数
|
|
|
+ Double startQty = NumberUtil.compare(minBuyQty, subPrice.getStart()) == 1 ? subPrice.getStart() : minBuyQty;
|
|
|
+ subPrice.setStart(startQty);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ goods.setQtyPrice(JSON.toJSONString(goods.getOriginalPrices()));
|
|
|
+ }
|
|
|
goodsService.setGoodsDefault(goods);
|
|
|
boolean autoPublish = goods.getAutoPublish() == null ? true : goods.getAutoPublish();
|
|
|
goods.setAutoPublish(autoPublish);
|