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.
service/supply/channel/order.go

295 lines
9.0 KiB

package channel
import (
"context"
"git.oa00.com/supply-chain/service/client"
2 years ago
"git.oa00.com/supply-chain/service/lib/bean"
_interface "git.oa00.com/supply-chain/service/supply/interface"
"github.com/shopspring/decimal"
"github.com/smallnest/rpcx/share"
)
2 years ago
const (
ReplyOrderFreightFeeErrCodeNone = 0 // 无错误
ReplyOrderFreightFeeErrCodeErr = 1 // 有错误
2 years ago
ReplyOrderFreightFeeErrCodeDone = 2 // 已下架
OrderStatusLock = 1 // 锁单待确认
OrderStatusLadingBill = 2 // 提单
OrderStatusClose = 3 // 关闭
OrderSubStatusLock = 1 // 锁单
OrderSubStatusLadingBill = 2 // 提单
OrderSubStatusSendOutGoods = 3 // 出库/发货
OrderSubStatusDelivered = 4 // 妥投
OrderSubStatusFinal = 5 // 完成
2 years ago
OrderCancelSubStatusFalse = 1 // 未取消
OrderCancelSubStatusTrue = 2 // 已取消
OrderSubIsSplitFalse = 1 // 无
OrderSubIsSplitTrue = 2 // 被拆单
2 years ago
)
type order struct {
}
type ArgsOrderFreightFee struct {
Address string // 地址
Skus []SkuFreightFeeItem // sku信息
}
type SkuFreightFeeItem struct {
2 years ago
SkuId uint // skuId
Quantity uint // 数量
}
type ReplyOrderFreightFee struct {
SkuIds []uint `json:"skuIds"`
FreightFee decimal.Decimal `json:"freightFee"`
2 years ago
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
}
2 years ago
type SkuOrderItem struct {
SkuId uint // skuId
Price decimal.Decimal // 单价
Quantity uint // 数量
}
type ArgsOrderSubmit struct {
2 years ago
ChannelOrderSn string // 渠道订单编号
Address string // 地址
Skus []SkuOrderItem // sku信息
Receiver Receiver // 收件信息
OrderFee decimal.Decimal // 订单金额-不含运费
FreightFees []OrderFreightFee // 运费
UserIp string // 下单用户ip
2 years ago
}
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 {
2 years ago
OrderSn string
ChannelOrderSn string
}
// Submit @Title 下单
2 years ago
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
}
2 years ago
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
}
2 years ago
return xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Close", orderSn, &reply)
}
type ArgsOrderChannel struct {
OrderSn string // 订单编号
Reason string // 取消原因
}
// Cancel @Title 订单取消
func (o *order) Cancel(ctx context.Context, channelId string, args ArgsOrderChannel) (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}), "Cancel", args, &reply)
}
2 years ago
type ArgsOrderSplit struct {
RootOrderSn string
ChannelOrderSn string
}
type ReplyOrderSplit struct {
OrderSn string `json:"orderSn"`
ChannelOrderSn string `json:"channelOrderSn"`
FreightFee decimal.Decimal `json:"freightFee"`
OrderFee decimal.Decimal `json:"orderFee"`
Skus []OrderSplitSkuItem `json:"skus"`
SubOrders []*OrderSubSplit `json:"subOrders"`
}
type OrderSubSplit struct {
OrderSn string `json:"orderSn"`
FreightFee decimal.Decimal `json:"freightFee"`
OrderFee decimal.Decimal `json:"orderFee"`
Skus []OrderSplitSkuItem `json:"skus"`
SubOrders []*OrderSubSplit `json:"subOrders"`
}
type OrderSplitSkuItem struct {
SkuId uint `json:"skuId"`
Quantity uint `json:"quantity"`
}
// Split @Title 获取拆单信息
func (o *order) Split(ctx context.Context, channelId string, args ArgsOrderSplit) (reply ReplyOrderSplit, err error) {
xClient, err := client.GetClient(o)
if err != nil {
return
}
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Split", args, &reply)
return
}
2 years ago
type OrderListsSearch struct {
2 years ago
SkuIds []uint // 商品Ids
2 years ago
SkuName string // 商品名称
2 years ago
Status []uint // 订单状态
CancelStatus uint // 订单取消状态
OrderSn string // 订单编号
ReceiverName string // 收件人
ReceiverMobile string // 手机号
LadingBillDateStart string // 提单日期
LadingBillDateEnd string // 提单日期
FinishDateStart string // 完成日期
FinishDateEnd string // 完成日期
}
type ArgsOrderLists struct {
Search OrderListsSearch
Page bean.Page
}
type OrderItem struct {
OrderId uint `json:"orderId"`
2 years ago
OrderSn string `json:"orderSn"`
2 years ago
ReceiverName string `json:"receiverName"`
ReceiverMobile string `json:"receiverMobile"`
Address string `json:"address"`
FreightFee decimal.Decimal `json:"freightFee"`
OrderFee decimal.Decimal `json:"orderFee"`
LadingBillAt int64 `json:"ladingBillAt"`
FinishAt int64 `json:"finishAt"`
Status uint `json:"status"`
CancelStatus uint `json:"cancelStatus"`
CreatedAt int64 `json:"createdAt"`
CloseAt int64 `json:"closeAt"`
2 years ago
Skus []OrderSku `json:"skus"`
Packages []OrderPackage `json:"packages"`
2 years ago
StockOutAt int64 `json:"stockOutAt"`
2 years ago
}
type OrderSku struct {
2 years ago
Id uint `json:"id"`
SkuId uint `json:"skuId"`
Name string `json:"name"`
Price decimal.Decimal `json:"price"`
ImgUrl string `json:"imgUrl"`
Size string `json:"size"`
Color string `json:"color"`
Quantity uint `json:"quantity"`
2 years ago
}
type OrderPackage struct {
LogisticsName string `json:"logisticsName"`
WaybillCode string `json:"waybillCode"`
}
2 years ago
type ReplyOrderList struct {
Lists []OrderItem `json:"lists"`
Total int64 `json:"total"`
}
// Lists @Title 订单列表
func (o *order) Lists(ctx context.Context, channelId string, args ArgsOrderLists) (reply ReplyOrderList, err error) {
xClient, err := client.GetClient(o)
if err != nil {
return
}
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Lists", args, &reply)
return
}
2 years ago
type ArgsOrderDetail struct {
RootOrderSn string
ChannelOrderSn string
}
type ReplyOrderDetail struct {
ChannelOrderSn string
OrderSn string
OrderFee decimal.Decimal
FreightFee decimal.Decimal
Receiver OrderReceiver
CreatedAt int64
LadingBillAt int64
CloseAt int64
}
type OrderReceiver struct {
ReceiverName string
ReceiverMobile string
ReceiverEmail string
ReceiverZipCode string
Address string
UserIp string
}
2 years ago
// Detail @Title 订单详情
func (o *order) Detail(ctx context.Context, channelId string, orderSn string) (reply OrderItem, err error) {
xClient, err := client.GetClient(o)
if err != nil {
return
}
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Detail", orderSn, &reply)
return
}
// Trajectory @Title 获取订单物流信息
func (o *order) Trajectory(ctx context.Context, channelId string, orderSn string) (reply []_interface.ReplyTrajectory, err error) {
xClient, err := client.GetClient(o)
if err != nil {
return
}
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Trajectory", orderSn, &reply)
return
}
// Finish @Title 确认收货
func (o *order) Finish(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}), "Finish", orderSn, &reply)
}