From d89ac6af57d2908797c6909b2fd2ace08d947942 Mon Sep 17 00:00:00 2001 From: kanade Date: Wed, 27 Jul 2022 15:23:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B8=A0=E9=81=93=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client.go | 8 ++--- supply/channel/channel.go | 5 +++ supply/channel/order.go | 56 +++++++++++++++++++++++++++++ supply/{customer => channel}/sku.go | 11 +++--- supply/customer/customer.go | 5 --- supply/supply.go | 4 +-- 6 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 supply/channel/channel.go create mode 100644 supply/channel/order.go rename supply/{customer => channel}/sku.go (96%) delete mode 100644 supply/customer/customer.go diff --git a/client/client.go b/client/client.go index 105e776..0fe95e9 100644 --- a/client/client.go +++ b/client/client.go @@ -56,15 +56,13 @@ func GetClient(s interface{}) client.XClient { // GetClientName @Title 根据服务名获取客户端 func GetClientName(base, service string) client.XClient { - key := fmt.Sprintf("%s.%s", base, service) + key := fmt.Sprintf("%s/%s", base, service) xClient, ok := mClient.Load(key) if !ok { mutex.Lock() xClient, ok = mClient.Load(key) if !ok { - servicePath := strings.ToUpper(service[0:1]) + service[1:] - - d, err := client.NewConsulDiscovery(base, servicePath, config.RpcConfig.RegistryServer, nil) + d, err := client.NewConsulDiscovery(base, service, config.RpcConfig.RegistryServer, nil) if err != nil { log.Println(err) return nil @@ -74,7 +72,7 @@ func GetClientName(base, service string) client.XClient { option.GenBreaker = func() client.Breaker { return client.NewConsecCircuitBreaker(2, 30*time.Second) } - xClient = client.NewXClient(servicePath, client.Failover, client.RoundRobin, d, option) + xClient = client.NewXClient(service, client.Failover, client.RoundRobin, d, option) mClient.Store(key, xClient) } mutex.Unlock() diff --git a/supply/channel/channel.go b/supply/channel/channel.go new file mode 100644 index 0000000..2bf7c0a --- /dev/null +++ b/supply/channel/channel.go @@ -0,0 +1,5 @@ +package channel + +type Channel struct { + Sku sku +} diff --git a/supply/channel/order.go b/supply/channel/order.go new file mode 100644 index 0000000..871f15b --- /dev/null +++ b/supply/channel/order.go @@ -0,0 +1,56 @@ +package channel + +import ( + "context" + "git.oa00.com/supply-chain/service/client" + "github.com/shopspring/decimal" +) + +type order struct { +} +type ArgsOrderFreightFee struct { + Address string // 地址 + Skus []SkuFreightFeeItem // sku信息 +} + +type SkuFreightFeeItem struct { + SkuId uint // skuId + Price decimal.Decimal // 价格 + Quantity uint // 数量 +} + +type ReplyOrderFreightFee struct { + SkuIds []uint `json:"skuIds"` + FreightFee decimal.Decimal `json:"freightFee"` +} + +// FreightFee @Title 获取运费 +func (o *order) FreightFee(ctx context.Context, args ArgsOrderFreightFee) (reply []ReplyOrderFreightFee, err error) { + err = client.GetClient(o).Call(ctx, "FreightFee", args, &reply) + return +} + +type ArgsOrderSubmit struct { + Address string // 地址 + Skus []SkuFreightFeeItem // sku信息 + Receiver Receiver // 收件信息 + OrderFee decimal.Decimal // 订单金额-不含运费 + FreightFee decimal.Decimal // 运费 + UserIp string // 下单用户ip +} + +type Receiver struct { + Name string // 姓名 + Mobile string // 手机号 + Email string // 邮箱 + ZipCode string // 邮编 +} + +type ReplyOrderSubmit struct { +} + +// Submit @Title 下单 +func (o *order) Submit(ctx context.Context, args ArgsOrderSubmit) (reply []ReplyOrderSubmit, err error) { + err = client.GetClient(o).Call(ctx, "Submit", args, &reply) + return +} diff --git a/supply/customer/sku.go b/supply/channel/sku.go similarity index 96% rename from supply/customer/sku.go rename to supply/channel/sku.go index bd90352..63f4d1f 100644 --- a/supply/customer/sku.go +++ b/supply/channel/sku.go @@ -1,4 +1,4 @@ -package customer +package channel import ( "context" @@ -15,9 +15,8 @@ type SkuSearch struct { SkuName string // 商品名称 } type ArgsSkuList struct { - CustomerId uint // 客户id - Search SkuSearch - Page bean.Page + Search SkuSearch + Page bean.Page } type SkuItem struct { @@ -56,8 +55,7 @@ func (s *sku) Lists(ctx context.Context, args ArgsSkuList) (reply ReplySkuList, } type ArgsSkuDetails struct { - CustomerId uint // 客户id - SkuIds []uint // sku数组 + SkuIds []uint // sku数组 } type SkuDetailItem struct { @@ -86,6 +84,7 @@ type SkuDetailItem struct { Content string `json:"content"` Imgs []SkuImg `json:"imgs"` Specifications []SkuSpecification `json:"specifications"` + GroupSkuIds []uint `json:"groupSkuIds"` } type SkuImg struct { Path string `json:"path"` diff --git a/supply/customer/customer.go b/supply/customer/customer.go deleted file mode 100644 index 1e7b1a0..0000000 --- a/supply/customer/customer.go +++ /dev/null @@ -1,5 +0,0 @@ -package customer - -type Customer struct { - Sku sku -} diff --git a/supply/supply.go b/supply/supply.go index a05ae9f..e5219f1 100644 --- a/supply/supply.go +++ b/supply/supply.go @@ -1,11 +1,11 @@ package supply -import "git.oa00.com/supply-chain/service/supply/customer" +import "git.oa00.com/supply-chain/service/supply/channel" type Supply struct { Brand brand Category category Sku sku SkuAudit skuAudit - Customer customer.Customer + Channel channel.Channel }