Files
junhong_cmp_fiber/pkg/constants/employee_collection.go
break ce24d5612e
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m20s
feat(员工代收款): 新增员工代收款账单闭环
- 新增 6 张表与成对迁移 000212,扩展企业微信审批场景业务类型白名单
- 后台线下套餐订单与两条代理线下充值入账路径在来源成功事务内建账,来源唯一键幂等
- 核销申请、审批尝试记录、账单分摊预占与驳回重提,审批业务类型 employee_collection_approval
- 企业微信终态消费幂等:通过转已核销、驳回释放预占、通过后撤销不回滚并转异常终态
- 退款成功事务内按 bill_id+refund_id 幂等冲销账单或仅写退款关联提示
- 线下收款方式字典、账单查询/统计/关闭、申请查询与代办权限,均写入事务内审计

OpenSpec Change: add-employee-collection-bills
2026-09-10 18:24:05 +08:00

165 lines
7.0 KiB
Go

package constants
// 员工代收款账单来源类型,取值与 tb_employee_collection_bill.source_type 检查约束一致。
const (
// EmployeeCollectionSourceTypeOrder 表示来源为后台线下套餐订单。
EmployeeCollectionSourceTypeOrder = "order"
// EmployeeCollectionSourceTypeRecharge 表示来源为代理线下充值入账。
EmployeeCollectionSourceTypeRecharge = "recharge"
)
// 员工代收款账单状态,取值与 tb_employee_collection_bill.status 检查约束一致。
const (
// EmployeeCollectionBillStatusPending 表示账单待核销。
EmployeeCollectionBillStatusPending = 0
// EmployeeCollectionBillStatusPartial 表示账单部分核销。
EmployeeCollectionBillStatusPartial = 1
// EmployeeCollectionBillStatusSettled 表示账单已核销。
EmployeeCollectionBillStatusSettled = 2
// EmployeeCollectionBillStatusClosed 表示账单已关闭,未核销余额作废。
EmployeeCollectionBillStatusClosed = 3
)
// 核销申请状态,取值与 tb_employee_collection_application.status 检查约束一致。
// 申请状态不覆盖账单核销状态,两者独立保存。
const (
// EmployeeCollectionApplicationStatusPending 表示核销申请审批中。
EmployeeCollectionApplicationStatusPending = 0
// EmployeeCollectionApplicationStatusApproved 表示核销申请企业微信最终通过。
EmployeeCollectionApplicationStatusApproved = 1
// EmployeeCollectionApplicationStatusRejected 表示核销申请企业微信最终驳回。
EmployeeCollectionApplicationStatusRejected = 2
// EmployeeCollectionApplicationStatusRevoked 表示核销申请通过后撤销等异常终态或已关闭。
EmployeeCollectionApplicationStatusRevoked = 3
)
// 核销分摊状态,取值与 tb_employee_collection_application_allocation.status 检查约束一致。
const (
// EmployeeCollectionAllocationStatusPending 表示分摊审批中并预占账单余额。
EmployeeCollectionAllocationStatusPending = 0
// EmployeeCollectionAllocationStatusApproved 表示分摊已通过并转入账单已核销金额。
EmployeeCollectionAllocationStatusApproved = 1
// EmployeeCollectionAllocationStatusReleased 表示分摊已驳回或已释放预占。
EmployeeCollectionAllocationStatusReleased = 2
)
// 退款冲销处理结果,取值与 tb_employee_collection_bill_refund.outcome 检查约束一致。
const (
// EmployeeCollectionRefundOutcomeClosedFull 表示退款金额等于账单应收且无分摊,账单全额关闭。
EmployeeCollectionRefundOutcomeClosedFull = "closed_full"
// EmployeeCollectionRefundOutcomeReduced 表示退款金额小于账单应收且无分摊,按退款金额冲减应收。
EmployeeCollectionRefundOutcomeReduced = "reduced"
// EmployeeCollectionRefundOutcomeHintOnly 表示存在已通过或审批中分摊,仅写退款关联提示。
EmployeeCollectionRefundOutcomeHintOnly = "hint_only"
)
// 线下收款方式字典启停状态,取值与 tb_employee_collection_payment_method.status 检查约束一致。
const (
// EmployeeCollectionPaymentMethodStatusDisabled 表示收款方式已停用,新申请不可选择。
EmployeeCollectionPaymentMethodStatusDisabled = 0
// EmployeeCollectionPaymentMethodStatusEnabled 表示收款方式已启用。
EmployeeCollectionPaymentMethodStatusEnabled = 1
)
// 员工代收款账单与核销申请的输入边界。
const (
// EmployeeCollectionCodeMaxLength 表示收款方式稳定编码最大长度。
EmployeeCollectionCodeMaxLength = 64
// EmployeeCollectionNameMaxLength 表示收款方式名称最大长度。
EmployeeCollectionNameMaxLength = 100
// EmployeeCollectionRemarkMaxLength 表示备注最大长度。
EmployeeCollectionRemarkMaxLength = 500
// EmployeeCollectionPayerNameMaxLength 表示付款方名称最大长度。
EmployeeCollectionPayerNameMaxLength = 100
// EmployeeCollectionExternalTransactionNoMaxLength 表示外部交易流水号最大长度。
EmployeeCollectionExternalTransactionNoMaxLength = 128
// EmployeeCollectionVoucherMinCount 表示一次申请要求的最少支付凭证数量。
EmployeeCollectionVoucherMinCount = 1
// EmployeeCollectionVoucherMaxCount 表示一次申请允许的最多支付凭证数量。
EmployeeCollectionVoucherMaxCount = 5
// EmployeeCollectionVoucherKeyMaxLength 表示单个支付凭证对象键最大长度。
EmployeeCollectionVoucherKeyMaxLength = 512
// EmployeeCollectionAllocationMaxCount 表示一次申请允许的最多账单分摊数量。
EmployeeCollectionAllocationMaxCount = 50
)
// 员工代收款审计配置键前缀。
const (
// EmployeeCollectionAuditConfigKeyPrefix 表示线下收款方式字典审计配置键前缀。
EmployeeCollectionAuditConfigKeyPrefix = "employee_collection.payment_method"
// EmployeeCollectionAuditModule 表示员工代收款能力的审计模块标识。
EmployeeCollectionAuditModule = "employee_collection"
)
// GetEmployeeCollectionBillStatusName 返回员工代收款账单状态的中文名称。
func GetEmployeeCollectionBillStatusName(status int) string {
switch status {
case EmployeeCollectionBillStatusPending:
return "待核销"
case EmployeeCollectionBillStatusPartial:
return "部分核销"
case EmployeeCollectionBillStatusSettled:
return "已核销"
case EmployeeCollectionBillStatusClosed:
return "已关闭"
default:
return "未知状态"
}
}
// GetEmployeeCollectionApplicationStatusName 返回核销申请状态的中文名称。
func GetEmployeeCollectionApplicationStatusName(status int) string {
switch status {
case EmployeeCollectionApplicationStatusPending:
return "审批中"
case EmployeeCollectionApplicationStatusApproved:
return "已通过"
case EmployeeCollectionApplicationStatusRejected:
return "已驳回"
case EmployeeCollectionApplicationStatusRevoked:
return "已撤销或已关闭"
default:
return "未知状态"
}
}
// GetEmployeeCollectionAllocationStatusName 返回核销分摊状态的中文名称。
func GetEmployeeCollectionAllocationStatusName(status int) string {
switch status {
case EmployeeCollectionAllocationStatusPending:
return "审批中预占"
case EmployeeCollectionAllocationStatusApproved:
return "已通过"
case EmployeeCollectionAllocationStatusReleased:
return "已驳回或已释放"
default:
return "未知状态"
}
}
// GetEmployeeCollectionSourceTypeName 返回员工代收款账单来源类型的中文名称。
func GetEmployeeCollectionSourceTypeName(sourceType string) string {
switch sourceType {
case EmployeeCollectionSourceTypeOrder:
return "后台线下套餐订单"
case EmployeeCollectionSourceTypeRecharge:
return "代理线下充值"
default:
return "未知来源"
}
}
// GetEmployeeCollectionRefundOutcomeName 返回退款冲销处理结果的中文名称。
func GetEmployeeCollectionRefundOutcomeName(outcome string) string {
switch outcome {
case EmployeeCollectionRefundOutcomeClosedFull:
return "来源订单全额退款关闭"
case EmployeeCollectionRefundOutcomeReduced:
return "按退款金额冲减应收"
case EmployeeCollectionRefundOutcomeHintOnly:
return "仅记录退款关联提示"
default:
return "未知结果"
}
}