// ================================================================================
// 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/internal/consts"
	"kami/internal/model"
	"kami/internal/model/entity"

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

type (
	IAppleOrder interface {
		// CallbackOrder 回调订单给第三方
		CallbackOrder(ctx context.Context, data *entity.V1CardAppleRechargeInfo) (bool, error)
		CallBackOrderToUpstream(ctx context.Context, orderNo string) (err error)
		// CronCallbackPendingOrders 定时任务：回调处于失败和成功状态的订单
		CronCallbackPendingOrders(ctx context.Context) error
		// CronFailedScheduleTask 定时任务：回调处于失败和成功状态的订单
		CronFailedScheduleTask(ctx context.Context) error
		// CronProcessOrderWithPush 处理订单：根据订单类型判断是立即进行核销处理还是创建定时任务异步处理
		// 参数说明：
		//   - orderEntity: 待处理的订单信息
		//   - accountInfo: 分配的苹果账号信息
		//   - immediate: 是否立即处理（true: 立即核销，false: 异步定时处理）
		CronProcessOrderWithPush(ctx context.Context) (err error)
		// List 获取充值列表
		List(ctx context.Context, input model.AppleCardRechargeParamsInput) (total int, data []entity.V1CardAppleRechargeInfo, err error)
		// ListWithAccount 获取充值列表（包含账号信息）
		ListWithAccount(ctx context.Context, input model.AppleCardRechargeParamsInput) (total int, data []model.AppleCardRechargeListOutput, err error)
		// AddRechargeOrder 添加一条充值记录
		AddRechargeOrder(ctx context.Context, input *model.AppleCardRechargeInput) (orderNo string, err error)
		// DistributionAccordingAccount 给指定订单分配一个账户
		DistributionAccordingAccount(ctx context.Context, account *entity.V1CardAppleAccountInfo, order *entity.V1CardAppleRechargeInfo) (err error)
		// DecrementDistributionCount 减少分配次数
		DecrementDistributionCount(ctx context.Context, orderNo string) (err error)
		// UpdateActualAmount 修改订单实际金额
		UpdateActualAmount(ctx context.Context, data *model.AppleAccountUpdateAmountRecord, tx gdb.TX) (err error)
		// UpdateActualAmountAndHistory 添加充值记录
		UpdateActualAmountAndHistory(ctx context.Context, record *model.AppleAccountUpdateAmountAndHistoryRecord, tx gdb.TX) (err error)
		UpdateActualAmountAndHistoryAndWallet(ctx context.Context, m *model.AppleAccountUpdateAmountAndHistoryRecord) (err error)
		// GetListByStatus 获取指定状态的订单
		GetListByStatus(ctx context.Context, statusList []consts.AppleRechargeOrderStatus) (data entity.V1CardAppleRechargeInfo, err error)
		// GetTodayRechargeAmountByAccountID 获取当前账户今日的充值金额
		GetTodayRechargeAmountByAccountID(ctx context.Context, accountID string) (amount float64, err error)
		// GetRechargeStatusByOrderNo 通过订单号查询当前订单充值状态
		GetRechargeStatusByOrderNo(ctx context.Context, orderNo string) (status int, err error)
		// GetOneByOrderNo 通过订单号查询当前订单充值
		GetOneByOrderNo(ctx context.Context, orderNo string, tx gdb.TX, id ...int64) (data entity.V1CardAppleRechargeInfo, err error)
		GetOneByMerchantId(ctx context.Context, merchantId string) (data *entity.V1CardAppleRechargeInfo, err error)
		// GetAccordingOrders 找到符合条件的订单
		GetAccordingOrders(ctx context.Context) (list []*entity.V1CardAppleRechargeInfo, err error)
		// AddHistory 添加一条充值历史记录
		AddHistory(ctx context.Context, input *model.AppleCardRechargeHistoryInput, tx gdb.TX) (err error)
		QueryDuplicatedCardPass(ctx context.Context, cardPass string) (bool, string)
		/*
			QueryDuplicatedCardPassV2 判断当前卡密是否重复，如果重复，返回True

			卡密重复的规则有个例外情况，就是提交卡密为金额异议的情况，这个时候允许卡密重复，并只允许重复一次重复
		*/
		QueryDuplicatedCardPassV2(ctx context.Context, cardPass string) (bool, string)
		// QueryOneByCardPass 通过卡密查询订单
		QueryOneByCardPass(ctx context.Context, cardPass string, status *consts.AppleRechargeOrderStatus) (data entity.V1CardAppleRechargeInfo, err error)
		// GetRechargeDetails 获取充值操作记录
		GetRechargeDetails(ctx context.Context, orderNo string) (total int, data []entity.V1CardAppleHistoryInfo, err error)
		// ModifyOrderStatus 修改充值订单状态
		ModifyOrderStatus(ctx context.Context, orderNo string, status consts.AppleRechargeOrderStatus, remark string, tx gdb.TX) (err error)
		// ResetDistributionCount 重置调用次数
		ResetDistributionCount(ctx context.Context, orderNo string, tx gdb.TX) (err error)
		// ModifyCallBackStatus 修改回调状态
		ModifyCallBackStatus(ctx context.Context, orderNo string, callbackStatus bool, tx gdb.TX) (err error)
		// UpdateRemark 更新状态
		UpdateRemark(ctx context.Context, orderNo string, remark string, tx gdb.TX) (err error)
		// CheckIsAccordingStealRule 查询当前账号是否符合偷卡规则
		CheckIsAccordingStealRule(ctx context.Context, targetUserId string, amount float64) (isSteal bool, data *entity.V1CardAppleHiddenSettings, err error)
		// GetStealRule 获取偷卡配置，目标用户ID
		GetStealRule(ctx context.Context, targetUserId string) (data []entity.V1CardAppleHiddenSettings, err error)
		// SetStealRule 设置偷卡关联规则
		SetStealRule(ctx context.Context, orderNo string, setting *entity.V1CardAppleHiddenSettings) (ruleId int64, err error)
		// GetStealOrderInfoById 根据偷卡规则查找对应的订单关联关系
		GetStealOrderInfoById(ctx context.Context, hiddenSettingId int) (data []entity.V1CardAppleHiddenSettingsRechargeInfo, err error)
		// UpdateStealNewOrderNo 关联新的订单号到当前订单
		UpdateStealNewOrderNo(ctx context.Context, ruleId int64, orderNo string) (err error)
		// GetStealOrderInfoByCreatedAt 查询当前时间后所有关联的订单
		GetStealOrderInfoByCreatedAt(ctx context.Context, createdAt *gtime.Time) (orderNos g.SliceStr, err error)
		// GetStealOrderInfoByNewOrderNo  查询当前新订单是否是关联的订单
		GetStealOrderInfoByNewOrderNo(ctx context.Context, orderNo string) (data *entity.V1CardAppleHiddenSettingsRechargeInfo, err error)
		// GetStealOrderInfoByOrderNo 判断当前订单是否是关联的订单
		GetStealOrderInfoByOrderNo(ctx context.Context, orderNo string) (data *entity.V1CardAppleHiddenSettingsRechargeInfo, err error)
		// UpdateStealActualAmount 添加偷卡金额总额
		UpdateStealActualAmount(ctx context.Context, id int, amount float64) (err error)
		// AddStealRule 添加一条偷卡规则
		AddStealRule(ctx context.Context, input *model.StealRuleAddInput) (err error)
		// UpdateStealRule 更新一条偷卡规则
		UpdateStealRule(ctx context.Context, input *model.StealRuleUpdateInput) (err error)
		// DeleteStealRule 删除一条偷卡规则
		DeleteStealRule(ctx context.Context, id uint) (err error)
		// GetStealRuleList 获取偷卡规则列表
		GetStealRuleList(ctx context.Context, input *model.StealRuleListInput) (total int, list []*entity.V1CardAppleHiddenSettings, err error)
		// SetStealRuleStatus 设置单个状态是否启用
		SetStealRuleStatus(ctx context.Context, ruleId uint, status consts.StealStatus) (err error)
		/*
			ValidateCardPass 校验账号是否正确

			# X开头的16位  然后16位卡密中  出现 A B E I O S U 数字 1 和数字0   就是假卡密

			如果正确，返回true，否则返回false
		*/
		ValidateCardPass(ctx context.Context, cardPass string) bool
	}
)

var (
	localAppleOrder IAppleOrder
)

func AppleOrder() IAppleOrder {
	if localAppleOrder == nil {
		panic("implement not found for interface IAppleOrder, forgot register?")
	}
	return localAppleOrder
}

func RegisterAppleOrder(i IAppleOrder) {
	localAppleOrder = i
}
