- 平台门店没有临时休息的概念,ReadStore不会返回临时休息

- 得到平台门店快照后,会刷新本地storeMap中的状态(但store的状态暂时没有更新)
This commit is contained in:
gazebo
2019-06-28 09:47:14 +08:00
parent 3e69149124
commit d87483cff6
5 changed files with 40 additions and 8 deletions

View File

@@ -1215,6 +1215,36 @@ func getCurrentSnapshotAt(now time.Time) (snapshotAt time.Time) {
return jxutils.GetLastTimeFromList(now, WatchVendorStoreTimeList)
}
func updateVendorStoreStatusBySnapshot(db *dao.DaoDB, curSnapshotList []*model.VendorStoreSnapshot) (err error) {
storeMapList, err := dao.GetStoresMapList(db, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll)
if err != nil {
return err
}
snapshotMap := make(map[int64]*model.VendorStoreSnapshot)
for _, v := range curSnapshotList {
snapshotMap[jxutils.Combine2Int(v.StoreID, v.VendorID)] = v
}
dao.Begin(db)
defer func() {
if r := recover(); r != nil || err != nil {
dao.Rollback(db)
if r != nil {
panic(r)
}
}
}()
for _, v := range storeMapList {
if snapshot := snapshotMap[jxutils.Combine2Int(v.StoreID, v.VendorID)]; snapshot != nil && v.Status != snapshot.Status {
v.Status = snapshot.Status
if _, err = dao.UpdateEntity(db, v, model.FieldStatus); err != nil {
return err
}
}
}
dao.Commit(db)
return err
}
func SaveStoresVendorSnapshot(db *dao.DaoDB, snapshotAt time.Time, curSnapshotList []*model.VendorStoreSnapshot) (err error) {
dao.Begin(db)
defer func() {
@@ -1369,6 +1399,8 @@ func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs
curSnapshotList, err = GetStoresVendorSnapshot(ctx, task, vendorIDs, storeIDs)
if len(curSnapshotList) == 0 {
task.Cancel()
} else {
updateVendorStoreStatusBySnapshot(db, curSnapshotList)
}
case 1:
err = SaveStoresVendorSnapshot(db, curSnapshotAt, curSnapshotList)