新增三个同步时间字段
This commit is contained in:
@@ -126,6 +126,9 @@
|
|||||||
| `real_name_status` | int | 实名状态(仅 card) |
|
| `real_name_status` | int | 实名状态(仅 card) |
|
||||||
| `current_month_usage_mb` | float64 | 本月已用流量 MB(仅 card) |
|
| `current_month_usage_mb` | float64 | 本月已用流量 MB(仅 card) |
|
||||||
| `last_sync_time` | time | 最后同步时间(仅 card) |
|
| `last_sync_time` | time | 最后同步时间(仅 card) |
|
||||||
|
| `last_data_check_at` | time | 最后一次流量检查时间(仅 card) |
|
||||||
|
| `last_real_name_check_at` | time | 最后一次实名检查时间(仅 card) |
|
||||||
|
| `last_card_status_check_at` | time | 最后一次卡状态检查时间(仅 card) |
|
||||||
| `device_protect_status` | string | 保护期:`none` / `stop` / `start`(仅 device) |
|
| `device_protect_status` | string | 保护期:`none` / `stop` / `start`(仅 device) |
|
||||||
| `cards[]` | array | 所有绑定卡的状态(仅 device),同 resolve 的 cards 结构 |
|
| `cards[]` | array | 所有绑定卡的状态(仅 device),同 resolve 的 cards 结构 |
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ type BoundCardInfo struct {
|
|||||||
CarrierName string `json:"carrier_name,omitempty" description:"运营商名称"`
|
CarrierName string `json:"carrier_name,omitempty" description:"运营商名称"`
|
||||||
RealnamePolicy string `json:"realname_policy" description:"实名认证策略 (none:无需实名, before_order:先实名后充值/购买, after_order:先充值/购买后实名)"`
|
RealnamePolicy string `json:"realname_policy" description:"实名认证策略 (none:无需实名, before_order:先实名后充值/购买, after_order:先充值/购买后实名)"`
|
||||||
GatewayExtend string `json:"gateway_extend" description:"Gateway 卡状态扩展字段,原样返回上游 extend,用于展示运营商侧实际停机原因"`
|
GatewayExtend string `json:"gateway_extend" description:"Gateway 卡状态扩展字段,原样返回上游 extend,用于展示运营商侧实际停机原因"`
|
||||||
|
LastSyncTime *time.Time `json:"last_sync_time" description:"最后同步时间"`
|
||||||
|
LastDataCheckAt *time.Time `json:"last_data_check_at" description:"最后一次流量检查时间"`
|
||||||
|
LastRealNameCheckAt *time.Time `json:"last_real_name_check_at" description:"最后一次实名检查时间"`
|
||||||
|
LastCardStatusCheckAt *time.Time `json:"last_card_status_check_at" description:"最后一次卡状态检查时间"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AssetRealtimeStatusResponse 资产实时状态(只读DB/Redis)
|
// AssetRealtimeStatusResponse 资产实时状态(只读DB/Redis)
|
||||||
@@ -96,7 +100,10 @@ type AssetRealtimeStatusResponse struct {
|
|||||||
RealnamePolicy string `json:"realname_policy,omitempty" description:"实名认证策略 (none:无需实名, before_order:先实名后充值/购买, after_order:先充值/购买后实名)"`
|
RealnamePolicy string `json:"realname_policy,omitempty" description:"实名认证策略 (none:无需实名, before_order:先实名后充值/购买, after_order:先充值/购买后实名)"`
|
||||||
CurrentMonthUsageMB float64 `json:"current_month_usage_mb,omitempty" description:"系统自然月累计流量(MB,asset_type=card时有效,不等于运营商周期口径)"`
|
CurrentMonthUsageMB float64 `json:"current_month_usage_mb,omitempty" description:"系统自然月累计流量(MB,asset_type=card时有效,不等于运营商周期口径)"`
|
||||||
LastGatewayReadingMB float64 `json:"last_gateway_reading_mb,omitempty" description:"运营商当前周期累计流量读数(MB,asset_type=card时有效,运营商口径展示建议读取该字段)"`
|
LastGatewayReadingMB float64 `json:"last_gateway_reading_mb,omitempty" description:"运营商当前周期累计流量读数(MB,asset_type=card时有效,运营商口径展示建议读取该字段)"`
|
||||||
LastSyncTime *time.Time `json:"last_sync_time,omitempty" description:"最后同步时间(asset_type=card时有效)"`
|
LastSyncTime *time.Time `json:"last_sync_time" description:"最后同步时间(asset_type=card时有效)"`
|
||||||
|
LastDataCheckAt *time.Time `json:"last_data_check_at" description:"最后一次流量检查时间(asset_type=card时有效)"`
|
||||||
|
LastRealNameCheckAt *time.Time `json:"last_real_name_check_at" description:"最后一次实名检查时间(asset_type=card时有效)"`
|
||||||
|
LastCardStatusCheckAt *time.Time `json:"last_card_status_check_at" description:"最后一次卡状态检查时间(asset_type=card时有效)"`
|
||||||
DeviceProtectStatus string `json:"device_protect_status,omitempty" description:"保护期状态(asset_type=device时有效):none/stop/start"`
|
DeviceProtectStatus string `json:"device_protect_status,omitempty" description:"保护期状态(asset_type=device时有效):none/stop/start"`
|
||||||
Cards []BoundCardInfo `json:"cards,omitempty" description:"绑定卡状态列表(asset_type=device时有效)"`
|
Cards []BoundCardInfo `json:"cards,omitempty" description:"绑定卡状态列表(asset_type=device时有效)"`
|
||||||
DeviceRealtime *DeviceGatewayInfo `json:"device_realtime" description:"设备实时状态(来自 Gateway sync-info,始终返回,失败时仅含 gateway_msg)"`
|
DeviceRealtime *DeviceGatewayInfo `json:"device_realtime" description:"设备实时状态(来自 Gateway sync-info,始终返回,失败时仅含 gateway_msg)"`
|
||||||
|
|||||||
@@ -201,6 +201,10 @@ func (s *Service) buildDeviceResolveResponse(ctx context.Context, device *model.
|
|||||||
CarrierName: c.CarrierName,
|
CarrierName: c.CarrierName,
|
||||||
RealnamePolicy: c.RealnamePolicy,
|
RealnamePolicy: c.RealnamePolicy,
|
||||||
GatewayExtend: c.GatewayExtend,
|
GatewayExtend: c.GatewayExtend,
|
||||||
|
LastSyncTime: c.LastSyncTime,
|
||||||
|
LastDataCheckAt: c.LastDataCheckAt,
|
||||||
|
LastRealNameCheckAt: c.LastRealNameCheckAt,
|
||||||
|
LastCardStatusCheckAt: c.LastCardStatusCheckAt,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,6 +372,9 @@ func (s *Service) GetRealtimeStatus(ctx context.Context, assetType string, id ui
|
|||||||
resp.CurrentMonthUsageMB = card.CurrentMonthUsageMB
|
resp.CurrentMonthUsageMB = card.CurrentMonthUsageMB
|
||||||
resp.LastGatewayReadingMB = card.LastGatewayReadingMB
|
resp.LastGatewayReadingMB = card.LastGatewayReadingMB
|
||||||
resp.LastSyncTime = card.LastSyncTime
|
resp.LastSyncTime = card.LastSyncTime
|
||||||
|
resp.LastDataCheckAt = card.LastDataCheckAt
|
||||||
|
resp.LastRealNameCheckAt = card.LastRealNameCheckAt
|
||||||
|
resp.LastCardStatusCheckAt = card.LastCardStatusCheckAt
|
||||||
|
|
||||||
case "device":
|
case "device":
|
||||||
// 查绑定卡状态列表
|
// 查绑定卡状态列表
|
||||||
@@ -401,6 +408,10 @@ func (s *Service) GetRealtimeStatus(ctx context.Context, assetType string, id ui
|
|||||||
CarrierName: c.CarrierName,
|
CarrierName: c.CarrierName,
|
||||||
RealnamePolicy: c.RealnamePolicy,
|
RealnamePolicy: c.RealnamePolicy,
|
||||||
GatewayExtend: c.GatewayExtend,
|
GatewayExtend: c.GatewayExtend,
|
||||||
|
LastSyncTime: c.LastSyncTime,
|
||||||
|
LastDataCheckAt: c.LastDataCheckAt,
|
||||||
|
LastRealNameCheckAt: c.LastRealNameCheckAt,
|
||||||
|
LastCardStatusCheckAt: c.LastCardStatusCheckAt,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ func (h *PollingCarddataHandler) Handle(ctx context.Context, t *asynq.Task) erro
|
|||||||
resetDay := h.carrierStore.GetDataResetDay(ctx, card.CarrierID)
|
resetDay := h.carrierStore.GetDataResetDay(ctx, card.CarrierID)
|
||||||
updates, flowIncrementMB, isCrossMonth := h.calculateFlowUpdates(card, gatewayFlowMB, now, resetDay)
|
updates, flowIncrementMB, isCrossMonth := h.calculateFlowUpdates(card, gatewayFlowMB, now, resetDay)
|
||||||
updates["last_data_check_at"] = now
|
updates["last_data_check_at"] = now
|
||||||
|
if h.gateway != nil {
|
||||||
|
updates["last_sync_time"] = now
|
||||||
|
}
|
||||||
|
|
||||||
if h.base.verboseLog && h.gateway != nil {
|
if h.base.verboseLog && h.gateway != nil {
|
||||||
h.base.logger.Info("流量轮询详情",
|
h.base.logger.Info("流量轮询详情",
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ func (h *PollingCardStatusHandler) Handle(ctx context.Context, t *asynq.Task) er
|
|||||||
fields := map[string]any{"last_card_status_check_at": now}
|
fields := map[string]any{"last_card_status_check_at": now}
|
||||||
if statusQueried {
|
if statusQueried {
|
||||||
fields["gateway_extend"] = gatewayExtend
|
fields["gateway_extend"] = gatewayExtend
|
||||||
|
fields["last_sync_time"] = now
|
||||||
}
|
}
|
||||||
if statusChanged {
|
if statusChanged {
|
||||||
fields["network_status"] = newNetworkStatus
|
fields["network_status"] = newNetworkStatus
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ func (h *PollingRealnameHandler) Handle(ctx context.Context, t *asynq.Task) erro
|
|||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
fields := map[string]any{"last_real_name_check_at": now}
|
fields := map[string]any{"last_real_name_check_at": now}
|
||||||
|
if h.gateway != nil {
|
||||||
|
fields["last_sync_time"] = now
|
||||||
|
}
|
||||||
if statusChanged {
|
if statusChanged {
|
||||||
fields["real_name_status"] = newStatus
|
fields["real_name_status"] = newStatus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user