You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
service/supply/channel/mq.go

66 lines
2.1 KiB

2 years ago
package channel
import (
"context"
"git.oa00.com/supply-chain/service/client"
"github.com/smallnest/rpcx/share"
)
2 years ago
const (
2 years ago
MqSubscribeNameSkuPriceChange = "sku_price_change" // sku价格变动
MqSubscribeNameSkuChange = "sku_change" // sku信息变动
MqSubscribeNameOrderSplit = "order_split" // 订单拆单
MqSubscribeNameOrderStockOut = "order_stock_out" // 订单出库
9 months ago
MqSubscribeNameOrderDelivered = "order_delivered" // 订单签收
2 years ago
MqSubscribeNameOrderFinish = "order_finish" // 订单完成
MqSubscribeNameOrderCancel = "order_cancel" // 订单取消
2 years ago
MqSubscribeNameAfsDeliver = "afs_deliver" // 需要客户发货
MqSubscribeNameAfsWait = "afs_wait" // 等待收货处理
MqSubscribeNameAfsClose = "afs_close" // 售后关闭
MqSubscribeNameAfsFinish = "afs_finish" // 售后完成
2 years ago
)
2 years ago
type mq struct {
}
type ArgsMqSubscribe struct {
2 years ago
Name string // 队列名称
AppKey string // 队列名称
2 years ago
}
// Subscribe @Title 订阅mq
2 years ago
func (m *mq) Subscribe(ctx context.Context, channelId string, args ArgsMqSubscribe) (key string, err error) {
2 years ago
xClient, err := client.GetClient(m)
if err != nil {
return
}
2 years ago
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Subscribe", args, &key)
2 years ago
return
}
2 years ago
// 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
}