新客立减修改
This commit is contained in:
@@ -51,10 +51,17 @@ public class MkConsumeDiscountServiceImpl extends ServiceImpl<MkConsumeDiscountM
|
||||
if (consumeDiscountDTO.getRandomDiscountList() == null && consumeDiscountDTO.getDiscountAmount() == null) {
|
||||
throw new ApiNotPrintException("优惠金额和随机优惠金额不能同时为空");
|
||||
}
|
||||
MkConsumeDiscount consumeDiscount = getOne(new QueryWrapper().eq(MkConsumeDiscount::getShopId, shopId));
|
||||
|
||||
if (TableValueConstant.ConsumeDiscount.DiscountType.RANDOM.getCode().equals(consumeDiscountDTO.getDiscountType())) {
|
||||
if (consumeDiscountDTO.getRandomDiscountList() == null || consumeDiscountDTO.getRandomDiscountList().isEmpty()) {
|
||||
throw new ApiNotPrintException("随机优惠金额不能为空");
|
||||
}
|
||||
|
||||
if (consumeDiscountDTO.getRandomDiscountList().stream().map(MkConsumeDiscountRandom::getProbability).reduce(BigDecimal.ZERO, BigDecimal::add).compareTo(new BigDecimal("100")) != 0) {
|
||||
throw new ApiNotPrintException("随机概率综合必须为100%");
|
||||
}
|
||||
consumeDiscount.setRandomDiscountList(JSONArray.toJSONString(consumeDiscountDTO.getRandomDiscountList()));
|
||||
} else {
|
||||
if (consumeDiscountDTO.getDiscountAmount() == null) {
|
||||
throw new ApiNotPrintException("减免金额不能为空");
|
||||
@@ -65,14 +72,8 @@ public class MkConsumeDiscountServiceImpl extends ServiceImpl<MkConsumeDiscountM
|
||||
}
|
||||
}
|
||||
|
||||
MkConsumeDiscount consumeDiscount = getOne(new QueryWrapper().eq(MkConsumeDiscount::getShopId, shopId));
|
||||
BeanUtil.copyProperties(consumeDiscountDTO, consumeDiscount);
|
||||
if (consumeDiscountDTO.getRandomDiscountList() != null) {
|
||||
if (consumeDiscountDTO.getRandomDiscountList().stream().map(MkConsumeDiscountRandom::getProbability).reduce(BigDecimal.ZERO, BigDecimal::add).compareTo(new BigDecimal("100")) != 0) {
|
||||
throw new ApiNotPrintException("随机概率综合必须为100%");
|
||||
}
|
||||
consumeDiscount.setRandomDiscountList(JSONArray.toJSONString(consumeDiscountDTO.getRandomDiscountList()));
|
||||
}
|
||||
|
||||
|
||||
if (consumeDiscountDTO.getUseTypeList() != null) {
|
||||
consumeDiscount.setUseTypeList(JSONArray.toJSONString(consumeDiscountDTO.getUseTypeList()));
|
||||
|
||||
Reference in New Issue
Block a user