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

437 lines
16 KiB

2 years ago
package supply
import (
"context"
"git.oa00.com/supply-chain/service/client"
2 years ago
"git.oa00.com/supply-chain/service/lib/bean"
2 years ago
"github.com/shopspring/decimal"
)
type sku struct {
}
type source uint
2 years ago
const (
2 years ago
SkuSourceJd source = 1 // 京东开普勒渠道
SkuSourceSupplier source = 2 // 供应链供应商渠道
2 years ago
SkuSourceOtoSaas source = 3 // 海旅供应商渠道
)
2 years ago
const (
2 years ago
SkuAdjustTypeRate = 1 // 加价比例
SkuAdjustTypeAmount = 2 // 加价金额
SkuPlatformStatusUp = 1 // 平台上架
SkuPlatformStatusDown = 2 // 平台下架
SkuSourceStatusUp = 1 // 供应商上架
SkuSourceStatusDown = 2 // 供应商下架
SkuHandleNone = 1 // 未处理
SkuHandleFinal = 2 // 已处理
SkuAuditStatusNone = 0 // 无
SkuAuditStatusWait = 1 // 待审核
SkuAuditStatusAdopt = 2 // 审核通过
SkuAuditStatusReject = 3 // 审核驳回
2 years ago
ProfitGtZero = 1 // 利润比大于0
ProfitEqZero = 2 // 利润比等于0
ProfitLtZero = 3 // 利润比小于0
2 years ago
)
type ArgsSkuAdd struct {
2 years ago
SourceSkuId string // 源skuId
SourceGroupSkuIds []string // 源skuId关系数组
SourceStatus uint // 源状态
Name string // 商品名称
BrandId uint // 品牌id
ThirdCategoryId uint // 三级分类id
SupplyPrice decimal.Decimal // 采购价
GuidePrice decimal.Decimal // 指导价-建议售价
Size string // 尺码
Color string // 颜色
Tax string // 税率
2 years ago
TaxName string // 税收名称
TaxCode string // 税收编码
2 years ago
Unit string // 销售单位
UpcCode string // 商品条码
Source source // 商品来源
Content string // 商品详情
Imgs []SkuImg // 商品图片 第一张主图
Specifications []SkuSpecification // 商品参数信息
2 years ago
}
type SkuImg struct {
2 years ago
Path string `json:"path"`
2 years ago
}
type SkuSpecification struct {
Name string `json:"name"`
Attributes []SkuAttribute `json:"attributes"`
}
type SkuAttribute struct {
Name string `json:"name"`
Value []string `json:"value"`
}
// Add @Title 添加商品
func (s *sku) Add(ctx context.Context, args ArgsSkuAdd) error {
reply := 0
xClient, err := client.GetClient(s)
if err != nil {
return err
}
return xClient.Call(ctx, "Add", args, &reply)
2 years ago
}
type ArgsSkuAdjust struct {
ApplyUserId uint // 修改人
SkuIds []uint // 商品id
AdjustType uint // 加价类型
AdjustPrice decimal.Decimal // 加价金额
}
// Adjust @Title 加价
func (s *sku) Adjust(ctx context.Context, args ArgsSkuAdjust) error {
reply := 0
xClient, err := client.GetClient(s)
if err != nil {
return err
}
return xClient.Call(ctx, "Adjust", args, &reply)
2 years ago
}
2 years ago
type ArgsSkuLists struct {
2 years ago
Search SkuListsSearch
2 years ago
Page bean.Page
}
2 years ago
type SkuListsSearch struct {
2 years ago
Id uint // 瑞库客id
Name string // 商品名称
SourceId uint // 所属供应商 1=京东
SourceSkuId uint // 供应商skuId
BrandId uint // 品牌Id
2 years ago
BrandIds []uint // 品牌Ids
2 years ago
TagIds []uint // 商品标签Ids
2 years ago
FirstCategoryId uint // 一级分类Id
2 years ago
FirstCategoryIds []uint // 一级分类ids
2 years ago
SecondCategoryId uint // 二级分类Id
2 years ago
SecondCategoryIds []uint // 二级分类Ids
2 years ago
ThirdCategoryId uint // 三级分类Id
2 years ago
ThirdCategoryIds []uint // 三级分类Ids
2 years ago
AdjustType uint // 加价规则
MaxSupplyPrice decimal.Decimal // 最大采购价格
MinSupplyPrice decimal.Decimal // 最小采购价格
CustomerProfitRate uint // 客户利润比 1=大于0 2=等于0 3=小于0
Handle uint // 处理状态
AuditStatus uint // 审核状态
SourceStatus uint // 供应商下架状态
PlatformStatus uint // 平台下架状态
UpcCode string // 商品条码
2 years ago
}
type ReplySkuList struct {
2 years ago
Lists []SkuItem `json:"lists"`
Total int64 `json:"total"`
2 years ago
}
type SkuItem struct {
2 years ago
Id uint `json:"id"`
Name string `json:"name"` // 名称
BrandName string `json:"brandName"` // 品牌名称
FirstCategoryId uint `json:"firstCategoryId"` // 一级分类id
SecondCategoryId uint `json:"secondCategoryId"` // 二级分类id
ThirdCategoryId uint `json:"thirdCategoryId"` // 三级分类id
SupplyPrice decimal.Decimal `json:"supplyPrice"` // 采购价
GuidePrice decimal.Decimal `json:"guidePrice"` // 指导价
ImgUrl string `json:"imgUrl"` // 商品主图
PlatformStatus uint `json:"platformStatus"` // 平台状态 1=上架 2=下架
2 years ago
SourceId uint `json:"sourceId"` // 所属供应商
2 years ago
SourceName string `json:"sourceName"` // 供应商名称
SourceSkuId string `json:"sourceSkuId"` // 源skuId
SourceStatus uint `json:"sourceStatus"` // 供应商状态 1=上架 2=下架
CustomerPrice decimal.Decimal `json:"customerPrice"` // 供货最高价
CustomerProfitRate decimal.Decimal `json:"customerProfitRate"` // 供货利润率 供货利润/供货最高价%
2 years ago
CustomerDiscount decimal.Decimal `json:"customerDiscount"` // 折扣
2 years ago
AdjustType uint `json:"adjustType"` // 加价类型
AdjustPrice decimal.Decimal `json:"adjustPrice"` // 加价金额
2 years ago
AfterAdjustType uint `json:"afterAdjustType"` // 改价后加价类型
AfterAdjustPrice decimal.Decimal `json:"afterAdjustPrice"` // 改价后加价金额
2 years ago
AfterPrice decimal.Decimal `json:"afterPrice"` // 改价后金额
2 years ago
AfterDiscount decimal.Decimal `json:"afterDiscount"` // 改价后折扣
2 years ago
AdjustAuditStatus uint `json:"adjustAuditStatus"` // 改价审核状态
2 years ago
Reason string `json:"reason"` // 改价驳回原因
UpcCode string `json:"upcCode"` // 商品条码
2 years ago
Color string `json:"color"` // 颜色
Size string `json:"size"` // 尺寸
2 years ago
Attributes []AttributeItem `json:"attributes"` // 商品属性
2 years ago
TagIds []uint `json:"tagIds"` // 商品标签ids
2 years ago
}
type AttributeItem struct {
GroupName string `json:"groupName"`
Name string `json:"name"`
Value string `json:"value"`
2 years ago
}
// Lists @Title 商品列表
2 years ago
func (s *sku) Lists(ctx context.Context, args ArgsSkuLists) (reply ReplySkuList, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "Lists", args, &reply)
2 years ago
return
2 years ago
}
2 years ago
type SkuEsSearch struct {
2 years ago
SourceId uint // 所属供应商
2 years ago
SourceSonId uint // 沙马供应商的供应商Id
SourceSkuId uint // 供应商SkuId
2 years ago
SourceStatus uint // 供应商上下架状态 1=上架 2=下架
PlatformStatus uint // 平台上下架状态 1=上架 2=下架
2 years ago
AuditStatus uint // 改价审核状态 1=待审核 2=通过 3=驳回
2 years ago
SkuId uint // Sku编码
SupplySkuId uint // 供应商Sku编码
SkuName string // 商品名称
SkuNameVague string // 商品名称-模糊查询
UpcCode string // 商品条码
2 years ago
BrandId uint // 品牌id
BrandName string // 品牌名称 全词匹配
FirstCategoryId uint // 一级分类id
FirstCategoryName string // 一级分类名称 全词匹配
SecondCategoryId uint // 二级分类id
SecondCategoryName string // 二级分类名称 全词匹配
ThirdCategoryId uint // 三级分类id
ThirdCategoryName string // 三级分类名称 全词匹配
AdjustType uint // 加价规则 1=比例 2=金额
2 years ago
Handel uint // 处理状态
2 years ago
MaxSupplyPrice decimal.Decimal // 最高金额
MinSupplyPrice decimal.Decimal // 最低金额
MinDiscount decimal.Decimal // 最低折扣
MaxDiscount decimal.Decimal // 最高折扣
2 years ago
AdjustMinDiscount decimal.Decimal // 改价后最小折扣
AdjustMaxDiscount decimal.Decimal // 改价后最大折扣
2 years ago
}
type ArgsSkuListsEs struct {
Search SkuEsSearch
Page bean.Page
}
// ListsEs @Title es商品列表 目前最大10000条数据超出不显示
func (s *sku) ListsEs(ctx context.Context, args ArgsSkuListsEs) (reply ReplySkuList, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "ListsEs", args, &reply)
return
}
type SkuInfo struct {
2 years ago
Id uint `json:"id"`
Name string `json:"name"`
SourceSkuId string `json:"jdSkuId"`
SupplyPrice decimal.Decimal `json:"supplyPrice"`
2 years ago
CustomerPrice decimal.Decimal `json:"customerPrice"`
2 years ago
GuidePrice decimal.Decimal `json:"guidePrice"`
Profit decimal.Decimal `json:"profit"`
2 years ago
CustomerProfitRate decimal.Decimal `json:"customerProfitRate"`
2 years ago
UpcCode string `json:"upcCode"`
Color string `json:"color"`
Size string `json:"size"`
FirstCategoryName string `json:"firstCategoryName"`
SecondCategoryName string `json:"secondCategoryName"`
ThirdCategoryName string `json:"thirdCategoryName"`
BrandName string `json:"brandName"`
Content string `json:"content"`
Tax string `json:"tax"`
TaxName string `json:"taxName"`
TaxCode string `json:"taxCode"`
2 years ago
Unit string `json:"unit"`
2 years ago
Imgs []SkuImgItem `json:"imgs"`
2 years ago
Reason string `json:"reason"`
Specifications []SkuSpecification `json:"specification"`
PlatformStatus uint `json:"platformStatus"`
2 years ago
SourceStatus uint `json:"sourceStatus"`
2 years ago
SourceName string `json:"sourceName"`
AdjustType uint `json:"adjustType"`
AdjustPrice decimal.Decimal `json:"adjustPrice"`
}
2 years ago
type SkuImgItem struct {
Id uint `json:"id"`
Path string `json:"path"`
}
// Info @Title 商品信息
func (s *sku) Info(ctx context.Context, skuId uint) (reply SkuInfo, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "Info", skuId, &reply)
return
}
2 years ago
type ArgsSkuOnShelves struct {
SkuIds []uint
}
2 years ago
type ArgsSkuDownShelves struct {
SkuIds []uint
}
2 years ago
// OnShelves @Title 上架
2 years ago
func (s *sku) OnShelves(ctx context.Context, args ArgsSkuOnShelves) error {
2 years ago
reply := 0
xClient, err := client.GetClient(s)
if err != nil {
return err
}
return xClient.Call(ctx, "OnShelves", args, &reply)
2 years ago
}
// DownShelves @Title 下架
2 years ago
func (s *sku) DownShelves(ctx context.Context, args ArgsSkuDownShelves) error {
2 years ago
reply := 0
xClient, err := client.GetClient(s)
if err != nil {
return err
}
return xClient.Call(ctx, "DownShelves", args, &reply)
2 years ago
}
2 years ago
// GetImgs @Title 获取预览图
2 years ago
func (s *sku) GetImgs(ctx context.Context, skuId uint) (reply []SkuImgItem, err error) {
2 years ago
xClient, err := client.GetClient(s)
if err != nil {
2 years ago
return nil, err
2 years ago
}
2 years ago
err = xClient.Call(ctx, "GetImgs", skuId, &reply)
return
2 years ago
}
type ArgsReplaceImg struct {
2 years ago
SkuId uint
Id uint
Path string
2 years ago
}
// ReplaceImg @Title 替换图片
2 years ago
func (s *sku) ReplaceImg(ctx context.Context, args ArgsReplaceImg) (err error) {
reply := 0
2 years ago
xClient, err := client.GetClient(s)
if err != nil {
2 years ago
return err
2 years ago
}
err = xClient.Call(ctx, "ReplaceImg", args, &reply)
return
}
2 years ago
type ArgsSkuChangePrice struct {
SourceSkuId string // 源skuId
SupplyPrice decimal.Decimal // 采购价
GuidePrice decimal.Decimal // 指导价-建议售价
Source source // 商品来源
}
// ChangePrice @Title 更新价格
func (s *sku) ChangePrice(ctx context.Context, args ArgsSkuChangePrice) (err error) {
reply := 0
xClient, err := client.GetClient(s)
if err != nil {
return err
}
err = xClient.Call(ctx, "ChangePrice", args, &reply)
return
}
type ArgsSkuChangeData struct {
SourceSkuId string // 源skuId
SourceStatus uint // 源状态
Name string // 商品名称
BrandId uint // 品牌id
ThirdCategoryId uint // 三级分类id
SupplyPrice decimal.Decimal // 采购价
GuidePrice decimal.Decimal // 指导价-建议售价
Size string // 尺码
Color string // 颜色
Tax string // 税率
Unit string // 销售单位
UpcCode string // 商品条码
Source source // 商品来源
Imgs []string // 商品图片 第一张主图
2 years ago
Specifications []SkuSpecification // 商品参数信息
}
// ChangeData @Title 更新商品信息
func (s *sku) ChangeData(ctx context.Context, args ArgsSkuChangeData) (err error) {
reply := 0
xClient, err := client.GetClient(s)
if err != nil {
return err
}
err = xClient.Call(ctx, "ChangeData", args, &reply)
return
}
type ByIdsSkuItem struct {
Id uint `json:"id"`
Name string `json:"name"` // 名称
BrandName string `json:"brandName"` // 品牌名称
FirstCategoryId uint `json:"firstCategoryId"` // 一级分类id
SecondCategoryId uint `json:"secondCategoryId"` // 二级分类id
ThirdCategoryId uint `json:"thirdCategoryId"` // 三级分类id
SupplyPrice decimal.Decimal `json:"supplyPrice"` // 采购价
GuidePrice decimal.Decimal `json:"guidePrice"` // 指导价
ImgUrl string `json:"imgUrl"` // 商品主图
PlatformStatus uint `json:"platformStatus"` // 平台状态 1=上架 2=下架
SourceName string `json:"sourceName"` // 供应商名称
SourceSkuId string `json:"sourceSkuId"` // 源skuId
SourceStatus uint `json:"sourceStatus"` // 供应商状态 1=上架 2=下架
CustomerPrice decimal.Decimal `json:"customerPrice"` // 供货最高价
CustomerProfitRate decimal.Decimal `json:"customerProfitRate"` // 供货利润率 供货利润/供货最高价%
AdjustType uint `json:"adjustType"` // 加价类型
AdjustPrice decimal.Decimal `json:"adjustPrice"` // 加价金额
AfterAdjustType uint `json:"afterAdjustType"` // 改价后加价类型
AfterAdjustPrice decimal.Decimal `json:"afterAdjustPrice"` // 改价后加价金额
Handle uint `json:"handle"` // 1=未处理 2=已处理
Reason string `json:"reason"` // 驳回原因
2 years ago
Size string `json:"size"`
Color string `json:"color"`
2 years ago
Specifications []SpecItem `json:"specifications"`
}
type SpecItem struct {
Id uint `json:"id"`
SkuId uint `json:"skuId"`
Name string `json:"name"`
Value string `json:"value"`
GroupName string `json:"groupName"`
}
// FindByIds @Title 根据Ids查询sku信息
func (s *sku) FindByIds(ctx context.Context, ids []uint) (reply []ByIdsSkuItem, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return nil, err
}
err = xClient.Call(ctx, "FindByIds", ids, &reply)
return
}
2 years ago
// AuthPut @Title 根据sourceSkuId查询供应链是否入库 true=入库 false=没有入库
2 years ago
func (s *sku) AuthPut(ctx context.Context, sourceSkuIds []uint) (reply bool) {
2 years ago
xClient, err := client.GetClient(s)
if err != nil {
2 years ago
return false
2 years ago
}
2 years ago
err = xClient.Call(ctx, "AuthPut", sourceSkuIds, &reply)
2 years ago
return
}