@pisell/pisellos 2.3.73 → 2.3.75
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/core/index.d.ts +7 -0
- package/dist/core/index.js +111 -71
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +0 -1
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.js +2 -4
- package/dist/modules/OpenData/index.js +0 -2
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +36 -64
- package/dist/modules/Payment/index.js +97 -162
- package/dist/modules/Quotation/index.d.ts +6 -0
- package/dist/modules/Quotation/index.js +75 -19
- package/dist/modules/Rules/index.js +1 -4
- package/dist/modules/Schedule/index.js +0 -1
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/plugins/request.d.ts +1 -0
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.d.ts +8 -2
- package/dist/server/index.js +303 -269
- package/dist/server/modules/floor-plan/index.d.ts +4 -0
- package/dist/server/modules/floor-plan/index.js +240 -98
- package/dist/server/modules/menu/index.js +75 -59
- package/dist/server/modules/order/index.d.ts +17 -7
- package/dist/server/modules/order/index.js +421 -211
- package/dist/server/modules/products/index.d.ts +8 -2
- package/dist/server/modules/products/index.js +191 -117
- package/dist/server/modules/quotation/index.js +29 -38
- package/dist/server/modules/resource/index.js +24 -17
- package/dist/server/modules/schedule/index.js +27 -35
- package/dist/server/utils/product.js +0 -1
- package/dist/solution/BaseSales/index.js +38 -41
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.js +0 -2
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
- package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.js +177 -252
- package/dist/solution/Checkout/utils/index.js +4 -16
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/ScanOrder/index.js +50 -60
- package/dist/solution/ShopDiscount/index.js +2 -7
- package/dist/solution/VenueBooking/index.js +45 -55
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.d.ts +7 -0
- package/lib/core/index.js +149 -131
- package/lib/effects/index.js +46 -57
- package/lib/index.js +82 -49
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
- package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
- package/lib/model/strategy/adapter/promotion/examples.js +222 -234
- package/lib/model/strategy/adapter/promotion/index.js +1 -0
- package/lib/model/strategy/adapter/promotion/type.js +243 -36
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.js +23 -42
- package/lib/modules/BookingContext/index.js +158 -136
- package/lib/modules/BookingContext/types.js +46 -32
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
- package/lib/modules/BookingContext/utils/flexible.js +38 -55
- package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
- package/lib/modules/BookingContext/utils/index.js +124 -41
- package/lib/modules/BookingContext/utils/noResource.js +58 -70
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
- package/lib/modules/BookingContext/utils/productExtend.js +202 -155
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
- package/lib/modules/BookingContext/utils/resources.js +209 -167
- package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
- package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +321 -251
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +70 -78
- package/lib/modules/Cart/utils/changePrice.js +22 -50
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.js +235 -172
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.js +122 -127
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.js +70 -76
- package/lib/modules/OpenData/types.js +4 -16
- package/lib/modules/OpenData/utils.js +44 -78
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +1713 -2118
- package/lib/modules/Order/payment-utils.js +77 -120
- package/lib/modules/Order/types.js +88 -35
- package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
- package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
- package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
- package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
- package/lib/modules/Order/utils.js +814 -647
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.js +532 -399
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.js +230 -108
- package/lib/modules/Payment/utils.js +52 -51
- package/lib/modules/Payment/walletpass.js +485 -660
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.js +113 -123
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.d.ts +6 -0
- package/lib/modules/Quotation/index.js +110 -103
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/ResourcePlanner/index.js +25 -23
- package/lib/modules/ResourcePlanner/localClock.js +54 -119
- package/lib/modules/ResourcePlanner/planner.js +589 -770
- package/lib/modules/ResourcePlanner/types.js +10 -29
- package/lib/modules/Rules/index.js +1218 -959
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +85 -90
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +355 -430
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
- package/lib/modules/Schedule/index.js +100 -114
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -71
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +773 -418
- package/lib/modules/SurchargeList/index.js +46 -60
- package/lib/modules/SurchargeList/types.js +4 -16
- package/lib/modules/index.js +245 -63
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.d.ts +1 -0
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.d.ts +8 -2
- package/lib/server/index.js +3083 -2663
- package/lib/server/modules/floor-plan/index.d.ts +4 -0
- package/lib/server/modules/floor-plan/index.js +159 -127
- package/lib/server/modules/floor-plan/types.js +15 -30
- package/lib/server/modules/index.js +106 -68
- package/lib/server/modules/menu/index.js +170 -124
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.d.ts +17 -7
- package/lib/server/modules/order/index.js +916 -977
- package/lib/server/modules/order/types.js +122 -33
- package/lib/server/modules/order/utils/filterBookings.js +219 -194
- package/lib/server/modules/order/utils/filterOrders.js +118 -92
- package/lib/server/modules/payment/index.js +59 -83
- package/lib/server/modules/payment/types.js +4 -16
- package/lib/server/modules/products/index.d.ts +8 -2
- package/lib/server/modules/products/index.js +656 -471
- package/lib/server/modules/products/types.js +44 -34
- package/lib/server/modules/quotation/index.js +137 -172
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.js +225 -186
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.js +135 -123
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +196 -139
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/small-ticket.js +479 -456
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.js +1186 -1410
- package/lib/solution/BaseSales/types.js +42 -38
- package/lib/solution/BaseSales/utils/cartPromotion.js +642 -498
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
- package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
- package/lib/solution/BaseSales/utils.js +158 -143
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1527 -1340
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.js +607 -522
- package/lib/solution/BookingTicket/types.js +99 -77
- package/lib/solution/BookingTicket/utils/addProductDecision.js +226 -189
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
- package/lib/solution/BookingTicket/utils/cartView.js +114 -99
- package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.js +1451 -1158
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +228 -156
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +493 -460
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.js +328 -324
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.js +832 -864
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.js +409 -374
- package/lib/solution/ShopDiscount/index.js +226 -232
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +300 -172
- package/lib/solution/UnifiedBookingSales/index.js +1035 -1201
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
- package/lib/solution/UnifiedBookingSales/types.js +10 -32
- package/lib/solution/VenueBooking/index.js +811 -879
- package/lib/solution/VenueBooking/types.js +19 -39
- package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
- package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.js +124 -41
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.js +4 -16
- package/lib/utils/payment-number.js +26 -46
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
|
@@ -78,6 +78,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
78
78
|
_defineProperty(_assertThisInitialized(_this), "quotationBridgeLoadedKey", '');
|
|
79
79
|
_defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshPromise", void 0);
|
|
80
80
|
_defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshKey", void 0);
|
|
81
|
+
_defineProperty(_assertThisInitialized(_this), "quotationBridgeUpdatedCallback", void 0);
|
|
81
82
|
_defineProperty(_assertThisInitialized(_this), "quotationScheduleCache", new Map());
|
|
82
83
|
_defineProperty(_assertThisInitialized(_this), "quotationScheduleCacheSource", null);
|
|
83
84
|
_defineProperty(_assertThisInitialized(_this), "quotationScheduleCacheLoaded", false);
|
|
@@ -124,9 +125,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
124
125
|
app = appPlugin.getApp();
|
|
125
126
|
this.dbManager = app.dbManager;
|
|
126
127
|
this.logger = app.logger;
|
|
127
|
-
if (this.dbManager) {
|
|
128
|
-
console.log('[Products] IndexDB Manager 已初始化');
|
|
129
|
-
} else {
|
|
128
|
+
if (this.dbManager) {} else {
|
|
130
129
|
console.warn('[Products] IndexDB Manager 未找到');
|
|
131
130
|
}
|
|
132
131
|
}
|
|
@@ -290,7 +289,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
290
289
|
value: (function () {
|
|
291
290
|
var _setupQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
292
291
|
var _this$otherParams,
|
|
293
|
-
_this3 = this
|
|
292
|
+
_this3 = this,
|
|
293
|
+
_this$quotationPriceB,
|
|
294
|
+
_this$quotationPriceB2;
|
|
294
295
|
var channel, quotation;
|
|
295
296
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
296
297
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -351,11 +352,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
351
352
|
return schedules[0];
|
|
352
353
|
});
|
|
353
354
|
}
|
|
354
|
-
|
|
355
|
+
if (params.onQuotationUpdated) {
|
|
356
|
+
this.quotationBridgeUpdatedCallback = params.onQuotationUpdated;
|
|
357
|
+
}
|
|
358
|
+
(_this$quotationPriceB = (_this$quotationPriceB2 = this.quotationPriceBridge).setQuotationListUpdatedListener) === null || _this$quotationPriceB === void 0 || _this$quotationPriceB.call(_this$quotationPriceB2, function () {
|
|
359
|
+
var _this3$quotationBridg;
|
|
360
|
+
_this3.quotationBridgeLoadedKey = _this3.getQuotationBridgeScopeKey();
|
|
361
|
+
_this3.clearPriceCache();
|
|
362
|
+
(_this3$quotationBridg = _this3.quotationBridgeUpdatedCallback) === null || _this3$quotationBridg === void 0 || _this3$quotationBridg.call(_this3);
|
|
363
|
+
});
|
|
364
|
+
_context3.next = 15;
|
|
355
365
|
return this.refreshQuotationPriceBridge({
|
|
356
366
|
customer_id: params.customer_id
|
|
357
367
|
});
|
|
358
|
-
case
|
|
368
|
+
case 15:
|
|
359
369
|
case "end":
|
|
360
370
|
return _context3.stop();
|
|
361
371
|
}
|
|
@@ -847,14 +857,13 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
847
857
|
_context7.prev = 29;
|
|
848
858
|
_context7.t0 = _context7["catch"](4);
|
|
849
859
|
errorMessage = _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0);
|
|
850
|
-
console.log("[ProductsModule] \uD83C\uDF10 ERROR", _context7.t0);
|
|
851
860
|
this.logError('prepareProductsWithPrice 处理失败', {
|
|
852
861
|
schedule_date: schedule_date,
|
|
853
862
|
error: errorMessage
|
|
854
863
|
});
|
|
855
|
-
case
|
|
864
|
+
case 33:
|
|
856
865
|
return _context7.abrupt("return", []);
|
|
857
|
-
case
|
|
866
|
+
case 34:
|
|
858
867
|
case "end":
|
|
859
868
|
return _context7.stop();
|
|
860
869
|
}
|
|
@@ -1083,10 +1092,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1083
1092
|
// 创建 legacy 报价单格式化器
|
|
1084
1093
|
var legacyPriceFormatter = function legacyPriceFormatter(products, context) {
|
|
1085
1094
|
if (!context.priceData || context.priceData.length === 0) {
|
|
1086
|
-
console.log('[ProductsModule] 💰 没有价格数据,跳过 legacy 报价单价格应用');
|
|
1087
1095
|
return products;
|
|
1088
1096
|
}
|
|
1089
|
-
console.log("[ProductsModule] \uD83D\uDCB0 \u5E94\u7528 legacy \u62A5\u4EF7\u5355\u4EF7\u683C\u5230 ".concat(products.length, " \u4E2A\u5546\u54C1"));
|
|
1090
1097
|
return applyPriceDataToProducts(products, context.priceData);
|
|
1091
1098
|
};
|
|
1092
1099
|
var i18nFormatter = function i18nFormatter(products, context) {
|
|
@@ -1102,7 +1109,6 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1102
1109
|
this.formatters.push(i18nFormatter);
|
|
1103
1110
|
this.formatters.push(detailValueFormatter);
|
|
1104
1111
|
this.isBuiltinFormatterRegistered = true;
|
|
1105
|
-
console.log('[ProductsModule] ✅ 内置商品格式化器已注册(智能定价优先)');
|
|
1106
1112
|
}
|
|
1107
1113
|
|
|
1108
1114
|
/**
|
|
@@ -1150,11 +1156,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1150
1156
|
// 插入到内置智能定价格式化器之后;legacy 报价单启用时需跳过它。
|
|
1151
1157
|
var insertIndex = this.isBuiltinFormatterRegistered ? this.isLegacyPriceFormatterEnabled ? 2 : 1 : 0;
|
|
1152
1158
|
this.formatters.splice(insertIndex, 0, formatter);
|
|
1153
|
-
console.log("[ProductsModule] \uD83D\uDCCC \u5DF2\u5728\u4F4D\u7F6E ".concat(insertIndex + 1, " \u63D2\u5165\u683C\u5F0F\u5316\u5668\uFF0C\u5F53\u524D\u5171 ").concat(this.formatters.length, " \u4E2A"));
|
|
1154
1159
|
} else {
|
|
1155
1160
|
// 追加到末尾
|
|
1156
1161
|
this.formatters.push(formatter);
|
|
1157
|
-
console.log("[ProductsModule] \uD83D\uDCCC \u5DF2\u6CE8\u518C\u683C\u5F0F\u5316\u5668\uFF0C\u5F53\u524D\u5171 ".concat(this.formatters.length, " \u4E2A"));
|
|
1158
1162
|
}
|
|
1159
1163
|
}
|
|
1160
1164
|
|
|
@@ -1170,11 +1174,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1170
1174
|
// 保留 legacy 兜底(如果启用)和智能定价格式化器。
|
|
1171
1175
|
var builtinCount = this.isLegacyPriceFormatterEnabled ? 2 : 1;
|
|
1172
1176
|
this.formatters = this.formatters.slice(0, builtinCount);
|
|
1173
|
-
console.log('[ProductsModule] 🧹 已清空自定义格式化器,保留内置智能定价格式化器');
|
|
1174
1177
|
} else {
|
|
1175
1178
|
this.formatters = [];
|
|
1176
1179
|
this.isBuiltinFormatterRegistered = false;
|
|
1177
|
-
console.log('[ProductsModule] 🧹 已清空所有格式化器');
|
|
1178
1180
|
}
|
|
1179
1181
|
}
|
|
1180
1182
|
|
|
@@ -1190,7 +1192,6 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1190
1192
|
var keys = Array.from(this.productsPriceCache.keys());
|
|
1191
1193
|
var oldestKey = keys[0];
|
|
1192
1194
|
this.productsPriceCache.delete(oldestKey);
|
|
1193
|
-
console.log("[ProductsModule] \uD83E\uDDF9 \u6E05\u7406\u8FC7\u671F\u5546\u54C1\u4EF7\u683C\u7F13\u5B58: ".concat(oldestKey));
|
|
1194
1195
|
}
|
|
1195
1196
|
}
|
|
1196
1197
|
|
|
@@ -1202,7 +1203,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1202
1203
|
key: "clearPriceCache",
|
|
1203
1204
|
value: function clearPriceCache() {
|
|
1204
1205
|
this.productsPriceCache.clear();
|
|
1205
|
-
|
|
1206
|
+
this.quotationScheduleCache.clear();
|
|
1207
|
+
this.quotationScheduleCacheLoaded = false;
|
|
1206
1208
|
}
|
|
1207
1209
|
|
|
1208
1210
|
/**
|
|
@@ -1212,62 +1214,76 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1212
1214
|
key: "loadProductsByServer",
|
|
1213
1215
|
value: (function () {
|
|
1214
1216
|
var _loadProductsByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
1215
|
-
var
|
|
1217
|
+
var options,
|
|
1218
|
+
trigger,
|
|
1219
|
+
t0,
|
|
1220
|
+
tSSE,
|
|
1221
|
+
productList,
|
|
1222
|
+
list,
|
|
1223
|
+
duration,
|
|
1224
|
+
errorMessage,
|
|
1225
|
+
_args9 = arguments;
|
|
1216
1226
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1217
1227
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1218
1228
|
case 0:
|
|
1229
|
+
options = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
|
|
1219
1230
|
if (this.productDataSource) {
|
|
1220
|
-
_context9.next =
|
|
1231
|
+
_context9.next = 4;
|
|
1221
1232
|
break;
|
|
1222
1233
|
}
|
|
1223
1234
|
this.logWarning('loadProductsByServer: ProductDataSource 不可用');
|
|
1224
1235
|
return _context9.abrupt("return", []);
|
|
1225
|
-
case
|
|
1226
|
-
|
|
1236
|
+
case 4:
|
|
1237
|
+
trigger = options.trigger || 'unknown';
|
|
1238
|
+
this.logInfo('开始通过 DataSource SSE 加载商品列表', {
|
|
1239
|
+
trigger: trigger
|
|
1240
|
+
});
|
|
1227
1241
|
t0 = performance.now();
|
|
1228
|
-
_context9.prev =
|
|
1242
|
+
_context9.prev = 7;
|
|
1229
1243
|
tSSE = performance.now();
|
|
1230
|
-
_context9.next =
|
|
1244
|
+
_context9.next = 11;
|
|
1231
1245
|
return this.productDataSource.run({
|
|
1232
1246
|
sse: {}
|
|
1233
1247
|
});
|
|
1234
|
-
case
|
|
1248
|
+
case 11:
|
|
1235
1249
|
productList = _context9.sent;
|
|
1236
1250
|
list = productList || [];
|
|
1237
1251
|
perfMark('loadProductsByServer.SSE', performance.now() - tSSE, {
|
|
1238
1252
|
count: list.length
|
|
1239
1253
|
});
|
|
1240
1254
|
this.logInfo('通过 DataSource SSE 加载商品列表成功', {
|
|
1255
|
+
trigger: trigger,
|
|
1241
1256
|
productCount: list.length,
|
|
1242
1257
|
duration: "".concat(Math.round(performance.now() - t0), "ms")
|
|
1243
1258
|
});
|
|
1244
|
-
_context9.next =
|
|
1259
|
+
_context9.next = 17;
|
|
1245
1260
|
return this.replaceProductsSnapshotInIndexDB(list, 'loadProductsByServer');
|
|
1246
|
-
case
|
|
1261
|
+
case 17:
|
|
1247
1262
|
this.lastServerFullFetchAtMs = Date.now();
|
|
1248
|
-
_context9.next =
|
|
1263
|
+
_context9.next = 20;
|
|
1249
1264
|
return this.core.effects.emit(ProductsHooks.onProductsLoaded, list);
|
|
1250
|
-
case
|
|
1265
|
+
case 20:
|
|
1251
1266
|
perfMark('loadProductsByServer', performance.now() - t0, {
|
|
1252
1267
|
count: list.length
|
|
1253
1268
|
});
|
|
1254
1269
|
return _context9.abrupt("return", list);
|
|
1255
|
-
case
|
|
1256
|
-
_context9.prev =
|
|
1257
|
-
_context9.t0 = _context9["catch"](
|
|
1270
|
+
case 24:
|
|
1271
|
+
_context9.prev = 24;
|
|
1272
|
+
_context9.t0 = _context9["catch"](7);
|
|
1258
1273
|
duration = Math.round(performance.now() - t0);
|
|
1259
1274
|
errorMessage = _context9.t0 instanceof Error ? _context9.t0.message : String(_context9.t0);
|
|
1260
1275
|
console.error('[Products] 加载商品数据失败:', _context9.t0);
|
|
1261
1276
|
this.logError('通过 DataSource SSE 加载商品列表失败', {
|
|
1277
|
+
trigger: trigger,
|
|
1262
1278
|
duration: "".concat(duration, "ms"),
|
|
1263
1279
|
error: errorMessage
|
|
1264
1280
|
});
|
|
1265
1281
|
return _context9.abrupt("return", []);
|
|
1266
|
-
case
|
|
1282
|
+
case 31:
|
|
1267
1283
|
case "end":
|
|
1268
1284
|
return _context9.stop();
|
|
1269
1285
|
}
|
|
1270
|
-
}, _callee9, this, [[
|
|
1286
|
+
}, _callee9, this, [[7, 24]]);
|
|
1271
1287
|
}));
|
|
1272
1288
|
function loadProductsByServer() {
|
|
1273
1289
|
return _loadProductsByServer.apply(this, arguments);
|
|
@@ -1664,7 +1680,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1664
1680
|
tTotal = performance.now();
|
|
1665
1681
|
this.logInfo('refreshProducts 开始');
|
|
1666
1682
|
_context16.next = 4;
|
|
1667
|
-
return this.loadProductsByServer(
|
|
1683
|
+
return this.loadProductsByServer({
|
|
1684
|
+
trigger: 'product_sync'
|
|
1685
|
+
});
|
|
1668
1686
|
case 4:
|
|
1669
1687
|
products = _context16.sent;
|
|
1670
1688
|
if (products && products.length > 0) {
|
|
@@ -1714,33 +1732,31 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1714
1732
|
|
|
1715
1733
|
// 同时清空 IndexDB 中的所有数据(包括商品和元数据)
|
|
1716
1734
|
if (!this.dbManager) {
|
|
1717
|
-
_context17.next =
|
|
1735
|
+
_context17.next = 15;
|
|
1718
1736
|
break;
|
|
1719
1737
|
}
|
|
1720
1738
|
_context17.prev = 4;
|
|
1721
1739
|
_context17.next = 7;
|
|
1722
1740
|
return this.dbManager.clear(INDEXDB_STORE_NAME);
|
|
1723
1741
|
case 7:
|
|
1724
|
-
console.log('[Products] IndexDB 缓存已清空');
|
|
1725
1742
|
this.logInfo('IndexDB 缓存已清空');
|
|
1726
|
-
_context17.next =
|
|
1743
|
+
_context17.next = 15;
|
|
1727
1744
|
break;
|
|
1728
|
-
case
|
|
1729
|
-
_context17.prev =
|
|
1745
|
+
case 10:
|
|
1746
|
+
_context17.prev = 10;
|
|
1730
1747
|
_context17.t0 = _context17["catch"](4);
|
|
1731
1748
|
errorMessage = _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0);
|
|
1732
1749
|
console.error('[Products] 清空 IndexDB 缓存失败:', _context17.t0);
|
|
1733
1750
|
this.logError('清空 IndexDB 缓存失败', {
|
|
1734
1751
|
error: errorMessage
|
|
1735
1752
|
});
|
|
1736
|
-
case
|
|
1737
|
-
console.log('[Products] 缓存已清空');
|
|
1753
|
+
case 15:
|
|
1738
1754
|
this.logInfo('缓存清空完成');
|
|
1739
|
-
case
|
|
1755
|
+
case 16:
|
|
1740
1756
|
case "end":
|
|
1741
1757
|
return _context17.stop();
|
|
1742
1758
|
}
|
|
1743
|
-
}, _callee17, this, [[4,
|
|
1759
|
+
}, _callee17, this, [[4, 10]]);
|
|
1744
1760
|
}));
|
|
1745
1761
|
function clear() {
|
|
1746
1762
|
return _clear.apply(this, arguments);
|
|
@@ -1756,7 +1772,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1756
1772
|
key: "loadProductsFromIndexDB",
|
|
1757
1773
|
value: (function () {
|
|
1758
1774
|
var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1759
|
-
var _products$length, _products$length2,
|
|
1775
|
+
var startedAt, _products$length, _products$length2, products, durationMs, errorMessage;
|
|
1760
1776
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1761
1777
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1762
1778
|
case 0:
|
|
@@ -1767,33 +1783,36 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1767
1783
|
this.logWarning('loadProductsFromIndexDB: dbManager 不可用');
|
|
1768
1784
|
return _context18.abrupt("return", []);
|
|
1769
1785
|
case 3:
|
|
1770
|
-
|
|
1771
|
-
|
|
1786
|
+
startedAt = performance.now();
|
|
1787
|
+
_context18.prev = 4;
|
|
1772
1788
|
_context18.next = 7;
|
|
1773
1789
|
return this.dbManager.getAll(INDEXDB_STORE_NAME);
|
|
1774
1790
|
case 7:
|
|
1775
1791
|
products = _context18.sent;
|
|
1776
|
-
|
|
1792
|
+
durationMs = +(performance.now() - startedAt).toFixed(2);
|
|
1793
|
+
perfMark('loadProductsFromIndexDB', durationMs, {
|
|
1777
1794
|
count: (_products$length = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length !== void 0 ? _products$length : 0
|
|
1778
1795
|
});
|
|
1779
1796
|
this.logInfo('从 IndexDB 加载商品数据', {
|
|
1780
|
-
productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0
|
|
1797
|
+
productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0,
|
|
1798
|
+
durationMs: durationMs
|
|
1781
1799
|
});
|
|
1782
1800
|
return _context18.abrupt("return", products || []);
|
|
1783
|
-
case
|
|
1784
|
-
_context18.prev =
|
|
1785
|
-
_context18.t0 = _context18["catch"](
|
|
1801
|
+
case 14:
|
|
1802
|
+
_context18.prev = 14;
|
|
1803
|
+
_context18.t0 = _context18["catch"](4);
|
|
1786
1804
|
errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
|
|
1787
1805
|
console.error('[Products] 从 IndexDB 读取数据失败:', _context18.t0);
|
|
1788
1806
|
this.logError('从 IndexDB 读取数据失败', {
|
|
1807
|
+
durationMs: +(performance.now() - startedAt).toFixed(2),
|
|
1789
1808
|
error: errorMessage
|
|
1790
1809
|
});
|
|
1791
1810
|
return _context18.abrupt("return", []);
|
|
1792
|
-
case
|
|
1811
|
+
case 20:
|
|
1793
1812
|
case "end":
|
|
1794
1813
|
return _context18.stop();
|
|
1795
1814
|
}
|
|
1796
|
-
}, _callee18, this, [[
|
|
1815
|
+
}, _callee18, this, [[4, 14]]);
|
|
1797
1816
|
}));
|
|
1798
1817
|
function loadProductsFromIndexDB() {
|
|
1799
1818
|
return _loadProductsFromIndexDB.apply(this, arguments);
|
|
@@ -1847,7 +1866,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1847
1866
|
value: (function () {
|
|
1848
1867
|
var _replaceProductsSnapshotInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(products, source) {
|
|
1849
1868
|
var _this9 = this;
|
|
1850
|
-
var errorMessage;
|
|
1869
|
+
var enqueuedAt, queueWaitMs, clearDurationMs, writeDurationMs, errorMessage;
|
|
1851
1870
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1852
1871
|
while (1) switch (_context21.prev = _context21.next) {
|
|
1853
1872
|
case 0:
|
|
@@ -1858,58 +1877,86 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1858
1877
|
this.logWarning('replaceProductsSnapshotInIndexDB: dbManager 不可用');
|
|
1859
1878
|
return _context21.abrupt("return");
|
|
1860
1879
|
case 3:
|
|
1861
|
-
|
|
1862
|
-
|
|
1880
|
+
enqueuedAt = performance.now();
|
|
1881
|
+
queueWaitMs = 0;
|
|
1882
|
+
clearDurationMs = 0;
|
|
1883
|
+
writeDurationMs = 0;
|
|
1884
|
+
_context21.prev = 7;
|
|
1885
|
+
_context21.next = 10;
|
|
1863
1886
|
return this.runInProductIndexDBSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1864
|
-
var
|
|
1887
|
+
var operationStartedAt, clearStartedAt, writeStartedAt, executeDurationMs;
|
|
1865
1888
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1866
1889
|
while (1) switch (_context20.prev = _context20.next) {
|
|
1867
1890
|
case 0:
|
|
1891
|
+
operationStartedAt = performance.now();
|
|
1892
|
+
queueWaitMs = +(operationStartedAt - enqueuedAt).toFixed(2);
|
|
1868
1893
|
_this9.logInfo('replaceProductsSnapshotInIndexDB 开始', {
|
|
1869
1894
|
source: source,
|
|
1870
|
-
productCount: products.length
|
|
1895
|
+
productCount: products.length,
|
|
1896
|
+
queueWaitMs: queueWaitMs
|
|
1871
1897
|
});
|
|
1872
|
-
|
|
1873
|
-
_context20.
|
|
1898
|
+
clearStartedAt = performance.now();
|
|
1899
|
+
_context20.prev = 4;
|
|
1900
|
+
_context20.next = 7;
|
|
1874
1901
|
return _this9.dbManager.clear(INDEXDB_STORE_NAME);
|
|
1875
|
-
case
|
|
1902
|
+
case 7:
|
|
1903
|
+
_context20.prev = 7;
|
|
1904
|
+
clearDurationMs = +(performance.now() - clearStartedAt).toFixed(2);
|
|
1905
|
+
return _context20.finish(7);
|
|
1906
|
+
case 10:
|
|
1876
1907
|
if (!(products.length > 0)) {
|
|
1877
|
-
_context20.next =
|
|
1908
|
+
_context20.next = 18;
|
|
1878
1909
|
break;
|
|
1879
1910
|
}
|
|
1880
|
-
|
|
1911
|
+
writeStartedAt = performance.now();
|
|
1912
|
+
_context20.prev = 12;
|
|
1913
|
+
_context20.next = 15;
|
|
1881
1914
|
return _this9.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
|
|
1882
|
-
case
|
|
1883
|
-
|
|
1915
|
+
case 15:
|
|
1916
|
+
_context20.prev = 15;
|
|
1917
|
+
writeDurationMs = +(performance.now() - writeStartedAt).toFixed(2);
|
|
1918
|
+
return _context20.finish(15);
|
|
1919
|
+
case 18:
|
|
1920
|
+
executeDurationMs = +(performance.now() - operationStartedAt).toFixed(2);
|
|
1921
|
+
perfMark('replaceProductsSnapshotInIndexDB', executeDurationMs, {
|
|
1884
1922
|
count: products.length
|
|
1885
1923
|
});
|
|
1886
1924
|
_this9.logInfo('replaceProductsSnapshotInIndexDB 完成', {
|
|
1887
1925
|
source: source,
|
|
1888
|
-
productCount: products.length
|
|
1926
|
+
productCount: products.length,
|
|
1927
|
+
queueWaitMs: queueWaitMs,
|
|
1928
|
+
clearDurationMs: clearDurationMs,
|
|
1929
|
+
writeDurationMs: writeDurationMs,
|
|
1930
|
+
executeDurationMs: executeDurationMs,
|
|
1931
|
+
totalDurationMs: +(performance.now() - enqueuedAt).toFixed(2)
|
|
1889
1932
|
});
|
|
1890
|
-
case
|
|
1933
|
+
case 21:
|
|
1891
1934
|
case "end":
|
|
1892
1935
|
return _context20.stop();
|
|
1893
1936
|
}
|
|
1894
|
-
}, _callee20);
|
|
1937
|
+
}, _callee20, null, [[4,, 7, 10], [12,, 15, 18]]);
|
|
1895
1938
|
})));
|
|
1896
|
-
case
|
|
1897
|
-
_context21.next =
|
|
1939
|
+
case 10:
|
|
1940
|
+
_context21.next = 16;
|
|
1898
1941
|
break;
|
|
1899
|
-
case
|
|
1900
|
-
_context21.prev =
|
|
1901
|
-
_context21.t0 = _context21["catch"](
|
|
1942
|
+
case 12:
|
|
1943
|
+
_context21.prev = 12;
|
|
1944
|
+
_context21.t0 = _context21["catch"](7);
|
|
1902
1945
|
errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
|
|
1903
1946
|
this.logError('全量保存商品到 IndexDB 失败', {
|
|
1904
1947
|
source: source,
|
|
1905
1948
|
productCount: products.length,
|
|
1949
|
+
queueWaitMs: queueWaitMs,
|
|
1950
|
+
clearDurationMs: clearDurationMs,
|
|
1951
|
+
writeDurationMs: writeDurationMs,
|
|
1952
|
+
totalDurationMs: +(performance.now() - enqueuedAt).toFixed(2),
|
|
1906
1953
|
error: errorMessage
|
|
1907
1954
|
});
|
|
1908
|
-
case
|
|
1955
|
+
case 16:
|
|
1909
1956
|
case "end":
|
|
1910
1957
|
return _context21.stop();
|
|
1911
1958
|
}
|
|
1912
|
-
}, _callee21, this, [[
|
|
1959
|
+
}, _callee21, this, [[7, 12]]);
|
|
1913
1960
|
}));
|
|
1914
1961
|
function replaceProductsSnapshotInIndexDB(_x21, _x22) {
|
|
1915
1962
|
return _replaceProductsSnapshotInIndexDB.apply(this, arguments);
|
|
@@ -2080,23 +2127,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2080
2127
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2081
2128
|
while (1) switch (_context24.prev = _context24.next) {
|
|
2082
2129
|
case 0:
|
|
2083
|
-
console.log('[Products] 开始预加载数据...');
|
|
2084
2130
|
tTotal = performance.now();
|
|
2085
2131
|
this.logInfo('开始预加载数据');
|
|
2086
|
-
_context24.prev =
|
|
2132
|
+
_context24.prev = 2;
|
|
2087
2133
|
tIndexDB = performance.now();
|
|
2088
|
-
_context24.next =
|
|
2134
|
+
_context24.next = 6;
|
|
2089
2135
|
return this.loadProductsFromIndexDB();
|
|
2090
|
-
case
|
|
2136
|
+
case 6:
|
|
2091
2137
|
cachedData = _context24.sent;
|
|
2092
2138
|
perfMark('preload.loadFromIndexDB', performance.now() - tIndexDB, {
|
|
2093
2139
|
count: (_cachedData$length = cachedData === null || cachedData === void 0 ? void 0 : cachedData.length) !== null && _cachedData$length !== void 0 ? _cachedData$length : 0
|
|
2094
2140
|
});
|
|
2095
2141
|
if (!(cachedData && cachedData.length > 0)) {
|
|
2096
|
-
_context24.next =
|
|
2142
|
+
_context24.next = 18;
|
|
2097
2143
|
break;
|
|
2098
2144
|
}
|
|
2099
|
-
console.log("[Products] \u4ECE IndexDB \u52A0\u8F7D\u4E86 ".concat(cachedData.length, " \u4E2A\u5546\u54C1"));
|
|
2100
2145
|
// IndexDB 反序列化的数据已经是全新的,无需 cloneDeep
|
|
2101
2146
|
this.store.list = cachedData;
|
|
2102
2147
|
tSync = performance.now();
|
|
@@ -2110,30 +2155,32 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2110
2155
|
source: 'IndexDB'
|
|
2111
2156
|
});
|
|
2112
2157
|
this.logInfo('预加载完成(从 IndexDB)', {
|
|
2158
|
+
trigger: 'preload',
|
|
2113
2159
|
productCount: cachedData.length,
|
|
2114
2160
|
duration: "".concat(Math.round(performance.now() - tTotal), "ms"),
|
|
2115
2161
|
source: 'IndexDB'
|
|
2116
2162
|
});
|
|
2117
2163
|
this.lastPreloadCompletedAtMs = Date.now();
|
|
2118
2164
|
return _context24.abrupt("return");
|
|
2119
|
-
case
|
|
2120
|
-
console.log('[Products] IndexDB 中没有缓存数据,从服务器加载...');
|
|
2165
|
+
case 18:
|
|
2121
2166
|
this.logInfo('IndexDB 中没有缓存数据,准备从服务器加载');
|
|
2122
|
-
_context24.next =
|
|
2167
|
+
_context24.next = 26;
|
|
2123
2168
|
break;
|
|
2124
|
-
case
|
|
2125
|
-
_context24.prev =
|
|
2126
|
-
_context24.t0 = _context24["catch"](
|
|
2169
|
+
case 21:
|
|
2170
|
+
_context24.prev = 21;
|
|
2171
|
+
_context24.t0 = _context24["catch"](2);
|
|
2127
2172
|
errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : String(_context24.t0);
|
|
2128
2173
|
console.warn('[Products] 从 IndexDB 加载数据失败:', _context24.t0);
|
|
2129
2174
|
this.logWarning('从 IndexDB 加载数据失败,准备从服务器加载', {
|
|
2130
2175
|
error: errorMessage
|
|
2131
2176
|
});
|
|
2132
|
-
case
|
|
2177
|
+
case 26:
|
|
2133
2178
|
tServer = performance.now();
|
|
2134
|
-
_context24.next =
|
|
2135
|
-
return this.loadProductsByServer(
|
|
2136
|
-
|
|
2179
|
+
_context24.next = 29;
|
|
2180
|
+
return this.loadProductsByServer({
|
|
2181
|
+
trigger: 'preload'
|
|
2182
|
+
});
|
|
2183
|
+
case 29:
|
|
2137
2184
|
products = _context24.sent;
|
|
2138
2185
|
perfMark('preload.loadFromServer', performance.now() - tServer, {
|
|
2139
2186
|
count: (_products$length3 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length3 !== void 0 ? _products$length3 : 0
|
|
@@ -2152,6 +2199,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2152
2199
|
source: 'Server'
|
|
2153
2200
|
});
|
|
2154
2201
|
this.logInfo('预加载完成(从服务器)', {
|
|
2202
|
+
trigger: 'preload',
|
|
2155
2203
|
productCount: products.length,
|
|
2156
2204
|
duration: "".concat(Math.round(performance.now() - tTotal), "ms"),
|
|
2157
2205
|
source: 'Server'
|
|
@@ -2165,11 +2213,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2165
2213
|
duration: "".concat(Math.round(performance.now() - tTotal), "ms")
|
|
2166
2214
|
});
|
|
2167
2215
|
}
|
|
2168
|
-
case
|
|
2216
|
+
case 32:
|
|
2169
2217
|
case "end":
|
|
2170
2218
|
return _context24.stop();
|
|
2171
2219
|
}
|
|
2172
|
-
}, _callee24, this, [[
|
|
2220
|
+
}, _callee24, this, [[2, 21]]);
|
|
2173
2221
|
}));
|
|
2174
2222
|
function preload() {
|
|
2175
2223
|
return _preload.apply(this, arguments);
|
|
@@ -2213,7 +2261,6 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2213
2261
|
return function (message) {
|
|
2214
2262
|
var data = (message === null || message === void 0 ? void 0 : message.data) || message;
|
|
2215
2263
|
if (!data) return;
|
|
2216
|
-
console.log("[ProductsModule] \u6536\u5230\u540C\u6B65\u6D88\u606F [".concat(channelKey, "]:"), data);
|
|
2217
2264
|
_this11.logInfo('收到同步消息', {
|
|
2218
2265
|
channelKey: channelKey,
|
|
2219
2266
|
action: data.action,
|
|
@@ -2776,64 +2823,91 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2776
2823
|
key: "silentRefresh",
|
|
2777
2824
|
value: (function () {
|
|
2778
2825
|
var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
2779
|
-
var
|
|
2826
|
+
var options,
|
|
2827
|
+
t0,
|
|
2828
|
+
now,
|
|
2829
|
+
trigger,
|
|
2830
|
+
elapsedSincePreloadMs,
|
|
2831
|
+
elapsedSinceFullFetchMs,
|
|
2832
|
+
products,
|
|
2833
|
+
errorMessage,
|
|
2834
|
+
_args29 = arguments;
|
|
2780
2835
|
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2781
2836
|
while (1) switch (_context29.prev = _context29.next) {
|
|
2782
2837
|
case 0:
|
|
2838
|
+
options = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
|
|
2783
2839
|
t0 = performance.now();
|
|
2784
2840
|
now = Date.now();
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2841
|
+
trigger = options.trigger || 'background';
|
|
2842
|
+
elapsedSincePreloadMs = now - this.lastPreloadCompletedAtMs;
|
|
2843
|
+
elapsedSinceFullFetchMs = now - this.lastServerFullFetchAtMs;
|
|
2844
|
+
if (!(this.lastPreloadCompletedAtMs > 0 && elapsedSincePreloadMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS || this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetchMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS)) {
|
|
2845
|
+
_context29.next = 9;
|
|
2789
2846
|
break;
|
|
2790
2847
|
}
|
|
2848
|
+
this.logInfo('silentRefresh 跳过全量 SSE', {
|
|
2849
|
+
trigger: trigger,
|
|
2850
|
+
reason: 'within_min_interval',
|
|
2851
|
+
minIntervalMs: PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS,
|
|
2852
|
+
elapsedSincePreloadMs: elapsedSincePreloadMs,
|
|
2853
|
+
elapsedSinceFullFetchMs: elapsedSinceFullFetchMs,
|
|
2854
|
+
productCount: this.store.list.length
|
|
2855
|
+
});
|
|
2791
2856
|
return _context29.abrupt("return", this.store.list);
|
|
2792
|
-
case
|
|
2793
|
-
this.logInfo('silentRefresh 开始'
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2857
|
+
case 9:
|
|
2858
|
+
this.logInfo('silentRefresh 开始', {
|
|
2859
|
+
trigger: trigger,
|
|
2860
|
+
elapsedSincePreloadMs: elapsedSincePreloadMs,
|
|
2861
|
+
elapsedSinceFullFetchMs: elapsedSinceFullFetchMs,
|
|
2862
|
+
productCount: this.store.list.length
|
|
2863
|
+
});
|
|
2864
|
+
_context29.prev = 10;
|
|
2865
|
+
_context29.next = 13;
|
|
2866
|
+
return this.loadProductsByServer({
|
|
2867
|
+
trigger: trigger
|
|
2868
|
+
});
|
|
2869
|
+
case 13:
|
|
2798
2870
|
products = _context29.sent;
|
|
2799
2871
|
if (!(products && products.length > 0)) {
|
|
2800
|
-
_context29.next =
|
|
2872
|
+
_context29.next = 24;
|
|
2801
2873
|
break;
|
|
2802
2874
|
}
|
|
2803
2875
|
this.store.list = products;
|
|
2804
2876
|
this.syncProductsMap();
|
|
2805
2877
|
this.clearPriceCache();
|
|
2806
2878
|
this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
|
|
2807
|
-
_context29.next =
|
|
2879
|
+
_context29.next = 21;
|
|
2808
2880
|
return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
|
|
2809
|
-
case
|
|
2881
|
+
case 21:
|
|
2810
2882
|
this.logInfo('silentRefresh 完成', {
|
|
2883
|
+
trigger: trigger,
|
|
2811
2884
|
productCount: products.length,
|
|
2812
2885
|
duration: "".concat(Math.round(performance.now() - t0), "ms")
|
|
2813
2886
|
});
|
|
2814
|
-
_context29.next =
|
|
2887
|
+
_context29.next = 25;
|
|
2815
2888
|
break;
|
|
2816
|
-
case
|
|
2889
|
+
case 24:
|
|
2817
2890
|
this.logWarning('silentRefresh: 服务器未返回数据');
|
|
2818
|
-
case
|
|
2891
|
+
case 25:
|
|
2819
2892
|
perfMark('silentRefresh', performance.now() - t0, {
|
|
2820
2893
|
count: this.store.list.length
|
|
2821
2894
|
});
|
|
2822
2895
|
return _context29.abrupt("return", this.store.list);
|
|
2823
|
-
case
|
|
2824
|
-
_context29.prev =
|
|
2825
|
-
_context29.t0 = _context29["catch"](
|
|
2896
|
+
case 29:
|
|
2897
|
+
_context29.prev = 29;
|
|
2898
|
+
_context29.t0 = _context29["catch"](10);
|
|
2826
2899
|
errorMessage = _context29.t0 instanceof Error ? _context29.t0.message : String(_context29.t0);
|
|
2827
2900
|
this.logError('silentRefresh 失败', {
|
|
2901
|
+
trigger: trigger,
|
|
2828
2902
|
duration: "".concat(Math.round(performance.now() - t0), "ms"),
|
|
2829
2903
|
error: errorMessage
|
|
2830
2904
|
});
|
|
2831
2905
|
return _context29.abrupt("return", this.store.list);
|
|
2832
|
-
case
|
|
2906
|
+
case 34:
|
|
2833
2907
|
case "end":
|
|
2834
2908
|
return _context29.stop();
|
|
2835
2909
|
}
|
|
2836
|
-
}, _callee29, this, [[
|
|
2910
|
+
}, _callee29, this, [[10, 29]]);
|
|
2837
2911
|
}));
|
|
2838
2912
|
function silentRefresh() {
|
|
2839
2913
|
return _silentRefresh.apply(this, arguments);
|