|
|
@@ -18,6 +18,7 @@ import com.jzg.commons.entity.agreement.dispatch.dto.PtlAgreementDispatchRulesAt
|
|
|
import com.jzg.commons.entity.agreement.dispatch.vo.PtlAgreementDispatchQuery;
|
|
|
import com.jzg.commons.entity.agreement.dispatch.vo.PtlAgreementDispatchVo;
|
|
|
import com.jzg.commons.entity.agreement.dispatch.vo.ValidateDispatchRuleVo;
|
|
|
+import com.jzg.commons.entity.agreement.po.PtlAgreementAttribution;
|
|
|
import com.jzg.commons.entity.costs.vo.ValidateSchemeRuleVo;
|
|
|
import com.jzg.commons.entity.po.*;
|
|
|
import com.jzg.commons.entity.quote.vo.CustomerInfoVo;
|
|
|
@@ -423,6 +424,49 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
log.info("租户[{}]有权限的保司有[{}]个", systemCode, CollUtil.size(companyListResult.getData()));
|
|
|
AssertionUtils.isFail(companyListResult.getCode() != 200, companyListResult.getMsg());
|
|
|
List<EsmInsCompany> companyList = companyListResult.getData();
|
|
|
+
|
|
|
+ // ========================= 协议和账号状态过滤 =========================
|
|
|
+ // 过滤条件:
|
|
|
+ // 1. 协议必须启用 (isEnable == 0)
|
|
|
+ // 2. 协议必须生效中 (validStatus == "0")
|
|
|
+ // 3. 关联账号必须可用 (useStatus == "0") 且可报价 (quoteStatus == "0")
|
|
|
+ // 过滤后如果某保司没有任何有效协议,会被下面的 removeIf 自动排除
|
|
|
+ if (CollUtil.isNotEmpty(companyList)) {
|
|
|
+ for (EsmInsCompany company : companyList) {
|
|
|
+ List<PtlAgreement> agreements = company.getAgreements();
|
|
|
+ if (CollUtil.isEmpty(agreements)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<PtlAgreement> validAgreements = agreements.stream()
|
|
|
+ // 协议自身状态
|
|
|
+ .filter(a -> a.getIsEnable() != null && a.getIsEnable() == 0)
|
|
|
+ .filter(a -> "0".equals(a.getValidStatus()))
|
|
|
+ // 归属账号状态
|
|
|
+ .filter(agreement -> {
|
|
|
+ String attributionId = agreement.getAttributionId();
|
|
|
+ if (attributionId == null || attributionId.isEmpty()) {
|
|
|
+ return true; // 没有关联账号,不做账号校验
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ com.jzg.commons.core.page.HttpResult<PtlAgreementAttribution> res =
|
|
|
+ platformClient.getAgreementAttribution2(attributionId);
|
|
|
+ if (res.getCode() != 200 || res.getData() == null) {
|
|
|
+ return true; // 查不到账号信息,默认保留
|
|
|
+ }
|
|
|
+ PtlAgreementAttribution attr = res.getData();
|
|
|
+ return "0".equals(attr.getUseStatus()) && "0".equals(attr.getQuoteStatus());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("查询协议[{}]的归属账号异常,默认保留", agreement.getId(), e);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ company.setAgreements(validAgreements);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("协议/账号状态过滤完成,开始后续业务匹配");
|
|
|
+ // ====================================================================
|
|
|
+
|
|
|
// 业务员的归属权限是可选参数,不选的话不进行过滤
|
|
|
companyList = salespersonFilterCompanyList(schemeRuleFilterVo, companyList);
|
|
|
|