feat(员工代收款): 新增员工代收款账单闭环
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m20s
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
This commit is contained in:
69
internal/domain/employeecollection/payment_method.go
Normal file
69
internal/domain/employeecollection/payment_method.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package employeecollection
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||
)
|
||||
|
||||
// PaymentMethodInput 是线下收款方式字典写入的领域输入。
|
||||
type PaymentMethodInput struct {
|
||||
// Code 表示稳定编码,创建后仅可在未被引用时修改。
|
||||
Code string
|
||||
// Name 表示收款方式名称。
|
||||
Name string
|
||||
// SortOrder 表示排序值,必须非负。
|
||||
SortOrder int64
|
||||
// Status 表示启停状态,取值见 constants.EmployeeCollectionPaymentMethodStatus*。
|
||||
Status int
|
||||
// Remark 表示备注。
|
||||
Remark string
|
||||
}
|
||||
|
||||
// NormalizedPaymentMethodInput 是通过校验并去空格后的字典写入事实。
|
||||
type NormalizedPaymentMethodInput struct {
|
||||
Code string
|
||||
Name string
|
||||
SortOrder int64
|
||||
Status int
|
||||
Remark string
|
||||
}
|
||||
|
||||
// NormalizePaymentMethodInput 校验并规范化线下收款方式字典写入输入。
|
||||
// 规则:编码 1 至 64 字符且不含空白或控制字符、名称 1 至 100 字符、
|
||||
// 排序值非负、状态仅允许启用或停用、备注不超过 500 字符。
|
||||
func NormalizePaymentMethodInput(input PaymentMethodInput) (NormalizedPaymentMethodInput, error) {
|
||||
code := strings.TrimSpace(input.Code)
|
||||
if code == "" {
|
||||
return NormalizedPaymentMethodInput{}, errors.New(errors.CodeInvalidParam, "收款方式编码必填")
|
||||
}
|
||||
if len([]rune(code)) > constants.EmployeeCollectionCodeMaxLength {
|
||||
return NormalizedPaymentMethodInput{}, errors.New(errors.CodeInvalidParam, "收款方式编码长度超出限制")
|
||||
}
|
||||
if strings.IndexFunc(code, func(r rune) bool { return unicode.IsSpace(r) || unicode.IsControl(r) }) >= 0 {
|
||||
return NormalizedPaymentMethodInput{}, errors.New(errors.CodeInvalidParam, "收款方式编码不能包含空白或控制字符")
|
||||
}
|
||||
name := strings.TrimSpace(input.Name)
|
||||
if name == "" {
|
||||
return NormalizedPaymentMethodInput{}, errors.New(errors.CodeInvalidParam, "收款方式名称必填")
|
||||
}
|
||||
if len([]rune(name)) > constants.EmployeeCollectionNameMaxLength {
|
||||
return NormalizedPaymentMethodInput{}, errors.New(errors.CodeInvalidParam, "收款方式名称长度超出限制")
|
||||
}
|
||||
if input.SortOrder < 0 {
|
||||
return NormalizedPaymentMethodInput{}, errors.New(errors.CodeInvalidParam, "收款方式排序值不能为负")
|
||||
}
|
||||
if input.Status != constants.EmployeeCollectionPaymentMethodStatusDisabled &&
|
||||
input.Status != constants.EmployeeCollectionPaymentMethodStatusEnabled {
|
||||
return NormalizedPaymentMethodInput{}, errors.New(errors.CodeInvalidParam, "收款方式状态仅支持停用或启用")
|
||||
}
|
||||
remark := strings.TrimSpace(input.Remark)
|
||||
if len([]rune(remark)) > constants.EmployeeCollectionRemarkMaxLength {
|
||||
return NormalizedPaymentMethodInput{}, errors.New(errors.CodeInvalidParam, "收款方式备注长度超出限制")
|
||||
}
|
||||
return NormalizedPaymentMethodInput{
|
||||
Code: code, Name: name, SortOrder: input.SortOrder, Status: input.Status, Remark: remark,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user