ebai filter
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -205,6 +207,7 @@ func GetStoreDetailByVendorStoreID(db *DaoDB, vendorStoreID string, vendorID int
|
||||
if storeDetail, err = getStoreDetail(db, int(utils.Str2Int64WithDefault(vendorStoreID, 0)), vendorID, "", vendorOrgCode); err == nil {
|
||||
storeDetail.VendorStoreID = vendorStoreID
|
||||
}
|
||||
globals.SugarLogger.Debugf("GetStoreDetailByVendorStoreID storeDetail ====%s", utils.Format4Output(storeDetail, false))
|
||||
return storeDetail, err
|
||||
}
|
||||
|
||||
|
||||
@@ -270,6 +270,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
if err == nil {
|
||||
if shopID > 0 {
|
||||
err = p.UpdateStoreCustomID(jxcontext.AdminCtx, "", store.VendorStoreID, int64(shopID))
|
||||
globals.SugarLogger.Debugf("UpdateStore store.VendorStoreID====%s,shopID====%s", store.VendorStoreID, shopID)
|
||||
} else if shopID == 0 {
|
||||
// todo remove out shop id
|
||||
}
|
||||
@@ -342,7 +343,9 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
|
||||
}
|
||||
}
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.ShopIDBatchUpdate(baiduShopIDs, shopIDs)
|
||||
fBaiduIDs, fShopIDs, err1 := FilterStoreRel(baiduShopIDs, shopIDs)
|
||||
globals.SugarLogger.Debugf("RefreshAllStoresID FilterStoreRel fBaiduIDs====%d fShopIDs====%d err====%v", fBaiduIDs, fShopIDs, err1)
|
||||
err = api.EbaiAPI.ShopIDBatchUpdate(fBaiduIDs, fShopIDs)
|
||||
globals.SugarLogger.Debugf("RefreshAllStoresID baiduShopIDs====%s,shopIDs====%s", baiduShopIDs, shopIDs)
|
||||
}
|
||||
return nil, err
|
||||
@@ -360,6 +363,29 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
|
||||
return rootTask.ID, err
|
||||
}
|
||||
|
||||
//过滤ebai平台与本地门店ID映射关系是否正确对应修改
|
||||
func FilterStoreRel(baiduShopIDs []string, shopIDs []string) (fBaiduShopIDs []string, fShopIDs []string, err error) {
|
||||
//线上获取映射关系
|
||||
if len(baiduShopIDs) > 0 && len(shopIDs) > 0 {
|
||||
relInfo := utils.Params2Map("baidu_shop_ids", baiduShopIDs, "shop_ids", shopIDs)
|
||||
globals.SugarLogger.Debugf("FilterStoreRel relInfo====%s", utils.Format4Output(relInfo, false))
|
||||
for k, _ := range relInfo {
|
||||
remoteRel, err := api.EbaiAPI.ShopGet2("", utils.Str2Int64(k))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
localRel, err := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), k, model.VendorIDEBAI, "")
|
||||
globals.SugarLogger.Debugf("get localRel err===%v", err)
|
||||
if remoteRel.ShopID != utils.Int2Str(localRel.ID) {
|
||||
fBaiduShopIDs = append(fBaiduShopIDs, k)
|
||||
fShopIDs = append(fShopIDs, utils.Int2Str(localRel.ID))
|
||||
}
|
||||
}
|
||||
return fBaiduShopIDs, fShopIDs, nil
|
||||
}
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
// todo 此函数只考虑了在饿了么侧开店的情况
|
||||
func EbaiDeliveryType2Jx(deliveryType string) int8 {
|
||||
spIndex := strings.Index(deliveryType, "|")
|
||||
@@ -645,8 +671,13 @@ func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context, vendorOrg
|
||||
|
||||
func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode string, vendorStoreID string, storeID int64) (err error) {
|
||||
if globals.EnableJdStoreWrite {
|
||||
err = api.EbaiAPI.ShopIDBatchUpdate([]string{vendorStoreID}, []string{utils.Int64ToStr(storeID)})
|
||||
globals.SugarLogger.Debugf("UpdateStoreCustomID vendorStoreID====%s storeID====%d", vendorStoreID, storeID)
|
||||
fBaiduIDs, fShopIDs, err1 := FilterStoreRel([]string{vendorStoreID}, []string{utils.Int64ToStr(storeID)})
|
||||
if err1 != nil {
|
||||
globals.SugarLogger.Debugf("UpdateStoreCustomID err1====%v", err1)
|
||||
}
|
||||
globals.SugarLogger.Debugf("UpdateStoreCustomID fBaiduIDs====%s fShopIDs====%d err1", fBaiduIDs, fShopIDs)
|
||||
err = api.EbaiAPI.ShopIDBatchUpdate(fBaiduIDs, fShopIDs)
|
||||
//err = api.EbaiAPI.ShopIDBatchUpdate([]string{vendorStoreID}, []string{utils.Int64ToStr(storeID)})
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -6,25 +6,24 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/astaxie/beego/client/orm"
|
||||
"github.com/astaxie/beego/server/web"
|
||||
)
|
||||
|
||||
func Init() {
|
||||
// set default database
|
||||
// orm.RegisterDataBase(aliasName, driverName, dataSource, params)
|
||||
//正式服务器
|
||||
orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", ""))
|
||||
orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(111.231.218.230:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
//orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", ""))
|
||||
//orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(111.231.218.230:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
//orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
// 本地测试服调试
|
||||
// orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", ""))
|
||||
//orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
//orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
|
||||
//本地服务器测试用 -ysq
|
||||
//orm.RegisterDataBase("default", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
//orm.RegisterDataBase("c4beta", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
//orm.RegisterDataBase("api", "mysql", "root:123456@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
orm.RegisterDataBase("default", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
orm.RegisterDataBase("c4beta", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
orm.RegisterDataBase("api", "mysql", "root:123456@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
|
||||
|
||||
// 开启sql打印
|
||||
//orm.Debug = true
|
||||
|
||||
@@ -101,8 +101,8 @@ func Init() {
|
||||
}
|
||||
|
||||
SugarLogger.Infof("globals RunMode=%s", web.BConfig.RunMode)
|
||||
ReallyCallPlatformAPI = (web.BConfig.RunMode != "dev" && web.BConfig.RunMode != "test")
|
||||
//ReallyCallPlatformAPI = true //本地测试用-ysq
|
||||
//ReallyCallPlatformAPI = (web.BConfig.RunMode != "dev" && web.BConfig.RunMode != "test")
|
||||
ReallyCallPlatformAPI = true //本地测试用-ysq
|
||||
ReallySendWeixinMsg = ReallyCallPlatformAPI && IsProductEnv()
|
||||
|
||||
AliKey = web.AppConfig.DefaultString("aliKey", "")
|
||||
|
||||
Reference in New Issue
Block a user