package v1

import (
	"kami/api/commonApi"
	"kami/internal/consts"
	"kami/internal/model/entity"

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

type TMallGameOrderRecord struct {
	Status             string                               `json:"status" description:"状态"`
	AccountNumber      string                               `json:"accountNumber" description:"账号编号"`
	OrderNo            string                               `json:"orderNo" description:"订单号"`
	MerchantOrder      string                               `json:"merchantOrder" description:"商户订单号"`
	ThirdMerchantOrder string                               `json:"thirdMerchantOrder" description:"充值账号"`
	TMallShopOrder     string                               `json:"tMallShopOrder" description:"天猫店铺订单号"`
	DateRange          []*gtime.Time                        `json:"dateRange" description:"时间范围"`
	CallBackType       consts.RechargeTMallGameCallBackType `json:"callbackType" description:"回调类型"`
}

type TMallGameOrderListReq struct {
	g.Meta `path:"/recharge/tMallGame/order/list" tags:"天猫游戏订单" method:"get" summary:"获取游戏订单列表"`
	TMallGameOrderRecord
	commonApi.CommonPageReq
}

type TMAllListRecord struct {
	entity.V1RechargeTMallOrder
	AccountInfo struct {
		g.Meta        `orm:"table:recharge_t_mall_game_account"`
		AccountNumber string `json:"accountNumber" orm:"account_number"`
		Id            string `json:"id" orm:"id"`
	} `json:"accountInfo"   orm:"with:id=account_id"`
	ShopInfo struct {
		g.Meta       `orm:"table:recharge_t_mall_shop"`
		OrderNo      string      `json:"orderNo" orm:"order_no"`
		TMallOrderNo string      `json:"tMallOrderNo" orm:"t_mall_order_no"`
		EndTime      *gtime.Time `json:"endTime" orm:"end_time"`
	} `json:"shopInfo"   orm:"with:order_no=order_no"`
}

type TMallGameOrderListRes struct {
	commonApi.CommonPageRes[TMAllListRecord]
}

type TMallGameOrderSubmitReq struct {
	g.Meta             `path:"/recharge/tMallGame/order/submit" tags:"天猫游戏订单" method:"post" summary:"提交订单"`
	AccountNumber      string                               `json:"accountNumber" description:"账户"`
	Amount             float64                              `json:"amount" description:"提交金额"`
	MerchantOrder      string                               `json:"merchantOrder" description:"第三方订单号"`
	ThirdMerchantOrder string                               `json:"thirdMerchantOrder" dc:"充值账号"`
	CallbackUrl        string                               `json:"callbackUrl"  description:"回调地址"`
	CallbackType       consts.RechargeTMallGameCallBackType `json:"callbackType" description:"回调类型 confirm 确认收货回调 evaluation 评价回调"`
	Attach             string                               `json:"attach"  description:"附加信息，附加信息会原封不动返回"`
	TimeStamp          int                                  `json:"timeStamp"  description:"时间戳"`
	Sign               string                               `json:"sign"  description:"签名"`
	ChannelName        string                               `json:"channelName" description:"渠道名称"`
}

type TMallGameOrderSubmitRes struct {
	OrderNo string                         `json:"orderNo" description:"订单ID"`
	Status  consts.TMallGameCallbackStatus `json:"status" description:"充值返回编码"`
	Message string                         `json:"message" description:"详细描述信息"`
}

// TMallGameOrderModifyStatusSucceedReq 手动将正确设置(纠正)为正确
type TMallGameOrderModifyStatusSucceedReq struct {
	g.Meta   `path:"/recharge/tMallGame/order/modifyStatusSucceed" tags:"天猫游戏订单" method:"post" summary:"手动将正确设置(纠正)为正确"`
	TotpCode string `json:"totpCode" description:"TOTP"`
	OrderNo  string `json:"orderNo" description:"订单ID" v:"required#订单号不能为空"`
}

type TMallGameOrderModifyStatusSucceedRes struct {
}
