package gd_management

type TGdMerchantDataApi struct {
	Id          uint64 `json:"id" description:""`
	MerchantId  uint64 `json:"merchant_id" description:""`
	DataApiId   uint64 `json:"data_api_id" description:""`
	Count       int    `json:"count" description:""`
	CountPerDay int    `json:"count_per_day" description:""`
	StartTime   string `json:"start_time" description:""`
	EndTime     string `json:"end_time" description:""`
	CreateTime  string `json:"create_time" description:""`
	UpdateTime  string `json:"update_time" description:""`
}

/*
type MerchantChildApiProvider struct {
	Id       uint64 `json:"id" description:""`
	DayCount int    `json:"day_count" description:""`
	Count    int    `json:"count" description:""`
	Enable   bool   `json:"enable" description:""`
}
*/
type TGdMerchantChildDataApi struct {
	Id                uint64 `json:"id" description:""`
	MerchantDataApiId uint64 `json:"merchant_data_api_id" description:""`
	ApiId             uint64 `json:"api_id" description:""`
	ProviderApis      string `json:"provider_apis" description:""`
	RequestParam      string `json:"request_param" description:""`
	ResponseParam     string `json:"response_param" description:""`
	CountType         bool   `json:"count_type" description:""`
	ForceUpdate       bool   `json:"force_update" description:""`
	IsCrypto          bool   `json:"is_crypto" description:""`
	IsEnable          bool   `json:"is_enable" description:""`
	CreateTime        string `json:"create_time" description:""`
	UpdateTime        string `json:"updated_time" description:""`
	Priority          int    `json:"priority" description:""`
	ReuseTime         int    `json:"reuse_time"`
}

//商户数据api列表
type ManagementGetMerchantDataApiListReq struct {
	MerchantId uint64 `json:"merchant_id" description:""`
	PageNumber int    `json:"page_number" description:""`
	IsAll      bool   `json:"is_all" description:"是否返回所有数据"`
}

type MerchantDataApiItem struct {
	MerchantDataApiId uint64 `json:"merchant_data_api_id" description:""`
	Name              string `json:"name" description:""`
	ComboType         int    `json:"combo_type" description:"套餐类型1 按总次数，2 按天"`
	QueryType         string `json:"query_type" description:""`
	TotalCount        int    `json:"total_count" description:""`
	RemainCount       int    `json:"remain_count" description:""`
	DayCount          int    `json:"day_count" description:""`
	DayRemainCount    int    `json:"day_remain_count" description:""`
	DayNumberCount    int    `json:"day_number_count" description:"天数上限"`
	DayNumberRemain   int    `json:"day_number_remain" description:"有效天数"`
	Status            string `json:"status"`
	UseTime           string `json:"use_time"`
}

type ManagementGetMerchantDataApiListReply struct {
	Total                int                   `json:"total" description:""`
	PageSize             int                   `json:"page_size" description:""`
	PageNumber           int                   `json:"page_number" description:""`
	MerchantDataApiItems []MerchantDataApiItem `json:"merchant_data_api_items"`
}

type MerchantDataApiModifiableTotal struct {
	CountThresholds       string `json:"count_thresholds"`
	TotalComboId          int64  `json:"total_combo_id" description:"按次套餐的id"`
	TotalComboCount       int64  `json:"total_combo_count" description:"按次套餐总次数"`
	DayTotalCount         int    `json:"day_total_count" description:"日即查量上限"`
	RemainDayTotalCount   int    `json:"remain_day_total_count" description:"日即查量余量"`
	IpWhitelist           string `json:"ip_whitelist"`
	IpWhitelistEnable     bool   `json:"ip_whitelist_enable"`
	CountThresholdsEnable bool   `json:"count_thresholds_enable"`
	TotalComboDayCount    int    `json:"total_combo_day_count"`
}

type MerchantDataApiModifiableDay struct {
	CountThresholds       string `json:"count_thresholds"`
	DayComboId            int64  `json:"day_combo_id" description:"按天套餐的id"`
	DayComboCount         int64  `json:"day_combo_count" description:"按天套餐总单天次数"`
	DayComboDays          int    `json:"day_combo_days" description:"按天套餐总天数"`
	DayThresholds         string `json:"day_thresholds"`
	CountThresholdsEnable bool   `json:"count_thresholds_enable"`
	DayTotalCount         int    `json:"day_total_count" description:"日即查量上限"`
	RemainDayTotalCount   int    `json:"remain_day_total_count" description:"日即查量余量"`
	EffectiveDay          int64  `json:"effective_day" description:"剩余有效天数"`
	IpWhitelist           string `json:"ip_whitelist"`
	IpWhitelistEnable     bool   `json:"ip_whitelist_enable"`
}

type MerchantDataApiModifiable struct {
	DayInfo   MerchantDataApiModifiableDay   `json:"day_info"`
	TotalInfo MerchantDataApiModifiableTotal `json:"total_info"`
}

type MerchantDataApiDayItem struct {
	MerchantDataApiId int64                     `json:"merchant_data_api_id" description:""`
	DataApiName       string                    `json:"data_api_name" description:""`
	QueryTypeName     string                    `json:"query_type_name" description:""`
	DayCount          int64                     `json:"day_count" description:"每天次数上限"`
	DayUsedCount      int64                     `json:"day_used_count" description:"当天调用次数"`
	DayRemainCount    int64                     `json:"day_remain_count" description:"当天剩余次数"`
	TotalDay          int64                     `json:"total_day" description:"总天数"`
	EffectiveDay      int64                     `json:"effective_day" description:"剩余有效天数"`
	StatusCode        int                       `json:"status_code" description:""`
	Status            string                    `json:"status"`
	IsFree            bool                      `json:"is_free"`
	UseTime           string                    `json:"use_time" description:""`
	Modifiable        MerchantDataApiModifiable `json:"modifiable"`
	Alias             string                    `json:"alias"`
}

type MerchantDataApiTotalItem struct {
	MerchantDataApiId int64                     `json:"merchant_data_api_id" description:""`
	DataApiName       string                    `json:"data_api_name" description:""`
	QueryTypeName     string                    `json:"query_type_name" description:""`
	TotalCount        int64                     `json:"total_count" description:"总次数"`
	UsedCount         int64                     `json:"used_count" description:"调用次数"`
	RemainCount       int64                     `json:"remain_count" description:"剩余次数"`
	StatusCode        int                       `json:"status_code" description:""`
	Status            string                    `json:"status"`
	IsFree            bool                      `json:"is_free"`
	UseTime           string                    `json:"use_time" description:""`
	DayCount          int64                     `json:"day_count" description:"单天调用上限"`
	Modifiable        MerchantDataApiModifiable `json:"modifiable"`
	Alias             string                    `json:"alias"`
}

type DayCount struct {
	Total                  int                      `json:"total" description:""`
	PageSize               int                      `json:"page_size" description:""`
	PageNumber             int                      `json:"page_number" description:""`
	MerchantDataApiDayItem []MerchantDataApiDayItem `json:"merchant_data_api_day_item"`
}
type TotalCount struct {
	Total                    int                        `json:"total" description:""`
	PageSize                 int                        `json:"page_size" description:""`
	PageNumber               int                        `json:"page_number" description:""`
	MerchantDataApiTotalItem []MerchantDataApiTotalItem `json:"merchant_data_api_total_item"`
}

type ManagementGetMerchantDataApiListByDayReq struct {
	MerchantId  int64  `json:"merchant_id" description:""`
	PageNumber  int    `json:"page_number" description:""`
	DataApiName string `json:"data_api_name" in:"query"`
	PageSize    int    `json:"page_size" in:"query"`
	IsAll       bool   `json:"is_all"`
}

type ManagementGetMerchantDataApiListByDayReply struct {
	DayCount
}

type ManagementGetMerchantDataApiListByTotalReq struct {
	MerchantId  int64  `json:"merchant_id" description:""`
	PageNumber  int    `json:"page_number" description:""`
	DataApiName string `json:"data_api_name" in:"query"`
	PageSize    int    `json:"page_size"`
	IsAll       bool   `json:"is_all"`
}

type ManagementGetMerchantDataApiListByTotalReply struct {
	TotalCount
}

//商户基础api操作
/*type MerchantBaseApiParam struct {
	Name     string `json:"name" description:""`
	Mean     string `json:"mean" description:"参数含义"`
	Required bool   `json:"required" description:"是否必选"`
	Type     string `json:"type" description:""`
	In       string `json:"in" description:"body 或query"`
}*/

type MerchantBaseApi struct {
	Name          string                   `json:"name" description:""`
	BaseApiId     uint64                   `json:"base_api_id" description:""`
	Priority      int                      `json:"priority" description:""`
	RequestParam  []ManagementBaseApiParam `json:"request_param" description:""`
	ResponseParam []ManagementBaseApiParam `json:"response_param" description:""`
}

type MerchantApiProviderRelation struct {
	Id                 int64 `json:"-"`
	MerchantChildApiId int64 `json:"-"`
	ProviderApiId      int64 `json:"provider_api_id"`
	Enable             bool  `json:"enable"`
	DayCount           int64 `json:"day_count"`
	GroupNo            int   `json:"group_no"`
}

/*type MerchantBaseApiItem struct {
	MerchantChildApiId uint64                        `json:"merchant_child_api_id" description:"商户的某数据api的某子api的id"`
	IsCrypto           bool                          `json:"is_crypto" description:""`
	CountType          byte                          `json:"count_type" description:""`
	ForceUpdate        bool                          `json:"force_update" description:"是否开启强更，若开启每次都调数据源"`
	ProviderApiLimit   []MerchantApiProviderRelation `json:"provider_api_limit"`
	ApiName            string                        `json:"api_name" description:""`
	ApiId              int64                         `json:"api_id" description:""`
	RequestParam       []MerchantBaseApiParam        `json:"request_param" description:""`
	ResponseParam      []MerchantBaseApiParam        `json:"response_param" description:""`
}
*/
type ManagementMerchantBaseApiItem struct {
	MerchantChildApiId   uint64 `json:"merchant_child_api_id" description:"商户的某数据api的某子api的id"`
	MerchantChildApiName string `json:"merchant_child_api_name" description""`
	Router               string `json:"router"`
}

//获取商户数据api对应的基础api列表
type ManagementGetMerchantBaseApiListReq struct {
	MerchantDataApiId uint64 `json:"merchant_data_api_id" description:""`
}

type ManagementGetMerchantBaseApiListReply struct {
	ManagementMerchantBaseApiList []ManagementMerchantBaseApiItem `json:"merchant_base_api_list"`
}

type ManagementGetMerchantBaseApiInfoReq struct {
	MerchantChildApiId uint64 `json:"merchant_child_api_id" description:"商户的某数据api的某子api的id"`
}

type MerchantProviderApi struct {
	ProviderApiId    int64  `json:"provider_api_id"`
	Priority         int    `json:"priority" description:"优先级"`
	ThirdpartApiName string `json:"thirdpart_api_name" description:"数据源接口名称"`
	PlatformName     string `json:"platform_name" description:"数据源平台名称"`
	Enable           bool   `json:"enable"`
	DayCount         int64  `json:"day_count"`
}

type MerchantProviderGroup struct {
	GroupNo                 int                   `json:"group_no"`
	GroupName               string                `json:"group_name"`
	MerchantProviderApiList []MerchantProviderApi `json:"merchant_provider_api_list"`
}

type ManagementGetMerchantBaseApiInfoReply struct {
	MerchantChildApiId        int64                    `json:"merchant_child_api_id" description:"商户的某数据api的某子api的id"`
	IsCrypto                  bool                     `json:"is_crypto" description:""`
	CountType                 int                      `json:"count_type" description:""`
	ForceUpdate               bool                     `json:"force_update" description:"是否开启强更，若开启每次都调数据源"`
	MerchantProviderGroupList []MerchantProviderGroup  `json:"merchant_provider_group_list"`
	ApiName                   string                   `json:"api_name" description:""`
	ApiRouter                 string                   `json:"api_router"`
	RequestParam              []ManagementBaseApiParam `json:"request_param" description:""`
	ResponseParam             []ManagementBaseApiParam `json:"response_param" description:""`
	CountCode                 string                   `json:"count_code" description:"当计数类型为查得时，错误码"`
	ReuseTime                 int                      `json:"reuse_time"`
	Timeout                   int                      `json:"timeout"`
	IpWhitelist               string                   `json:"ip_whitelist"`
	Filters                   []BaseApiParamFilter     `json:"filters"`
	MinimalTimeConsuming      int                      `json:"minimal_time_consuming" description:"最小耗时"`
	RandomPercentage          int                      `json:"random_percentage" description:"随机百分比"`
	IsRawErrorCode            int                      `json:"is_raw_error_code" description:"是否原始错误码"`
	RateLimit                 int                      `json:"rate_limit" description:"并发限制"`
}

//在商户数据api中添加基础api
type ManagementAddMerchantBaseApiReq struct {
	MerchantDataApiId uint64   `json:"merchant_data_api_id" description:""`
	BaseApiIds        []uint64 `json:"base_api_ids" description:""`
}

type ManagementAddMerchantBaseApiReply struct {
	//MerchantChildApiId uint64 `json:"merchant_child_api_id" description:""`
}

//在商户数据api中删除基础api
type ManagementDelMerchantBaseApiReq struct {
	MerchantChildApiId uint64 `json:"merchant_child_api_id" description:""`
}

type ManagementDelMerchantBaseApiReply struct {
}

//更新商户数据api中某基础api信息
type ManagementUpdateMerchantBaseApiReq struct {
	MerchantChildApiId int64 `json:"merchant_child_api_id" description:"商户的某数据api的某子api的id"`
	IsCrypto           bool  `json:"is_crypto" description:""`
	CountType          int   `json:"count_type" description:""`
	ForceUpdate        bool  `json:"force_update" description:"是否开启强更，若开启每次都调数据源"`
	//ProviderApiLimit   []MerchantApiProviderRelation `json:"provider_api_limit"`

	MerchantProviderGroupList []MerchantProviderGroup  `json:"merchant_provider_group_list"`
	RequestParam              []ManagementBaseApiParam `json:"request_param" description:""`
	ResponseParam             []ManagementBaseApiParam `json:"response_param" description:""`
	CountCode                 string                   `json:"count_code" description:"当计数类型为查得时，错误码"`
	ReuseTime                 int                      `json:"reuse_time"`
	Timeout                   int                      `json:"timeout"`
	IpWhitelist               string                   `json:"ip_whitelist"`
	Filters                   []BaseApiParamFilter     `json:"filters"`
	MinimalTimeConsuming      int                      `json:"minimal_time_consuming" description:"最小耗时"`
	RandomPercentage          int                      `json:"random_percentage" description:"随机百分比"`
	IsRawErrorCode            int                      `json:"is_raw_error_code" description:"是否原始错误码"`
	RateLimit                 int                      `json:"rate_limit" description:"并发限制"`
}

type ManagementUpdateMerchantBaseApiReply struct {
}

//设置商户数据api中基础api优先级
type ManagementSetMerchantBaseApiPriorityReq struct {
	MerchantChildApiIds []uint64 `json:"merchant_child_api_ids" description:"按优先级排好序的id"`
}

type ManagementSetMerchantBaseApiPriorityReply struct {
}

//修改商户数据api配额
type ManagementSetMerchantDataApiQuotaReq struct {
	MerchantDataApiId uint64 `json:"merchant_data_api_id" description:""`
	DayCount          int    `json:"day_count" description:"日调用量上限"`
	Count             int    `json:"count" description:"总调用上限"`
	DayNumber         int    `json:"day_number" description:"剩余有效天数"`
}

type ManagementSetMerchantDataApiQuotaReply struct {
}

type ManagementGetMerchantDataApiQuotaReq struct {
	MerchantDataApiId int64 `json:"merchant_data_api_id" description:""`
}

type ManagementGetMerchantDataApiQuotaReply struct {
	DayCount  int `json:"day_count" description:"日调用量上限"`
	Count     int `json:"count" description:"总调用上限"`
	DayNumber int `json:"day_number" description:"剩余有效天数"`
	Type      int `json:"type" description:"1 按总次数， 2按天"`
}

type ManagementAddMerchantDataApiReq struct {
	MerchantId     uint64 `json:"merchant_id" description:""`
	QueryTypeId    uint64 `json:"query_type_id"`
	DataApiComboId uint64 `json:"combo_id" description:""`
}

type ManagementAddMerchantDataApiReply struct {
}

type ManagementConvertMerchantDataApiReq struct {
	MerchantDataApiId int64 `json:"merchant_data_api_id"`
}

type ParamStruct struct {
	StructName string                   `json:"struct_name"`
	Params     []ManagementBaseApiParam `json:"params"`
}

type ErrorCode struct {
	Code string `json:"code"`
	Msg  string `json:"msg"`
}

type ApiParamStructInfo struct {
	ApiName        string        `json:"api_name"`
	ApiCode        string        `json:"api_code"`
	ApiMethod      string        `json:"api_method"`
	ApiRouter      string        `json:"api_router"`
	IsCrypto       bool          `json:"is_crypto"`
	Comment        string        `json:"comment"`
	RequestParams  []ParamStruct `json:"request_params"`
	ResponseParams []ParamStruct `json:"response_params"`
	ErrorList      []ErrorCode   `json:"error_list"`
	JsonExample    string        `json:"json_example"`
}

type ManagementConvertMerchantDataApiReply struct {
	DataApiName string               `json:"data_api_name"`
	Apis        []ApiParamStructInfo `json:"apis"`
}

type GetMerchantDataApiQuotaReq struct {
	Id int64 `json:"id"`
}

type GetMerchantDataApiQuotaReply struct {
	MerchantId  int64 `json:"merchant_id" description:""`
	QueryTypeId int64 `json:"data_api_id" description:""`
	Count       int   `json:"count" description:""`
	CountPerDay int   `json:"count_per_day" description:""`
	StartTime   int64 `json:"start_time" description:""`
	EndTime     int64 `json:"end_time" description:""`
	ComboType   int   `json:"combo_type"`
	State       int   `json:"state"`
}

type ManagementDelMerchantDataApiReq struct {
	MerchantDataApiId int64 `json:"merchant_data_api_id"`
}

type ManagementDelMerchantDataApiReply struct {
}

type ManagementMerchantBaseApiAllInfo struct {
	ApiId         int64                    `json:"api_id"`
	DataApiName   string                   `json:"data_api_name"`
	Name          string                   `json:"name" description:"基础api名"`
	Method        string                   `json:"method" description:"方法，GET POST等"`
	Router        string                   `json:"router" description:"路由"`
	RequestParam  []ManagementBaseApiParam `json:"request_param" description:"请求参数"`
	ResponseParam []ManagementBaseApiParam `json:"response_param" description:"响应参数"`
	IsCrypto      bool                     `json:"is_crypto"`
}

type ManagementGetMerchantBaseApiListAllReq struct {
	MerchantId  int64 `json:"merchant_id"`
	OnlyBaseApi bool  `json:"only_base_api"`
}
type ManagementGetMerchantBaseApiListAllReply struct {
	ManagementMerchantBaseApiList []ManagementMerchantBaseApiAllInfo `json:"merchant_base_api_list"`
}

//修改商户数据api每日调用上限
type ManagementSetDayCountLimitReq struct {
	MerchantDataApiId int64 `json:"merchant_data_api_id" description:""`
	DayCount          int   `json:"day_count" description:"日调用量上限"`
	DayTotalCount     int   `json:"day_total_count" description:"日即查量上限"`
}

type ManagementSetDayCountLimitReply struct {
}

type UpdateMerchantDataApiReq struct {
	MerchantDataApiId     int64  `json:"merchant_data_api_id" description:""`
	DayCount              int    `json:"day_count" description:"日调用量上限"`
	Count                 int    `json:"count" description:"总调用上限"`
	DayNumber             int    `json:"day_number" description:"剩余有效天数"`
	CountThresholds       string `json:"count_thresholds"`
	DayThresholds         string `json:"day_thresholds"`
	ComboId               int64  `json:"combo_id"`
	IpWhitelist           string `json:"ip_whitelist"`
	IpWhitelistEnable     bool   `json:"ip_whitelist_enable"`
	CountThresholdsEnable bool   `json:"count_thresholds_enable"`
	DayTotalCount         int    `json:"day_total_count"`
	TotalComboDayCount    int    `json:"total_combo_day_count"`
}

type UpdateMerchantDataApiReply struct {
}
