From 77e6d47741abc543b6bf9e1247a3865637b58af5 Mon Sep 17 00:00:00 2001 From: kanade Date: Wed, 31 Aug 2022 10:19:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=94=AE=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rpc/error.go | 2 + supply/channel/afterService.go | 121 +++++++++++++++++++++++++++++++ supply/channel/channel.go | 5 +- supply/interface/afterService.go | 69 ++++++++++++++++++ supply/order.go | 34 +++++++++ 5 files changed, 229 insertions(+), 2 deletions(-) create mode 100644 supply/channel/afterService.go create mode 100644 supply/interface/afterService.go create mode 100644 supply/order.go diff --git a/rpc/error.go b/rpc/error.go index 1ccf7f1..f837c89 100644 --- a/rpc/error.go +++ b/rpc/error.go @@ -17,6 +17,7 @@ const ( ErrorOrderError Error = 11011 // 订单错误 ErrorOrderUnPay Error = 11012 // 订单未支付 ErrorOrderInvalid Error = 11013 // 订单失效 + ErrorOrderSkuInvalid Error = 11014 // 订单商品错误 ) var ErrorCodes = map[Error]string{ @@ -33,6 +34,7 @@ var ErrorCodes = map[Error]string{ ErrorOrderError: "订单错误", ErrorOrderUnPay: "订单未支付", ErrorOrderInvalid: "订单失效", + ErrorOrderSkuInvalid: "订单商品错误", } func (e Error) Error() string { diff --git a/supply/channel/afterService.go b/supply/channel/afterService.go new file mode 100644 index 0000000..8ab9367 --- /dev/null +++ b/supply/channel/afterService.go @@ -0,0 +1,121 @@ +package channel + +import ( + "context" + "git.oa00.com/supply-chain/service/client" + "github.com/smallnest/rpcx/share" +) + +type afterService struct { +} +type ArgsAfterServiceType struct { + OrderSn string // 订单编号 + SkuId uint // skuId +} +type ReplyAfterServiceType struct { + Type string `json:"type"` // 类型 + TypeName string `json:"typeName"` // 类型名称 +} + +// Type @Title 获取可发起的售后类型 +func (a *afterService) Type(ctx context.Context, channelId string, args ArgsAfterServiceType) (reply []ReplyAfterServiceType, err error) { + xClient, err := client.GetClient(a) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Type", args, &reply) + return +} + +type ArgsAfterServiceReason struct { + OrderSn string // 订单编号 + SkuId uint // skuId + Type string // 售后类型 +} +type ReplyAfterServiceReason struct { + ReasonCode string `json:"reasonCode"` // 售后原因编码 + ReasonName string `json:"reasonName"` // 售后原因描述 + NeedPicture uint `json:"needPicture"` // 是否需要上传图片 1=需要上传 2=不需要上传 +} + +// Reason @Title 获取售后原因 +func (a *afterService) Reason(ctx context.Context, channelId string, args ArgsAfterServiceReason) (reply []ReplyAfterServiceReason, err error) { + xClient, err := client.GetClient(a) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Reason", args, &reply) + return +} + +type ArgsAfterServiceApply struct { + Type string // 售后类型 + TypeName string // 售后名称 + ReasonCode string // 售后原因编码 + ReasonName string // 售后原因描述 + ChannelAfterServiceSn string // 渠道售后单号 + OrderSn string // 订单编号 + SkuId uint // skuId + Pictures []string // 图片地址数组 + Quantity uint // 售后申请数量 +} +type ReplyAfterServiceApply struct { + AfterServiceSn string `json:"afterServiceSn"` // 渠道售后单号 + ChannelAfterServiceSn string `json:"channelAfterServiceSn"` // 渠道售后单号 +} + +// Apply @Title 发起售后 +func (a *afterService) Apply(ctx context.Context, channelId string, args ArgsAfterServiceApply) (reply ReplyAfterServiceApply, err error) { + xClient, err := client.GetClient(a) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Apply", args, &reply) + return +} + +type ReplyAfterServiceLogisticsAddress struct { + Name string `json:"name"` // 姓名 + Mobile string `json:"mobile"` // 手机号 + ZipCode string `json:"zipCode"` // 邮编 + Address string `json:"address"` // 地址 +} + +// LogisticsAddress @Title 寄回地址 +func (a *afterService) LogisticsAddress(ctx context.Context, channelId string, afterServiceSn string) (reply ReplyAfterServiceLogisticsAddress, err error) { + xClient, err := client.GetClient(a) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "LogisticsAddress", afterServiceSn, &reply) + return +} + +type ArgsAfterServiceBackLogisticsBill struct { + AfterServiceSn string // 售后单号 + LogisticsCompany string // 物流公司 + WaybillCode string // 运单号 + SendGoodsDate int64 // 运单发货日期 +} + +// BackLogisticsBill @Title 回传物流信息 +func (a *afterService) BackLogisticsBill(ctx context.Context, channelId string, args ArgsAfterServiceBackLogisticsBill) (err error) { + xClient, err := client.GetClient(a) + if err != nil { + return + } + reply := 0 + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "BackLogisticsBill", args, &reply) + return +} + +// Cancel @Title 取消售后 +func (a *afterService) Cancel(ctx context.Context, channelId string, afterServiceSn string) (err error) { + xClient, err := client.GetClient(a) + if err != nil { + return + } + reply := 0 + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Cancel", afterServiceSn, &reply) + return +} diff --git a/supply/channel/channel.go b/supply/channel/channel.go index 5d8b79f..4d4ef19 100644 --- a/supply/channel/channel.go +++ b/supply/channel/channel.go @@ -1,6 +1,7 @@ package channel type Channel struct { - Sku sku - Order order + Sku sku + Order order + AfterService afterService } diff --git a/supply/interface/afterService.go b/supply/interface/afterService.go new file mode 100644 index 0000000..58a642a --- /dev/null +++ b/supply/interface/afterService.go @@ -0,0 +1,69 @@ +package _interface + +import ( + "context" +) + +type AfterServiceInterface interface { + // Type 获取可发起的售后类型 + Type(ctx context.Context, args ArgsAfterServiceType, reply *[]ReplyAfterServiceType) error + // Reason 获取售后原因 + Reason(ctx context.Context, args ArgsAfterServiceReason, reply *ReplyAfterServiceReason) error + // Apply @Title 发起售后 + Apply(ctx context.Context, args ArgsAfterServiceApply, reply *ReplyAfterServiceApply) error + // LogisticsAddress @Title 寄回地址 + LogisticsAddress(ctx context.Context, afterServiceSn string, reply *ReplyAfterServiceLogisticsAddress) error + // BackLogisticsBill @Title 回传物流信息 + BackLogisticsBill(ctx context.Context, args ArgsAfterServiceBackLogisticsBill, reply *int) error + // Cancel @Title 取消售后 + Cancel(ctx context.Context, afterServiceSn string, reply *int) error +} +type ArgsAfterServiceType struct { + OrderSn string // 订单编号 + SkuId string // skuId +} +type ReplyAfterServiceType struct { + Type string `json:"type"` // 类型 + TypeName string `json:"typeName"` // 类型名称 +} + +type ArgsAfterServiceReason struct { + OrderSn string // 订单编号 + SkuId string // skuId + Type string // 售后类型 +} +type ReplyAfterServiceReason struct { + ReasonCode string `json:"reasonCode"` // 售后原因编码 + ReasonName string `json:"reasonName"` // 售后原因描述 + NeedPicture uint `json:"needPicture"` // 是否需要上传图片 1=需要上传 2=不需要上传 +} + +type ArgsAfterServiceApply struct { + Type string // 售后类型 + TypeName string // 售后名称 + ReasonCode string // 售后原因编码 + ReasonName string // 售后原因描述 + ChannelAfterServiceSn string // 渠道售后单号 + OrderSn string // 订单编号 + SkuId string // skuId + Pictures []string // 图片地址数组 + Quantity uint // 售后申请数量 +} +type ReplyAfterServiceApply struct { + AfterServiceSn string `json:"afterServiceSn"` // 渠道售后单号 + ChannelAfterServiceSn string `json:"channelAfterServiceSn"` // 渠道售后单号 +} + +type ReplyAfterServiceLogisticsAddress struct { + Name string `json:"name"` // 姓名 + Mobile string `json:"mobile"` // 手机号 + ZipCode string `json:"zipCode"` // 邮编 + Address string `json:"address"` // 地址 +} + +type ArgsAfterServiceBackLogisticsBill struct { + AfterServiceSn string // 售后单号 + LogisticsCompany string // 物流公司 + WaybillCode string // 运单号 + SendGoodsDate int64 // 运单发货日期 +} diff --git a/supply/order.go b/supply/order.go new file mode 100644 index 0000000..f338fb9 --- /dev/null +++ b/supply/order.go @@ -0,0 +1,34 @@ +package supply + +import ( + "context" + "git.oa00.com/supply-chain/service/client" + "github.com/shopspring/decimal" +) + +type order struct { +} +type ArgsOrderSplit struct { + SourceOrderSn string // 供应商订单号 + Source source // 商品来源 + ParentSourceOrderSn 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, "Lists", args, &reply) + return +} From ecf0b36ce3788be50e65592111ec778681685818 Mon Sep 17 00:00:00 2001 From: kanade Date: Wed, 31 Aug 2022 10:39:30 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supply/sku.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/supply/sku.go b/supply/sku.go index b93b428..d57fb00 100644 --- a/supply/sku.go +++ b/supply/sku.go @@ -60,7 +60,6 @@ type ArgsSkuAdd struct { } type SkuImg struct { - Id uint `json:"id"` Path string `json:"path"` } @@ -181,7 +180,7 @@ type SkuInfo struct { TaxName string `json:"taxName"` TaxCode string `json:"taxCode"` Unit string `json:"unit"` - Imgs []SkuImg `json:"imgs"` + Imgs []SkuImgItem `json:"imgs"` Reason string `json:"reason"` Specifications []SkuSpecification `json:"specification"` PlatformStatus uint `json:"platformStatus"` @@ -191,6 +190,11 @@ type SkuInfo struct { AdjustPrice decimal.Decimal `json:"adjustPrice"` } +type SkuImgItem struct { + Id uint `json:"id"` + Path string `json:"path"` +} + // Info @Title 商品信息 func (s *sku) Info(ctx context.Context, skuId uint) (reply SkuInfo, err error) { xClient, err := client.GetClient(s) @@ -230,7 +234,7 @@ func (s *sku) DownShelves(ctx context.Context, args ArgsSkuDownShelves) error { } // GetImgs @Title 获取预览图 -func (s *sku) GetImgs(ctx context.Context, skuId uint) (reply []SkuImg, err error) { +func (s *sku) GetImgs(ctx context.Context, skuId uint) (reply []SkuImgItem, err error) { xClient, err := client.GetClient(s) if err != nil { return nil, err From 18f271f7759fcc81c5a68f86b4b941eec181fe18 Mon Sep 17 00:00:00 2001 From: kanade Date: Wed, 31 Aug 2022 11:19:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supplier/goods.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/supplier/goods.go b/supplier/goods.go index fadfe08..15fd1d8 100644 --- a/supplier/goods.go +++ b/supplier/goods.go @@ -153,3 +153,13 @@ func (g *goods) Discard(ctx context.Context, goodsIds []uint) (reply []AdoptItem err = xClient.Call(ctx, "Discard", goodsIds, &reply) return } + +// ReHandle @Title 重新处理商品 +func (g *goods) ReHandle(ctx context.Context, skuId uint) error { + reply := 0 + xClient, err := client.GetClient(g) + if err != nil { + return err + } + return xClient.Call(ctx, "ReHandle", skuId, &reply) +}