@pisell/pisellos 2.2.243 → 2.2.244
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/evaluator.js +2 -3
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +4 -7
- package/dist/modules/Cart/utils/cartProduct.js +3 -24
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Customer/index.d.ts +0 -20
- package/dist/modules/Customer/index.js +83 -172
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.js +3 -4
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.d.ts +0 -8
- package/dist/modules/OpenData/index.js +17 -37
- package/dist/modules/Order/index.d.ts +18 -268
- package/dist/modules/Order/index.js +757 -3306
- package/dist/modules/Order/types.d.ts +31 -279
- package/dist/modules/Order/types.js +0 -38
- package/dist/modules/Order/utils.d.ts +5 -147
- package/dist/modules/Order/utils.js +103 -746
- package/dist/modules/Payment/index.d.ts +13 -10
- package/dist/modules/Payment/index.js +837 -467
- package/dist/modules/Payment/types.d.ts +0 -2
- package/dist/modules/Payment/utils.js +1 -2
- package/dist/modules/Payment/walletpass.js +7 -14
- package/dist/modules/ProductList/index.d.ts +12 -16
- package/dist/modules/ProductList/index.js +59 -133
- package/dist/modules/ProductList/types.d.ts +0 -14
- package/dist/modules/Quotation/index.d.ts +1 -0
- package/dist/modules/Quotation/index.js +22 -25
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +69 -93
- package/dist/modules/Rules/types.d.ts +0 -1
- package/dist/modules/SalesSummary/index.d.ts +25 -8
- package/dist/modules/SalesSummary/index.js +35 -86
- package/dist/modules/SalesSummary/types.d.ts +1 -4
- package/dist/modules/SalesSummary/utils.d.ts +25 -2
- package/dist/modules/SalesSummary/utils.js +162 -794
- package/dist/modules/Schedule/index.d.ts +0 -7
- package/dist/modules/Schedule/index.js +2 -24
- package/dist/modules/Summary/index.js +3 -4
- package/dist/modules/index.d.ts +0 -2
- package/dist/modules/index.js +1 -3
- package/dist/plugins/request.d.ts +0 -1
- package/dist/server/index.d.ts +1 -204
- package/dist/server/index.js +928 -3658
- package/dist/server/modules/index.d.ts +0 -2
- package/dist/server/modules/index.js +0 -2
- package/dist/server/modules/order/index.d.ts +4 -120
- package/dist/server/modules/order/index.js +483 -1779
- package/dist/server/modules/order/types.d.ts +3 -32
- package/dist/server/modules/order/types.js +0 -8
- package/dist/server/modules/order/utils/filterBookings.js +3 -26
- package/dist/server/modules/order/utils/filterOrders.js +8 -23
- package/dist/server/modules/products/index.d.ts +7 -34
- package/dist/server/modules/products/index.js +317 -631
- package/dist/server/modules/resource/index.d.ts +0 -2
- package/dist/server/modules/resource/index.js +3 -29
- package/dist/server/modules/schedule/index.d.ts +4 -4
- package/dist/server/modules/schedule/index.js +88 -111
- package/dist/solution/BaseSales/index.d.ts +9 -131
- package/dist/solution/BaseSales/index.js +447 -1944
- package/dist/solution/BaseSales/types.d.ts +6 -76
- package/dist/solution/BaseSales/types.js +4 -5
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -105
- package/dist/solution/BaseSales/utils.d.ts +1 -1
- package/dist/solution/BaseSales/utils.js +21 -62
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +10 -270
- package/dist/solution/BookingTicket/index.js +237 -1772
- package/dist/solution/BookingTicket/types.d.ts +1 -118
- package/dist/solution/BookingTicket/types.js +2 -41
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
- package/dist/solution/BookingTicket/utils/bookingStatus.js +0 -70
- package/dist/solution/BookingTicket/utils/cartView.d.ts +1 -9
- package/dist/solution/BookingTicket/utils/cartView.js +7 -94
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -5
- package/dist/solution/BookingTicket/utils/scan/index.js +8 -20
- package/dist/solution/Checkout/appointmentDemo.json +1 -0
- package/dist/solution/Checkout/index.d.ts +0 -1
- package/dist/solution/Checkout/index.js +9 -10
- package/dist/solution/RegisterAndLogin/config.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +134 -241
- package/dist/solution/ScanOrder/types.d.ts +5 -9
- package/dist/solution/ScanOrder/types.js +3 -2
- package/dist/solution/ScanOrder/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +22 -84
- package/dist/solution/VenueBooking/index.d.ts +2 -5
- package/dist/solution/VenueBooking/index.js +59 -110
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +2 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/dist/types/index.d.ts +0 -10
- package/lib/model/strategy/adapter/promotion/evaluator.js +1 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/model/strategy/adapter/walletPass/utils.js +2 -3
- package/lib/modules/Cart/utils/cartProduct.js +3 -20
- package/lib/modules/Cart/utils/changePrice.js +20 -12
- package/lib/modules/Customer/index.d.ts +0 -20
- package/lib/modules/Customer/index.js +11 -64
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.js +1 -5
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/OpenData/index.d.ts +0 -8
- package/lib/modules/OpenData/index.js +5 -19
- package/lib/modules/Order/index.d.ts +18 -268
- package/lib/modules/Order/index.js +344 -2149
- package/lib/modules/Order/types.d.ts +31 -279
- package/lib/modules/Order/types.js +0 -1
- package/lib/modules/Order/utils.d.ts +5 -147
- package/lib/modules/Order/utils.js +46 -614
- package/lib/modules/Payment/index.d.ts +13 -10
- package/lib/modules/Payment/index.js +150 -18
- package/lib/modules/Payment/types.d.ts +0 -2
- package/lib/modules/Payment/utils.js +1 -2
- package/lib/modules/Payment/walletpass.js +3 -7
- package/lib/modules/ProductList/index.d.ts +12 -16
- package/lib/modules/ProductList/index.js +4 -41
- package/lib/modules/ProductList/types.d.ts +0 -14
- package/lib/modules/Quotation/index.d.ts +1 -0
- package/lib/modules/Quotation/index.js +16 -19
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +120 -136
- package/lib/modules/Rules/types.d.ts +0 -1
- package/lib/modules/SalesSummary/index.d.ts +25 -8
- package/lib/modules/SalesSummary/index.js +4 -30
- package/lib/modules/SalesSummary/types.d.ts +1 -4
- package/lib/modules/SalesSummary/utils.d.ts +25 -2
- package/lib/modules/SalesSummary/utils.js +91 -645
- package/lib/modules/Schedule/index.d.ts +0 -7
- package/lib/modules/Schedule/index.js +1 -17
- package/lib/modules/Summary/index.js +4 -5
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/index.js +1 -5
- package/lib/plugins/request.d.ts +0 -1
- package/lib/server/index.d.ts +1 -204
- package/lib/server/index.js +57 -1888
- package/lib/server/modules/index.d.ts +0 -2
- package/lib/server/modules/index.js +0 -3
- package/lib/server/modules/order/index.d.ts +4 -120
- package/lib/server/modules/order/index.js +142 -919
- package/lib/server/modules/order/types.d.ts +3 -32
- package/lib/server/modules/order/utils/filterBookings.js +5 -24
- package/lib/server/modules/order/utils/filterOrders.js +6 -15
- package/lib/server/modules/products/index.d.ts +7 -34
- package/lib/server/modules/products/index.js +54 -189
- package/lib/server/modules/resource/index.d.ts +0 -2
- package/lib/server/modules/resource/index.js +3 -27
- package/lib/server/modules/schedule/index.d.ts +4 -4
- package/lib/server/modules/schedule/index.js +40 -47
- package/lib/solution/BaseSales/index.d.ts +9 -131
- package/lib/solution/BaseSales/index.js +63 -1106
- package/lib/solution/BaseSales/types.d.ts +6 -76
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +18 -106
- package/lib/solution/BaseSales/utils.d.ts +1 -1
- package/lib/solution/BaseSales/utils.js +10 -54
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +10 -270
- package/lib/solution/BookingTicket/index.js +29 -922
- package/lib/solution/BookingTicket/types.d.ts +1 -118
- package/lib/solution/BookingTicket/types.js +0 -11
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
- package/lib/solution/BookingTicket/utils/bookingStatus.js +2 -44
- package/lib/solution/BookingTicket/utils/cartView.d.ts +1 -9
- package/lib/solution/BookingTicket/utils/cartView.js +6 -61
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -5
- package/lib/solution/BookingTicket/utils/scan/index.js +3 -17
- package/lib/solution/Checkout/appointmentDemo.json +1 -0
- package/lib/solution/Checkout/index.d.ts +0 -1
- package/lib/solution/Checkout/index.js +2 -1
- package/lib/solution/RegisterAndLogin/config.js +10 -2
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +70 -153
- package/lib/solution/ScanOrder/types.d.ts +5 -9
- package/lib/solution/ScanOrder/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +17 -83
- package/lib/solution/VenueBooking/index.d.ts +2 -5
- package/lib/solution/VenueBooking/index.js +17 -54
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +2 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/types/index.d.ts +0 -10
- package/package.json +1 -1
- package/dist/modules/BookingContext/index.d.ts +0 -48
- package/dist/modules/BookingContext/index.js +0 -566
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -284
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -145
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -218
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +0 -36
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -210
- package/dist/modules/SurchargeList/index.d.ts +0 -16
- package/dist/modules/SurchargeList/index.js +0 -162
- package/dist/modules/SurchargeList/types.d.ts +0 -11
- package/dist/modules/SurchargeList/types.js +0 -1
- package/dist/server/modules/payment/index.d.ts +0 -28
- package/dist/server/modules/payment/index.js +0 -305
- package/dist/server/modules/payment/types.d.ts +0 -9
- package/dist/server/modules/payment/types.js +0 -1
- package/dist/server/test.json +0 -713
- package/dist/server/utils/small-ticket.d.ts +0 -71
- package/dist/server/utils/small-ticket.js +0 -830
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
- package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1438
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
- package/dist/solution/BookingTicket/utils/addTimeAvailability.js +0 -95
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +0 -123
- package/dist/solution/BookingTicket/utils/exampleData.js +0 -183
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -438
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -399
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -56
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +0 -150
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +0 -78
- package/lib/modules/BookingContext/index.d.ts +0 -48
- package/lib/modules/BookingContext/index.js +0 -368
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -276
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -151
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -201
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +0 -56
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -206
- package/lib/modules/SurchargeList/index.d.ts +0 -16
- package/lib/modules/SurchargeList/index.js +0 -89
- package/lib/modules/SurchargeList/types.d.ts +0 -11
- package/lib/modules/SurchargeList/types.js +0 -17
- package/lib/server/modules/payment/index.d.ts +0 -28
- package/lib/server/modules/payment/index.js +0 -192
- package/lib/server/modules/payment/types.d.ts +0 -9
- package/lib/server/modules/payment/types.js +0 -17
- package/lib/server/test.json +0 -713
- package/lib/server/utils/small-ticket.d.ts +0 -71
- package/lib/server/utils/small-ticket.js +0 -781
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
- package/lib/solution/BaseSales/utils/cartPromotion.js +0 -992
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +0 -125
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +0 -123
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -254
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -168
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -51
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +0 -127
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +0 -85
|
@@ -28,7 +28,6 @@ var import_types = require("./types");
|
|
|
28
28
|
var import_product = require("../../utils/product");
|
|
29
29
|
var INDEXDB_STORE_NAME = "products";
|
|
30
30
|
var PRODUCT_SYNC_DEBOUNCE_MS = 1e4;
|
|
31
|
-
var PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS = 3e4;
|
|
32
31
|
var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
33
32
|
constructor(name, version) {
|
|
34
33
|
super(name, version);
|
|
@@ -45,14 +44,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
45
44
|
this.formatters = [];
|
|
46
45
|
// 是否已注册内置价格格式化器
|
|
47
46
|
this.isPriceFormatterRegistered = false;
|
|
48
|
-
this.quotationBridgeLoadedKey = "";
|
|
49
47
|
this.pendingSyncMessages = [];
|
|
50
|
-
/** 最近一次 SSE 全量拉取完成时间 */
|
|
51
|
-
this.lastServerFullFetchAtMs = 0;
|
|
52
|
-
/** 最近一次 preload 完成时间(含 IndexDB 命中) */
|
|
53
|
-
this.lastPreloadCompletedAtMs = 0;
|
|
54
|
-
/** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
|
|
55
|
-
this.productIndexDBSaveQueue = Promise.resolve();
|
|
56
48
|
}
|
|
57
49
|
async initialize(core, options) {
|
|
58
50
|
var _a;
|
|
@@ -185,7 +177,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
185
177
|
* Server 层负责传入完整 schedule 模块,Products 只负责把报价单计算结果转成价格响应形状。
|
|
186
178
|
*/
|
|
187
179
|
async setupQuotationPriceBridge(params) {
|
|
188
|
-
var _a;
|
|
180
|
+
var _a, _b, _c;
|
|
189
181
|
if (!this.core) {
|
|
190
182
|
this.logWarning("setupQuotationPriceBridge: core 尚未初始化");
|
|
191
183
|
return;
|
|
@@ -198,25 +190,15 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
198
190
|
this.quotationPriceBridge = quotation;
|
|
199
191
|
}
|
|
200
192
|
if (params.scheduleModule) {
|
|
201
|
-
const
|
|
202
|
-
|
|
193
|
+
const scheduleList = ((_c = (_b = params.scheduleModule).getScheduleList) == null ? void 0 : _c.call(_b)) || [];
|
|
194
|
+
const scheduleMap = new Map(
|
|
195
|
+
scheduleList.map((schedule) => [schedule.id, schedule])
|
|
196
|
+
);
|
|
203
197
|
this.quotationPriceBridge.setScheduleResolver((id) => {
|
|
204
|
-
var _a2,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (!hasLoadedScheduleList) {
|
|
209
|
-
const scheduleList = ((_b = (_a2 = params.scheduleModule).getScheduleList) == null ? void 0 : _b.call(_a2)) || [];
|
|
210
|
-
for (const schedule of scheduleList) {
|
|
211
|
-
scheduleCache.set(String(schedule.id), schedule);
|
|
212
|
-
}
|
|
213
|
-
hasLoadedScheduleList = true;
|
|
214
|
-
}
|
|
215
|
-
if (scheduleCache.has(scheduleId))
|
|
216
|
-
return scheduleCache.get(scheduleId);
|
|
217
|
-
const schedules = ((_d = (_c = params.scheduleModule).getScheduleListByIds) == null ? void 0 : _d.call(_c, [id])) || ((_f = (_e = params.scheduleModule).getScheduleByIds) == null ? void 0 : _f.call(_e, [id])) || [];
|
|
218
|
-
if (schedules[0])
|
|
219
|
-
scheduleCache.set(scheduleId, schedules[0]);
|
|
198
|
+
var _a2, _b2;
|
|
199
|
+
if (scheduleMap.has(id))
|
|
200
|
+
return scheduleMap.get(id);
|
|
201
|
+
const schedules = ((_b2 = (_a2 = params.scheduleModule).getScheduleByIds) == null ? void 0 : _b2.call(_a2, [id])) || [];
|
|
220
202
|
return schedules[0];
|
|
221
203
|
});
|
|
222
204
|
}
|
|
@@ -228,7 +210,8 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
228
210
|
async refreshQuotationPriceBridge(params) {
|
|
229
211
|
if (!this.quotationPriceBridge)
|
|
230
212
|
return;
|
|
231
|
-
const
|
|
213
|
+
const customerId = params && "customer_id" in params ? params.customer_id : this.quotationBridgeCustomerId;
|
|
214
|
+
const refreshKey = this.getQuotationBridgeScopeKey(customerId);
|
|
232
215
|
if (this.quotationBridgeRefreshPromise && this.quotationBridgeRefreshKey === refreshKey) {
|
|
233
216
|
await this.quotationBridgeRefreshPromise;
|
|
234
217
|
return;
|
|
@@ -238,9 +221,10 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
238
221
|
}
|
|
239
222
|
this.quotationBridgeRefreshKey = refreshKey;
|
|
240
223
|
this.quotationBridgeRefreshPromise = this.quotationPriceBridge.loadQuotations({
|
|
241
|
-
channel: this.quotationBridgeChannel
|
|
224
|
+
channel: this.quotationBridgeChannel,
|
|
225
|
+
customer_id: customerId
|
|
242
226
|
}).then(() => {
|
|
243
|
-
this.
|
|
227
|
+
this.quotationBridgeCustomerId = customerId;
|
|
244
228
|
}).finally(() => {
|
|
245
229
|
this.quotationBridgeRefreshPromise = void 0;
|
|
246
230
|
this.quotationBridgeRefreshKey = void 0;
|
|
@@ -259,12 +243,12 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
259
243
|
if (this.quotationBridgeRefreshPromise) {
|
|
260
244
|
await this.quotationBridgeRefreshPromise;
|
|
261
245
|
}
|
|
262
|
-
if (this.getQuotationBridgeScopeKey() !== this.
|
|
246
|
+
if (this.getQuotationBridgeScopeKey(customerId) !== this.getQuotationBridgeScopeKey(this.quotationBridgeCustomerId)) {
|
|
263
247
|
await this.refreshQuotationPriceBridge({ customer_id: customerId });
|
|
264
248
|
}
|
|
265
249
|
}
|
|
266
|
-
getQuotationBridgeScopeKey() {
|
|
267
|
-
return this.quotationBridgeChannel || ""
|
|
250
|
+
getQuotationBridgeScopeKey(customerId) {
|
|
251
|
+
return `${this.quotationBridgeChannel || ""}:${customerId ?? ""}`;
|
|
268
252
|
}
|
|
269
253
|
buildPriceDataFromQuotation(product, datetime, customerId) {
|
|
270
254
|
var _a;
|
|
@@ -274,11 +258,10 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
274
258
|
customer_id: customerId
|
|
275
259
|
});
|
|
276
260
|
const productPrice = quotedPrice ?? product.price;
|
|
277
|
-
const productBasePrice = quotedPrice ?? product.base_price ?? product.price ?? 0;
|
|
278
261
|
return {
|
|
279
262
|
id: product.id,
|
|
280
263
|
price: String(productPrice ?? 0),
|
|
281
|
-
base_price: String(
|
|
264
|
+
base_price: String(product.base_price ?? product.price ?? 0),
|
|
282
265
|
variant: this.buildVariantPriceData(product, datetime, customerId),
|
|
283
266
|
bundle_group: this.buildBundleGroupPriceData(product, datetime, customerId)
|
|
284
267
|
};
|
|
@@ -295,7 +278,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
295
278
|
customer_id: customerId
|
|
296
279
|
});
|
|
297
280
|
const price = quotedPrice ?? variant.price ?? product.price ?? 0;
|
|
298
|
-
const basePrice =
|
|
281
|
+
const basePrice = variant.base_price ?? variant.price ?? product.base_price ?? product.price ?? 0;
|
|
299
282
|
return {
|
|
300
283
|
id: Number(variant.id),
|
|
301
284
|
product_id: Number(variant.product_id ?? product.id),
|
|
@@ -320,7 +303,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
320
303
|
customer_id: customerId
|
|
321
304
|
});
|
|
322
305
|
const price = quotedPrice ?? item.price ?? 0;
|
|
323
|
-
const basePrice =
|
|
306
|
+
const basePrice = item.base_price ?? item.price ?? 0;
|
|
324
307
|
return {
|
|
325
308
|
id: Number(item.id),
|
|
326
309
|
product_id: Number(item.product_id ?? product.id),
|
|
@@ -721,8 +704,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
721
704
|
productCount: list.length,
|
|
722
705
|
duration: `${Math.round(performance.now() - t0)}ms`
|
|
723
706
|
});
|
|
724
|
-
await this.
|
|
725
|
-
this.lastServerFullFetchAtMs = Date.now();
|
|
707
|
+
await this.saveProductsToIndexDB(list);
|
|
726
708
|
await this.core.effects.emit(import_types.ProductsHooks.onProductsLoaded, list);
|
|
727
709
|
(0, import_product.perfMark)("loadProductsByServer", performance.now() - t0, { count: list.length });
|
|
728
710
|
return list;
|
|
@@ -821,8 +803,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
821
803
|
async loadProductsByServerHttp(params) {
|
|
822
804
|
const productList = await this.fetchProductsByHttp(params);
|
|
823
805
|
if (productList.length > 0) {
|
|
824
|
-
await this.
|
|
825
|
-
this.lastServerFullFetchAtMs = Date.now();
|
|
806
|
+
await this.saveProductsToIndexDB(productList);
|
|
826
807
|
await this.core.effects.emit(import_types.ProductsHooks.onProductsLoaded, productList);
|
|
827
808
|
}
|
|
828
809
|
return productList;
|
|
@@ -961,86 +942,33 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
961
942
|
}
|
|
962
943
|
}
|
|
963
944
|
/**
|
|
964
|
-
*
|
|
965
|
-
*
|
|
966
|
-
* @example
|
|
967
|
-
* await this.runInProductIndexDBSaveQueue(async () => {
|
|
968
|
-
* await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products)
|
|
969
|
-
* })
|
|
970
|
-
*/
|
|
971
|
-
async runInProductIndexDBSaveQueue(task) {
|
|
972
|
-
const queuedTask = this.productIndexDBSaveQueue.then(task, task);
|
|
973
|
-
this.productIndexDBSaveQueue = queuedTask.then(() => void 0, () => void 0);
|
|
974
|
-
return queuedTask;
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* 全量快照写入 IndexDB:clear + bulkUpdate,仅用于 SSE/HTTP 全量拉取。
|
|
978
|
-
*
|
|
979
|
-
* @example
|
|
980
|
-
* await this.replaceProductsSnapshotInIndexDB(list, 'loadProductsByServer')
|
|
945
|
+
* 保存商品数据到 IndexDB(平铺存储)
|
|
946
|
+
* @private
|
|
981
947
|
*/
|
|
982
|
-
async
|
|
948
|
+
async saveProductsToIndexDB(products) {
|
|
983
949
|
if (!this.dbManager) {
|
|
984
|
-
this.logWarning("
|
|
950
|
+
this.logWarning("saveProductsToIndexDB: dbManager 不可用");
|
|
985
951
|
return;
|
|
986
952
|
}
|
|
953
|
+
this.logInfo("开始保存商品数据到 IndexDB", { productCount: products.length });
|
|
987
954
|
try {
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
this.logInfo("replaceProductsSnapshotInIndexDB 完成", { source, productCount: products.length });
|
|
997
|
-
});
|
|
955
|
+
const t0 = performance.now();
|
|
956
|
+
await this.dbManager.clear(INDEXDB_STORE_NAME);
|
|
957
|
+
await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
|
|
958
|
+
(0, import_product.perfMark)("saveProductsToIndexDB", performance.now() - t0, { count: products.length });
|
|
959
|
+
console.log(
|
|
960
|
+
`[Products] 已将 ${products.length} 个商品平铺保存到 IndexDB`
|
|
961
|
+
);
|
|
962
|
+
this.logInfo("商品数据已保存到 IndexDB", { productCount: products.length });
|
|
998
963
|
} catch (error) {
|
|
999
964
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1000
|
-
|
|
1001
|
-
|
|
965
|
+
console.error("[Products] 保存数据到 IndexDB 失败:", error);
|
|
966
|
+
this.logError("保存数据到 IndexDB 失败", {
|
|
1002
967
|
productCount: products.length,
|
|
1003
968
|
error: errorMessage
|
|
1004
969
|
});
|
|
1005
970
|
}
|
|
1006
971
|
}
|
|
1007
|
-
/**
|
|
1008
|
-
* 增量 upsert 商品到 IndexDB,不清空表;用于 pubsub 批次合并后的变更商品。
|
|
1009
|
-
*
|
|
1010
|
-
* @example
|
|
1011
|
-
* await this.patchProductsInIndexDB(changedProducts, 'pubsub.processProductSyncMessages', mergeActions)
|
|
1012
|
-
*/
|
|
1013
|
-
async patchProductsInIndexDB(products, source, mergeActions = {}) {
|
|
1014
|
-
if (!this.dbManager || products.length === 0) {
|
|
1015
|
-
return;
|
|
1016
|
-
}
|
|
1017
|
-
const validProducts = products.filter((p) => (p == null ? void 0 : p.id) !== void 0 && (p == null ? void 0 : p.id) !== null);
|
|
1018
|
-
if (validProducts.length === 0) {
|
|
1019
|
-
return;
|
|
1020
|
-
}
|
|
1021
|
-
try {
|
|
1022
|
-
await this.runInProductIndexDBSaveQueue(async () => {
|
|
1023
|
-
this.logInfo("patchProductsInIndexDB 开始", { source, count: validProducts.length });
|
|
1024
|
-
const t0 = performance.now();
|
|
1025
|
-
if (typeof this.dbManager.bulkUpdate === "function") {
|
|
1026
|
-
await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, validProducts);
|
|
1027
|
-
} else if (typeof this.dbManager.update === "function") {
|
|
1028
|
-
for (const product of validProducts) {
|
|
1029
|
-
await this.dbManager.update(INDEXDB_STORE_NAME, product);
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
(0, import_product.perfMark)("patchProductsInIndexDB", performance.now() - t0, { count: validProducts.length });
|
|
1033
|
-
this.logInfo("patchProductsInIndexDB 完成", { source, count: validProducts.length });
|
|
1034
|
-
});
|
|
1035
|
-
} catch (error) {
|
|
1036
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1037
|
-
this.logError("增量保存商品到 IndexDB 失败", {
|
|
1038
|
-
source,
|
|
1039
|
-
error: errorMessage,
|
|
1040
|
-
productCount: validProducts.length
|
|
1041
|
-
});
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
972
|
/**
|
|
1045
973
|
* 同步更新商品 Map 缓存
|
|
1046
974
|
* 将 list 中的商品同步到 map,以 id 为 key
|
|
@@ -1085,7 +1013,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1085
1013
|
duration: `${Math.round(performance.now() - tTotal)}ms`,
|
|
1086
1014
|
source: "IndexDB"
|
|
1087
1015
|
});
|
|
1088
|
-
this.lastPreloadCompletedAtMs = Date.now();
|
|
1089
1016
|
return;
|
|
1090
1017
|
}
|
|
1091
1018
|
console.log("[Products] IndexDB 中没有缓存数据,从服务器加载...");
|
|
@@ -1113,7 +1040,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1113
1040
|
duration: `${Math.round(performance.now() - tTotal)}ms`,
|
|
1114
1041
|
source: "Server"
|
|
1115
1042
|
});
|
|
1116
|
-
this.lastPreloadCompletedAtMs = Date.now();
|
|
1117
1043
|
} else {
|
|
1118
1044
|
(0, import_product.perfMark)("preload(empty)", performance.now() - tTotal, { source: "empty" });
|
|
1119
1045
|
this.logWarning("预加载完成但未获取到数据", {
|
|
@@ -1170,6 +1096,10 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1170
1096
|
this.productDataSource.run({
|
|
1171
1097
|
pubsub: {
|
|
1172
1098
|
callback: (res) => {
|
|
1099
|
+
console.log("sse_products_callback", res);
|
|
1100
|
+
this.logInfo("sse_products_callback: 收到同步消息", {
|
|
1101
|
+
data: res == null ? void 0 : res.data
|
|
1102
|
+
});
|
|
1173
1103
|
if (!(res == null ? void 0 : res.data))
|
|
1174
1104
|
return;
|
|
1175
1105
|
const data = res.data;
|
|
@@ -1265,50 +1195,19 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1265
1195
|
if (uniqueDeleteIds.length > 0) {
|
|
1266
1196
|
await this.removeProductsByIds(uniqueDeleteIds);
|
|
1267
1197
|
}
|
|
1268
|
-
const patchProductMap = /* @__PURE__ */ new Map();
|
|
1269
|
-
const patchMergeActions = {};
|
|
1270
|
-
let storeMutated = uniqueDeleteIds.length > 0;
|
|
1271
1198
|
if (bodyUpdates.size > 0) {
|
|
1272
|
-
|
|
1273
|
-
skipIndexDB: true,
|
|
1274
|
-
skipEmit: true
|
|
1275
|
-
});
|
|
1276
|
-
for (const product of bodyResult.changedProducts) {
|
|
1277
|
-
patchProductMap.set(product.id, product);
|
|
1278
|
-
patchMergeActions[product.id] = bodyResult.mergeActions[product.id];
|
|
1279
|
-
}
|
|
1280
|
-
storeMutated = true;
|
|
1199
|
+
await this.applyBodyUpdatesToStore(bodyUpdates);
|
|
1281
1200
|
}
|
|
1282
|
-
let freshProducts = [];
|
|
1283
1201
|
if (uniqueSSEIds.length > 0) {
|
|
1284
|
-
freshProducts = await this.fetchProductsBySSE(uniqueSSEIds);
|
|
1202
|
+
const freshProducts = await this.fetchProductsBySSE(uniqueSSEIds);
|
|
1285
1203
|
if (freshProducts.length > 0) {
|
|
1286
|
-
|
|
1287
|
-
skipIndexDB: true,
|
|
1288
|
-
skipEmit: true
|
|
1289
|
-
});
|
|
1290
|
-
for (const product of mergeResult.changedProducts) {
|
|
1291
|
-
patchProductMap.set(product.id, product);
|
|
1292
|
-
patchMergeActions[product.id] = mergeResult.mergeActions[product.id];
|
|
1293
|
-
}
|
|
1294
|
-
storeMutated = true;
|
|
1204
|
+
await this.mergeProductsToStore(freshProducts);
|
|
1295
1205
|
}
|
|
1296
1206
|
this.logInfo("processProductSyncMessages: SSE 增量更新完成123", {
|
|
1297
1207
|
requestedCount: uniqueSSEIds.length,
|
|
1298
1208
|
receivedCount: freshProducts.length
|
|
1299
1209
|
});
|
|
1300
1210
|
}
|
|
1301
|
-
const patchProducts = [...patchProductMap.values()];
|
|
1302
|
-
if (patchProducts.length > 0) {
|
|
1303
|
-
await this.patchProductsInIndexDB(
|
|
1304
|
-
patchProducts,
|
|
1305
|
-
"pubsub.processProductSyncMessages",
|
|
1306
|
-
patchMergeActions
|
|
1307
|
-
);
|
|
1308
|
-
}
|
|
1309
|
-
if (storeMutated) {
|
|
1310
|
-
this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
|
|
1311
|
-
}
|
|
1312
1211
|
const allChangedIds = [.../* @__PURE__ */ new Set([
|
|
1313
1212
|
...Array.from(bodyUpdates.keys()),
|
|
1314
1213
|
...uniqueSSEIds,
|
|
@@ -1372,26 +1271,19 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1372
1271
|
/**
|
|
1373
1272
|
* 将 body 完整数据直接覆盖到本地 store(不调用报价单接口)
|
|
1374
1273
|
* 已存在的 → 直接替换;不存在的 → 追加
|
|
1375
|
-
*
|
|
1376
|
-
*
|
|
1377
|
-
* await this.applyBodyUpdatesToStore(bodyUpdates, { skipIndexDB: true })
|
|
1274
|
+
* 同时更新 Map 缓存、IndexDB,触发 onProductsChanged
|
|
1275
|
+
* 价格缓存由 processProductSyncMessages 末尾统一清除
|
|
1378
1276
|
*/
|
|
1379
|
-
async applyBodyUpdatesToStore(bodyUpdates
|
|
1380
|
-
const changedProductIds = [...bodyUpdates.keys()];
|
|
1277
|
+
async applyBodyUpdatesToStore(bodyUpdates) {
|
|
1381
1278
|
this.logInfo("applyBodyUpdatesToStore: 开始", { count: bodyUpdates.size });
|
|
1382
1279
|
let updatedCount = 0;
|
|
1383
1280
|
let newCount = 0;
|
|
1384
1281
|
const appliedIds = /* @__PURE__ */ new Set();
|
|
1385
|
-
const mergeActions = {};
|
|
1386
|
-
const changedProducts = [];
|
|
1387
1282
|
this.store.list = this.store.list.map((p) => {
|
|
1388
1283
|
if (bodyUpdates.has(p.id)) {
|
|
1389
1284
|
updatedCount++;
|
|
1390
1285
|
appliedIds.add(p.id);
|
|
1391
|
-
|
|
1392
|
-
const next = bodyUpdates.get(p.id);
|
|
1393
|
-
changedProducts.push(next);
|
|
1394
|
-
return next;
|
|
1286
|
+
return bodyUpdates.get(p.id);
|
|
1395
1287
|
}
|
|
1396
1288
|
return p;
|
|
1397
1289
|
});
|
|
@@ -1399,44 +1291,31 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1399
1291
|
if (!appliedIds.has(id)) {
|
|
1400
1292
|
this.store.list.push(body);
|
|
1401
1293
|
newCount++;
|
|
1402
|
-
mergeActions[id] = "insert";
|
|
1403
|
-
changedProducts.push(body);
|
|
1404
1294
|
}
|
|
1405
1295
|
}
|
|
1406
1296
|
this.syncProductsMap();
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
}
|
|
1410
|
-
if (!(options == null ? void 0 : options.skipEmit)) {
|
|
1411
|
-
this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
|
|
1412
|
-
}
|
|
1297
|
+
await this.saveProductsToIndexDB(this.store.list);
|
|
1298
|
+
this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
|
|
1413
1299
|
this.logInfo("applyBodyUpdatesToStore: 完成", {
|
|
1414
1300
|
updatedCount,
|
|
1415
1301
|
newCount,
|
|
1416
1302
|
totalCount: this.store.list.length
|
|
1417
1303
|
});
|
|
1418
|
-
return { changedProducts, mergeActions, updatedCount, newCount };
|
|
1419
1304
|
}
|
|
1420
1305
|
/**
|
|
1421
1306
|
* 将增量拉取的商品合并到 store
|
|
1422
1307
|
* 已存在的 → 替换;新的 → 追加
|
|
1423
|
-
*
|
|
1424
|
-
* @example
|
|
1425
|
-
* await this.mergeProductsToStore(freshProducts, { skipIndexDB: true })
|
|
1308
|
+
* 同时更新 store.map、IndexDB,触发 onProductsChanged
|
|
1426
1309
|
*/
|
|
1427
|
-
async mergeProductsToStore(freshProducts
|
|
1310
|
+
async mergeProductsToStore(freshProducts) {
|
|
1428
1311
|
const freshMap = /* @__PURE__ */ new Map();
|
|
1429
1312
|
for (const p of freshProducts) {
|
|
1430
1313
|
freshMap.set(p.id, p);
|
|
1431
1314
|
}
|
|
1432
|
-
const mergeActions = {};
|
|
1433
|
-
const changedProducts = [];
|
|
1434
1315
|
const updatedList = this.store.list.map((p) => {
|
|
1435
1316
|
if (freshMap.has(p.id)) {
|
|
1436
1317
|
const fresh = freshMap.get(p.id);
|
|
1437
1318
|
freshMap.delete(p.id);
|
|
1438
|
-
mergeActions[p.id] = "update";
|
|
1439
|
-
changedProducts.push(fresh);
|
|
1440
1319
|
return fresh;
|
|
1441
1320
|
}
|
|
1442
1321
|
return p;
|
|
@@ -1444,25 +1323,17 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1444
1323
|
const newCount = freshMap.size;
|
|
1445
1324
|
for (const p of freshMap.values()) {
|
|
1446
1325
|
updatedList.push(p);
|
|
1447
|
-
mergeActions[p.id] = "insert";
|
|
1448
|
-
changedProducts.push(p);
|
|
1449
1326
|
}
|
|
1450
1327
|
const updatedCount = freshProducts.length - newCount;
|
|
1451
|
-
const changedProductIds = freshProducts.map((p) => p.id);
|
|
1452
1328
|
this.store.list = updatedList;
|
|
1453
1329
|
this.syncProductsMap();
|
|
1454
|
-
|
|
1455
|
-
await this.patchProductsInIndexDB(changedProducts, "pubsub.mergeProductsToStore", mergeActions);
|
|
1456
|
-
}
|
|
1457
|
-
if (!(options == null ? void 0 : options.skipEmit)) {
|
|
1458
|
-
this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
|
|
1459
|
-
}
|
|
1330
|
+
await this.saveProductsToIndexDB(this.store.list);
|
|
1460
1331
|
this.logInfo("mergeProductsToStore: 合并完成", {
|
|
1461
1332
|
updatedCount,
|
|
1462
1333
|
newCount,
|
|
1463
1334
|
totalCount: this.store.list.length
|
|
1464
1335
|
});
|
|
1465
|
-
|
|
1336
|
+
this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
|
|
1466
1337
|
}
|
|
1467
1338
|
/**
|
|
1468
1339
|
* 静默全量刷新:后台重新拉取全量 SSE 数据并更新本地
|
|
@@ -1471,12 +1342,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1471
1342
|
*/
|
|
1472
1343
|
async silentRefresh() {
|
|
1473
1344
|
const t0 = performance.now();
|
|
1474
|
-
const now = Date.now();
|
|
1475
|
-
const elapsedSincePreload = now - this.lastPreloadCompletedAtMs;
|
|
1476
|
-
const elapsedSinceFullFetch = now - this.lastServerFullFetchAtMs;
|
|
1477
|
-
if (this.lastPreloadCompletedAtMs > 0 && elapsedSincePreload < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS || this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetch < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS) {
|
|
1478
|
-
return this.store.list;
|
|
1479
|
-
}
|
|
1480
1345
|
this.logInfo("silentRefresh 开始");
|
|
1481
1346
|
try {
|
|
1482
1347
|
const products = await this.loadProductsByServer();
|
|
@@ -61,8 +61,6 @@ export declare class ResourceModule extends BaseModule implements Module {
|
|
|
61
61
|
*/
|
|
62
62
|
clear(): Promise<void>;
|
|
63
63
|
private attachBookingsToResource;
|
|
64
|
-
private normalizeIntegerIdValue;
|
|
65
|
-
private normalizeResourceIdFields;
|
|
66
64
|
private normalizeResource;
|
|
67
65
|
private safeEmit;
|
|
68
66
|
private syncResourcesMap;
|
|
@@ -268,35 +268,11 @@ var ResourceModule = class extends import_BaseModule.BaseModule {
|
|
|
268
268
|
bookings: this.getBookingsByResourceId(resource.id)
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
|
-
normalizeIntegerIdValue(value) {
|
|
272
|
-
if (typeof value !== "string")
|
|
273
|
-
return value;
|
|
274
|
-
const matched = value.match(/^(-?\d+)\.0+$/);
|
|
275
|
-
if (!matched)
|
|
276
|
-
return value;
|
|
277
|
-
return matched[1];
|
|
278
|
-
}
|
|
279
|
-
normalizeResourceIdFields(resource) {
|
|
280
|
-
resource.id = this.normalizeIntegerIdValue(resource.id);
|
|
281
|
-
if (resource.form_record_id !== void 0) {
|
|
282
|
-
resource.form_record_id = this.normalizeIntegerIdValue(resource.form_record_id);
|
|
283
|
-
}
|
|
284
|
-
if (resource.form_id !== void 0) {
|
|
285
|
-
resource.form_id = this.normalizeIntegerIdValue(resource.form_id);
|
|
286
|
-
}
|
|
287
|
-
if (resource.resource_form_id !== void 0) {
|
|
288
|
-
resource.resource_form_id = this.normalizeIntegerIdValue(resource.resource_form_id);
|
|
289
|
-
}
|
|
290
|
-
if (resource.resource_id !== void 0) {
|
|
291
|
-
resource.resource_id = this.normalizeIntegerIdValue(resource.resource_id);
|
|
292
|
-
}
|
|
293
|
-
return resource;
|
|
294
|
-
}
|
|
295
271
|
normalizeResource(resource) {
|
|
296
|
-
const normalized =
|
|
272
|
+
const normalized = {
|
|
297
273
|
...resource,
|
|
298
|
-
id:
|
|
299
|
-
}
|
|
274
|
+
id: (resource == null ? void 0 : resource.id) ?? (resource == null ? void 0 : resource.form_record_id) ?? ""
|
|
275
|
+
};
|
|
300
276
|
if (normalized.form_record_id === void 0 && normalized.id !== "") {
|
|
301
277
|
normalized.form_record_id = normalized.id;
|
|
302
278
|
}
|
|
@@ -64,15 +64,15 @@ export declare class ScheduleModuleEx extends BaseModule implements Module, Sche
|
|
|
64
64
|
*/
|
|
65
65
|
getDateIsInSchedule(date: string, scheduleList: (ScheduleItem | number)[]): boolean;
|
|
66
66
|
/**
|
|
67
|
-
* 从
|
|
67
|
+
* 从 IndexDB 加载日程数据
|
|
68
68
|
* @private
|
|
69
69
|
*/
|
|
70
|
-
private
|
|
70
|
+
private loadScheduleFromIndexDB;
|
|
71
71
|
/**
|
|
72
|
-
* 保存日程数据到
|
|
72
|
+
* 保存日程数据到 IndexDB
|
|
73
73
|
* @private
|
|
74
74
|
*/
|
|
75
|
-
private
|
|
75
|
+
private saveScheduleToIndexDB;
|
|
76
76
|
/**
|
|
77
77
|
* 预加载模块数据(统一接口)
|
|
78
78
|
* 在模块注册后自动调用
|