From 8c283004e70d6ac93a14617e91d1c95fb4560152 Mon Sep 17 00:00:00 2001 From: kanade Date: Fri, 16 Dec 2022 11:22:05 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=89=B9=E5=8F=91=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wholesale/channel/channel.go | 5 ++- wholesale/channel/order.go | 75 ++++++++++++++++++++++++++++++++++++ wholesale/interface/order.go | 67 ++++++++++++++++++++++++++++++++ wholesale/order.go | 42 ++++++++++++++++++++ 4 files changed, 187 insertions(+), 2 deletions(-) create mode 100644 wholesale/channel/order.go create mode 100644 wholesale/interface/order.go create mode 100644 wholesale/order.go diff --git a/wholesale/channel/channel.go b/wholesale/channel/channel.go index 44d18f4..ee22bfe 100644 --- a/wholesale/channel/channel.go +++ b/wholesale/channel/channel.go @@ -1,6 +1,7 @@ package channel type Channel struct { - Sku sku - Mq mq + Sku sku + Order order + Mq mq } diff --git a/wholesale/channel/order.go b/wholesale/channel/order.go new file mode 100644 index 0000000..323eef7 --- /dev/null +++ b/wholesale/channel/order.go @@ -0,0 +1,75 @@ +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 // 有错误 + 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 // 手机号 + 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 +} diff --git a/wholesale/interface/order.go b/wholesale/interface/order.go new file mode 100644 index 0000000..7157237 --- /dev/null +++ b/wholesale/interface/order.go @@ -0,0 +1,67 @@ +package _interface + +import ( + "context" + "github.com/shopspring/decimal" +) + +type OrderInterface interface { + // FreightFee 获取运费 + FreightFee(ctx context.Context, args ArgsOrderFreightFee, freightFee *ReplyOrderFreightFee) error + // Submit 下单 + Submit(ctx context.Context, args ArgsOrderSubmit, sourceOrderSn *string) error + // LadingBill @Title 提单 + LadingBill(ctx context.Context, orderSn string, reply *int) error + // Close @Title 关闭订单 + Close(ctx context.Context, orderSn string, reply *int) error + // Cancel @Title 取消订单 + Cancel(ctx context.Context, args ArgsOrderCancel, reply *int) error + // Trajectory @Title 物流轨迹 + Trajectory(ctx context.Context, orderSn string, reply *[]ReplyTrajectory) error + // Finish @Title 确认收货 + Finish(ctx context.Context, orderSn string, reply *int) error +} +type ArgsOrderCancel struct { + OrderSn string // 订单编号 + Reason string // 取消原因 +} +type ArgsOrderFreightFee struct { + Skus []OrderFreightFeeSkuItem // 商品信息 + Address string // 地址 +} +type ReplyOrderFreightFee struct { + FreightFee decimal.Decimal // 运费 + ErrMsg string // 错误信息 +} + +type OrderFreightFeeSkuItem struct { + SourceSkuId string // 源skuId + SourceSkuPrice decimal.Decimal // 采购价 + Quantity uint // 数量 +} + +type ArgsOrderSubmit struct { + OrderSn uint64 // 订单号 + Skus []OrderFreightFeeSkuItem // 商品信息 + Address string // 地址 + Receiver OrderReceiver // 收件信息 + UserIp string // 用户ip +} + +type OrderReceiver struct { + Name string // 姓名 + Phone string // 手机号 + Email string // 邮件 + ZipCode string // 邮编 +} + +type ReplyTrajectory struct { + LogisticsName string `json:"logisticsName"` + WaybillCode string `json:"waybillCode"` + Steps []PackageStep `json:"steps"` +} +type PackageStep struct { + State string `json:"state"` + Content string `json:"content"` + OperatorAt int64 `json:"operatorAt"` +} diff --git a/wholesale/order.go b/wholesale/order.go new file mode 100644 index 0000000..3dab488 --- /dev/null +++ b/wholesale/order.go @@ -0,0 +1,42 @@ +package wholesale + +import ( + "context" + "git.oa00.com/supply-chain/service/client" + "github.com/shopspring/decimal" +) + +const ( + OrderCancelStatusSuccess = 1 // 取消成功 + OrderCancelStatusFail = 2 // 取消失败 +) + +type order struct { +} +type ArgsOrderSplit struct { + Source source // 商品来源 + ParentSourceOrderSn string // 上级订单号 + OrderSubs []OrderSub // 子订单 +} +type OrderSub struct { + SourceOrderSn string // 供应商订单号 + FreightFee decimal.Decimal // 运费 + OrderFee decimal.Decimal // 订单金额 + Skus []OrderSplitSkuItem // 拆分订单sku +} +type OrderSplitSkuItem struct { + SourceSkuId string + Quantity uint + SupplyPrice decimal.Decimal +} + +// Split @Title 拆单 +func (o *order) Split(ctx context.Context, args ArgsOrderSplit) (err error) { + xClient, err := client.GetClient(o) + if err != nil { + return + } + reply := 0 + err = xClient.Call(ctx, "Split", args, &reply) + return +} From 4aa68a959b6400cb67e2b0d9209d4555946b78fc Mon Sep 17 00:00:00 2001 From: kanade Date: Fri, 16 Dec 2022 11:22:40 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=89=B9=E5=8F=91=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rpc/error.go | 2 ++ wholesale/interface/order.go | 68 ++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 wholesale/interface/order.go diff --git a/rpc/error.go b/rpc/error.go index 203d156..c34fe1e 100644 --- a/rpc/error.go +++ b/rpc/error.go @@ -26,6 +26,7 @@ const ( ErrorOrderCancelError Error = 11020 // 订单取消失败 ErrorAfterServiceLogisticsAddressError Error = 11021 // 售后寄回地址获取失败 ErrorAfterServiceLogisticsAddressReturnError Error = 11022 // 售后寄回地址已回传 + ErrorWholesaleBatchOrderStartNumErr Error = 13101 // 商品未达到最小起批量 ) var ErrorCodes = map[Error]string{ @@ -51,6 +52,7 @@ var ErrorCodes = map[Error]string{ ErrorOrderCancelError: "订单取消失败", ErrorAfterServiceLogisticsAddressError: "售后寄回地址获取失败", ErrorAfterServiceLogisticsAddressReturnError: "售后寄回地址已回传", + ErrorWholesaleBatchOrderStartNumErr: "商品未达到最小起批量", } func (e Error) Error() string { diff --git a/wholesale/interface/order.go b/wholesale/interface/order.go new file mode 100644 index 0000000..56edcc0 --- /dev/null +++ b/wholesale/interface/order.go @@ -0,0 +1,68 @@ +package _interface + +import ( + "context" + "github.com/shopspring/decimal" +) + +type OrderInterface interface { + // FreightFee 获取运费 + FreightFee(ctx context.Context, args ArgsOrderFreightFee, freightFee *ReplyOrderFreightFee) error + // Submit 下单 + Submit(ctx context.Context, args ArgsOrderSubmit, sourceOrderSn *string) error + // LadingBill @Title 提单 + LadingBill(ctx context.Context, orderSn string, reply *int) error + // Close @Title 关闭订单 + Close(ctx context.Context, orderSn string, reply *int) error + // Cancel @Title 取消订单 + Cancel(ctx context.Context, args ArgsOrderCancel, reply *int) error + // Trajectory @Title 物流轨迹 + Trajectory(ctx context.Context, orderSn string, reply *[]ReplyTrajectory) error + // Finish @Title 确认收货 + Finish(ctx context.Context, orderSn string, reply *int) error +} +type ArgsOrderCancel struct { + OrderSn string // 订单编号 + Reason string // 取消原因 +} +type ArgsOrderFreightFee struct { + Skus []OrderFreightFeeSkuItem // 商品信息 + Address string // 地址 +} +type ReplyOrderFreightFee struct { + FreightFee decimal.Decimal // 运费 + ErrMsg string // 错误信息 +} + +type OrderFreightFeeSkuItem struct { + SourceSkuId string // 源skuId + SourceSkuPrice decimal.Decimal // 采购价 + Quantity uint // 数量(箱) +} + +type ArgsOrderSubmit struct { + OrderSn uint64 // 订单号 + Skus []OrderFreightFeeSkuItem // 商品信息 + Address string // 地址 + FreightFee decimal.Decimal // 运费 + Receiver OrderReceiver // 收件信息 + UserIp string // 用户ip +} + +type OrderReceiver struct { + Name string // 姓名 + Phone string // 手机号 + Email string // 邮件 + ZipCode string // 邮编 +} + +type ReplyTrajectory struct { + LogisticsName string `json:"logisticsName"` + WaybillCode string `json:"waybillCode"` + Steps []PackageStep `json:"steps"` +} +type PackageStep struct { + State string `json:"state"` + Content string `json:"content"` + OperatorAt int64 `json:"operatorAt"` +} From cdb38b32e854b2275f1768889eb83a63ce4f9e8f Mon Sep 17 00:00:00 2001 From: kanade Date: Fri, 16 Dec 2022 16:50:14 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=8F=98=E5=8A=A8rpc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supplier/goods.go | 14 ++++++++++++++ supply/sku.go | 1 + wholesale/wholesale.go | 1 + 3 files changed, 16 insertions(+) diff --git a/supplier/goods.go b/supplier/goods.go index d136d68..cab13b4 100644 --- a/supplier/goods.go +++ b/supplier/goods.go @@ -193,3 +193,17 @@ func (g *goods) FindBySkuIds(ctx context.Context, skuIds []uint) (reply []ReplyB err = xClient.Call(ctx, "FindBySkuIds", skuIds, &reply) return } + +type ArgsGoodsChange struct { + GoodsId uint // 商品id +} + +// Change @Title 商品信息变动 +func (g *goods) Change(ctx context.Context, args ArgsGoodsChange) (err error) { + xClient, err := client.GetClient(g) + if err != nil { + return err + } + reply := 0 + return xClient.Call(ctx, "Change", args, &reply) +} diff --git a/supply/sku.go b/supply/sku.go index 653560c..d09c9fc 100644 --- a/supply/sku.go +++ b/supply/sku.go @@ -361,6 +361,7 @@ type ArgsSkuChangeData struct { Unit string // 销售单位 UpcCode string // 商品条码 Source source // 商品来源 + Imgs []string // 商品图片 第一张主图 Specifications []SkuSpecification // 商品参数信息 } diff --git a/wholesale/wholesale.go b/wholesale/wholesale.go index 95b0102..e0610c0 100644 --- a/wholesale/wholesale.go +++ b/wholesale/wholesale.go @@ -10,6 +10,7 @@ type Wholesale struct { Category category Source sourceRpc Sku sku + Order order SkuAudit skuAudit Setting setting.Setting Channel channel.Channel From 8455e5432bbeee2e0f741d6175b91f1994e432a3 Mon Sep 17 00:00:00 2001 From: kanade Date: Fri, 16 Dec 2022 17:02:19 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=8F=98=E5=8A=A8rpc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supplier/goods.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supplier/goods.go b/supplier/goods.go index cab13b4..400d922 100644 --- a/supplier/goods.go +++ b/supplier/goods.go @@ -195,7 +195,7 @@ func (g *goods) FindBySkuIds(ctx context.Context, skuIds []uint) (reply []ReplyB } type ArgsGoodsChange struct { - GoodsId uint // 商品id + GoodsIds []uint // 商品id } // Change @Title 商品信息变动