feat: add signed PostgreSQL release updates
This commit is contained in:
@@ -113,10 +113,11 @@ public class FinancingController {
|
||||
|
||||
public record FinancingRequest(
|
||||
String code, String lender, String financingType, Double creditLimit, Double amount,
|
||||
String currency, Double rate, String startDate, String endDate, Integer termMonths,
|
||||
String currency, BigDecimal rate, String startDate, String endDate, Integer termMonths,
|
||||
String repayMethod, String status, String companySubject, String purpose, String owner) {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@PostMapping
|
||||
public ApiResp<Financing> create(@RequestBody FinancingRequest req) {
|
||||
if (req.lender() == null || req.lender().isBlank()) {
|
||||
@@ -143,6 +144,7 @@ public class FinancingController {
|
||||
return ApiResp.ok(financingRepo.save(f));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@PatchMapping("/{id}")
|
||||
public ApiResp<Financing> update(@PathVariable Long id, @RequestBody FinancingRequest req) {
|
||||
Financing f = financingRepo.findById(id)
|
||||
@@ -165,7 +167,6 @@ public class FinancingController {
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@Transactional
|
||||
public ApiResp<Void> delete(@PathVariable Long id) {
|
||||
if (!financingRepo.existsById(id)) {
|
||||
throw new NotFoundException("financing not found: " + id);
|
||||
@@ -188,7 +189,6 @@ public class FinancingController {
|
||||
* 已有任意期次「已还」时拒绝重算,避免抹掉还款历史。
|
||||
*/
|
||||
@PostMapping("/{id}/schedule")
|
||||
@Transactional
|
||||
public ApiResp<List<RepaymentPlan>> schedule(@PathVariable Long id) {
|
||||
Financing f = financingRepo.findById(id)
|
||||
.orElseThrow(() -> new NotFoundException("financing not found: " + id));
|
||||
@@ -200,7 +200,7 @@ public class FinancingController {
|
||||
planRepo.deleteByFinancingId(id);
|
||||
|
||||
int term = f.getTermMonths() == null || f.getTermMonths() <= 0 ? 12 : f.getTermMonths();
|
||||
double annualRate = f.getRate() == null ? 0 : f.getRate();
|
||||
double annualRate = f.getRate() == null ? 0 : f.getRate().doubleValue();
|
||||
BigDecimal principalTotal = Money.nz(f.getAmount());
|
||||
String method = f.getRepayMethod() == null ? "等额本息" : f.getRepayMethod();
|
||||
LocalDate start = parseDateOrNull(f.getStartDate());
|
||||
@@ -288,7 +288,6 @@ public class FinancingController {
|
||||
* 这条联动把"融资还款"打通到结算/支付链(与需求"还款联动结算中心生成付款单"一致)。
|
||||
*/
|
||||
@PostMapping("/repayments/{planId}/pay")
|
||||
@Transactional
|
||||
public ApiResp<RepaymentPlan> payRepayment(@PathVariable Long planId) {
|
||||
RepaymentPlan plan = planRepo.findById(planId)
|
||||
.orElseThrow(() -> new NotFoundException("repayment plan not found: " + planId));
|
||||
@@ -552,7 +551,7 @@ public class FinancingController {
|
||||
rows.add(new DebtLedgerRow(f.getId(), f.getCode(), f.getLender(), f.getFinancingType(),
|
||||
f.getCompanySubject(), f.getStatus(), principal.doubleValue(),
|
||||
paid.doubleValue(), unpaid.doubleValue(),
|
||||
f.getRate() == null ? 0 : f.getRate(),
|
||||
f.getRate() == null ? 0.0 : f.getRate().doubleValue(),
|
||||
f.getEndDate() == null ? "" : f.getEndDate(),
|
||||
daysToMaturity == Long.MAX_VALUE ? -999 : daysToMaturity,
|
||||
maturityLevel));
|
||||
@@ -561,7 +560,7 @@ public class FinancingController {
|
||||
totalUnpaid = Money.add(totalUnpaid, unpaid);
|
||||
if (f.getRate() != null) {
|
||||
weightedRateSum = Money.add(weightedRateSum,
|
||||
unpaid.multiply(BigDecimal.valueOf(f.getRate())));
|
||||
unpaid.multiply(f.getRate()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,7 +589,6 @@ public class FinancingController {
|
||||
* 若余量 < 0 则拒绝提交,给出明确提示,要求先调整授信或融资金额。
|
||||
*/
|
||||
@PostMapping("/{id}/submit-approval")
|
||||
@Transactional
|
||||
public ApiResp<FormInstance> submitApproval(@PathVariable Long id,
|
||||
@RequestBody(required = false) ApprovalSubmitRequest req) {
|
||||
Financing f = financingRepo.findById(id)
|
||||
@@ -791,7 +789,7 @@ public class FinancingController {
|
||||
rateMap.put("7%以上", new long[]{0, 0, 0});
|
||||
for (Financing f : all) {
|
||||
if (List.of("已结清", "已驳回").contains(nvl(f.getStatus()))) continue;
|
||||
double r = f.getRate() == null ? 0 : f.getRate();
|
||||
double r = f.getRate() == null ? 0 : f.getRate().doubleValue();
|
||||
String bucket = r < 3 ? "3%以下" : r < 5 ? "3%-5%" : r < 7 ? "5%-7%" : "7%以上";
|
||||
long[] slot = rateMap.get(bucket);
|
||||
slot[0]++;
|
||||
@@ -807,7 +805,7 @@ public class FinancingController {
|
||||
// --- 高成本融资识别(年化利率 > benchmarkRate) ---
|
||||
List<Map<String, Object>> highCost = all.stream()
|
||||
.filter(f -> !List.of("已结清", "已驳回").contains(nvl(f.getStatus())))
|
||||
.filter(f -> f.getRate() != null && f.getRate() > benchmarkRate)
|
||||
.filter(f -> f.getRate() != null && f.getRate().doubleValue() > benchmarkRate)
|
||||
.map(f -> {
|
||||
Map<String, Object> m = new LinkedHashMap<>();
|
||||
m.put("financingId", f.getId());
|
||||
@@ -816,8 +814,9 @@ public class FinancingController {
|
||||
m.put("financingType", f.getFinancingType());
|
||||
m.put("amount", Money.nz(f.getAmount()).doubleValue());
|
||||
m.put("rate", f.getRate());
|
||||
m.put("excessBps", Math.round((f.getRate() - benchmarkRate) * 100));
|
||||
m.put("suggestion", f.getRate() - benchmarkRate > 2 ? "建议择机置换或提前还款" : "关注,可在续授信时争取降利率");
|
||||
double rateVal = f.getRate().doubleValue();
|
||||
m.put("excessBps", Math.round((rateVal - benchmarkRate) * 100));
|
||||
m.put("suggestion", rateVal - benchmarkRate > 2 ? "建议择机置换或提前还款" : "关注,可在续授信时争取降利率");
|
||||
return m;
|
||||
})
|
||||
.toList();
|
||||
@@ -928,7 +927,6 @@ public class FinancingController {
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/legal-reviews/link")
|
||||
@Transactional
|
||||
public ApiResp<LegalRiskEvent> linkLegalReview(@PathVariable Long id,
|
||||
@RequestBody LinkLegalReviewRequest req) {
|
||||
if (!financingRepo.existsById(id)) {
|
||||
@@ -957,7 +955,6 @@ public class FinancingController {
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/push-cost-alloc")
|
||||
@Transactional
|
||||
public ApiResp<PmtCostAllocRule> pushCostAlloc(@PathVariable Long id,
|
||||
@RequestBody(required = false) PushCostAllocRequest req) {
|
||||
Financing f = financingRepo.findById(id)
|
||||
@@ -982,7 +979,7 @@ public class FinancingController {
|
||||
.reduce(BigDecimal.ZERO, Money::add);
|
||||
// 若无还款计划,按月息估算(本金 × 年化利率 / 12)
|
||||
if (periodInterest.signum() == 0) {
|
||||
double annualRate = f.getRate() == null ? 0.0 : f.getRate();
|
||||
double annualRate = f.getRate() == null ? 0.0 : f.getRate().doubleValue();
|
||||
periodInterest = Money.of(Money.nz(f.getAmount()).doubleValue() * annualRate / 100.0 / 12.0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user