package model

import (
	v1 "kami/api/card_info_walmart/v1"
	"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 RedeemAccountGroup struct {
	*v1.GroupRecord
	CreatedUserId string
	Category      consts.CardRedeemAccountCategory
}

type RedeemAccountGroupList struct {
	*v1.GroupListReq
	CreatedUserId string
	Category      consts.CardRedeemAccountCategory
}

type RedeemAccountGroupStatsInput struct {
	CreatedUserId string
	Category      consts.CardRedeemAccountCategory
	*v1.GroupStatReq
}

type RedeemAccountGroupStatsOutput struct {
	*v1.V1CardRedeemAccountGroupEntity
}

type RedeemAccountGroupAll struct {
	CreatedUserId string
	Category      consts.CardRedeemAccountCategory
	GroupIds      []int
}

type RedeemAccountAddHistory struct {
	AccountId        string
	AccountName      string
	OrderNo          string
	Remark           string
	Cookie           string
	Amount           float64
	Balance          float64
	EffectiveBalance float64
	Category         consts.CardRedeemAccountCategory
	OperationStatus  consts.RedeemAccountOperationStatus
}

type RedeemAccountAddInput struct {
	Cookie         string
	Name           string
	MaxAmountLimit int
	MaxCountLimit  int
	Status         int
	Remark         string
	UserId         string
	Username       string
	Nickname       string
	Balance        float64
	GroupId        int
	Category       consts.CardRedeemAccountCategory
}

type RedeemAccountUpdateInput struct {
	commonApi.CommonStrId
	Cookie         string `json:"cookie" description:"cookie不能为空"`
	Status         int    `json:"status" description:"状态"`
	Name           string `json:"name" description:"别名"`
	Remark         string `json:"remark" description:"备注"`
	GroupId        int
	MaxAmountLimit int `json:"maxAmountLimit" description:"最大充值限制"`
	MaxCountLimit  int `json:"maxCountLimit" description:"最大充值次数"`
}

type RedeemAccountOutput struct {
	g.Meta `orm:"table:card_redeem_account_info"`
	entity.V1CardRedeemAccountInfo
	UploadUser V1SysUserRecord `json:"UploadUser"   orm:"with:id=create_user_id"`
}

type RedeemAccountListInput struct {
	commonApi.CommonPageReq
	Name            string `json:"name" description:"账户名称"`
	NickName        string `json:"nickName" description:"用户昵称"`
	Cookie          string `json:"cookie"`
	UserId          string
	CreatedUserName string `json:"createdUserName" description:"创建用户昵称"`
	Category        consts.CardRedeemAccountCategory
	GroupId         int64
}

type RedeemAccountQueryInput struct {
	NickName string `json:"accountNickName" dc:"账户昵称"`
	Name     string `json:"accountName" description:"账户名称"`
	Ck       string `json:"accountCk" description:"账户cookie"`
	GroupId  int64
}

type RedeemOrderAddDeductionRecordInput struct {
	OrderNo   string
	Balance   float64
	AccountId string
	Status    consts.DeductionStatus
}

type RedeemAccountReductionSucceed struct {
	OrderNo   string
	AccountId string
	Category  consts.CardRedeemAccountCategory
	Amount    float64
	Remark    string
}

type RedeemAccountHistoryQueryInput struct {
	commonApi.CommonPageReq
	AccountId string `json:"accountId" v:"required#缺失ID"`
}

type RedeemCardOrderAddHistory struct {
	AccountNickname string
	AccountUsername string
	AccountId       string
	AccountName     string
	CardAmount      float64
	Amount          float64
	OrderNo         string
	Remark          string
	ResponseRawData string
	OperationStatus consts.RedeemOrderOperationStatus
}

type RedeemCardSubmitInput struct {
	CardNo      string  `json:"cardNo" description:"卡号"`
	GiftCardPwd string  `json:"giftCardPwd" v:"required#苹果充值卡不能为空" description:"礼品卡密码"`
	NotifyUrl   string  `json:"notifyUrl" v:"required#回调地址不能为空" description:"回调地址"`
	Amount      float64 `json:"amount" v:"required#充值金额不能为空" description:"充值金额"`
	MerchantId  string  `json:"merchantId" v:"required#商户ID不能为空" description:"商户ID"`
	Attach      string  `json:"attach" description:"附加信息"`
	Category    consts.CardRedeemAccountCategory
}

type RedeemCardListInput struct {
	commonApi.CommonPageReq
	GroupId         int64
	GiftCardPwd     string `json:"giftCardPwd" description:"礼品卡密码"`
	MerchantId      string `json:"merchantId" description:"商户ID"`
	Attach          string `json:"attach" description:"附加信息"`
	AccountNickName string `json:"accountNickName" dc:"账户昵称"`
	AccountCk       string `json:"accountCk" description:"账户cookie"`
	UserId          string
	Category        consts.CardRedeemAccountCategory
	DateRange       []*gtime.Time `json:"dateRange" description:"时间范围"`
}

type RedeemCardSummaryOutput struct {
	Count            int                              `orm:"count" json:"count"`
	AmountTotalCount int                              `orm:"amount_total_count" json:"amountTotalCount"`
	AmountTotalSum   float64                          `orm:"amount_total_sum" json:"amountTotalSum"`
	Amount           float64                          `orm:"amount" json:"amount"`
	AccountId        string                           `orm:"account_id" json:"accountId"`
	Date             *gtime.Time                      `orm:"date" json:"date"`
	Name             string                           `orm:"name" json:"name"`
	Category         consts.CardRedeemAccountCategory `orm:"category" json:"category"`
}

type RedeemCardSummaryWithOutAccountOutput struct {
	Rate     float64                          `orm:"rate" json:"rate"`
	Count    int                              `orm:"count" json:"count"`
	Amount   float64                          `orm:"amount" json:"amount"`
	Date     *gtime.Time                      `orm:"date" json:"date"`
	Category consts.CardRedeemAccountCategory `orm:"category" json:"category"`
}

type AccountDailySummaryGetInput struct {
	*v1.AccountDailySummaryReq
	CreatedUserId string
	Category      consts.CardRedeemAccountCategory
}

type AccountDailySummaryGetOutput struct {
	*v1.CardRedeemAccountSummary
}

type RedeemCardOrderOutput struct {
	*v1.ListOutput
}

type RedeemAccountGroupStatsOverviewReq struct {
	GroupId   int64
	AccountId string
	UserId    string
	Category  consts.CardRedeemAccountCategory
	DateRange []*gtime.Time `json:"dateRange" description:"时间范围"`
}

type RedeemAccountGroupStatsOverviewRes struct {
	TotalActiveAccountCount int     `json:"totalActiveAccountCount"`
	TotalAccountCount       int     `json:"totalAccountCount"`
	TotalOrderAmount        float64 `json:"totalOrderAmount"`
	TotalOrderAmountSuccess float64 `json:"totalOrderAmountSuccess"`
	TotalOrderCount         int     `json:"totalOrderCount"`
	TotalOrderCountSuccess  int     `json:"totalOrderCountSuccess"`
}
