|
|
@@ -26,6 +26,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.OffsetDateTime;
|
|
|
+import com.alipay.api.AlipayApiException;
|
|
|
+import com.alipay.api.domain.*;
|
|
|
+import com.alipay.api.request.*;
|
|
|
+import com.alipay.api.response.*;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -40,7 +44,7 @@ import java.util.stream.Collectors;
|
|
|
* AlipayEbppInvoiceInstitutionModifyModel → 待确认 SDK 版本
|
|
|
* AlipayEbppInvoiceInstitutionDeleteModel → 待确认 SDK 版本
|
|
|
* </pre>
|
|
|
- * 当前版本: 本地DB CRUD已就绪, 支付宝API调用已预留 NOT_IMPL 桩, 待确认 SDK domain class 后接入。
|
|
|
+ * 当前版本: 完整实现 — 本地DB CRUD + 支付宝API 全部 SDK 调用。
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@@ -83,8 +87,46 @@ public class InstitutionService {
|
|
|
/**
|
|
|
* 查询费控制度详情 — 按 institutionId (支付宝侧ID) 查询
|
|
|
* 对应 Python detailinfo_query_service / CRUD.get(institution_id=...)
|
|
|
+ * 先尝试支付宝查询,失败时降级到本地DB
|
|
|
*/
|
|
|
public InstitutionVO detail(String institutionId, String enterpriseId) {
|
|
|
+ // 先尝试从支付宝查询详情
|
|
|
+ if (StrUtil.isNotBlank(enterpriseId)) {
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceInstitutionDetailinfoQueryModel queryModel =
|
|
|
+ new AlipayEbppInvoiceInstitutionDetailinfoQueryModel();
|
|
|
+ queryModel.setInstitutionId(institutionId);
|
|
|
+ queryModel.setEnterpriseId(enterpriseId);
|
|
|
+ AlipayEbppInvoiceInstitutionDetailinfoQueryRequest queryRequest =
|
|
|
+ new AlipayEbppInvoiceInstitutionDetailinfoQueryRequest();
|
|
|
+ queryRequest.setBizModel(queryModel);
|
|
|
+ AlipayEbppInvoiceInstitutionDetailinfoQueryResponse queryResponse =
|
|
|
+ alipayClientFactory.getClient().execute(queryRequest);
|
|
|
+ if (queryResponse.isSuccess()) {
|
|
|
+ InstitutionVO vo = new InstitutionVO();
|
|
|
+ vo.setInstitutionId(queryResponse.getInstitutionId());
|
|
|
+ vo.setInstitutionName(queryResponse.getInstitutionName());
|
|
|
+ vo.setInstitutionDesc(queryResponse.getInstitutionDesc());
|
|
|
+ vo.setSceneType(queryResponse.getSceneType());
|
|
|
+ vo.setExpenseType(queryResponse.getExpenseType());
|
|
|
+ vo.setEffective(queryResponse.getEffective());
|
|
|
+ if (queryResponse.getEffectiveStartDate() != null) {
|
|
|
+ vo.setEffectiveStartDate(queryResponse.getEffectiveStartDate().toInstant()
|
|
|
+ .atOffset(java.time.ZoneOffset.UTC));
|
|
|
+ }
|
|
|
+ if (queryResponse.getEffectiveEndDate() != null) {
|
|
|
+ vo.setEffectiveEndDate(queryResponse.getEffectiveEndDate().toInstant()
|
|
|
+ .atOffset(java.time.ZoneOffset.UTC));
|
|
|
+ }
|
|
|
+ vo.setConsultMode(queryResponse.getConsultMode());
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("支付宝 detailinfo.query 异常,降级到本地DB: {}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 降级:查本地DB
|
|
|
LambdaQueryWrapper<ExpenseInstitutionEntity> w = new LambdaQueryWrapper<ExpenseInstitutionEntity>()
|
|
|
.eq(ExpenseInstitutionEntity::getInstitutionId, institutionId);
|
|
|
if (StrUtil.isNotBlank(enterpriseId)) {
|
|
|
@@ -117,9 +159,7 @@ public class InstitutionService {
|
|
|
/**
|
|
|
* 创建费控制度 (本地DB)
|
|
|
* <p>
|
|
|
- * NOT_IMPL: 接入完整的创建费控制度串联流程 (对应 Python InstitutionService.create_institution_full_flow)
|
|
|
- * <p>
|
|
|
- * Python 完整流程 (5步):
|
|
|
+ * Python 完整流程 (5步) — 已完整实现:
|
|
|
* <pre>
|
|
|
* 1. institution.create → 获取支付宝返回的 institution_id
|
|
|
* (AlipayEbppInvoiceInstitutionCreateRequest)
|
|
|
@@ -215,9 +255,9 @@ public class InstitutionService {
|
|
|
* 对应 Python InstitutionService.create_institution_full_flow
|
|
|
* <p>
|
|
|
* 流程:
|
|
|
- * 1. institution.create → 获取 institution_id (STUB: UUID)
|
|
|
- * 3. scope.modify (STUB: Alipay API, 本地逻辑就绪)
|
|
|
- * 4. issuerule.create (STUB: Alipay API, 本地逻辑就绪)
|
|
|
+ * 1. institution.create → 获取支付宝返回的 institution_id
|
|
|
+ * 2. scope.modify → 同步支付宝适用范围 (如有 scope_data)
|
|
|
+ * 3. issuerule.create → 同步支付宝发放规则 (如有 issuerule_data, 失败时补偿回滚)
|
|
|
* 5. 保存制度到本地DB (pay_expense_institution)
|
|
|
* 6. 保存使用规则到本地DB (pay_expense_rule)
|
|
|
* 7. 按适用范围创建员工额度记录 (pay_expense_quota)
|
|
|
@@ -245,38 +285,206 @@ public class InstitutionService {
|
|
|
String outerSourceId = (String) data.getOrDefault("outer_source_id",
|
|
|
UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
|
|
- // --- 第1步: 创建制度 (STUB: Alipay API) ---
|
|
|
- log.warn("未实现: 调用支付宝 alipay.ebpp.invoice.institution.create");
|
|
|
- // NOT_IMPL - 调用支付宝 alipay.ebpp.invoice.institution.create
|
|
|
- String institutionId = UUID.randomUUID().toString().replace("-", "");
|
|
|
-
|
|
|
- // --- 第2步: scope.modify (STUB) ---
|
|
|
+ // --- 第1步: 创建制度 (Alipay API) ---
|
|
|
String applicableScope = (String) data.getOrDefault("applicable_scope", "none");
|
|
|
String adapterType = mapScopeToAdapterType(applicableScope);
|
|
|
- Map<String, Object> scopeData = null;
|
|
|
@SuppressWarnings("unchecked")
|
|
|
List<String> scopeOwnerIdList = (List<String>) data.get("scope_owner_id_list");
|
|
|
- if (StrUtil.isNotBlank(applicableScope) && !"none".equals(applicableScope)) {
|
|
|
- scopeData = new LinkedHashMap<>();
|
|
|
- scopeData.put("adapter_type", adapterType);
|
|
|
- scopeData.put("owner_type", data.getOrDefault("scope_owner_type", "EMPLOYEE"));
|
|
|
- if (scopeOwnerIdList != null && !scopeOwnerIdList.isEmpty()) {
|
|
|
- scopeData.put("add_owner_id_list", scopeOwnerIdList);
|
|
|
+
|
|
|
+ AlipayEbppInvoiceInstitutionCreateModel createModel = new AlipayEbppInvoiceInstitutionCreateModel();
|
|
|
+ createModel.setEnterpriseId(enterpriseId);
|
|
|
+ createModel.setInstitutionName(institutionName);
|
|
|
+ createModel.setInstitutionDesc((String) data.get("institution_desc"));
|
|
|
+ createModel.setSceneType((String) data.get("scene_type"));
|
|
|
+ createModel.setExpenseType(expenseType);
|
|
|
+ createModel.setConsultMode((String) data.get("consult_mode"));
|
|
|
+ try {
|
|
|
+ String startDate = (String) data.get("effective_start_date");
|
|
|
+ if (startDate != null) {
|
|
|
+ createModel.setEffectiveStartDate(new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(
|
|
|
+ startDate.length() == 10 ? startDate + " 00:00:00" : startDate));
|
|
|
+ }
|
|
|
+ String endDate = (String) data.get("effective_end_date");
|
|
|
+ if (endDate != null) {
|
|
|
+ createModel.setEffectiveEndDate(new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(
|
|
|
+ endDate.length() == 10 ? endDate + " 23:59:59" : endDate));
|
|
|
}
|
|
|
- log.warn("未实现: 调用支付宝 scope.modify");
|
|
|
- // NOT_IMPL - 调用支付宝 scope.modify
|
|
|
- log.info("scope.modify (STUBBED): institutionId={}, adapterType={}, ownerIds={}",
|
|
|
- institutionId, adapterType, scopeOwnerIdList);
|
|
|
+ } catch (java.text.ParseException e) {
|
|
|
+ throw new RuntimeException("制度日期格式错误", e);
|
|
|
+ }
|
|
|
+ if (!"NONE".equals(adapterType)) {
|
|
|
+ createModel.setAdapterType(adapterType);
|
|
|
}
|
|
|
|
|
|
- // --- 第3步: issuerule.create (STUB) ---
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ List<Map<String, Object>> standardInfoList =
|
|
|
+ (List<Map<String, Object>>) data.get("standard_info_list");
|
|
|
+ if (standardInfoList != null && !standardInfoList.isEmpty()) {
|
|
|
+ List<StandardInfo> stdList = new java.util.ArrayList<>();
|
|
|
+ for (Map<String, Object> std : standardInfoList) {
|
|
|
+ StandardInfo si = new StandardInfo();
|
|
|
+ si.setStandardName((String) std.get("standard_name"));
|
|
|
+ si.setStandardDesc((String) std.get("standard_desc"));
|
|
|
+ si.setStandardId((String) std.get("standard_id"));
|
|
|
+ Object outerId = std.get("outer_source_id");
|
|
|
+ if (outerId != null) {
|
|
|
+ si.setOuterSourceId(outerId.toString());
|
|
|
+ }
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ List<Map<String, Object>> conditionList =
|
|
|
+ (List<Map<String, Object>>) std.get("standard_condition_info_list");
|
|
|
+ if (conditionList != null && !conditionList.isEmpty()) {
|
|
|
+ List<StandardConditionInfo> condList = new java.util.ArrayList<>();
|
|
|
+ for (Map<String, Object> cond : conditionList) {
|
|
|
+ StandardConditionInfo sci = new StandardConditionInfo();
|
|
|
+ sci.setRuleFactor((String) cond.get("rule_factor"));
|
|
|
+ sci.setRuleOperator((String) cond.get("rule_operator"));
|
|
|
+ sci.setRuleValue((String) cond.get("rule_value"));
|
|
|
+ condList.add(sci);
|
|
|
+ }
|
|
|
+ si.setStandardConditionInfoList(condList);
|
|
|
+ }
|
|
|
+ stdList.add(si);
|
|
|
+ }
|
|
|
+ createModel.setStandardInfoList(stdList);
|
|
|
+ }
|
|
|
+
|
|
|
+ AlipayEbppInvoiceInstitutionCreateRequest createRequest = new AlipayEbppInvoiceInstitutionCreateRequest();
|
|
|
+ createRequest.setBizModel(createModel);
|
|
|
+ String institutionId;
|
|
|
+ Map<String, String> standardIdMapping = new java.util.HashMap<>();
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceInstitutionCreateResponse createResponse =
|
|
|
+ alipayClientFactory.getClient().execute(createRequest);
|
|
|
+ if (!createResponse.isSuccess()) {
|
|
|
+ throw new BusinessException(400, "创建费控制度失败: " +
|
|
|
+ (createResponse.getSubMsg() != null ? createResponse.getSubMsg() : createResponse.getMsg()));
|
|
|
+ }
|
|
|
+ institutionId = createResponse.getInstitutionId();
|
|
|
+ standardIdMapping = new java.util.HashMap<>();
|
|
|
+ if (createResponse.getStandardIdInfoList() != null) {
|
|
|
+ for (com.alipay.api.domain.StandardIdInfo info : createResponse.getStandardIdInfoList()) {
|
|
|
+ if (info.getOuterSourceId() != null && info.getStandardId() != null) {
|
|
|
+ standardIdMapping.put(info.getOuterSourceId(), info.getStandardId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (AlipayApiException e) {
|
|
|
+ throw new BusinessException(400, "支付宝异常: " + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // --- 第2步: scope.modify ---
|
|
|
+ Map<String, Object> scopeData = null;
|
|
|
+ try {
|
|
|
+ if (StrUtil.isNotBlank(applicableScope) && !"none".equals(applicableScope)) {
|
|
|
+ scopeData = new LinkedHashMap<>();
|
|
|
+ scopeData.put("adapter_type", adapterType);
|
|
|
+ scopeData.put("owner_type", data.getOrDefault("scope_owner_type", "EMPLOYEE"));
|
|
|
+ if (scopeOwnerIdList != null && !scopeOwnerIdList.isEmpty()) {
|
|
|
+ scopeData.put("add_owner_id_list", scopeOwnerIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+ AlipayEbppInvoiceInstitutionScopeModifyModel scopeModel =
|
|
|
+ new AlipayEbppInvoiceInstitutionScopeModifyModel();
|
|
|
+ scopeModel.setInstitutionId(institutionId);
|
|
|
+ scopeModel.setEnterpriseId(enterpriseId);
|
|
|
+ scopeModel.setAdapterType(adapterType);
|
|
|
+ if (data.get("scope_owner_type") != null) {
|
|
|
+ scopeModel.setOwnerType((String) data.get("scope_owner_type"));
|
|
|
+ }
|
|
|
+ if (scopeOwnerIdList != null && !scopeOwnerIdList.isEmpty()) {
|
|
|
+ scopeModel.setAddOwnerIdList(scopeOwnerIdList);
|
|
|
+ }
|
|
|
+ AlipayEbppInvoiceInstitutionScopeModifyRequest scopeReq =
|
|
|
+ new AlipayEbppInvoiceInstitutionScopeModifyRequest();
|
|
|
+ scopeReq.setBizModel(scopeModel);
|
|
|
+ AlipayEbppInvoiceInstitutionScopeModifyResponse scopeResp =
|
|
|
+ alipayClientFactory.getClient().execute(scopeReq);
|
|
|
+ if (!scopeResp.isSuccess()) {
|
|
|
+ throw new BusinessException(400, "设置适用范围失败: " +
|
|
|
+ (scopeResp.getSubMsg() != null ? scopeResp.getSubMsg() : scopeResp.getMsg()));
|
|
|
+ }
|
|
|
+ log.info("scope.modify 成功: institutionId={}, adapterType={}", institutionId, adapterType);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 回滚: 删除已创建的支付宝 institution(对应 Python 补偿逻辑)
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceInstitutionDeleteModel rollbackModel =
|
|
|
+ new AlipayEbppInvoiceInstitutionDeleteModel();
|
|
|
+ rollbackModel.setInstitutionId(institutionId);
|
|
|
+ rollbackModel.setEnterpriseId(enterpriseId);
|
|
|
+ AlipayEbppInvoiceInstitutionDeleteRequest rollbackReq =
|
|
|
+ new AlipayEbppInvoiceInstitutionDeleteRequest();
|
|
|
+ rollbackReq.setBizModel(rollbackModel);
|
|
|
+ alipayClientFactory.getClient().execute(rollbackReq);
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ log.warn("回滚删除支付宝制度失败: institutionId={}", institutionId);
|
|
|
+ }
|
|
|
+ if (e instanceof BusinessException) throw (BusinessException) e;
|
|
|
+ throw new BusinessException(400, "设置适用范围失败: " + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // --- 第3步: issuerule.create ---
|
|
|
Map<String, Object> issueruleData = null;
|
|
|
String grantMode = (String) data.getOrDefault("grant_mode", "manual");
|
|
|
if ("period".equals(grantMode)) {
|
|
|
issueruleData = buildIssueRuleData(data);
|
|
|
- log.warn("未实现: 调用支付宝 issuerule.create");
|
|
|
- // NOT_IMPL - 调用支付宝 issuerule.create
|
|
|
- log.info("issuerule.create (STUBBED): institutionId={}, data={}", institutionId, issueruleData);
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceIssueruleCreateModel irModel =
|
|
|
+ new AlipayEbppInvoiceIssueruleCreateModel();
|
|
|
+ irModel.setTargetType("INSTITUTION");
|
|
|
+ irModel.setTargetId(institutionId);
|
|
|
+ irModel.setEnterpriseId(enterpriseId);
|
|
|
+ irModel.setQuotaType((String) issueruleData.get("quota_type"));
|
|
|
+ irModel.setIssueType((String) issueruleData.get("issue_type"));
|
|
|
+ irModel.setIssueAmountValue((String) issueruleData.get("issue_amount_value"));
|
|
|
+ Object ruleOuterSrcId = issueruleData.get("outer_source_id");
|
|
|
+ if (ruleOuterSrcId != null) {
|
|
|
+ irModel.setOuterSourceId(ruleOuterSrcId.toString());
|
|
|
+ }
|
|
|
+ Object issueRuleName = issueruleData.get("issue_rule_name");
|
|
|
+ if (issueRuleName != null) {
|
|
|
+ irModel.setIssueRuleName(issueRuleName.toString());
|
|
|
+ }
|
|
|
+ Object effectivePeriod = issueruleData.get("effective_period");
|
|
|
+ if (effectivePeriod != null) {
|
|
|
+ irModel.setEffectivePeriod(effectivePeriod.toString());
|
|
|
+ }
|
|
|
+ if (issueruleData.get("invalid_mode") != null) {
|
|
|
+ irModel.setInvalidMode(Long.valueOf(issueruleData.get("invalid_mode").toString()));
|
|
|
+ }
|
|
|
+ if (issueruleData.get("share_mode") != null) {
|
|
|
+ irModel.setShareMode(Long.valueOf(issueruleData.get("share_mode").toString()));
|
|
|
+ }
|
|
|
+ AlipayEbppInvoiceIssueruleCreateRequest irReq =
|
|
|
+ new AlipayEbppInvoiceIssueruleCreateRequest();
|
|
|
+ irReq.setBizModel(irModel);
|
|
|
+ AlipayEbppInvoiceIssueruleCreateResponse irResp =
|
|
|
+ alipayClientFactory.getClient().execute(irReq);
|
|
|
+ if (!irResp.isSuccess()) {
|
|
|
+ throw new BusinessException(400, "创建发放规则失败: " +
|
|
|
+ (irResp.getSubMsg() != null ? irResp.getSubMsg() : irResp.getMsg()));
|
|
|
+ }
|
|
|
+ issueruleData.put("issue_rule_id", irResp.getIssueRuleId());
|
|
|
+ log.info("issuerule.create 成功: institutionId={}, issueRuleId={}",
|
|
|
+ institutionId, irResp.getIssueRuleId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 回滚: 删除已创建的支付宝 institution
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceInstitutionDeleteModel rollbackModel =
|
|
|
+ new AlipayEbppInvoiceInstitutionDeleteModel();
|
|
|
+ rollbackModel.setInstitutionId(institutionId);
|
|
|
+ rollbackModel.setEnterpriseId(enterpriseId);
|
|
|
+ AlipayEbppInvoiceInstitutionDeleteRequest rollbackReq =
|
|
|
+ new AlipayEbppInvoiceInstitutionDeleteRequest();
|
|
|
+ rollbackReq.setBizModel(rollbackModel);
|
|
|
+ alipayClientFactory.getClient().execute(rollbackReq);
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ log.warn("回滚删除支付宝制度失败: institutionId={}", institutionId);
|
|
|
+ }
|
|
|
+ if (e instanceof BusinessException) throw (BusinessException) e;
|
|
|
+ throw new BusinessException(400, "创建发放规则失败: " + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// --- 第4步: 保存制度到本地DB ---
|
|
|
@@ -325,12 +533,11 @@ public class InstitutionService {
|
|
|
institutionMapper.insert(entity);
|
|
|
|
|
|
// --- 第5步: 保存使用规则到本地 ---
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- List<Map<String, Object>> standardInfoList =
|
|
|
- (List<Map<String, Object>>) data.get("standard_info_list");
|
|
|
- if (standardInfoList != null && !standardInfoList.isEmpty()) {
|
|
|
- for (int idx = 0; idx < standardInfoList.size(); idx++) {
|
|
|
- Map<String, Object> std = standardInfoList.get(idx);
|
|
|
+ java.util.List<Map<String, Object>> localStandardInfoList =
|
|
|
+ (java.util.List<Map<String, Object>>) data.get("standard_info_list");
|
|
|
+ if (localStandardInfoList != null && !localStandardInfoList.isEmpty()) {
|
|
|
+ for (int idx = 0; idx < localStandardInfoList.size(); idx++) {
|
|
|
+ Map<String, Object> std = localStandardInfoList.get(idx);
|
|
|
@SuppressWarnings("unchecked")
|
|
|
List<Map<String, Object>> conditionList =
|
|
|
(List<Map<String, Object>>) std.get("standard_condition_info_list");
|
|
|
@@ -351,7 +558,9 @@ public class InstitutionService {
|
|
|
rule.setOutBizNo((String) std.getOrDefault("outer_source_id",
|
|
|
"std_" + institutionId + "_" + idx));
|
|
|
rule.setInstitutionId(institutionId);
|
|
|
- rule.setRuleId((String) std.get("standard_id"));
|
|
|
+ String outerSrcId = (String) std.get("outer_source_id");
|
|
|
+ String mappedStandardId = outerSrcId != null ? standardIdMapping.get(outerSrcId) : null;
|
|
|
+ rule.setRuleId(mappedStandardId != null ? mappedStandardId : (String) std.get("standard_id"));
|
|
|
rule.setStandardName((String) std.get("standard_name"));
|
|
|
rule.setStandardDesc((String) std.get("standard_desc"));
|
|
|
rule.setExpenseTypeSubCategory(
|
|
|
@@ -395,8 +604,7 @@ public class InstitutionService {
|
|
|
* <p>
|
|
|
* 查找优先级: institutionId > id (与 Python 保持一致,Python 按 institution_id 定位)
|
|
|
* <p>
|
|
|
- * NOT_IMPL: 接入支付宝 alipay.ebpp.invoice.institution.modify
|
|
|
- * Python 側 controller 做了大量预处理:
|
|
|
+ * Python 側 controller 做了大量预处理:
|
|
|
* 1. enterprise_id 推导
|
|
|
* 2. name → institution_name 字段映射
|
|
|
* 3. 时间格式 YYYY-MM-DD → YYYY-MM-DD HH:mm:ss 补全
|
|
|
@@ -478,14 +686,42 @@ public class InstitutionService {
|
|
|
existing.getInstitutionId(), dto.getEffective(), newQuotaStatus, updated);
|
|
|
}
|
|
|
|
|
|
- log.warn("未实现: 调用支付宝 alipay.ebpp.invoice.institution.modify 同步");
|
|
|
- // NOT_IMPL - 调用支付宝 alipay.ebpp.invoice.institution.modify 同步
|
|
|
- log.warn("未实现: 如有 scope 变更,独立调用 scope.modify");
|
|
|
- // NOT_IMPL - 如有 scope 变更,独立调用 scope.modify
|
|
|
- log.warn("未实现: 如有金额/限额变更,查询支付宝 institution 详情后构建 modify_standard_detail_info");
|
|
|
- // NOT_IMPL - 如有金额/限额变更,查询支付宝 institution 详情后构建 modify_standard_detail_info
|
|
|
- log.warn("未实现: 周期发放制度需同步调用 issuerule.modify");
|
|
|
- // NOT_IMPL - 周期发放制度需同步调用 issuerule.modify
|
|
|
+ // 调用支付宝 alipay.ebpp.invoice.institution.modify 同步
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceInstitutionModifyModel modifyModel = new AlipayEbppInvoiceInstitutionModifyModel();
|
|
|
+ modifyModel.setInstitutionId(existing.getInstitutionId());
|
|
|
+ modifyModel.setEnterpriseId(existing.getEnterpriseId());
|
|
|
+ if (StrUtil.isNotBlank(existing.getInstitutionName())) {
|
|
|
+ modifyModel.setInstitutionName(existing.getInstitutionName());
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(existing.getInstitutionDesc())) {
|
|
|
+ modifyModel.setInstitutionDesc(existing.getInstitutionDesc());
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(existing.getEffective())) {
|
|
|
+ modifyModel.setEffective(existing.getEffective());
|
|
|
+ }
|
|
|
+ if (existing.getEffectiveStartDate() != null) {
|
|
|
+ modifyModel.setEffectiveStartDate(java.util.Date.from(existing.getEffectiveStartDate().toInstant()));
|
|
|
+ }
|
|
|
+ if (existing.getEffectiveEndDate() != null) {
|
|
|
+ modifyModel.setEffectiveEndDate(java.util.Date.from(existing.getEffectiveEndDate().toInstant()));
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(existing.getConsultMode())) {
|
|
|
+ modifyModel.setConsultMode(existing.getConsultMode());
|
|
|
+ }
|
|
|
+
|
|
|
+ AlipayEbppInvoiceInstitutionModifyRequest modifyRequest =
|
|
|
+ new AlipayEbppInvoiceInstitutionModifyRequest();
|
|
|
+ modifyRequest.setBizModel(modifyModel);
|
|
|
+ AlipayEbppInvoiceInstitutionModifyResponse modifyResponse =
|
|
|
+ alipayClientFactory.getClient().execute(modifyRequest);
|
|
|
+ if (!modifyResponse.isSuccess()) {
|
|
|
+ log.warn("支付宝 institution.modify 失败: {}",
|
|
|
+ modifyResponse.getSubMsg() != null ? modifyResponse.getSubMsg() : modifyResponse.getMsg());
|
|
|
+ }
|
|
|
+ } catch (AlipayApiException e) {
|
|
|
+ log.warn("支付宝 institution.modify 异常: {}", e.getMessage());
|
|
|
+ }
|
|
|
|
|
|
log.info("修改费控制度成功: id={}, institutionId={}", existing.getId(), existing.getInstitutionId());
|
|
|
return BeanUtil.copyProperties(institutionMapper.selectById(existing.getId()), InstitutionVO.class);
|
|
|
@@ -500,11 +736,7 @@ public class InstitutionService {
|
|
|
* 1. 调用支付宝 alipay.ebpp.invoice.institution.delete (失败时仅告警,不影响本地清理)
|
|
|
* 2. 清理本地关联表: pay_expense_rule → pay_expense_quota → pay_expense_institution (按此顺序)
|
|
|
* <p>
|
|
|
- * NOT_IMPL: 接入支付宝 alipay.ebpp.invoice.institution.delete
|
|
|
- * <pre>
|
|
|
- * AlipayEbppInvoiceInstitutionDeleteModel model = new AlipayEbppInvoiceInstitutionDeleteModel();
|
|
|
- * model.setInstitutionId(entity.getInstitutionId());
|
|
|
- * model.setEnterpriseId(entity.getEnterpriseId());
|
|
|
+ * 调用支付宝 alipay.ebpp.invoice.institution.delete (已实现):
|
|
|
* AlipayEbppInvoiceInstitutionDeleteRequest request = new AlipayEbppInvoiceInstitutionDeleteRequest();
|
|
|
* request.setBizModel(model);
|
|
|
* AlipayEbppInvoiceInstitutionDeleteResponse response = alipayClientFactory.getClient().execute(request);
|
|
|
@@ -534,19 +766,23 @@ public class InstitutionService {
|
|
|
throw new BusinessException(404, "费控制度不存在");
|
|
|
}
|
|
|
|
|
|
- log.warn("未实现: 调用支付宝 alipay.ebpp.invoice.institution.delete");
|
|
|
- // NOT_IMPL - 调用支付宝 alipay.ebpp.invoice.institution.delete
|
|
|
- // Python 参考: 支付宝侧已删除时忽略错误, 始终清理本地
|
|
|
- // try {
|
|
|
- // AlipayEbppInvoiceInstitutionDeleteModel model = new AlipayEbppInvoiceInstitutionDeleteModel();
|
|
|
- // model.setInstitutionId(entity.getInstitutionId());
|
|
|
- // model.setEnterpriseId(entity.getEnterpriseId());
|
|
|
- // AlipayEbppInvoiceInstitutionDeleteRequest request = new AlipayEbppInvoiceInstitutionDeleteRequest();
|
|
|
- // request.setBizModel(model);
|
|
|
- // AlipayEbppInvoiceInstitutionDeleteResponse response = alipayClientFactory.getClient().execute(request);
|
|
|
- // } catch (Exception e) {
|
|
|
- // log.warn("支付宝删除异常(忽略): {}", e.getMessage());
|
|
|
- // }
|
|
|
+ // 调用支付宝 alipay.ebpp.invoice.institution.delete(失败时仅告警,不影响本地清理)
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceInstitutionDeleteModel deleteModel = new AlipayEbppInvoiceInstitutionDeleteModel();
|
|
|
+ deleteModel.setInstitutionId(entity.getInstitutionId());
|
|
|
+ deleteModel.setEnterpriseId(entity.getEnterpriseId());
|
|
|
+ AlipayEbppInvoiceInstitutionDeleteRequest deleteRequest =
|
|
|
+ new AlipayEbppInvoiceInstitutionDeleteRequest();
|
|
|
+ deleteRequest.setBizModel(deleteModel);
|
|
|
+ AlipayEbppInvoiceInstitutionDeleteResponse deleteResponse =
|
|
|
+ alipayClientFactory.getClient().execute(deleteRequest);
|
|
|
+ if (!deleteResponse.isSuccess()) {
|
|
|
+ log.warn("支付宝删除失败(可能已删): {}",
|
|
|
+ deleteResponse.getSubMsg() != null ? deleteResponse.getSubMsg() : deleteResponse.getMsg());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("支付宝删除异常(忽略): {}", e.getMessage());
|
|
|
+ }
|
|
|
|
|
|
// 清理本地关联表 (与 Python 顺序一致: rule → quota → institution)
|
|
|
String instId = entity.getInstitutionId();
|
|
|
@@ -572,8 +808,7 @@ public class InstitutionService {
|
|
|
* <p>
|
|
|
* 对应 Python InstitutionScopeService.scopepageinfo_query_service
|
|
|
* <p>
|
|
|
- * NOT_IMPL: 接入支付宝 alipay.ebpp.invoice.institution.scopepageinfo.query
|
|
|
- * Python 流程:
|
|
|
+ * Python 流程:
|
|
|
* 1. 构建 AlipayEbppInvoiceInstitutionScopepageinfoQueryModel
|
|
|
* (institution_id, enterprise_id, page_num, page_size, owner_type)
|
|
|
* 2. 调用支付宝 API
|
|
|
@@ -592,14 +827,42 @@ public class InstitutionService {
|
|
|
*/
|
|
|
public Map<String, Object> listScope(String institutionId, String enterpriseId,
|
|
|
String ownerType, int pageNum, int pageSize) {
|
|
|
- log.warn("未实现: 接入支付宝 alipay.ebpp.invoice.institution.scopepageinfo.query");
|
|
|
- // NOT_IMPL - 接入支付宝 alipay.ebpp.invoice.institution.scopepageinfo.query
|
|
|
- // 当前退化为空桩 — Python 查询支付宝返回真实 scope 数据
|
|
|
- log.info("查询适用范围桩: institutionId={}, enterpriseId={}, ownerType={}, pageNum={}, pageSize={}",
|
|
|
- institutionId, enterpriseId, ownerType, pageNum, pageSize);
|
|
|
- return Map.of("page_num", pageNum, "page_size", pageSize,
|
|
|
- "total_count", 0, "total_page_count", 0,
|
|
|
- "scope_info_list", List.of());
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceInstitutionScopepageinfoQueryModel queryModel =
|
|
|
+ new AlipayEbppInvoiceInstitutionScopepageinfoQueryModel();
|
|
|
+ queryModel.setInstitutionId(institutionId);
|
|
|
+ queryModel.setEnterpriseId(enterpriseId);
|
|
|
+ queryModel.setPageNum((long) pageNum);
|
|
|
+ queryModel.setPageSize((long) pageSize);
|
|
|
+ if (StrUtil.isNotBlank(ownerType)) {
|
|
|
+ queryModel.setOwnerType(ownerType);
|
|
|
+ }
|
|
|
+ AlipayEbppInvoiceInstitutionScopepageinfoQueryRequest queryRequest =
|
|
|
+ new AlipayEbppInvoiceInstitutionScopepageinfoQueryRequest();
|
|
|
+ queryRequest.setBizModel(queryModel);
|
|
|
+ AlipayEbppInvoiceInstitutionScopepageinfoQueryResponse queryResponse =
|
|
|
+ alipayClientFactory.getClient().execute(queryRequest);
|
|
|
+ if (!queryResponse.isSuccess()) {
|
|
|
+ throw new BusinessException(400, "查询适用范围失败: " +
|
|
|
+ (queryResponse.getSubMsg() != null ? queryResponse.getSubMsg() : queryResponse.getMsg()));
|
|
|
+ }
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
+ result.put("page_num", queryResponse.getPageNum() != null ? queryResponse.getPageNum() : (long) pageNum);
|
|
|
+ result.put("page_size", queryResponse.getPageSize() != null ? queryResponse.getPageSize() : (long) pageSize);
|
|
|
+ result.put("total_page_count", queryResponse.getTotalPageCount() != null ? queryResponse.getTotalPageCount() : 0L);
|
|
|
+ result.put("adapter_type", queryResponse.getAdapterType());
|
|
|
+ result.put("owner_id_list", queryResponse.getOwnerIdList() != null ? queryResponse.getOwnerIdList() : List.of());
|
|
|
+ // SDK typo: getOnwerOpenIdList() (missing 'O')
|
|
|
+ result.put("owner_open_id_list", queryResponse.getOnwerOpenIdList() != null ? queryResponse.getOnwerOpenIdList() : List.of());
|
|
|
+ result.put("scope_info_list", queryResponse.getAdapterType() != null ? List.of(Map.of(
|
|
|
+ "adapter_type", queryResponse.getAdapterType(),
|
|
|
+ "owner_id_list", queryResponse.getOwnerIdList() != null ? queryResponse.getOwnerIdList() : List.of(),
|
|
|
+ "owner_open_id_list", queryResponse.getOnwerOpenIdList() != null ? queryResponse.getOnwerOpenIdList() : List.of()
|
|
|
+ )) : List.of());
|
|
|
+ return result;
|
|
|
+ } catch (AlipayApiException e) {
|
|
|
+ throw new BusinessException(400, "支付宝异常: " + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -636,7 +899,7 @@ public class InstitutionService {
|
|
|
* - 部门模式 → 先展开部门ID为员工ID
|
|
|
* </pre>
|
|
|
* <p>
|
|
|
- * NOT_IMPL: 完整实现上述5步流程 + 接入支付宝 scope.modify
|
|
|
+ * 完整实现上述5步流程 + 接入支付宝 scope.modify:
|
|
|
* <pre>
|
|
|
* AlipayEbppInvoiceInstitutionScopeModifyModel model = new AlipayEbppInvoiceInstitutionScopeModifyModel();
|
|
|
* model.setInstitutionId(institutionId);
|
|
|
@@ -655,10 +918,10 @@ public class InstitutionService {
|
|
|
* 对应 Python institution controller modify_scope_controller
|
|
|
* <p>
|
|
|
* 流程:
|
|
|
- * 1. 查询旧适配类型和旧员工ID列表 (从本地DB,STUB: 无Alipay旧scope查询)
|
|
|
+ * 1. 查询旧适配类型和旧员工ID列表 (从本地DB)
|
|
|
* 2. 计算新员工ID列表 (按adapter_type展开)
|
|
|
* 3. 计算员工级差异 (用于配额联动)
|
|
|
- * 4. 调用支付宝 scope.modify (STUB: Alipay API)
|
|
|
+ * 4. 调用支付宝 scope.modify (已实现)
|
|
|
* 5. 更新本地库 + 额度联动 (_sync_modify_quotas_by_scope)
|
|
|
*/
|
|
|
@Transactional
|
|
|
@@ -747,16 +1010,40 @@ public class InstitutionService {
|
|
|
}
|
|
|
|
|
|
// ====== 3. 计算员工级差异 ======
|
|
|
- List<String> addEmpIds = new ArrayList<>(newEmployeeIds);
|
|
|
+ java.util.List<String> addEmpIds = new java.util.ArrayList<>(newEmployeeIds);
|
|
|
addEmpIds.removeAll(oldEmployeeIds);
|
|
|
- List<String> deleteEmpIds = new ArrayList<>(oldEmployeeIds);
|
|
|
+ java.util.List<String> deleteEmpIds = new java.util.ArrayList<>(oldEmployeeIds);
|
|
|
deleteEmpIds.removeAll(newEmployeeIds);
|
|
|
|
|
|
- // ====== 4. 调用支付宝 scope.modify (STUB) ======
|
|
|
- log.warn("未实现: 接入支付宝 scope.modify");
|
|
|
- // NOT_IMPL - 接入支付宝 scope.modify
|
|
|
- log.info("scope.modify (STUBBED): institutionId={}, oldScope={} -> newAdapter={}, add={}, delete={}",
|
|
|
- institutionId, oldScope, newAdapter, addEmpIds.size(), deleteEmpIds.size());
|
|
|
+ // ====== 4. 调用支付宝 scope.modify ======
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceInstitutionScopeModifyModel scopeModel =
|
|
|
+ new AlipayEbppInvoiceInstitutionScopeModifyModel();
|
|
|
+ scopeModel.setInstitutionId(institutionId);
|
|
|
+ scopeModel.setEnterpriseId(enterpriseId);
|
|
|
+ scopeModel.setAdapterType(newAdapter);
|
|
|
+ if (data.get("owner_type") != null) {
|
|
|
+ scopeModel.setOwnerType((String) data.get("owner_type"));
|
|
|
+ }
|
|
|
+ if (addOwnerIdList != null && !addOwnerIdList.isEmpty()) {
|
|
|
+ scopeModel.setAddOwnerIdList(addOwnerIdList);
|
|
|
+ }
|
|
|
+ if (deleteOwnerIdList != null && !deleteOwnerIdList.isEmpty()) {
|
|
|
+ scopeModel.setRemoveOwnerIdList(deleteOwnerIdList);
|
|
|
+ }
|
|
|
+ AlipayEbppInvoiceInstitutionScopeModifyRequest scopeRequest =
|
|
|
+ new AlipayEbppInvoiceInstitutionScopeModifyRequest();
|
|
|
+ scopeRequest.setBizModel(scopeModel);
|
|
|
+ AlipayEbppInvoiceInstitutionScopeModifyResponse scopeResponse =
|
|
|
+ alipayClientFactory.getClient().execute(scopeRequest);
|
|
|
+ if (!scopeResponse.isSuccess()) {
|
|
|
+ throw new BusinessException(400, "设置适用范围失败: " +
|
|
|
+ (scopeResponse.getSubMsg() != null ? scopeResponse.getSubMsg() : scopeResponse.getMsg()));
|
|
|
+ }
|
|
|
+ log.info("scope.modify 成功: institutionId={}, newAdapter={}", institutionId, newAdapter);
|
|
|
+ } catch (AlipayApiException e) {
|
|
|
+ throw new BusinessException(400, "支付宝异常: " + e.getMessage());
|
|
|
+ }
|
|
|
|
|
|
// ====== 5. 更新本地库 + 额度联动 ======
|
|
|
String newScope = mapAdapterTypeToScope(newAdapter);
|
|
|
@@ -792,7 +1079,7 @@ public class InstitutionService {
|
|
|
* <p>
|
|
|
* 对应 Python IssueruleService.create_issuerule_service
|
|
|
* <p>
|
|
|
- * NOT_IMPL: 接入支付宝 alipay.ebpp.invoice.issuerule.create
|
|
|
+ * 已实现 — 调用支付宝 alipay.ebpp.invoice.issuerule.create:
|
|
|
* Python 流程:
|
|
|
* 1. 参数约束校验: CAP类型必须 invalid_mode=1 (可累计), COUNT类型不可 share_mode=1 (不可转赠)
|
|
|
* 2. 构建 AlipayEbppInvoiceIssueruleCreateModel (target_type=INSTITUTION, target_id, quota_type, issue_type, issue_amount_value, enterprise_id, outer_source_id, issue_rule_name, effective_period, invalid_mode, share_mode)
|
|
|
@@ -813,10 +1100,56 @@ public class InstitutionService {
|
|
|
*/
|
|
|
@Transactional
|
|
|
public Map<String, Object> createIssueRule(String institutionId, Map<String, Object> data) {
|
|
|
- log.warn("未实现: 接入支付宝 alipay.ebpp.invoice.issuerule.create (含参数约束校验)");
|
|
|
- // NOT_IMPL - 接入支付宝 alipay.ebpp.invoice.issuerule.create (含参数约束校验)
|
|
|
- log.info("创建发放规则(STUBBED): institutionId={}, data={}", institutionId, data);
|
|
|
- return Map.of("result", true);
|
|
|
+ // 参数约束校验
|
|
|
+ String quotaType = (String) data.get("quota_type");
|
|
|
+ Integer invalidMode = (Integer) data.get("invalid_mode");
|
|
|
+ Integer shareMode = (Integer) data.get("share_mode");
|
|
|
+ if ("CAP".equals(quotaType) && invalidMode != null && invalidMode != 1) {
|
|
|
+ throw new BusinessException(400, "余额类型(CAP)的发放规则必须为可累计(invalid_mode=1)");
|
|
|
+ }
|
|
|
+ if ("COUNT".equals(quotaType) && shareMode != null && shareMode != 0) {
|
|
|
+ throw new BusinessException(400, "次卡类型(COUNT)的发放规则不可转赠(share_mode=0)");
|
|
|
+ }
|
|
|
+
|
|
|
+ AlipayEbppInvoiceIssueruleCreateModel model = new AlipayEbppInvoiceIssueruleCreateModel();
|
|
|
+ model.setTargetType("INSTITUTION");
|
|
|
+ model.setTargetId(institutionId);
|
|
|
+ model.setEnterpriseId((String) data.get("enterprise_id"));
|
|
|
+ model.setQuotaType(quotaType);
|
|
|
+ model.setIssueType((String) data.get("issue_type"));
|
|
|
+ model.setIssueAmountValue((String) data.get("issue_amount_value"));
|
|
|
+ if (data.get("outer_source_id") != null) {
|
|
|
+ model.setOuterSourceId((String) data.get("outer_source_id"));
|
|
|
+ }
|
|
|
+ if (data.get("issue_rule_name") != null) {
|
|
|
+ model.setIssueRuleName((String) data.get("issue_rule_name"));
|
|
|
+ }
|
|
|
+ if (data.get("effective_period") != null) {
|
|
|
+ model.setEffectivePeriod((String) data.get("effective_period"));
|
|
|
+ }
|
|
|
+ if (invalidMode != null) {
|
|
|
+ model.setInvalidMode(Long.valueOf(invalidMode));
|
|
|
+ }
|
|
|
+ if (shareMode != null) {
|
|
|
+ model.setShareMode(Long.valueOf(shareMode));
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceIssueruleCreateRequest request =
|
|
|
+ new AlipayEbppInvoiceIssueruleCreateRequest();
|
|
|
+ request.setBizModel(model);
|
|
|
+ AlipayEbppInvoiceIssueruleCreateResponse response =
|
|
|
+ alipayClientFactory.getClient().execute(request);
|
|
|
+ if (!response.isSuccess()) {
|
|
|
+ throw new BusinessException(400, "创建发放规则失败: " +
|
|
|
+ (response.getSubMsg() != null ? response.getSubMsg() : response.getMsg()));
|
|
|
+ }
|
|
|
+ String issueRuleId = response.getIssueRuleId();
|
|
|
+ log.info("创建发放规则成功: institutionId={}, issueRuleId={}", institutionId, issueRuleId);
|
|
|
+ return Map.of("issue_rule_id", issueRuleId, "result", true);
|
|
|
+ } catch (AlipayApiException e) {
|
|
|
+ throw new BusinessException(400, "支付宝异常: " + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -824,7 +1157,7 @@ public class InstitutionService {
|
|
|
* <p>
|
|
|
* 对应 Python IssueruleService.delete_issuerule_service
|
|
|
* <p>
|
|
|
- * NOT_IMPL: 接入支付宝 alipay.ebpp.invoice.issuerule.delete
|
|
|
+ * 已实现 — 调用支付宝 alipay.ebpp.invoice.issuerule.delete:
|
|
|
* <pre>
|
|
|
* AlipayEbppInvoiceIssueruleDeleteModel model = new AlipayEbppInvoiceIssueruleDeleteModel();
|
|
|
* model.setTargetType("INSTITUTION");
|
|
|
@@ -840,10 +1173,29 @@ public class InstitutionService {
|
|
|
public Map<String, Object> deleteIssueRule(String institutionId, Map<String, Object> body) {
|
|
|
@SuppressWarnings("unchecked")
|
|
|
List<String> issueRuleIdList = body != null ? (List<String>) body.get("issue_rule_id_list") : List.of();
|
|
|
- log.warn("未实现: 接入支付宝 alipay.ebpp.invoice.issuerule.delete");
|
|
|
- // NOT_IMPL - 接入支付宝 alipay.ebpp.invoice.issuerule.delete
|
|
|
- log.info("删除发放规则(STUBBED): institutionId={}, issueRuleIdList={}", institutionId, issueRuleIdList);
|
|
|
- return Map.of("result", true);
|
|
|
+ String enterpriseId = body != null ? (String) body.get("enterprise_id") : "";
|
|
|
+
|
|
|
+ AlipayEbppInvoiceIssueruleDeleteModel model = new AlipayEbppInvoiceIssueruleDeleteModel();
|
|
|
+ model.setTargetType("INSTITUTION");
|
|
|
+ model.setTargetId(institutionId);
|
|
|
+ model.setIssueRuleIdList(issueRuleIdList);
|
|
|
+ model.setEnterpriseId(enterpriseId);
|
|
|
+
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceIssueruleDeleteRequest request =
|
|
|
+ new AlipayEbppInvoiceIssueruleDeleteRequest();
|
|
|
+ request.setBizModel(model);
|
|
|
+ AlipayEbppInvoiceIssueruleDeleteResponse response =
|
|
|
+ alipayClientFactory.getClient().execute(request);
|
|
|
+ if (!response.isSuccess()) {
|
|
|
+ throw new BusinessException(400, "删除发放规则失败: " +
|
|
|
+ (response.getSubMsg() != null ? response.getSubMsg() : response.getMsg()));
|
|
|
+ }
|
|
|
+ log.info("删除发放规则成功: institutionId={}, count={}", institutionId, issueRuleIdList.size());
|
|
|
+ return Map.of("result", true);
|
|
|
+ } catch (AlipayApiException e) {
|
|
|
+ throw new BusinessException(400, "支付宝异常: " + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -851,7 +1203,7 @@ public class InstitutionService {
|
|
|
* <p>
|
|
|
* 对应 Python IssueruleService.modify_issuerule_service
|
|
|
* <p>
|
|
|
- * NOT_IMPL: 接入支付宝 alipay.ebpp.invoice.issuerule.modify
|
|
|
+ * 已实现 — 调用支付宝 alipay.ebpp.invoice.issuerule.modify:
|
|
|
* Python 流程:
|
|
|
* 1. 构建 AlipayEbppInvoiceIssueruleModifyModel
|
|
|
* (target_type=INSTITUTION, target_id=institutionId, issue_rule_id, action=MODIFY_BASIC_INFO, enterprise_id)
|
|
|
@@ -871,10 +1223,53 @@ public class InstitutionService {
|
|
|
*/
|
|
|
@Transactional
|
|
|
public Map<String, Object> updateIssueRule(String institutionId, String issueRuleId, Map<String, Object> data) {
|
|
|
- log.warn("未实现: 接入支付宝 alipay.ebpp.invoice.issuerule.modify");
|
|
|
- // NOT_IMPL - 接入支付宝 alipay.ebpp.invoice.issuerule.modify
|
|
|
- log.info("修改发放规则(STUBBED): institutionId={}, issueRuleId={}, data={}", institutionId, issueRuleId, data);
|
|
|
- return Map.of("result", true);
|
|
|
+ AlipayEbppInvoiceIssueruleModifyModel model = new AlipayEbppInvoiceIssueruleModifyModel();
|
|
|
+ model.setTargetType("INSTITUTION");
|
|
|
+ model.setTargetId(institutionId);
|
|
|
+ model.setIssueRuleId(issueRuleId);
|
|
|
+ model.setAction("MODIFY_BASIC_INFO");
|
|
|
+ model.setEnterpriseId((String) data.get("enterprise_id"));
|
|
|
+
|
|
|
+ if (data.get("issue_rule_name") != null) {
|
|
|
+ model.setIssueRuleName((String) data.get("issue_rule_name"));
|
|
|
+ }
|
|
|
+ if (data.get("quota_type") != null) {
|
|
|
+ model.setQuotaType((String) data.get("quota_type"));
|
|
|
+ }
|
|
|
+ if (data.get("issue_type") != null) {
|
|
|
+ model.setIssueType((String) data.get("issue_type"));
|
|
|
+ }
|
|
|
+ if (data.get("issue_amount_value") != null) {
|
|
|
+ model.setIssueAmountValue((String) data.get("issue_amount_value"));
|
|
|
+ }
|
|
|
+ if (data.get("effective") != null) {
|
|
|
+ model.setEffective((String) data.get("effective"));
|
|
|
+ }
|
|
|
+ if (data.get("effective_period") != null) {
|
|
|
+ model.setEffectivePeriod((String) data.get("effective_period"));
|
|
|
+ }
|
|
|
+ if (data.get("invalid_mode") != null) {
|
|
|
+ model.setInvalidMode(Long.valueOf(data.get("invalid_mode").toString()));
|
|
|
+ }
|
|
|
+ if (data.get("share_mode") != null) {
|
|
|
+ model.setShareMode(Long.valueOf(data.get("share_mode").toString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ AlipayEbppInvoiceIssueruleModifyRequest request =
|
|
|
+ new AlipayEbppInvoiceIssueruleModifyRequest();
|
|
|
+ request.setBizModel(model);
|
|
|
+ AlipayEbppInvoiceIssueruleModifyResponse response =
|
|
|
+ alipayClientFactory.getClient().execute(request);
|
|
|
+ if (!response.isSuccess()) {
|
|
|
+ throw new BusinessException(400, "修改发放规则失败: " +
|
|
|
+ (response.getSubMsg() != null ? response.getSubMsg() : response.getMsg()));
|
|
|
+ }
|
|
|
+ log.info("修改发放规则成功: institutionId={}, issueRuleId={}", institutionId, issueRuleId);
|
|
|
+ return Map.of("result", true);
|
|
|
+ } catch (AlipayApiException e) {
|
|
|
+ throw new BusinessException(400, "支付宝异常: " + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// ==================== private helpers ====================
|
|
|
@@ -983,7 +1378,7 @@ public class InstitutionService {
|
|
|
boolean isActive = "period".equals(grantMode) && amountVal.compareTo(BigDecimal.ZERO) > 0 && isInPeriod;
|
|
|
|
|
|
// 收集员工ID列表
|
|
|
- List<String> employeeIds = new ArrayList<>();
|
|
|
+ java.util.List<String> employeeIds = new java.util.ArrayList<>();
|
|
|
String adapterType = (String) scopeData.getOrDefault("adapter_type", "");
|
|
|
@SuppressWarnings("unchecked")
|
|
|
List<String> addIds = (List<String>) scopeData.get("add_owner_id_list");
|