活动 置空问题

This commit is contained in:
2024-11-14 10:59:17 +08:00
parent e84d655796
commit 65c9667d9f
2 changed files with 4 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
package cn.ysk.cashier.mybatis.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -17,10 +18,12 @@ public class TbActivate extends Model<TbActivate> {
//赠送金额
private Integer giftAmount;
//赠送积分
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private Integer giftPoints;
//是否使用优惠卷 0否 1是
private Integer isUseCoupon;
//优惠卷id
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private Integer couponId;
@TableField(exist = false)
private String couponName;

View File

@@ -45,15 +45,7 @@ public class TbActivateServiceImpl extends ServiceImpl<TbActivateMapper, TbActiv
@Override
public void modifyActivate(TbActivate activate) {
if (Objects.nonNull(activate.getId()) && activate.getId() > 0) {
UpdateWrapper<TbActivate> updateWrapper = new UpdateWrapper<>();
updateWrapper.setEntity(activate);
if (Objects.isNull(activate.getCouponId())) {
updateWrapper.set("coupon_id", null);
}
if (Objects.isNull(activate.getGiftPoints())) {
updateWrapper.set("gift_points", null);
}
activateMapper.update(updateWrapper);
activateMapper.updateById(activate);
} else {
activateMapper.insert(activate);
}