package afterSale_applyMarketAfterSale_request

import (
	"encoding/json"
	afterSale_applyMarketAfterSale_respone "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/afterSale_ApplyMarketAfterSale/response"
	doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
)

type AfterSaleApplyMarketAfterSaleRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *AfterSaleApplyMarketAfterSaleParam
}

func (c *AfterSaleApplyMarketAfterSaleRequest) GetUrlPath() string {
	return "/afterSale/ApplyMarketAfterSale"
}

func New() *AfterSaleApplyMarketAfterSaleRequest {
	request := &AfterSaleApplyMarketAfterSaleRequest{
		Param: &AfterSaleApplyMarketAfterSaleParam{},
	}
	request.SetConfig(doudian_sdk.GlobalConfig)
	request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
	return request

}

func (c *AfterSaleApplyMarketAfterSaleRequest) Execute(accessToken *doudian_sdk.AccessToken) (*afterSale_applyMarketAfterSale_respone.ApplyMarketAfterSaleResponse, error) {
	responseJson, err := c.GetClient().Request(c, accessToken)
	if err != nil {
		return nil, err
	}
	response := &afterSale_applyMarketAfterSale_respone.ApplyMarketAfterSaleResponse{}
	_ = json.Unmarshal([]byte(responseJson), response)
	return response, nil

}

func (c *AfterSaleApplyMarketAfterSaleRequest) GetParamObject() interface{} {
	return c.Param
}

func (c *AfterSaleApplyMarketAfterSaleRequest) GetParams() *AfterSaleApplyMarketAfterSaleParam {
	return c.Param
}

type AfterSaleApplyMarketAfterSaleParam struct {
	// 订单id
	SkuOrderId int64 `json:"sku_order_id"`
	// 缺重克数，非缺重场景不传；单位 毫克
	MissGram int `json:"miss_gram"`
	// 退款金额，单位分。 只缺重有效，缺货/拒签场景由系统计费算出。 最多不会超过订单金额
	RefundAmount int64 `json:"refund_amount"`
	// 退款金额如果传了，就按传的金额退；不传由平台根据件数来分摊计算（特别注只有整单退才会退运费，否则运费不退；缺货暂时不支持按件数退，只能整单退；）
	ItemCount int64 `json:"item_count"`
	// 售后原因枚举 MissGram = 1缺重，必传克数、金额； MissItem = 2缺货，只支持整单退； RefuseSign = 3 拒收，支持按件数退，必传件数，金额由抖音计算
	AfterSaleReason int32 `json:"after_sale_reason"`
	// 门店ID，传了就做检验，不传默认通过，由isv自行保证权限
	StoreId int64 `json:"store_id"`
}
