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/supplier/goods.go

167 lines
4.4 KiB

2 years ago
package supplier
2 years ago
import (
"context"
"git.oa00.com/supply-chain/service/client"
"git.oa00.com/supply-chain/service/lib/bean"
"github.com/shopspring/decimal"
)
2 years ago
type goods struct {
2 years ago
}
type GoodsSearch struct {
2 years ago
Name string // 商品名称
CategoryId uint64 // 类目id
BrandName string // 品牌名
2 years ago
Handle uint // 处理状态 1=待处理 2=入库 3=废弃
2 years ago
}
type ArgsGoodsList struct {
Search GoodsSearch
Page bean.Page
}
type GoodsItem struct {
2 years ago
Id uint `json:"id"`
Name string `json:"name"`
Img string `json:"img"`
GoodsNum string `json:"goodsNum"`
CategoryId uint `json:"categoryId"`
BrandId uint `json:"brandId"`
BrandName string `json:"brandName"`
SkuItems []GoodsItemLists `json:"skuItems"`
StockCount uint `json:"stockCount"`
MinPrice decimal.Decimal `json:"minPrice"`
CreatedAt int64 `json:"createdAt"`
2 years ago
}
type GoodsItemLists struct {
Id uint `json:"id"`
Specifications []SkuSpecificationItem `json:"specifications"`
Stock uint `json:"stock"`
SupplyPrice decimal.Decimal `json:"supplyPrice"`
GoodsId uint `json:"goodsId"`
Img string `json:"img"`
}
type GoodsSpecificationItem struct {
Name string `json:"name"`
Values []string `json:"values"`
}
type SkuSpecificationItem struct {
Name string `json:"name"`
Value string `json:"value"`
}
type ReplyGoodsLists struct {
List []GoodsItem `json:"list"`
Total int64 `json:"total"`
}
// Lists @Title 获取商品列表
2 years ago
func (g *goods) Lists(ctx context.Context, args ArgsGoodsList) (reply ReplyGoodsLists, err error) {
xClient, err := client.GetClient(g)
2 years ago
if err != nil {
return
}
err = xClient.Call(ctx, "Lists", args, &reply)
return
}
2 years ago
type ArgsGoodsInfo struct {
SkuId uint
}
2 years ago
type ReplyGoodsInfo struct {
2 years ago
Id uint `json:"id"`
Name string `json:"name"`
SupplierId uint `json:"supplierId"`
CategoryId uint `json:"categoryId"`
BrandId uint `json:"brandId"`
Imgs []string `json:"imgs"`
Content string `json:"content"`
Attributes []GoodsAttributeItem `json:"attributes"`
Skus []SkuItem `json:"skus"`
Status uint `json:"status"`
2 years ago
}
type GoodsAttributeItem struct {
2 years ago
Name string `json:"name"`
Value string `json:"value"`
GroupName string `json:"groupName"`
2 years ago
}
type SkuSpecItem struct {
Name string `json:"name"`
Value string `json:"value"`
}
type SkuItem struct {
Color string `json:"color"`
Size string `json:"size"`
SupplyPrice decimal.Decimal `json:"supplyPrice"`
MarketPrice decimal.Decimal `json:"marketPrice"`
UpcCode string `json:"upcCode"`
UintId uint `json:"uintId"`
TaxCategoryId uint `json:"taxCategoryId"`
Tax decimal.Decimal `json:"tax"`
2 years ago
}
2 years ago
// Info @Title 商品详情
2 years ago
func (g *goods) Info(ctx context.Context, goodsId uint) (reply ReplyGoodsInfo, err error) {
2 years ago
xClient, err := client.GetClient(g)
if err != nil {
return
}
2 years ago
err = xClient.Call(ctx, "Info", goodsId, &reply)
2 years ago
return
}
2 years ago
// GetImgs @Title 获取商品主图
func (g *goods) GetImgs(ctx context.Context, goodsId uint) (reply []string, err error) {
xClient, err := client.GetClient(g)
if err != nil {
return
}
err = xClient.Call(ctx, "GetImgs", goodsId, &reply)
return
}
2 years ago
type AdoptItem struct {
Id uint `json:"id"`
GoodsNum string `json:"goodsNum"`
Name string `json:"name"`
Error string `json:"error"`
}
// Adopt @Title 批量入库
func (g *goods) Adopt(ctx context.Context, goodsIds []uint) (reply []AdoptItem, err error) {
2 years ago
xClient, err := client.GetClient(g)
if err != nil {
return
}
err = xClient.Call(ctx, "Adopt", goodsIds, &reply)
return
2 years ago
}
// Discard @Title 批量废弃
2 years ago
func (g *goods) Discard(ctx context.Context, goodsIds []uint) (err error) {
2 years ago
xClient, err := client.GetClient(g)
if err != nil {
return
}
2 years ago
reply := 0
err = xClient.Call(ctx, "Discard", goodsIds, &reply)
return
2 years ago
}
// ReHandle @Title 重新处理商品
func (g *goods) ReHandle(ctx context.Context, skuId uint) error {
reply := 0
xClient, err := client.GetClient(g)
if err != nil {
return err
}
return xClient.Call(ctx, "ReHandle", skuId, &reply)
}