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/skycrane/sku.go

192 lines
6.3 KiB

7 months ago
package skycrane
import (
"context"
"git.oa00.com/supply-chain/service/client"
"git.oa00.com/supply-chain/service/lib/bean"
"github.com/shopspring/decimal"
)
const (
SkuStatusNone = 1 // 待处理
SkuStatusAdopt = 2 // 同步入库
SkuStatusReject = 3 // 废弃商品
)
type sku struct {
}
type SkuSearch struct {
Status int // 状态
Name string // 商品名称
Code string // sku编码
CategoryId int64 // 类目id
BrandName string // 品牌
MinSupplyPrice decimal.Decimal // 采购价最小
MaxSupplyPrice decimal.Decimal // 采购价最大
}
type ArgsSkuList struct {
Search SkuSearch
Page bean.Page
}
type SkuItem struct {
Id int64 `json:"id"`
Name string `json:"name"`
Code string `json:"code"`
MainPhoto string `json:"mainPhoto"`
BrandName string `json:"brandName"`
FirstCategoryName string `json:"firstCategoryName"`
SecondCategoryName string `json:"secondCategoryName"`
ThirdCategoryName string `json:"thirdCategoryName"`
SupplyPrice decimal.Decimal `json:"supplyPrice"`
GuidePrice decimal.Decimal `json:"guidePrice"`
ShelvesStatus int64 `json:"shelvesStatus"`
Status int64 `json:"status"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
MateBrandId int64 `json:"mateBrandId"`
MateCategoryId int64 `json:"mateCategoryId"`
}
type ReplySkuList struct {
Lists []SkuItem `json:"lists"`
Total int64 `json:"total"`
}
// List @Title 商品列表
func (s *sku) List(ctx context.Context, args ArgsSkuList) (reply ReplySkuList, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
xClient.Call(ctx, "List", args, &reply)
return
}
type SkuImg struct {
Id int64 `json:"id"`
Path string `json:"path"`
ReplacePath string `json:"replacePath"`
}
// Imgs @Title 获取预览图
func (s *sku) Imgs(ctx context.Context, skuId int64) (reply []SkuImg, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "Imgs", skuId, &reply)
return
}
type ReplySkuInfo struct {
Id int64 `json:"id"`
GoodsCode string `json:"goodsCode"`
GoodsName string `json:"goodsName"`
Code string `json:"code"`
Name string `json:"name"`
Title string `json:"title"`
SellPrice decimal.Decimal `json:"sellPrice"`
MarketPrice decimal.Decimal `json:"marketPrice"`
StartQty int64 `json:"startQty"`
ShelvesStatus int64 `json:"shelvesStatus"`
TaxCode string `json:"taxCode"`
TaxRate decimal.Decimal `json:"taxRate"`
BarCode string `json:"barCode"`
IsDeleted int64 `json:"isDeleted"`
BrandId int64 `json:"brandId"`
BrandCode string `json:"brandCode"`
BrandName string `json:"brandName"`
CategoryId int64 `json:"categoryId"`
FirstCategoryCode string `json:"firstCategoryCode"`
FirstCategoryName string `json:"firstCategoryName"`
SecondCategoryCode string `json:"secondCategoryCode"`
SecondCategoryName string `json:"secondCategoryName"`
ThirdCategoryCode string `json:"thirdCategoryCode"`
ThirdCategoryName string `json:"thirdCategoryName"`
ReturnGoodsRules int64 `json:"returnGoodsRules"`
GoodsCharacteristic string `json:"goodsCharacteristic"`
GoodsUnit string `json:"goodsUnit"`
ModelNumber string `json:"modelNumber"`
ProductPlace string `json:"productPlace"`
HaveShelfLife int64 `json:"haveShelfLife"`
ShelfLife string `json:"shelfLife"`
FragileGoods int64 `json:"fragileGoods"`
GrossWeight decimal.Decimal `json:"grossWeight"`
GrossWeightUnit string `json:"grossWeightUnit"`
Density decimal.Decimal `json:"density"`
Extent decimal.Decimal `json:"extent"`
Width decimal.Decimal `json:"width"`
Height decimal.Decimal `json:"height"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
MateBrandId int64 `json:"mateBrandId"`
MateCategoryId int64 `json:"mateCategoryId"`
Content string `json:"content"`
Imgs []SkuImg `json:"imgs"`
Attributes []SkuAttribute `json:"attributes"`
Specs []SkuSpec `json:"specs"`
}
type SkuAttribute struct {
Id int64 `json:"id"`
Name string `json:"name"`
Value string `json:"value"`
}
type SkuSpec struct {
Id int64 `json:"id"`
Name string `json:"name"`
Value string `json:"value"`
}
// Info @Title 获取详情
func (s *sku) Info(ctx context.Context, skuId int64) (reply ReplySkuInfo, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "Info", skuId, &reply)
return
}
type ArgsSkuReplaceImg struct {
SkuId int64 // 商品id
ImgId int64 // 图片id
ImgPath string // 图片路径
}
// ReplaceImg @Title 替换图片
func (s *sku) ReplaceImg(ctx context.Context, args ArgsSkuReplaceImg) error {
reply := 0
xClient, err := client.GetClient(s)
if err != nil {
return err
}
return xClient.Call(ctx, "ReplaceImg", args, &reply)
}
type AdoptItem struct {
Id int64 `json:"id"`
Code string `json:"code"`
Name string `json:"name"`
Error string `json:"error"`
}
// Adopt @Title 入库
func (s *sku) Adopt(ctx context.Context, skuIds []int64) (reply []AdoptItem, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "Adopt", skuIds, &reply)
return
}
// Discard @Title 废弃
func (s *sku) Discard(ctx context.Context, skuIds []int64) error {
reply := 0
xClient, err := client.GetClient(s)
if err != nil {
return err
}
return xClient.Call(ctx, "Discard", skuIds, &reply)
}