更新渠道接口

finance
杨赟 2 years ago
parent 9c5ff3d82f
commit d89ac6af57

@ -56,15 +56,13 @@ func GetClient(s interface{}) client.XClient {
// GetClientName @Title 根据服务名获取客户端 // GetClientName @Title 根据服务名获取客户端
func GetClientName(base, service string) client.XClient { 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) xClient, ok := mClient.Load(key)
if !ok { if !ok {
mutex.Lock() mutex.Lock()
xClient, ok = mClient.Load(key) xClient, ok = mClient.Load(key)
if !ok { if !ok {
servicePath := strings.ToUpper(service[0:1]) + service[1:] d, err := client.NewConsulDiscovery(base, service, config.RpcConfig.RegistryServer, nil)
d, err := client.NewConsulDiscovery(base, servicePath, config.RpcConfig.RegistryServer, nil)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
return nil return nil
@ -74,7 +72,7 @@ func GetClientName(base, service string) client.XClient {
option.GenBreaker = func() client.Breaker { option.GenBreaker = func() client.Breaker {
return client.NewConsecCircuitBreaker(2, 30*time.Second) 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) mClient.Store(key, xClient)
} }
mutex.Unlock() mutex.Unlock()

@ -0,0 +1,5 @@
package channel
type Channel struct {
Sku sku
}

@ -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
}

@ -1,4 +1,4 @@
package customer package channel
import ( import (
"context" "context"
@ -15,7 +15,6 @@ type SkuSearch struct {
SkuName string // 商品名称 SkuName string // 商品名称
} }
type ArgsSkuList struct { type ArgsSkuList struct {
CustomerId uint // 客户id
Search SkuSearch Search SkuSearch
Page bean.Page Page bean.Page
} }
@ -56,7 +55,6 @@ func (s *sku) Lists(ctx context.Context, args ArgsSkuList) (reply ReplySkuList,
} }
type ArgsSkuDetails struct { type ArgsSkuDetails struct {
CustomerId uint // 客户id
SkuIds []uint // sku数组 SkuIds []uint // sku数组
} }
@ -86,6 +84,7 @@ type SkuDetailItem struct {
Content string `json:"content"` Content string `json:"content"`
Imgs []SkuImg `json:"imgs"` Imgs []SkuImg `json:"imgs"`
Specifications []SkuSpecification `json:"specifications"` Specifications []SkuSpecification `json:"specifications"`
GroupSkuIds []uint `json:"groupSkuIds"`
} }
type SkuImg struct { type SkuImg struct {
Path string `json:"path"` Path string `json:"path"`

@ -1,5 +0,0 @@
package customer
type Customer struct {
Sku sku
}

@ -1,11 +1,11 @@
package supply package supply
import "git.oa00.com/supply-chain/service/supply/customer" import "git.oa00.com/supply-chain/service/supply/channel"
type Supply struct { type Supply struct {
Brand brand Brand brand
Category category Category category
Sku sku Sku sku
SkuAudit skuAudit SkuAudit skuAudit
Customer customer.Customer Channel channel.Channel
} }

Loading…
Cancel
Save