package consts

import (
	"github.com/gogf/gf/v2/os/gtime"
)

// ====================================================================================
// 骆驼加油订单处理模块常量定义
// ====================================================================================

// CamelOilAccountStatus 骆驼加油账号状态枚举
type CamelOilAccountStatus int

const (
	CamelOilAccountStatusPending  CamelOilAccountStatus = 0 // 待登录
	CamelOilAccountStatusSendCode CamelOilAccountStatus = 1 // 发送验证码
	CamelOilAccountStatusOnline   CamelOilAccountStatus = 2 // 在线
	CamelOilAccountStatusPaused   CamelOilAccountStatus = 3 // 已暂停
	CamelOilAccountStatusInvalid  CamelOilAccountStatus = 4 // 已失效
)

// CamelOilAccountStatusText 账号状态文本映射
var CamelOilAccountStatusText = map[CamelOilAccountStatus]string{
	CamelOilAccountStatusPending:  "待登录",
	CamelOilAccountStatusSendCode: "登录中",
	CamelOilAccountStatusOnline:   "在线",
	CamelOilAccountStatusPaused:   "已暂停",
	CamelOilAccountStatusInvalid:  "已失效",
}

// CamelOilOrderStatus 骆驼加油订单状态枚举
type CamelOilOrderStatus int

const (
	CamelOilOrderStatusPending    CamelOilOrderStatus = 0 // 待处理
	CamelOilOrderStatusProcessing CamelOilOrderStatus = 1 // 处理中
	CamelOilOrderStatusCompleted  CamelOilOrderStatus = 2 // 已完成
	CamelOilOrderStatusFailed     CamelOilOrderStatus = 3 // 已失败
)

// CamelOilOrderStatusText 订单状态文本映射
var CamelOilOrderStatusText = map[CamelOilOrderStatus]string{
	CamelOilOrderStatusPending:    "待处理",
	CamelOilOrderStatusProcessing: "处理中",
	CamelOilOrderStatusCompleted:  "已完成",
	CamelOilOrderStatusFailed:     "已失败",
}

// CamelOilPayStatus 支付状态枚举
type CamelOilPayStatus int

const (
	CamelOilPaymentStatusUnpaid   CamelOilPayStatus = 0 // 未支付
	CamelOilPaymentStatusPaid     CamelOilPayStatus = 1 // 已支付
	CamelOilPaymentStatusRefunded CamelOilPayStatus = 2 // 已退款
	CamelOilPaymentStatusTimeout  CamelOilPayStatus = 3 // 已超时
)

// CamelOilPaymentStatusText 支付状态文本映射
var CamelOilPaymentStatusText = map[CamelOilPayStatus]string{
	CamelOilPaymentStatusUnpaid:   "未支付",
	CamelOilPaymentStatusPaid:     "已支付",
	CamelOilPaymentStatusRefunded: "已退款",
	CamelOilPaymentStatusTimeout:  "已超时",
}

// CamelOilNotifyStatus 回调状态枚举
type CamelOilNotifyStatus int

const (
	CamelOilCallbackStatusPending CamelOilNotifyStatus = 0 // 未回调
	CamelOilCallbackStatusSuccess CamelOilNotifyStatus = 1 // 回调成功
	CamelOilCallbackStatusFailed  CamelOilNotifyStatus = 2 // 回调失败
)

// CamelOilCallbackStatusText 回调状态文本映射
var CamelOilCallbackStatusText = map[CamelOilNotifyStatus]string{
	CamelOilCallbackStatusPending: "未回调",
	CamelOilCallbackStatusSuccess: "回调成功",
	CamelOilCallbackStatusFailed:  "回调失败",
}

// CamelOilTokenStatus Token管理状态枚举
type CamelOilTokenStatus int

const (
	CamelOilTokenStatusPendingVerification CamelOilTokenStatus = 0 // 待验证码
	CamelOilTokenStatusAvailable           CamelOilTokenStatus = 1 // 已登录/可用
	CamelOilTokenStatusDisabled            CamelOilTokenStatus = 2 // 已禁用
	CamelOilTokenStatusExpired             CamelOilTokenStatus = 3 // 已过期
	CamelOilTokenStatusLoginFailed         CamelOilTokenStatus = 4 // 登录失败
	CamelOilTokenStatusCodeSent            CamelOilTokenStatus = 5 // 验证码已发送
	CamelOilTokenStatusVerificationFailed  CamelOilTokenStatus = 6 // 验证码验证失败
)

// CamelOilTokenStatusText Token状态文本映射
var CamelOilTokenStatusText = map[CamelOilTokenStatus]string{
	CamelOilTokenStatusPendingVerification: "待验证码",
	CamelOilTokenStatusAvailable:           "已登录",
	CamelOilTokenStatusDisabled:            "已禁用",
	CamelOilTokenStatusExpired:             "已过期",
	CamelOilTokenStatusLoginFailed:         "登录失败",
	CamelOilTokenStatusCodeSent:            "验证码已发送",
	CamelOilTokenStatusVerificationFailed:  "验证码验证失败",
}

// ====================================================================================
// 变更类型常量定义
// ====================================================================================

// CamelOilAccountChangeType 账号变更类型
type CamelOilAccountChangeType string

const (
	CamelOilAccountChangeTypeCreate        CamelOilAccountChangeType = "create"         // 创建账号
	CamelOilAccountChangeTypeLogin         CamelOilAccountChangeType = "login"          // 登录成功
	CamelOilAccountChangeTypeOffline       CamelOilAccountChangeType = "offline"        // 检测到掉线
	CamelOilAccountChangeTypeLoginFail     CamelOilAccountChangeType = "login_fail"     // 登录失败
	CamelOilAccountChangeTypePause         CamelOilAccountChangeType = "pause"          // 订单数达到10，暂停使用
	CamelOilAccountChangeTypeResume        CamelOilAccountChangeType = "resume"         // 次日重置，恢复使用
	CamelOilAccountChangeTypeInvalidate    CamelOilAccountChangeType = "invalidate"     // 单日下单不足10个，账号失效
	CamelOilAccountChangeTypeOrderBind     CamelOilAccountChangeType = "order_bind"     // 绑定订单
	CamelOilAccountChangeTypeOrderComplete CamelOilAccountChangeType = "order_complete" // 订单完成
	CamelOilAccountChangeTypeUpdate        CamelOilAccountChangeType = "update"         // 更新账号信息
	CamelOilAccountChangeTypeDelete        CamelOilAccountChangeType = "delete"         // 删除账号
)

// CamelOilAccountChangeTypeText 账号变更类型文本映射
var CamelOilAccountChangeTypeText = map[CamelOilAccountChangeType]string{
	CamelOilAccountChangeTypeCreate:        "创建账号",
	CamelOilAccountChangeTypeLogin:         "登录成功",
	CamelOilAccountChangeTypeOffline:       "检测到掉线",
	CamelOilAccountChangeTypeLoginFail:     "登录失败",
	CamelOilAccountChangeTypePause:         "暂停使用",
	CamelOilAccountChangeTypeResume:        "恢复使用",
	CamelOilAccountChangeTypeInvalidate:    "账号失效",
	CamelOilAccountChangeTypeOrderBind:     "绑定订单",
	CamelOilAccountChangeTypeOrderComplete: "订单完成",
	CamelOilAccountChangeTypeUpdate:        "更新账号",
	CamelOilAccountChangeTypeDelete:        "删除账号",
}

// CamelOilOrderChangeType 订单变更类型
type CamelOilOrderChangeType string

const (
	CamelOilOrderChangeTypeCreate          CamelOilOrderChangeType = "create"           // 创建订单
	CamelOilOrderChangeTypeSubmit          CamelOilOrderChangeType = "submit"           // 提交到骆驼平台
	CamelOilOrderChangeTypeGetPayUrl       CamelOilOrderChangeType = "get_pay_url"      // 获取支付链接
	CamelOilOrderChangeTypeCheckPay        CamelOilOrderChangeType = "check_pay"        // 检测支付状态
	CamelOilOrderChangeTypePaid            CamelOilOrderChangeType = "paid"             // 支付成功
	CamelOilOrderChangeTypeTimeout         CamelOilOrderChangeType = "timeout"          // 支付超时
	CamelOilOrderChangeTypeFail            CamelOilOrderChangeType = "fail"             // 下单失败
	CamelOilOrderChangeTypeCallbackSuccess CamelOilOrderChangeType = "callback_success" // 回调商户成功
	CamelOilOrderChangeTypeCallbackFail    CamelOilOrderChangeType = "callback_fail"    // 回调商户失败
	CamelOilOrderChangeTypeFillCard        CamelOilOrderChangeType = "fill_card"        // 填写卡密和卡号
)

// CamelOilOrderChangeTypeText 订单变更类型文本映射
var CamelOilOrderChangeTypeText = map[CamelOilOrderChangeType]string{
	CamelOilOrderChangeTypeCreate:          "创建订单",
	CamelOilOrderChangeTypeSubmit:          "提交平台",
	CamelOilOrderChangeTypeGetPayUrl:       "获取支付链接",
	CamelOilOrderChangeTypeCheckPay:        "检测支付",
	CamelOilOrderChangeTypePaid:            "支付成功",
	CamelOilOrderChangeTypeTimeout:         "支付超时",
	CamelOilOrderChangeTypeFail:            "下单失败",
	CamelOilOrderChangeTypeCallbackSuccess: "回调成功",
	CamelOilOrderChangeTypeCallbackFail:    "回调失败",
	CamelOilOrderChangeTypeFillCard:        "填写卡密",
}

// ====================================================================================
// 预拉取订单相关常量定义
// ====================================================================================

// CamelOilPrefetchOrderStatus 预拉取订单状态枚举
type CamelOilPrefetchOrderStatus int

const (
	CamelOilPrefetchOrderStatusPending CamelOilPrefetchOrderStatus = 1 // 待匹配
	CamelOilPrefetchOrderStatusMatched CamelOilPrefetchOrderStatus = 2 // 已匹配
	CamelOilPrefetchOrderStatusExpired CamelOilPrefetchOrderStatus = 3 // 已过期
	CamelOilPrefetchOrderStatusInvalid CamelOilPrefetchOrderStatus = 4 // 已失效
)

// CamelOilPrefetchOrderStatusText 预拉取订单状态文本映射
var CamelOilPrefetchOrderStatusText = map[CamelOilPrefetchOrderStatus]string{
	CamelOilPrefetchOrderStatusPending: "待匹配",
	CamelOilPrefetchOrderStatusMatched: "已匹配",
	CamelOilPrefetchOrderStatusExpired: "已过期",
	CamelOilPrefetchOrderStatusInvalid: "已失效",
}

// CamelOilPrefetchOrderChangeType 预拉取订单变更类型
type CamelOilPrefetchOrderChangeType string

const (
	CamelOilPrefetchOrderChangeTypeCreate     CamelOilPrefetchOrderChangeType = "create"     // 创建预拉取订单
	CamelOilPrefetchOrderChangeTypeFetch      CamelOilPrefetchOrderChangeType = "fetch"      // 从骆驼平台拉取
	CamelOilPrefetchOrderChangeTypeMatch      CamelOilPrefetchOrderChangeType = "match"      // 与用户订单匹配
	CamelOilPrefetchOrderChangeTypeExpire     CamelOilPrefetchOrderChangeType = "expire"     // 过期失效
	CamelOilPrefetchOrderChangeTypeInvalidate CamelOilPrefetchOrderChangeType = "invalidate" // 标记为失效
)

// CamelOilPrefetchOrderChangeTypeText 预拉取订单变更类型文本映射
var CamelOilPrefetchOrderChangeTypeText = map[CamelOilPrefetchOrderChangeType]string{
	CamelOilPrefetchOrderChangeTypeCreate:     "创建预拉取订单",
	CamelOilPrefetchOrderChangeTypeFetch:      "从平台拉取",
	CamelOilPrefetchOrderChangeTypeMatch:      "与订单匹配",
	CamelOilPrefetchOrderChangeTypeExpire:     "订单过期",
	CamelOilPrefetchOrderChangeTypeInvalidate: "标记失效",
}

// ====================================================================================
// 预拉取订单业务配置常量
// ====================================================================================

const (
	// CamelOilPrefetchOrderExpireDuration 预拉取订单过期时间（小时）
	CamelOilPrefetchOrderExpireDuration = gtime.M * 5

	// CamelOilPrefetchOrderLockKey Redis中预拉取订单的分布式锁键名前缀
	CamelOilPrefetchOrderLockKey = "camel_oil_api:prefetch:order:lock:"

	// CamelOilPrefetchTaskLockKey Redis中预拉取任务的分布式锁键名
	CamelOilPrefetchTaskLockKey = "camel_oil_api:task:prefetch:lock"
)

// ====================================================================================
// 业务配置常量
// ====================================================================================

const (
	// CamelOilAccountDailyOrderLimit 账号每日订单上限
	CamelOilAccountDailyOrderLimit = 10

	// CamelOilOrderExpireDuration 订单支付超时时间（小时）
	CamelOilOrderExpireDuration = gtime.H

	// CamelOilMaxCallbackRetry 回调最大重试次数
	CamelOilMaxCallbackRetry = 5
)
