All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m20s
- 新增 6 张表与成对迁移 000212,扩展企业微信审批场景业务类型白名单 - 后台线下套餐订单与两条代理线下充值入账路径在来源成功事务内建账,来源唯一键幂等 - 核销申请、审批尝试记录、账单分摊预占与驳回重提,审批业务类型 employee_collection_approval - 企业微信终态消费幂等:通过转已核销、驳回释放预占、通过后撤销不回滚并转异常终态 - 退款成功事务内按 bill_id+refund_id 幂等冲销账单或仅写退款关联提示 - 线下收款方式字典、账单查询/统计/关闭、申请查询与代办权限,均写入事务内审计 OpenSpec Change: add-employee-collection-bills
42 lines
1.9 KiB
Go
42 lines
1.9 KiB
Go
package audit
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
employeecollection "github.com/break/junhong_cmp_fiber/internal/application/employeecollection"
|
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
|
)
|
|
|
|
// WriteEmployeeCollectionBill 将员工代收款账单事实变化写入统一 Audit Event。
|
|
// 操作者与入口来自调用方审计上下文:订单建账为后台账号入口,充值入账为 Worker 或渠道回调入口。
|
|
func (w *Writer) WriteEmployeeCollectionBill(ctx context.Context, tx *gorm.DB, change employeecollection.BillAudit) error {
|
|
if change.Bill == nil || change.Bill.ID == 0 || change.Bill.SourceKey == "" {
|
|
return errors.New(errors.CodeInvalidParam, "员工代收款账单审计资源不完整")
|
|
}
|
|
bill := change.Bill
|
|
resourceID := strconv.FormatUint(uint64(bill.ID), 10)
|
|
return w.Append(ctx, tx, AppendInput{
|
|
EventID: change.EventID, ActionCode: change.ActionCode, Summary: change.Summary,
|
|
ScopeType: constants.AuditScopePlatform, Result: constants.AuditResultSuccess,
|
|
CorrelationID: change.CorrelationID,
|
|
Resources: []ResourceInput{{
|
|
Type: constants.AuditResourceEmployeeCollectionBill, ID: &resourceID,
|
|
Key: bill.SourceKey, DisplayName: bill.SourceNo,
|
|
Relation: constants.AuditResourceRelationPrimary, Role: constants.AuditResourceRoleCollectionBill,
|
|
IdentitySnapshot: map[string]any{
|
|
"id": bill.ID, "source_type": bill.SourceType, "source_id": bill.SourceID,
|
|
"source_key": bill.SourceKey, "source_no": bill.SourceNo,
|
|
"debtor_account_id": bill.DebtorAccountID, "receivable_amount": bill.ReceivableAmount,
|
|
"received_amount": bill.ReceivedAmount, "reserved_amount": bill.ReservedAmount,
|
|
"status": bill.Status,
|
|
},
|
|
BeforeData: change.BeforeData, AfterData: change.AfterData,
|
|
SubjectVisibility: constants.AuditSubjectResult, SubjectSummary: change.Summary,
|
|
}},
|
|
})
|
|
}
|