- 调整dao.GetVendorStoreSnapshot的实现
- updateVendorStoreStatusBySnapshot中更新本地平台门店信息
This commit is contained in:
@@ -1391,10 +1391,12 @@ func updateVendorStoreStatusBySnapshot(db *dao.DaoDB, curSnapshotList []*model.V
|
||||
}
|
||||
}()
|
||||
for _, v := range storeMapList {
|
||||
if snapshot := snapshotMap[jxutils.Combine2Int(v.StoreID, v.VendorID)]; snapshot != nil && v.Status != snapshot.Status {
|
||||
if snapshot := snapshotMap[jxutils.Combine2Int(v.StoreID, v.VendorID)]; snapshot != nil &&
|
||||
(v.Status != snapshot.Status || v.DeliveryType != snapshot.DeliveryType) {
|
||||
v.Status = snapshot.Status
|
||||
v.DeliveryType = snapshot.DeliveryType
|
||||
if _, err = dao.UpdateEntity(db, v, model.FieldStatus, "DeliveryType"); err != nil {
|
||||
v.LastOperator = model.AdminName
|
||||
if _, err = dao.UpdateEntity(db, v, model.FieldLastOperator, model.FieldUpdatedAt, model.FieldStatus, "DeliveryType"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -1649,6 +1651,7 @@ func sendStoreStatusInfo2Mobile(mobile, title, txtAlarm string) {
|
||||
|
||||
func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs []int, isAsync bool) (err error) {
|
||||
curSnapshotAt := getCurrentSnapshotAt(time.Now())
|
||||
prevSnapshotAt := getCurrentSnapshotAt(curSnapshotAt.Add(-1 * time.Second))
|
||||
db := dao.GetDB()
|
||||
var curSnapshotList, prevSnapshotList []*model.VendorStoreSnapshot
|
||||
task := tasksch.NewSeqTask("SaveAndSendAlarmVendorSnapshot", ctx,
|
||||
@@ -1664,7 +1667,7 @@ func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs
|
||||
case 1:
|
||||
err = SaveStoresVendorSnapshot(db, curSnapshotAt, curSnapshotList)
|
||||
case 2:
|
||||
prevSnapshotList, err = dao.GetVendorStoreSnapshot(db, curSnapshotAt)
|
||||
prevSnapshotList, err = dao.GetVendorStoreSnapshot(db, prevSnapshotAt)
|
||||
case 3:
|
||||
err = SendAlarmVendorSnapshot(ctx, task, prevSnapshotList, curSnapshotList)
|
||||
}
|
||||
|
||||
@@ -27,3 +27,9 @@ func TestSendAlarmVendorSnapshot(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateVendorStoreStatusBySnapshot(t *testing.T) {
|
||||
db := dao.GetDB()
|
||||
curSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-07-30 08:00:00"))
|
||||
updateVendorStoreStatusBySnapshot(db, curSnapshotList)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user