CaiWuXiTong/config/business_data.php

144 lines
11 KiB
PHP

<?php
/*
|--------------------------------------------------------------------------
| Shared business-data placement
|--------------------------------------------------------------------------
|
| MariaDB remains the control plane and serving store for dimensions,
| operational records and compact aggregates. Large analytical facts are
| copied to ClickHouse from the existing mirror before any reader cutover.
| Immutable Parquet archives are written only after reconciliation succeeds.
|
| `target_store` is a migration destination, not an activation switch. The
| application continues to read MariaDB until a verified placement record is
| explicitly activated. No policy below deletes an existing mirror table.
|
*/
return [
'clickhouse' => [
'enabled' => filter_var(env('BUSINESS_CLICKHOUSE_ENABLED', false), FILTER_VALIDATE_BOOL),
'url' => env('BUSINESS_CLICKHOUSE_URL', 'http://clickhouse:8123'),
'database' => env('BUSINESS_CLICKHOUSE_DATABASE', 'caiwu_business_analytics'),
'username' => env('BUSINESS_CLICKHOUSE_USERNAME', 'caiwu_app'),
'password' => env('BUSINESS_CLICKHOUSE_PASSWORD', ''),
'connect_timeout_seconds' => (float) env('BUSINESS_CLICKHOUSE_CONNECT_TIMEOUT', 3),
'query_timeout_seconds' => (float) env('BUSINESS_CLICKHOUSE_QUERY_TIMEOUT', 30),
'stream_timeout_seconds' => (float) env('BUSINESS_CLICKHOUSE_STREAM_TIMEOUT', 1800),
],
'archive' => [
'disk' => env('BUSINESS_DATA_ARCHIVE_DISK', 'business_uploads_qiniu'),
'prefix' => trim((string) env('BUSINESS_DATA_ARCHIVE_PREFIX', 'business-data-archive'), '/'),
],
/*
* Every code-owned dataset in config/upstream_mirrors.php is classified.
* `sync` values:
* - always: keep the existing central incremental sync running;
* - after_columnar_activation: do not grow MariaDB before a columnar
* generation has been verified and activated;
* - disabled: no current page consumes the dataset; retain/archive the
* existing table, but do not keep querying the upstream source.
*/
'datasets' => [
// Small organization and catalog dimensions stay in MariaDB.
'operations_replica.rpt.fys_companyInfo' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '公司资料'],
'operations_replica.rpt.fys_shopInfo' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '店铺资料/店铺报表'],
'operations_replica.rpt.fys_TrademarkInfo' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '商标资料'],
'operations_replica.rpt.jst_sku' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '商品资料/售后费用'],
'operations_replica.rpt.jst_warehouseInfo' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '售后费用'],
'operations_replica.rpt.jst_shopInfo' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '推广费用'],
// Large analytical facts move to ClickHouse after a MariaDB backfill.
'operations_replica.rpt.jst_Orders' => [
'role' => 'fact', 'target_store' => 'clickhouse', 'consumer' => '售后费用',
'partition_column' => 'order_date', 'activation_group' => 'order-analysis',
],
'operations_replica.rpt.jst_OrderItem' => [
'role' => 'fact', 'target_store' => 'clickhouse', 'consumer' => '售后费用',
'activation_group' => 'order-analysis',
],
'operations_replica.rpt.ads_itemid_sales_cost_ratio_v2_di' => [
'role' => 'fact', 'target_store' => 'clickhouse', 'consumer' => '推广费用',
'partition_column' => 'stat_date', 'activation_group' => 'promotion-analysis',
],
'operations_replica.rpt.jst_returnAndRefundInfo' => [
'role' => 'fact', 'target_store' => 'clickhouse', 'consumer' => '售后费用/非京喜退款',
'partition_column' => 'as_date', 'activation_group' => 'order-analysis',
],
'operations_replica.rpt.jst_returnAndRefundItem' => [
'role' => 'fact', 'target_store' => 'clickhouse', 'consumer' => '售后费用/非京喜退款',
'activation_group' => 'order-analysis',
],
'operations_replica.rpt.jst_originalBillInfo' => [
'role' => 'fact', 'target_store' => 'clickhouse', 'consumer' => '通用原始账单(当前无页面直读)',
'partition_column' => 'fee_time', 'sync' => 'after_columnar_activation',
],
// This 20M+ row mapping is not queried by the current promotion page.
// Keep/archive its existing data, but stop upstream refresh immediately.
'operations_replica.rpt.jst_skumap' => [
'role' => 'archive_only', 'target_store' => 'parquet', 'consumer' => '当前无页面读取',
'sync' => 'disabled',
],
// Work orders are current-state operational data and remain row-store.
'operations_replica.rpt.work_order_main' => ['role' => 'operational', 'target_store' => 'mariadb', 'consumer' => '协同工单'],
'operations_replica.rpt.work_order_sub' => ['role' => 'operational', 'target_store' => 'mariadb', 'consumer' => '协同工单'],
'operations_replica.rpt.work_order_form_config' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '协同工单'],
'operations_replica.rpt.work_order_form_value' => ['role' => 'operational', 'target_store' => 'mariadb', 'consumer' => '协同工单'],
'jiansun.dbo.jst_workOrderInfo' => ['role' => 'operational', 'target_store' => 'mariadb', 'consumer' => '小额打款工单'],
'jiansun.dbo.jst_small_payment_order_map' => ['role' => 'operational', 'target_store' => 'mariadb', 'consumer' => '小额打款工单'],
// Account bills and supplier pages are bounded serving datasets today.
'jiansun.dbo.tmall_spread_bills' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '淘宝推广账单'],
'jiansun.dbo.pdd_spread_bills' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '拼多多推广账单'],
'jiansun.dbo.alibaba_bill' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '阿里巴巴账单'],
'jiansun.dbo.jd_spreadBills' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '京东推广账单'],
'jiansun.dbo.jd_costBills' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '京东钱包账单'],
'jiansun.dbo.fys_Ticketing_install_view' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '安装明细'],
'jiansun.dbo.fys_Ticketing_install_item' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '安装明细详情'],
'jiansun.dbo.finance_purchaseReturn' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '供应商退货对账'],
'jiansun.dbo.finance_invoiceDeduction' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '供应商发票扣款'],
'jiansun.dbo.fys_supplierPaymentSummary' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '供应商应付'],
'jiansun.dbo.finance_advanceLoans' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '借支明细'],
'jiansun.dbo.pm_unOrderDetails' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '未定价明细'],
'jiansun.dbo.finance_sampleDeduction' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '样品扣款'],
'jiansun.dbo.fys_express_courier_settlement' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '代发快递'],
'jiansun.dbo.finance_boardDeduction' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '板材扣款'],
'jiansun.dbo.pm_plainPlateData' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '素板资料'],
'jiansun.dbo.pm_boardPurchasePrice' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '板材采购价'],
'jiansun.dbo.pm_boardPriceChangeImport' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '板材调价'],
'jiansun.dbo.pm_boardApplyDetail' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '板材申请明细'],
'jiansun.dbo.pm_edgeBandData' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '封边条资料'],
'jiansun.dbo.pm_edgeBandApplyDetail' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '封边条明细'],
'jiansun.dbo.pm_edgeBandProfitInfo' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '封边条利润'],
'jiansun.dbo.finance_edgeBandDeductio' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '封边条扣款'],
'jiansun.dbo.pm_averageUnitPrice' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '平均单价'],
'jiansun.dbo.pm_boardInventoryDetail_snapshot' => ['role' => 'aggregate', 'target_store' => 'mariadb', 'consumer' => '板材库存'],
'jiansun.dbo.fys_supplierGoods_sttlement_purchase' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '货款采购对账'],
'jiansun.dbo.fys_supplierGoods_sttlement_sale' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '货款销售对账'],
'jiansun.dbo.pm_purchaseIn' => ['role' => 'serving_fact', 'target_store' => 'mariadb', 'consumer' => '采购入库'],
'jiansun.dbo.wp_express' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '快递资料'],
'jiansun.dbo.wp_express_expNet' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '快递网点'],
'jiansun.dbo.wp_express_account' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '快递打款账户'],
'jiansun.dbo.wp_express_extension' => ['role' => 'dimension', 'target_store' => 'mariadb', 'consumer' => '快递扩展资料'],
],
'special_tables' => [
'store_report_bill_rows' => [
'role' => 'fact',
'target_store' => 'clickhouse',
'consumer' => '店铺经营报表的可恢复原始层;页面只读日汇总',
'partition_column' => 'occurred_at',
],
'store_report_daily_rows' => [
'role' => 'aggregate',
'target_store' => 'mariadb',
'consumer' => '店铺经营报表',
],
],
];