增加了用户支付次数,购买次数等字段维护

This commit is contained in:
2024-08-02 14:32:45 +08:00
parent 8094cd3c51
commit f3833ee5d5
6 changed files with 123 additions and 10 deletions
+18
View File
@@ -115,3 +115,21 @@ func (r *UserDao) GetUserListByMemberValidTime(maps interface{}, startTime, endT
}
return m, nil
}
// Inc 自增
func (r *UserDao) Inc(tx *gorm.DB, userId int64, field string, numeral int) error {
err := tx.Model(&model.User{}).Where("user_id = ?", userId).UpdateColumn(field, gorm.Expr(field+" + ?", numeral)).Error
if err != nil {
return err
}
return nil
}
// Dec 自减
func (r *UserDao) Dec(tx *gorm.DB, userId int64, field string, numeral int) error {
err := tx.Model(&model.User{}).Where("user_id = ?", userId).UpdateColumn(field, gorm.Expr(field+" - ?", numeral)).Error
if err != nil {
return err
}
return nil
}