package commerce

import "context"

type TaskDefinition struct {
	Key           string
	Name          string
	Group         string
	Description   string
	ManualEnabled bool
	IntervalLabel string
}

type TaskExecutor interface {
	Definitions() []TaskDefinition
	Execute(ctx context.Context, taskKey string) (map[string]any, error)
}

func DefaultTaskDefinitions() []TaskDefinition {
	return []TaskDefinition{
		{Key: "provision", Name: "开通队列", Group: "资源", Description: "处理自动开通、上游提交和开通结果回填。", ManualEnabled: true, IntervalLabel: "按系统设置"},
		{Key: "settlement", Name: "代理结算释放", Group: "代理", Description: "扫描到期冻结奖励并释放代理及会员推广结算。", ManualEnabled: true, IntervalLabel: "按系统设置"},
		{Key: "upstream_actions", Name: "上游任务同步", Group: "资源", Description: "同步上游动作结果并执行成功落地或失败补偿。", ManualEnabled: true, IntervalLabel: "按系统设置"},
		{Key: "instance_lifecycle", Name: "实例生命周期", Group: "资源", Description: "处理自动续费、到期提醒、暂停和释放。", ManualEnabled: true, IntervalLabel: "每 10 分钟"},
		{Key: "agent_lifecycle_evaluate", Name: "代理自动考核", Group: "代理", Description: "滚动考核代理并处理观察期、降档和风控状态。", ManualEnabled: true, IntervalLabel: "每 60 分钟"},
		{Key: "zjmf_stock_sync", Name: "魔方财务库存同步", Group: "资源", Description: "同步已绑定魔方财务产品的上游库存。", ManualEnabled: true, IntervalLabel: "每 10 分钟"},
		{Key: "promotion_coupon_refund_expired", Name: "过期会员券退积分", Group: "优惠券", Description: "退还过期未使用会员券的剩余积分成本。", ManualEnabled: true, IntervalLabel: "每 60 分钟"},
		{Key: "promotion_coupon_notify_expiring", Name: "优惠券到期提醒", Group: "优惠券", Description: "通知即将在 24 小时内过期的已领取优惠券。", ManualEnabled: true, IntervalLabel: "每 60 分钟"},
		{Key: "verification_material_cleanup", Name: "实名材料清理", Group: "安全", Description: "清理超过保留期限的实名图片和敏感材料。", ManualEnabled: true, IntervalLabel: "每 60 分钟"},
		{Key: "instance_real_data_collect", Name: "实例实时数据采集", Group: "资源", Description: "采集实例监控数据并清理过期历史快照。", ManualEnabled: true, IntervalLabel: "每 5 分钟"},
		{Key: "recharge_maintenance", Name: "充值订单维护", Group: "财务", Description: "过期未支付充值单；支付结果仅通过已验签回调确认，不伪造主动对账。", ManualEnabled: true, IntervalLabel: "每 5 分钟"},
		{Key: "cloud_node_health", Name: "云节点健康检查", Group: "资源", Description: "检查云节点连通性并更新最近检查状态。", ManualEnabled: true, IntervalLabel: "每 5 分钟"},
	}
}
