package channel import ( "context" "git.oa00.com/supply-chain/service/client" "git.oa00.com/supply-chain/service/lib/bean" "github.com/shopspring/decimal" "github.com/smallnest/rpcx/share" ) const ( ReplyOrderFreightFeeErrCodeNone = 0 // 无错误 ReplyOrderFreightFeeErrCodeErr = 1 // 有错误 ReplyOrderFreightFeeErrCodeDone = 2 // 已下架 OrderStatusSubmit = 1 // 下单 OrderStatusFreightFee = 2 // 已确认运费 OrderStatusPay = 3 // 已支付 OrderStatusClose = 4 // 关闭 OrderSubStatusSubmit = 1 // 下单 OrderSubStatusFreightFee = 2 // 确认运费 OrderSubStatusPay = 3 // 已支付 OrderSubStatusCheckout = 4 // 出库 OrderSubStatusFinish = 5 // 完成 OrderCancelSubStatusFalse = 1 // 未取消 OrderCancelSubStatusTrue = 2 // 已取消 OrderSubIsSplitFalse = 1 // 无 OrderSubIsSplitTrue = 2 // 被拆单 OrderSubTypeApi = 1 // api接口下单 OrderSubTypeCustomerWeb = 2 // 客户商城下单 ) type order struct { } type SkuOrderItem struct { SkuId uint // skuId Price decimal.Decimal // 单价 Quantity uint // 数量 (箱) PackingRate uint // 装箱率 } type ArgsOrderSubmit struct { ChannelOrderSn string // 渠道订单编号 Address string // 地址 Skus []SkuOrderItem // sku信息 Receiver Receiver // 收件信息 OrderFee decimal.Decimal // 订单金额-不含运费 UserIp string // 下单用户ip Type uint // 下单方式 } type Receiver struct { Name string // 姓名 Mobile string // 手机号 HopeStockOutDate string // 期望发货日期 Email string // 邮箱 ZipCode string // 邮编 } type ReplyOrderSubmit struct { OrderSn string `json:"orderSn"` ChannelOrderSn string `json:"channelOrderSn"` } // 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 } // Pay @Title 支付提单 func (o *order) Pay(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}), "Pay", 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 ArgsOrderLists struct { Search OrderSearch Page bean.Page } type OrderSearch struct { Status []uint // 订单状态 CancelStatus uint // 取消状态 OrderSubSn string // 订单号 CreatedStartDate string // 创建开始日期 CreatedEndDate string // 创建结束日期 PayStartDate string // 支付开始日期 PayEndDate string // 支付结束日期 } type ReplyOrderLists struct { Lists []OrderItem `json:"lists"` Total int64 `json:"total"` } type OrderItem struct { Id uint `json:"id"` ReceiverName string `json:"receiverName"` ReceiverMobile string `json:"receiverMobile"` Address string `json:"address"` OrderSubSn string `json:"orderSubSn"` SourceOrderSn string `json:"sourceOrderSn"` OrderSn string `json:"orderSn"` FreightFee decimal.Decimal `json:"freightFee"` OrderFee decimal.Decimal `json:"orderFee"` Status uint `json:"status"` CancelStatus uint `json:"cancelStatus"` CreatedAt int64 `json:"createdAt"` PayTime int64 `json:"payTime"` FinishAt int64 `json:"finishAt"` StockOutAt int64 `json:"stockOutAt"` CloseAt int64 `json:"closeAt"` Skus []OrderSku `json:"skus"` Packages []OrderPackage `json:"packages"` ExpireAt int64 `json:"expireAt"` } type OrderPackage struct { LogisticsName string `json:"logisticsName"` WaybillCode string `json:"waybillCode"` } type OrderSku struct { Img string `json:"img"` SkuName string `json:"skuName"` SkuId uint `json:"skuId"` Size string `json:"size"` Color string `json:"color"` PackingRate uint `json:"packingRate"` SupplyPrice decimal.Decimal `json:"supplyPrice"` Quantity uint `json:"quantity"` } // Lists @Title 订单列表 func (o *order) Lists(ctx context.Context, channelId string, args ArgsOrderLists) (reply ReplyOrderLists, err error) { xClient, err := client.GetClient(o) if err != nil { return ReplyOrderLists{}, err } err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Lists", args, &reply) return } // SubDetail @Title 子订单详情 func (o *order) SubDetail(ctx context.Context, channelId, 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}), "SubDetail", orderSn, &reply) return } // Finish @Title 确认收货 func (o *order) Finish(ctx context.Context, channelId, orderSn string) error { xClient, err := client.GetClient(o) if err != nil { return err } reply := 0 err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Finish", orderSn, &reply) return err }