From fb32b4ec3a10ed5402e449ccc7940e3c4e626114 Mon Sep 17 00:00:00 2001 From: sian Date: Thu, 15 Dec 2022 09:20:40 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=B5=B7=E6=97=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otosaas/category.go | 62 +++++++++++ otosaas/otosaas.go | 5 + otosaas/sku.go | 253 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 320 insertions(+) create mode 100644 otosaas/category.go create mode 100644 otosaas/otosaas.go create mode 100644 otosaas/sku.go 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) +} From d5ea51ce71538500a9f3da4587f75fa6cd5388f7 Mon Sep 17 00:00:00 2001 From: sian Date: Thu, 15 Dec 2022 09:31:02 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rpc.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rpc.go b/rpc.go index 3046df6..762be91 100644 --- a/rpc.go +++ b/rpc.go @@ -3,6 +3,7 @@ package service import ( "git.oa00.com/supply-chain/service/customer" "git.oa00.com/supply-chain/service/jd" + "git.oa00.com/supply-chain/service/otosaas" "git.oa00.com/supply-chain/service/supplier" "git.oa00.com/supply-chain/service/supply" "git.oa00.com/supply-chain/service/wholesale" @@ -16,4 +17,5 @@ type rpc struct { Customer customer.Customer Supplier supplier.Supplier Wholesale wholesale.Wholesale + OtoSaas otosaas.OtoSaas } From 2523a27ba394cf964c6fc0a087afd9f47210f8fd Mon Sep 17 00:00:00 2001 From: sian Date: Thu, 15 Dec 2022 11:43:33 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=B7=E6=97=85?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otosaas/commodity.go | 195 +++++++++++++++++++++++++++++++++ otosaas/otosaas.go | 3 +- otosaas/sku.go | 253 ------------------------------------------- 3 files changed, 197 insertions(+), 254 deletions(-) create mode 100644 otosaas/commodity.go delete mode 100644 otosaas/sku.go diff --git a/otosaas/commodity.go b/otosaas/commodity.go new file mode 100644 index 0000000..d252ce4 --- /dev/null +++ b/otosaas/commodity.go @@ -0,0 +1,195 @@ +package otosaas + +import ( + "context" + "git.oa00.com/supply-chain/service/client" + "git.oa00.com/supply-chain/service/lib/bean" + "github.com/shopspring/decimal" +) + +const ( + CommodityStatusNone = 1 // 待处理 + CommodityStatusAdopt = 2 // 同步入库 + CommodityStatusReject = 3 // 废弃商品 + + CommodityHandleNone = 1 // 未处理 + CommodityHandleStart = 2 // 开始处理 + + CommoditySaasSkuStatusUp = 1 // 商品上架 + CommoditySaasSkuStatusDown = 2 // 商品下架 +) + +type commodity struct { +} +type CommoditySearch struct { + Name string // 商品名称 + CategoryIds []uint // 类目id + SkuCode string // 商品条码 + Handle uint // 处理状态 1=待处理 2=入库 3=废弃 + SkuId uint // 供应商skuId + MinSupplyPrice decimal.Decimal // 最小采购价 + MaxSupplyPrice decimal.Decimal // 最大采购价 +} +type ArgsGoodsList struct { + Search CommoditySearch + Page bean.Page +} + +type CommodityItem struct { + Id uint `json:"id"` + Name string `json:"name"` + Img string `json:"img"` + CategoryId uint `json:"categoryId"` + CategoryNames string `json:"categoryNames"` + Skus []CommoditySkuItem `json:"skus"` + GuidePrices []decimal.Decimal `json:"guidePrices"` + SupplyPrices []decimal.Decimal `json:"supplyPrices"` + Status uint `json:"status"` + CreatedAt int64 `json:"createdAt"` +} + +type CommoditySkuItem struct { + Id uint `json:"id"` + Img string `json:"img"` + SupplyPrice decimal.Decimal `json:"supplyPrice"` + SpecValue string `json:"specValue"` + SkuCode string `json:"skuCode"` +} + +type GoodsSpecificationItem struct { + Name string `json:"name"` + Values []string `json:"values"` +} + +type ReplyCommodityLists struct { + List []CommodityItem `json:"list"` + Total int64 `json:"total"` +} + +// Lists @Title 获取商品列表 +func (g *commodity) Lists(ctx context.Context, args ArgsGoodsList) (reply ReplyCommodityLists, err error) { + xClient, err := client.GetClient(g) + if err != nil { + return + } + err = xClient.Call(ctx, "Lists", args, &reply) + return +} + +type ArgsGoodsInfo struct { + SkuId uint +} + +type ReplyGoodsInfo struct { + Id uint `json:"id"` + Name string `json:"name"` + SupplierId uint `json:"supplierId"` + SupplierName string `json:"supplierName"` + 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"` +} + +type GoodsAttributeItem struct { + Name string `json:"name"` + Value string `json:"value"` + GroupName string `json:"groupName"` +} + +type SkuSpecItem struct { + Name string `json:"name"` + Value string `json:"value"` +} + +type SkuItem struct { + SkuId uint `json:"skuId"` + Color string `json:"color"` + Size string `json:"size"` + SupplyPrice decimal.Decimal `json:"supplyPrice"` + MarketPrice decimal.Decimal `json:"marketPrice"` + UpcCode string `json:"upcCode"` + UnitId uint `json:"uintId"` + TaxCategoryId uint `json:"taxCategoryId"` + TaxName string `json:"taxName"` + TaxCode string `json:"taxCode"` + Unit string `json:"uint"` + Tax decimal.Decimal `json:"tax"` + Img string `json:"img"` +} + +// Info @Title 商品详情 +func (g *commodity) Info(ctx context.Context, goodsId uint) (reply ReplyGoodsInfo, err error) { + xClient, err := client.GetClient(g) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", goodsId, &reply) + return +} + +// GetImgs @Title 获取商品主图 +func (g *commodity) 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 +} + +type AdoptItem struct { + Id uint `json:"id"` + Name string `json:"name"` + Error string `json:"error"` +} + +// Adopt @Title 批量入库 +func (g *commodity) Adopt(ctx context.Context, goodsIds []uint) (reply []AdoptItem, err error) { + xClient, err := client.GetClient(g) + if err != nil { + return + } + err = xClient.Call(ctx, "Adopt", goodsIds, &reply) + return +} + +// Discard @Title 批量废弃 +func (g *commodity) Discard(ctx context.Context, goodsIds []uint) (err error) { + xClient, err := client.GetClient(g) + if err != nil { + return + } + reply := 0 + err = xClient.Call(ctx, "Discard", goodsIds, &reply) + return +} + +// ReHandle @Title 重新处理商品 +func (g *commodity) ReHandle(ctx context.Context, goodsIds []uint) (reply []AdoptItem, err error) { + xClient, err := client.GetClient(g) + if err != nil { + return nil, err + } + err = xClient.Call(ctx, "ReHandle", goodsIds, &reply) + return +} + +type ReplyByIdItem struct { + SkuId uint `json:"skuId"` + SupplierId uint `json:"supplierIds"` + SupplierName string `json:"supplierName"` +} + +// FindBySkuIds @Title 根据商品Ids获取商品信息 +func (g *commodity) FindBySkuIds(ctx context.Context, skuIds []uint) (reply []ReplyByIdItem, err error) { + xClient, err := client.GetClient(g) + if err != nil { + return nil, err + } + err = xClient.Call(ctx, "FindBySkuIds", skuIds, &reply) + return +} diff --git a/otosaas/otosaas.go b/otosaas/otosaas.go index 450e841..92ab618 100644 --- a/otosaas/otosaas.go +++ b/otosaas/otosaas.go @@ -1,5 +1,6 @@ package otosaas type OtoSaas struct { - Category category + Category category + Commodity commodity } diff --git a/otosaas/sku.go b/otosaas/sku.go deleted file mode 100644 index 5502217..0000000 --- a/otosaas/sku.go +++ /dev/null @@ -1,253 +0,0 @@ -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) -} From f2a665a091f9c3c2f1b24805317625555a370c4d Mon Sep 17 00:00:00 2001 From: sian Date: Thu, 15 Dec 2022 13:28:51 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otosaas/commodity.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/otosaas/commodity.go b/otosaas/commodity.go index d252ce4..81e8f37 100644 --- a/otosaas/commodity.go +++ b/otosaas/commodity.go @@ -26,11 +26,11 @@ type CommoditySearch struct { CategoryIds []uint // 类目id SkuCode string // 商品条码 Handle uint // 处理状态 1=待处理 2=入库 3=废弃 - SkuId uint // 供应商skuId + CommodityCode string // 商品编码 MinSupplyPrice decimal.Decimal // 最小采购价 MaxSupplyPrice decimal.Decimal // 最大采购价 } -type ArgsGoodsList struct { +type ArgsCommodityList struct { Search CommoditySearch Page bean.Page } @@ -38,6 +38,7 @@ type ArgsGoodsList struct { type CommodityItem struct { Id uint `json:"id"` Name string `json:"name"` + CommodityCode string `json:"commodityCode"` Img string `json:"img"` CategoryId uint `json:"categoryId"` CategoryNames string `json:"categoryNames"` @@ -56,18 +57,13 @@ type CommoditySkuItem struct { SkuCode string `json:"skuCode"` } -type GoodsSpecificationItem struct { - Name string `json:"name"` - Values []string `json:"values"` -} - type ReplyCommodityLists struct { List []CommodityItem `json:"list"` Total int64 `json:"total"` } // Lists @Title 获取商品列表 -func (g *commodity) Lists(ctx context.Context, args ArgsGoodsList) (reply ReplyCommodityLists, err error) { +func (g *commodity) Lists(ctx context.Context, args ArgsCommodityList) (reply ReplyCommodityLists, err error) { xClient, err := client.GetClient(g) if err != nil { return From 5b569596993bdbd34a8f29f60fa8981a3e774eb2 Mon Sep 17 00:00:00 2001 From: sian Date: Thu, 15 Dec 2022 14:53:52 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otosaas/commodity.go | 75 +++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/otosaas/commodity.go b/otosaas/commodity.go index 81e8f37..c3e01b5 100644 --- a/otosaas/commodity.go +++ b/otosaas/commodity.go @@ -76,49 +76,41 @@ type ArgsGoodsInfo struct { SkuId uint } -type ReplyGoodsInfo struct { - Id uint `json:"id"` - Name string `json:"name"` - SupplierId uint `json:"supplierId"` - SupplierName string `json:"supplierName"` - 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"` -} - -type GoodsAttributeItem struct { - Name string `json:"name"` - Value string `json:"value"` - GroupName string `json:"groupName"` -} - -type SkuSpecItem struct { - Name string `json:"name"` - Value string `json:"value"` +type ReplyCommodityInfo struct { + Id uint `json:"id"` + CommodityCode string `json:"commodityCode"` + Name string `json:"name"` + ImgUrl string `json:"imgUrl"` + FirstCategoryId uint `json:"firstCategoryId"` + FirstCategoryName string `json:"firstCategoryName"` + SecondCategoryId uint `json:"secondCategoryId"` + SecondCategoryName string `json:"secondCategoryName"` + ThirdCategoryId uint `json:"thirdCategoryId"` + ThirdCategoryName string `json:"thirdCategoryName"` + Handle uint `json:"handle"` + Status uint `json:"status"` + Skus []SkuItem `json:"skus"` + Imgs []CommodityImgItem `json:"imgs"` +} + +type CommodityImgItem struct { + Id uint `json:"id"` + Path string `json:"path"` + ReplacePath string `json:"replacePath"` } type SkuItem struct { - SkuId uint `json:"skuId"` - Color string `json:"color"` - Size string `json:"size"` - SupplyPrice decimal.Decimal `json:"supplyPrice"` - MarketPrice decimal.Decimal `json:"marketPrice"` - UpcCode string `json:"upcCode"` - UnitId uint `json:"uintId"` - TaxCategoryId uint `json:"taxCategoryId"` - TaxName string `json:"taxName"` - TaxCode string `json:"taxCode"` - Unit string `json:"uint"` - Tax decimal.Decimal `json:"tax"` - Img string `json:"img"` + Id uint `json:"id"` + SkuCode string `json:"skuCode"` + SpecName string `json:"specName"` + SpecValue string `json:"specValue"` + SupplyPrice decimal.Decimal `json:"supplyPrice"` + GuidePrice decimal.Decimal `json:"guidePrice"` + ImgUrl string `json:"imgUrl"` } // Info @Title 商品详情 -func (g *commodity) Info(ctx context.Context, goodsId uint) (reply ReplyGoodsInfo, err error) { +func (g *commodity) Info(ctx context.Context, goodsId uint) (reply ReplyCommodityInfo, err error) { xClient, err := client.GetClient(g) if err != nil { return @@ -127,13 +119,18 @@ func (g *commodity) Info(ctx context.Context, goodsId uint) (reply ReplyGoodsInf return } +type ReplyImgs struct { + GoodsId uint `json:"goodsId"` + Imgs []string `json:"imgs"` +} + // GetImgs @Title 获取商品主图 -func (g *commodity) GetImgs(ctx context.Context, goodsId uint) (reply []string, err error) { +func (g *commodity) GetImgs(ctx context.Context, goodsIds []uint) (reply []ReplyImgs, err error) { xClient, err := client.GetClient(g) if err != nil { return } - err = xClient.Call(ctx, "GetImgs", goodsId, &reply) + err = xClient.Call(ctx, "GetImgs", goodsIds, &reply) return } From 573a37a3c82c9e511afe1b7df0e6cbfcb782468e Mon Sep 17 00:00:00 2001 From: sian Date: Thu, 15 Dec 2022 15:13:42 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otosaas/commodity.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/otosaas/commodity.go b/otosaas/commodity.go index c3e01b5..0558d78 100644 --- a/otosaas/commodity.go +++ b/otosaas/commodity.go @@ -72,10 +72,6 @@ func (g *commodity) Lists(ctx context.Context, args ArgsCommodityList) (reply Re return } -type ArgsGoodsInfo struct { - SkuId uint -} - type ReplyCommodityInfo struct { Id uint `json:"id"` CommodityCode string `json:"commodityCode"` @@ -87,6 +83,7 @@ type ReplyCommodityInfo struct { SecondCategoryName string `json:"secondCategoryName"` ThirdCategoryId uint `json:"thirdCategoryId"` ThirdCategoryName string `json:"thirdCategoryName"` + SupplyCategoryId uint `json:"supplyCategoryId"` Handle uint `json:"handle"` Status uint `json:"status"` Skus []SkuItem `json:"skus"` From 8c283004e70d6ac93a14617e91d1c95fb4560152 Mon Sep 17 00:00:00 2001 From: kanade Date: Fri, 16 Dec 2022 11:22:05 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=89=B9=E5=8F=91=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wholesale/channel/channel.go | 5 ++- wholesale/channel/order.go | 75 ++++++++++++++++++++++++++++++++++++ wholesale/interface/order.go | 67 ++++++++++++++++++++++++++++++++ wholesale/order.go | 42 ++++++++++++++++++++ 4 files changed, 187 insertions(+), 2 deletions(-) create mode 100644 wholesale/channel/order.go create mode 100644 wholesale/interface/order.go create mode 100644 wholesale/order.go diff --git a/wholesale/channel/channel.go b/wholesale/channel/channel.go index 44d18f4..ee22bfe 100644 --- a/wholesale/channel/channel.go +++ b/wholesale/channel/channel.go @@ -1,6 +1,7 @@ package channel type Channel struct { - Sku sku - Mq mq + Sku sku + Order order + Mq mq } diff --git a/wholesale/channel/order.go b/wholesale/channel/order.go new file mode 100644 index 0000000..323eef7 --- /dev/null +++ b/wholesale/channel/order.go @@ -0,0 +1,75 @@ +package channel + +import ( + "context" + "git.oa00.com/supply-chain/service/client" + "github.com/shopspring/decimal" + "github.com/smallnest/rpcx/share" +) + +const ( + ReplyOrderFreightFeeErrCodeNone = 0 // 无错误 + ReplyOrderFreightFeeErrCodeErr = 1 // 有错误 + ReplyOrderFreightFeeErrCodeDone = 2 // 已下架 + + OrderStatusSubmit = 1 // 下单 + OrderStatusFreightFee = 2 // 已确认运费 + OrderStatusPay = 3 // 已支付 + OrderStatusClose = 4 // 关闭 + + OrderSubStatusSubmit = 1 // 下单 + OrderSubStatusFreightFee = 2 // 确认运费 + OrderSubStatusPay = 3 // 已支付 + OrderSubStatusCheckout = 4 // 出库 + OrderSubStatusFinish = 5 // 完成 + + OrderCancelSubStatusFalse = 1 // 未取消 + OrderCancelSubStatusTrue = 2 // 已取消 + + OrderSubIsSplitFalse = 1 // 无 + OrderSubIsSplitTrue = 2 // 被拆单 + + OrderSubTypeApi = 1 // api接口下单 + OrderSubTypeCustomerWeb = 2 // 客户商城下单 + +) + +type order struct { +} +type SkuOrderItem struct { + SkuId uint // skuId + Price decimal.Decimal // 单价 + Quantity uint // 数量 (箱) + PackingRate uint // 装箱率 +} +type ArgsOrderSubmit struct { + ChannelOrderSn string // 渠道订单编号 + Address string // 地址 + Skus []SkuOrderItem // sku信息 + Receiver Receiver // 收件信息 + OrderFee decimal.Decimal // 订单金额-不含运费 + UserIp string // 下单用户ip + Type uint // 下单方式 +} + +type Receiver struct { + Name string // 姓名 + Mobile string // 手机号 + Email string // 邮箱 + ZipCode string // 邮编 +} + +type ReplyOrderSubmit struct { + OrderSn string `json:"orderSn"` + ChannelOrderSn string `json:"channelOrderSn"` +} + +// Submit @Title 下单 +func (o *order) Submit(ctx context.Context, channelId string, args ArgsOrderSubmit) (reply ReplyOrderSubmit, err error) { + xClient, err := client.GetClient(o) + if err != nil { + return + } + err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Submit", args, &reply) + return +} diff --git a/wholesale/interface/order.go b/wholesale/interface/order.go new file mode 100644 index 0000000..7157237 --- /dev/null +++ b/wholesale/interface/order.go @@ -0,0 +1,67 @@ +package _interface + +import ( + "context" + "github.com/shopspring/decimal" +) + +type OrderInterface interface { + // FreightFee 获取运费 + FreightFee(ctx context.Context, args ArgsOrderFreightFee, freightFee *ReplyOrderFreightFee) error + // Submit 下单 + Submit(ctx context.Context, args ArgsOrderSubmit, sourceOrderSn *string) error + // LadingBill @Title 提单 + LadingBill(ctx context.Context, orderSn string, reply *int) error + // Close @Title 关闭订单 + Close(ctx context.Context, orderSn string, reply *int) error + // Cancel @Title 取消订单 + Cancel(ctx context.Context, args ArgsOrderCancel, reply *int) error + // Trajectory @Title 物流轨迹 + Trajectory(ctx context.Context, orderSn string, reply *[]ReplyTrajectory) error + // Finish @Title 确认收货 + Finish(ctx context.Context, orderSn string, reply *int) error +} +type ArgsOrderCancel struct { + OrderSn string // 订单编号 + Reason string // 取消原因 +} +type ArgsOrderFreightFee struct { + Skus []OrderFreightFeeSkuItem // 商品信息 + Address string // 地址 +} +type ReplyOrderFreightFee struct { + FreightFee decimal.Decimal // 运费 + ErrMsg string // 错误信息 +} + +type OrderFreightFeeSkuItem struct { + SourceSkuId string // 源skuId + SourceSkuPrice decimal.Decimal // 采购价 + Quantity uint // 数量 +} + +type ArgsOrderSubmit struct { + OrderSn uint64 // 订单号 + Skus []OrderFreightFeeSkuItem // 商品信息 + Address string // 地址 + Receiver OrderReceiver // 收件信息 + UserIp string // 用户ip +} + +type OrderReceiver struct { + Name string // 姓名 + Phone string // 手机号 + Email string // 邮件 + ZipCode string // 邮编 +} + +type ReplyTrajectory struct { + LogisticsName string `json:"logisticsName"` + WaybillCode string `json:"waybillCode"` + Steps []PackageStep `json:"steps"` +} +type PackageStep struct { + State string `json:"state"` + Content string `json:"content"` + OperatorAt int64 `json:"operatorAt"` +} diff --git a/wholesale/order.go b/wholesale/order.go new file mode 100644 index 0000000..3dab488 --- /dev/null +++ b/wholesale/order.go @@ -0,0 +1,42 @@ +package wholesale + +import ( + "context" + "git.oa00.com/supply-chain/service/client" + "github.com/shopspring/decimal" +) + +const ( + OrderCancelStatusSuccess = 1 // 取消成功 + OrderCancelStatusFail = 2 // 取消失败 +) + +type order struct { +} +type ArgsOrderSplit struct { + Source source // 商品来源 + ParentSourceOrderSn string // 上级订单号 + OrderSubs []OrderSub // 子订单 +} +type OrderSub struct { + SourceOrderSn string // 供应商订单号 + FreightFee decimal.Decimal // 运费 + OrderFee decimal.Decimal // 订单金额 + Skus []OrderSplitSkuItem // 拆分订单sku +} +type OrderSplitSkuItem struct { + SourceSkuId string + Quantity uint + SupplyPrice decimal.Decimal +} + +// Split @Title 拆单 +func (o *order) Split(ctx context.Context, args ArgsOrderSplit) (err error) { + xClient, err := client.GetClient(o) + if err != nil { + return + } + reply := 0 + err = xClient.Call(ctx, "Split", args, &reply) + return +}