|
@@ -740,10 +740,9 @@ public class InstitutionService {
|
|
|
existing.getInstitutionId(), dto.getEffective(), newQuotaStatus, updated);
|
|
existing.getInstitutionId(), dto.getEffective(), newQuotaStatus, updated);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 调用支付宝 alipay.ebpp.invoice.institution.modify 同步
|
|
|
|
|
|
|
+ // 调用支付宝 alipay.ebpp.invoice.institution.modify 同步(基础字段)
|
|
|
try {
|
|
try {
|
|
|
- com.payment.platform.core.alipay.ExtendedInstitutionModifyModel modifyModel =
|
|
|
|
|
- new com.payment.platform.core.alipay.ExtendedInstitutionModifyModel();
|
|
|
|
|
|
|
+ AlipayEbppInvoiceInstitutionModifyModel modifyModel = new AlipayEbppInvoiceInstitutionModifyModel();
|
|
|
modifyModel.setInstitutionId(existing.getInstitutionId());
|
|
modifyModel.setInstitutionId(existing.getInstitutionId());
|
|
|
modifyModel.setEnterpriseId(existing.getEnterpriseId());
|
|
modifyModel.setEnterpriseId(existing.getEnterpriseId());
|
|
|
if (StrUtil.isNotBlank(existing.getInstitutionName())) {
|
|
if (StrUtil.isNotBlank(existing.getInstitutionName())) {
|
|
@@ -765,61 +764,6 @@ public class InstitutionService {
|
|
|
modifyModel.setConsultMode(existing.getConsultMode());
|
|
modifyModel.setConsultMode(existing.getConsultMode());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 金额/限额变更 → 构建 modify_standard_detail_info 同步支付宝
|
|
|
|
|
- boolean amountChanged = dto.getAmount() != null
|
|
|
|
|
- && !dto.getAmount().equals(existing.getAmount());
|
|
|
|
|
- boolean limitChanged = dto.getSingleLimit() != null
|
|
|
|
|
- && !dto.getSingleLimit().equals(existing.getSingleLimit());
|
|
|
|
|
- if ((amountChanged || limitChanged) && StrUtil.isNotBlank(existing.getEnterpriseId())) {
|
|
|
|
|
- try {
|
|
|
|
|
- // 查询支付宝制度详情获取已有 standard_id
|
|
|
|
|
- var detailModel = new AlipayEbppInvoiceInstitutionDetailinfoQueryModel();
|
|
|
|
|
- detailModel.setInstitutionId(existing.getInstitutionId());
|
|
|
|
|
- detailModel.setEnterpriseId(existing.getEnterpriseId());
|
|
|
|
|
- var detailReq = new AlipayEbppInvoiceInstitutionDetailinfoQueryRequest();
|
|
|
|
|
- detailReq.setBizModel(detailModel);
|
|
|
|
|
- var detailResp = alipayClientFactory.getClient(existing.getEnterpriseId()).execute(detailReq);
|
|
|
|
|
- if (detailResp.isSuccess() && detailResp.getStandardInfoDetailList() != null) {
|
|
|
|
|
- String periodFactor = mapPeriodTypeToFactor(existing.getPeriodType());
|
|
|
|
|
- java.util.List<com.payment.platform.core.alipay.ExtendedInstitutionModifyModel.ModifyStandardItem>
|
|
|
|
|
- modifyList = new java.util.ArrayList<>();
|
|
|
|
|
- for (com.alipay.api.domain.StandardInfo info : detailResp.getStandardInfoDetailList()) {
|
|
|
|
|
- String stdId = info.getStandardId();
|
|
|
|
|
- if (stdId == null) continue;
|
|
|
|
|
- java.util.List<com.payment.platform.core.alipay.ExtendedInstitutionModifyModel.ModifyCondition>
|
|
|
|
|
- condList = new java.util.ArrayList<>();
|
|
|
|
|
- if (amountChanged && periodFactor != null) {
|
|
|
|
|
- var c = new com.payment.platform.core.alipay.ExtendedInstitutionModifyModel.ModifyCondition();
|
|
|
|
|
- c.setRuleFactor(periodFactor);
|
|
|
|
|
- c.setRuleValue(dto.getAmount().toPlainString());
|
|
|
|
|
- condList.add(c);
|
|
|
|
|
- }
|
|
|
|
|
- if (limitChanged) {
|
|
|
|
|
- var c = new com.payment.platform.core.alipay.ExtendedInstitutionModifyModel.ModifyCondition();
|
|
|
|
|
- c.setRuleFactor("QUOTA_TOTAL");
|
|
|
|
|
- c.setRuleValue(dto.getSingleLimit().toPlainString());
|
|
|
|
|
- condList.add(c);
|
|
|
|
|
- }
|
|
|
|
|
- if (!condList.isEmpty()) {
|
|
|
|
|
- var item = new com.payment.platform.core.alipay.ExtendedInstitutionModifyModel.ModifyStandardItem();
|
|
|
|
|
- item.setStandardId(stdId);
|
|
|
|
|
- item.setModifyConditionList(condList);
|
|
|
|
|
- modifyList.add(item);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (!modifyList.isEmpty()) {
|
|
|
|
|
- var detailInfo = new com.payment.platform.core.alipay.ExtendedInstitutionModifyModel.ModifyStandardDetailInfo();
|
|
|
|
|
- detailInfo.setModifyStandardList(modifyList);
|
|
|
|
|
- modifyModel.setModifyStandardDetailInfo(detailInfo);
|
|
|
|
|
- log.info("已构建 modify_standard_detail_info: amountChanged={}, limitChanged={}",
|
|
|
|
|
- amountChanged, limitChanged);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.warn("构建 modify_standard_detail_info 失败(不影响基础修改): {}", e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
AlipayEbppInvoiceInstitutionModifyRequest modifyRequest =
|
|
AlipayEbppInvoiceInstitutionModifyRequest modifyRequest =
|
|
|
new AlipayEbppInvoiceInstitutionModifyRequest();
|
|
new AlipayEbppInvoiceInstitutionModifyRequest();
|
|
|
modifyRequest.setBizModel(modifyModel);
|
|
modifyRequest.setBizModel(modifyModel);
|
|
@@ -833,6 +777,121 @@ public class InstitutionService {
|
|
|
log.warn("支付宝 institution.modify 异常: {}", e.getMessage());
|
|
log.warn("支付宝 institution.modify 异常: {}", e.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 金额/限额变更 → 第二次请求同步 modify_standard_detail_info
|
|
|
|
|
+ boolean amountChanged = dto.getAmount() != null
|
|
|
|
|
+ && (existing.getAmount() == null || dto.getAmount().compareTo(existing.getAmount()) != 0);
|
|
|
|
|
+ boolean limitChanged = dto.getSingleLimit() != null
|
|
|
|
|
+ && (existing.getSingleLimit() == null || dto.getSingleLimit().compareTo(existing.getSingleLimit()) != 0);
|
|
|
|
|
+ if ((amountChanged || limitChanged) && StrUtil.isNotBlank(existing.getEnterpriseId())) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 查询支付宝制度详情获取已有 standard_id
|
|
|
|
|
+ var detailModel = new AlipayEbppInvoiceInstitutionDetailinfoQueryModel();
|
|
|
|
|
+ detailModel.setInstitutionId(existing.getInstitutionId());
|
|
|
|
|
+ detailModel.setEnterpriseId(existing.getEnterpriseId());
|
|
|
|
|
+ var detailReq = new AlipayEbppInvoiceInstitutionDetailinfoQueryRequest();
|
|
|
|
|
+ detailReq.setBizModel(detailModel);
|
|
|
|
|
+ var detailResp = alipayClientFactory.getClient(existing.getEnterpriseId()).execute(detailReq);
|
|
|
|
|
+
|
|
|
|
|
+ if (detailResp.isSuccess() && detailResp.getStandardInfoDetailList() != null) {
|
|
|
|
|
+ String periodFactor = mapPeriodTypeToFactor(existing.getPeriodType());
|
|
|
|
|
+ java.util.List<Map<String, Object>> modifyConditions = new java.util.ArrayList<>();
|
|
|
|
|
+ if (amountChanged && periodFactor != null) {
|
|
|
|
|
+ Map<String, Object> c = new LinkedHashMap<>();
|
|
|
|
|
+ c.put("rule_factor", periodFactor);
|
|
|
|
|
+ c.put("rule_value", dto.getAmount().toPlainString());
|
|
|
|
|
+ modifyConditions.add(c);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (limitChanged) {
|
|
|
|
|
+ Map<String, Object> c = new LinkedHashMap<>();
|
|
|
|
|
+ c.put("rule_factor", "QUOTA_TOTAL");
|
|
|
|
|
+ c.put("rule_value", dto.getSingleLimit().toPlainString());
|
|
|
|
|
+ modifyConditions.add(c);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!modifyConditions.isEmpty()) {
|
|
|
|
|
+ java.util.List<Map<String, Object>> modifyStandardList = new java.util.ArrayList<>();
|
|
|
|
|
+ for (com.alipay.api.domain.StandardInfo info : detailResp.getStandardInfoDetailList()) {
|
|
|
|
|
+ if (info.getStandardId() == null) continue;
|
|
|
|
|
+ Map<String, Object> item = new LinkedHashMap<>();
|
|
|
|
|
+ item.put("standard_id", info.getStandardId());
|
|
|
|
|
+ item.put("modify_condition_list", modifyConditions);
|
|
|
|
|
+ modifyStandardList.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> bizContent = new LinkedHashMap<>();
|
|
|
|
|
+ bizContent.put("enterprise_id", existing.getEnterpriseId());
|
|
|
|
|
+ bizContent.put("institution_id", existing.getInstitutionId());
|
|
|
|
|
+ bizContent.put("modify_standard_detail_info",
|
|
|
|
|
+ Map.of("modify_standard_list", modifyStandardList));
|
|
|
|
|
+
|
|
|
|
|
+ // 二次请求:用 DefaultAlipayClient 直接调用
|
|
|
|
|
+ var client = alipayClientFactory.getClient(existing.getEnterpriseId());
|
|
|
|
|
+ var request = new com.alipay.api.AlipayRequest<com.alipay.api.AlipayResponse>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getApiMethodName() {
|
|
|
|
|
+ return "alipay.ebpp.invoice.institution.modify";
|
|
|
|
|
+ }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getBizContent() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(bizContent);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return "{}";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Class<com.alipay.api.AlipayResponse> getResponseClass() {
|
|
|
|
|
+ return com.alipay.api.AlipayResponse.class;
|
|
|
|
|
+ }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getNotifyUrl() { return null; }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getReturnUrl() { return null; }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getTerminalType() { return null; }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getTerminalInfo() { return null; }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getProdCode() { return null; }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getApiVersion() { return null; }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getAuthToken() { return null; }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getAppAuthToken() { return null; }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public java.util.Map<String, String> getTextParams() { return null; }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean isNeedEncrypt() { return false; }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void setNotifyUrl(String notifyUrl) {}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void setReturnUrl(String returnUrl) {}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void setTerminalType(String terminalType) {}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void setTerminalInfo(String terminalInfo) {}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void setProdCode(String prodCode) {}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void setApiVersion(String apiVersion) {}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void setAuthToken(String authToken) {}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void setAppAuthToken(String appAuthToken) {}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void setNeedEncrypt(boolean needEncrypt) {}
|
|
|
|
|
+ };
|
|
|
|
|
+ client.execute(request, null);
|
|
|
|
|
+ log.info("已同步 modify_standard_detail_info: amount={}, singleLimit={}",
|
|
|
|
|
+ dto.getAmount(), dto.getSingleLimit());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("同步 modify_standard_detail_info 失败(不影响基础修改): {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 同步适用范围变更到支付宝 scope.modify
|
|
// 同步适用范围变更到支付宝 scope.modify
|
|
|
if (dto.getApplicableScope() != null && dto.getScopeOwnerIdList() != null
|
|
if (dto.getApplicableScope() != null && dto.getScopeOwnerIdList() != null
|
|
|
&& !dto.getScopeOwnerIdList().isEmpty()) {
|
|
&& !dto.getScopeOwnerIdList().isEmpty()) {
|