You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
3.3 KiB
116 lines
3.3 KiB
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 // 有错误
|
|
|
|
OrderStatusLock = 1 // 锁单待确认
|
|
OrderStatusLadingBill = 2 // 提单
|
|
OrderStatusClose = 3 // 关闭
|
|
|
|
OrderSubStatusLock = 1 // 锁单
|
|
OrderSubStatusLadingBill = 2 // 提单
|
|
OrderSubStatusSendOutGoods = 3 // 出库/发货
|
|
OrderSubStatusDelivered = 4 // 妥投
|
|
OrderSubStatusFinal = 5 // 完成
|
|
OrderSubStatusCancel = 6 // 取消
|
|
)
|
|
|
|
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
|
|
}
|
|
|
|
// LadingBill @Title 提单
|
|
func (o *order) LadingBill(ctx context.Context, channelId string, orderSn string) (err error) {
|
|
reply := 0
|
|
xClient, err := client.GetClient(o)
|
|
if err != nil {
|
|
return
|
|
}
|
|
return xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "LadingBill", orderSn, &reply)
|
|
}
|
|
|
|
// Close @Title 关闭
|
|
func (o *order) Close(ctx context.Context, channelId string, orderSn string) (err error) {
|
|
reply := 0
|
|
xClient, err := client.GetClient(o)
|
|
if err != nil {
|
|
return
|
|
}
|
|
return xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Close", orderSn, &reply)
|
|
}
|