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.
85 lines
2.6 KiB
85 lines
2.6 KiB
package supply
|
|
|
|
import "github.com/shopspring/decimal"
|
|
|
|
const (
|
|
orderFreightFee = "/order/freight_fee" // 获取运费
|
|
orderSubmit = "/order/submit" // 提交订单
|
|
orderLadingBill = "/order/lading_bill" // 提单
|
|
orderClose = "/order/close" // 关闭订单
|
|
|
|
ReplyOrderFreightFeeErrCodeNone = 0 // 无错误
|
|
ReplyOrderFreightFeeErrCodeErr = 1 // 有错误
|
|
)
|
|
|
|
type order struct {
|
|
}
|
|
|
|
type OrderFreightFeeItem struct {
|
|
SkuId uint `json:"skuId"`
|
|
Quantity uint `json:"quantity"`
|
|
Price decimal.Decimal `json:"price"`
|
|
}
|
|
type ReplyOrderFreightFee struct {
|
|
SkuIds []uint `json:"skuIds"`
|
|
FreightFee float64 `json:"freightFee"`
|
|
ErrCode uint `json:"errCode"`
|
|
ErrMsg string `json:"errMsg"`
|
|
}
|
|
|
|
// FreightFee @Title 获取运费
|
|
func (o *order) FreightFee(address string, skus []OrderFreightFeeItem) (result []ReplyOrderFreightFee, err error) {
|
|
err = exec(orderFreightFee, map[string]interface{}{
|
|
"address": address,
|
|
"skus": skus,
|
|
}, &result)
|
|
return
|
|
}
|
|
|
|
type OrderSubmit struct {
|
|
ChannelOrderSn string `json:"channelOrderSn"` // 订单编号
|
|
Address string `json:"address"` // 配送地址
|
|
Skus []OrderFreightFeeItem `json:"skus"` // sku信息
|
|
Receiver Receiver `json:"receiver"` // 收货信息
|
|
OrderFee decimal.Decimal `json:"orderFee"` // 订单金额
|
|
FreightFees []OrderFreightFee `json:"freightFees"` // 运费
|
|
UserIp string `json:"userIp"` // 用户ip
|
|
}
|
|
|
|
type OrderFreightFee struct {
|
|
SkuIds []uint `json:"skuIds"` // skuIds
|
|
FreightFee decimal.Decimal `json:"freightFee"` // 运费
|
|
}
|
|
type Receiver struct {
|
|
Name string `json:"name"` // 姓名
|
|
Mobile string `json:"mobile"` // 手机号
|
|
Email string `json:"email"` // 邮箱
|
|
ZipCode string `json:"zipCode"` // 邮编
|
|
}
|
|
type ReplyOrderSubmit struct {
|
|
OrderSn string `json:"orderSn"`
|
|
ChannelOrderSn string `json:"channelOrderSn"`
|
|
}
|
|
|
|
// Submit @Title 提交订单
|
|
func (o *order) Submit(data OrderSubmit) (result ReplyOrderSubmit, err error) {
|
|
err = exec(orderSubmit, data, &result)
|
|
return
|
|
}
|
|
|
|
// LadingBill @Title 提单
|
|
func (o *order) LadingBill(orderSn string) (result ReplyOrderSubmit, err error) {
|
|
err = exec(orderLadingBill, map[string]interface{}{
|
|
"orderSn": orderSn,
|
|
}, &result)
|
|
return
|
|
}
|
|
|
|
// Close @Title 关闭订单
|
|
func (o *order) Close(orderSn string) (result ReplyOrderSubmit, err error) {
|
|
err = exec(orderClose, map[string]interface{}{
|
|
"orderSn": orderSn,
|
|
}, &result)
|
|
return
|
|
}
|