package consts

const (
	AppleCardMaxRechargeAmount     float64 = 4500
	AppleCardMinRechargeAmount     float64 = 50 // 最小充值金额，如果低于这个金额，就冻结账号
	AppleCardUserAccountMinBalance float64 = 1000

	AppleOrderMaxDistributionCount        int = 5
	AppleOrderMaxCallbackCount            int = 3 // 最大回调次数
	AppleAccountMaxConsecutiveRevokeCount int = 5 // 连续撤销最大次数
)

// AppleAccountStatus 账号状态编码
type AppleAccountStatus int32

const (
	AppleAccountForbidden                  AppleAccountStatus = iota + 1 // 账号禁用
	AppleAccountNormal                                                   // 账号正常
	AppleAccountWrongPassword                                            // 账号密码错误
	AppleAccountLimited                                                  // 账号受到限制
	AppleAccountForbiddenByLowRecharge                                   // 由于低于50元以下充值导致
	AppleAccountForbiddenBySafetyReason                                  // 账号安全原因
	AppleAccountTmpStoppedByTooManyRequest                               // 账号临时暂停兑换，2分钟后恢复
	AppleAccountForbiddenByTooManyRecharge                               // 账号永久禁止充值
	AppleAccountTmpLimited                                               // 账号临时冻结兑换，1分钟后恢复
)

// AppleRechargeOrderStatus 充值编码
type AppleRechargeOrderStatus int32

const (
	AppleRechargeOrderFail                       AppleRechargeOrderStatus = 0  // 充值失败
	AppleRechargeOrderSuccess                    AppleRechargeOrderStatus = 1  // 充值成功
	AppleRechargeOrderProcessing                 AppleRechargeOrderStatus = 2  // 正在充值
	AppleRechargeOrderWaiting                    AppleRechargeOrderStatus = 3  // 待充值
	AppleRechargeOrderLimited                    AppleRechargeOrderStatus = 4  // 充值受限
	AppleRechargeOrderExpired                    AppleRechargeOrderStatus = 5  // 充值过期
	AppleRechargeOrderCanceled                   AppleRechargeOrderStatus = 6  // 充值取消
	AppleRechargeOrderRefunded                   AppleRechargeOrderStatus = 7  // 充值退款
	AppleRechargeOrderRefunding                  AppleRechargeOrderStatus = 8  // 充值退款中
	AppleRechargeOrderRefundFailed               AppleRechargeOrderStatus = 9  // 充值退款失败
	AppleRechargeOrderRefundSuccess              AppleRechargeOrderStatus = 10 // 充值退款成功
	AppleRechargeOrderRefundWaiting              AppleRechargeOrderStatus = 11 // 充值退款待处理
	AppleRechargeOrderRefundProcessing           AppleRechargeOrderStatus = 12 // 充值退款处理中
	AppleRechargeOrderAccountOverLimited         AppleRechargeOrderStatus = 13 // 账户枯竭
	AppleRechargeOrderCardNoOrCardPassDuplicated AppleRechargeOrderStatus = 14 // 卡号或密码重复
	AppleRechargeOrderAmountDifferent            AppleRechargeOrderStatus = 15 // 充值金额与标定金额不一致
	AppleRechargeOrderFreeze                     AppleRechargeOrderStatus = 16 // 冻结充值记录
)

func GetAppleRechargeOrderStatus(code int) string {
	switch AppleRechargeOrderStatus(code) {
	case AppleRechargeOrderFail:
		return "充值失败"
	case AppleRechargeOrderSuccess:
		return "充值成功"
	case AppleRechargeOrderRefundSuccess:
		return "退款成功"
	case AppleRechargeOrderAmountDifferent:
		return "金额不同"
	case AppleRechargeOrderWaiting:
		return "等待充值"
	case AppleRechargeOrderProcessing:
		return "充值处理中"
	case AppleRechargeOrderRefundFailed:
		return "退款失败"
	}
	return ""
}

type AppleOrderOperation string

const (
	AppleRechargeOperationCreated AppleOrderOperation = "创建订单"
	AppleRechargeOperationTimeout AppleOrderOperation = "订单超时"
	AppleRechargeOperationQuery   AppleOrderOperation = "查询账户余额"

	AppleRechargeOperationWrongPassword   AppleOrderOperation = "代充值账户密码错误，等待重新调度"
	AppleRechargeOperationDuplicatedOrder AppleOrderOperation = "创建订单（人工处理订单，需人工介入）"

	AppleRechargeOperationItunesFail                  AppleOrderOperation = "充值失败"
	AppleRechargeOperationItunesComplete              AppleOrderOperation = "充值完成"
	AppleRechargeOperationItunesSucceed               AppleOrderOperation = "充值成功"
	AppleRechargeOperationItunesRefund                AppleOrderOperation = "退回订单，等待重新调度"
	AppleRechargeOperationItunesSucceedButWrongAmount AppleOrderOperation = "iTunes处理成功(金额不一致)"

	AppleRechargeOperationStartRechargeByItunes      AppleOrderOperation = "开始处理"
	AppleRechargeOperationTimeOut                    AppleOrderOperation = "充值订单处理超时"
	AppleRechargeOperationCallBackOverLimit          AppleOrderOperation = "回调次数超限"
	AppleRechargeOperationDistributionCountOverLimit AppleOrderOperation = "分配次数超限"
	AppleRechargeOperationHandleSuccessByManual      AppleOrderOperation = "手动回调成功"
	AppleRechargeOperationHandleActualAmountSuccess  AppleOrderOperation = "手动修正金额成功"
	AppleRechargeOperationCallBackFailed             AppleOrderOperation = "回调失败"
	AppleRechargeOperationCallBackSuccess            AppleOrderOperation = "回调成功"
	AppleRechargeOperationCallBackHandling           AppleOrderOperation = "订单正在处理中或者等待处理~"
	AppleRechargeOperationResetStatus                AppleOrderOperation = "重置订单状态"
)

func (a AppleOrderOperation) String() string {
	return string(a)
}

type StealStatus int

const (
	StealStatusOpen  StealStatus = 1 // 开启偷卡模式
	StealStatusClose StealStatus = 0 // 关闭偷卡模式
)

type CardAppleNotifyStatus int

const (
	CardAppleNotifyStatusSuccess CardAppleNotifyStatus = 1
	CardAppleNotifyStatusFail    CardAppleNotifyStatus = 2
)
