新增了:发放系统优惠卷

This commit is contained in:
2024-05-31 17:21:26 +08:00
parent d207720a4c
commit 7b021906a2
14 changed files with 767 additions and 24 deletions
+18
View File
@@ -165,3 +165,21 @@ func (r *CouponDao) GetCouponPageSearch(req requests.GetSystemCouponPage, page,
}
return m, totalRecords, nil
}
// Inc 自增
func (r *CouponDao) Inc(tx *gorm.DB, couponId int64, field string, numeral int) error {
err := tx.Model(&model.Coupon{}).Where("coupon_id = ?", couponId).UpdateColumn("coupon_take_count", gorm.Expr(field+" + ?", numeral)).Error
if err != nil {
return err
}
return nil
}
// Dec 自减
func (r *CouponDao) Dec(tx *gorm.DB, couponId int64, field string, numeral int) error {
err := tx.Model(&model.Coupon{}).Where("coupon_id = ?", couponId).UpdateColumn("coupon_take_count", gorm.Expr(field+" - ?", numeral)).Error
if err != nil {
return err
}
return nil
}