// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================

package service

import (
	"context"
	"kami/api/commonApi"
	"kami/internal/consts"
	"kami/internal/model"
	"kami/internal/model/entity"

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

type (
	ICardRedeemOrder interface {
		CallBackOrderToUpstream(ctx context.Context, orderNo string, autoCallback bool) (err error)
		// GetEarlyWaitingOrder 查找等待核销的订单
		GetEarlyWaitingOrder(ctx context.Context, category consts.CardRedeemAccountCategory, tx gdb.TX) (data *entity.V1CardRedeemOrderInfo, err error)
		// GetOrderCount 查询当前待充值订单数量
		GetOrderCount(ctx context.Context, status consts.RedeemOrderStatus) (count int, err error)
		ConsumeOne(ctx context.Context, category consts.CardRedeemAccountCategory) (err error)
		// TriggerValidateAndConsume 触发器，被动验证订单，如果订单有效，就消费订单
		TriggerValidateAndConsume() (err error)
		TriggerConsumeWithContext(ctx context.Context) (err error)
		AddHistory(ctx context.Context, input *model.RedeemCardOrderAddHistory, tx gdb.TX) (err error)
		// GetOrderDetail 获取充值操作记录
		GetOrderDetail(ctx context.Context, orderNo string) (total int, data []*entity.V1CardRedeemOrderHistory, err error)
		// AddOne 添加一条充值记录
		AddOne(ctx context.Context, input *model.RedeemCardSubmitInput) (orderNo string, err error)
		GetOrderOneByOrderNo(ctx context.Context, orderNo string, tx gdb.TX) (data *entity.V1CardRedeemOrderInfo, err error)
		// List 获取充值列表
		List(ctx context.Context, input *model.RedeemCardListInput) (total int, data []*model.RedeemCardOrderOutput, err error)
		// IsCardPassRepeated 当前卡号是否重复
		IsCardPassRepeated(ctx context.Context, cardNo string, CardPass string, tx gdb.TX) (isRepeated bool)
		GetOneByMerchantId(ctx context.Context, merchantId string, tx gdb.TX) (entity *entity.V1CardRedeemOrderInfo, err error)
		// GetRandomOneById 随机获取一个失败订单
		GetRandomOneById(ctx context.Context, accountId string, status consts.RedeemOrderStatus, category consts.CardRedeemAccountCategory, tx gdb.TX) (entity *entity.V1CardRedeemOrderInfo, err error)
		// StartProcessOrder 开始受理订单
		StartProcessOrder(ctx context.Context, orderInfo *entity.V1CardRedeemOrderInfo, tx gdb.TX) (err error)
		// AllocateAccountToOrder 分配账号给订单
		AllocateAccountToOrder(ctx context.Context, accountInfo *entity.V1CardRedeemAccountInfo, orderInfo *entity.V1CardRedeemOrderInfo, tx gdb.TX) (err error)
		// ProcessOrderCallback 操作处理后的订单
		ProcessOrderCallback(ctx context.Context, input *model.RedeemCardOrderAddHistory, status consts.RedeemOrderStatus, tx gdb.TX) (err error)
		ProcessOrderReduction(ctx context.Context, orderNo string, tx gdb.TX) (err error)
		UpdateStatus(ctx context.Context, orderNo string, status consts.RedeemOrderStatus, remark string, tx gdb.TX) (err error)
		// SetCallBackCount 重置调用次数
		SetCallBackCount(ctx context.Context, orderNo string, callbackCount int, tx gdb.TX) (err error)
		// UpdateOrderStatus 更新订单原本状态
		UpdateOrderStatus(ctx context.Context, orderNo string, status consts.RedeemOrderStatus, tx gdb.TX) (err error)
		// ModifyCallBackStatus 修改回调状态
		ModifyCallBackStatus(ctx context.Context, orderNo string, callbackStatus consts.RedeemOrderCallbackStatus, tx gdb.TX) (err error)
		// UpdateCardNoAndCardType 更新卡号和卡种
		UpdateCardNoAndCardType(ctx context.Context, orderNo string, cardNo string, cardTypeName string, tx gdb.TX) (err error)
		Summary(ctx context.Context, page commonApi.CommonPageReq, category consts.CardRedeemAccountCategory, username string, date *gtime.Time, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error)
		SummaryWithOutAccount(ctx context.Context, groupId int64, category consts.CardRedeemAccountCategory, username string, dateRange []*gtime.Time, tx gdb.TX) (output []*model.RedeemCardSummaryWithOutAccountOutput, err error)
		// DailySummary 查询某个用户当日的订单总额
		DailySummary(ctx context.Context, date *gtime.Time, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error)
	}
)

var (
	localCardRedeemOrder ICardRedeemOrder
)

func CardRedeemOrder() ICardRedeemOrder {
	if localCardRedeemOrder == nil {
		panic("implement not found for interface ICardRedeemOrder, forgot register?")
	}
	return localCardRedeemOrder
}

func RegisterCardRedeemOrder(i ICardRedeemOrder) {
	localCardRedeemOrder = i
}
