package channel import ( "context" "git.oa00.com/supply-chain/service/client" "github.com/shopspring/decimal" "github.com/smallnest/rpcx/share" ) const ( ReplyOrderFreightFeeErrCodeNone = 0 // 无错误 ReplyOrderFreightFeeErrCodeErr = 1 // 有错误 ) type order struct { } type ArgsOrderFreightFee struct { Address string // 地址 Skus []SkuFreightFeeItem // sku信息 } type SkuFreightFeeItem struct { SkuId uint // skuId Quantity uint // 数量 } type ReplyOrderFreightFee struct { SkuIds []uint `json:"skuIds"` FreightFee decimal.Decimal `json:"freightFee"` ErrCode uint `json:"errCode"` ErrMsg string `json:"errMsg"` } // FreightFee @Title 获取运费 func (o *order) FreightFee(ctx context.Context, channelId string, args ArgsOrderFreightFee) (reply []ReplyOrderFreightFee, err error) { xClient, err := client.GetClient(o) if err != nil { return } err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "FreightFee", args, &reply) return } type SkuOrderItem struct { SkuId uint // skuId Price decimal.Decimal // 单价 Quantity uint // 数量 } type ArgsOrderSubmit struct { ChannelOrderSn string // 渠道订单编号 Address string // 地址 Skus []SkuOrderItem // sku信息 Receiver Receiver // 收件信息 OrderFee decimal.Decimal // 订单金额-不含运费 FreightFees []OrderFreightFee // 运费 UserIp string // 下单用户ip } type OrderFreightFee struct { SkuIds []uint `json:"skuIds"` FreightFee decimal.Decimal `json:"freightFee"` } type Receiver struct { Name string // 姓名 Mobile string // 手机号 Email string // 邮箱 ZipCode string // 邮编 } type ReplyOrderSubmit struct { OrderSn string ChannelOrderSn string } // Submit @Title 下单 func (o *order) Submit(ctx context.Context, channelId string, args ArgsOrderSubmit) (reply ReplyOrderSubmit, err error) { xClient, err := client.GetClient(o) if err != nil { return } err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Submit", args, &reply) return }