|
@@ -249,48 +249,7 @@ public class QuotaService {
|
|
|
afterTotal = beforeTotal.add(diff).max(BigDecimal.ZERO);
|
|
afterTotal = beforeTotal.add(diff).max(BigDecimal.ZERO);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 5. 调支付宝 alipay.ebpp.invoice.expensecontrol.quota.modify (ADD/DEDUCT)
|
|
|
|
|
- // quota_id 取自请求体(与 Python 一致),非本地 UUID
|
|
|
|
|
- String alipayQuotaId = dto.getQuotaId();
|
|
|
|
|
- if (diff.compareTo(BigDecimal.ZERO) != 0 && alipayQuotaId != null && !alipayQuotaId.isBlank()) {
|
|
|
|
|
- try {
|
|
|
|
|
- AlipayEbppInvoiceExpensecontrolQuotaModifyModel model =
|
|
|
|
|
- new AlipayEbppInvoiceExpensecontrolQuotaModifyModel();
|
|
|
|
|
- model.setQuotaId(alipayQuotaId);
|
|
|
|
|
- model.setAction(diff.compareTo(BigDecimal.ZERO) > 0 ? "ADD" : "DEDUCT");
|
|
|
|
|
- model.setOuterSourceId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
|
- model.setEnterpriseId(
|
|
|
|
|
- dto.getEnterpriseId() != null ? dto.getEnterpriseId() : entity.getEnterpriseId());
|
|
|
|
|
- // 元 → 分(取绝对值)
|
|
|
|
|
- model.setAmount(String.valueOf(diff.abs().multiply(new BigDecimal("100"))
|
|
|
|
|
- .setScale(0, RoundingMode.DOWN).longValue()));
|
|
|
|
|
-
|
|
|
|
|
- AlipayEbppInvoiceExpensecontrolQuotaModifyRequest request =
|
|
|
|
|
- new AlipayEbppInvoiceExpensecontrolQuotaModifyRequest();
|
|
|
|
|
- request.setBizModel(model);
|
|
|
|
|
-
|
|
|
|
|
- AlipayEbppInvoiceExpensecontrolQuotaModifyResponse response =
|
|
|
|
|
- alipayClientFactory.getClient(model.getEnterpriseId()).execute(request);
|
|
|
|
|
-
|
|
|
|
|
- if (!response.isSuccess()) {
|
|
|
|
|
- String subMsg = response.getSubMsg() != null ? response.getSubMsg() : response.getMsg();
|
|
|
|
|
- log.error("支付宝额度调整失败: code={}, msg={}, subCode={}, subMsg={}",
|
|
|
|
|
- response.getCode(), response.getMsg(), response.getSubCode(), response.getSubMsg());
|
|
|
|
|
- throw new BusinessException(400, "支付宝额度调整失败: " + subMsg);
|
|
|
|
|
- }
|
|
|
|
|
- log.info("支付宝额度调整成功, alipayQuotaId={}, action={}, amount={}",
|
|
|
|
|
- alipayQuotaId, model.getAction(), model.getAmount());
|
|
|
|
|
- } catch (BusinessException e) {
|
|
|
|
|
- throw e;
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("支付宝额度调整异常", e);
|
|
|
|
|
- throw new BusinessException(500, "支付宝额度调整异常: " + e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- } else if (diff.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
- log.info("本地额度调整(无支付宝quota_id,仅更新本地): localId={}, diff={}", quotaId, diff);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 6. 更新本地额度记录(同时更新 totalAmount 和 availableAmount)
|
|
|
|
|
|
|
+ // 5. 更新本地额度记录(不做手工发放,纯本地调整)(同时更新 totalAmount 和 availableAmount)
|
|
|
// MyBatis-Plus @Version 自动校验: WHERE version = #{entity.version}
|
|
// MyBatis-Plus @Version 自动校验: WHERE version = #{entity.version}
|
|
|
// 若并发冲突则抛出 MybatisPlusException,由外层 adjust() 重试
|
|
// 若并发冲突则抛出 MybatisPlusException,由外层 adjust() 重试
|
|
|
entity.setAvailableAmount(afterAvailable);
|
|
entity.setAvailableAmount(afterAvailable);
|