package channel import ( "context" "git.oa00.com/supply-chain/service/client" "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" ) const ( ReplyOrderFreightFeeErrCodeNone = 0 // 无错误 ReplyOrderFreightFeeErrCodeErr = 1 // 有错误 OrderStatusLock = 1 // 锁单待确认 OrderStatusLadingBill = 2 // 提单 OrderStatusClose = 3 // 关闭 OrderSubStatusLock = 1 // 锁单 OrderSubStatusLadingBill = 2 // 提单 OrderSubStatusSendOutGoods = 3 // 出库/发货 OrderSubStatusDelivered = 4 // 妥投 OrderSubStatusFinal = 5 // 完成 OrderCancelSubStatusFalse = 1 // 未取消 OrderCancelSubStatusTrue = 2 // 已取消 OrderSubIsSplitFalse = 1 // 无 OrderSubIsSplitTrue = 2 // 被拆单 ) 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) } 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) } 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 } type OrderListsSearch struct { SkuName string // 商品名称 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"` OrderSn string `json:"orderSn"` 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"` Skus []OrderSku `json:"skus"` Packages []OrderPackage `json:"packages"` } type OrderSku struct { 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"` } type OrderPackage struct { LogisticsName string `json:"logisticsName"` WaybillCode string `json:"waybillCode"` } 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 } 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 } // 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) }