diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 06a31c268..ba50d9730 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -530,7 +530,19 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa if err = dao.GetEntity(db, store); err != nil { return 0, err } + valid := dao.StrictMakeMapByStructObject(payload, store, userName) + if payload["lng"] != nil || payload["lat"] != nil { + intLng := jxutils.StandardCoordinate2Int(utils.Interface2Float64WithDefault(payload["lng"], 0.0)) + intLat := jxutils.StandardCoordinate2Int(utils.Interface2Float64WithDefault(payload["lat"], 0.0)) + if intLng != 0 && intLng != store.Lng { + valid["lng"] = intLng + } + if intLat != 0 && intLat != store.Lng { + valid["lat"] = intLat + } + } + if valid["originalName"] != nil { delete(valid, "originalName") } @@ -589,18 +601,15 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa "address", "deliveryRange", } { - if payload[v] != nil { + if valid[v] != nil { syncStatus |= model.SyncFlagStoreAddress break } } - var lng, lat float64 - if payload["lng"] != nil || payload["lat"] != nil { - lng = utils.Interface2Float64WithDefault(payload["lng"], 0.0) - lat = utils.Interface2Float64WithDefault(payload["lat"], 0.0) - valid["lng"] = jxutils.StandardCoordinate2Int(lng) - valid["lat"] = jxutils.StandardCoordinate2Int(lat) + if valid["status"] != nil { + syncStatus |= model.SyncFlagStoreStatus } + if valid["deliveryRange"] != nil { valid["deliveryRange"] = strings.Trim(valid["deliveryRange"].(string), ";") } @@ -830,7 +839,11 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor if err = dao.GetEntity(db, storeMap, model.FieldStoreID, model.FieldVendorID, model.FieldDeletedAt); err != nil { return 0, err } + syncStatus := model.SyncFlagModifiedMask valid := dao.StrictMakeMapByStructObject(payload, storeMap, userName) + if valid["status"] != nil { + syncStatus |= model.SyncFlagStoreStatus + } if valid["pricePercentagePack"] != nil { if pricePercentagePack := utils.Interface2String(valid["pricePercentagePack"]); pricePercentagePack != "" { _, err2 := dao.QueryConfigs(db, pricePercentagePack, model.ConfigTypePricePack, "") @@ -857,7 +870,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor num, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, storeMap, valid, userName, map[string]interface{}{ model.FieldStoreID: storeID, model.FieldVendorID: vendorID, - }, model.FieldSyncStatus, model.SyncFlagModifiedMask) + }, model.FieldSyncStatus, syncStatus) } else { num, err = dao.UpdateEntityLogically(db, storeMap, valid, userName, map[string]interface{}{ model.FieldStoreID: storeID, diff --git a/business/model/model.go b/business/model/model.go index d46d57e25..c8c2ca3e5 100644 --- a/business/model/model.go +++ b/business/model/model.go @@ -81,6 +81,7 @@ const ( SyncFlagStoreName = 8 SyncFlagStoreAddress = 16 + SyncFlagStoreStatus = 32 ) func IsSyncStatusNew(syncStatus int8) bool { diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index b4e9884c7..f34187abb 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -177,9 +177,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin } } if err == nil { - mergeStatus := jxutils.MergeStoreStatus(store.Status, store.EbaiStoreStatus) - if err = p.updateStoreStatus(userName, storeID, store.VendorStoreID, mergeStatus, store2.Status); err != nil { - return err + if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 { + mergeStatus := jxutils.MergeStoreStatus(store.Status, store.EbaiStoreStatus) + if err = p.updateStoreStatus(userName, storeID, store.VendorStoreID, mergeStatus, store2.Status); err != nil { + return err + } } params := genStoreMapFromStore(store) if err = api.EbaiAPI.ShopUpdate(params); err == nil { diff --git a/business/partner/purchase/jd/store.go b/business/partner/purchase/jd/store.go index 144ed378d..6682e81a1 100644 --- a/business/partner/purchase/jd/store.go +++ b/business/partner/purchase/jd/store.go @@ -142,7 +142,9 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin params["deliveryRangeRadius"] = utils.Str2Int64WithDefault(store.DeliveryRange, 0) } } - _, params["closeStatus"] = JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus)) + if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 { + _, params["closeStatus"] = JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus)) + } globals.SugarLogger.Debug(utils.Format4Output(params, false)) if globals.EnableJdStoreWrite { if err = api.JdAPI.UpdateStoreInfo4Open(store.VendorStoreID, store.RealLastOperator, params); err != nil { diff --git a/business/partner/purchase/mtwm/store.go b/business/partner/purchase/mtwm/store.go index 6444b41a7..9e7491c06 100644 --- a/business/partner/purchase/mtwm/store.go +++ b/business/partner/purchase/mtwm/store.go @@ -129,7 +129,9 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin // if globals.EnableMtwmStoreWrite { // err = api.MtwmAPI.PoiSave(storeDetail.VendorStoreID, params) // } - errList.AddErr(p.UpdateStoreStatus(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus))) + if storeDetail.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 { + errList.AddErr(p.UpdateStoreStatus(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus))) + } errList.AddErr(p.UpdateStoreOpTime(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, storeDetail.GetOpTimeList())) return errList.GetErrListAsOne() }