Pause salary settlement and wallet outflows

This commit is contained in:
hy001 2026-05-20 01:29:31 +08:00
parent ad73326eae
commit 35ceb5d80f
10 changed files with 196 additions and 92 deletions

View File

@ -60,9 +60,11 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@RocketMqMessageListener(groupId = TeamBillSettleSink.INPUT, tag = TeamBillSettleSink.TAG)
@RequiredArgsConstructor
public class TeamBillSettleListener implements MessageListener {
private final String tag = "团队账单";
public class TeamBillSettleListener implements MessageListener {
private static final boolean SALARY_SETTLEMENT_PAUSED = true;
private final String tag = "团队账单";
private final TeamProfileService teamProfileService;
private final MessageEventProcess messageEventProcess;
private final TeamBillCycleService teamBillCycleService;
@ -76,9 +78,14 @@ public class TeamBillSettleListener implements MessageListener {
private final SalaryDiamondRunningWaterClient salaryDiamondRunningWaterClient;
private final BillDiamondBalanceService billDiamondBalanceService;
@Override
public Action consume(ConsumerMessage message) {
return messageEventProcess.consume(
@Override
public Action consume(ConsumerMessage message) {
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("team_bill_settle_message skipped: salary settlement is temporarily paused");
return Action.SUCCESS;
}
return messageEventProcess.consume(
MessageEventProcessDescribe.builder()
.logTag(tag)
.consumeMsgTimeoutMinute(30)

View File

@ -77,9 +77,11 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@RocketMqMessageListener(groupId = TeamSalaryPaymentSink.INPUT, tag = TeamSalaryPaymentSink.TAG)
@RequiredArgsConstructor
public class TeamSalaryPaymentListener implements MessageListener {
private final PropsSendCommon propsSendCommon;
public class TeamSalaryPaymentListener implements MessageListener {
private static final boolean SALARY_SETTLEMENT_PAUSED = true;
private final PropsSendCommon propsSendCommon;
private final TeamMemberService teamMemberService;
private final TeamProfileService teamProfileService;
private final MessageEventProcess messageEventProcess;
@ -95,9 +97,14 @@ public class TeamSalaryPaymentListener implements MessageListener {
private final BillDiamondBalanceService billDiamondBalanceService;
private final BillDiamondBalanceDetailsService billDiamondBalanceDetailsService;
@Override
public Action consume(ConsumerMessage message) {
return messageEventProcess.consume(
@Override
public Action consume(ConsumerMessage message) {
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("team_salary_payment_message skipped: salary settlement is temporarily paused");
return Action.SUCCESS;
}
return messageEventProcess.consume(
MessageEventProcessDescribe.builder()
.logTag("满足政策的团队工资实时发送")
.consumeMsgTimeoutMinute(30)

View File

@ -18,9 +18,11 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@RequiredArgsConstructor
public class AdminSalarySettlementTask {
private final AdminSalarySettlementService adminSalarySettlementService;
public class AdminSalarySettlementTask {
private static final boolean SALARY_SETTLEMENT_PAUSED = true;
private final AdminSalarySettlementService adminSalarySettlementService;
/**
* 每月1号2点执行上月整月结算.
@ -28,7 +30,12 @@ public class AdminSalarySettlementTask {
@Scheduled(cron = "0 0 2 1 * ?", zone = "Asia/Riyadh")
@TaskCacheLock(key = "ADMIN_SALARY_SETTLEMENT", expireSecond = 86400)
public void processAdminSalarySettlement() {
long startTime = System.currentTimeMillis();
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("admin_salary_settlement skipped: salary settlement is temporarily paused");
return;
}
long startTime = System.currentTimeMillis();
log.warn("========== 管理员工资结算定时任务开始 ==========");
try {
@ -61,8 +68,13 @@ public class AdminSalarySettlementTask {
/**
* 测试方法手动触发.
*/
public void processAdminSalarySettlementTest(Integer billBelong) {
String billTitle = TeamBillCycleUtils.parseBillBelongToDateRangeStr(billBelong);
public void processAdminSalarySettlementTest(Integer billBelong) {
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("admin_salary_settlement_test skipped: salary settlement is temporarily paused");
return;
}
String billTitle = TeamBillCycleUtils.parseBillBelongToDateRangeStr(billBelong);
adminSalarySettlementService.processAllAdminSettlement(billBelong, billTitle);
}
}

View File

@ -18,9 +18,11 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@RequiredArgsConstructor
public class BdLeaderSalarySettlementTask {
private final BdLeaderSalarySettlementService bdLeaderSalarySettlementService;
public class BdLeaderSalarySettlementTask {
private static final boolean SALARY_SETTLEMENT_PAUSED = true;
private final BdLeaderSalarySettlementService bdLeaderSalarySettlementService;
/**
* 每月1号1点执行上月整月结算.
@ -28,7 +30,12 @@ public class BdLeaderSalarySettlementTask {
@Scheduled(cron = "0 0 1 1 * ?", zone = "Asia/Riyadh")
@TaskCacheLock(key = "BD_LEADER_SALARY_SETTLEMENT", expireSecond = 86400)
public void processBdLeaderSalarySettlement() {
long startTime = System.currentTimeMillis();
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("bd_leader_salary_settlement skipped: salary settlement is temporarily paused");
return;
}
long startTime = System.currentTimeMillis();
log.warn("========== BD Leader工资结算定时任务开始 ==========");
try {
@ -61,8 +68,13 @@ public class BdLeaderSalarySettlementTask {
/**
* 测试方法手动触发.
*/
public void processBdLeaderSalarySettlementTest(Integer billBelong) {
String billTitle = TeamBillCycleUtils.parseBillBelongToDateRangeStr(billBelong);
public void processBdLeaderSalarySettlementTest(Integer billBelong) {
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("bd_leader_salary_settlement_test skipped: salary settlement is temporarily paused");
return;
}
String billTitle = TeamBillCycleUtils.parseBillBelongToDateRangeStr(billBelong);
bdLeaderSalarySettlementService.processAllBdLeaderSettlement(billBelong, billTitle);
}
}

View File

@ -18,9 +18,11 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@RequiredArgsConstructor
public class BdSalarySettlementTask {
private final BdSalarySettlementService bdSalarySettlementService;
public class BdSalarySettlementTask {
private static final boolean SALARY_SETTLEMENT_PAUSED = true;
private final BdSalarySettlementService bdSalarySettlementService;
/**
* 每月1号0点30分执行上月整月结算.
@ -28,7 +30,12 @@ public class BdSalarySettlementTask {
@Scheduled(cron = "0 30 0 1 * ?", zone = "Asia/Riyadh")
@TaskCacheLock(key = "BD_SALARY_SETTLEMENT", expireSecond = 86400)
public void processBdSalarySettlement() {
long startTime = System.currentTimeMillis();
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("bd_salary_settlement skipped: salary settlement is temporarily paused");
return;
}
long startTime = System.currentTimeMillis();
log.warn("========== BD工资结算定时任务开始 ==========");
try {
@ -61,8 +68,13 @@ public class BdSalarySettlementTask {
/**
* 测试方法手动触发.
*/
public void processBdSalarySettlementTest(Integer billBelong) {
String billTitle = TeamBillCycleUtils.parseBillBelongToDateRangeStr(billBelong);
public void processBdSalarySettlementTest(Integer billBelong) {
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("bd_salary_settlement_test skipped: salary settlement is temporarily paused");
return;
}
String billTitle = TeamBillCycleUtils.parseBillBelongToDateRangeStr(billBelong);
bdSalarySettlementService.processAllBdSettlement(billBelong, billTitle);
}
}

View File

@ -29,9 +29,11 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@AllArgsConstructor
public class TeamBillTask {
private final TeamSalaryMqMessage otherMqMessage;
public class TeamBillTask {
private static final boolean SALARY_SETTLEMENT_PAUSED = true;
private final TeamSalaryMqMessage otherMqMessage;
private final TeamProfileService teamProfileService;
private final TeamBillCycleService teamBillCycleService;
private final GiftGiveRunningWaterService giftGiveRunningWaterService;
@ -55,8 +57,13 @@ public class TeamBillTask {
}
private void processTeamBill() {
log.warn("开始执行账单处理:{},{}", ZonedDateTimeUtils.nowAsiaRiyadhToInt(), LocalDateTime.now());
private void processTeamBill() {
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("process_team_bill skipped: salary settlement is temporarily paused");
return;
}
log.warn("开始执行账单处理:{},{}", ZonedDateTimeUtils.nowAsiaRiyadhToInt(), LocalDateTime.now());
// 出单
teamBillCycleService.billStatusPayOut();
@ -65,10 +72,15 @@ public class TeamBillTask {
log.warn("结束账单处理");
}
public void processTeamBillRetry() {
// 创建本月账单发出结算信号
consumeProcessPayOutBill();
}
public void processTeamBillRetry() {
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("process_team_bill_retry skipped: salary settlement is temporarily paused");
return;
}
// 创建本月账单发出结算信号
consumeProcessPayOutBill();
}
/**
* 创建本月账单发出结算信号.

View File

@ -24,10 +24,12 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@AllArgsConstructor
public class TeamSalaryPaymentTask {
private final TeamProfileService teamProfileService;
private final TeamSalaryMqMessage teamSalaryMqMessage;
public class TeamSalaryPaymentTask {
private static final boolean SALARY_SETTLEMENT_PAUSED = true;
private final TeamProfileService teamProfileService;
private final TeamSalaryMqMessage teamSalaryMqMessage;
/**
* 每天凌晨0点过30秒执行一次处理团队工资结算.
@ -35,6 +37,11 @@ public class TeamSalaryPaymentTask {
@Scheduled(cron = "30 1 0 * * ?", zone = "Asia/Riyadh")
@TaskCacheLock(key = "TEAM_SALARY_PAYMENT_TASK", expireSecond = 10800)
public void teamSalaryPaymentTask() {
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("team_salary_payment_task skipped: salary settlement is temporarily paused");
return;
}
long startTime = System.currentTimeMillis();
log.warn("exec team_salary_payment_task start");
@ -66,9 +73,13 @@ public class TeamSalaryPaymentTask {
log.warn("exec team_salary_payment_task end with {}",System.currentTimeMillis()-startTime);
}
public void teamSalaryPaymentTaskTest() {
log.warn("支付团队工资 start时间:{}", TimestampUtils.now());
public void teamSalaryPaymentTaskTest() {
if (SALARY_SETTLEMENT_PAUSED) {
log.warn("team_salary_payment_task_test skipped: salary settlement is temporarily paused");
return;
}
log.warn("支付团队工资 start时间:{}", TimestampUtils.now());
// 是否本月一号
Boolean thisMonthFirstDay = Objects.equals(ZonedDateTimeUtils.nowAsiaRiyadhToInt(),

View File

@ -1,6 +1,8 @@
package com.red.circle.wallet.app.service;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.wallet.app.command.salary.SalaryExchangeGoldCmdExe;
import com.red.circle.wallet.app.command.salary.SalaryIssueCmdExe;
import com.red.circle.wallet.app.command.salary.SalaryTransferGoldCmdExe;
@ -22,8 +24,10 @@ import java.util.Objects;
*/
@Service
@RequiredArgsConstructor
public class SalaryAccountServiceImpl implements SalaryAccountService {
public class SalaryAccountServiceImpl implements SalaryAccountService {
private static final boolean SALARY_WALLET_OUT_PAUSED = true;
private final SalaryAccountBalanceQryExe salaryAccountBalanceQryExe;
private final SalaryRunningWaterQryExe salaryRunningWaterQryExe;
private final SalaryIssueCmdExe salaryIssueCmdExe;
@ -52,15 +56,21 @@ public class SalaryAccountServiceImpl implements SalaryAccountService {
return salaryRunningWaterQryExe.execute(cmd);
}
@Override
public UserBankWithdrawResultCO transferGold(SalaryWithdrawCmd cmd) {
return salaryTransferGoldCmdExe.execute(cmd);
}
@Override
public UserBankExchangeGoldResultCO exchangeGold(SalaryWithdrawCmd cmd) {
return salaryExchangeGoldCmdExe.execute(cmd);
}
@Override
public UserBankWithdrawResultCO transferGold(SalaryWithdrawCmd cmd) {
rejectPausedSalaryWalletOut();
return salaryTransferGoldCmdExe.execute(cmd);
}
@Override
public UserBankExchangeGoldResultCO exchangeGold(SalaryWithdrawCmd cmd) {
rejectPausedSalaryWalletOut();
return salaryExchangeGoldCmdExe.execute(cmd);
}
private void rejectPausedSalaryWalletOut() {
ResponseAssert.isTrue(CommonErrorCode.SYSTEM_IS_DOWN, !SALARY_WALLET_OUT_PAUSED);
}
@Override
public BigDecimal getTotalIncome(Long userId, String salaryType, String salaryEvent, String startTime, String endTime) {

View File

@ -1,9 +1,11 @@
package com.red.circle.wallet.app.service;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
import com.red.circle.framework.core.dto.CommonCommand;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.dto.CommonCommand;
import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.wallet.app.command.bank.UserBankExchangeGoldCmdExe;
import com.red.circle.wallet.app.command.bank.query.UserBankCheckExchangeGoldQryExe;
import com.red.circle.wallet.app.command.bank.query.UserBankCheckTransferQryExe;
@ -29,8 +31,10 @@ import java.util.List;
*/
@Service
@RequiredArgsConstructor
public class SalaryDiamondServiceImpl implements SalaryDiamondService {
public class SalaryDiamondServiceImpl implements SalaryDiamondService {
private static final boolean SALARY_EXCHANGE_PAUSED = true;
private final UserBillAgentSalaryDiamondCheckExchangeGoldQryExe userBillAgentSalaryDiamondCheckExchangeGoldQryExe;
private final UserSalaryDiamondBalanceQryExe userSalaryDiamondBalanceQryExe;
private final UserSalaryDiamondRunningWaterQryExe userSalaryDiamondRunningWaterQryExe;
@ -85,25 +89,33 @@ public class SalaryDiamondServiceImpl implements SalaryDiamondService {
return userBankCheckTransferQryExe.executeDiamond(cmd);
}
@Override
public UserBankExchangeGoldResultCO exchangeGold(UserBankExchangeGoldCmd cmd) {
return userBankExchangeGoldCmdExe.executeDiamond(cmd);
}
@Override
public UserBankExchangeGoldResultCO exchangeGoldYolo(UserBankExchangeGoldCmd cmd) {
return userBankExchangeGoldCmdExe.exchangeGoldYolo(cmd);
}
@Override
public UserBankExchangeGoldResultCO agentBillExchangeGold(UserBillExchangeGoldCmd cmd) {
return userBankExchangeGoldCmdExe.agentBillExchangeGold(cmd);
}
@Override
public UserBankExchangeGoldResultCO memberWorkExchangeGold(UserBillExchangeGoldCmd cmd) {
return userBankExchangeGoldCmdExe.memberWorkExchangeGold(cmd);
}
@Override
public UserBankExchangeGoldResultCO exchangeGold(UserBankExchangeGoldCmd cmd) {
rejectPausedSalaryExchange();
return userBankExchangeGoldCmdExe.executeDiamond(cmd);
}
@Override
public UserBankExchangeGoldResultCO exchangeGoldYolo(UserBankExchangeGoldCmd cmd) {
rejectPausedSalaryExchange();
return userBankExchangeGoldCmdExe.exchangeGoldYolo(cmd);
}
@Override
public UserBankExchangeGoldResultCO agentBillExchangeGold(UserBillExchangeGoldCmd cmd) {
rejectPausedSalaryExchange();
return userBankExchangeGoldCmdExe.agentBillExchangeGold(cmd);
}
@Override
public UserBankExchangeGoldResultCO memberWorkExchangeGold(UserBillExchangeGoldCmd cmd) {
rejectPausedSalaryExchange();
return userBankExchangeGoldCmdExe.memberWorkExchangeGold(cmd);
}
private void rejectPausedSalaryExchange() {
ResponseAssert.isTrue(CommonErrorCode.SYSTEM_IS_DOWN, !SALARY_EXCHANGE_PAUSED);
}
@Override
public UserBankWithdrawResultCO withdraw(UserBankWithdrawCmd cmd) {

View File

@ -1,8 +1,10 @@
package com.red.circle.wallet.app.service;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.core.dto.CommonCommand;
import com.red.circle.other.inner.model.dto.user.SysExchangeGoldTipDTO;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.dto.CommonCommand;
import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.other.inner.model.dto.user.SysExchangeGoldTipDTO;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.wallet.app.command.bank.*;
import com.red.circle.wallet.app.command.bank.query.UserBankCheckExchangeGoldQryExe;
@ -37,8 +39,10 @@ import org.springframework.stereotype.Service;
*/
@Service
@RequiredArgsConstructor
public class UserBankServiceImpl implements UserBankService {
public class UserBankServiceImpl implements UserBankService {
private static final boolean USER_TO_COIN_SELLER_TRANSFER_PAUSED = true;
private final UserBankWaterQryExe userBankWaterQryExe;
private final UserBankBalanceQryExe userBankBalanceQryExe;
private final UserBankWithdrawCmdExe userBankWithdrawCmdExe;
@ -86,10 +90,15 @@ public class UserBankServiceImpl implements UserBankService {
return userBankWithdrawTransferCmdExe.execute(cmd);
}
@Override
public UserBankWithdrawResultCO transferGold(UserBankWithdrawTransferCmd cmd) {
return userBankTransferGoldCmdExe.execute(cmd);
}
@Override
public UserBankWithdrawResultCO transferGold(UserBankWithdrawTransferCmd cmd) {
rejectPausedUserToCoinSellerTransfer();
return userBankTransferGoldCmdExe.execute(cmd);
}
private void rejectPausedUserToCoinSellerTransfer() {
ResponseAssert.isTrue(CommonErrorCode.SYSTEM_IS_DOWN, !USER_TO_COIN_SELLER_TRANSFER_PAUSED);
}
@Override
public UserBankWithdrawResultCO diamondTransfer(UserBankWithdrawTransferCmd cmd) {