// ================================================================================
// 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/shopspring/decimal"
)

type (
	IAppleAccount interface {
		Add(ctx context.Context, data *model.AppleAccountRecordInput, tx gdb.TX) (err error)
		// Update 修改用户信息
		Update(ctx context.Context, data *model.V1CardAppleAccountInfo, tx gdb.TX) (err error)
		// AddWalletAmount 添加金额到账户中
		AddWalletAmount(ctx context.Context, input *model.AppleCardWalletInfo, tx gdb.TX) (isFull bool, err error)
		// Delete 删除苹果账号
		Delete(ctx context.Context, id string, tx gdb.TX) (err error)
		// List 获取所有苹果账户
		List(ctx context.Context, input *model.CardInfoParamsInput) (total int, data []model.AppleAccountListOutput, err error)
		// ListUnscoped 获取所有苹果账户
		ListUnscoped(ctx context.Context, input *model.CardInfoParamsInput) (total int, data []model.AppleAccountListOutput, err error)
		// GetDetailById 根据ID获取账号详情
		GetDetailById(ctx context.Context, id string) (data *entity.V1CardAppleAccountInfo, err error)
		GetUnscopedDetailById(ctx context.Context, id string) (data *entity.V1CardAppleAccountInfo, err error)
		GetDetailsByCreatedUser(ctx context.Context, createdUserId string) (data []*entity.V1CardAppleAccountInfo, err error)
		// GetFirstNormalByCreatedUser 通过上传人获取最先上传切正常的账号
		GetFirstNormalByCreatedUser(ctx context.Context, createdUserId string) (data entity.V1CardAppleAccountInfo, err error)
		// GetDetailByName 根据账号获取账号详情
		GetDetailByName(ctx context.Context, account string) (data entity.V1CardAppleAccountInfo, err error)
		// IsUnscopedTodayRepeatedByName 判断档当前添加的账号是否重复
		IsUnscopedTodayRepeatedByName(ctx context.Context, account string) (isRepeated bool, err error)
		// GetAll 获取所有账号
		GetAll(ctx context.Context) (data []entity.V1CardAppleAccountInfo, err error)
		// GetAllNormal 获取所有可用账户
		GetAllNormal(ctx context.Context) (data []*entity.V1CardAppleAccountInfo, err error)
		// GetListByStatus 获取所有可用的账号
		GetListByStatus(ctx context.Context, status consts.AppleAccountStatus) (data []entity.V1CardAppleAccountInfo, err error)
		// CheckIsNormal 查询当前账户是否正常
		CheckIsNormal(ctx context.Context, accountId string)
		// GetDecryptedPassword 获取解密后的密码
		GetDecryptedPassword(encryptedPassword string) (string, error)
		// GetNextUser 从sysUser表中查询所有用户，获取排序后的当前用户后面下一个Id
		GetNextUser(ctx context.Context, originalUserId string, amount decimal.Decimal) (targetId string, err error)
		SetCurrentTargetAccount(ctx context.Context, m *model.AccountIdInfo) (err error)
		GetCurrentTargetAccount(ctx context.Context) (m model.AccountIdInfo, err error)
		GetAllTargetAccount(ctx context.Context) (m []*model.AccountIdInfo, err error)
		GetExcludeAccounts(ctx context.Context) (m []*model.AccountIdInfo, err error)
		// ClearCurrentTargetAccount 清空缓存
		ClearCurrentTargetAccount(ctx context.Context) (err error)
		CronHealthCheck(ctx context.Context)
		// CronResetStatus 重置账号状态
		CronResetStatus(ctx context.Context, tx gdb.TX) (err error)
		// CronHandleTmpStoppedList 处理临时暂停账号
		CronHandleTmpStoppedList(ctx context.Context) (err error)
		// GetHistoryOneByOrderNo 根据ID获取账号历史
		GetHistoryOneByOrderNo(ctx context.Context, accountId string, orderNo string) (data *entity.V1CardAppleAccountInfoHistory, err error)
		// GetAccordingAccount 账户分配算法，适合多线程
		GetAccordingAccount(ctx context.Context, amount decimal.Decimal, excludeAccountIds []string) (accountInfo *entity.V1CardAppleAccountInfo, err error)
		ModifyStatus(ctx context.Context, id string, status consts.AppleAccountStatus, tx gdb.TX) (err error)
		// CheckAllAccountIsNormal 判断当前用户上传是否有账户可用
		CheckAllAccountIsNormal(ctx context.Context, createdUserId string) (isNormal bool, err error)
		// AddWalletHistory 添加账户历史明细
		AddWalletHistory(ctx context.Context, input model.AppleCardAccountHistoryInput, tx gdb.TX) (err error)
		// GetWalletHistory 获取单账户钱包明细
		GetWalletHistory(ctx context.Context, input model.CardAppleAccountHistoryQueryInput) (total int, data []entity.V1CardAppleAccountInfoHistory, err error)
		// CheckWalletHistoryNormal 检查账户流水是否跟iTunes余额一致，如果不一致，就手动添加添加差额
		CheckWalletHistoryNormal(ctx context.Context, accountId string)
	}
)

var (
	localAppleAccount IAppleAccount
)

func AppleAccount() IAppleAccount {
	if localAppleAccount == nil {
		panic("implement not found for interface IAppleAccount, forgot register?")
	}
	return localAppleAccount
}

func RegisterAppleAccount(i IAppleAccount) {
	localAppleAccount = i
}
