Files
junhong_cmp_fiber/internal/domain/operationsreport/purchase.go
break 5e78809b93
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 15m33s
feat(运营报表): AUG26-015 设备激活与套餐续费日报快照、查询趋势与受控导出
- 新增成对迁移 000231 与三张快照表:日级头行、设备粒度激活行、到期事件粒度续费行,以快照日期为唯一键
- 新增每日 03:30(Asia/Shanghai)日报快照生成任务与幂等整日替换,失败重试沿用同一目标日
- 新增六条受控入口:两张报表的汇总、日/月趋势与受控导出,配套查询层只读快照事实
- 新增 operations_activation 与 operations_renewal 两个导出场景,创建期冻结筛选与可见店铺范围、派发期冻结表头、执行期只按冻结值复核资格
- 采购数量口径按系统内未删除设备数实施并在 PRD 标注,附实测差额依据
- 同步证据链 requirement-evidence.json 与入口能力矩阵、ARCHITECTURE 与验证记录
- 归档 change add-operations-reports 并新建主 Spec openspec/specs/operations-report/spec.md
2026-09-18 09:42:28 +08:00

38 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package operationsreport
import (
"context"
"time"
"github.com/break/junhong_cmp_fiber/pkg/constants"
)
// PurchaseCountSource 是采购数量口径的取值端口。
// 由基础设施层实现为只读查询(截至快照日系统内未删除的设备数)。
type PurchaseCountSource interface {
CountUndeletedDevicesAsOf(ctx context.Context, snapshotDate time.Time) (int64, error)
}
// PurchaseCountAsOf 返回截至快照日的采购数量,是采购数量口径的**唯一实现点**(设计 D6
//
// 采用口径:采购数量 = 截至快照日(上海自然日)系统内未删除的设备数,
// 与 `111.md` §22.4.1「系统录入的设备数量」同读法,不新建采购或入库台账。
//
// 被拒绝的字面口径:`tb_device_import_task` 中 `operation_type='import'` 且已完成任务的
// `success_count` 之和。生产库实测该值为 474而系统内未删除设备为 18,970
// 差额来自老系统迁移脚本直接写入设备表、绕过导入任务,按字面口径激活率约 1,399%,指标不可用。
//
// 切换口径只需替换本函数体内的取值方式(一行),调用方与快照表结构都不需要改动。
func PurchaseCountAsOf(ctx context.Context, source PurchaseCountSource, snapshotDate time.Time) (int64, error) {
return source.CountUndeletedDevicesAsOf(ctx, snapshotDate)
}
// ValidMainPackageStatuses 是「有效主套餐」的状态集合:生效中与已用完。
// 「有效」的完整口径为主套餐master_usage_id IS NULL、状态属于本集合、未退款refund_id IS NULL
// 既有先例见 internal/query/packageexpiry/list.go、internal/query/assetautorenewal/query.go
// 与 internal/infrastructure/packagetrafficalert/scanner.go。
var ValidMainPackageStatuses = []int{
constants.PackageUsageStatusActive,
constants.PackageUsageStatusDepleted,
}