@pisell/pisellos 2.2.181 → 2.2.183
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/modules/BookingContext/index.d.ts +37 -0
- package/dist/modules/BookingContext/index.js +436 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +276 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Customer/index.d.ts +6 -0
- package/dist/modules/Customer/index.js +129 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.js +4 -3
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +100 -9
- package/dist/modules/Order/index.js +1447 -499
- package/dist/modules/Order/types.d.ts +201 -18
- package/dist/modules/Order/types.js +31 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
- package/dist/modules/Order/utils.d.ts +83 -1
- package/dist/modules/Order/utils.js +405 -61
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Quotation/index.d.ts +0 -1
- package/dist/modules/Quotation/index.js +23 -21
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +43 -39
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/SalesSummary/utils.js +21 -7
- package/dist/modules/Schedule/index.js +6 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/server/index.js +87 -29
- package/dist/server/modules/order/index.d.ts +23 -0
- package/dist/server/modules/order/index.js +123 -46
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/server/modules/products/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +130 -113
- package/dist/server/modules/schedule/index.js +13 -6
- package/dist/solution/BaseSales/index.d.ts +89 -7
- package/dist/solution/BaseSales/index.js +1504 -380
- package/dist/solution/BaseSales/types.d.ts +67 -1
- package/dist/solution/BaseSales/types.js +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1258 -0
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +68 -16
- package/dist/solution/BaseSales/utils.js +46 -8
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +151 -1
- package/dist/solution/BookingTicket/index.js +848 -184
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/BookingTicket/types.js +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/BookingTicket/utils/cartView.js +4 -2
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +46 -8
- package/dist/solution/VenueBooking/index.d.ts +5 -2
- package/dist/solution/VenueBooking/index.js +103 -55
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/modules/BookingContext/index.d.ts +37 -0
- package/lib/modules/BookingContext/index.js +297 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +271 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Customer/index.d.ts +6 -0
- package/lib/modules/Customer/index.js +26 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.js +5 -1
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +100 -9
- package/lib/modules/Order/index.js +751 -160
- package/lib/modules/Order/types.d.ts +201 -18
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
- package/lib/modules/Order/utils.d.ts +83 -1
- package/lib/modules/Order/utils.js +340 -22
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Quotation/index.d.ts +0 -1
- package/lib/modules/Quotation/index.js +18 -15
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +26 -27
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/SalesSummary/utils.js +21 -7
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/server/index.js +41 -4
- package/lib/server/modules/order/index.d.ts +23 -0
- package/lib/server/modules/order/index.js +46 -14
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/server/modules/products/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +30 -20
- package/lib/server/modules/schedule/index.js +2 -1
- package/lib/solution/BaseSales/index.d.ts +89 -7
- package/lib/solution/BaseSales/index.js +743 -23
- package/lib/solution/BaseSales/types.d.ts +67 -1
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +836 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +71 -12
- package/lib/solution/BaseSales/utils.js +46 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +151 -1
- package/lib/solution/BookingTicket/index.js +389 -9
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/BookingTicket/types.js +6 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/BookingTicket/utils/cartView.js +4 -2
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +46 -6
- package/lib/solution/VenueBooking/index.d.ts +5 -2
- package/lib/solution/VenueBooking/index.js +50 -14
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/package.json +1 -1
|
@@ -73,7 +73,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
73
73
|
// 普通层 QuotationModule 桥接器:本地计算报价单价格,替代 /product/query/price
|
|
74
74
|
_defineProperty(_assertThisInitialized(_this), "quotationPriceBridge", void 0);
|
|
75
75
|
_defineProperty(_assertThisInitialized(_this), "quotationBridgeChannel", void 0);
|
|
76
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
76
|
+
_defineProperty(_assertThisInitialized(_this), "quotationBridgeLoadedKey", '');
|
|
77
77
|
_defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshPromise", void 0);
|
|
78
78
|
_defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshKey", void 0);
|
|
79
79
|
// ---- 商品数据同步相关 ----
|
|
@@ -277,7 +277,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
277
277
|
value: (function () {
|
|
278
278
|
var _setupQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
279
279
|
var _this$otherParams;
|
|
280
|
-
var channel, quotation,
|
|
280
|
+
var channel, quotation, scheduleCache, hasLoadedScheduleList;
|
|
281
281
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
282
282
|
while (1) switch (_context3.prev = _context3.next) {
|
|
283
283
|
case 0:
|
|
@@ -301,14 +301,32 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
301
301
|
this.quotationPriceBridge = quotation;
|
|
302
302
|
case 10:
|
|
303
303
|
if (params.scheduleModule) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
return [schedule.id, schedule];
|
|
307
|
-
}));
|
|
304
|
+
scheduleCache = new Map();
|
|
305
|
+
hasLoadedScheduleList = false;
|
|
308
306
|
this.quotationPriceBridge.setScheduleResolver(function (id) {
|
|
309
|
-
var _params$scheduleModul3, _params$scheduleModul4;
|
|
310
|
-
|
|
311
|
-
|
|
307
|
+
var _params$scheduleModul3, _params$scheduleModul4, _params$scheduleModul5, _params$scheduleModul6;
|
|
308
|
+
var scheduleId = String(id);
|
|
309
|
+
if (scheduleCache.has(scheduleId)) return scheduleCache.get(scheduleId);
|
|
310
|
+
if (!hasLoadedScheduleList) {
|
|
311
|
+
var _params$scheduleModul, _params$scheduleModul2;
|
|
312
|
+
var scheduleList = ((_params$scheduleModul = (_params$scheduleModul2 = params.scheduleModule).getScheduleList) === null || _params$scheduleModul === void 0 ? void 0 : _params$scheduleModul.call(_params$scheduleModul2)) || [];
|
|
313
|
+
var _iterator = _createForOfIteratorHelper(scheduleList),
|
|
314
|
+
_step;
|
|
315
|
+
try {
|
|
316
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
317
|
+
var schedule = _step.value;
|
|
318
|
+
scheduleCache.set(String(schedule.id), schedule);
|
|
319
|
+
}
|
|
320
|
+
} catch (err) {
|
|
321
|
+
_iterator.e(err);
|
|
322
|
+
} finally {
|
|
323
|
+
_iterator.f();
|
|
324
|
+
}
|
|
325
|
+
hasLoadedScheduleList = true;
|
|
326
|
+
}
|
|
327
|
+
if (scheduleCache.has(scheduleId)) return scheduleCache.get(scheduleId);
|
|
328
|
+
var schedules = ((_params$scheduleModul3 = (_params$scheduleModul4 = params.scheduleModule).getScheduleListByIds) === null || _params$scheduleModul3 === void 0 ? void 0 : _params$scheduleModul3.call(_params$scheduleModul4, [id])) || ((_params$scheduleModul5 = (_params$scheduleModul6 = params.scheduleModule).getScheduleByIds) === null || _params$scheduleModul5 === void 0 ? void 0 : _params$scheduleModul5.call(_params$scheduleModul6, [id])) || [];
|
|
329
|
+
if (schedules[0]) scheduleCache.set(scheduleId, schedules[0]);
|
|
312
330
|
return schedules[0];
|
|
313
331
|
});
|
|
314
332
|
}
|
|
@@ -336,7 +354,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
336
354
|
value: (function () {
|
|
337
355
|
var _refreshQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
338
356
|
var _this3 = this;
|
|
339
|
-
var
|
|
357
|
+
var refreshKey;
|
|
340
358
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
341
359
|
while (1) switch (_context4.prev = _context4.next) {
|
|
342
360
|
case 0:
|
|
@@ -346,37 +364,35 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
346
364
|
}
|
|
347
365
|
return _context4.abrupt("return");
|
|
348
366
|
case 2:
|
|
349
|
-
|
|
350
|
-
refreshKey = this.getQuotationBridgeScopeKey(customerId);
|
|
367
|
+
refreshKey = this.getQuotationBridgeScopeKey();
|
|
351
368
|
if (!(this.quotationBridgeRefreshPromise && this.quotationBridgeRefreshKey === refreshKey)) {
|
|
352
|
-
_context4.next =
|
|
369
|
+
_context4.next = 7;
|
|
353
370
|
break;
|
|
354
371
|
}
|
|
355
|
-
_context4.next =
|
|
372
|
+
_context4.next = 6;
|
|
356
373
|
return this.quotationBridgeRefreshPromise;
|
|
357
|
-
case
|
|
374
|
+
case 6:
|
|
358
375
|
return _context4.abrupt("return");
|
|
359
|
-
case
|
|
376
|
+
case 7:
|
|
360
377
|
if (!this.quotationBridgeRefreshPromise) {
|
|
361
|
-
_context4.next =
|
|
378
|
+
_context4.next = 10;
|
|
362
379
|
break;
|
|
363
380
|
}
|
|
364
|
-
_context4.next =
|
|
381
|
+
_context4.next = 10;
|
|
365
382
|
return this.quotationBridgeRefreshPromise;
|
|
366
|
-
case
|
|
383
|
+
case 10:
|
|
367
384
|
this.quotationBridgeRefreshKey = refreshKey;
|
|
368
385
|
this.quotationBridgeRefreshPromise = this.quotationPriceBridge.loadQuotations({
|
|
369
|
-
channel: this.quotationBridgeChannel
|
|
370
|
-
customer_id: customerId
|
|
386
|
+
channel: this.quotationBridgeChannel
|
|
371
387
|
}).then(function () {
|
|
372
|
-
_this3.
|
|
388
|
+
_this3.quotationBridgeLoadedKey = refreshKey;
|
|
373
389
|
}).finally(function () {
|
|
374
390
|
_this3.quotationBridgeRefreshPromise = undefined;
|
|
375
391
|
_this3.quotationBridgeRefreshKey = undefined;
|
|
376
392
|
});
|
|
377
|
-
_context4.next =
|
|
393
|
+
_context4.next = 14;
|
|
378
394
|
return this.quotationBridgeRefreshPromise;
|
|
379
|
-
case
|
|
395
|
+
case 14:
|
|
380
396
|
case "end":
|
|
381
397
|
return _context4.stop();
|
|
382
398
|
}
|
|
@@ -414,7 +430,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
414
430
|
_context5.next = 7;
|
|
415
431
|
return this.quotationBridgeRefreshPromise;
|
|
416
432
|
case 7:
|
|
417
|
-
if (!(this.getQuotationBridgeScopeKey(
|
|
433
|
+
if (!(this.getQuotationBridgeScopeKey() !== this.quotationBridgeLoadedKey)) {
|
|
418
434
|
_context5.next = 10;
|
|
419
435
|
break;
|
|
420
436
|
}
|
|
@@ -435,23 +451,24 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
435
451
|
}()
|
|
436
452
|
}, {
|
|
437
453
|
key: "getQuotationBridgeScopeKey",
|
|
438
|
-
value: function getQuotationBridgeScopeKey(
|
|
439
|
-
return
|
|
454
|
+
value: function getQuotationBridgeScopeKey() {
|
|
455
|
+
return this.quotationBridgeChannel || '';
|
|
440
456
|
}
|
|
441
457
|
}, {
|
|
442
458
|
key: "buildPriceDataFromQuotation",
|
|
443
459
|
value: function buildPriceDataFromQuotation(product, datetime, customerId) {
|
|
444
|
-
var _this$quotationPriceB, _ref2,
|
|
460
|
+
var _this$quotationPriceB, _ref2, _ref3;
|
|
445
461
|
var quotedPrice = (_this$quotationPriceB = this.quotationPriceBridge) === null || _this$quotationPriceB === void 0 ? void 0 : _this$quotationPriceB.getPriceForProduct({
|
|
446
462
|
productId: product.id,
|
|
447
463
|
datetime: datetime,
|
|
448
464
|
customer_id: customerId
|
|
449
465
|
});
|
|
450
466
|
var productPrice = quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : product.price;
|
|
467
|
+
var productBasePrice = (_ref2 = (_ref3 = quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : product.base_price) !== null && _ref3 !== void 0 ? _ref3 : product.price) !== null && _ref2 !== void 0 ? _ref2 : 0;
|
|
451
468
|
return {
|
|
452
469
|
id: product.id,
|
|
453
470
|
price: String(productPrice !== null && productPrice !== void 0 ? productPrice : 0),
|
|
454
|
-
base_price: String(
|
|
471
|
+
base_price: String(productBasePrice),
|
|
455
472
|
variant: this.buildVariantPriceData(product, datetime, customerId),
|
|
456
473
|
bundle_group: this.buildBundleGroupPriceData(product, datetime, customerId)
|
|
457
474
|
};
|
|
@@ -462,15 +479,15 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
462
479
|
var _this4 = this;
|
|
463
480
|
if (!Array.isArray(product.variant)) return [];
|
|
464
481
|
return product.variant.map(function (variant) {
|
|
465
|
-
var _this4$quotationPrice,
|
|
482
|
+
var _this4$quotationPrice, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _variant$product_id;
|
|
466
483
|
var quotedPrice = (_this4$quotationPrice = _this4.quotationPriceBridge) === null || _this4$quotationPrice === void 0 ? void 0 : _this4$quotationPrice.getPriceForProduct({
|
|
467
484
|
productId: product.id,
|
|
468
485
|
variantId: Number(variant.id),
|
|
469
486
|
datetime: datetime,
|
|
470
487
|
customer_id: customerId
|
|
471
488
|
});
|
|
472
|
-
var price = (
|
|
473
|
-
var basePrice = (
|
|
489
|
+
var price = (_ref4 = (_ref5 = quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : variant.price) !== null && _ref5 !== void 0 ? _ref5 : product.price) !== null && _ref4 !== void 0 ? _ref4 : 0;
|
|
490
|
+
var basePrice = (_ref6 = (_ref7 = (_ref8 = (_ref9 = quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : variant.base_price) !== null && _ref9 !== void 0 ? _ref9 : variant.price) !== null && _ref8 !== void 0 ? _ref8 : product.base_price) !== null && _ref7 !== void 0 ? _ref7 : product.price) !== null && _ref6 !== void 0 ? _ref6 : 0;
|
|
474
491
|
return {
|
|
475
492
|
id: Number(variant.id),
|
|
476
493
|
product_id: Number((_variant$product_id = variant.product_id) !== null && _variant$product_id !== void 0 ? _variant$product_id : product.id),
|
|
@@ -488,7 +505,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
488
505
|
return {
|
|
489
506
|
id: Number(group.id),
|
|
490
507
|
bundle_item: (group.bundle_item || []).map(function (item) {
|
|
491
|
-
var _this5$quotationPrice,
|
|
508
|
+
var _this5$quotationPrice, _ref10, _ref11, _ref12, _item$product_id, _item$group_id;
|
|
492
509
|
var bundleProductId = Number(item.bundle_product_id);
|
|
493
510
|
var bundleVariantId = Number(item.bundle_variant_id || 0);
|
|
494
511
|
var quotedPrice = (_this5$quotationPrice = _this5.quotationPriceBridge) === null || _this5$quotationPrice === void 0 ? void 0 : _this5$quotationPrice.getPriceForProduct({
|
|
@@ -497,8 +514,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
497
514
|
datetime: datetime,
|
|
498
515
|
customer_id: customerId
|
|
499
516
|
});
|
|
500
|
-
var price = (
|
|
501
|
-
var basePrice = (
|
|
517
|
+
var price = (_ref10 = quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : item.price) !== null && _ref10 !== void 0 ? _ref10 : 0;
|
|
518
|
+
var basePrice = (_ref11 = (_ref12 = quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : item.base_price) !== null && _ref12 !== void 0 ? _ref12 : item.price) !== null && _ref11 !== void 0 ? _ref11 : 0;
|
|
502
519
|
return {
|
|
503
520
|
id: Number(item.id),
|
|
504
521
|
product_id: Number((_item$product_id = item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : product.id),
|
|
@@ -531,7 +548,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
531
548
|
value: (function () {
|
|
532
549
|
var _getProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(schedule_date, extraContext, options) {
|
|
533
550
|
var _options$changedIds;
|
|
534
|
-
var t0, scopedProductIds, cacheKey, scopedProductIdSet, changedIds, cachedProducts, updatedProducts, updatedMap, mergedCache,
|
|
551
|
+
var t0, scopedProductIds, cacheKey, scopedProductIdSet, changedIds, cachedProducts, updatedProducts, updatedMap, mergedCache, _iterator2, _step2, p, _iterator3, _step3, _p, errorMessage, result;
|
|
535
552
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
536
553
|
while (1) switch (_context6.prev = _context6.next) {
|
|
537
554
|
case 0:
|
|
@@ -572,10 +589,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
572
589
|
return [p.id, p];
|
|
573
590
|
}));
|
|
574
591
|
mergedCache = [];
|
|
575
|
-
|
|
592
|
+
_iterator2 = _createForOfIteratorHelper(cachedProducts);
|
|
576
593
|
try {
|
|
577
|
-
for (
|
|
578
|
-
p =
|
|
594
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
595
|
+
p = _step2.value;
|
|
579
596
|
if (updatedMap.has(p.id)) {
|
|
580
597
|
mergedCache.push(updatedMap.get(p.id));
|
|
581
598
|
updatedMap.delete(p.id);
|
|
@@ -585,20 +602,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
585
602
|
}
|
|
586
603
|
// 剩余的是新增商品(create 场景)
|
|
587
604
|
} catch (err) {
|
|
588
|
-
|
|
605
|
+
_iterator2.e(err);
|
|
589
606
|
} finally {
|
|
590
|
-
|
|
607
|
+
_iterator2.f();
|
|
591
608
|
}
|
|
592
|
-
|
|
609
|
+
_iterator3 = _createForOfIteratorHelper(updatedMap.values());
|
|
593
610
|
try {
|
|
594
|
-
for (
|
|
595
|
-
_p =
|
|
611
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
612
|
+
_p = _step3.value;
|
|
596
613
|
mergedCache.push(_p);
|
|
597
614
|
}
|
|
598
615
|
} catch (err) {
|
|
599
|
-
|
|
616
|
+
_iterator3.e(err);
|
|
600
617
|
} finally {
|
|
601
|
-
|
|
618
|
+
_iterator3.f();
|
|
602
619
|
}
|
|
603
620
|
this.productsPriceCache.set(cacheKey, mergedCache);
|
|
604
621
|
this.logInfo('增量更新完成', {
|
|
@@ -833,25 +850,25 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
833
850
|
}
|
|
834
851
|
if (productIds.length === 0 && collectionIds.length === 0) return [];
|
|
835
852
|
var result = new Set();
|
|
836
|
-
var
|
|
837
|
-
|
|
853
|
+
var _iterator4 = _createForOfIteratorHelper(productIds),
|
|
854
|
+
_step4;
|
|
838
855
|
try {
|
|
839
|
-
for (
|
|
840
|
-
var id =
|
|
856
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
857
|
+
var id = _step4.value;
|
|
841
858
|
if (this.store.map.has(id)) result.add(id);
|
|
842
859
|
}
|
|
843
860
|
} catch (err) {
|
|
844
|
-
|
|
861
|
+
_iterator4.e(err);
|
|
845
862
|
} finally {
|
|
846
|
-
|
|
863
|
+
_iterator4.f();
|
|
847
864
|
}
|
|
848
865
|
if (collectionIds.length === 0) return Array.from(result);
|
|
849
866
|
var collectionIdSet = new Set(collectionIds);
|
|
850
|
-
var
|
|
851
|
-
|
|
867
|
+
var _iterator5 = _createForOfIteratorHelper(this.getProductsRef()),
|
|
868
|
+
_step5;
|
|
852
869
|
try {
|
|
853
|
-
for (
|
|
854
|
-
var product =
|
|
870
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
871
|
+
var product = _step5.value;
|
|
855
872
|
if (result.has(product.id)) continue;
|
|
856
873
|
if (!Array.isArray(product.collection)) continue;
|
|
857
874
|
var isInCollection = product.collection.some(function (collection) {
|
|
@@ -860,9 +877,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
860
877
|
if (isInCollection) result.add(product.id);
|
|
861
878
|
}
|
|
862
879
|
} catch (err) {
|
|
863
|
-
|
|
880
|
+
_iterator5.e(err);
|
|
864
881
|
} finally {
|
|
865
|
-
|
|
882
|
+
_iterator5.f();
|
|
866
883
|
}
|
|
867
884
|
return Array.from(result);
|
|
868
885
|
}
|
|
@@ -1141,11 +1158,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1141
1158
|
key: "fetchProductsByHttp",
|
|
1142
1159
|
value: (function () {
|
|
1143
1160
|
var _fetchProductsByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
1144
|
-
var
|
|
1161
|
+
var _ref13, _ref13$category_ids, category_ids, _ref13$product_ids, product_ids, _ref13$collection, collection, customer_id, cacheId, startTime, _this$otherParams3, _productsData$data, productsData, productList, duration, _duration2, errorMessage;
|
|
1145
1162
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1146
1163
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1147
1164
|
case 0:
|
|
1148
|
-
|
|
1165
|
+
_ref13 = params || {}, _ref13$category_ids = _ref13.category_ids, category_ids = _ref13$category_ids === void 0 ? [] : _ref13$category_ids, _ref13$product_ids = _ref13.product_ids, product_ids = _ref13$product_ids === void 0 ? [] : _ref13$product_ids, _ref13$collection = _ref13.collection, collection = _ref13$collection === void 0 ? [] : _ref13$collection, customer_id = _ref13.customer_id, cacheId = _ref13.cacheId;
|
|
1149
1166
|
this.logInfo('fetchProductsByHttp: 开始请求', {
|
|
1150
1167
|
categoryIdsCount: category_ids.length,
|
|
1151
1168
|
productIdsCount: product_ids.length,
|
|
@@ -1293,18 +1310,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1293
1310
|
key: "getProductsRefByIds",
|
|
1294
1311
|
value: function getProductsRefByIds(ids) {
|
|
1295
1312
|
var products = [];
|
|
1296
|
-
var
|
|
1297
|
-
|
|
1313
|
+
var _iterator6 = _createForOfIteratorHelper(ids),
|
|
1314
|
+
_step6;
|
|
1298
1315
|
try {
|
|
1299
|
-
for (
|
|
1300
|
-
var id =
|
|
1316
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1317
|
+
var id = _step6.value;
|
|
1301
1318
|
var product = this.store.map.get(id);
|
|
1302
1319
|
if (product) products.push(product);
|
|
1303
1320
|
}
|
|
1304
1321
|
} catch (err) {
|
|
1305
|
-
|
|
1322
|
+
_iterator6.e(err);
|
|
1306
1323
|
} finally {
|
|
1307
|
-
|
|
1324
|
+
_iterator6.f();
|
|
1308
1325
|
}
|
|
1309
1326
|
return products;
|
|
1310
1327
|
}
|
|
@@ -1343,7 +1360,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1343
1360
|
key: "removeProductsByIds",
|
|
1344
1361
|
value: (function () {
|
|
1345
1362
|
var _removeProductsByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(ids) {
|
|
1346
|
-
var idSet,
|
|
1363
|
+
var idSet, _iterator7, _step7, _id, _iterator8, _step8, id, errorMessage, _iterator9, _step9, _step9$value, dateKey, cachedProducts;
|
|
1347
1364
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1348
1365
|
while (1) switch (_context14.prev = _context14.next) {
|
|
1349
1366
|
case 0:
|
|
@@ -1355,31 +1372,31 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1355
1372
|
this.store.list = this.store.list.filter(function (p) {
|
|
1356
1373
|
return !idSet.has(p.id);
|
|
1357
1374
|
});
|
|
1358
|
-
|
|
1375
|
+
_iterator7 = _createForOfIteratorHelper(ids);
|
|
1359
1376
|
try {
|
|
1360
|
-
for (
|
|
1361
|
-
_id =
|
|
1377
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
1378
|
+
_id = _step7.value;
|
|
1362
1379
|
this.store.map.delete(_id);
|
|
1363
1380
|
}
|
|
1364
1381
|
} catch (err) {
|
|
1365
|
-
|
|
1382
|
+
_iterator7.e(err);
|
|
1366
1383
|
} finally {
|
|
1367
|
-
|
|
1384
|
+
_iterator7.f();
|
|
1368
1385
|
}
|
|
1369
1386
|
if (!this.dbManager) {
|
|
1370
1387
|
_context14.next = 30;
|
|
1371
1388
|
break;
|
|
1372
1389
|
}
|
|
1373
1390
|
_context14.prev = 6;
|
|
1374
|
-
|
|
1391
|
+
_iterator8 = _createForOfIteratorHelper(ids);
|
|
1375
1392
|
_context14.prev = 8;
|
|
1376
|
-
|
|
1393
|
+
_iterator8.s();
|
|
1377
1394
|
case 10:
|
|
1378
|
-
if ((
|
|
1395
|
+
if ((_step8 = _iterator8.n()).done) {
|
|
1379
1396
|
_context14.next = 16;
|
|
1380
1397
|
break;
|
|
1381
1398
|
}
|
|
1382
|
-
id =
|
|
1399
|
+
id = _step8.value;
|
|
1383
1400
|
_context14.next = 14;
|
|
1384
1401
|
return this.dbManager.delete(INDEXDB_STORE_NAME, id);
|
|
1385
1402
|
case 14:
|
|
@@ -1391,10 +1408,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1391
1408
|
case 18:
|
|
1392
1409
|
_context14.prev = 18;
|
|
1393
1410
|
_context14.t0 = _context14["catch"](8);
|
|
1394
|
-
|
|
1411
|
+
_iterator8.e(_context14.t0);
|
|
1395
1412
|
case 21:
|
|
1396
1413
|
_context14.prev = 21;
|
|
1397
|
-
|
|
1414
|
+
_iterator8.f();
|
|
1398
1415
|
return _context14.finish(21);
|
|
1399
1416
|
case 24:
|
|
1400
1417
|
_context14.next = 30;
|
|
@@ -1408,18 +1425,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1408
1425
|
error: errorMessage
|
|
1409
1426
|
});
|
|
1410
1427
|
case 30:
|
|
1411
|
-
|
|
1428
|
+
_iterator9 = _createForOfIteratorHelper(this.productsPriceCache.entries());
|
|
1412
1429
|
try {
|
|
1413
|
-
for (
|
|
1414
|
-
|
|
1430
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1431
|
+
_step9$value = _slicedToArray(_step9.value, 2), dateKey = _step9$value[0], cachedProducts = _step9$value[1];
|
|
1415
1432
|
this.productsPriceCache.set(dateKey, cachedProducts.filter(function (p) {
|
|
1416
1433
|
return !idSet.has(p.id);
|
|
1417
1434
|
}));
|
|
1418
1435
|
}
|
|
1419
1436
|
} catch (err) {
|
|
1420
|
-
|
|
1437
|
+
_iterator9.e(err);
|
|
1421
1438
|
} finally {
|
|
1422
|
-
|
|
1439
|
+
_iterator9.f();
|
|
1423
1440
|
}
|
|
1424
1441
|
this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
|
|
1425
1442
|
this.logInfo('removeProductsByIds 完成', {
|
|
@@ -1659,17 +1676,17 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1659
1676
|
value: function syncProductsMap() {
|
|
1660
1677
|
var t0 = performance.now();
|
|
1661
1678
|
this.store.map.clear();
|
|
1662
|
-
var
|
|
1663
|
-
|
|
1679
|
+
var _iterator10 = _createForOfIteratorHelper(this.store.list),
|
|
1680
|
+
_step10;
|
|
1664
1681
|
try {
|
|
1665
|
-
for (
|
|
1666
|
-
var product =
|
|
1682
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
1683
|
+
var product = _step10.value;
|
|
1667
1684
|
this.store.map.set(product.id, product);
|
|
1668
1685
|
}
|
|
1669
1686
|
} catch (err) {
|
|
1670
|
-
|
|
1687
|
+
_iterator10.e(err);
|
|
1671
1688
|
} finally {
|
|
1672
|
-
|
|
1689
|
+
_iterator10.f();
|
|
1673
1690
|
}
|
|
1674
1691
|
perfMark('syncProductsMap', performance.now() - t0, {
|
|
1675
1692
|
count: this.store.map.size
|
|
@@ -1881,7 +1898,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1881
1898
|
key: "processProductSyncMessages",
|
|
1882
1899
|
value: (function () {
|
|
1883
1900
|
var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1884
|
-
var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache,
|
|
1901
|
+
var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator11, _step11, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _bodyId, _msg$relation_product2, _msg$relation_product3, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, freshProducts, allChangedIds, hasChanges, errorMessage;
|
|
1885
1902
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1886
1903
|
while (1) switch (_context20.prev = _context20.next) {
|
|
1887
1904
|
case 0:
|
|
@@ -1901,15 +1918,15 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1901
1918
|
sseRefreshIds = [];
|
|
1902
1919
|
priceRefreshIds = [];
|
|
1903
1920
|
shouldClearPriceCache = false;
|
|
1904
|
-
|
|
1921
|
+
_iterator11 = _createForOfIteratorHelper(messages);
|
|
1905
1922
|
_context20.prev = 11;
|
|
1906
|
-
|
|
1923
|
+
_iterator11.s();
|
|
1907
1924
|
case 13:
|
|
1908
|
-
if ((
|
|
1925
|
+
if ((_step11 = _iterator11.n()).done) {
|
|
1909
1926
|
_context20.next = 36;
|
|
1910
1927
|
break;
|
|
1911
1928
|
}
|
|
1912
|
-
msg =
|
|
1929
|
+
msg = _step11.value;
|
|
1913
1930
|
channelKey = msg._channelKey || msg.module || 'product';
|
|
1914
1931
|
if (!(channelKey === 'product')) {
|
|
1915
1932
|
_context20.next = 33;
|
|
@@ -1975,10 +1992,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1975
1992
|
case 38:
|
|
1976
1993
|
_context20.prev = 38;
|
|
1977
1994
|
_context20.t0 = _context20["catch"](11);
|
|
1978
|
-
|
|
1995
|
+
_iterator11.e(_context20.t0);
|
|
1979
1996
|
case 41:
|
|
1980
1997
|
_context20.prev = 41;
|
|
1981
|
-
|
|
1998
|
+
_iterator11.f();
|
|
1982
1999
|
return _context20.finish(41);
|
|
1983
2000
|
case 44:
|
|
1984
2001
|
uniqueDeleteIds = _toConsumableArray(new Set(deleteIds));
|
|
@@ -2149,7 +2166,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2149
2166
|
key: "applyBodyUpdatesToStore",
|
|
2150
2167
|
value: (function () {
|
|
2151
2168
|
var _applyBodyUpdatesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(bodyUpdates) {
|
|
2152
|
-
var updatedCount, newCount, appliedIds,
|
|
2169
|
+
var updatedCount, newCount, appliedIds, _iterator12, _step12, _step12$value, id, body;
|
|
2153
2170
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2154
2171
|
while (1) switch (_context22.prev = _context22.next) {
|
|
2155
2172
|
case 0:
|
|
@@ -2167,19 +2184,19 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2167
2184
|
}
|
|
2168
2185
|
return p;
|
|
2169
2186
|
});
|
|
2170
|
-
|
|
2187
|
+
_iterator12 = _createForOfIteratorHelper(bodyUpdates);
|
|
2171
2188
|
try {
|
|
2172
|
-
for (
|
|
2173
|
-
|
|
2189
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
2190
|
+
_step12$value = _slicedToArray(_step12.value, 2), id = _step12$value[0], body = _step12$value[1];
|
|
2174
2191
|
if (!appliedIds.has(id)) {
|
|
2175
2192
|
this.store.list.push(body);
|
|
2176
2193
|
newCount++;
|
|
2177
2194
|
}
|
|
2178
2195
|
}
|
|
2179
2196
|
} catch (err) {
|
|
2180
|
-
|
|
2197
|
+
_iterator12.e(err);
|
|
2181
2198
|
} finally {
|
|
2182
|
-
|
|
2199
|
+
_iterator12.f();
|
|
2183
2200
|
}
|
|
2184
2201
|
this.syncProductsMap();
|
|
2185
2202
|
_context22.next = 10;
|
|
@@ -2212,21 +2229,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2212
2229
|
key: "mergeProductsToStore",
|
|
2213
2230
|
value: (function () {
|
|
2214
2231
|
var _mergeProductsToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(freshProducts) {
|
|
2215
|
-
var freshMap,
|
|
2232
|
+
var freshMap, _iterator13, _step13, p, updatedList, newCount, _iterator14, _step14, _p2, updatedCount;
|
|
2216
2233
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2217
2234
|
while (1) switch (_context23.prev = _context23.next) {
|
|
2218
2235
|
case 0:
|
|
2219
2236
|
freshMap = new Map();
|
|
2220
|
-
|
|
2237
|
+
_iterator13 = _createForOfIteratorHelper(freshProducts);
|
|
2221
2238
|
try {
|
|
2222
|
-
for (
|
|
2223
|
-
p =
|
|
2239
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
2240
|
+
p = _step13.value;
|
|
2224
2241
|
freshMap.set(p.id, p);
|
|
2225
2242
|
}
|
|
2226
2243
|
} catch (err) {
|
|
2227
|
-
|
|
2244
|
+
_iterator13.e(err);
|
|
2228
2245
|
} finally {
|
|
2229
|
-
|
|
2246
|
+
_iterator13.f();
|
|
2230
2247
|
}
|
|
2231
2248
|
updatedList = this.store.list.map(function (p) {
|
|
2232
2249
|
if (freshMap.has(p.id)) {
|
|
@@ -2237,16 +2254,16 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2237
2254
|
return p;
|
|
2238
2255
|
}); // freshMap 中剩余的是新商品(create 场景)
|
|
2239
2256
|
newCount = freshMap.size;
|
|
2240
|
-
|
|
2257
|
+
_iterator14 = _createForOfIteratorHelper(freshMap.values());
|
|
2241
2258
|
try {
|
|
2242
|
-
for (
|
|
2243
|
-
_p2 =
|
|
2259
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
2260
|
+
_p2 = _step14.value;
|
|
2244
2261
|
updatedList.push(_p2);
|
|
2245
2262
|
}
|
|
2246
2263
|
} catch (err) {
|
|
2247
|
-
|
|
2264
|
+
_iterator14.e(err);
|
|
2248
2265
|
} finally {
|
|
2249
|
-
|
|
2266
|
+
_iterator14.f();
|
|
2250
2267
|
}
|
|
2251
2268
|
updatedCount = freshProducts.length - newCount;
|
|
2252
2269
|
this.store.list = updatedList;
|
|
@@ -257,6 +257,7 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
257
257
|
}, {
|
|
258
258
|
key: "getScheduleByIds",
|
|
259
259
|
value: function getScheduleByIds(ids) {
|
|
260
|
+
var _this2 = this;
|
|
260
261
|
if (!ids || ids.length === 0) {
|
|
261
262
|
this.logInfo('getScheduleByIds: 未提供有效的 ids', {
|
|
262
263
|
idsCount: 0
|
|
@@ -264,15 +265,21 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
264
265
|
return [];
|
|
265
266
|
}
|
|
266
267
|
var result = [];
|
|
268
|
+
var scheduleList = this.store.scheduleList || [];
|
|
267
269
|
var _iterator = _createForOfIteratorHelper(ids),
|
|
268
270
|
_step;
|
|
269
271
|
try {
|
|
270
|
-
|
|
272
|
+
var _loop = function _loop() {
|
|
271
273
|
var id = _step.value;
|
|
272
|
-
var schedule =
|
|
274
|
+
var schedule = _this2.store.map.get(id) || scheduleList.find(function (item) {
|
|
275
|
+
return String(item.id) === String(id);
|
|
276
|
+
});
|
|
273
277
|
if (schedule) {
|
|
274
278
|
result.push(schedule);
|
|
275
279
|
}
|
|
280
|
+
};
|
|
281
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
282
|
+
_loop();
|
|
276
283
|
}
|
|
277
284
|
} catch (err) {
|
|
278
285
|
_iterator.e(err);
|
|
@@ -371,11 +378,11 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
371
378
|
}, {
|
|
372
379
|
key: "getDateIsInSchedule",
|
|
373
380
|
value: function getDateIsInSchedule(date, scheduleList) {
|
|
374
|
-
var
|
|
381
|
+
var _this3 = this;
|
|
375
382
|
var scheduleListData = [];
|
|
376
383
|
scheduleList.forEach(function (item) {
|
|
377
384
|
if (typeof item === 'number') {
|
|
378
|
-
scheduleListData.push.apply(scheduleListData, _toConsumableArray(
|
|
385
|
+
scheduleListData.push.apply(scheduleListData, _toConsumableArray(_this3.getScheduleByIds([item])));
|
|
379
386
|
} else {
|
|
380
387
|
scheduleListData.push(item);
|
|
381
388
|
}
|
|
@@ -446,7 +453,7 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
446
453
|
key: "saveScheduleToIndexDB",
|
|
447
454
|
value: (function () {
|
|
448
455
|
var _saveScheduleToIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(scheduleList) {
|
|
449
|
-
var
|
|
456
|
+
var _this4 = this;
|
|
450
457
|
var savePromises, errorMessage;
|
|
451
458
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
452
459
|
while (1) switch (_context5.prev = _context5.next) {
|
|
@@ -467,7 +474,7 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
467
474
|
case 7:
|
|
468
475
|
// 逐个保存日程(每个日程是独立的记录)
|
|
469
476
|
savePromises = scheduleList.map(function (schedule) {
|
|
470
|
-
return
|
|
477
|
+
return _this4.dbManager.add(INDEXDB_STORE_NAME, schedule);
|
|
471
478
|
});
|
|
472
479
|
_context5.next = 10;
|
|
473
480
|
return Promise.all(savePromises);
|