diff --git a/otosaas/category.go b/otosaas/category.go new file mode 100644 index 0000000..40c7869 --- /dev/null +++ b/otosaas/category.go @@ -0,0 +1,62 @@ +package otosaas + +import ( + "context" + "git.oa00.com/supply-chain/service/client" + "git.oa00.com/supply-chain/service/lib/bean" +) + +type category struct { +} +type ArgsCategoryList struct { + ThirdCategoryId uint + Page bean.Page +} + +type CategoryItem struct { + Id uint `json:"id"` + FirstCategoryName string `json:"firstCategoryName"` + SecondCategoryName string `json:"secondCategoryName"` + ThirdCategoryName string `json:"thirdCategoryName"` + SupplyCategoryId uint `json:"supplyCategoryId"` +} +type ReplyCategoryList struct { + Lists []CategoryItem `json:"lists"` + Total int64 `json:"total"` +} + +// Lists @Title 获取品牌匹配列表 +func (c *category) Lists(ctx context.Context, args ArgsCategoryList) (reply ReplyCategoryList, err error) { + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) + return +} + +type ArgsCategoryEdit struct { + CategoryId uint // 分类id + SupplyCategoryId uint // 匹配分类id +} + +// Edit @Title 编辑品牌匹配 +func (c *category) Edit(ctx context.Context, args ArgsCategoryEdit) error { + reply := 0 + xClient, err := client.GetClient(c) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) +} + +// Select @Title 类目筛选 +func (c *category) Select(ctx context.Context) (reply []CategoryItem, err error) { + args := 0 + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "Select", args, &reply) + return +} diff --git a/otosaas/otosaas.go b/otosaas/otosaas.go new file mode 100644 index 0000000..450e841 --- /dev/null +++ b/otosaas/otosaas.go @@ -0,0 +1,5 @@ +package otosaas + +type OtoSaas struct { + Category category +} diff --git a/otosaas/sku.go b/otosaas/sku.go new file mode 100644 index 0000000..5502217 --- /dev/null +++ b/otosaas/sku.go @@ -0,0 +1,253 @@ +package otosaas + +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 // 废弃商品 + + SkuHandleNone = 1 // 未处理 + SkuHandleStart = 2 // 开始处理 + + OtoSaasSkuStatusUp = 1 // 商品上架 + OtoSaasSkuStatusDown = 2 // 商品下架 +) + +type sku struct { +} +type GoodsSearch struct { + Status uint // 状态 + Handle uint // 处理状态 + Name string // 商品名称 + SkuCode string // 商品编码 + CategoryId uint64 // 类目id + MinSupplyPrice decimal.Decimal // 采购价最小 + MaxSupplyPrice decimal.Decimal // 采购价最大 +} +type ArgsGoodsList struct { + Search GoodsSearch + Page bean.Page +} + +type GoodsItem struct { + Id uint `json:"id"` + Name string `json:"name"` + FirstCategoryId uint `json:"firstCategoryId"` + FirstCategoryName string `json:"firstCategoryName"` + SecondCategoryId uint `json:"secondCategoryId"` + SecondCategoryName string `json:"secondCategoryName"` + ThirdCategoryId uint `json:"thirdCategoryId"` + ThirdCategoryName string `json:"thirdCategoryName"` + SupplyPrices []decimal.Decimal `json:"supplyPrices"` + GuidePrices []decimal.Decimal `json:"guidePrices"` + Skus []SkuItem `json:"skus"` + CreatedAt int64 `json:"createdAt"` +} +type SkuItem struct { + Id uint `json:"id"` + SkuCode string `json:"skuCode"` + SupplyPrice decimal.Decimal `json:"supplyPrice"` + GuidePrice decimal.Decimal `json:"guidePrice"` + SpecName string `json:"specName"` + SpecValue string `json:"specValue"` +} +type ReplyGoodsList struct { + Lists []GoodsItem `json:"lists"` + Total int64 `json:"total"` +} + +// Lists @Title 获取商品列表 +func (s *sku) Lists(ctx context.Context, args ArgsGoodsList) (reply ReplyGoodsList, err error) { + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) + return +} + +// Start @Title 开始处理 +func (s *sku) Start(ctx context.Context, skuIds []uint) error { + reply := 0 + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Start", skuIds, &reply) +} + +type ReplySkuInfo struct { + Id uint `json:"id"` + Name string `json:"name"` + JdSkuId uint64 `json:"jdSkuId"` + SupplyPrice decimal.Decimal `json:"supplyPrice"` + GuidePrice decimal.Decimal `json:"guidePrice"` + Profit decimal.Decimal `json:"profit"` + UpcCode string `json:"upcCode"` + Color string `json:"color"` + Size string `json:"size"` + FirstCategoryName string `json:"firstCategoryName"` + SecondCategoryName string `json:"secondCategoryName"` + ThirdCategoryName string `json:"thirdCategoryName"` + SupplyCategoryId uint `json:"supplyCategoryId"` + BrandName string `json:"brandName"` + SupplyBrandId uint `json:"supplyBrandId"` + Content string `json:"content"` + Tax string `json:"tax"` + Unit string `json:"unit"` + Imgs []SkuImg `json:"imgs"` + Specifications []SkuSpecification `json:"specifications"` + JdSkuStatus uint `json:"jdSkuStatus"` +} + +type SkuImg struct { + Id uint `json:"id"` + Path string `json:"path"` + ReplacePath string `json:"replacePath"` +} + +// GetImgs @Title 获取预览图 +func (s *sku) GetImgs(ctx context.Context, skuId uint) (reply []SkuImg, err error) { + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "GetImgs", skuId, &reply) + return +} + +type SkusImg struct { + Id uint `json:"id"` + SkuId uint `json:"skuId"` + Path string `json:"path"` + ReplacePath string `json:"replacePath"` + Sort uint `json:"sort"` +} + +// GetSkusImgs @Title 批量获取预览图 +func (s *sku) GetSkusImgs(ctx context.Context, skuId []uint) (reply []SkusImg, err error) { + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "GetSkusImgs", skuId, &reply) + return +} + +type SkuSpecification struct { + Name string `json:"name"` + Attributes []SkuAttribute `json:"attributes"` +} + +type SkuAttribute struct { + Name string `json:"name"` + Value []string `json:"value"` +} + +// Info @Title 获取商品详情 +func (s *sku) Info(ctx context.Context, skuId uint) (reply ReplySkuInfo, err error) { + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", skuId, &reply) + return +} + +type ArgsSkuEdit struct { + SkuId uint + SupplyBandId uint + SupplyCategoryId uint + Content string + Imgs []SkuImgEdit +} + +type SkuImgEdit struct { + Id uint + ReplacePath string +} + +// Edit @Title 商品编辑 +func (s *sku) Edit(ctx context.Context, args ArgsSkuEdit) error { + reply := 0 + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Edit", args, &reply) +} + +// Discard @Title 废弃 +func (s *sku) Discard(ctx context.Context, skuIds []uint) error { + reply := 0 + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "Discard", skuIds, &reply) +} + +type AdoptItem struct { + Id uint `json:"id"` + JdSkuId uint64 `json:"jdSkuId"` + Name string `json:"name"` + Error string `json:"error"` +} + +// Adopt @Title 入库 +func (s *sku) Adopt(ctx context.Context, skuIds []uint) (reply []AdoptItem, err error) { + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "Adopt", skuIds, &reply) + return +} + +type ArgsSkuReplaceImg struct { + SkuId uint // 商品id + ImgId uint // 图片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 ArgsSkuReplaceImgJdSku struct { + JdSkuId uint64 // 京东skuId + ImgSort uint // 图片排序 + ImgPath string // 图片路径 +} + +// ReplaceImgJdSku @Title 根据JdSkuId sort替换图片 +func (s *sku) ReplaceImgJdSku(ctx context.Context, args ArgsSkuReplaceImgJdSku) error { + reply := 0 + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "ReplaceImgJdSku", args, &reply) +} + +// ReHandle @Title 重新处理商品 +func (s *sku) ReHandle(ctx context.Context, skuId uint) error { + reply := 0 + xClient, err := client.GetClient(s) + if err != nil { + return err + } + return xClient.Call(ctx, "ReHandle", skuId, &reply) +}