feat(收口): 补齐 8 月迭代缺口并同步 Spec 与证据链
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
- 新增六对成对迁移 000232–000237:H5 弹窗类型、退款结算标识与申请人备注、优先轮询事实字段与两个新终态、通道阈值命中留痕、手机号最近解绑人、提现资格校验留痕 - 退款:原因必填与申请人备注、来源支付与渠道流水冻结、线下处理流水号补录审计、按订单查询可选退款方式、企微审批材料补齐且新增字段缺失映射即明确失败 - 优先轮询:人工关闭、有效期到期独立周期任务、失败与过期人工重触发、事实字段与异常重试查询、资产解析端点只读投影 - 通道阈值:命中事实同事务留痕与命中记录查询;员工账单:列表筛选与详情投影;商户池:列表投影与统计周期语义;H5:弹窗类型与类别排序 - 手机号:有效关联数量与最近解绑人、短信验证码失败次数限制;导出:佣金明细十五列与报表序号列 - 时间筛选:三处新增筛选纳入统一严格解析契约,员工账单产生时间参数改名 - 同步 12 份主 Spec 需求、两端点与异步任务证据链,门禁 context-health 与 OpenSpec 校验通过
This commit is contained in:
@@ -3,17 +3,20 @@ package exporter
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||
)
|
||||
|
||||
// CommissionRecordDataSource 佣金明细导出数据源。
|
||||
// 粒度为佣金记录:原佣金与回溯明细各占一行,金额保持分并在展示层转元,
|
||||
// 负数金额与可为负的余额原样导出,不因符号或余额不足被裁剪。
|
||||
// 归属与设备维度列按导出执行时的当前事实补充,缺值以空值导出,不因个别行缺值丢失整行或整列。
|
||||
type CommissionRecordDataSource struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
@@ -50,11 +53,16 @@ func (s *CommissionRecordDataSource) Count(ctx context.Context, params ExportPar
|
||||
}
|
||||
|
||||
// Headers 返回佣金明细导出表头。
|
||||
//
|
||||
// 前十五列按 111.md §18.2 与变更 delta 的固定列序输出:店铺、业务员、用户组、资产类型、设备类型、
|
||||
// 设备型号、资产标识、订单号、下单时间、佣金金额、佣金来源、佣金状态、关联佣金明细、入账后金额、创建时间。
|
||||
// 其后的记录来源、记录ID、来源退款单号、是否可提现与佣金入账时间为变更前既有列,予以保留:
|
||||
// 「回溯记录导出」场景要求导出结果仍可辨认行来源、退款单标识与不可提现标识,delta 对导出列的约束为「至少包含」上述十五列。
|
||||
func (s *CommissionRecordDataSource) Headers(context.Context, ExportParams) ([]string, error) {
|
||||
return []string{
|
||||
"记录来源", "记录ID", "代理店铺名称", "关联订单号", "资产标识", "佣金来源",
|
||||
"金额(元)", "是否可提现", "状态", "回溯后佣金余额(元)",
|
||||
"原佣金记录ID", "来源退款单号", "佣金入账时间", "生成时间",
|
||||
"店铺", "业务员", "用户组", "资产类型", "设备类型", "设备型号", "资产标识", "订单号", "下单时间",
|
||||
"佣金金额", "佣金来源", "佣金状态", "关联佣金明细", "入账后金额", "创建时间",
|
||||
"记录来源", "记录ID", "来源退款单号", "是否可提现", "佣金入账时间",
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -80,9 +88,11 @@ func (s *CommissionRecordDataSource) Fetch(ctx context.Context, params ExportPar
|
||||
Select(`
|
||||
ledger.source,
|
||||
ledger.id,
|
||||
COALESCE(sh.shop_name, '') AS shop_name,
|
||||
ledger.shop_id,
|
||||
ledger.order_no,
|
||||
COALESCE(NULLIF(ledger.iccid, ''), ledger.virtual_no, '') AS asset_identifier,
|
||||
ledger.order_created_at,
|
||||
ledger.iot_card_id,
|
||||
ledger.device_id,
|
||||
ledger.commission_source,
|
||||
ledger.amount,
|
||||
ledger.withdrawable,
|
||||
@@ -93,31 +103,97 @@ func (s *CommissionRecordDataSource) Fetch(ctx context.Context, params ExportPar
|
||||
ledger.released_at,
|
||||
ledger.created_at
|
||||
`).
|
||||
Joins("LEFT JOIN tb_shop AS sh ON sh.id = ledger.shop_id").
|
||||
// 合并后统一排序并分页,保证两类记录落在同一结果集,任一条不缺失也不重复。
|
||||
Order("ledger.created_at DESC").Order("ledger.id DESC").Order("ledger.source ASC").
|
||||
Limit(limit).Offset(offset)
|
||||
if err := query.Scan(&items).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(items) == 0 {
|
||||
return [][]string{}, nil
|
||||
}
|
||||
|
||||
// 归属与设备维度按导出执行时当前事实批量补充:只读当前店铺、账号、用户组与资产,不回写任何事实。
|
||||
shopIDs := make([]uint, 0, len(items))
|
||||
cardIDs := make([]uint, 0, len(items))
|
||||
deviceIDs := make([]uint, 0, len(items))
|
||||
originalIDs := make([]uint, 0, len(items))
|
||||
for _, item := range items {
|
||||
shopIDs = append(shopIDs, item.ShopID)
|
||||
if item.IotCardID != nil {
|
||||
cardIDs = append(cardIDs, *item.IotCardID)
|
||||
}
|
||||
if item.DeviceID != nil {
|
||||
deviceIDs = append(deviceIDs, *item.DeviceID)
|
||||
}
|
||||
if item.Source == sourceOriginal {
|
||||
originalIDs = append(originalIDs, item.ID)
|
||||
}
|
||||
}
|
||||
shops, err := s.loadShopOwners(ctx, normalizeUintSlice(shopIDs))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ownerIDs := make([]uint, 0, len(shops))
|
||||
for _, shop := range shops {
|
||||
if shop.BusinessOwnerAccountID != nil {
|
||||
ownerIDs = append(ownerIDs, *shop.BusinessOwnerAccountID)
|
||||
}
|
||||
}
|
||||
ownerIDs = normalizeUintSlice(ownerIDs)
|
||||
ownerNames, err := loadAccountNames(ctx, s.db, ownerIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupNames, err := businessUserGroupNames(ctx, s.db, ownerIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
assets, err := s.loadAssetDimensions(ctx, normalizeUintSlice(cardIDs), normalizeUintSlice(deviceIDs))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
clawbackIDs, err := s.loadClawbackIDs(ctx, normalizeUintSlice(originalIDs))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rows := make([][]string, 0, len(items))
|
||||
for _, item := range items {
|
||||
shop := shops[item.ShopID]
|
||||
var ownerName, groupName string
|
||||
// 业务员取店铺当前业务员,用户组按该业务员实时推导;店铺无业务员时两列均留空。
|
||||
if shop.BusinessOwnerAccountID != nil {
|
||||
ownerName = ownerNames[*shop.BusinessOwnerAccountID]
|
||||
groupName = currentOwnerGroupName(groupNames, shop.BusinessOwnerAccountID)
|
||||
}
|
||||
assetType, assetIdentifier, deviceType, deviceModel := assets.describe(item.IotCardID, item.DeviceID)
|
||||
// 关联佣金明细:原佣金列其全部回溯明细编号,回溯明细列被回溯的原佣金编号。
|
||||
relatedCommission := formatOptionalUint(item.OriginalCommissionID)
|
||||
if item.Source == sourceOriginal {
|
||||
relatedCommission = formatClawbackIDList(clawbackIDs[item.ID])
|
||||
}
|
||||
rows = append(rows, []string{
|
||||
shop.ShopName,
|
||||
ownerName,
|
||||
groupName,
|
||||
assetType,
|
||||
deviceType,
|
||||
deviceModel,
|
||||
assetIdentifier,
|
||||
item.OrderNo,
|
||||
formatOptionalTime(item.OrderCreatedAt),
|
||||
formatMoneyYuan(item.Amount),
|
||||
formatCommissionSource(item.CommissionSource),
|
||||
constants.GetCommissionRecordStatusName(item.Status),
|
||||
relatedCommission,
|
||||
formatMoneyYuan(item.BalanceAfter),
|
||||
item.CreatedAt.Format(exportTimeLayout),
|
||||
formatCommissionLedgerSource(item.Source),
|
||||
strconv.FormatUint(uint64(item.ID), 10),
|
||||
item.ShopName,
|
||||
item.OrderNo,
|
||||
item.AssetIdentifier,
|
||||
formatCommissionSource(item.CommissionSource),
|
||||
formatMoneyYuan(item.Amount),
|
||||
formatCommissionWithdrawable(item.Source, item.Withdrawable),
|
||||
constants.GetCommissionRecordStatusName(item.Status),
|
||||
formatMoneyYuan(item.BalanceAfter),
|
||||
formatOptionalUint(item.OriginalCommissionID),
|
||||
item.RefundNo,
|
||||
formatCommissionWithdrawable(item.Source, item.Withdrawable),
|
||||
formatOptionalTime(item.ReleasedAt),
|
||||
item.CreatedAt.Format(exportTimeLayout),
|
||||
})
|
||||
}
|
||||
return rows, nil
|
||||
@@ -128,10 +204,9 @@ func (s *CommissionRecordDataSource) originalBranch(ctx context.Context, params
|
||||
query := s.db.WithContext(ctx).Table("tb_commission_record AS c").
|
||||
Where("c.deleted_at IS NULL").
|
||||
Joins("LEFT JOIN tb_order o ON c.order_id = o.id AND o.deleted_at IS NULL").
|
||||
Joins("LEFT JOIN tb_iot_card ic ON c.iot_card_id = ic.id AND ic.deleted_at IS NULL").
|
||||
Joins("LEFT JOIN tb_device d ON c.device_id = d.id AND d.deleted_at IS NULL").
|
||||
Select(`'` + sourceOriginal + `' AS source, c.id, c.shop_id, c.order_id, o.order_no, ` +
|
||||
`ic.iccid, d.virtual_no, c.commission_source, c.amount, c.balance_after, c.status, ` +
|
||||
`o.created_at AS order_created_at, c.iot_card_id, c.device_id, ` +
|
||||
`c.commission_source, c.amount, c.balance_after, c.status, ` +
|
||||
`c.released_at, c.created_at, NULL::bigint AS original_commission_id, ''::varchar AS refund_no, ` +
|
||||
`NULL::boolean AS withdrawable`)
|
||||
query = applyExportShopScope(query, params, "c.shop_id")
|
||||
@@ -143,10 +218,9 @@ func (s *CommissionRecordDataSource) clawbackBranch(ctx context.Context, params
|
||||
query := s.db.WithContext(ctx).Table("tb_commission_clawback_record AS g").
|
||||
Joins("LEFT JOIN tb_commission_record oc ON oc.id = g.original_commission_id").
|
||||
Joins("LEFT JOIN tb_order o ON g.order_id = o.id AND o.deleted_at IS NULL").
|
||||
Joins("LEFT JOIN tb_iot_card ic ON oc.iot_card_id = ic.id AND ic.deleted_at IS NULL").
|
||||
Joins("LEFT JOIN tb_device d ON oc.device_id = d.id AND oc.deleted_at IS NULL").
|
||||
Select(`'` + sourceClawback + `' AS source, g.id, g.shop_id, g.order_id, ` +
|
||||
`COALESCE(NULLIF(g.order_no, ''), o.order_no) AS order_no, ic.iccid, d.virtual_no, ` +
|
||||
`COALESCE(NULLIF(g.order_no, ''), o.order_no) AS order_no, o.created_at AS order_created_at, ` +
|
||||
`oc.iot_card_id, oc.device_id, ` +
|
||||
`g.commission_source, g.amount, g.balance_after, g.status, ` +
|
||||
`NULL::timestamp AS released_at, g.created_at, g.original_commission_id, g.refund_no, g.withdrawable`)
|
||||
query = applyExportShopScope(query, params, "g.shop_id")
|
||||
@@ -191,9 +265,11 @@ func applyCommissionExportFilters(query *gorm.DB, params ExportParams, shopColum
|
||||
type commissionRecordExportRow struct {
|
||||
Source string `gorm:"column:source"`
|
||||
ID uint `gorm:"column:id"`
|
||||
ShopName string `gorm:"column:shop_name"`
|
||||
ShopID uint `gorm:"column:shop_id"`
|
||||
OrderNo string `gorm:"column:order_no"`
|
||||
AssetIdentifier string `gorm:"column:asset_identifier"`
|
||||
OrderCreatedAt *time.Time `gorm:"column:order_created_at"`
|
||||
IotCardID *uint `gorm:"column:iot_card_id"`
|
||||
DeviceID *uint `gorm:"column:device_id"`
|
||||
CommissionSource string `gorm:"column:commission_source"`
|
||||
Amount int64 `gorm:"column:amount"`
|
||||
Withdrawable *bool `gorm:"column:withdrawable"`
|
||||
@@ -205,6 +281,161 @@ type commissionRecordExportRow struct {
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
}
|
||||
|
||||
// commissionExportShop 是执行时当前店铺归属投影。
|
||||
type commissionExportShop struct {
|
||||
ID uint `gorm:"column:id"`
|
||||
ShopName string `gorm:"column:shop_name"`
|
||||
BusinessOwnerAccountID *uint `gorm:"column:business_owner_account_id"`
|
||||
}
|
||||
|
||||
// commissionAssetDevice 是执行时当前设备类型与型号投影。
|
||||
type commissionAssetDevice struct {
|
||||
ID uint `gorm:"column:id"`
|
||||
VirtualNo string `gorm:"column:virtual_no"`
|
||||
DeviceType string `gorm:"column:device_type"`
|
||||
DeviceModel string `gorm:"column:device_model"`
|
||||
}
|
||||
|
||||
// commissionExportAssets 是执行时当前资产维度投影:卡标识、卡当前绑定设备与设备自身的类型型号。
|
||||
type commissionExportAssets struct {
|
||||
cardICCIDs map[uint]string
|
||||
boundDeviceIDs map[uint]uint
|
||||
devices map[uint]commissionAssetDevice
|
||||
}
|
||||
|
||||
// describe 返回单条佣金记录资产在导出执行时的当前维度。
|
||||
// 关联卡时资产类型为卡、资产标识取卡 ICCID、设备维度取该卡当前绑定的设备;
|
||||
// 关联设备时资产类型为设备、资产标识取设备虚拟号、设备维度取设备自身;
|
||||
// 既无卡也无设备、或对应资产已不可读时一律返回空值,不影响该行其余列。
|
||||
func (a commissionExportAssets) describe(cardID, deviceID *uint) (assetType, identifier, deviceType, deviceModel string) {
|
||||
switch {
|
||||
case cardID != nil:
|
||||
assetType = assetTypeName(constants.AssetTypeIotCard)
|
||||
identifier = a.cardICCIDs[*cardID]
|
||||
if bound, ok := a.boundDeviceIDs[*cardID]; ok {
|
||||
device := a.devices[bound]
|
||||
deviceType, deviceModel = device.DeviceType, device.DeviceModel
|
||||
}
|
||||
case deviceID != nil:
|
||||
assetType = assetTypeName(constants.AssetTypeDevice)
|
||||
device := a.devices[*deviceID]
|
||||
identifier = device.VirtualNo
|
||||
deviceType, deviceModel = device.DeviceType, device.DeviceModel
|
||||
default:
|
||||
return "", "", "", ""
|
||||
}
|
||||
return assetType, identifier, deviceType, deviceModel
|
||||
}
|
||||
|
||||
// loadShopOwners 按店铺 ID 批量读取执行时当前店铺名称与业务员账号。
|
||||
func (s *CommissionRecordDataSource) loadShopOwners(ctx context.Context, shopIDs []uint) (map[uint]commissionExportShop, error) {
|
||||
result := make(map[uint]commissionExportShop, len(shopIDs))
|
||||
if len(shopIDs) == 0 {
|
||||
return result, nil
|
||||
}
|
||||
var rows []commissionExportShop
|
||||
if err := s.db.WithContext(ctx).Table("tb_shop").
|
||||
Select("id, shop_name, business_owner_account_id").
|
||||
Where("id IN ? AND deleted_at IS NULL", shopIDs).
|
||||
Scan(&rows).Error; err != nil {
|
||||
return nil, errors.Wrap(errors.CodeDatabaseError, err, "查询佣金导出店铺当前归属失败")
|
||||
}
|
||||
for _, row := range rows {
|
||||
result[row.ID] = row
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// loadAssetDimensions 按卡与设备 ID 批量读取执行时当前资产维度。
|
||||
// 卡资产的设备维度取该卡当前绑定的设备(一卡至多一条生效绑定),未绑定或绑定设备已删除时留空。
|
||||
func (s *CommissionRecordDataSource) loadAssetDimensions(ctx context.Context, cardIDs, deviceIDs []uint) (commissionExportAssets, error) {
|
||||
result := commissionExportAssets{
|
||||
cardICCIDs: make(map[uint]string, len(cardIDs)),
|
||||
boundDeviceIDs: make(map[uint]uint, len(cardIDs)),
|
||||
devices: make(map[uint]commissionAssetDevice, len(deviceIDs)),
|
||||
}
|
||||
if len(cardIDs) > 0 {
|
||||
var cards []struct {
|
||||
ID uint `gorm:"column:id"`
|
||||
ICCID string `gorm:"column:iccid"`
|
||||
}
|
||||
if err := s.db.WithContext(ctx).Table("tb_iot_card").
|
||||
Select("id, iccid").
|
||||
Where("id IN ? AND deleted_at IS NULL", cardIDs).
|
||||
Scan(&cards).Error; err != nil {
|
||||
return commissionExportAssets{}, errors.Wrap(errors.CodeDatabaseError, err, "查询佣金导出资产卡标识失败")
|
||||
}
|
||||
for _, card := range cards {
|
||||
result.cardICCIDs[card.ID] = card.ICCID
|
||||
}
|
||||
|
||||
var bindings []struct {
|
||||
IotCardID uint `gorm:"column:iot_card_id"`
|
||||
DeviceID uint `gorm:"column:device_id"`
|
||||
}
|
||||
if err := s.db.WithContext(ctx).Table("tb_device_sim_binding AS b").
|
||||
Select("b.iot_card_id, b.device_id").
|
||||
Joins("JOIN tb_device AS d ON d.id = b.device_id AND d.deleted_at IS NULL").
|
||||
Where("b.iot_card_id IN ? AND b.bind_status = ? AND b.deleted_at IS NULL", cardIDs, constants.BindStatusBound).
|
||||
Scan(&bindings).Error; err != nil {
|
||||
return commissionExportAssets{}, errors.Wrap(errors.CodeDatabaseError, err, "查询佣金导出卡当前绑定设备失败")
|
||||
}
|
||||
for _, binding := range bindings {
|
||||
result.boundDeviceIDs[binding.IotCardID] = binding.DeviceID
|
||||
deviceIDs = append(deviceIDs, binding.DeviceID)
|
||||
}
|
||||
}
|
||||
deviceIDs = normalizeUintSlice(deviceIDs)
|
||||
if len(deviceIDs) > 0 {
|
||||
var devices []commissionAssetDevice
|
||||
if err := s.db.WithContext(ctx).Table("tb_device").
|
||||
Select("id, virtual_no, device_type, device_model").
|
||||
Where("id IN ? AND deleted_at IS NULL", deviceIDs).
|
||||
Scan(&devices).Error; err != nil {
|
||||
return commissionExportAssets{}, errors.Wrap(errors.CodeDatabaseError, err, "查询佣金导出设备类型与型号失败")
|
||||
}
|
||||
for _, device := range devices {
|
||||
result.devices[device.ID] = device
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// loadClawbackIDs 按原佣金批量读取其全部回溯明细编号,按生成顺序稳定排列。
|
||||
func (s *CommissionRecordDataSource) loadClawbackIDs(ctx context.Context, originalIDs []uint) (map[uint][]uint, error) {
|
||||
result := make(map[uint][]uint, len(originalIDs))
|
||||
if len(originalIDs) == 0 {
|
||||
return result, nil
|
||||
}
|
||||
var rows []struct {
|
||||
ID uint `gorm:"column:id"`
|
||||
OriginalCommissionID uint `gorm:"column:original_commission_id"`
|
||||
}
|
||||
if err := s.db.WithContext(ctx).Table("tb_commission_clawback_record").
|
||||
Select("id, original_commission_id").
|
||||
Where("original_commission_id IN ?", originalIDs).
|
||||
Order("id ASC").
|
||||
Scan(&rows).Error; err != nil {
|
||||
return nil, errors.Wrap(errors.CodeDatabaseError, err, "查询原佣金关联回溯明细失败")
|
||||
}
|
||||
for _, row := range rows {
|
||||
result[row.OriginalCommissionID] = append(result[row.OriginalCommissionID], row.ID)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// formatClawbackIDList 输出原佣金关联的全部回溯明细编号;无回溯关系时为空。
|
||||
func formatClawbackIDList(ids []uint) string {
|
||||
if len(ids) == 0 {
|
||||
return ""
|
||||
}
|
||||
parts := make([]string, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
parts = append(parts, strconv.FormatUint(uint64(id), 10))
|
||||
}
|
||||
return strings.Join(parts, "、")
|
||||
}
|
||||
|
||||
// formatCommissionLedgerSource 把记录来源转为导出用中文描述。
|
||||
func formatCommissionLedgerSource(source string) string {
|
||||
if source == sourceClawback {
|
||||
|
||||
@@ -20,9 +20,13 @@ const operationsReportEmptyValue = "-"
|
||||
// 合计行的分组列值。
|
||||
const operationsReportTotalGroup = "合计"
|
||||
|
||||
// 序号列表头;分组行按导出展示顺序从 1 连续递增,合计行留空不写入任何数字或文字。
|
||||
const operationsReportSerialHeader = "序号"
|
||||
|
||||
// OperationsActivationDataSource 设备激活情况报表导出数据源。
|
||||
//
|
||||
// 导出列与页面展示字段一致并包含合计行,不含任何文字总结;
|
||||
// 导出列与页面展示字段一致并包含合计行,首列为「序号」:分组行按展示顺序从 1 连续递增,
|
||||
// 合计行的序号列留空且其余各列的既有表示不变;导出不含任何文字总结;
|
||||
// 行集合与汇总查询完全一致:两侧共用同一个查询实现,因此筛选与口径不会漂移。
|
||||
// 本场景只对超级管理员与平台账号开放:受控入口已做角色门禁,这里再按任务内冻结的账号类型复核一次,
|
||||
// 阻止通过通用导出入口以代理身份创建本场景任务后读到运营报表数据。
|
||||
@@ -81,12 +85,13 @@ func (s *OperationsActivationDataSource) build(ctx context.Context, params Expor
|
||||
return nil, err
|
||||
}
|
||||
headers := []string{
|
||||
response.GroupName, "采购数量", "累计激活数", "激活率", "新增激活数",
|
||||
operationsReportSerialHeader, response.GroupName, "采购数量", "累计激活数", "激活率", "新增激活数",
|
||||
"累计在网数", "活跃用户数", "累计用量(GB)", "单用户卡均(GB)", "含零预测卡均(GB)", "不含零预测卡均(GB)",
|
||||
}
|
||||
rows := make([][]string, 0, len(response.Items)+1)
|
||||
for _, item := range response.Items {
|
||||
for index, item := range response.Items {
|
||||
rows = append(rows, []string{
|
||||
strconv.Itoa(index + 1),
|
||||
item.GroupValue,
|
||||
formatOptionalInt64(item.PurchasedDeviceCount),
|
||||
formatOptionalInt64(item.ActivatedDeviceCount),
|
||||
@@ -103,6 +108,8 @@ func (s *OperationsActivationDataSource) build(ctx context.Context, params Expor
|
||||
if response.Totals != nil {
|
||||
total := response.Totals
|
||||
rows = append(rows, []string{
|
||||
// 合计行序号列留空,其余各列沿用既有表示。
|
||||
"",
|
||||
operationsReportTotalGroup,
|
||||
formatOptionalInt64(total.PurchasedDeviceCount),
|
||||
formatOptionalInt64(total.ActivatedDeviceCount),
|
||||
@@ -121,7 +128,8 @@ func (s *OperationsActivationDataSource) build(ctx context.Context, params Expor
|
||||
|
||||
// OperationsRenewalDataSource 套餐续费情况报表导出数据源。
|
||||
//
|
||||
// 导出列与页面展示字段一致并包含合计行,不含任何文字总结;
|
||||
// 导出列与页面展示字段一致并包含合计行,首列为「序号」:分组行按展示顺序从 1 连续递增,
|
||||
// 合计行的序号列留空且其余各列的既有表示不变;导出不含任何文字总结;
|
||||
// 行集合与汇总查询完全一致:两侧共用同一个查询实现,因此筛选与口径不会漂移。
|
||||
// 本场景同样按任务内冻结的账号类型复核导出资格。
|
||||
type OperationsRenewalDataSource struct {
|
||||
@@ -178,10 +186,11 @@ func (s *OperationsRenewalDataSource) build(ctx context.Context, params ExportPa
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
headers := []string{response.GroupName, "到期资产数", "续费资产数", "续费率", "新增未续费数"}
|
||||
headers := []string{operationsReportSerialHeader, response.GroupName, "到期资产数", "续费资产数", "续费率", "新增未续费数"}
|
||||
rows := make([][]string, 0, len(response.Items)+1)
|
||||
for _, item := range response.Items {
|
||||
for index, item := range response.Items {
|
||||
rows = append(rows, []string{
|
||||
strconv.Itoa(index + 1),
|
||||
item.GroupValue,
|
||||
formatOptionalInt64(item.DueAssetCount),
|
||||
formatOptionalInt64(item.RenewedAssetCount),
|
||||
@@ -192,6 +201,8 @@ func (s *OperationsRenewalDataSource) build(ctx context.Context, params ExportPa
|
||||
if response.Totals != nil {
|
||||
total := response.Totals
|
||||
rows = append(rows, []string{
|
||||
// 合计行序号列留空,其余各列沿用既有表示。
|
||||
"",
|
||||
operationsReportTotalGroup,
|
||||
formatOptionalInt64(total.DueAssetCount),
|
||||
formatOptionalInt64(total.RenewedAssetCount),
|
||||
|
||||
@@ -43,6 +43,7 @@ func (s *RefundDataSource) Headers(context.Context, ExportParams) ([]string, err
|
||||
"当前退款套餐已用量(MB)", "当前退款套餐总量(MB)", "原订单金额(元)",
|
||||
"实收金额(元)", "可退金额(元)", "申请退款金额(元)", "实际退款金额(元)", "状态", "退款方式",
|
||||
"冻结实收金额(元)", "渠道退款状态", "渠道退款流水号", "渠道退款金额(元)", "失败分类", "异常标记",
|
||||
"来源支付单号", "原支付渠道交易流水号", "线下退款处理流水号",
|
||||
"退款原因", "审批备注",
|
||||
"审批来源", "审批状态", "退款处理状态", "退款申请时间", "退款审批时间", "提交人", "退款凭证",
|
||||
}, nil
|
||||
@@ -70,6 +71,9 @@ func (s *RefundDataSource) Fetch(ctx context.Context, params ExportParams, offse
|
||||
r.channel_refund_status,
|
||||
r.channel_refund_no,
|
||||
r.channel_refund_amount,
|
||||
r.source_payment_no,
|
||||
r.original_channel_trade_no,
|
||||
r.offline_settlement_no,
|
||||
r.failure_reason,
|
||||
r.anomaly_flag,
|
||||
r.refund_reason,
|
||||
@@ -146,6 +150,9 @@ func (s *RefundDataSource) Fetch(ctx context.Context, params ExportParams, offse
|
||||
constants.RefundChannelStatusName(item.ChannelRefundStatus),
|
||||
item.ChannelRefundNo,
|
||||
formatMoneyYuan(item.ChannelRefundAmount),
|
||||
item.SourcePaymentNo,
|
||||
item.OriginalChannelTradeNo,
|
||||
item.OfflineSettlementNo,
|
||||
constants.RefundFailureReasonName(item.FailureReason),
|
||||
formatRefundAnomalyFlag(item.AnomalyFlag),
|
||||
item.RefundReason,
|
||||
@@ -203,6 +210,9 @@ type refundExportRow struct {
|
||||
ChannelRefundStatus int `gorm:"column:channel_refund_status"`
|
||||
ChannelRefundNo string `gorm:"column:channel_refund_no"`
|
||||
ChannelRefundAmount int64 `gorm:"column:channel_refund_amount"`
|
||||
SourcePaymentNo string `gorm:"column:source_payment_no"`
|
||||
OriginalChannelTradeNo string `gorm:"column:original_channel_trade_no"`
|
||||
OfflineSettlementNo string `gorm:"column:offline_settlement_no"`
|
||||
FailureReason string `gorm:"column:failure_reason"`
|
||||
AnomalyFlag int `gorm:"column:anomaly_flag"`
|
||||
RefundReason string `gorm:"column:refund_reason"`
|
||||
|
||||
Reference in New Issue
Block a user