门店绑定银豹平台的appidkey的判断
This commit is contained in:
@@ -13,6 +13,8 @@ import (
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/yinbaoapi"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals/refutil"
|
||||
|
||||
"github.com/360EntSecGroup-Skylar/excelize"
|
||||
@@ -1129,6 +1131,11 @@ 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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
dao.WrapAddIDCULDEntity(storeMap, userName)
|
||||
@@ -2869,3 +2876,42 @@ func DeletePrinterSeq(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func checkAppIDAndAppKey(db *dao.DaoDB, storeMap *model.StoreMap, storeID int) (err error) {
|
||||
var (
|
||||
appID = storeMap.YbAppID
|
||||
appKey = storeMap.YbAppKey
|
||||
)
|
||||
if appID == "" {
|
||||
return fmt.Errorf("绑定银豹平台必须输入appID!")
|
||||
}
|
||||
if appKey == "" {
|
||||
return fmt.Errorf("绑定银豹平台必须输入appKey!")
|
||||
}
|
||||
_, err = api.YinBaoAPI.QueryProductByBarcode("")
|
||||
if err != nil {
|
||||
if errCode, ok := err.(*utils.ErrorWithCode); ok {
|
||||
if errCode.Code() == yinbaoapi.AppIDErrCode {
|
||||
return fmt.Errorf("请输入正确的银豹appID!,[%v]", appID)
|
||||
}
|
||||
if errCode.Code() == yinbaoapi.AppKeyErrCode {
|
||||
return fmt.Errorf("请输入正确的银豹appKey!,[%v]", appKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
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 {
|
||||
return fmt.Errorf("appID和已有店铺重复![%v]", v.StoreName)
|
||||
}
|
||||
if v.YbAppKey == appKey {
|
||||
return fmt.Errorf("appKey和已有店铺重复![%v]", v.StoreName)
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user