package card_apple_account

import (
	"context"
	"kami/internal/dao"
	"kami/internal/model/entity"
	"kami/utility/config"
	"kami/utility/utils"
)

// GetHistoryOneByOrderNo 根据ID获取账号历史
func (a *sAppleAccount) GetHistoryOneByOrderNo(ctx context.Context, accountId string, orderNo string) (data *entity.V1CardAppleAccountInfoHistory, err error) {
	data = &entity.V1CardAppleAccountInfoHistory{}
	err = dao.V1CardAppleAccountInfoHistory.Ctx(ctx).DB(config.GetDatabaseV1()).
		Where(dao.V1CardAppleAccountInfoHistory.Columns().AccountId, accountId).
		OrderDesc(dao.V1CardAppleAccountInfoHistory.Columns().CreatedAt).
		Where(dao.V1CardAppleAccountInfoHistory.Columns().OrderNo, orderNo).Scan(&data)
	err = utils.HandleNoRowsError(err)
	return
}
