parent
2a61e52c5e
commit
f2565707e4
@ -0,0 +1,6 @@
|
||||
package channel
|
||||
|
||||
type Channel struct {
|
||||
Sku sku
|
||||
Mq mq
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package channel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.oa00.com/supply-chain/service/client"
|
||||
"github.com/smallnest/rpcx/share"
|
||||
)
|
||||
|
||||
const (
|
||||
MqSubscribeNameSkuPriceChange = "sku_price_change" // sku价格变动
|
||||
MqSubscribeNameSkuChange = "sku_change" // sku信息变动
|
||||
)
|
||||
|
||||
type mq struct {
|
||||
}
|
||||
type ArgsMqSubscribe struct {
|
||||
Name string // 队列名称
|
||||
AppKey string // 队列名称
|
||||
}
|
||||
|
||||
// Subscribe @Title 订阅mq
|
||||
func (m *mq) Subscribe(ctx context.Context, channelId string, args ArgsMqSubscribe) (key string, err error) {
|
||||
xClient, err := client.GetClient(m)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Subscribe", args, &key)
|
||||
return
|
||||
}
|
||||
|
||||
// SubscribeCancel @Title 订阅取消
|
||||
func (m *mq) SubscribeCancel(ctx context.Context, channelId string, args ArgsMqSubscribe) (err error) {
|
||||
reply := 0
|
||||
xClient, err := client.GetClient(m)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "SubscribeCancel", args, &reply)
|
||||
return
|
||||
}
|
||||
|
||||
type ArgsMqUser struct {
|
||||
AppKey string
|
||||
AppSecret string
|
||||
}
|
||||
|
||||
// User @Title Mq用户
|
||||
func (m *mq) User(ctx context.Context, channelId string, args ArgsMqUser) (err error) {
|
||||
reply := 0
|
||||
xClient, err := client.GetClient(m)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "User", args, &reply)
|
||||
return
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package _interface
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type skuState uint
|
||||
|
||||
const (
|
||||
SkuStateIn = 1 // 有货
|
||||
SkuStateOut = 2 // 无货
|
||||
SkuStateDone = 3 // 下架商品
|
||||
)
|
||||
|
||||
type Sku interface {
|
||||
// Stock 库存查询
|
||||
Stock(ctx context.Context, args ArgsSkuStock, reply *[]ReplySkuStock) error
|
||||
}
|
||||
|
||||
type ArgsSkuStock struct {
|
||||
Address string // 地址
|
||||
Skus []SkuStockItem // sku信息
|
||||
}
|
||||
|
||||
type SkuStockItem struct {
|
||||
SourceSkuId string // 源skuId
|
||||
Quantity uint // 数量
|
||||
}
|
||||
type ReplySkuStock struct {
|
||||
SourceSkuId string `json:"sourceSkuId"` // 源skuId
|
||||
State uint `json:"state"` // 库存状态
|
||||
}
|
Loading…
Reference in new issue