增加了发放优惠卷
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user