活动 置空问题

This commit is contained in:
wangw 2024-11-14 11:22:21 +08:00
parent 65c9667d9f
commit 08351e6260
1 changed files with 14 additions and 0 deletions

View File

@ -45,8 +45,22 @@ public class TbActivateServiceImpl extends ServiceImpl<TbActivateMapper, TbActiv
@Override
public void modifyActivate(TbActivate activate) {
if (Objects.nonNull(activate.getId()) && activate.getId() > 0) {
if(activate.getIsUseCoupon()==0){
activate.setCouponId(null);
} else if (activate.getIsUseCoupon()==1) {
if (activate.getCouponId() == null) {
throw new RuntimeException("优惠券不能为空");
}
}
activateMapper.updateById(activate);
} else {
if(activate.getIsUseCoupon()==0){
activate.setCouponId(null);
} else if (activate.getIsUseCoupon()==1) {
if (activate.getCouponId() == null) {
throw new RuntimeException("优惠券不能为空");
}
}
activateMapper.insert(activate);
}
}