package card_redeem_account

import (
	"context"
	"kami/internal/dao"
	"kami/internal/model"
	"kami/internal/model/do"
	"kami/utility/config"

	"github.com/gogf/gf/v2/database/gdb"
)

// AddDeductionRecord 添加预扣款记录
func (a *sCardRedeemAccount) AddDeductionRecord(ctx context.Context, input *model.RedeemOrderAddDeductionRecordInput, tx gdb.TX) (err error) {
	m := dao.V1CardRedeemAccountDeduction.Ctx(ctx).DB(config.GetDatabaseV1())
	if tx != nil {
		m = m.TX(tx)
	}
	_, err = m.Insert(do.V1CardRedeemAccountDeduction{
		OrderNo:         input.OrderNo,
		AccountId:       input.AccountId,
		OperationStatus: input.Status,
		Balance:         input.Balance,
	})
	return
}
