- 平台门店没有临时休息的概念,ReadStore不会返回临时休息
- 得到平台门店快照后,会刷新本地storeMap中的状态(但store的状态暂时没有更新)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -27,7 +27,7 @@ func init() {
|
||||
|
||||
func EbaiBusStatus2JxStatus(ebaiStatus int) int {
|
||||
if ebaiStatus == ebaiapi.ShopBusStatusHaveRest || ebaiStatus == ebaiapi.ShopBusStatusSuspended {
|
||||
return model.StoreStatusHaveRest
|
||||
return model.StoreStatusClosed
|
||||
}
|
||||
return model.StoreStatusOpened
|
||||
}
|
||||
|
||||
@@ -215,11 +215,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
}
|
||||
|
||||
func isStoreStatusSame(status1, status2 int) bool {
|
||||
if status1 == model.StoreStatusClosed {
|
||||
status1 = model.StoreStatusHaveRest
|
||||
if status1 == model.StoreStatusHaveRest {
|
||||
status1 = model.StoreStatusClosed
|
||||
}
|
||||
if status2 == model.StoreStatusClosed {
|
||||
status2 = model.StoreStatusHaveRest
|
||||
if status2 == model.StoreStatusHaveRest {
|
||||
status2 = model.StoreStatusClosed
|
||||
}
|
||||
return status1 == status2
|
||||
}
|
||||
@@ -425,7 +425,7 @@ func (c *PurchaseHandler) onShopMsgPush(msg *ebaiapi.CallbackMsg) (response *eba
|
||||
if int(utils.ForceInterface2Int64(msg.Body["business_ele"])) == 1 {
|
||||
storeStatus = model.StoreStatusOpened
|
||||
} else {
|
||||
storeStatus = model.StoreStatusHaveRest
|
||||
storeStatus = model.StoreStatusClosed
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
|
||||
@@ -42,7 +42,7 @@ func JdStoreStatus2JxStatus(yn, closeStatus interface{}) int {
|
||||
if yn2 == 1 {
|
||||
return model.StoreStatusDisabled
|
||||
} else if closeStatus2 == 1 {
|
||||
return model.StoreStatusHaveRest
|
||||
return model.StoreStatusClosed
|
||||
}
|
||||
return model.StoreStatusOpened
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ func bizStatusMtwm2JX(openLevel, online int) int {
|
||||
return model.StoreStatusDisabled
|
||||
} else {
|
||||
if openLevel == mtwmapi.PoiOpenLevelHaveRest {
|
||||
return model.StoreStatusHaveRest
|
||||
return model.StoreStatusClosed
|
||||
}
|
||||
}
|
||||
return model.StoreStatusOpened
|
||||
|
||||
Reference in New Issue
Block a user