package v1

import (
	"kami/internal/consts"

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

// ====================================================================================
// History API
// ====================================================================================

type JdCookieHistoryApi struct {
	CookieHistoryReq *CookieHistoryReq `path:"/jd-cookie/history/cookie" method:"get" summary:"Cookie Change History" tags:"JD History"`
	OrderHistoryReq  *OrderHistoryReq  `path:"/jd-cookie/history/order" method:"get" summary:"Order Change History" tags:"JD History"`
}

// ====================================================================================
// History Request/Response Structures
// ====================================================================================

// CookieHistoryReq Cookie Change History Request
type CookieHistoryReq struct {
	g.Meta     `path:"/jd-cookie/history/cookie" method:"get" summary:"Cookie Change History" tags:"JD History"`
	CookieId   string                  `json:"cookieId" v:"required#Cookie ID不能为空" dc:"Cookie ID"`
	Page       int                     `json:"page" d:"1" dc:"页码"`
	Size       int                     `json:"size" d:"20" dc:"每页大小"`
	ChangeType consts.CookieChangeType `json:"changeType" dc:"变更类型筛选"`
}

type CookieHistoryRes struct {
	g.Meta `mime:"application/json"`
	List   []*CookieHistoryInfo `json:"list" dc:"变更历史列表"`
	Total  int                  `json:"total" dc:"总数"`
}

type CookieHistoryInfo struct {
	HistoryUuid  string                  `json:"historyUuid" dc:"历史记录唯一标识"`
	CookieId     string                  `json:"cookieId" dc:"Cookie ID"`
	ChangeType   consts.CookieChangeType `json:"changeType" dc:"变更类型"`
	StatusBefore consts.JdCookieStatus   `json:"statusBefore" dc:"变更前状态"`
	StatusAfter  consts.JdCookieStatus   `json:"statusAfter" dc:"变更后状态"`
	OrderId      string                  `json:"orderId" dc:"关联的订单号"`
	UserOrderId  string                  `json:"userOrderId" dc:"用户订单号"`
	FailureCount int                     `json:"failureCount" dc:"失败次数"`
	Remark       string                  `json:"remark" dc:"备注信息"`
	CreatedAt    *gtime.Time             `json:"createdAt" dc:"创建时间"`
}

// OrderHistoryReq Order Change History Request
type OrderHistoryReq struct {
	g.Meta  `path:"/jd-cookie/history/order" method:"get" summary:"Order Change History" tags:"JD History"`
	OrderId string `json:"orderId" v:"required#订单号不能为空" dc:"订单号"`
	Page    int    `json:"page" d:"1" dc:"页码"`
	Size    int    `json:"size" d:"20" dc:"每页大小"`
}

type OrderHistoryRes struct {
	g.Meta `mime:"application/json"`
	List   []*OrderHistoryInfo `json:"list" dc:"变更历史列表"`
	Total  int                 `json:"total" dc:"总数"`
}

type OrderHistoryInfo struct {
	HistoryUuid string                 `json:"historyUuid" dc:"历史记录唯一标识"`
	OrderId     string                 `json:"orderId" dc:"订单号"`
	ChangeType  consts.OrderChangeType `json:"changeType" dc:"变更类型"`
	JdOrderId   string                 `json:"jdOrderId" dc:"关联的京东订单号"`
	WxPayUrl    string                 `json:"wxPayUrl" dc:"微信支付链接"`
	Remark      string                 `json:"remark" dc:"备注信息"`
	CreatedAt   *gtime.Time            `json:"createdAt" dc:"创建时间"`
}
