银豹分类修改

This commit is contained in:
苏尹岚
2020-03-25 11:59:46 +08:00
parent 6395ac1b1e
commit 1cdada6076
3 changed files with 57 additions and 8 deletions

View File

@@ -159,15 +159,43 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, vendorOrg
return failedList, err
}
func (p *PurchaseHandler) GetStoreAllCategories(ctx *jxcontext.Context, storeID int, vendorStoreID string) (cats []*partner.BareCategoryInfo, err error) {
vendorOrgCode, err := buildYbConfigs(storeID)
if err != nil {
return nil, err
}
remoteCats, err := api.YinBaoAPI.LoadCategorysWithOption(vendorOrgCode)
if err == nil {
cats = convertVendorCatList(remoteCats)
}
return cats, err
}
func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
if globals.EnableYbStoreWrite {
vendorOrgCode, err := buildYbConfigs(storeID)
if err != nil {
return err
}
vendorCatID, err := api.YinBaoAPI.AddNewCategory(vendorOrgCode, storeCat.Name, storeCat.ParentCatName)
if err == nil {
storeCat.VendorCatID = vendorCatID
}
}
return err
}
func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
if globals.EnableYbStoreWrite {
}
return err
}
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error) {
if globals.EnableYbStoreWrite {
}
return err
}
@@ -175,6 +203,10 @@ func (p *PurchaseHandler) IsErrSkuExist(err error) (isExist bool) {
return yinbaoapi.IsErrSkuExist(err)
}
func (p *PurchaseHandler) IsErrCategoryExist(err error) (isExist bool) {
return yinbaoapi.IsErrCategoryExist(err)
}
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
return 1
}
@@ -271,14 +303,31 @@ func buildProductInfoParam(storeSku *dao.StoreSkuSyncInfo) (productInfoParam *yi
return productInfoParam
}
func buildYbConfigs(storeID int) (err error) {
func buildYbConfigs(storeID int) (vendorOrgCode string, err error) {
if storeID == 0 {
return fmt.Errorf("门店ID不能为空平台[%v]", model.VendorIDYB)
return "", fmt.Errorf("门店ID不能为空平台[%v]", model.VendorIDYB)
}
store, err := dao.GetStoreDetail(dao.GetDB(), storeID, model.VendorIDYB)
if err != nil {
return err
return "", err
}
api.YinBaoAPI = yinbaoapi.New(store.YbAppKey, store.YbAppID)
return err
vendorOrgCode = store.VendorOrgCode
return vendorOrgCode, err
}
func convertVendorCatList(remoteCats []*yinbaoapi.LoadCategorysWithOptionResult) (cats []*partner.BareCategoryInfo) {
for _, rCat := range remoteCats {
cat := &partner.BareCategoryInfo{
VendorCatID: rCat.TxtUID,
Name: rCat.Name,
}
if rCat.TxtParentUID == "" {
cat.Level = 1
} else {
cat.Level = 2
}
cats = append(cats, cat)
}
return cats
}