package v1

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

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

type GroupRecord struct {
	Name  string `json:"name" description:"分组名称"  v:"required#分组名称不能为空"`
	Notes string `json:"notes" description:"备注"`
}

type GroupAddReq struct {
	g.Meta `path:"/cardInfo/walmart/group/add" tags:"沃尔玛充值卡账户" method:"post" summary:"添加沃尔玛账户分组"`
	GroupRecord
}

type GroupAddRes struct {
}

type GroupUpdateReq struct {
	g.Meta `path:"/cardInfo/walmart/group/update" tags:"沃尔玛充值卡账户" method:"put" summary:"修改沃尔玛账户分组"`
	commonApi.CommonIntId
	GroupRecord
}

type GroupUpdateRes struct {
}

type GroupListReq struct {
	g.Meta `path:"/cardInfo/walmart/group/list" tags:"沃尔玛充值卡账户" method:"get" summary:"获取沃尔玛账户分组"`
	commonApi.CommonPageReq
	UserId string `json:"userId" description:"用户ID"`
	Name   string `json:"name" description:"分组名称"`
}

type GroupListRes struct {
	commonApi.CommonPageRes[*entity.V1CardRedeemAccountGroup]
}

type GroupDeleteReq struct {
	g.Meta `path:"/cardInfo/walmart/group/delete" tags:"沃尔玛充值卡账户" method:"delete" summary:"修改沃尔玛账户分组"`
	commonApi.CommonIntId
}

type GroupDeleteRes struct {
}

type GroupAllListReq struct {
	g.Meta `path:"/cardInfo/walmart/group/allList" tags:"沃尔玛充值卡账户" method:"get" summary:"获取所有沃尔玛账户分组"`
	UserId string `json:"userId" description:"用户ID"`
}

// GroupAllListRes 获取所有分组
type GroupAllListRes struct {
	commonApi.CommonPageRes[*entity.V1CardRedeemAccountGroup]
}

// 分组统计
type GroupStatReq struct {
	g.Meta `path:"/cardInfo/walmart/group/stat" tags:"沃尔玛充值卡账户" method:"get" summary:"分组统计"`
	commonApi.CommonPageReq
	Name     string      `json:"name" description:"分组名称"`
	Username string      `json:"username" description:"用户名"`
	Date     *gtime.Time `json:"date" description:"日期"`
	UserId   string      `json:"userId" description:"用户ID"`
}

type V1CardRedeemAccountGroupStatsEntity struct {
	OrderDate       string  `orm:"order_date" json:"orderDate"`
	GroupId         int     `orm:"group_id" json:"groupId"`
	GroupName       string  `orm:"group_name" json:"groupName"`
	Count           int     `orm:"count" json:"count"`
	Sum             float64 `orm:"sum" json:"sum"`
	CreatedUserId   string  `orm:"group_created_user_id" json:"createdUserId"`
	CreatedUserName string  `orm:"username" json:"createdUserName"`
}

type V1CardRedeemAccountGroupEntityAccount struct {
	Total    int `json:"total"`
	Normal   int `json:"normal"`
	UnNormal int `json:"unNormal"`
	Deleted  int `json:"deleted"`
}

type V1CardRedeemAccountGroupEntity struct {
	*V1CardRedeemAccountGroupStatsEntity
	Account *V1CardRedeemAccountGroupEntityAccount `json:"account"`
}

type GroupStatRes struct {
	commonApi.CommonPageRes[*V1CardRedeemAccountGroupEntity]
}

// 导出
type GroupExportReq struct {
	g.Meta `path:"/cardInfo/walmart/group/export" tags:"沃尔玛充值卡账户" method:"get" summary:"导出账户分组" produces:"application/octet-stream"`
	commonApi.CommonPageReq
	Username string      `json:"username" description:"用户名"`
	Date     *gtime.Time `json:"date" description:"日期"`
	UserId   string      `json:"userId" description:"用户ID"`
	Name     string      `json:"name" description:"分组名称"`
}

type GroupExportRes struct {
	g.Meta `mime:"application/vnd.ms-excel"`
}
