新客立减修改
This commit is contained in:
parent
84acedfff6
commit
78f3c5e0bc
|
|
@ -24,7 +24,7 @@ import java.math.BigDecimal;
|
||||||
* @since 2025-09-16
|
* @since 2025-09-16
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class MkConsumeDiscountServiceImpl extends ServiceImpl<MkConsumeDiscountMapper, MkConsumeDiscount> implements MkConsumeDiscountService{
|
public class MkConsumeDiscountServiceImpl extends ServiceImpl<MkConsumeDiscountMapper, MkConsumeDiscount> implements MkConsumeDiscountService {
|
||||||
@Override
|
@Override
|
||||||
public MkConsumeDiscountVO detail(Long shopId) {
|
public MkConsumeDiscountVO detail(Long shopId) {
|
||||||
MkConsumeDiscount consumeDiscount = getOne(new QueryWrapper().eq(MkConsumeDiscount::getShopId, shopId));
|
MkConsumeDiscount consumeDiscount = getOne(new QueryWrapper().eq(MkConsumeDiscount::getShopId, shopId));
|
||||||
|
|
@ -51,28 +51,29 @@ public class MkConsumeDiscountServiceImpl extends ServiceImpl<MkConsumeDiscountM
|
||||||
if (consumeDiscountDTO.getRandomDiscountList() == null && consumeDiscountDTO.getDiscountAmount() == null) {
|
if (consumeDiscountDTO.getRandomDiscountList() == null && consumeDiscountDTO.getDiscountAmount() == null) {
|
||||||
throw new ApiNotPrintException("优惠金额和随机优惠金额不能同时为空");
|
throw new ApiNotPrintException("优惠金额和随机优惠金额不能同时为空");
|
||||||
}
|
}
|
||||||
|
MkConsumeDiscount consumeDiscount = getOne(new QueryWrapper().eq(MkConsumeDiscount::getShopId, shopId));
|
||||||
|
|
||||||
if (TableValueConstant.ConsumeDiscount.DiscountType.RANDOM.getCode().equals(consumeDiscountDTO.getDiscountType())) {
|
if (TableValueConstant.ConsumeDiscount.DiscountType.RANDOM.getCode().equals(consumeDiscountDTO.getDiscountType())) {
|
||||||
if (consumeDiscountDTO.getRandomDiscountList() == null || consumeDiscountDTO.getRandomDiscountList().isEmpty()) {
|
if (consumeDiscountDTO.getRandomDiscountList() == null || consumeDiscountDTO.getRandomDiscountList().isEmpty()) {
|
||||||
throw new ApiNotPrintException("随机优惠金额不能为空");
|
throw new ApiNotPrintException("随机优惠金额不能为空");
|
||||||
}
|
}
|
||||||
}else {
|
|
||||||
|
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) {
|
if (consumeDiscountDTO.getDiscountAmount() == null) {
|
||||||
throw new ApiNotPrintException("减免金额不能为空");
|
throw new ApiNotPrintException("减免金额不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (consumeDiscountDTO.getDiscountAmount().compareTo(BigDecimal.ZERO) <= 0) {
|
if (consumeDiscountDTO.getDiscountAmount().compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
throw new ApiNotPrintException("减免金额不能等于0");
|
throw new ApiNotPrintException("减免金额不能等于0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MkConsumeDiscount consumeDiscount = getOne(new QueryWrapper().eq(MkConsumeDiscount::getShopId, shopId));
|
|
||||||
BeanUtil.copyProperties(consumeDiscountDTO, consumeDiscount);
|
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) {
|
if (consumeDiscountDTO.getUseTypeList() != null) {
|
||||||
consumeDiscount.setUseTypeList(JSONArray.toJSONString(consumeDiscountDTO.getUseTypeList()));
|
consumeDiscount.setUseTypeList(JSONArray.toJSONString(consumeDiscountDTO.getUseTypeList()));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue