Merge branch 'jdshop' of e.coding.net:rosydev/jx-callback into jdshop
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"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 {
|
if storeDetail, err = getStoreDetail(db, int(utils.Str2Int64WithDefault(vendorStoreID, 0)), vendorID, "", vendorOrgCode); err == nil {
|
||||||
storeDetail.VendorStoreID = vendorStoreID
|
storeDetail.VendorStoreID = vendorStoreID
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debugf("GetStoreDetailByVendorStoreID storeDetail ====%s", utils.Format4Output(storeDetail, false))
|
||||||
return storeDetail, err
|
return storeDetail, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
if shopID > 0 {
|
if shopID > 0 {
|
||||||
err = p.UpdateStoreCustomID(jxcontext.AdminCtx, "", store.VendorStoreID, int64(shopID))
|
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 {
|
} else if shopID == 0 {
|
||||||
// todo remove out shop id
|
// todo remove out shop id
|
||||||
}
|
}
|
||||||
@@ -342,7 +343,9 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if globals.EnableEbaiStoreWrite {
|
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)
|
globals.SugarLogger.Debugf("RefreshAllStoresID baiduShopIDs====%s,shopIDs====%s", baiduShopIDs, shopIDs)
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -360,6 +363,29 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
|
|||||||
return rootTask.ID, err
|
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 此函数只考虑了在饿了么侧开店的情况
|
// todo 此函数只考虑了在饿了么侧开店的情况
|
||||||
func EbaiDeliveryType2Jx(deliveryType string) int8 {
|
func EbaiDeliveryType2Jx(deliveryType string) int8 {
|
||||||
spIndex := strings.Index(deliveryType, "|")
|
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) {
|
func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode string, vendorStoreID string, storeID int64) (err error) {
|
||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
err = api.EbaiAPI.ShopIDBatchUpdate([]string{vendorStoreID}, []string{utils.Int64ToStr(storeID)})
|
fBaiduIDs, fShopIDs, err1 := FilterStoreRel([]string{vendorStoreID}, []string{utils.Int64ToStr(storeID)})
|
||||||
globals.SugarLogger.Debugf("UpdateStoreCustomID vendorStoreID====%s storeID====%d", vendorStoreID, 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
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user