银豹api修改

This commit is contained in:
苏尹岚
2020-03-26 09:31:23 +08:00
parent 615e6abbae
commit 1afb9ef1a3

View File

@@ -165,7 +165,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, vendorOrg
} }
func (p *PurchaseHandler) GetStoreAllCategories(ctx *jxcontext.Context, storeID int, vendorStoreID string) (cats []*partner.BareCategoryInfo, err error) { func (p *PurchaseHandler) GetStoreAllCategories(ctx *jxcontext.Context, storeID int, vendorStoreID string) (cats []*partner.BareCategoryInfo, err error) {
vendorOrgCode, err := buildYbConfigs(storeID) vendorOrgCode, err := getVendorOrgCode(storeID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -178,7 +178,7 @@ func (p *PurchaseHandler) GetStoreAllCategories(ctx *jxcontext.Context, storeID
func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) { func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
if globals.EnableYbStoreWrite { if globals.EnableYbStoreWrite {
vendorOrgCode, err := buildYbConfigs(storeID) vendorOrgCode, err := getVendorOrgCode(storeID)
if err != nil { if err != nil {
return err return err
} }
@@ -192,7 +192,7 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in
func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) { func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
if globals.EnableYbStoreWrite { if globals.EnableYbStoreWrite {
vendorOrgCode, err := buildYbConfigs(storeID) vendorOrgCode, err := getVendorOrgCode(storeID)
if err != nil { if err != nil {
return err return err
} }
@@ -203,7 +203,7 @@ func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID in
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error) { func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error) {
if globals.EnableYbStoreWrite { if globals.EnableYbStoreWrite {
vendorOrgCode, err := buildYbConfigs(storeID) vendorOrgCode, err := getVendorOrgCode(storeID)
if err != nil { if err != nil {
return err return err
} }
@@ -328,7 +328,19 @@ func buildProductInfoParam(storeSku *dao.StoreSkuSyncInfo) (productInfoParam *yi
return productInfoParam return productInfoParam
} }
func buildYbConfigs(storeID int) (vendorOrgCode string, err error) { func buildYbConfigs(storeID int) (err error) {
if storeID == 0 {
return fmt.Errorf("门店ID不能为空平台[%v]", model.VendorIDYB)
}
store, err := dao.GetStoreDetail(dao.GetDB(), storeID, model.VendorIDYB)
if err != nil {
return err
}
api.YinBaoAPI = yinbaoapi.New(store.YbAppKey, store.YbAppID)
return err
}
func getVendorOrgCode(storeID int) (vendorOrgCode string, err error) {
if storeID == 0 { if storeID == 0 {
return "", fmt.Errorf("门店ID不能为空平台[%v]", model.VendorIDYB) return "", fmt.Errorf("门店ID不能为空平台[%v]", model.VendorIDYB)
} }
@@ -336,9 +348,7 @@ func buildYbConfigs(storeID int) (vendorOrgCode string, err error) {
if err != nil { if err != nil {
return "", err return "", err
} }
api.YinBaoAPI = yinbaoapi.New(store.YbAppKey, store.YbAppID) return store.VendorOrgCode, err
vendorOrgCode = store.VendorOrgCode
return vendorOrgCode, err
} }
func convertVendorCatList(remoteCats []*yinbaoapi.LoadCategorysWithOptionResult) (cats []*partner.BareCategoryInfo) { func convertVendorCatList(remoteCats []*yinbaoapi.LoadCategorysWithOptionResult) (cats []*partner.BareCategoryInfo) {