|
@@ -2,7 +2,9 @@ package com.payment.platform.module.payment.notification.handler;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.payment.platform.module.payment.account.entity.AccountEntity;
|
|
|
import com.payment.platform.module.payment.account.entity.TransferEntity;
|
|
import com.payment.platform.module.payment.account.entity.TransferEntity;
|
|
|
|
|
+import com.payment.platform.module.payment.account.mapper.AccountMapper;
|
|
|
import com.payment.platform.module.payment.account.mapper.TransferMapper;
|
|
import com.payment.platform.module.payment.account.mapper.TransferMapper;
|
|
|
import com.payment.platform.module.payment.enterprise.entity.EnterpriseEntity;
|
|
import com.payment.platform.module.payment.enterprise.entity.EnterpriseEntity;
|
|
|
import com.payment.platform.module.payment.enterprise.mapper.EnterpriseMapper;
|
|
import com.payment.platform.module.payment.enterprise.mapper.EnterpriseMapper;
|
|
@@ -28,6 +30,7 @@ import java.util.Map;
|
|
|
public class AccountHandler extends BaseNotifyHandler {
|
|
public class AccountHandler extends BaseNotifyHandler {
|
|
|
|
|
|
|
|
private final TransferMapper transferMapper;
|
|
private final TransferMapper transferMapper;
|
|
|
|
|
+ private final AccountMapper accountMapper;
|
|
|
private final EnterpriseMapper enterpriseMapper;
|
|
private final EnterpriseMapper enterpriseMapper;
|
|
|
private final PointsService pointsService;
|
|
private final PointsService pointsService;
|
|
|
|
|
|
|
@@ -37,7 +40,8 @@ public class AccountHandler extends BaseNotifyHandler {
|
|
|
"alipay.commerce.ec.trans.account.transfer",
|
|
"alipay.commerce.ec.trans.account.transfer",
|
|
|
"alipay.commerce.ec.trans.account.deposit",
|
|
"alipay.commerce.ec.trans.account.deposit",
|
|
|
"alipay.commerce.ec.fund.change.notify",
|
|
"alipay.commerce.ec.fund.change.notify",
|
|
|
- "alipay.commerce.ec.trans.authorize.notify"
|
|
|
|
|
|
|
+ "alipay.commerce.ec.trans.authorize.notify",
|
|
|
|
|
+ "alipay.user.agreement.page.sign" // 安全发签约结果通知
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -46,7 +50,9 @@ public class AccountHandler extends BaseNotifyHandler {
|
|
|
log.info("处理资金变动通知: method={}", msgMethod);
|
|
log.info("处理资金变动通知: method={}", msgMethod);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- if ("alipay.commerce.ec.fund.change.notify".equals(msgMethod)) {
|
|
|
|
|
|
|
+ if ("alipay.user.agreement.page.sign".equals(msgMethod)) {
|
|
|
|
|
+ handleAgreementSign(params);
|
|
|
|
|
+ } else if ("alipay.commerce.ec.fund.change.notify".equals(msgMethod)) {
|
|
|
handleFundChange(params);
|
|
handleFundChange(params);
|
|
|
} else if ("alipay.commerce.ec.trans.authorize.notify".equals(msgMethod)) {
|
|
} else if ("alipay.commerce.ec.trans.authorize.notify".equals(msgMethod)) {
|
|
|
handleTransAuthorize(params);
|
|
handleTransAuthorize(params);
|
|
@@ -58,6 +64,33 @@ public class AccountHandler extends BaseNotifyHandler {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 签约结果通知 — 安全发 alipay.user.agreement.page.sign 异步通知
|
|
|
|
|
+ * 将 agreement_no 写入 AccountEntity,后续创建记账本时自动使用
|
|
|
|
|
+ */
|
|
|
|
|
+ private void handleAgreementSign(Map<String, String> params) {
|
|
|
|
|
+ String agreementNo = params.get("agreement_no");
|
|
|
|
|
+ String externalAgreementNo = params.get("external_agreement_no");
|
|
|
|
|
+ String status = params.get("status");
|
|
|
|
|
+ log.info("签约结果通知: agreementNo={}, externalAgreementNo={}, status={}", agreementNo, externalAgreementNo, status);
|
|
|
|
|
+
|
|
|
|
|
+ if (agreementNo == null || agreementNo.isBlank() || externalAgreementNo == null) return;
|
|
|
|
|
+ if (!"NORMAL".equals(status)) return;
|
|
|
|
|
+
|
|
|
|
|
+ String enterpriseId = externalAgreementNo.replace("_agreement", "");
|
|
|
|
|
+ var accounts = accountMapper.selectList(
|
|
|
|
|
+ new LambdaQueryWrapper<AccountEntity>()
|
|
|
|
|
+ .eq(AccountEntity::getEnterpriseId, enterpriseId));
|
|
|
|
|
+ for (AccountEntity acc : accounts) {
|
|
|
|
|
+ if (acc.getAgreementNo() == null || acc.getAgreementNo().isBlank()) {
|
|
|
|
|
+ acc.setAgreementNo(agreementNo);
|
|
|
|
|
+ acc.setSignStatus("SIGNED");
|
|
|
|
|
+ accountMapper.updateById(acc);
|
|
|
|
|
+ log.info("签约结果写入成功: enterpriseId={}, agreementNo={}", enterpriseId, agreementNo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 资金变更通知 -- 对应 Python _handle_fund_change
|
|
* 资金变更通知 -- 对应 Python _handle_fund_change
|
|
|
*
|
|
*
|