Parcourir la source

@
fix: 修改制度时同步适用范围到支付宝 scope.modify

InstitutionUpdateDTO 新增 scopeOwnerType/scopeOwnerIdList 字段,
update() 方法在 institution.modify 后调用 scope.modify 同步适用范围变更。
@

alphaH il y a 9 heures
Parent
commit
a263466234

+ 6 - 0
java/src/main/java/com/payment/platform/module/payment/expense/institution/dto/InstitutionUpdateDTO.java

@@ -75,6 +75,12 @@ public class InstitutionUpdateDTO {
     @Schema(description = "适用范围 (employee/department/all/none)")
     private String applicableScope;
 
+    @Schema(description = "适用范围所有者类型 (EMPLOYEE / DEPARTMENT)")
+    private String scopeOwnerType;
+
+    @Schema(description = "适用范围员工/部门ID列表")
+    private java.util.List<String> scopeOwnerIdList;
+
     @Schema(description = "币种", defaultValue = "CNY")
     private String currency;
 }

+ 25 - 0
java/src/main/java/com/payment/platform/module/payment/expense/institution/service/InstitutionService.java

@@ -773,6 +773,31 @@ public class InstitutionService {
             log.warn("支付宝 institution.modify 异常: {}", e.getMessage());
         }
 
+        // 同步适用范围变更到支付宝 scope.modify
+        if (dto.getApplicableScope() != null && dto.getScopeOwnerIdList() != null
+                && !dto.getScopeOwnerIdList().isEmpty()) {
+            try {
+                String adapterType = mapScopeToAdapterType(dto.getApplicableScope());
+                AlipayEbppInvoiceInstitutionScopeModifyModel scopeModel =
+                        new AlipayEbppInvoiceInstitutionScopeModifyModel();
+                scopeModel.setInstitutionId(existing.getInstitutionId());
+                scopeModel.setEnterpriseId(existing.getEnterpriseId());
+                scopeModel.setAdapterType(adapterType);
+                if (dto.getScopeOwnerType() != null) {
+                    scopeModel.setOwnerType(dto.getScopeOwnerType());
+                }
+                scopeModel.setAddOwnerIdList(dto.getScopeOwnerIdList());
+                AlipayEbppInvoiceInstitutionScopeModifyRequest scopeReq =
+                        new AlipayEbppInvoiceInstitutionScopeModifyRequest();
+                scopeReq.setBizModel(scopeModel);
+                alipayClientFactory.getClient(existing.getEnterpriseId()).execute(scopeReq);
+                log.info("修改制度时同步适用范围成功: institutionId={}, adapterType={}",
+                        existing.getInstitutionId(), adapterType);
+            } catch (Exception e) {
+                log.warn("修改制度时同步适用范围失败(不影响主流程): {}", e.getMessage());
+            }
+        }
+
         // TODO E1: sync modify_standard_detail_info when amount/limit changes
         // When dto.amount or dto.singleLimit changed, build modifyStandardDetailInfo
         // and call Alipay institution.modify again with the updated standard detail info.