- add conf enableJdStoreWrite
- enable enableEbaiStoreWrite on beta
This commit is contained in:
@@ -436,7 +436,7 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync, isContinueW
|
|||||||
for k, v := range modifyPrices {
|
for k, v := range modifyPrices {
|
||||||
modifyPrices2[k] = v.(*jdapi.SkuPriceInfo)
|
modifyPrices2[k] = v.(*jdapi.SkuPriceInfo)
|
||||||
}
|
}
|
||||||
if globals.EnableStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
if _, err = api.JdAPI.UpdateVendorStationPrice(utils.Int2Str(storeID), "", modifyPrices2); err != nil {
|
if _, err = api.JdAPI.UpdateVendorStationPrice(utils.Int2Str(storeID), "", modifyPrices2); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -1048,7 +1048,7 @@ func getPromotionHander(promotionType int) JdPromotionHandler {
|
|||||||
// panic(fmt.Sprintf("unknown promotion type:%d", promotionType))
|
// panic(fmt.Sprintf("unknown promotion type:%d", promotionType))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !globals.EnableStoreWrite {
|
if !globals.EnableJdStoreWrite {
|
||||||
promotionHandler = &JdNullHandler{}
|
promotionHandler = &JdNullHandler{}
|
||||||
}
|
}
|
||||||
return promotionHandler
|
return promotionHandler
|
||||||
|
|||||||
@@ -728,7 +728,7 @@ func TransformJdSpu2Sku(ctx *jxcontext.Context, skuNameIDs []int, count int, isA
|
|||||||
skuIDs = append(skuIDs, sku.ID)
|
skuIDs = append(skuIDs, sku.ID)
|
||||||
locker.Unlock()
|
locker.Unlock()
|
||||||
if !jxutils.IsFakeID(sku.JdID) {
|
if !jxutils.IsFakeID(sku.JdID) {
|
||||||
if globals.EnableStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
if err = api.JdAPI.UpdateSkuBaseInfo(utils.Int2Str(skuName.ID), utils.Int2Str(sku.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusDeleted)); err != nil {
|
if err = api.JdAPI.UpdateSkuBaseInfo(utils.Int2Str(skuName.ID), utils.Int2Str(sku.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusDeleted)); err != nil {
|
||||||
if errExt, ok := err.(*utils.ErrorWithCode); ok && errExt.IntCode() == 11004 {
|
if errExt, ok := err.(*utils.ErrorWithCode); ok && errExt.IntCode() == 11004 {
|
||||||
err = nil
|
err = nil
|
||||||
@@ -740,7 +740,7 @@ func TransformJdSpu2Sku(ctx *jxcontext.Context, skuNameIDs []int, count int, isA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err == nil && globals.EnableStoreWrite {
|
if err == nil && globals.EnableJdStoreWrite {
|
||||||
if err = api.JdAPI.UpdateSpu(utils.Int2Str(skuName.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusOffline)); err == nil {
|
if err = api.JdAPI.UpdateSpu(utils.Int2Str(skuName.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusOffline)); err == nil {
|
||||||
err = api.JdAPI.UpdateSpu(utils.Int2Str(skuName.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusDeleted))
|
err = api.JdAPI.UpdateSpu(utils.Int2Str(skuName.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusDeleted))
|
||||||
} else if errExt, ok := err.(*utils.ErrorWithCode); ok && errExt.IntCode() == 11035 {
|
} else if errExt, ok := err.(*utils.ErrorWithCode); ok && errExt.IntCode() == 11035 {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"github.com/astaxie/beego"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IAuther interface {
|
type IAuther interface {
|
||||||
@@ -71,7 +70,7 @@ func New(notUsed interface{}, token string, w http.ResponseWriter, r *http.Reque
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err == model.ErrTokenIsInvalid {
|
if err == model.ErrTokenIsInvalid {
|
||||||
if beego.BConfig.RunMode != "prod" {
|
if !globals.IsProductEnv() {
|
||||||
err = nil
|
err = nil
|
||||||
} else {
|
} else {
|
||||||
errCode = model.ErrCodeTokenIsInvalid
|
errCode = model.ErrCodeTokenIsInvalid
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func RefreshConfig(configKey string, expiresTime time.Duration, configGetter fun
|
|||||||
}
|
}
|
||||||
if handleType != 0 {
|
if handleType != 0 {
|
||||||
if curConfig.Token, curConfig.Date = configGetter(); curConfig.Token == "" {
|
if curConfig.Token, curConfig.Date = configGetter(); curConfig.Token == "" {
|
||||||
if beego.BConfig.RunMode == "prod" {
|
if globals.IsProductEnv() {
|
||||||
globals.SugarLogger.Errorf("RefreshConfig %s get empty token", configKey)
|
globals.SugarLogger.Errorf("RefreshConfig %s get empty token", configKey)
|
||||||
sleepDuration = errRefreshGap
|
sleepDuration = errRefreshGap
|
||||||
} else {
|
} else {
|
||||||
@@ -154,7 +154,7 @@ func RefreshWeixinToken() (err error) {
|
|||||||
func RefreshElmToken() (err error) {
|
func RefreshElmToken() (err error) {
|
||||||
if api.ElmAPI != nil {
|
if api.ElmAPI != nil {
|
||||||
err = RefreshConfig("eleme", elmTokenExpires, func() (string, string) {
|
err = RefreshConfig("eleme", elmTokenExpires, func() (string, string) {
|
||||||
if beego.BConfig.RunMode == "prod" {
|
if globals.IsProductEnv() {
|
||||||
if tokenInfo, err := api.ElmAPI.RefreshTokenIndividual(); err == nil {
|
if tokenInfo, err := api.ElmAPI.RefreshTokenIndividual(); err == nil {
|
||||||
tokenInfo2 := &ElmTokenForCompatible{
|
tokenInfo2 := &ElmTokenForCompatible{
|
||||||
Error: "",
|
Error: "",
|
||||||
@@ -183,7 +183,7 @@ func RefreshElmToken() (err error) {
|
|||||||
func RefreshWeimobToken() (err error) {
|
func RefreshWeimobToken() (err error) {
|
||||||
if api.WeimobAPI != nil {
|
if api.WeimobAPI != nil {
|
||||||
err = RefreshConfig("weimob", weimobTokenExpires, func() (string, string) {
|
err = RefreshConfig("weimob", weimobTokenExpires, func() (string, string) {
|
||||||
if beego.BConfig.RunMode == "prod" {
|
if globals.IsProductEnv() {
|
||||||
if tokenInfo, err := api.WeimobAPI.RefreshTokenByRefreshToken(); err == nil {
|
if tokenInfo, err := api.WeimobAPI.RefreshTokenByRefreshToken(); err == nil {
|
||||||
return string(utils.MustMarshal(tokenInfo)), utils.Time2Str(time.Now().Add((time.Duration(tokenInfo.ExpiresIn) - weimobTokenExpires/time.Second) * time.Second))
|
return string(utils.MustMarshal(tokenInfo)), utils.Time2Str(time.Now().Add((time.Duration(tokenInfo.ExpiresIn) - weimobTokenExpires/time.Second) * time.Second))
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ func RefreshDingDingToken() (err error) {
|
|||||||
api.DingDingAPI.RetrieveToken()
|
api.DingDingAPI.RetrieveToken()
|
||||||
return RefreshConfig("dingding", dingdingTokenExpires, func() (string, string) {
|
return RefreshConfig("dingding", dingdingTokenExpires, func() (string, string) {
|
||||||
globals.SugarLogger.Debugf("RefreshDingDingToken RunMode:%s", beego.BConfig.RunMode)
|
globals.SugarLogger.Debugf("RefreshDingDingToken RunMode:%s", beego.BConfig.RunMode)
|
||||||
if true { //beego.BConfig.RunMode == "prod" {
|
if true { //globals.IsProductEnv() {
|
||||||
if token, err := api.DingDingAPI.RetrieveToken(); err == nil {
|
if token, err := api.DingDingAPI.RetrieveToken(); err == nil {
|
||||||
globals.SugarLogger.Debugf("RefreshDingDingToken tokenInfo:%s", token)
|
globals.SugarLogger.Debugf("RefreshDingDingToken tokenInfo:%s", token)
|
||||||
return token, ""
|
return token, ""
|
||||||
@@ -232,7 +232,7 @@ func SaveWeimobToken(token *weimobapi.TokenInfo) (err error) {
|
|||||||
func RefreshYilianyunToken() (err error) {
|
func RefreshYilianyunToken() (err error) {
|
||||||
return RefreshConfig("yilianyun", yilianyunTokenExpires, func() (string, string) {
|
return RefreshConfig("yilianyun", yilianyunTokenExpires, func() (string, string) {
|
||||||
globals.SugarLogger.Debugf("RefreshYilianyunToken RunMode:%s", beego.BConfig.RunMode)
|
globals.SugarLogger.Debugf("RefreshYilianyunToken RunMode:%s", beego.BConfig.RunMode)
|
||||||
if beego.BConfig.RunMode == "prod" {
|
if globals.IsProductEnv() {
|
||||||
if tokenInfo, err := api.YilianyunAPI.RetrieveToken(); err == nil {
|
if tokenInfo, err := api.YilianyunAPI.RetrieveToken(); err == nil {
|
||||||
return string(utils.MustMarshal(tokenInfo)), ""
|
return string(utils.MustMarshal(tokenInfo)), ""
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func (p *PurchaseHandler) CreateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
params["category1"] = ""
|
params["category1"] = ""
|
||||||
params["category2"] = ""
|
params["category2"] = ""
|
||||||
params["category3"] = ""
|
params["category3"] = ""
|
||||||
if globals.EnableStoreWrite && globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
intVendorStoreID, err2 := api.EbaiAPI.ShopCreate(params)
|
intVendorStoreID, err2 := api.EbaiAPI.ShopCreate(params)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
return utils.Int64ToStr(intVendorStoreID), err
|
return utils.Int64ToStr(intVendorStoreID), err
|
||||||
@@ -160,7 +160,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
if err = dao.GetRows(db, &stores, sql, model.VendorIDEBAI, utils.DefaultTimeValue, storeID); err == nil {
|
if err = dao.GetRows(db, &stores, sql, model.VendorIDEBAI, utils.DefaultTimeValue, storeID); err == nil {
|
||||||
for _, store := range stores {
|
for _, store := range stores {
|
||||||
// globals.SugarLogger.Debug(utils.Format4Output(params, false))
|
// globals.SugarLogger.Debug(utils.Format4Output(params, false))
|
||||||
if globals.EnableStoreWrite && globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
shopID := 0
|
shopID := 0
|
||||||
if store.SyncStatus&model.SyncFlagDeletedMask == 0 {
|
if store.SyncStatus&model.SyncFlagDeletedMask == 0 {
|
||||||
shopID = store.ID
|
shopID = store.ID
|
||||||
@@ -248,7 +248,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
|
|||||||
shopIDs[k] = utils.GetUUID()
|
shopIDs[k] = utils.GetUUID()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if globals.EnableStoreWrite && globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
err = api.EbaiAPI.ShopIDBatchUpdate(baiduShopIDs, shopIDs)
|
err = api.EbaiAPI.ShopIDBatchUpdate(baiduShopIDs, shopIDs)
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
|||||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
storeSku := batchItemList[0].(*tStoreSkuFullInfo)
|
storeSku := batchItemList[0].(*tStoreSkuFullInfo)
|
||||||
updateFields := []string{model.FieldEbaiSyncStatus}
|
updateFields := []string{model.FieldEbaiSyncStatus}
|
||||||
if globals.EnableStoreWrite && globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
if storeSku.SkuID == 0 || storeSku.EbaiSyncStatus&model.SyncFlagDeletedMask != 0 {
|
if storeSku.SkuID == 0 || storeSku.EbaiSyncStatus&model.SyncFlagDeletedMask != 0 {
|
||||||
if storeSku.EbaiSyncStatus&model.SyncFlagNewMask == 0 && storeSku.EbaiID != 0 {
|
if storeSku.EbaiSyncStatus&model.SyncFlagNewMask == 0 && storeSku.EbaiID != 0 {
|
||||||
err = api.EbaiAPI.SkuDelete(strStoreID, utils.Int64ToStr(storeSku.EbaiID))
|
err = api.EbaiAPI.SkuDelete(strStoreID, utils.Int64ToStr(storeSku.EbaiID))
|
||||||
@@ -344,7 +344,7 @@ func (p *PurchaseHandler) DeleteRemoteSkus(ctx *jxcontext.Context, parentTask ta
|
|||||||
for k, v := range batchItemList {
|
for k, v := range batchItemList {
|
||||||
strList[k] = v.(string)
|
strList[k] = v.(string)
|
||||||
}
|
}
|
||||||
if globals.EnableStoreWrite && globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
err = api.EbaiAPI.SkuDelete(utils.Int2Str(storeID), strings.Join(strList, ","))
|
err = api.EbaiAPI.SkuDelete(utils.Int2Str(storeID), strings.Join(strList, ","))
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -369,7 +369,7 @@ func (p *PurchaseHandler) DeleteRemoteCategories(ctx *jxcontext.Context, parentT
|
|||||||
}
|
}
|
||||||
task := tasksch.NewParallelTask("DeleteRemoteCategories", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
task := tasksch.NewParallelTask("DeleteRemoteCategories", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
if globals.EnableStoreWrite && globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
err = api.EbaiAPI.ShopCategoryDelete(strStoreID, batchItemList[0].(int64))
|
err = api.EbaiAPI.ShopCategoryDelete(strStoreID, batchItemList[0].(int64))
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -516,7 +516,7 @@ func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask t
|
|||||||
updateFields := []string{model.FieldEbaiSyncStatus}
|
updateFields := []string{model.FieldEbaiSyncStatus}
|
||||||
catInfo := batchItemList[0].(*tStoreCatInfo)
|
catInfo := batchItemList[0].(*tStoreCatInfo)
|
||||||
// globals.SugarLogger.Debug(utils.Format4Output(catInfo, false))
|
// globals.SugarLogger.Debug(utils.Format4Output(catInfo, false))
|
||||||
if globals.EnableStoreWrite && globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
if catInfo.EbaiSyncStatus&model.SyncFlagDeletedMask != 0 { // 删除
|
if catInfo.EbaiSyncStatus&model.SyncFlagDeletedMask != 0 { // 删除
|
||||||
if catInfo.EbaiSyncStatus&model.SyncFlagNewMask == 0 && catInfo.EbaiID != 0 {
|
if catInfo.EbaiSyncStatus&model.SyncFlagNewMask == 0 && catInfo.EbaiID != 0 {
|
||||||
err = api.EbaiAPI.ShopCategoryDelete(strStoreID, catInfo.EbaiID)
|
err = api.EbaiAPI.ShopCategoryDelete(strStoreID, catInfo.EbaiID)
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
}
|
}
|
||||||
_, params["closeStatus"] = JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus))
|
_, params["closeStatus"] = JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus))
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(params, false))
|
globals.SugarLogger.Debug(utils.Format4Output(params, false))
|
||||||
if globals.EnableStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
if err = api.JdAPI.UpdateStoreInfo4Open(store.VendorStoreID, store.RealLastOperator, params); err != nil {
|
if err = api.JdAPI.UpdateStoreInfo4Open(store.VendorStoreID, store.RealLastOperator, params); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
|
|||||||
if step != stepCount-1 {
|
if step != stepCount-1 {
|
||||||
storeParams["outSystemId"] = utils.GetUUID()
|
storeParams["outSystemId"] = utils.GetUUID()
|
||||||
}
|
}
|
||||||
if true { //globals.EnableStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
err = api.JdAPI.UpdateStoreInfo4Open(store.VendorStoreID, ctx.GetUserName(), storeParams)
|
err = api.JdAPI.UpdateStoreInfo4Open(store.VendorStoreID, ctx.GetUserName(), storeParams)
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
|||||||
}
|
}
|
||||||
syncMask := 0
|
syncMask := 0
|
||||||
errList := []error{}
|
errList := []error{}
|
||||||
if globals.EnableStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
// todo 以下可以优化为并行操作
|
// todo 以下可以优化为并行操作
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(skuVendibilityList, false), utils.Format4Output(skuPriceInfoList, false), utils.Format4Output(skuStockList, false))
|
globals.SugarLogger.Debug(utils.Format4Output(skuVendibilityList, false), utils.Format4Output(skuPriceInfoList, false), utils.Format4Output(skuStockList, false))
|
||||||
if len(skuVendibilityList) > 0 {
|
if len(skuVendibilityList) > 0 {
|
||||||
@@ -239,7 +239,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("jd syncStoreSkus sync detail, storeID:%d, skuVendibilityList:%s, skuPriceInfoList:%s, skuStockList:%s", storeID, utils.Format4Output(skuVendibilityList, true), utils.Format4Output(skuPriceInfoList, true), utils.Format4Output(skuStockList, true))
|
globals.SugarLogger.Debugf("jd syncStoreSkus sync detail, storeID:%d, skuVendibilityList:%s, skuPriceInfoList:%s, skuStockList:%s", storeID, utils.Format4Output(skuVendibilityList, true), utils.Format4Output(skuPriceInfoList, true), utils.Format4Output(skuStockList, true))
|
||||||
if globals.EnableStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
// todo 以下可以优化为并行操作
|
// todo 以下可以优化为并行操作
|
||||||
if len(skuVendibilityList) > 0 {
|
if len(skuVendibilityList) > 0 {
|
||||||
_, err = api.JdAPI.BatchUpdateVendibility("", stationNo, skuVendibilityList, ctx.GetUserName())
|
_, err = api.JdAPI.BatchUpdateVendibility("", stationNo, skuVendibilityList, ctx.GetUserName())
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask t
|
|||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
updateFields := []string{dao.GetSyncStatusStructField(model.VendorNames[model.VendorIDMTWM])}
|
updateFields := []string{dao.GetSyncStatusStructField(model.VendorNames[model.VendorIDMTWM])}
|
||||||
catInfo := batchItemList[0].(*dao.StoreCatSyncInfo)
|
catInfo := batchItemList[0].(*dao.StoreCatSyncInfo)
|
||||||
if globals.EnableStoreWrite && globals.EnableMtwmStoreWrite {
|
if globals.EnableMtwmStoreWrite {
|
||||||
if catInfo.MtwmSyncStatus&model.SyncFlagDeletedMask != 0 { // 删除
|
if catInfo.MtwmSyncStatus&model.SyncFlagDeletedMask != 0 { // 删除
|
||||||
if catInfo.MtwmSyncStatus&model.SyncFlagNewMask == 0 && catInfo.MtwmID != "" {
|
if catInfo.MtwmSyncStatus&model.SyncFlagNewMask == 0 && catInfo.MtwmID != "" {
|
||||||
globals.SugarLogger.Debugf("RetailCatDelete vendorStoreID:%s, MtwmID:%s", vendorStoreID, catInfo.MtwmID)
|
globals.SugarLogger.Debugf("RetailCatDelete vendorStoreID:%s, MtwmID:%s", vendorStoreID, catInfo.MtwmID)
|
||||||
@@ -129,7 +129,7 @@ func (p *PurchaseHandler) SyncLocalStoreCategory(ctx *jxcontext.Context, db *dao
|
|||||||
localCat := catMap[level-1][parentCatName+"/"+catName]
|
localCat := catMap[level-1][parentCatName+"/"+catName]
|
||||||
// globals.SugarLogger.Debug(parentCatName, " ", catName, " ", localCat)
|
// globals.SugarLogger.Debug(parentCatName, " ", catName, " ", localCat)
|
||||||
if localCat == nil { // 本地分类就没有这个名字,直接删除
|
if localCat == nil { // 本地分类就没有这个名字,直接删除
|
||||||
if globals.EnableStoreWrite && globals.EnableMtwmStoreWrite {
|
if globals.EnableMtwmStoreWrite {
|
||||||
globals.SugarLogger.Debugf("RetailCatDelete2 vendorStoreID:%s, catName:%s", vendorStoreID, catName)
|
globals.SugarLogger.Debugf("RetailCatDelete2 vendorStoreID:%s, catName:%s", vendorStoreID, catName)
|
||||||
if err = api.MtwmAPI.RetailCatDelete(vendorStoreID, catName); err != nil {
|
if err = api.MtwmAPI.RetailCatDelete(vendorStoreID, catName); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -292,7 +292,7 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
|||||||
skus[0]["weight"] = skuItem.Weight // weight字段仅限服饰鞋帽、美妆、日用品、母婴、生鲜果蔬、生活超市下的便利店/超市门店品类的商家使用
|
skus[0]["weight"] = skuItem.Weight // weight字段仅限服饰鞋帽、美妆、日用品、母婴、生鲜果蔬、生活超市下的便利店/超市门店品类的商家使用
|
||||||
}
|
}
|
||||||
foodData["skus"] = skus
|
foodData["skus"] = skus
|
||||||
if globals.EnableStoreWrite && globals.EnableMtwmStoreWrite {
|
if globals.EnableMtwmStoreWrite {
|
||||||
if err = api.MtwmAPI.RetailBatchInitData(vendorStoreID, foodDataList); err == nil {
|
if err = api.MtwmAPI.RetailBatchInitData(vendorStoreID, foodDataList); err == nil {
|
||||||
storeSkuBind.MtwmID = int64(skuItem.ID)
|
storeSkuBind.MtwmID = int64(skuItem.ID)
|
||||||
updateFields = append(updateFields, model.FieldMtwmID)
|
updateFields = append(updateFields, model.FieldMtwmID)
|
||||||
@@ -373,7 +373,7 @@ func (p *PurchaseHandler) DeleteRemoteSkus(ctx *jxcontext.Context, parentTask ta
|
|||||||
vendorStoreID := storeDetail.VendorStoreID
|
vendorStoreID := storeDetail.VendorStoreID
|
||||||
task := tasksch.NewParallelTask("mtwm DeleteRemoteSkus", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
task := tasksch.NewParallelTask("mtwm DeleteRemoteSkus", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
if globals.EnableStoreWrite && globals.EnableMtwmStoreWrite {
|
if globals.EnableMtwmStoreWrite {
|
||||||
// globals.SugarLogger.Debugf("mtwm RetailDelete vendorStoreID:%s, sku:%s", vendorStoreID, batchItemList[0].(string))
|
// globals.SugarLogger.Debugf("mtwm RetailDelete vendorStoreID:%s, sku:%s", vendorStoreID, batchItemList[0].(string))
|
||||||
err = api.MtwmAPI.RetailDelete(vendorStoreID, batchItemList[0].(string))
|
err = api.MtwmAPI.RetailDelete(vendorStoreID, batchItemList[0].(string))
|
||||||
}
|
}
|
||||||
@@ -434,7 +434,7 @@ func (p *PurchaseHandler) DeleteRemoteCategories(ctx *jxcontext.Context, parentT
|
|||||||
if len(catIDs) > 0 {
|
if len(catIDs) > 0 {
|
||||||
task := tasksch.NewParallelTask("mtwm DeleteRemoteCategories paralle", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
task := tasksch.NewParallelTask("mtwm DeleteRemoteCategories paralle", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
if globals.EnableStoreWrite && globals.EnableMtwmStoreWrite {
|
if globals.EnableMtwmStoreWrite {
|
||||||
err = api.MtwmAPI.RetailCatDelete(vendorStoreID, batchItemList[0].(string))
|
err = api.MtwmAPI.RetailCatDelete(vendorStoreID, batchItemList[0].(string))
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask t
|
|||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
updateFields := []string{dao.GetSyncStatusStructField(model.VendorNames[model.VendorIDWSC])}
|
updateFields := []string{dao.GetSyncStatusStructField(model.VendorNames[model.VendorIDWSC])}
|
||||||
catInfo := batchItemList[0].(*dao.StoreCatSyncInfo)
|
catInfo := batchItemList[0].(*dao.StoreCatSyncInfo)
|
||||||
if globals.EnableStoreWrite && globals.EnableWscStoreWrite {
|
if globals.EnableWscStoreWrite {
|
||||||
if catInfo.WscSyncStatus&model.SyncFlagDeletedMask != 0 { // 删除
|
if catInfo.WscSyncStatus&model.SyncFlagDeletedMask != 0 { // 删除
|
||||||
if catInfo.WscSyncStatus&model.SyncFlagNewMask == 0 {
|
if catInfo.WscSyncStatus&model.SyncFlagNewMask == 0 {
|
||||||
globals.SugarLogger.Debugf("UpdateClassify strStoreID:%s, WscID:%d", strStoreID, catInfo.WscID)
|
globals.SugarLogger.Debugf("UpdateClassify strStoreID:%s, WscID:%d", strStoreID, catInfo.WscID)
|
||||||
@@ -222,7 +222,7 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if globals.EnableStoreWrite && globals.EnableWscStoreWrite {
|
if globals.EnableWscStoreWrite {
|
||||||
if skuItem.SkuSyncStatus&model.SyncFlagNewMask != 0 {
|
if skuItem.SkuSyncStatus&model.SyncFlagNewMask != 0 {
|
||||||
goodsID, skuMap, err2 := api.WeimobAPI.AddGoods(outerGoodsCode, title, false, []string{skuItem.Img}, skuItem.Comment, isPutAway, 0, categoryId, classifyIdList, b2cGoods, skuList, nil)
|
goodsID, skuMap, err2 := api.WeimobAPI.AddGoods(outerGoodsCode, title, false, []string{skuItem.Img}, skuItem.Comment, isPutAway, 0, categoryId, classifyIdList, b2cGoods, skuList, nil)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ mtwmCallbackURL = "http://callback.jxc4.com"
|
|||||||
autonaviKey = "4427170f870af2110becb8852d36ab08"
|
autonaviKey = "4427170f870af2110becb8852d36ab08"
|
||||||
|
|
||||||
enableStoreWrite = false
|
enableStoreWrite = false
|
||||||
|
enableJdStoreWrite = false
|
||||||
enableEbaiStoreWrite = false
|
enableEbaiStoreWrite = false
|
||||||
enableElmStoreWrite = true
|
enableElmStoreWrite = false
|
||||||
enableMtwmStoreWrite = false
|
enableMtwmStoreWrite = false
|
||||||
enableWscStoreWrite = false
|
enableWscStoreWrite = false
|
||||||
|
|
||||||
@@ -139,6 +140,7 @@ weixinSecret = "6bbbed1443cc062c20a015a64c07a531"
|
|||||||
dbConnectStr = "root:WebServer@1@tcp(db1.int.jxc4.com:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
dbConnectStr = "root:WebServer@1@tcp(db1.int.jxc4.com:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
||||||
|
|
||||||
enableStoreWrite = true
|
enableStoreWrite = true
|
||||||
|
enableJdStoreWrite = true
|
||||||
enableEbaiStoreWrite = true
|
enableEbaiStoreWrite = true
|
||||||
enableMtwmStoreWrite = true
|
enableMtwmStoreWrite = true
|
||||||
enableWscStoreWrite = true
|
enableWscStoreWrite = true
|
||||||
@@ -169,6 +171,7 @@ disableMtwm = true
|
|||||||
disableWeimob = true
|
disableWeimob = true
|
||||||
|
|
||||||
enableStoreWrite = true
|
enableStoreWrite = true
|
||||||
|
enableJdStoreWrite = true
|
||||||
enableEbaiStoreWrite = true
|
enableEbaiStoreWrite = true
|
||||||
|
|
||||||
mtpsAppKey = "3c0a05d464c247c19d7ec13accc78605"
|
mtpsAppKey = "3c0a05d464c247c19d7ec13accc78605"
|
||||||
@@ -293,6 +296,13 @@ enableMtwmStoreWrite = true
|
|||||||
enableWscStoreWrite = false
|
enableWscStoreWrite = false
|
||||||
|
|
||||||
[beta]
|
[beta]
|
||||||
|
enableStoreWrite = true
|
||||||
|
enableJdStoreWrite = false
|
||||||
|
enableEbaiStoreWrite = true
|
||||||
|
enableElmStoreWrite = false
|
||||||
|
enableMtwmStoreWrite = false
|
||||||
|
enableWscStoreWrite = false
|
||||||
|
|
||||||
jdToken = "ccb10daf-e6f5-4a58-ada5-b97f9073a137"
|
jdToken = "ccb10daf-e6f5-4a58-ada5-b97f9073a137"
|
||||||
jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d"
|
jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d"
|
||||||
jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4"
|
jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4"
|
||||||
@@ -302,8 +312,8 @@ elmToken = ""
|
|||||||
elmAppKey = "KLRDcOZGrk"
|
elmAppKey = "KLRDcOZGrk"
|
||||||
elmSecret = "1fc221f8265506531da36fb613d5f5ad673f2e9a"
|
elmSecret = "1fc221f8265506531da36fb613d5f5ad673f2e9a"
|
||||||
|
|
||||||
ebaiSource = "34665"
|
ebaiSource = "35957"
|
||||||
ebaiSecret = "c3db75b754ea2d89"
|
ebaiSecret = "10013fbb7c2ddad7"
|
||||||
|
|
||||||
mtpsAppKey = "3c0a05d464c247c19d7ec13accc78605"
|
mtpsAppKey = "3c0a05d464c247c19d7ec13accc78605"
|
||||||
mtpsSecret = "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE"
|
mtpsSecret = "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE"
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ var (
|
|||||||
AliSecret string
|
AliSecret string
|
||||||
|
|
||||||
EnableStoreWrite bool
|
EnableStoreWrite bool
|
||||||
|
EnableJdStoreWrite bool
|
||||||
EnableEbaiStoreWrite bool
|
EnableEbaiStoreWrite bool
|
||||||
EnableElmStoreWrite bool
|
EnableElmStoreWrite bool
|
||||||
EnableMtwmStoreWrite bool
|
EnableMtwmStoreWrite bool
|
||||||
@@ -55,13 +56,14 @@ func init() {
|
|||||||
func Init() {
|
func Init() {
|
||||||
SugarLogger.Infof("globals RunMode=%s", beego.BConfig.RunMode)
|
SugarLogger.Infof("globals RunMode=%s", beego.BConfig.RunMode)
|
||||||
ReallyCallPlatformAPI = (beego.BConfig.RunMode != "dev" && beego.BConfig.RunMode != "test")
|
ReallyCallPlatformAPI = (beego.BConfig.RunMode != "dev" && beego.BConfig.RunMode != "test")
|
||||||
ReallySendWeixinMsg = ReallyCallPlatformAPI && beego.BConfig.RunMode == "prod"
|
ReallySendWeixinMsg = ReallyCallPlatformAPI && IsProductEnv()
|
||||||
ReallyReplyComment = ReallyCallPlatformAPI && beego.BConfig.RunMode == "prod"
|
ReallyReplyComment = ReallyCallPlatformAPI && IsProductEnv()
|
||||||
|
|
||||||
AliKey = beego.AppConfig.DefaultString("aliKey", "")
|
AliKey = beego.AppConfig.DefaultString("aliKey", "")
|
||||||
AliSecret = beego.AppConfig.DefaultString("aliSecret", "")
|
AliSecret = beego.AppConfig.DefaultString("aliSecret", "")
|
||||||
|
|
||||||
EnableStoreWrite = beego.AppConfig.DefaultBool("enableStoreWrite", false)
|
EnableStoreWrite = beego.AppConfig.DefaultBool("enableStoreWrite", false)
|
||||||
|
EnableJdStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableJdStoreWrite", false)
|
||||||
EnableEbaiStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableEbaiStoreWrite", false)
|
EnableEbaiStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableEbaiStoreWrite", false)
|
||||||
EnableElmStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableElmStoreWrite", false)
|
EnableElmStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableElmStoreWrite", false)
|
||||||
EnableMtwmStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableMtwmStoreWrite", false)
|
EnableMtwmStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableMtwmStoreWrite", false)
|
||||||
|
|||||||
5
main.go
5
main.go
@@ -46,7 +46,7 @@ func Init() {
|
|||||||
cms.InitServiceInfo(Version, buildTime, GitCommit)
|
cms.InitServiceInfo(Version, buildTime, GitCommit)
|
||||||
promotion.Init()
|
promotion.Init()
|
||||||
|
|
||||||
if beego.BConfig.RunMode == "prod" {
|
if globals.IsProductEnv() {
|
||||||
misc.StartRefreshEbaiRealMobile()
|
misc.StartRefreshEbaiRealMobile()
|
||||||
ebai.CurPurchaseHandler.StartRefreshComment()
|
ebai.CurPurchaseHandler.StartRefreshComment()
|
||||||
}
|
}
|
||||||
@@ -120,8 +120,7 @@ func main() {
|
|||||||
orderman.LoadPendingOrders()
|
orderman.LoadPendingOrders()
|
||||||
|
|
||||||
// 延时的原因是等回调准备好
|
// 延时的原因是等回调准备好
|
||||||
if beego.BConfig.RunMode == "prod" ||
|
if globals.IsProductEnv() {
|
||||||
beego.BConfig.RunMode == "jxgy" {
|
|
||||||
utils.AfterFuncWithRecover(2*time.Second, func() {
|
utils.AfterFuncWithRecover(2*time.Second, func() {
|
||||||
api.DingDingAPI.DeleteCallback()
|
api.DingDingAPI.DeleteCallback()
|
||||||
if err := api.DingDingAPI.RegisterCallback([]string{dingdingapi.CBTagUserAddOrg, dingdingapi.CBTagUserModifyOrg, dingdingapi.CBTagUserLeaveOrg}, beego.AppConfig.DefaultString("dingdingCallbackToken", ""), beego.AppConfig.DefaultString("dingdingCallbackAESKey", ""), beego.AppConfig.DefaultString("dingdingCallbackURL", "")); err != nil {
|
if err := api.DingDingAPI.RegisterCallback([]string{dingdingapi.CBTagUserAddOrg, dingdingapi.CBTagUserModifyOrg, dingdingapi.CBTagUserLeaveOrg}, beego.AppConfig.DefaultString("dingdingCallbackToken", ""), beego.AppConfig.DefaultString("dingdingCallbackAESKey", ""), beego.AppConfig.DefaultString("dingdingCallbackURL", "")); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user