- 修改门店状态同步逻辑,只有在京西本地修改过门店状态相关的信息后才同步

This commit is contained in:
gazebo
2019-08-07 09:52:35 +08:00
parent e3e900cd10
commit b1209a954b
5 changed files with 33 additions and 13 deletions

View File

@@ -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,