定时任务失效信用额度,临时额度
This commit is contained in:
+2
-1
@@ -294,7 +294,8 @@ public class CustomerAccountApiImpl implements ICustomerAccountApi
|
||||
Long userId = currentUserId();
|
||||
// 计费开单准入:客户被停用(含删除)时直接拦截,与账户状态接口口径保持一致。
|
||||
// 仅占用(新增计费)校验;释放/核销等清欠动作不受限,避免客户被停用后无法平账。
|
||||
assertCustomerActive(customerId);
|
||||
//9月20 调整,客户被停用不拦截计费,继续占用信用额度,
|
||||
// assertCustomerActive(customerId);
|
||||
CustomerAccount account = lockAccountForUsage(customerId, currency, username);
|
||||
if (account == null)
|
||||
{
|
||||
|
||||
+14
-32
@@ -3,22 +3,20 @@ package com.ruoyi.customer.customermoney.task;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.ruoyi.customer.customermoney.api.ICustomerAccountApi;
|
||||
|
||||
/**
|
||||
* 客户授信(信用额度/临时额度)到期自动失效任务。
|
||||
*
|
||||
* <p>每天 01:30 扫描授信已到期(信用或临时额度>0 且失效日期早于今天)的CNY账户,
|
||||
* <p>扫描授信已到期(信用或临时额度>0 且失效日期早于今天)的CNY账户,
|
||||
* 逐户独立事务物化失效:额度清零 -> 释放角色额度池 -> 回写客户档案 -> 写 EXPIRE 额度流水。
|
||||
* 失效日当天额度仍有效,故严格按「早于今天」判断。</p>
|
||||
*
|
||||
* <p>除惰性触发(访问资金接口时即查即失效)外,本任务保证展示口径一致:
|
||||
* 客户列表可用额度是账户表现算,不经过惰性入口,需由本任务把到期状态落库。
|
||||
* 应用启动后也会执行一次,避免停机期间错过调度。</p>
|
||||
* <p>本任务纳入 RuoYi 定时任务菜单(Quartz / sys_job)统一管理:
|
||||
* 调用目标为 {@code customerCreditTask.expireCredits()},cron、启停均在
|
||||
* 「系统监控 - 定时任务」中配置,不再使用 @Scheduled 硬编码。
|
||||
* 除定时调度外,资金接口访问时仍有惰性失效(即查即失效)兜底。</p>
|
||||
*
|
||||
* <p>到期不影响已用额度:已确认账单形成的授信占用仍然有效,客户回款核销后
|
||||
* used_credit 自然下降;可用额度可能短暂为负,新计费开单会被额度校验拦截。</p>
|
||||
@@ -26,37 +24,21 @@ import com.ruoyi.customer.customermoney.api.ICustomerAccountApi;
|
||||
* @author ruoyi
|
||||
* @date 2026-09-17
|
||||
*/
|
||||
@Component
|
||||
public class TempCreditExpireTask implements ApplicationRunner
|
||||
@Component("customerCreditTask")
|
||||
public class TempCreditExpireTask
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(TempCreditExpireTask.class);
|
||||
|
||||
@Autowired
|
||||
private ICustomerAccountApi customerAccountApi;
|
||||
|
||||
/** 每天 01:30 执行(cron: 秒 分 时 日 月 周) */
|
||||
@Scheduled(cron = "0 30 1 * * ?")
|
||||
public void scheduled()
|
||||
/**
|
||||
* 授信到期失效(sys_job 调用目标:customerCreditTask.expireCredits())。
|
||||
* 异常直接抛出,由 Quartz 框架记录任务执行失败日志。
|
||||
*/
|
||||
public void expireCredits()
|
||||
{
|
||||
runExpire();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args)
|
||||
{
|
||||
runExpire();
|
||||
}
|
||||
|
||||
private void runExpire()
|
||||
{
|
||||
try
|
||||
{
|
||||
int count = customerAccountApi.expireAllDueCredits();
|
||||
log.info("客户授信到期失效任务执行完成,失效账户数={}", count);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("客户授信到期失效任务执行异常", e);
|
||||
}
|
||||
int count = customerAccountApi.expireAllDueCredits();
|
||||
log.info("客户授信到期失效任务执行完成,失效账户数={}", count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
-- =============================================================
|
||||
-- 客户授信到期失效 - 纳入 RuoYi 定时任务菜单(Quartz / sys_job)
|
||||
-- 调用目标:customerCreditTask.expireCredits()
|
||||
-- cron:每天 01:30(失效日当天仍有效,严格按「早于今天」判断)
|
||||
-- 幂等:已存在同名调用目标则跳过
|
||||
-- =============================================================
|
||||
INSERT INTO sys_job
|
||||
(job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark)
|
||||
SELECT '客户授信到期失效', 'DEFAULT', 'customerCreditTask.expireCredits()',
|
||||
'0 30 1 * * ?', '3', '1', '0', 'admin', NOW(),
|
||||
'每天01:30扫描已到期的信用/临时额度并物化失效(额度清零、释放额度池、写EXPIRE流水);失效日当天仍有效'
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM sys_job WHERE invoke_target = 'customerCreditTask.expireCredits()'
|
||||
);
|
||||
Reference in New Issue
Block a user