feat(H5弹窗): AUG26-007 风险换卡与运营弹窗投放通知
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m23s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m23s
新增 000225 迁移:运营弹窗配置表 tb_h5_popup_configuration(页面/范围/优先级/频率/受控动作/启停/有效期/版本) 与 tb_notification 可空 JSONB 列 popup_snapshot。 新增通知直建窄接口 DirectWriter.CreateOrGetPersonal:与 Outbox 消费共用 prepareDelivery 的渲染、 展示期与 CreateIdempotent 规则,冲突时回查返回既有行;同步扩展个人通知查询与已读两处类型白名单, 并按个人客户入口补齐投递审计来源。 新增 H5 候选与风险换卡:GET /api/c/v1/popup-candidates 先判风险资格(广电卡 + 风险停机 + 无活动物流换货单),命中只返回风险候选;未命中再按时间/启停/页面/店铺/设备类型/卡类型范围/频率 匹配运营配置。POST /api/c/v1/risk-exchanges/:asset_id/address 锁资产行后幂等创建待发货物流换货单, 首次地址锁定,不沿用资产级群发通知。 新增后台运营弹窗配置 CRUD 与启停(仅超级管理员与平台账号),更新递增版本并刷新最近更新时间, 标题与正文统一拒绝 URL 与前端路由,全部写操作记录操作者、前后值、版本与时间。 同步 OpenAPI(cmd/gendocs、cmd/api/docs.go、pkg/openapi/handlers.go)与参数校验中文提示共用实现。
This commit is contained in:
@@ -79,15 +79,9 @@ func (q *Query) List(ctx context.Context, recipientID uint, request dto.Notifica
|
||||
if err := base.Order("created_at DESC, id DESC").Offset(offset).Limit(pageSize).Find(&records).Error; err != nil {
|
||||
return nil, errors.Wrap(errors.CodeDatabaseError, err, "查询通知列表失败")
|
||||
}
|
||||
items := make([]dto.NotificationItem, 0, len(records))
|
||||
for _, record := range records {
|
||||
items = append(items, dto.NotificationItem{
|
||||
ID: record.ID, Category: record.Category, Type: record.Type, Severity: record.Severity,
|
||||
Title: record.Title, Body: record.Body, RefType: record.RefType, RefID: record.RefID,
|
||||
RefKey: record.RefKey, IsRead: record.IsRead, ReadAt: record.ReadAt, CreatedAt: record.CreatedAt,
|
||||
})
|
||||
}
|
||||
return &dto.NotificationListResponse{Items: items, Total: total, Page: page, Size: pageSize}, nil
|
||||
return &dto.NotificationListResponse{
|
||||
Items: notificationItems(records), Total: total, Page: page, Size: pageSize,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// PersonalUnreadCount 查询当前个人客户可见业务通知的准确未读数。
|
||||
@@ -198,7 +192,12 @@ func personalNotificationScope(db *gorm.DB, customerID uint, now time.Time) *gor
|
||||
constants.NotificationRecipientKindPersonalCustomer,
|
||||
customerID,
|
||||
[]string{constants.NotificationCategoryApproval, constants.NotificationCategoryExpiry, constants.NotificationCategorySystem},
|
||||
[]string{constants.NotificationTypePackageExpiring, constants.NotificationTypeExchangeShippingCreated},
|
||||
[]string{
|
||||
constants.NotificationTypePackageExpiring,
|
||||
constants.NotificationTypeExchangeShippingCreated,
|
||||
constants.NotificationTypeH5PopupRiskExchange,
|
||||
constants.NotificationTypeH5PopupOperation,
|
||||
},
|
||||
now,
|
||||
)
|
||||
}
|
||||
@@ -218,7 +217,23 @@ func notificationItems(records []model.Notification) []dto.NotificationItem {
|
||||
ID: record.ID, Category: record.Category, Type: record.Type, Severity: record.Severity,
|
||||
Title: record.Title, Body: record.Body, RefType: record.RefType, RefID: record.RefID,
|
||||
RefKey: record.RefKey, IsRead: record.IsRead, ReadAt: record.ReadAt, CreatedAt: record.CreatedAt,
|
||||
PopupSnapshot: popupSnapshotItem(record),
|
||||
})
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
// popupSnapshotItem 只对弹窗投放类型投影投放快照,其他类型(含历史数据)一律为空。
|
||||
// 快照只含配置标识、资产关联与受控动作,不含任何 URL 或前端路由。
|
||||
func popupSnapshotItem(record model.Notification) *dto.NotificationPopupSnapshotItem {
|
||||
if !constants.IsH5PopupNotificationType(record.Type) || record.PopupSnapshot == nil {
|
||||
return nil
|
||||
}
|
||||
return &dto.NotificationPopupSnapshotItem{
|
||||
ConfigID: record.PopupSnapshot.ConfigID,
|
||||
ConfigVersion: record.PopupSnapshot.ConfigVersion,
|
||||
AssetType: record.PopupSnapshot.AssetType,
|
||||
AssetID: record.PopupSnapshot.AssetID,
|
||||
ActionType: record.PopupSnapshot.ActionType,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user