- first update shop id, then status, then other property for ebai shop, because shop property can not be changed after approved
This commit is contained in:
@@ -156,47 +156,47 @@ 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 {
|
||||||
params := genStoreMapFromStore(store)
|
|
||||||
// globals.SugarLogger.Debug(utils.Format4Output(params, false))
|
// globals.SugarLogger.Debug(utils.Format4Output(params, false))
|
||||||
if globals.EnableStoreWrite && globals.EnableEbaiStoreWrite {
|
if globals.EnableStoreWrite && globals.EnableEbaiStoreWrite {
|
||||||
if err = api.EbaiAPI.ShopUpdate(params); err == nil {
|
shopID := 0
|
||||||
shopID := 0
|
if store.SyncStatus&model.SyncFlagDeletedMask == 0 {
|
||||||
if store.SyncStatus&model.SyncFlagDeletedMask == 0 {
|
shopID = store.ID
|
||||||
shopID = store.ID
|
}
|
||||||
|
store2, err2 := p.ReadStore(store.VendorStoreID)
|
||||||
|
if err = err2; err == nil {
|
||||||
|
if store2.ID == store.ID {
|
||||||
|
shopID = -1
|
||||||
}
|
}
|
||||||
store2, err2 := p.ReadStore(store.VendorStoreID)
|
}
|
||||||
if err = err2; err == nil {
|
if err == nil {
|
||||||
if store2.ID == store.ID {
|
if shopID > 0 {
|
||||||
shopID = -1
|
err = api.EbaiAPI.ShopIDBatchUpdate([]string{store.VendorStoreID}, []string{utils.Int2Str(shopID)})
|
||||||
}
|
} else if shopID == 0 {
|
||||||
|
// todo remove out shop id
|
||||||
}
|
}
|
||||||
if err == nil {
|
}
|
||||||
if shopID > 0 {
|
if err == nil {
|
||||||
err = api.EbaiAPI.ShopIDBatchUpdate([]string{store.VendorStoreID}, []string{utils.Int2Str(shopID)})
|
mergeStatus := jxutils.MergeStoreStatus(store.Status, store.EbaiStoreStatus)
|
||||||
} else if shopID == 0 {
|
if mergeStatus == model.StoreStatusOpened {
|
||||||
// todo remove out shop id
|
err = api.EbaiAPI.ShopOnline("", utils.Str2Int64(store.VendorStoreID))
|
||||||
}
|
} else if mergeStatus == model.StoreStatusClosed {
|
||||||
|
err = api.EbaiAPI.ShopOffline("", utils.Str2Int64(store.VendorStoreID))
|
||||||
|
} else if mergeStatus == model.StoreStatusClosed {
|
||||||
|
err = api.EbaiAPI.ShopClose("", utils.Str2Int64(store.VendorStoreID))
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err != nil {
|
||||||
mergeStatus := jxutils.MergeStoreStatus(store.Status, store.EbaiStoreStatus)
|
// todo
|
||||||
if mergeStatus == model.StoreStatusOpened {
|
if intErr, ok := err.(*utils.ErrorWithCode); ok {
|
||||||
err = api.EbaiAPI.ShopOnline("", utils.Str2Int64(store.VendorStoreID))
|
if intErr.IntCode() == 201101 {
|
||||||
} else if mergeStatus == model.StoreStatusClosed {
|
err = nil
|
||||||
err = api.EbaiAPI.ShopOffline("", utils.Str2Int64(store.VendorStoreID))
|
|
||||||
} else if mergeStatus == model.StoreStatusClosed {
|
|
||||||
err = api.EbaiAPI.ShopClose("", utils.Str2Int64(store.VendorStoreID))
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
// todo
|
|
||||||
if intErr, ok := err.(*utils.ErrorWithCode); ok {
|
|
||||||
if intErr.IntCode() == 201101 {
|
|
||||||
err = nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
params := genStoreMapFromStore(store)
|
||||||
|
if err = api.EbaiAPI.ShopUpdate(params); err == nil {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user