diff --git a/.gitignore b/.gitignore
index 4ae261a..86f86f8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,12 @@ application-local.yml
application-local.yaml
application-local.properties
+# Private runtime configuration. Spring Boot loads ./config/application.yml
+# automatically when the process starts from the deployment directory.
+config/application.yml
+config/application.yaml
+!config/application.example.yml
+
# IDE, temporary and OS files.
.idea/
.vscode/
diff --git a/README.md b/README.md
index a0a7920..763357d 100644
--- a/README.md
+++ b/README.md
@@ -1,26 +1,41 @@
# Backend deployment notes
+## Configuration file-only deployment
+
+Runtime configuration is read from `./config/application.yml`. Spring Boot loads
+that file automatically when IDEA or the packaged JAR starts with the backend
+directory as its working directory; no environment variables or additional JVM
+arguments are required. Copy `config/application.example.yml` when preparing a
+new server and replace every `CHANGE_ME` value before startup.
+
+`config/application.yml` contains database credentials and cryptographic keys and
+is intentionally ignored by Git. Include it in the private deployment package,
+restrict its filesystem permissions to the service account, and never publish it
+to a source repository. The classpath `src/main/resources/application.yml` keeps
+fail-fast placeholders so a missing private configuration cannot silently start
+with shared credentials.
+
Before saving any `secret=true` value in `sys_integration_config`, configure
-`APP_INTEGRATION_ENCRYPTION_KEY` (preferably a randomly generated 32-byte or
-longer secret) in the backend runtime environment. Do not commit the key or
-place a real value in `src/main/resources/application.yml`.
+`app.integration-encryption-key` in the private configuration file with a random
+32-byte-or-longer secret.
## Payee bank-account protection
-Before creating or changing a payee bank account, provide these runtime secrets:
+Before creating or changing a payee bank account, provide these values in the
+private configuration file:
-- `APP_BANK_ACCOUNT_ENCRYPTION_KEYS`: comma-separated `version=Base64Key`
+- `app.bank-account.encryption-keys`: comma-separated `version=Base64Key`
entries; every decoded AES key must be exactly 32 bytes. Keep old versions
present while old ciphertext still exists.
-- `APP_BANK_ACCOUNT_ACTIVE_KEY_VERSION`: the version used for new ciphertext.
-- `APP_BANK_ACCOUNT_FINGERPRINT_KEY`: a separate Base64-encoded 32-byte HMAC key.
+- `app.bank-account.active-key-version`: the version used for new ciphertext.
+- `app.bank-account.fingerprint-key`: a separate Base64-encoded 32-byte HMAC key.
Never reuse the integration key, JWT secret, database password, or an encryption
key as the fingerprint key. Keep all real values outside the repository.
For an existing database, apply
`V20261201_02__protect_payee_bank_accounts.sql` first. After a verified backup,
-set `APP_BANK_ACCOUNT_LEGACY_BACKFILL_ENABLED=true` for one observed maintenance
+set `app.bank-account.legacy-backfill-enabled=true` for one observed maintenance
run, then return it to `false`. The backfill is deliberately non-destructive: it
adds ciphertext, mask, fingerprint, and key version but does not clear the legacy
plaintext column. Final plaintext clearing requires a separate reviewed change,
@@ -42,7 +57,7 @@ or have a DBA pre-create those tables and keep the runtime account DML-only.
Existing installations use the closed manifest and chain runner documented in
[`../financial_system_docs/mysql-migration-runner.md`](../financial_system_docs/mysql-migration-runner.md), with
DBA review and staging rehearsal; never run the clean-install snapshot against them.
-Deployment JDBC `serverTimezone` and `DB_TIME_ZONE` are both `UTC`. MySQL 8.4 LTS
+Deployment JDBC `serverTimezone` and `database.time-zone` are both `UTC`. MySQL 8.4 LTS
is the runtime target; repository tests are not evidence of execution on a real
production-equivalent instance, so the exact manifest requires production-like rehearsal.
diff --git a/config/application.example.yml b/config/application.example.yml
new file mode 100644
index 0000000..baf069c
--- /dev/null
+++ b/config/application.example.yml
@@ -0,0 +1,126 @@
+# Copy this file to ./config/application.yml and replace every CHANGE_ME value.
+# The private application.yml is loaded automatically and must never be committed.
+server:
+ port: 8080
+
+spring:
+ datasource:
+ url: "jdbc:mysql://127.0.0.1:3306/finance_system?useUnicode=true&characterEncoding=utf8&useSSL=true&serverTimezone=UTC"
+ username: "CHANGE_ME_DATABASE_USER"
+ password: "CHANGE_ME_DATABASE_PASSWORD"
+ jpa:
+ hibernate:
+ ddl-auto: validate
+ show-sql: false
+ open-in-view: false
+
+database:
+ time-zone: "UTC"
+
+jwt:
+ secret: "CHANGE_ME_RANDOM_SECRET_AT_LEAST_32_UTF8_BYTES"
+ expiration: 86400000
+
+auth:
+ time-zone: "Asia/Shanghai"
+
+file:
+ storage:
+ provider: "local"
+ local:
+ base-path: "./uploads"
+ aliyun-oss:
+ region: ""
+ endpoint: ""
+ bucket: ""
+ access-key-id: ""
+ access-key-secret: ""
+ session-token: ""
+ cleanup:
+ interval-ms: 30000
+ stale-upload-minutes: 60
+
+feishu:
+ enabled: false
+ app-id: ""
+ app-secret: ""
+ redirect-uri: "https://CHANGE_ME_PUBLIC_HOST/api/feishu/callback"
+ sync-org-enabled: false
+ local-bootstrap-enabled: false
+ local-bootstrap-open-id: ""
+ directory:
+ bootstrap-sync-on-startup: false
+ credential-revision: "1"
+ max-elapsed-seconds: 120
+ department-id-type: "open_department_id"
+ directory-concurrency: 4
+ max-retries: 3
+ requests-per-second: 45
+ requests-per-minute: 900
+ approval:
+ approval-code: ""
+ verification-token: ""
+ encrypt-key: ""
+
+app:
+ frontend-url: "https://CHANGE_ME_PUBLIC_HOST"
+ frontend-allowed-origins: "https://CHANGE_ME_PUBLIC_HOST"
+ integration-encryption-key: "CHANGE_ME_RANDOM_SECRET_AT_LEAST_32_UTF8_BYTES"
+ bank-account:
+ encryption-keys: "v1=CHANGE_ME_BASE64_ENCODED_32_BYTE_AES_KEY"
+ fingerprint-key: "CHANGE_ME_BASE64_ENCODED_32_BYTE_HMAC_KEY"
+ active-key-version: "v1"
+ legacy-backfill-enabled: false
+
+finance:
+ payment:
+ # 付款前财务核对门禁;付款后的银行回单缺失会单独进入待补回单状态。
+ require-receipt-before-registration: false
+ require-independent-review: false
+
+kingdee:
+ enabled: false
+ base-url: ""
+ allowed-hosts: "app.kingdee.com"
+ client-id: ""
+ client-secret: ""
+ db-id: ""
+
+logging:
+ level:
+ com.finance.system: "INFO"
+ com.finance.system.adapter.feishu.FeishuDirectoryService: "INFO"
+ org.springframework.security: "INFO"
+ org.hibernate.SQL: "WARN"
+
+springdoc:
+ api-docs:
+ path: "/v3/api-docs"
+ enabled: false
+ swagger-ui:
+ path: "/swagger-ui.html"
+ enabled: false
+
+management:
+ endpoints:
+ web:
+ exposure:
+ include: "health,prometheus"
+ endpoint:
+ health:
+ show-details: "never"
+
+observability:
+ tenant-id: "CHANGE_ME_TENANT_ID"
+ organization-id: 1
+ audit:
+ max-attempts: 10
+ integrity:
+ current-key-id: "v1"
+ current-key: "CHANGE_ME_RANDOM_SECRET_AT_LEAST_32_UTF8_BYTES"
+ # Key rotation: keep retired keys here only while their audit records still exist.
+ historical-keys: {}
+ verification-enabled: true
+ verification-delay-ms: 300000
+ verification-initial-delay-ms: 60000
+ verification-batch-size: 200
diff --git a/pom.xml b/pom.xml
index 1eb0160..e51b8cb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@
financial_system_backend
1.0.0
financial_system_backend
- 统一费用支付平台 - 员工报销管理系统
+ 统一付款平台 - 企业付款申请与结果管理系统
8
diff --git a/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalEventStateService.java b/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalEventStateService.java
index 58468fd..820cc92 100644
--- a/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalEventStateService.java
+++ b/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalEventStateService.java
@@ -32,7 +32,7 @@ public class FeishuApprovalEventStateService {
}
// Global lock order: application first, then current mapping.
ReimApplication app = applications.findByIdForUpdate(candidate.getApplicationId())
- .orElseThrow(() -> retryable("报销申请尚未就绪"));
+ .orElseThrow(() -> retryable("付款申请尚未就绪"));
IntFeishuApproval mapping = approvals.findByApplicationIdForUpdate(candidate.getApplicationId())
.orElseThrow(() -> retryable("飞书审批映射尚未就绪"));
if (!Objects.equals(instanceCode, mapping.getFeishuInstanceCode())) {
@@ -56,13 +56,13 @@ public class FeishuApprovalEventStateService {
app.setApprovalStatus(normalized);
if (ApprovalStatus.PENDING.name().equals(normalized)) {
app.setApplicationStatus(ApplicationStatus.SUBMITTED.name()); app.setCurrentApprovalNode("飞书审批");
- app.setCurrentApproverId(null); app.setApproveTime(null);
+ app.setCurrentApproverId(null); app.setApproveTime(null); app.setApprovedAmount(null);
} else {
app.setCurrentApproverId(null); app.setCurrentApprovalNode(null);
if (ApprovalStatus.APPROVED.name().equals(normalized)) {
- app.setApplicationStatus(ApplicationStatus.SUBMITTED.name()); app.setApproveTime(LocalDateTime.now());
+ app.setApplicationStatus(ApplicationStatus.SUBMITTED.name()); app.setApproveTime(LocalDateTime.now()); app.setApprovedAmount(app.getTotalAmount());
} else {
- app.setApplicationStatus(ApplicationStatus.DRAFT.name()); app.setApproveTime(null);
+ app.setApplicationStatus(ApplicationStatus.DRAFT.name()); app.setApproveTime(null); app.setApprovedAmount(null);
}
}
applications.save(app);
@@ -76,7 +76,7 @@ public class FeishuApprovalEventStateService {
Long approvalId;
if (candidate != null) {
applications.findByIdForUpdate(candidate.getApplicationId())
- .orElseThrow(() -> retryable("报销申请尚未就绪"));
+ .orElseThrow(() -> retryable("付款申请尚未就绪"));
IntFeishuApproval mapping = approvals.findByApplicationIdForUpdate(candidate.getApplicationId())
.orElseThrow(() -> retryable("飞书审批映射尚未就绪"));
if (Objects.equals(instanceCode, mapping.getFeishuInstanceCode())) approvalId = mapping.getId();
@@ -121,7 +121,7 @@ public class FeishuApprovalEventStateService {
IntFeishuApprovalAttempt known = attempts.findByInstanceCode(instanceCode)
.orElseThrow(() -> retryable("飞书审批映射尚未就绪"));
applications.findByIdForUpdate(known.getApplicationId())
- .orElseThrow(() -> retryable("报销申请尚未就绪"));
+ .orElseThrow(() -> retryable("付款申请尚未就绪"));
IntFeishuApprovalAttempt attempt = attempts.findByInstanceCodeForUpdate(instanceCode)
.orElseThrow(() -> retryable("飞书历史审批映射尚未就绪"));
if (attempt.getEventUpdatedAt() != null && eventTime.isBefore(attempt.getEventUpdatedAt())) return;
@@ -135,7 +135,7 @@ public class FeishuApprovalEventStateService {
IntFeishuApprovalAttempt known = attempts.findByInstanceCode(instanceCode)
.orElseThrow(() -> retryable("飞书审批映射尚未就绪"));
applications.findByIdForUpdate(known.getApplicationId())
- .orElseThrow(() -> retryable("报销申请尚未就绪"));
+ .orElseThrow(() -> retryable("付款申请尚未就绪"));
return attempts.findByInstanceCodeForUpdate(instanceCode)
.orElseThrow(() -> retryable("飞书历史审批映射尚未就绪")).getFeishuApprovalId();
}
diff --git a/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalFormBuilder.java b/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalFormBuilder.java
index b807bb4..4c4702c 100644
--- a/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalFormBuilder.java
+++ b/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalFormBuilder.java
@@ -22,11 +22,11 @@ public final class FeishuApprovalFormBuilder {
public static String buildFormJson(ReimApplication app) {
if (!StringUtils.hasText(app.getFeishuFormFingerprint()) || !StringUtils.hasText(app.getFeishuFormSchema()))
- throw new BusinessException("报销申请缺少已固定的飞书表单快照,禁止创建远程审批", 409);
+ throw new BusinessException("付款申请缺少已固定的飞书表单快照,禁止创建远程审批", 409);
if (!app.getFeishuFormFingerprint().equals(Sha256.hex(app.getFeishuFormSchema())))
- throw new BusinessException("报销申请的飞书表单快照校验失败", 409);
+ throw new BusinessException("付款申请的飞书表单快照校验失败", 409);
if (!StringUtils.hasText(app.getFeishuFormDisplayValues()))
- throw new BusinessException("报销申请缺少不可变的飞书展示值快照", 409);
+ throw new BusinessException("付款申请缺少不可变的飞书展示值快照", 409);
try {
requireSize(app.getFeishuFormSchema(), "飞书表单快照过大");
requireSize(app.getFeishuFormValues(), "飞书自定义表单值过大");
@@ -46,7 +46,7 @@ public final class FeishuApprovalFormBuilder {
requireSize(result, "飞书审批表单过大");
return result;
} catch (BusinessException e) { throw e; }
- catch (Exception e) { throw new BusinessException("报销申请的飞书表单快照无效", 409); }
+ catch (Exception e) { throw new BusinessException("付款申请的飞书表单快照无效", 409); }
}
/** Compatibility overload; mutable master data and line entities are deliberately ignored. */
diff --git a/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalService.java b/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalService.java
index 49c05b3..1cb3a09 100644
--- a/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalService.java
+++ b/src/main/java/com/finance/system/adapter/feishu/FeishuApprovalService.java
@@ -210,7 +210,7 @@ public class FeishuApprovalService {
throw new BusinessException("飞书审批创建参数无效", 400);
String normalizedApprovalCode = intendedApprovalCode.trim();
ReimApplication application = reimApplicationRepository.findById(applicationId)
- .orElseThrow(() -> new BusinessException("报销申请不存在,无法创建飞书审批", 400));
+ .orElseThrow(() -> new BusinessException("付款申请不存在,无法创建飞书审批", 400));
SysUser applicant = application.getApplicantId() == null ? null
: sysUserRepository.findById(application.getApplicantId()).orElse(null);
if (applicant == null || (!StringUtils.hasText(applicant.getFeishuUserId())
@@ -380,7 +380,7 @@ public class FeishuApprovalService {
// Terminal records are monotonic. This prevents a delayed PENDING
// callback from reopening an already approved/rejected application.
ReimApplication application = reimApplicationRepository.findByIdForUpdate(candidate.getApplicationId())
- .orElseThrow(() -> new BusinessException("未找到对应的报销申请"));
+ .orElseThrow(() -> new BusinessException("未找到对应的付款申请"));
IntFeishuApproval syncRecord = intFeishuApprovalRepository.findByApplicationIdForUpdate(candidate.getApplicationId())
.filter(value -> Objects.equals(instanceCode, value.getFeishuInstanceCode()))
.orElseThrow(() -> new BusinessException("审批实例已不是当前申请", 409));
@@ -402,17 +402,20 @@ public class FeishuApprovalService {
application.setCurrentApprovalNode("飞书审批");
application.setCurrentApproverId(null);
application.setApproveTime(null);
+ application.setApprovedAmount(null);
} else {
application.setCurrentApproverId(null);
application.setCurrentApprovalNode(null);
if (ApprovalStatus.APPROVED.name().equals(normalizedStatus)) {
application.setApplicationStatus(ApplicationStatus.SUBMITTED.name());
application.setApproveTime(LocalDateTime.now());
+ application.setApprovedAmount(application.getTotalAmount());
} else {
// Rejected/cancelled applications follow the existing local
// returned-draft behavior and can be corrected and resubmitted.
application.setApplicationStatus(ApplicationStatus.DRAFT.name());
application.setApproveTime(null);
+ application.setApprovedAmount(null);
}
}
reimApplicationRepository.save(application);
@@ -421,7 +424,7 @@ public class FeishuApprovalService {
}
/**
- * 根据报销单ID查询审批进度
+ * 根据付款申请ID查询审批进度
*/
public List getApprovalTimelineByApplication(Long applicationId) {
IntFeishuApproval syncRecord = intFeishuApprovalRepository
diff --git a/src/main/java/com/finance/system/adapter/feishu/FeishuMessageService.java b/src/main/java/com/finance/system/adapter/feishu/FeishuMessageService.java
index b6a6f36..32e8e51 100644
--- a/src/main/java/com/finance/system/adapter/feishu/FeishuMessageService.java
+++ b/src/main/java/com/finance/system/adapter/feishu/FeishuMessageService.java
@@ -93,8 +93,8 @@ public class FeishuMessageService {
private String buildApprovalCard(String applicationNo, String title,
String applicantName, BigDecimal amount, String detailUrl) {
return String.format("{\"config\":{\"wide_screen_mode\":true},"
- + "\"header\":{\"title\":{\"tag\":\"plain_text\",\"content\":\"📋 报销审批待办\"},\"template\":\"blue\"},"
- + "\"elements\":[{\"tag\":\"div\",\"text\":{\"tag\":\"lark_md\",\"content\":\"您有一笔报销申请需要审批:\\n**单号**:%s\\n**标题**:%s\\n**申请人**:%s\\n**金额**:¥%.2f\"}},"
+ + "\"header\":{\"title\":{\"tag\":\"plain_text\",\"content\":\"📋 付款申请审批待办\"},\"template\":\"blue\"},"
+ + "\"elements\":[{\"tag\":\"div\",\"text\":{\"tag\":\"lark_md\",\"content\":\"您有一笔付款申请需要审批:\\n**单号**:%s\\n**标题**:%s\\n**申请人**:%s\\n**申请付款金额**:¥%.2f\"}},"
+ "{\"tag\":\"action\",\"actions\":[{\"tag\":\"button\",\"text\":{\"tag\":\"plain_text\",\"content\":\"去审批\"},\"type\":\"primary\",\"multi_url\":{\"url\":\"%s\",\"pc_url\":\"\"}}]}]}",
applicationNo, title, applicantName, amount, detailUrl);
}
@@ -114,7 +114,7 @@ public class FeishuMessageService {
return String.format("{\"config\":{\"wide_screen_mode\":true},"
+ "\"header\":{\"title\":{\"tag\":\"plain_text\",\"content\":\"💰 付款结果通知\"},\"template\":\"green\"},"
- + "\"elements\":[{\"tag\":\"div\",\"text\":{\"tag\":\"lark_md\",\"content\":\"您的报销申请已处理:\\n**单号**:%s\\n**金额**:¥%.2f\\n**状态**:%s\"}},"
+ + "\"elements\":[{\"tag\":\"div\",\"text\":{\"tag\":\"lark_md\",\"content\":\"您的付款申请已处理:\\n**单号**:%s\\n**申请付款金额**:¥%.2f\\n**状态**:%s\"}},"
+ "{\"tag\":\"action\",\"actions\":[{\"tag\":\"button\",\"text\":{\"tag\":\"plain_text\",\"content\":\"查看详情\"},\"type\":\"default\",\"multi_url\":{\"url\":\"%s\",\"pc_url\":\"\"}}]}]}",
applicationNo, amount, statusText, detailUrl);
}
diff --git a/src/main/java/com/finance/system/adapter/kingdee/KingdeeSyncService.java b/src/main/java/com/finance/system/adapter/kingdee/KingdeeSyncService.java
index 51ce529..8f32e71 100644
--- a/src/main/java/com/finance/system/adapter/kingdee/KingdeeSyncService.java
+++ b/src/main/java/com/finance/system/adapter/kingdee/KingdeeSyncService.java
@@ -18,16 +18,16 @@ public class KingdeeSyncService {
private final KingdeeClient kingdeeClient;
/**
- * 同步报销单到金蝶
+ * 同步付款申请关联单据到金蝶
*/
public void syncExpenseReimbursement(ReimApplication application) {
if (!kingdeeClient.isEnabled()) return;
try {
Map data = buildReimbursementData(application);
Map result = kingdeeClient.save("FIN_EXPENSE_REIMBURSEMENT", data);
- log.info("金蝶同步报销单成功: applicationNo={}", application.getApplicationNo());
+ log.info("金蝶同步付款申请成功: applicationNo={}", application.getApplicationNo());
} catch (Exception e) {
- log.error("金蝶同步报销单失败: applicationNo={}", application.getApplicationNo(), e);
+ log.error("金蝶同步付款申请失败: applicationNo={}", application.getApplicationNo(), e);
throw new BusinessException("金蝶同步失败: " + e.getMessage());
}
}
@@ -48,13 +48,13 @@ public class KingdeeSyncService {
}
/**
- * 查询金蝶报销单状态
+ * 查询金蝶关联业务单据状态
*/
public Map queryReimbursementStatus(String billNo) {
try {
return kingdeeClient.view("FIN_EXPENSE_REIMBURSEMENT", billNo);
} catch (Exception e) {
- log.error("查询金蝶报销单状态失败: billNo={}", billNo, e);
+ log.error("查询金蝶关联业务单据状态失败: billNo={}", billNo, e);
Map result = new HashMap<>();
result.put("error", "金蝶查询失败");
return result;
@@ -62,7 +62,7 @@ public class KingdeeSyncService {
}
/**
- * 构建报销单数据
+ * 构建付款申请关联单据数据
*/
private Map buildReimbursementData(ReimApplication app) {
Map data = new HashMap<>();
diff --git a/src/main/java/com/finance/system/config/LocalDataInitializer.java b/src/main/java/com/finance/system/config/LocalDataInitializer.java
index be1111e..41b00d6 100644
--- a/src/main/java/com/finance/system/config/LocalDataInitializer.java
+++ b/src/main/java/com/finance/system/config/LocalDataInitializer.java
@@ -115,6 +115,7 @@ public class LocalDataInitializer implements CommandLineRunner {
bank.setUserId(employee.getId());
SysPayee payee = SysPayee.builder().tenantId(employee.getTenantId())
.organizationId(employee.getOrganizationId()).payeeType("EMPLOYEE")
+ .relationType("INTERNAL").countryRegion("中国")
.displayName(employee.getRealName()).employeeUserId(employee.getId())
.employeeOpenId(employee.getFeishuOpenId()).status("ACTIVE").build();
payee = payees.save(payee);
diff --git a/src/main/java/com/finance/system/controller/CashierController.java b/src/main/java/com/finance/system/controller/CashierController.java
index 34de9b2..33c985c 100644
--- a/src/main/java/com/finance/system/controller/CashierController.java
+++ b/src/main/java/com/finance/system/controller/CashierController.java
@@ -15,6 +15,7 @@ import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
+import java.time.LocalDate;
import java.util.List;
import java.util.Map;
@@ -52,9 +53,12 @@ public class CashierController {
@RequestHeader(value = "Idempotency-Key", required = false) String idempotencyKey) {
Long userId = AuditUtil.getCurrentUserId();
String resolvedIdempotencyKey = resolveIdempotencyKey(idempotencyKey, request.getIdempotencyKey());
+ BigDecimal amount = resolveAmount(request);
+ String method = resolveAlias(request.getPaymentMethod(), request.getActualPaymentMethod(), "付款方式");
+ String reference = resolveAlias(request.getReferenceNo(), request.getBankTransactionNo(), "银行流水号");
PaymentResultDto result = reimPaymentService.executePayment(request.getApplicationId(),
- request.getPaymentAmount(), userId, request.getPaymentMethod(), request.getReferenceNo(),
- request.getRemark(), resolvedIdempotencyKey);
+ amount, userId, method, reference, requiredPaymentDate(request.getActualPaymentDate()),
+ request.getPaymentReceipt(), request.getSource(), request.getRemark(), resolvedIdempotencyKey);
return ResponseEntity.ok(ApiResponse.success(result));
}
@@ -64,11 +68,14 @@ public class CashierController {
@RequestBody CreatePaymentRequest request,
@RequestHeader(value = "Idempotency-Key", required = false) String idempotencyKey) {
Long applicationId = request.getApplicationId();
- BigDecimal amount = request.getPaymentAmount();
+ BigDecimal amount = resolveAmount(request);
Long userId = AuditUtil.getCurrentUserId();
String resolvedIdempotencyKey = resolveIdempotencyKey(idempotencyKey, request.getIdempotencyKey());
+ String method = resolveAlias(request.getPaymentMethod(), request.getActualPaymentMethod(), "付款方式");
+ String reference = resolveAlias(request.getReferenceNo(), request.getBankTransactionNo(), "银行流水号");
PaymentResultDto result = reimPaymentService.processPartialPayment(applicationId, amount, userId,
- request.getPaymentMethod(), request.getReferenceNo(), request.getRemark(), resolvedIdempotencyKey);
+ method, reference, requiredPaymentDate(request.getActualPaymentDate()), request.getPaymentReceipt(),
+ request.getSource(), request.getRemark(), resolvedIdempotencyKey);
return ResponseEntity.ok(ApiResponse.success(result));
}
@@ -91,6 +98,15 @@ public class CashierController {
request.getPaymentId(), AuditUtil.getCurrentUserId(), request.getRejectionCode())));
}
+ @PatchMapping("/payments/{paymentId}/receipt")
+ @PreAuthorize("@permissionChecker.hasEdit(authentication, 'finance.payment.register')")
+ public ResponseEntity> attachPaymentReceipt(
+ @PathVariable Long paymentId,
+ @javax.validation.Valid @RequestBody PaymentReceiptRequest request) {
+ return ResponseEntity.ok(ApiResponse.success(reimPaymentService.attachPaymentReceipt(
+ paymentId, request.getPaymentReceipt(), AuditUtil.getCurrentUserId())));
+ }
+
@GetMapping("/history")
@PreAuthorize("@permissionChecker.has(authentication, 'page.finance-receipt')")
public ResponseEntity>> getPaymentHistory() {
@@ -122,4 +138,28 @@ public class CashierController {
if (normalized.length() > 100) throw new BadRequestException("幂等键长度不能超过100个字符");
return normalized;
}
+
+ private BigDecimal resolveAmount(CreatePaymentRequest request) {
+ BigDecimal legacy = request.getPaymentAmount();
+ BigDecimal actual = request.getActualPaymentAmount();
+ if (legacy != null && actual != null && legacy.compareTo(actual) != 0) {
+ throw new BadRequestException("付款金额与 actualPaymentAmount 不一致");
+ }
+ return actual != null ? actual : legacy;
+ }
+
+ private String resolveAlias(String legacy, String current, String label) {
+ String left = StringUtils.hasText(legacy) ? legacy.trim() : null;
+ String right = StringUtils.hasText(current) ? current.trim() : null;
+ if (left != null && right != null && !left.equals(right)) {
+ throw new BadRequestException(label + "字段值不一致");
+ }
+ return right != null ? right : left;
+ }
+
+ private LocalDate requiredPaymentDate(LocalDate value) {
+ if (value == null) throw new BadRequestException("实际付款日期不能为空");
+ if (value.isAfter(LocalDate.now())) throw new BadRequestException("实际付款日期不能晚于今天");
+ return value;
+ }
}
diff --git a/src/main/java/com/finance/system/controller/FeishuAuthController.java b/src/main/java/com/finance/system/controller/FeishuAuthController.java
index 7e350df..fe634b7 100644
--- a/src/main/java/com/finance/system/controller/FeishuAuthController.java
+++ b/src/main/java/com/finance/system/controller/FeishuAuthController.java
@@ -364,7 +364,7 @@ public class FeishuAuthController {
}
/**
- * 根据报销单ID获取审批进度
+ * 根据付款申请ID获取审批进度
*/
@GetMapping("/approval/application/{applicationId}")
@PreAuthorize("@permissionChecker.has(authentication, 'page.applications') || @permissionChecker.has(authentication, 'page.finance-receipt')")
diff --git a/src/main/java/com/finance/system/controller/MetadataController.java b/src/main/java/com/finance/system/controller/MetadataController.java
index ed33246..190aef4 100644
--- a/src/main/java/com/finance/system/controller/MetadataController.java
+++ b/src/main/java/com/finance/system/controller/MetadataController.java
@@ -24,18 +24,19 @@ public class MetadataController {
private final PayeeAccountService payeeAccountService;
/**
- * 获取费用类型列表
+ * 获取付款情形列表(保留旧接口路径兼容)
*/
- @GetMapping("/expense-types")
+ @GetMapping({"/payment-scenarios", "/expense-types"})
@PreAuthorize("@permissionChecker.has(authentication, 'page.expense-types') || @permissionChecker.has(authentication, 'page.application-create') || @permissionChecker.has(authentication, 'page.application-edit')")
public ResponseEntity>>> getExpenseTypes() {
List