diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 343eb29c3..c2ce3b835 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -1132,7 +1132,7 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vend } else if vendorID == model.VendorIDJX { ReCalculateJxPriceLight(db, ctx, storeID) } else if vendorID == model.VendorIDYB { - err = checkAppIDAndAppKey(db, storeMap, storeID) + err = checkYbParams(db, storeMap, storeID) if err != nil { return nil, err } @@ -2877,10 +2877,11 @@ func DeletePrinterSeq(ctx *jxcontext.Context, storeIDs []int) (err error) { return err } -func checkAppIDAndAppKey(db *dao.DaoDB, storeMap *model.StoreMap, storeID int) (err error) { +func checkYbParams(db *dao.DaoDB, storeMap *model.StoreMap, storeID int) (err error) { var ( - appID = storeMap.YbAppID - appKey = storeMap.YbAppKey + appID = storeMap.YbAppID + appKey = storeMap.YbAppKey + yinbaoCookie string ) if appID == "" { return fmt.Errorf("绑定银豹平台必须输入appID!") @@ -2901,9 +2902,6 @@ func checkAppIDAndAppKey(db *dao.DaoDB, storeMap *model.StoreMap, storeID int) ( } } storeMaps, err := dao.GetStoresMapList2(db, []int{model.VendorIDYB}, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", false) - if err != nil { - return err - } if len(storeMaps) > 0 { for _, v := range storeMaps { if v.YbAppID == appID { @@ -2914,5 +2912,22 @@ func checkAppIDAndAppKey(db *dao.DaoDB, storeMap *model.StoreMap, storeID int) ( } } } + stores, err := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "") + if len(stores) > 0 { + if configs, err := dao.QueryConfigs(dao.GetDB(), "yinbaoCookie", model.ConfigTypeCookie, ""); err == nil { + yinbaoCookie = configs[0].Value + } + api.YinBaoAPI.SetCookie(".POSPALAUTH30220", yinbaoCookie) + result, err := api.YinBaoAPI.LoadSubStoresByUserIdDDLJson() + if err != nil { + return err + } + for _, v := range result { + if v.Company == stores[0].Name { + storeMap.VendorStoreID = utils.Int2Str(v.ID) + break + } + } + } return err }