渠道接口

finance
杨赟 2 years ago
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,237 @@
package channel
import (
"context"
"git.oa00.com/supply-chain/service/client"
"git.oa00.com/supply-chain/service/lib/bean"
"github.com/shopspring/decimal"
"github.com/smallnest/rpcx/share"
)
type sku struct {
}
type SkuSearch struct {
Status uint // 1=上架 2=下架
SkuName string // 商品名称
}
type ArgsSkuList struct {
Search SkuSearch
Page bean.Page
}
type SkuItem struct {
Id uint `json:"id"`
Name string `json:"name"`
BrandId uint `json:"brandId"`
BrandName string `json:"brandName"`
FirstCategoryId uint `json:"firstCategoryId"`
FirstCategoryName string `json:"firstCategoryName"`
SecondCategoryId uint `json:"secondCategoryId"`
SecondCategoryName string `json:"secondCategoryName"`
ThirdCategoryId uint `json:"thirdCategoryId"`
ThirdCategoryName string `json:"thirdCategoryName"`
Price decimal.Decimal `json:"price"`
Discount decimal.Decimal `json:"discount"`
GuidePrice decimal.Decimal `json:"guidePrice"`
ImgUrl string `json:"imgUrl"`
Profit decimal.Decimal `json:"profit"`
Size string `json:"size"`
Color string `json:"color"`
Tax string `json:"tax"`
Unit string `json:"unit"`
UpcCode string `json:"upcCode"`
TaxName string `json:"taxName"`
TaxCode string `json:"taxCode"`
Status uint `json:"status"`
Length decimal.Decimal `json:"length"` // 长
Width decimal.Decimal `json:"width"` // 宽
Height decimal.Decimal `json:"height"` // 高
Weight decimal.Decimal `json:"weight"` // 重
PackingRate uint `json:"packingRate"` // 装箱率
StartingBatch uint `json:"startingBatch"` // 起批量
InitialFreight decimal.Decimal `json:"initialFreight"` // 起批运费
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
}
type ReplySkuList struct {
Lists []SkuItem `json:"lists"`
Total int64 `json:"total"`
}
// Lists @Title 商品列表
func (s *sku) Lists(ctx context.Context, channelId string, args ArgsSkuList) (reply ReplySkuList, err error) {
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
}
type SkuEsSearch struct {
SkuIds []uint // 商品SkuIds
Status uint // 1=上架 2=下架
SkuName string // 商品名称
BrandId uint // 品牌id
BrandName string // 品牌名称 全词匹配
FirstCategoryId uint // 一级分类id
FirstCategoryName string // 一级分类名称 全词匹配
SecondCategoryId uint // 二级分类id
SecondCategoryName string // 二级分类名称 全词匹配
ThirdCategoryId uint // 三级分类id
ThirdCategoryName string // 三级分类名称 全词匹配
MaxPrice decimal.Decimal // 最高金额
MinPrice decimal.Decimal // 最低金额
MinDiscount decimal.Decimal // 最低折扣
MaxDiscount decimal.Decimal // 最高折扣
Expand []map[string]interface{} // 拓展查询
}
type ArgsSkuListsEs struct {
Search SkuEsSearch
Page bean.Page
}
// ListsEs @Title es商品列表 目前最大10000条数据超出不显示
func (s *sku) ListsEs(ctx context.Context, channelId string, args ArgsSkuListsEs) (reply ReplySkuList, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "ListsEs", args, &reply)
return
}
type ArgsSkuDetails struct {
SkuIds []uint // sku数组
}
type SkuDetailItem struct {
Id uint `json:"id"`
Name string `json:"name"`
BrandId uint `json:"brandId"`
BrandName string `json:"brandName"`
FirstCategoryId uint `json:"firstCategoryId"`
FirstCategoryName string `json:"firstCategoryName"`
SecondCategoryId uint `json:"secondCategoryId"`
SecondCategoryName string `json:"secondCategoryName"`
ThirdCategoryId uint `json:"thirdCategoryId"`
ThirdCategoryName string `json:"thirdCategoryName"`
Price decimal.Decimal `json:"price"`
GuidePrice decimal.Decimal `json:"guidePrice"`
ImgUrl string `json:"imgUrl"`
Profit decimal.Decimal `json:"profit"`
Size string `json:"size"`
Color string `json:"color"`
Tax string `json:"tax"`
Unit string `json:"unit"`
UpcCode string `json:"upcCode"`
TaxName string `json:"taxName"`
TaxCode string `json:"taxCode"`
Status uint `json:"status"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
Content string `json:"content"`
Imgs []SkuImg `json:"imgs"`
Specifications []SkuSpecification `json:"specifications"`
GroupSkuIds []uint `json:"groupSkuIds"`
Length decimal.Decimal `json:"length"` // 长
Width decimal.Decimal `json:"width"` // 宽
Height decimal.Decimal `json:"height"` // 高
Weight decimal.Decimal `json:"weight"` // 重
PackingRate uint `json:"packingRate"` // 装箱率
StartingBatch uint `json:"startingBatch"` // 起批量
InitialFreight decimal.Decimal `json:"initialFreight"` // 起批运费
}
type SkuImg struct {
Path string `json:"path"`
}
type SkuSpecification struct {
Name string `json:"name"`
Attributes []SkuAttribute `json:"attributes"`
}
type SkuAttribute struct {
Name string `json:"name"`
Value []string `json:"value"`
}
// Details @Title 获取sku详情
func (s *sku) Details(ctx context.Context, channelId string, args ArgsSkuDetails) (reply []SkuDetailItem, err error) {
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
}
type ArgsSkuPrices struct {
SkuIds []uint // sku数组
}
type SkuPrice struct {
Id uint `json:"id"`
Name string `json:"name"`
Price decimal.Decimal `json:"price"`
GuidePrice decimal.Decimal `json:"guidePrice"`
Profit decimal.Decimal `json:"profit"`
Status uint `json:"status"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
}
// Prices @Title 获取sku价格
func (s *sku) Prices(ctx context.Context, channelId string, args ArgsSkuPrices) (reply []SkuPrice, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Prices", args, &reply)
return
}
type ArgsSkuGroups struct {
SkuIds []uint // sku数组
}
type SkuGroup struct {
SkuId uint `json:"skuId"`
GroupSkuIds []uint `json:"groupSkuIds"`
}
// Groups @Title 获取sku分组信息
func (s *sku) Groups(ctx context.Context, channelId string, args ArgsSkuGroups) (reply []SkuGroup, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Groups", args, &reply)
return
}
type ArgsSkuStock struct {
Address string // 地址
Skus []SkuStockItem // sku信息
}
type SkuStockItem struct {
SkuId uint // skuId
Quantity uint // 数量
}
type ReplySkuStock struct {
SkuId uint `json:"skuId"` // skuId
State uint `json:"state"` // 库存状态
}
// Stock @Title 库存查询
func (s *sku) Stock(ctx context.Context, channelId string, args ArgsSkuStock) (reply []ReplySkuStock, err error) {
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
}

@ -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…
Cancel
Save