增加了发放优惠卷

This commit is contained in:
2024-08-13 08:51:24 +08:00
parent ca2f2c4421
commit 978dadf14e
8 changed files with 197 additions and 39 deletions
+18
View File
@@ -115,3 +115,21 @@ func (r *CouponDao) GetCouponListByValidTime(maps interface{}, startTime, endTim
}
return m, 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(field, 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(field, gorm.Expr(field+" - ?", numeral)).Error
if err != nil {
return err
}
return nil
}