|
@@ -780,6 +780,197 @@ async fn load_page_with_children(
|
|
|
Ok((rows, items))
|
|
Ok((rows, items))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/// 列表快路径(无 `opened` 筛):页主档 ∪ 条目 ∪ plan ∪ 订阅开通日 ∪ total/opened 统计 **一跳**。
|
|
|
|
|
+///
|
|
|
|
|
+/// 改前=页 ID + opened 统计 + 页 children + 本页 opened_flags=4 跳/2 轮墙钟;
|
|
|
|
|
+/// 结果字段与判据同 [`load_page_with_children`]+[`opened_flags`]+统计卡(⛔ 改语义)。
|
|
|
|
|
+///
|
|
|
|
|
+/// ⚠️ `LEFT JOIN` 条目与订阅会笛卡尔放大行数 ⇒ 条目按 `item_id` 去重,开通日按合同归并。
|
|
|
|
|
+async fn load_list_page_fast(
|
|
|
|
|
+ db: &UdsClient,
|
|
|
|
|
+ where_sql: &str,
|
|
|
|
|
+ params: &[Value],
|
|
|
|
|
+ lim: &str,
|
|
|
|
|
+ off: &str,
|
|
|
|
|
+) -> Result<(i64, i64, Vec<ContractRow>, Children, HashMap<String, Opened>, HashMap<String, String>), BosError>
|
|
|
|
|
+{
|
|
|
|
|
+ let sql = format!(
|
|
|
|
|
+ "WITH page AS ( \
|
|
|
|
|
+ SELECT {CONTRACT_COLS}, COUNT(*) OVER()::text AS _list_total \
|
|
|
|
|
+ {CONTRACT_FROM} {where_sql} \
|
|
|
|
|
+ ORDER BY k.created_at DESC LIMIT {lim} OFFSET {off} \
|
|
|
|
|
+ ), \
|
|
|
|
|
+ opened_stats AS ( \
|
|
|
|
|
+ SELECT COUNT(DISTINCT s.contract_id)::text AS opened \
|
|
|
|
|
+ FROM subscription s \
|
|
|
|
|
+ WHERE s.actual_opened_at IS NOT NULL \
|
|
|
|
|
+ AND TRIM(CAST(s.actual_opened_at AS TEXT)) <> '' \
|
|
|
|
|
+ AND s.contract_id IN (SELECT k.contract_id {CONTRACT_FROM} {where_sql}) \
|
|
|
|
|
+ ) \
|
|
|
|
|
+ SELECT page.*, \
|
|
|
|
|
+ (SELECT opened FROM opened_stats) AS _list_opened, \
|
|
|
|
|
+ i.item_id AS item_id, i.plan_id AS item_plan_id, i.quantity AS item_quantity, \
|
|
|
|
|
+ i.item_family AS item_family, i.item_mode AS item_mode, \
|
|
|
|
|
+ i.serves_item_id AS serves_item_id, i.ref_subscription_id AS ref_subscription_id, \
|
|
|
|
|
+ i.line_exits AS line_exits, \
|
|
|
|
|
+ p.plan_name AS joined_plan_name, p.plan_family AS joined_plan_family, \
|
|
|
|
|
+ p.sub_account_quota AS joined_sub_account_quota, \
|
|
|
|
|
+ s.actual_opened_at AS sub_opened_at \
|
|
|
|
|
+ FROM page \
|
|
|
|
|
+ LEFT JOIN contract_service_item i ON i.contract_id = page.contract_id \
|
|
|
|
|
+ LEFT JOIN catalog_plan p ON p.plan_id = i.plan_id \
|
|
|
|
|
+ LEFT JOIN subscription s ON s.contract_id = page.contract_id \
|
|
|
|
|
+ ORDER BY page.created_at DESC, i.created_at, i.item_id"
|
|
|
|
|
+ );
|
|
|
|
|
+ #[derive(Deserialize)]
|
|
|
|
|
+ struct FastPageRow {
|
|
|
|
|
+ #[serde(flatten)]
|
|
|
|
|
+ contract: ContractRow,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ _list_total: Option<String>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ _list_opened: Option<String>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ item_id: Option<String>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ item_plan_id: Option<String>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ item_quantity: Option<String>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ item_family: Option<String>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ item_mode: Option<String>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ serves_item_id: Option<String>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ ref_subscription_id: Option<String>,
|
|
|
|
|
+ #[serde(default)]
|
|
|
|
|
+ line_exits: Option<Value>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ joined_plan_name: Option<String>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ joined_plan_family: Option<String>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ joined_sub_account_quota: Option<String>,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ sub_opened_at: Option<String>,
|
|
|
|
|
+ }
|
|
|
|
|
+ let joined: Vec<FastPageRow> = db.query_all::<FastPageRow>(&sql, params).await?;
|
|
|
|
|
+ if joined.is_empty() {
|
|
|
|
|
+ return Ok((0, 0, Vec::new(), HashMap::new(), HashMap::new(), HashMap::new()));
|
|
|
|
|
+ }
|
|
|
|
|
+ let total_n = joined
|
|
|
|
|
+ .first()
|
|
|
|
|
+ .and_then(|r| r._list_total.as_deref())
|
|
|
|
|
+ .and_then(|s| s.parse::<i64>().ok())
|
|
|
|
|
+ .unwrap_or(0);
|
|
|
|
|
+ let opened_n = joined
|
|
|
|
|
+ .first()
|
|
|
|
|
+ .and_then(|r| r._list_opened.as_deref())
|
|
|
|
|
+ .and_then(|s| s.parse::<i64>().ok())
|
|
|
|
|
+ .unwrap_or(0);
|
|
|
|
|
+
|
|
|
|
|
+ let mut page_ids: Vec<String> = Vec::new();
|
|
|
|
|
+ let mut by_id: HashMap<String, ContractRow> = HashMap::new();
|
|
|
|
|
+ let mut plans: HashMap<String, PlanName> = HashMap::new();
|
|
|
|
|
+ let mut items: Children = HashMap::new();
|
|
|
|
|
+ let mut seen_items: HashMap<String, HashSet<String>> = HashMap::new();
|
|
|
|
|
+ let mut backfill: HashMap<String, Vec<Option<String>>> = HashMap::new();
|
|
|
|
|
+ let mut dates: HashMap<String, String> = HashMap::new();
|
|
|
|
|
+ let mut seen_sub: HashMap<String, HashSet<String>> = HashMap::new();
|
|
|
|
|
+
|
|
|
|
|
+ for r in joined {
|
|
|
|
|
+ let cid = r.contract.contract_id.clone();
|
|
|
|
|
+ if !by_id.contains_key(&cid) {
|
|
|
|
|
+ page_ids.push(cid.clone());
|
|
|
|
|
+ backfill.entry(cid.clone()).or_default();
|
|
|
|
|
+ }
|
|
|
|
|
+ by_id.entry(cid.clone()).or_insert(r.contract);
|
|
|
|
|
+
|
|
|
|
|
+ if let Some(raw) = r.sub_opened_at.as_ref() {
|
|
|
|
|
+ let key = raw.clone();
|
|
|
|
|
+ let first = seen_sub.entry(cid.clone()).or_default().insert(key);
|
|
|
|
|
+ if first {
|
|
|
|
|
+ if let Some(d) = raw.trim().to_string().into_iter().next().filter(|_| !raw.trim().is_empty()) {
|
|
|
|
|
+ let d = raw.trim().to_string();
|
|
|
|
|
+ dates
|
|
|
|
|
+ .entry(cid.clone())
|
|
|
|
|
+ .and_modify(|cur| {
|
|
|
|
|
+ if d.as_str() < cur.as_str() {
|
|
|
|
|
+ *cur = d.clone();
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .or_insert_with(|| d.clone());
|
|
|
|
|
+ backfill
|
|
|
|
|
+ .entry(cid.clone())
|
|
|
|
|
+ .or_default()
|
|
|
|
|
+ .push(Some(d));
|
|
|
|
|
+ } else if raw.trim().is_empty() {
|
|
|
|
|
+ backfill.entry(cid.clone()).or_default().push(Some(raw.clone()));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ backfill.entry(cid.clone()).or_default().push(Some(raw.clone()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let Some(item_id) = blank(&r.item_id).map(str::to_string) else {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ };
|
|
|
|
|
+ if !seen_items.entry(cid.clone()).or_default().insert(item_id.clone()) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ let plan_id = blank(&r.item_plan_id).unwrap_or("").to_string();
|
|
|
|
|
+ if let Some(name) = r
|
|
|
|
|
+ .joined_plan_name
|
|
|
|
|
+ .as_ref()
|
|
|
|
|
+ .map(|s| s.trim())
|
|
|
|
|
+ .filter(|s| !s.is_empty())
|
|
|
|
|
+ {
|
|
|
|
|
+ plans.entry(plan_id.clone()).or_insert_with(|| PlanName {
|
|
|
|
|
+ plan_id: plan_id.clone(),
|
|
|
|
|
+ plan_name: name.to_string(),
|
|
|
|
|
+ plan_family: r.joined_plan_family.clone(),
|
|
|
|
|
+ sub_account_quota: r.joined_sub_account_quota.clone(),
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ let item = ItemRow {
|
|
|
|
|
+ item_id,
|
|
|
|
|
+ contract_id: cid.clone(),
|
|
|
|
|
+ plan_id,
|
|
|
|
|
+ quantity: r.item_quantity,
|
|
|
|
|
+ item_family: r.item_family,
|
|
|
|
|
+ item_mode: r.item_mode,
|
|
|
|
|
+ serves_item_id: r.serves_item_id,
|
|
|
|
|
+ ref_subscription_id: r.ref_subscription_id,
|
|
|
|
|
+ line_exits: r.line_exits,
|
|
|
|
|
+ };
|
|
|
|
|
+ items.entry(cid).or_default().push(item_json(item, &plans));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 与 [`opened_flags`] 同判据:工单侧 Unconfigured,只看订阅回填。
|
|
|
|
|
+ for id in &page_ids {
|
|
|
|
|
+ backfill.entry(id.clone()).or_default();
|
|
|
|
|
+ }
|
|
|
|
|
+ let probes: Vec<(String, OpenedProbe)> = backfill
|
|
|
|
|
+ .into_iter()
|
|
|
|
|
+ .map(|(id, v)| {
|
|
|
|
|
+ (
|
|
|
|
|
+ id,
|
|
|
|
|
+ OpenedProbe {
|
|
|
|
|
+ open_tickets: CrossRead::Unconfigured,
|
|
|
|
|
+ subscription_actual_opened_at: v,
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+ .collect();
|
|
|
|
|
+ let flags = contracts_opened(&probes)?;
|
|
|
|
|
+ let rows: Vec<ContractRow> = page_ids
|
|
|
|
|
+ .iter()
|
|
|
|
|
+ .filter_map(|id| by_id.remove(id))
|
|
|
|
|
+ .collect();
|
|
|
|
|
+ Ok((total_n, opened_n, rows, items, flags, dates))
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
async fn load_children(db: &UdsClient, ids: &[String]) -> Result<Children, BosError> {
|
|
async fn load_children(db: &UdsClient, ids: &[String]) -> Result<Children, BosError> {
|
|
|
if ids.is_empty() {
|
|
if ids.is_empty() {
|
|
|
return Ok(HashMap::new());
|
|
return Ok(HashMap::new());
|
|
@@ -4332,52 +4523,110 @@ pub async fn get_list(
|
|
|
Ok(s) => w.push(s),
|
|
Ok(s) => w.push(s),
|
|
|
Err(e) => return json_err(e),
|
|
Err(e) => return json_err(e),
|
|
|
}
|
|
}
|
|
|
- // ① 先取「符合本条 WHERE 的合同 ID 全集」——开通态是跨表派生值,统计卡要与列表同口径,
|
|
|
|
|
- // 而 UDS 侧执行引擎⛔ 支持相关子查询(`EXISTS` 回 `13001 Physical plan not
|
|
|
|
|
- // implemented`),故判据只能在内存里做。合同量级=单运营可见范围(十~百级),
|
|
|
|
|
- // 差异登 18 册。
|
|
|
|
|
- let id_sql = format!(
|
|
|
|
|
- "SELECT k.contract_id AS id {CONTRACT_FROM} {} ORDER BY k.created_at DESC",
|
|
|
|
|
- p.where_clause(&w)
|
|
|
|
|
- );
|
|
|
|
|
- let all_ids: Vec<String> = match state.db.query_all::<IdRow>(&id_sql, p.values()).await {
|
|
|
|
|
- Ok(rs) => rs.into_iter().map(|r| r.id).collect(),
|
|
|
|
|
- Err(e) => return json_err(e),
|
|
|
|
|
- };
|
|
|
|
|
- // ② 一次批量取开通态(判据=`bos-invariant::opened_of`,⛔ 在本层重写、⛔ 逐行 N+1)。
|
|
|
|
|
- let (flags, opened_on_all) = match opened_flags(state.db.as_ref(), &all_ids).await {
|
|
|
|
|
- Ok(m) => m,
|
|
|
|
|
- Err(e) => return json_err(e),
|
|
|
|
|
- };
|
|
|
|
|
- let is_opened = |id: &str| matches!(flags.get(id), Some(Opened::Opened));
|
|
|
|
|
- // ③ 统计卡与列表**同一条 WHERE**(`opened` 筛选也照吃):在同一个 ID 全集上判定,
|
|
|
|
|
- // ⛔ 再发一条不带筛选的 `COUNT`——那会让「已开通」卡片和列表行数对不上。
|
|
|
|
|
- let filtered: Vec<String> = match opened {
|
|
|
|
|
- None => all_ids.clone(),
|
|
|
|
|
- Some(true) => all_ids.iter().filter(|id| is_opened(id)).cloned().collect(),
|
|
|
|
|
- Some(false) => all_ids.iter().filter(|id| !is_opened(id)).cloned().collect(),
|
|
|
|
|
- };
|
|
|
|
|
- let total_n = filtered.len() as i64;
|
|
|
|
|
- let opened_n = filtered.iter().filter(|id| is_opened(id)).count() as i64;
|
|
|
|
|
- // ④ 分页=在内存里切 ID,再 **一跳** 取本页主档 ∪ 条目 ∪ plan(改前页行+children=2 跳)。
|
|
|
|
|
- // ⚠️ 切好的 page_ids **不再**套 LIMIT/OFFSET(D-CT-02:二次分页让 page≥1 恒空集)。
|
|
|
|
|
- // 业务跳合计:全量 ID + opened_flags + 本跳 = 3(含 binding 热后碰红线)。
|
|
|
|
|
- let page_ids: Vec<String> = filtered
|
|
|
|
|
- .iter()
|
|
|
|
|
- .skip(body.pg.offset().max(0) as usize)
|
|
|
|
|
- .take(body.pg.limit() as usize)
|
|
|
|
|
- .cloned()
|
|
|
|
|
- .collect();
|
|
|
|
|
- let (rows, items) = match load_page_with_children(state.db.as_ref(), &page_ids).await {
|
|
|
|
|
- Ok(v) => v,
|
|
|
|
|
- Err(e) => return json_err(e),
|
|
|
|
|
|
|
+ let where_sql = p.where_clause(&w);
|
|
|
|
|
+ let filter_vals: Vec<Value> = p.values().to_vec();
|
|
|
|
|
+
|
|
|
|
|
+ // Wave D 快路径:无 `opened` 筛时 ⛔ 拉全量 ID/全量 opened_flags(墙钟主因)。
|
|
|
|
|
+ // 页行 `COUNT(*) OVER()` + 本页 children;开通态只算本页;统计卡 opened 用非相关 IN 聚合。
|
|
|
|
|
+ // 有 `opened` 筛时仍走全量 ID 内存滤(UDS ⛔ 相关 EXISTS)。
|
|
|
|
|
+ let (total_n, opened_n, rows, items, flags, opened_on) = if opened.is_none() {
|
|
|
|
|
+ let lim = p.push(Value::from(body.pg.limit()));
|
|
|
|
|
+ let off = p.push(Value::from(body.pg.offset().max(0)));
|
|
|
|
|
+ let page_sql = format!(
|
|
|
|
|
+ "SELECT k.contract_id AS id, COUNT(*) OVER()::text AS total \
|
|
|
|
|
+ {CONTRACT_FROM} {where_sql} ORDER BY k.created_at DESC LIMIT {lim} OFFSET {off}"
|
|
|
|
|
+ );
|
|
|
|
|
+ #[derive(Deserialize)]
|
|
|
|
|
+ struct PageIdRow {
|
|
|
|
|
+ #[serde(deserialize_with = "de::as_string")]
|
|
|
|
|
+ id: String,
|
|
|
|
|
+ #[serde(default, deserialize_with = "de::as_opt_string")]
|
|
|
|
|
+ total: Option<String>,
|
|
|
|
|
+ }
|
|
|
|
|
+ let opened_sql = format!(
|
|
|
|
|
+ "SELECT COUNT(DISTINCT s.contract_id)::text AS c FROM subscription s \
|
|
|
|
|
+ WHERE s.actual_opened_at IS NOT NULL \
|
|
|
|
|
+ AND TRIM(CAST(s.actual_opened_at AS TEXT)) <> '' \
|
|
|
|
|
+ AND s.contract_id IN (SELECT k.contract_id {CONTRACT_FROM} {where_sql})"
|
|
|
|
|
+ );
|
|
|
|
|
+ #[derive(Deserialize)]
|
|
|
|
|
+ struct CountRow {
|
|
|
|
|
+ #[serde(deserialize_with = "de::as_string")]
|
|
|
|
|
+ c: String,
|
|
|
|
|
+ }
|
|
|
|
|
+ let page_fut = state.db.query_all::<PageIdRow>(&page_sql, p.values());
|
|
|
|
|
+ let opened_fut = state.db.query_one::<CountRow>(&opened_sql, &filter_vals);
|
|
|
|
|
+ let (page_ids_rows, opened_row) = match tokio::try_join!(page_fut, opened_fut) {
|
|
|
|
|
+ Ok(v) => v,
|
|
|
|
|
+ Err(e) => return json_err(e),
|
|
|
|
|
+ };
|
|
|
|
|
+ let total_n = if let Some(r) = page_ids_rows.first() {
|
|
|
|
|
+ r.total
|
|
|
|
|
+ .as_deref()
|
|
|
|
|
+ .and_then(|s| s.parse::<i64>().ok())
|
|
|
|
|
+ .unwrap_or(0)
|
|
|
|
|
+ } else if body.pg.offset() > 0 {
|
|
|
|
|
+ let count_sql = format!("SELECT COUNT(*)::text AS c {CONTRACT_FROM} {where_sql}");
|
|
|
|
|
+ match state.db.query_one::<CountRow>(&count_sql, &filter_vals).await {
|
|
|
|
|
+ Ok(Some(r)) => r.c.parse().unwrap_or(0),
|
|
|
|
|
+ Ok(None) => 0,
|
|
|
|
|
+ Err(e) => return json_err(e),
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ 0
|
|
|
|
|
+ };
|
|
|
|
|
+ let opened_n = opened_row
|
|
|
|
|
+ .and_then(|r| r.c.parse::<i64>().ok())
|
|
|
|
|
+ .unwrap_or(0);
|
|
|
|
|
+ let page_ids: Vec<String> = page_ids_rows.into_iter().map(|r| r.id).collect();
|
|
|
|
|
+ let page_fut = load_page_with_children(state.db.as_ref(), &page_ids);
|
|
|
|
|
+ let flags_fut = opened_flags(state.db.as_ref(), &page_ids);
|
|
|
|
|
+ let ((rows, items), (flags, opened_on)) = match tokio::try_join!(page_fut, flags_fut) {
|
|
|
|
|
+ Ok(v) => v,
|
|
|
|
|
+ Err(e) => return json_err(e),
|
|
|
|
|
+ };
|
|
|
|
|
+ (total_n, opened_n, rows, items, flags, opened_on)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // ① 先取「符合本条 WHERE 的合同 ID 全集」——开通态是跨表派生值,统计卡要与列表同口径。
|
|
|
|
|
+ let id_sql = format!(
|
|
|
|
|
+ "SELECT k.contract_id AS id {CONTRACT_FROM} {where_sql} ORDER BY k.created_at DESC"
|
|
|
|
|
+ );
|
|
|
|
|
+ let all_ids: Vec<String> = match state.db.query_all::<IdRow>(&id_sql, &filter_vals).await {
|
|
|
|
|
+ Ok(rs) => rs.into_iter().map(|r| r.id).collect(),
|
|
|
|
|
+ Err(e) => return json_err(e),
|
|
|
|
|
+ };
|
|
|
|
|
+ let (flags_all, opened_on_all) = match opened_flags(state.db.as_ref(), &all_ids).await {
|
|
|
|
|
+ Ok(m) => m,
|
|
|
|
|
+ Err(e) => return json_err(e),
|
|
|
|
|
+ };
|
|
|
|
|
+ let is_opened = |id: &str| matches!(flags_all.get(id), Some(Opened::Opened));
|
|
|
|
|
+ let filtered: Vec<String> = match opened {
|
|
|
|
|
+ Some(true) => all_ids.iter().filter(|id| is_opened(id)).cloned().collect(),
|
|
|
|
|
+ Some(false) => all_ids.iter().filter(|id| !is_opened(id)).cloned().collect(),
|
|
|
|
|
+ None => all_ids,
|
|
|
|
|
+ };
|
|
|
|
|
+ let total_n = filtered.len() as i64;
|
|
|
|
|
+ let opened_n = filtered.iter().filter(|id| is_opened(id)).count() as i64;
|
|
|
|
|
+ let page_ids: Vec<String> = filtered
|
|
|
|
|
+ .iter()
|
|
|
|
|
+ .skip(body.pg.offset().max(0) as usize)
|
|
|
|
|
+ .take(body.pg.limit() as usize)
|
|
|
|
|
+ .cloned()
|
|
|
|
|
+ .collect();
|
|
|
|
|
+ let (rows, items) = match load_page_with_children(state.db.as_ref(), &page_ids).await {
|
|
|
|
|
+ Ok(v) => v,
|
|
|
|
|
+ Err(e) => return json_err(e),
|
|
|
|
|
+ };
|
|
|
|
|
+ let opened_on: HashMap<String, String> = page_ids
|
|
|
|
|
+ .iter()
|
|
|
|
|
+ .filter_map(|id| opened_on_all.get(id).cloned().map(|d| (id.clone(), d)))
|
|
|
|
|
+ .collect();
|
|
|
|
|
+ let flags: HashMap<String, Opened> = page_ids
|
|
|
|
|
+ .iter()
|
|
|
|
|
+ .filter_map(|id| flags_all.get(id).copied().map(|f| (id.clone(), f)))
|
|
|
|
|
+ .collect();
|
|
|
|
|
+ (total_n, opened_n, rows, items, flags, opened_on)
|
|
|
};
|
|
};
|
|
|
- let cids: Vec<String> = rows.iter().map(|r| r.contract_id.clone()).collect();
|
|
|
|
|
- // 04 册 §4.5:实际开通日已在 opened_flags 同趟取回(按本页 ID 裁剪)。
|
|
|
|
|
- let opened_on: HashMap<String, String> = cids
|
|
|
|
|
- .iter()
|
|
|
|
|
- .filter_map(|id| opened_on_all.get(id).cloned().map(|d| (id.clone(), d)))
|
|
|
|
|
- .collect();
|
|
|
|
|
json_ok(with_pending(json!({
|
|
json_ok(with_pending(json!({
|
|
|
"items": rows
|
|
"items": rows
|
|
|
.iter()
|
|
.iter()
|