From 9d48a244c0140129608f55688bfdbc7c7f54f112 Mon Sep 17 00:00:00 2001 From: kanade Date: Wed, 3 Aug 2022 09:29:07 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client.go | 14 +++++------ customer/service/audit.go | 6 ++++- customer/service/audit/supply.go | 24 +++++++++++++++--- customer/user.go | 42 ++++++++++++++++++++++++++------ customer/user/deposit.go | 12 +++++++-- customer/user/depositAudit.go | 18 +++++++++++--- customer/user/wallet.go | 6 ++++- jd/brand.go | 18 +++++++++++--- jd/category.go | 18 +++++++++++--- jd/sku.go | 42 ++++++++++++++++++++++++++------ jd/task.go | 12 +++++++-- supply/brand.go | 30 +++++++++++++++++++---- supply/category.go | 24 +++++++++++++++--- supply/channel/order.go | 12 +++++++-- supply/channel/sku.go | 18 +++++++++++--- supply/setting/rate.go | 12 +++++++-- supply/sku.go | 42 ++++++++++++++++++++++++++------ supply/skuAudit.go | 18 +++++++++++--- 18 files changed, 302 insertions(+), 66 deletions(-) diff --git a/client/client.go b/client/client.go index 0fe95e9..a9531bd 100644 --- a/client/client.go +++ b/client/client.go @@ -1,6 +1,7 @@ package client import ( + "errors" "fmt" "git.oa00.com/supply-chain/service/config" "github.com/smallnest/rpcx/client" @@ -23,7 +24,7 @@ func init() { } // GetClient @Title 获取RPC客户的 -func GetClient(s interface{}) client.XClient { +func GetClient(s interface{}) (client.XClient, error) { path := strings.TrimPrefix(reflect.ValueOf(s).Elem().Type().PkgPath(), basePkgPath) actionName := reflect.ValueOf(s).Elem().Type().Name() key := path + "/" + actionName @@ -38,8 +39,7 @@ func GetClient(s interface{}) client.XClient { d, err := client.NewConsulDiscovery(basePath, servicePath, config.RpcConfig.RegistryServer, nil) if err != nil { - log.Println(err) - return nil + return nil, errors.New("系统异常") } option := client.DefaultOption option.Retries = 3 @@ -51,11 +51,11 @@ func GetClient(s interface{}) client.XClient { } mutex.Unlock() } - return xClient.(client.XClient) + return xClient.(client.XClient), nil } // GetClientName @Title 根据服务名获取客户端 -func GetClientName(base, service string) client.XClient { +func GetClientName(base, service string) (client.XClient, error) { key := fmt.Sprintf("%s/%s", base, service) xClient, ok := mClient.Load(key) if !ok { @@ -65,7 +65,7 @@ func GetClientName(base, service string) client.XClient { d, err := client.NewConsulDiscovery(base, service, config.RpcConfig.RegistryServer, nil) if err != nil { log.Println(err) - return nil + return nil, errors.New("系统异常") } option := client.DefaultOption option.Retries = 3 @@ -77,5 +77,5 @@ func GetClientName(base, service string) client.XClient { } mutex.Unlock() } - return xClient.(client.XClient) + return xClient.(client.XClient), nil } diff --git a/customer/service/audit.go b/customer/service/audit.go index 27ee3c6..bb7bd49 100644 --- a/customer/service/audit.go +++ b/customer/service/audit.go @@ -34,6 +34,10 @@ type ReplyAuditLists struct { // Lists @Title 服务审核列表 func (a *audit) Lists(ctx context.Context, args ArgsAuditLists) (reply ReplyAuditLists, err error) { - err = client.GetClient(a).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(a) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } diff --git a/customer/service/audit/supply.go b/customer/service/audit/supply.go index 64c7891..821f006 100644 --- a/customer/service/audit/supply.go +++ b/customer/service/audit/supply.go @@ -19,7 +19,11 @@ type ArgsSupplyApply struct { // Apply @Title 申请 func (s *supply) Apply(ctx context.Context, args ArgsSupplyApply) error { reply := 0 - return client.GetClient(s).Call(ctx, "Apply", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Apply", args, &reply) } type ArgsSupplyAdopt struct { @@ -30,7 +34,11 @@ type ArgsSupplyAdopt struct { // Adopt @Title 审核通过 func (s *supply) Adopt(ctx context.Context, args ArgsSupplyAdopt) error { reply := 0 - return client.GetClient(s).Call(ctx, "Adopt", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Adopt", args, &reply) } type ArgsSupplyReject struct { @@ -42,7 +50,11 @@ type ArgsSupplyReject struct { // Reject @Title 驳回 func (s *supply) Reject(ctx context.Context, args ArgsSupplyReject) error { reply := 0 - return client.GetClient(s).Call(ctx, "Reject", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Reject", args, &reply) } type ReplySupplyInfo struct { @@ -63,6 +75,10 @@ type ReplySupplyInfo struct { // Info @Title 详情 func (s *supply) Info(ctx context.Context, userServiceId uint) (reply ReplySupplyInfo, err error) { - err = client.GetClient(s).Call(ctx, "Info", userServiceId, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", userServiceId, &reply) return } diff --git a/customer/user.go b/customer/user.go index 1278a5e..92fd31e 100644 --- a/customer/user.go +++ b/customer/user.go @@ -46,7 +46,11 @@ type ReplyUserList struct { // Lists @Title 获取客户列表 func (u *user) Lists(ctx context.Context, args ArgsUserList) (reply ReplyUserList, err error) { - err = client.GetClient(u).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -63,7 +67,11 @@ type ArgsUserAdd struct { // Add @Title 添加客户 func (u *user) Add(ctx context.Context, args ArgsUserAdd) error { reply := 0 - return client.GetClient(u).Call(ctx, "Add", args, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return err + } + return xClient.Call(ctx, "Add", args, &reply) } type ReplyUserInfo struct { @@ -76,7 +84,11 @@ type ReplyUserInfo struct { // Info @Title 客户详情 func (u *user) Info(ctx context.Context, userId uint) (result ReplyUserInfo, err error) { - err = client.GetClient(u).Call(ctx, "Info", userId, &result) + xClient, err := client.GetClient(u) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", userId, &result) return } @@ -91,19 +103,31 @@ type ArgsUserEdit struct { // Edit @Title 编辑客户 func (u *user) Edit(ctx context.Context, args ArgsUserEdit) error { reply := 0 - return client.GetClient(u).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) } // Enable @Title 启用 func (u *user) Enable(ctx context.Context, userId uint) error { reply := 0 - return client.GetClient(u).Call(ctx, "Enable", userId, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return err + } + return xClient.Call(ctx, "Enable", userId, &reply) } // Disable @Title 停用 func (u *user) Disable(ctx context.Context, userId uint) error { reply := 0 - return client.GetClient(u).Call(ctx, "Disable", userId, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return err + } + return xClient.Call(ctx, "Disable", userId, &reply) } type ArgsUserServiceInfo struct { @@ -118,6 +142,10 @@ type ReplyUserServiceInfo struct { // ServiceInfo @Title 获取服务信息 func (u *user) ServiceInfo(ctx context.Context, args ArgsUserServiceInfo) (reply ReplyUserServiceInfo, err error) { - err = client.GetClient(u).Call(ctx, "ServiceInfo", args, &reply) + xClient, err := client.GetClient(u) + if err != nil { + return + } + err = xClient.Call(ctx, "ServiceInfo", args, &reply) return } diff --git a/customer/user/deposit.go b/customer/user/deposit.go index 9501065..6f6419f 100644 --- a/customer/user/deposit.go +++ b/customer/user/deposit.go @@ -31,7 +31,11 @@ type ArgsDepositAdd struct { // Add @Title 充值 func (d *deposit) Add(ctx context.Context, args ArgsDepositAdd) error { reply := 0 - return client.GetClient(d).Call(ctx, "Add", args, &reply) + xClient, err := client.GetClient(d) + if err != nil { + return err + } + return xClient.Call(ctx, "Add", args, &reply) } type ArgsDepositInfo struct { @@ -57,6 +61,10 @@ type ReplyDepositInfo struct { // Info @Title 详情 func (d *deposit) Info(ctx context.Context, args ArgsDepositInfo) (reply ReplyDepositInfo, err error) { - err = client.GetClient(d).Call(ctx, "Info", args, &reply) + xClient, err := client.GetClient(d) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", args, &reply) return } diff --git a/customer/user/depositAudit.go b/customer/user/depositAudit.go index 21e28c4..1af29f5 100644 --- a/customer/user/depositAudit.go +++ b/customer/user/depositAudit.go @@ -41,7 +41,11 @@ type DepositAuditItem struct { // Lists @Title 充值审核列表 func (d *depositAudit) Lists(ctx context.Context, args ArgsDepositAuditLists) (reply ReplyDepositAuditList, err error) { - err = client.GetClient(d).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(d) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -53,7 +57,11 @@ type ArgsDepositAuditAdopt struct { // Adopt @Title 通过 func (d *depositAudit) Adopt(ctx context.Context, args ArgsDepositAuditAdopt) error { reply := 0 - return client.GetClient(d).Call(ctx, "Adopt", args, &reply) + xClient, err := client.GetClient(d) + if err != nil { + return err + } + return xClient.Call(ctx, "Adopt", args, &reply) } @@ -66,5 +74,9 @@ type ArgsDepositAuditReject struct { // Reject @Title 驳回 func (d *depositAudit) Reject(ctx context.Context, args ArgsDepositAuditReject) error { reply := 0 - return client.GetClient(d).Call(ctx, "Reject", args, &reply) + xClient, err := client.GetClient(d) + if err != nil { + return err + } + return xClient.Call(ctx, "Reject", args, &reply) } diff --git a/customer/user/wallet.go b/customer/user/wallet.go index 04aa620..1136b89 100644 --- a/customer/user/wallet.go +++ b/customer/user/wallet.go @@ -30,5 +30,9 @@ type ArgsWalletDirect struct { // Direct @Title 直接消费 func (w *wallet) Direct(ctx context.Context, args ArgsDepositAuditReject) error { reply := 0 - return client.GetClient(w).Call(ctx, "Direct", args, &reply) + xClient, err := client.GetClient(w) + if err != nil { + return err + } + return xClient.Call(ctx, "Direct", args, &reply) } diff --git a/jd/brand.go b/jd/brand.go index f8366f1..3ad00d1 100644 --- a/jd/brand.go +++ b/jd/brand.go @@ -25,7 +25,11 @@ type ReplyBrandList struct { // Lists @Title 获取品牌匹配列表 func (b *brand) Lists(ctx context.Context, args ArgsBrandList) (reply ReplyBrandList, err error) { - err = client.GetClient(b).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(b) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -38,7 +42,11 @@ type ArgsBrandEdit struct { // Edit @Title 编辑品牌匹配 func (b *brand) Edit(ctx context.Context, args ArgsBrandEdit) error { reply := 0 - return client.GetClient(b).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(b) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) } type ArgsImport struct { @@ -48,5 +56,9 @@ type ArgsImport struct { func (b *brand) Import(ctx context.Context, args []ArgsImport) error { reply := 0 - return client.GetClient(b).Call(ctx, "Import", args, &reply) + xClient, err := client.GetClient(b) + if err != nil { + return err + } + return xClient.Call(ctx, "Import", args, &reply) } diff --git a/jd/category.go b/jd/category.go index 8b0fd20..2aad24d 100644 --- a/jd/category.go +++ b/jd/category.go @@ -27,7 +27,11 @@ type ReplyCategoryList struct { // Lists @Title 获取品牌匹配列表 func (c *category) Lists(ctx context.Context, args ArgsCategoryList) (reply ReplyCategoryList, err error) { - err = client.GetClient(c).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -42,12 +46,20 @@ type ArgsCategoryEdit struct { // Edit @Title 编辑品牌匹配 func (c *category) Edit(ctx context.Context, args ArgsCategoryEdit) error { reply := 0 - return client.GetClient(c).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(c) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) } // Select @Title 类目筛选 func (c *category) Select(ctx context.Context) (reply []CategoryItem, err error) { args := 0 - err = client.GetClient(c).Call(ctx, "Select", args, &reply) + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "Select", args, &reply) return } diff --git a/jd/sku.go b/jd/sku.go index e905ef3..b40e03d 100644 --- a/jd/sku.go +++ b/jd/sku.go @@ -61,14 +61,22 @@ type ReplySkuList struct { // Lists @Title 获取商品列表 func (s *sku) Lists(ctx context.Context, args ArgsSkuList) (reply ReplySkuList, err error) { - err = client.GetClient(s).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } // Start @Title 开始处理 func (s *sku) Start(ctx context.Context, skuIds []uint) error { reply := 0 - return client.GetClient(s).Call(ctx, "Start", skuIds, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Start", skuIds, &reply) } type ReplySkuInfo struct { @@ -103,7 +111,11 @@ type SkuImg struct { // GetImgs @Title 获取预览图 func (s *sku) GetImgs(ctx context.Context, skuId uint) (reply []SkuImg, err error) { - err = client.GetClient(s).Call(ctx, "GetImgs", skuId, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "GetImgs", skuId, &reply) return } @@ -119,7 +131,11 @@ type SkuAttribute struct { // Info @Title 获取商品详情 func (s *sku) Info(ctx context.Context, skuId uint) (reply ReplySkuInfo, err error) { - err = client.GetClient(s).Call(ctx, "Info", skuId, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", skuId, &reply) return } @@ -139,13 +155,21 @@ type SkuImgEdit struct { // Edit @Title 商品编辑 func (s *sku) Edit(ctx context.Context, args ArgsSkuEdit) error { reply := 0 - return client.GetClient(s).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) } // Discard @Title 废弃 func (s *sku) Discard(ctx context.Context, skuIds []uint) error { reply := 0 - return client.GetClient(s).Call(ctx, "Discard", skuIds, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Discard", skuIds, &reply) } type AdoptItem struct { @@ -157,6 +181,10 @@ type AdoptItem struct { // Adopt @Title 入库 func (s *sku) Adopt(ctx context.Context, skuIds []uint) (reply []AdoptItem, err error) { - err = client.GetClient(s).Call(ctx, "Adopt", skuIds, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Adopt", skuIds, &reply) return } diff --git a/jd/task.go b/jd/task.go index 802a463..5a3b0a6 100644 --- a/jd/task.go +++ b/jd/task.go @@ -11,11 +11,19 @@ type task struct { // PullSku @Title 拉取京东商品 func (t *task) PullSku(ctx context.Context) error { a := 0 - return client.GetClient(t).Call(ctx, "PullSku", 0, &a) + xClient, err := client.GetClient(t) + if err != nil { + return err + } + return xClient.Call(ctx, "PullSku", 0, &a) } // SkuAdd @Title 添加商品到库 func (t *task) SkuAdd(ctx context.Context) error { a := 0 - return client.GetClient(t).Call(ctx, "SkuAdd", 0, &a) + xClient, err := client.GetClient(t) + if err != nil { + return err + } + return xClient.Call(ctx, "SkuAdd", 0, &a) } diff --git a/supply/brand.go b/supply/brand.go index b4054d6..d4516ff 100644 --- a/supply/brand.go +++ b/supply/brand.go @@ -31,13 +31,21 @@ type BrandSearch struct { // Lists @Title 品牌列表 func (b *brand) Lists(ctx context.Context, args ArgsBrandList) (result ReplyBrandList, err error) { - err = client.GetClient(b).Call(ctx, "Lists", args, &result) + xClient, err := client.GetClient(b) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &result) return } // All @Title 全部品牌 func (b *brand) All(ctx context.Context) (result []BrandItem, err error) { - err = client.GetClient(b).Call(ctx, "All", 0, &result) + xClient, err := client.GetClient(b) + if err != nil { + return + } + err = xClient.Call(ctx, "All", 0, &result) return } @@ -48,7 +56,11 @@ type ArgsBrandAdd struct { // Add @Title 添加品牌 func (b *brand) Add(ctx context.Context, args ArgsBrandAdd) (err error) { reply := 0 - return client.GetClient(b).Call(ctx, "Add", args, &reply) + xClient, err := client.GetClient(b) + if err != nil { + return err + } + return xClient.Call(ctx, "Add", args, &reply) } type ArgsBrandEdit struct { @@ -59,7 +71,11 @@ type ArgsBrandEdit struct { // Edit @Title 编辑品牌 func (b *brand) Edit(ctx context.Context, args ArgsBrandEdit) (err error) { reply := 0 - return client.GetClient(b).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(b) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) } type ArgsBrandFindByIds struct { @@ -68,6 +84,10 @@ type ArgsBrandFindByIds struct { // FindByIds @Title 品牌获取 func (b *brand) FindByIds(ctx context.Context, args ArgsBrandFindByIds) (result []BrandItem, err error) { - err = client.GetClient(b).Call(ctx, "FindByIds", args, &result) + xClient, err := client.GetClient(b) + if err != nil { + return + } + err = xClient.Call(ctx, "FindByIds", args, &result) return } diff --git a/supply/category.go b/supply/category.go index d6673c2..0795cfc 100644 --- a/supply/category.go +++ b/supply/category.go @@ -17,7 +17,11 @@ type CategoryItem struct { // All @Title 获取分类 func (c *category) All(ctx context.Context) (result []CategoryItem, err error) { - err = client.GetClient(c).Call(ctx, "All", 0, &result) + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "All", 0, &result) return } @@ -29,7 +33,11 @@ type ArgsCategoryAdd struct { // Add @Title 添加分类 func (c *category) Add(ctx context.Context, args ArgsCategoryAdd) (err error) { reply := 0 - return client.GetClient(c).Call(ctx, "Add", args, &reply) + xClient, err := client.GetClient(c) + if err != nil { + return + } + return xClient.Call(ctx, "Add", args, &reply) } type ArgsCategoryEdit struct { @@ -41,7 +49,11 @@ type ArgsCategoryEdit struct { // Edit @Title 编辑分类 func (c *category) Edit(ctx context.Context, args ArgsCategoryEdit) (err error) { reply := 0 - return client.GetClient(c).Call(ctx, "Edit", args, &reply) + xClient, err := client.GetClient(c) + if err != nil { + return + } + return xClient.Call(ctx, "Edit", args, &reply) } type ArgsCategoryFindByIds struct { @@ -56,6 +68,10 @@ type ThirdCategoryItem struct { // FindByIds @Title 三级分类获取 func (c *category) FindByIds(ctx context.Context, args ArgsCategoryFindByIds) (result []ThirdCategoryItem, err error) { - err = client.GetClient(c).Call(ctx, "FindByIds", args, &result) + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "FindByIds", args, &result) return } diff --git a/supply/channel/order.go b/supply/channel/order.go index 2450dc5..f253939 100644 --- a/supply/channel/order.go +++ b/supply/channel/order.go @@ -27,7 +27,11 @@ type ReplyOrderFreightFee struct { // FreightFee @Title 获取运费 func (o *order) FreightFee(ctx context.Context, channelId string, args ArgsOrderFreightFee) (reply []ReplyOrderFreightFee, err error) { - err = client.GetClient(o).Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "FreightFee", args, &reply) + 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 } @@ -52,6 +56,10 @@ type ReplyOrderSubmit struct { // Submit @Title 下单 func (o *order) Submit(ctx context.Context, channelId string, args ArgsOrderSubmit) (reply []ReplyOrderSubmit, err error) { - err = client.GetClient(o).Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Submit", args, &reply) + 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/supply/channel/sku.go b/supply/channel/sku.go index a4af4e6..ee277f6 100644 --- a/supply/channel/sku.go +++ b/supply/channel/sku.go @@ -51,7 +51,11 @@ type ReplySkuList struct { // Lists @Title 商品列表 func (s *sku) Lists(ctx context.Context, channelId string, args ArgsSkuList) (reply ReplySkuList, err error) { - err = client.GetClient(s).Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Lists", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Lists", args, &reply) return } @@ -103,7 +107,11 @@ type SkuAttribute struct { // Details @Title 获取sku详情 func (s *sku) Details(ctx context.Context, channelId string, args ArgsSkuDetails) (reply []SkuDetailItem, err error) { - err = client.GetClient(s).Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Details", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Details", args, &reply) return } @@ -124,6 +132,10 @@ type ReplySkuStock struct { // Stock @Title 库存查询 func (s *sku) Stock(ctx context.Context, channelId string, args ArgsSkuStock) (reply []ReplySkuStock, err error) { - err = client.GetClient(s).Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Stock", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Stock", args, &reply) return } diff --git a/supply/setting/rate.go b/supply/setting/rate.go index bbde3c8..8ffb1fa 100644 --- a/supply/setting/rate.go +++ b/supply/setting/rate.go @@ -17,7 +17,11 @@ type RateItem struct { // All @Title 全部利率 func (r *rate) All(ctx context.Context) (result []RateItem, err error) { - err = client.GetClient(r).Call(ctx, "All", 0, &result) + xClient, err := client.GetClient(r) + if err != nil { + return + } + err = xClient.Call(ctx, "All", 0, &result) return } @@ -29,5 +33,9 @@ type ArgsRateChannel struct { // Channel @Title 设置渠道利率 func (r *rate) Channel(ctx context.Context, args ArgsRateChannel) error { reply := 0 - return client.GetClient(r).Call(ctx, "Channel", args, &reply) + xClient, err := client.GetClient(r) + if err != nil { + return err + } + return xClient.Call(ctx, "Channel", args, &reply) } diff --git a/supply/sku.go b/supply/sku.go index 24a0725..79ee92f 100644 --- a/supply/sku.go +++ b/supply/sku.go @@ -76,7 +76,11 @@ type SkuAttribute struct { // Add @Title 添加商品 func (s *sku) Add(ctx context.Context, args ArgsSkuAdd) error { reply := 0 - return client.GetClient(s).Call(ctx, "Add", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Add", args, &reply) } type ArgsSkuAdjust struct { @@ -89,7 +93,11 @@ type ArgsSkuAdjust struct { // Adjust @Title 加价 func (s *sku) Adjust(ctx context.Context, args ArgsSkuAdjust) error { reply := 0 - return client.GetClient(s).Call(ctx, "Adjust", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Adjust", args, &reply) } type ArgsSkuLists struct { @@ -143,7 +151,11 @@ type SkuItem struct { // Lists @Title 商品列表 func (s *sku) Lists(ctx context.Context, args ArgsSkuLists) (reply ReplySkuList, err error) { - err = client.GetClient(s).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -175,7 +187,11 @@ type SkuInfo struct { // Info @Title 商品信息 func (s *sku) Info(ctx context.Context, skuId uint) (reply SkuInfo, err error) { - err = client.GetClient(s).Call(ctx, "Info", skuId, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", skuId, &reply) return } @@ -190,13 +206,21 @@ type ArgsSkuDownShelves struct { // OnShelves @Title 上架 func (s *sku) OnShelves(ctx context.Context, args ArgsSkuOnShelves) error { reply := 0 - return client.GetClient(s).Call(ctx, "OnShelves", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "OnShelves", args, &reply) } // DownShelves @Title 下架 func (s *sku) DownShelves(ctx context.Context, args ArgsSkuDownShelves) error { reply := 0 - return client.GetClient(s).Call(ctx, "DownShelves", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "DownShelves", args, &reply) } type ArgsSkuAdjustType struct { @@ -209,5 +233,9 @@ type ArgsSkuAdjustType struct { // EditAdjust @Title 修改改价类型 func (s *sku) EditAdjust(ctx context.Context, args ArgsSkuAdjustType) error { reply := 0 - return client.GetClient(s).Call(ctx, "EditAdjust", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "EditAdjust", args, &reply) } diff --git a/supply/skuAudit.go b/supply/skuAudit.go index 6058a5f..5624d0b 100644 --- a/supply/skuAudit.go +++ b/supply/skuAudit.go @@ -53,7 +53,11 @@ type ReplySkuAuditLists struct { // Lists @Title 审核列表 func (s *skuAudit) Lists(ctx context.Context, args ArgsSkuAuditLists) (reply ReplySkuAuditLists, err error) { - err = client.GetClient(s).Call(ctx, "Lists", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) return } @@ -65,7 +69,11 @@ type ArgsSkuAuditAdopt struct { // Adopt @Title 通过 func (s *skuAudit) Adopt(ctx context.Context, args ArgsSkuAuditAdopt) error { reply := 0 - return client.GetClient(s).Call(ctx, "Adopt", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Adopt", args, &reply) } type ArgsSkuAuditReject struct { @@ -77,7 +85,11 @@ type ArgsSkuAuditReject struct { // Reject @Title 驳回 func (s *skuAudit) Reject(ctx context.Context, args ArgsSkuAuditReject) error { reply := 0 - return client.GetClient(s).Call(ctx, "Reject", args, &reply) + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Reject", args, &reply) } // Stock @Title 库存查询 From be1ab67e7f972749b28c57b57c9e668474ed8976 Mon Sep 17 00:00:00 2001 From: sian Date: Wed, 3 Aug 2022 10:12:49 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E6=9A=B4=E9=9C=B2service=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- customer/service.go | 6 ++++++ customer/service/audit.go | 7 +++++-- customer/service/audit/supply.go | 10 +++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/customer/service.go b/customer/service.go index 1712f31..dee26e8 100644 --- a/customer/service.go +++ b/customer/service.go @@ -1,5 +1,7 @@ package customer +import "git.oa00.com/supply-chain/service/customer/service" + type serviceId uint const ( @@ -10,3 +12,7 @@ const ( UserServiceStatusAdopt = 2 // 审核通过 UserServiceStatusReject = 3 // 审核驳回 ) + +type Service struct { + Audit service.Audit +} diff --git a/customer/service/audit.go b/customer/service/audit.go index 27ee3c6..e24a879 100644 --- a/customer/service/audit.go +++ b/customer/service/audit.go @@ -3,11 +3,14 @@ package service import ( "context" "git.oa00.com/supply-chain/service/client" + "git.oa00.com/supply-chain/service/customer/service/audit" "git.oa00.com/supply-chain/service/lib/bean" ) -type audit struct { +type Audit struct { + Supply audit.Supply } + type AuditSearch struct { Status uint // 审核状态 1=未审核 2=通过 3=驳回 Name string // 用户名称 @@ -33,7 +36,7 @@ type ReplyAuditLists struct { } // Lists @Title 服务审核列表 -func (a *audit) Lists(ctx context.Context, args ArgsAuditLists) (reply ReplyAuditLists, err error) { +func (a *Audit) Lists(ctx context.Context, args ArgsAuditLists) (reply ReplyAuditLists, err error) { err = client.GetClient(a).Call(ctx, "Lists", args, &reply) return } diff --git a/customer/service/audit/supply.go b/customer/service/audit/supply.go index 64c7891..56c145e 100644 --- a/customer/service/audit/supply.go +++ b/customer/service/audit/supply.go @@ -5,7 +5,7 @@ import ( "git.oa00.com/supply-chain/service/client" ) -type supply struct { +type Supply struct { } type ArgsSupplyApply struct { @@ -17,7 +17,7 @@ type ArgsSupplyApply struct { } // Apply @Title 申请 -func (s *supply) Apply(ctx context.Context, args ArgsSupplyApply) error { +func (s *Supply) Apply(ctx context.Context, args ArgsSupplyApply) error { reply := 0 return client.GetClient(s).Call(ctx, "Apply", args, &reply) } @@ -28,7 +28,7 @@ type ArgsSupplyAdopt struct { } // Adopt @Title 审核通过 -func (s *supply) Adopt(ctx context.Context, args ArgsSupplyAdopt) error { +func (s *Supply) Adopt(ctx context.Context, args ArgsSupplyAdopt) error { reply := 0 return client.GetClient(s).Call(ctx, "Adopt", args, &reply) } @@ -40,7 +40,7 @@ type ArgsSupplyReject struct { } // Reject @Title 驳回 -func (s *supply) Reject(ctx context.Context, args ArgsSupplyReject) error { +func (s *Supply) Reject(ctx context.Context, args ArgsSupplyReject) error { reply := 0 return client.GetClient(s).Call(ctx, "Reject", args, &reply) } @@ -62,7 +62,7 @@ type ReplySupplyInfo struct { } // Info @Title 详情 -func (s *supply) Info(ctx context.Context, userServiceId uint) (reply ReplySupplyInfo, err error) { +func (s *Supply) Info(ctx context.Context, userServiceId uint) (reply ReplySupplyInfo, err error) { err = client.GetClient(s).Call(ctx, "Info", userServiceId, &reply) return } From 015176e15f2ecca915dc8322e739975b2722d934 Mon Sep 17 00:00:00 2001 From: sian Date: Wed, 3 Aug 2022 10:46:36 +0800 Subject: [PATCH 03/12] bug fix --- supply/sku.go | 1 + 1 file changed, 1 insertion(+) diff --git a/supply/sku.go b/supply/sku.go index 79ee92f..500f3f5 100644 --- a/supply/sku.go +++ b/supply/sku.go @@ -57,6 +57,7 @@ type ArgsSkuAdd struct { Content string // 商品详情 Imgs []SkuImg // 商品图片 第一张主图 Specifications []SkuSpecification // 商品参数信息 + ImgUrl string // 商品主图 } type SkuImg struct { From f408b436a1586f5bdac0ce2fb8f623a62a631c51 Mon Sep 17 00:00:00 2001 From: kanade Date: Wed, 3 Aug 2022 11:20:25 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supply/sku.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/supply/sku.go b/supply/sku.go index 79ee92f..a279236 100644 --- a/supply/sku.go +++ b/supply/sku.go @@ -123,30 +123,30 @@ type SkuListsSearch struct { } type ReplySkuList struct { - Lists []SkuItem - Total int64 + Lists []SkuItem `json:"lists"` + Total int64 `json:"total"` } type SkuItem struct { - Id uint - Name string // 名称 - BrandName string // 品牌名称 - FirstCategoryId uint // 一级分类id - SecondCategoryId uint // 二级分类id - ThirdCategoryId uint // 三级分类id - SupplyPrice decimal.Decimal // 采购价 - GuidePrice decimal.Decimal // 指导价 - ImgUrl string // 商品主图 - PlatformStatus uint // 平台状态 1=上架 2=下架 - SourceName string // 供应商名称 - SourceSkuId string // 源skuId - SourceStatus uint // 供应商状态 1=上架 2=下架 - CustomerPrice decimal.Decimal // 供货最高价 - CustomerProfitRate decimal.Decimal // 供货利润率 供货利润/供货最高价% - AdjustType uint // 加价类型 - AdjustPrice decimal.Decimal // 加价金额 - Handle uint // 1=未处理 2=已处理 - Reason string // 驳回原因 + Id uint `json:"id"` + Name string `json:"name"` // 名称 + BrandName string `json:"brandName"` // 品牌名称 + FirstCategoryId uint `json:"firstCategoryId"` // 一级分类id + SecondCategoryId uint `json:"secondCategoryId"` // 二级分类id + ThirdCategoryId uint `json:"thirdCategoryId"` // 三级分类id + SupplyPrice decimal.Decimal `json:"supplyPrice"` // 采购价 + GuidePrice decimal.Decimal `json:"guidePrice"` // 指导价 + ImgUrl string `json:"imgUrl"` // 商品主图 + PlatformStatus uint `json:"platformStatus"` // 平台状态 1=上架 2=下架 + SourceName string `json:"sourceName"` // 供应商名称 + SourceSkuId string `json:"sourceSkuId"` // 源skuId + SourceStatus uint `json:"sourceStatus"` // 供应商状态 1=上架 2=下架 + CustomerPrice decimal.Decimal `json:"customerPrice"` // 供货最高价 + CustomerProfitRate decimal.Decimal `json:"customerProfitRate"` // 供货利润率 供货利润/供货最高价% + AdjustType uint `json:"adjustType"` // 加价类型 + AdjustPrice decimal.Decimal `json:"adjustPrice"` // 加价金额 + Handle uint `json:"handle"` // 1=未处理 2=已处理 + Reason string `json:"reason"` // 驳回原因 } // Lists @Title 商品列表 From 08afe3f664df675d721f602fbfb9573ba7c08d01 Mon Sep 17 00:00:00 2001 From: kanade Date: Wed, 3 Aug 2022 11:34:13 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- customer/customer.go | 5 ++++- customer/service/audit.go | 2 ++ customer/service/audit/audit.go | 5 +++++ customer/service/audit/supply.go | 6 +++--- customer/service/service.go | 5 +++++ 5 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 customer/service/audit/audit.go create mode 100644 customer/service/service.go diff --git a/customer/customer.go b/customer/customer.go index 2ce164f..aef31de 100644 --- a/customer/customer.go +++ b/customer/customer.go @@ -1,5 +1,8 @@ package customer +import "git.oa00.com/supply-chain/service/customer/service" + type Customer struct { - User user + User user + Service service.Service } diff --git a/customer/service/audit.go b/customer/service/audit.go index bb7bd49..553b5b1 100644 --- a/customer/service/audit.go +++ b/customer/service/audit.go @@ -3,10 +3,12 @@ package service import ( "context" "git.oa00.com/supply-chain/service/client" + audit2 "git.oa00.com/supply-chain/service/customer/service/audit" "git.oa00.com/supply-chain/service/lib/bean" ) type audit struct { + audit2.Audit } type AuditSearch struct { Status uint // 审核状态 1=未审核 2=通过 3=驳回 diff --git a/customer/service/audit/audit.go b/customer/service/audit/audit.go new file mode 100644 index 0000000..ccbd49d --- /dev/null +++ b/customer/service/audit/audit.go @@ -0,0 +1,5 @@ +package audit + +type Audit struct { + Supply supply +} diff --git a/customer/service/audit/supply.go b/customer/service/audit/supply.go index 821f006..368109e 100644 --- a/customer/service/audit/supply.go +++ b/customer/service/audit/supply.go @@ -9,7 +9,7 @@ type supply struct { } type ArgsSupplyApply struct { - ApplyId uint // 申请人id + ApplyUserId uint // 申请人id CustomerId uint // 客户id RateId uint // 费率id ExpirationAt int64 // 到期时间 @@ -27,7 +27,7 @@ func (s *supply) Apply(ctx context.Context, args ArgsSupplyApply) error { } type ArgsSupplyAdopt struct { - AuditId uint // 审核人id + AuditUserId uint // 审核人id UserServiceId uint // 客户服务id } @@ -42,7 +42,7 @@ func (s *supply) Adopt(ctx context.Context, args ArgsSupplyAdopt) error { } type ArgsSupplyReject struct { - AuditId uint // 审核人id + AuditUserId uint // 审核人id UserServiceId uint // 客户服务id Reason string // 驳回原因 } diff --git a/customer/service/service.go b/customer/service/service.go new file mode 100644 index 0000000..6a8ec8c --- /dev/null +++ b/customer/service/service.go @@ -0,0 +1,5 @@ +package service + +type Service struct { + Audit audit +} From c2710b480baf77a59651708c9f40d6f7f13bd6ee Mon Sep 17 00:00:00 2001 From: sian Date: Wed, 3 Aug 2022 14:15:07 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=B1=BB=E7=9B=AE?= =?UTF-8?q?=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd/category.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jd/category.go b/jd/category.go index 2aad24d..93d831e 100644 --- a/jd/category.go +++ b/jd/category.go @@ -63,3 +63,21 @@ func (c *category) Select(ctx context.Context) (reply []CategoryItem, err error) err = xClient.Call(ctx, "Select", args, &reply) return } + +type ArgsCategoryImport struct { + First string + Second string + Third string + SupplyCategoryId uint +} + +// Import @Title 导入 +func (*category) Import(ctx context.Context, args ArgsCategoryImport) (err error) { + reply := 0 + xClient, err := client.GetClient(ctx) + if err != nil { + return + } + err = xClient.Call(ctx, "Import", args, &reply) + return +} From 7f8cf737e4ed03b12acf7fb9bcb7ab141428b5bb Mon Sep 17 00:00:00 2001 From: sian Date: Wed, 3 Aug 2022 14:17:56 +0800 Subject: [PATCH 07/12] bug fix --- jd/category.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jd/category.go b/jd/category.go index 93d831e..54cf054 100644 --- a/jd/category.go +++ b/jd/category.go @@ -72,7 +72,7 @@ type ArgsCategoryImport struct { } // Import @Title 导入 -func (*category) Import(ctx context.Context, args ArgsCategoryImport) (err error) { +func (*category) Import(ctx context.Context, args []ArgsCategoryImport) (err error) { reply := 0 xClient, err := client.GetClient(ctx) if err != nil { From 87b6aebb791df7295dff96e584f84464623fef44 Mon Sep 17 00:00:00 2001 From: kanade Date: Wed, 3 Aug 2022 14:29:15 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supply/sku.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/supply/sku.go b/supply/sku.go index ddacfc0..7085a8e 100644 --- a/supply/sku.go +++ b/supply/sku.go @@ -240,3 +240,19 @@ func (s *sku) EditAdjust(ctx context.Context, args ArgsSkuAdjustType) error { } return xClient.Call(ctx, "EditAdjust", args, &reply) } + +type ArgsSkuReplaceImg struct { + SkuId uint // 商品id + ImgId uint // 图片id + ImgPath string // 图片路径 +} + +// ReplaceImg @Title 替换图片 +func (s *sku) ReplaceImg(ctx context.Context, args ArgsSkuReplaceImg) error { + reply := 0 + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "ReplaceImg", args, &reply) +} From 41cc917ed43848f610f4e0fed1823476793163e0 Mon Sep 17 00:00:00 2001 From: sian Date: Wed, 3 Aug 2022 14:37:20 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E7=B1=BB=E7=9B=AE=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd/category.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jd/category.go b/jd/category.go index 54cf054..d8477fe 100644 --- a/jd/category.go +++ b/jd/category.go @@ -81,3 +81,14 @@ func (*category) Import(ctx context.Context, args []ArgsCategoryImport) (err err err = xClient.Call(ctx, "Import", args, &reply) return } + +// Export @Title 导出 +func (*category) Export(ctx context.Context) (reply []ArgsCategoryImport, err error) { + args := 0 + xClient, err := client.GetClient(ctx) + if err != nil { + return + } + err = xClient.Call(ctx, "Export", args, &reply) + return +} From b920b708a67e6a19a12e711152527e3f193a8a97 Mon Sep 17 00:00:00 2001 From: sian Date: Wed, 3 Aug 2022 15:25:42 +0800 Subject: [PATCH 10/12] bug fix --- jd/category.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jd/category.go b/jd/category.go index d8477fe..0cd8685 100644 --- a/jd/category.go +++ b/jd/category.go @@ -82,8 +82,15 @@ func (*category) Import(ctx context.Context, args []ArgsCategoryImport) (err err return } +type ArgsCategoryExport struct { + First string + Second string + Third string + SupplyCategoryId uint +} + // Export @Title 导出 -func (*category) Export(ctx context.Context) (reply []ArgsCategoryImport, err error) { +func (*category) Export(ctx context.Context) (reply []ArgsCategoryExport, err error) { args := 0 xClient, err := client.GetClient(ctx) if err != nil { From 6cf82ee71b9a785819c9c358ea54804f7a5c00f0 Mon Sep 17 00:00:00 2001 From: sian Date: Wed, 3 Aug 2022 17:31:57 +0800 Subject: [PATCH 11/12] bug fix --- jd/category.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jd/category.go b/jd/category.go index 0cd8685..bbae089 100644 --- a/jd/category.go +++ b/jd/category.go @@ -72,9 +72,9 @@ type ArgsCategoryImport struct { } // Import @Title 导入 -func (*category) Import(ctx context.Context, args []ArgsCategoryImport) (err error) { +func (c *category) Import(ctx context.Context, args []ArgsCategoryImport) (err error) { reply := 0 - xClient, err := client.GetClient(ctx) + xClient, err := client.GetClient(c) if err != nil { return } @@ -90,9 +90,9 @@ type ArgsCategoryExport struct { } // Export @Title 导出 -func (*category) Export(ctx context.Context) (reply []ArgsCategoryExport, err error) { +func (c *category) Export(ctx context.Context) (reply []ArgsCategoryExport, err error) { args := 0 - xClient, err := client.GetClient(ctx) + xClient, err := client.GetClient(c) if err != nil { return } From 36b86eb167b8edd3d06f67b86a8bc9203819a855 Mon Sep 17 00:00:00 2001 From: kanade Date: Thu, 4 Aug 2022 09:29:56 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd/sku.go | 34 ++++++++++++++++++++++++++++++++++ supply/sku.go | 16 ---------------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/jd/sku.go b/jd/sku.go index b40e03d..63f5111 100644 --- a/jd/sku.go +++ b/jd/sku.go @@ -119,6 +119,24 @@ func (s *sku) GetImgs(ctx context.Context, skuId uint) (reply []SkuImg, err erro return } +type SkusImg struct { + Id uint `json:"id"` + SkuId uint `json:"skuId"` + Path string `json:"path"` + ReplacePath string `json:"replacePath"` + Sort uint `json:"sort"` +} + +// GetSkusImgs @Title 批量获取预览图 +func (s *sku) GetSkusImgs(ctx context.Context, skuId uint) (reply []SkusImg, err error) { + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "GetSkusImgs", skuId, &reply) + return +} + type SkuSpecification struct { Name string `json:"name"` Attributes []SkuAttribute `json:"attributes"` @@ -188,3 +206,19 @@ func (s *sku) Adopt(ctx context.Context, skuIds []uint) (reply []AdoptItem, err err = xClient.Call(ctx, "Adopt", skuIds, &reply) return } + +type ArgsSkuReplaceImg struct { + SkuId uint // 商品id + ImgId uint // 图片id + ImgPath string // 图片路径 +} + +// ReplaceImg @Title 替换图片 +func (s *sku) ReplaceImg(ctx context.Context, args ArgsSkuReplaceImg) error { + reply := 0 + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "ReplaceImg", args, &reply) +} diff --git a/supply/sku.go b/supply/sku.go index 7085a8e..ddacfc0 100644 --- a/supply/sku.go +++ b/supply/sku.go @@ -240,19 +240,3 @@ func (s *sku) EditAdjust(ctx context.Context, args ArgsSkuAdjustType) error { } return xClient.Call(ctx, "EditAdjust", args, &reply) } - -type ArgsSkuReplaceImg struct { - SkuId uint // 商品id - ImgId uint // 图片id - ImgPath string // 图片路径 -} - -// ReplaceImg @Title 替换图片 -func (s *sku) ReplaceImg(ctx context.Context, args ArgsSkuReplaceImg) error { - reply := 0 - xClient, err := client.GetClient(s) - if err != nil { - return err - } - return xClient.Call(ctx, "ReplaceImg", args, &reply) -}