package logisitics

import "git.oa00.com/go/jcook-sdk/api/rest"

// GetMethodRequest 获取物流方法.
type GetMethodRequest struct {
	CtpProtocol          rest.CtpProtocol     `json:"protocol"`
	ApiShipmentTypeParam ApiShipmentTypeParam `json:"apiShipmentTypeParam"`
}

type ApiShipmentTypeParam struct {
	Address     rest.Address `json:"address"`
	Pin         string       `json:"pin"`
	PaymentType uint         `json:"paymentType"`
	SkuList     []SkuInfo    `json:"skuList"`
}

func (o GetMethodRequest) GetApiName() string {
	return "jingdong.ctp.order.getShipmentType"
}

func (o GetMethodRequest) GetRespName() string {
	return "jingdong_ctp_order_getShipmentType_responce"
}

func (o GetMethodRequest) GetRespObj() interface{} {
	return GetMethodResponse{}
}

// GetMethodResponse 获取物流轨迹返回.
type GetMethodResponse struct {
	Result struct {
		Data    GetMethodParams `json:"data"`
		ErrCode uint            `json:"errCode"`
		ErrMsg  string          `json:"errMsg"`
		Success bool            `json:"success"`
	} `json:"result"`
}

type shipmentType uint

const (
	JdSelf shipmentType = iota + 1
	JdOther
	Third
	Normal
	NotSupport = 9
)

var shipmentTypeMap = map[shipmentType]string{
	JdSelf:     "京东配送",
	JdOther:    "京配转三方配送",
	Third:      "第三方配送",
	Normal:     "普通快递配送",
	NotSupport: "不支持配送",
}

func (o shipmentType) String() string {
	if value, ok := shipmentTypeMap[o]; !ok {
		return rest.UnKnow
	} else {
		return value
	}
}

type GetMethodParams struct {
	ShipmentType     shipmentType         `json:"shipmentType"`
	ShipmentInfoList []ShipmentInfoParams `json:"shipmentInfoList"`
}

type ShipmentInfoParams struct {
	SkuID          string               `json:"skuId"`
	ShipmentDetail ShipmentDetailParams `json:"shipmentDetail"`
}

type ShipmentDetailParams struct {
	ShipmentType   shipmentType `json:"shipmentType"`
	AttachmentList []Attachment `json:"attachmentList"`
	GiftList       []Gift       `json:"giftList"`
}

type Attachment struct {
	SkuID        string       `json:"skuId"`
	ShipmentType shipmentType `json:"shipmentType"`
}

type Gift struct {
	SkuID        string       `json:"skuId"`
	ShipmentType shipmentType `json:"shipmentType"`
}