@pisell/pisellos 2.2.178 → 2.2.179
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/index.js +9 -0
- package/dist/modules/Customer/index.d.ts +0 -6
- package/dist/modules/Customer/index.js +83 -129
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +93 -8
- package/dist/modules/Discount/types.d.ts +7 -1
- package/dist/modules/Order/index.d.ts +18 -88
- package/dist/modules/Order/index.js +501 -1357
- package/dist/modules/Order/types.d.ts +19 -198
- package/dist/modules/Order/types.js +0 -31
- package/dist/modules/Order/utils.d.ts +1 -50
- package/dist/modules/Order/utils.js +32 -261
- package/dist/modules/Quotation/index.d.ts +1 -0
- package/dist/modules/Quotation/index.js +21 -23
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +10 -26
- package/dist/modules/SalesSummary/index.js +2 -4
- package/dist/modules/SalesSummary/utils.js +7 -21
- package/dist/modules/Schedule/index.js +2 -6
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +1 -2
- package/dist/server/index.js +29 -87
- package/dist/server/modules/order/index.d.ts +0 -23
- package/dist/server/modules/order/index.js +46 -123
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/server/modules/order/utils/filterOrders.js +6 -20
- package/dist/server/modules/products/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +113 -130
- package/dist/server/modules/schedule/index.js +6 -13
- package/dist/solution/BaseSales/index.d.ts +7 -89
- package/dist/solution/BaseSales/index.js +375 -1494
- package/dist/solution/BaseSales/types.d.ts +1 -67
- package/dist/solution/BaseSales/types.js +1 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
- package/dist/solution/BaseSales/utils.js +8 -46
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -133
- package/dist/solution/BookingTicket/index.js +175 -780
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/BookingTicket/types.js +0 -3
- package/dist/solution/BookingTicket/utils/cartView.js +2 -4
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +128 -231
- package/dist/solution/ScanOrder/utils.js +8 -46
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +9 -5
- package/dist/solution/VenueBooking/index.js +55 -103
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/modules/Customer/index.d.ts +0 -6
- package/lib/modules/Customer/index.js +11 -26
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +63 -8
- package/lib/modules/Discount/types.d.ts +7 -1
- package/lib/modules/Order/index.d.ts +18 -88
- package/lib/modules/Order/index.js +149 -677
- package/lib/modules/Order/types.d.ts +19 -198
- package/lib/modules/Order/types.js +0 -1
- package/lib/modules/Order/utils.d.ts +1 -50
- package/lib/modules/Order/utils.js +22 -229
- package/lib/modules/Quotation/index.d.ts +1 -0
- package/lib/modules/Quotation/index.js +15 -18
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +14 -22
- package/lib/modules/SalesSummary/index.js +2 -4
- package/lib/modules/SalesSummary/utils.js +7 -21
- package/lib/modules/Schedule/index.js +1 -3
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +1 -3
- package/lib/server/index.js +4 -41
- package/lib/server/modules/order/index.d.ts +0 -23
- package/lib/server/modules/order/index.js +14 -46
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +4 -12
- package/lib/server/modules/products/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +20 -30
- package/lib/server/modules/schedule/index.js +1 -2
- package/lib/solution/BaseSales/index.d.ts +7 -89
- package/lib/solution/BaseSales/index.js +22 -736
- package/lib/solution/BaseSales/types.d.ts +1 -67
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
- package/lib/solution/BaseSales/utils.js +6 -46
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -133
- package/lib/solution/BookingTicket/index.js +8 -352
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/BookingTicket/types.js +0 -6
- package/lib/solution/BookingTicket/utils/cartView.js +2 -4
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +66 -147
- package/lib/solution/ScanOrder/utils.js +6 -46
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +9 -5
- package/lib/solution/VenueBooking/index.js +14 -50
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/package.json +2 -2
- package/dist/modules/BookingContext/index.d.ts +0 -37
- package/dist/modules/BookingContext/index.js +0 -436
- 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 -193
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
- 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/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 -212
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1258
- 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 -113
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/lib/modules/BookingContext/index.d.ts +0 -37
- package/lib/modules/BookingContext/index.js +0 -297
- 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 -207
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
- 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/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 -207
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/lib/solution/BaseSales/utils/cartPromotion.js +0 -836
- 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 -113
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
-
/** 从订单 payments 提取支付方式 code,与 UI 筛选选项及 filterBookings 一致 */
|
|
3
|
-
function getOrderPaymentCodes(order) {
|
|
4
|
-
var payments = order.payments;
|
|
5
|
-
if (!Array.isArray(payments) || payments.length === 0) {
|
|
6
|
-
return [];
|
|
7
|
-
}
|
|
8
|
-
return payments.map(function (item) {
|
|
9
|
-
return item === null || item === void 0 ? void 0 : item.code;
|
|
10
|
-
}).filter(function (code) {
|
|
11
|
-
return typeof code === 'string' && code.length > 0;
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
2
|
/**
|
|
16
3
|
* 订单过滤函数
|
|
17
4
|
* @param orders 原始订单列表
|
|
@@ -139,23 +126,22 @@ export function filterOrders(orders, filters) {
|
|
|
139
126
|
}
|
|
140
127
|
}
|
|
141
128
|
|
|
142
|
-
// payment_methods -
|
|
129
|
+
// payment_methods - 支付方式
|
|
143
130
|
if (safeFilters.payment_methods && safeFilters.payment_methods.length > 0) {
|
|
144
|
-
|
|
145
|
-
if (orderPaymentCodes.length === 0) {
|
|
131
|
+
if (!order.payment_methods || !Array.isArray(order.payment_methods) || order.payment_methods.length === 0) {
|
|
146
132
|
rejected.push({
|
|
147
133
|
order_id: order.order_id,
|
|
148
134
|
order_number: order.order_number,
|
|
149
135
|
reason: {
|
|
150
136
|
field: 'payment_methods',
|
|
151
|
-
actual: order.
|
|
137
|
+
actual: order.payment_methods,
|
|
152
138
|
expected: safeFilters.payment_methods
|
|
153
139
|
}
|
|
154
140
|
});
|
|
155
141
|
return false;
|
|
156
142
|
}
|
|
157
|
-
var hasMatch =
|
|
158
|
-
return safeFilters.payment_methods.includes(
|
|
143
|
+
var hasMatch = order.payment_methods.some(function (pm) {
|
|
144
|
+
return safeFilters.payment_methods.includes(pm);
|
|
159
145
|
});
|
|
160
146
|
if (!hasMatch) {
|
|
161
147
|
rejected.push({
|
|
@@ -163,7 +149,7 @@ export function filterOrders(orders, filters) {
|
|
|
163
149
|
order_number: order.order_number,
|
|
164
150
|
reason: {
|
|
165
151
|
field: 'payment_methods',
|
|
166
|
-
actual:
|
|
152
|
+
actual: order.payment_methods,
|
|
167
153
|
expected: safeFilters.payment_methods
|
|
168
154
|
}
|
|
169
155
|
});
|
|
@@ -21,7 +21,7 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
21
21
|
private isPriceFormatterRegistered;
|
|
22
22
|
private quotationPriceBridge?;
|
|
23
23
|
private quotationBridgeChannel?;
|
|
24
|
-
private
|
|
24
|
+
private quotationBridgeCustomerId?;
|
|
25
25
|
private quotationBridgeRefreshPromise?;
|
|
26
26
|
private quotationBridgeRefreshKey?;
|
|
27
27
|
private productDataSource;
|
|
@@ -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), "quotationBridgeCustomerId", void 0);
|
|
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, _params$scheduleModul, _params$scheduleModul2, scheduleList, scheduleMap;
|
|
281
281
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
282
282
|
while (1) switch (_context3.prev = _context3.next) {
|
|
283
283
|
case 0:
|
|
@@ -301,32 +301,14 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
301
301
|
this.quotationPriceBridge = quotation;
|
|
302
302
|
case 10:
|
|
303
303
|
if (params.scheduleModule) {
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
scheduleList = ((_params$scheduleModul = (_params$scheduleModul2 = params.scheduleModule).getScheduleList) === null || _params$scheduleModul === void 0 ? void 0 : _params$scheduleModul.call(_params$scheduleModul2)) || [];
|
|
305
|
+
scheduleMap = new Map(scheduleList.map(function (schedule) {
|
|
306
|
+
return [schedule.id, schedule];
|
|
307
|
+
}));
|
|
306
308
|
this.quotationPriceBridge.setScheduleResolver(function (id) {
|
|
307
|
-
var _params$scheduleModul3, _params$scheduleModul4
|
|
308
|
-
|
|
309
|
-
|
|
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]);
|
|
309
|
+
var _params$scheduleModul3, _params$scheduleModul4;
|
|
310
|
+
if (scheduleMap.has(id)) return scheduleMap.get(id);
|
|
311
|
+
var schedules = ((_params$scheduleModul3 = (_params$scheduleModul4 = params.scheduleModule).getScheduleByIds) === null || _params$scheduleModul3 === void 0 ? void 0 : _params$scheduleModul3.call(_params$scheduleModul4, [id])) || [];
|
|
330
312
|
return schedules[0];
|
|
331
313
|
});
|
|
332
314
|
}
|
|
@@ -354,7 +336,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
354
336
|
value: (function () {
|
|
355
337
|
var _refreshQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
356
338
|
var _this3 = this;
|
|
357
|
-
var refreshKey;
|
|
339
|
+
var customerId, refreshKey;
|
|
358
340
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
359
341
|
while (1) switch (_context4.prev = _context4.next) {
|
|
360
342
|
case 0:
|
|
@@ -364,35 +346,37 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
364
346
|
}
|
|
365
347
|
return _context4.abrupt("return");
|
|
366
348
|
case 2:
|
|
367
|
-
|
|
349
|
+
customerId = params && 'customer_id' in params ? params.customer_id : this.quotationBridgeCustomerId;
|
|
350
|
+
refreshKey = this.getQuotationBridgeScopeKey(customerId);
|
|
368
351
|
if (!(this.quotationBridgeRefreshPromise && this.quotationBridgeRefreshKey === refreshKey)) {
|
|
369
|
-
_context4.next =
|
|
352
|
+
_context4.next = 8;
|
|
370
353
|
break;
|
|
371
354
|
}
|
|
372
|
-
_context4.next =
|
|
355
|
+
_context4.next = 7;
|
|
373
356
|
return this.quotationBridgeRefreshPromise;
|
|
374
|
-
case 6:
|
|
375
|
-
return _context4.abrupt("return");
|
|
376
357
|
case 7:
|
|
358
|
+
return _context4.abrupt("return");
|
|
359
|
+
case 8:
|
|
377
360
|
if (!this.quotationBridgeRefreshPromise) {
|
|
378
|
-
_context4.next =
|
|
361
|
+
_context4.next = 11;
|
|
379
362
|
break;
|
|
380
363
|
}
|
|
381
|
-
_context4.next =
|
|
364
|
+
_context4.next = 11;
|
|
382
365
|
return this.quotationBridgeRefreshPromise;
|
|
383
|
-
case
|
|
366
|
+
case 11:
|
|
384
367
|
this.quotationBridgeRefreshKey = refreshKey;
|
|
385
368
|
this.quotationBridgeRefreshPromise = this.quotationPriceBridge.loadQuotations({
|
|
386
|
-
channel: this.quotationBridgeChannel
|
|
369
|
+
channel: this.quotationBridgeChannel,
|
|
370
|
+
customer_id: customerId
|
|
387
371
|
}).then(function () {
|
|
388
|
-
_this3.
|
|
372
|
+
_this3.quotationBridgeCustomerId = customerId;
|
|
389
373
|
}).finally(function () {
|
|
390
374
|
_this3.quotationBridgeRefreshPromise = undefined;
|
|
391
375
|
_this3.quotationBridgeRefreshKey = undefined;
|
|
392
376
|
});
|
|
393
|
-
_context4.next =
|
|
377
|
+
_context4.next = 15;
|
|
394
378
|
return this.quotationBridgeRefreshPromise;
|
|
395
|
-
case
|
|
379
|
+
case 15:
|
|
396
380
|
case "end":
|
|
397
381
|
return _context4.stop();
|
|
398
382
|
}
|
|
@@ -430,7 +414,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
430
414
|
_context5.next = 7;
|
|
431
415
|
return this.quotationBridgeRefreshPromise;
|
|
432
416
|
case 7:
|
|
433
|
-
if (!(this.getQuotationBridgeScopeKey() !== this.
|
|
417
|
+
if (!(this.getQuotationBridgeScopeKey(customerId) !== this.getQuotationBridgeScopeKey(this.quotationBridgeCustomerId))) {
|
|
434
418
|
_context5.next = 10;
|
|
435
419
|
break;
|
|
436
420
|
}
|
|
@@ -451,24 +435,23 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
451
435
|
}()
|
|
452
436
|
}, {
|
|
453
437
|
key: "getQuotationBridgeScopeKey",
|
|
454
|
-
value: function getQuotationBridgeScopeKey() {
|
|
455
|
-
return this.quotationBridgeChannel || '';
|
|
438
|
+
value: function getQuotationBridgeScopeKey(customerId) {
|
|
439
|
+
return "".concat(this.quotationBridgeChannel || '', ":").concat(customerId !== null && customerId !== void 0 ? customerId : '');
|
|
456
440
|
}
|
|
457
441
|
}, {
|
|
458
442
|
key: "buildPriceDataFromQuotation",
|
|
459
443
|
value: function buildPriceDataFromQuotation(product, datetime, customerId) {
|
|
460
|
-
var _this$quotationPriceB, _ref2,
|
|
444
|
+
var _this$quotationPriceB, _ref2, _product$base_price;
|
|
461
445
|
var quotedPrice = (_this$quotationPriceB = this.quotationPriceBridge) === null || _this$quotationPriceB === void 0 ? void 0 : _this$quotationPriceB.getPriceForProduct({
|
|
462
446
|
productId: product.id,
|
|
463
447
|
datetime: datetime,
|
|
464
448
|
customer_id: customerId
|
|
465
449
|
});
|
|
466
450
|
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;
|
|
468
451
|
return {
|
|
469
452
|
id: product.id,
|
|
470
453
|
price: String(productPrice !== null && productPrice !== void 0 ? productPrice : 0),
|
|
471
|
-
base_price: String(
|
|
454
|
+
base_price: String((_ref2 = (_product$base_price = product.base_price) !== null && _product$base_price !== void 0 ? _product$base_price : product.price) !== null && _ref2 !== void 0 ? _ref2 : 0),
|
|
472
455
|
variant: this.buildVariantPriceData(product, datetime, customerId),
|
|
473
456
|
bundle_group: this.buildBundleGroupPriceData(product, datetime, customerId)
|
|
474
457
|
};
|
|
@@ -479,15 +462,15 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
479
462
|
var _this4 = this;
|
|
480
463
|
if (!Array.isArray(product.variant)) return [];
|
|
481
464
|
return product.variant.map(function (variant) {
|
|
482
|
-
var _this4$quotationPrice, _ref4, _ref5, _ref6, _ref7,
|
|
465
|
+
var _this4$quotationPrice, _ref3, _ref4, _ref5, _ref6, _ref7, _variant$base_price, _variant$product_id;
|
|
483
466
|
var quotedPrice = (_this4$quotationPrice = _this4.quotationPriceBridge) === null || _this4$quotationPrice === void 0 ? void 0 : _this4$quotationPrice.getPriceForProduct({
|
|
484
467
|
productId: product.id,
|
|
485
468
|
variantId: Number(variant.id),
|
|
486
469
|
datetime: datetime,
|
|
487
470
|
customer_id: customerId
|
|
488
471
|
});
|
|
489
|
-
var price = (
|
|
490
|
-
var basePrice = (
|
|
472
|
+
var price = (_ref3 = (_ref4 = quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : variant.price) !== null && _ref4 !== void 0 ? _ref4 : product.price) !== null && _ref3 !== void 0 ? _ref3 : 0;
|
|
473
|
+
var basePrice = (_ref5 = (_ref6 = (_ref7 = (_variant$base_price = variant.base_price) !== null && _variant$base_price !== void 0 ? _variant$base_price : variant.price) !== null && _ref7 !== void 0 ? _ref7 : product.base_price) !== null && _ref6 !== void 0 ? _ref6 : product.price) !== null && _ref5 !== void 0 ? _ref5 : 0;
|
|
491
474
|
return {
|
|
492
475
|
id: Number(variant.id),
|
|
493
476
|
product_id: Number((_variant$product_id = variant.product_id) !== null && _variant$product_id !== void 0 ? _variant$product_id : product.id),
|
|
@@ -505,7 +488,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
505
488
|
return {
|
|
506
489
|
id: Number(group.id),
|
|
507
490
|
bundle_item: (group.bundle_item || []).map(function (item) {
|
|
508
|
-
var _this5$quotationPrice,
|
|
491
|
+
var _this5$quotationPrice, _ref8, _ref9, _item$base_price, _item$product_id, _item$group_id;
|
|
509
492
|
var bundleProductId = Number(item.bundle_product_id);
|
|
510
493
|
var bundleVariantId = Number(item.bundle_variant_id || 0);
|
|
511
494
|
var quotedPrice = (_this5$quotationPrice = _this5.quotationPriceBridge) === null || _this5$quotationPrice === void 0 ? void 0 : _this5$quotationPrice.getPriceForProduct({
|
|
@@ -514,8 +497,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
514
497
|
datetime: datetime,
|
|
515
498
|
customer_id: customerId
|
|
516
499
|
});
|
|
517
|
-
var price = (
|
|
518
|
-
var basePrice = (
|
|
500
|
+
var price = (_ref8 = quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : item.price) !== null && _ref8 !== void 0 ? _ref8 : 0;
|
|
501
|
+
var basePrice = (_ref9 = (_item$base_price = item.base_price) !== null && _item$base_price !== void 0 ? _item$base_price : item.price) !== null && _ref9 !== void 0 ? _ref9 : 0;
|
|
519
502
|
return {
|
|
520
503
|
id: Number(item.id),
|
|
521
504
|
product_id: Number((_item$product_id = item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : product.id),
|
|
@@ -548,7 +531,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
548
531
|
value: (function () {
|
|
549
532
|
var _getProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(schedule_date, extraContext, options) {
|
|
550
533
|
var _options$changedIds;
|
|
551
|
-
var t0, scopedProductIds, cacheKey, scopedProductIdSet, changedIds, cachedProducts, updatedProducts, updatedMap, mergedCache,
|
|
534
|
+
var t0, scopedProductIds, cacheKey, scopedProductIdSet, changedIds, cachedProducts, updatedProducts, updatedMap, mergedCache, _iterator, _step, p, _iterator2, _step2, _p, errorMessage, result;
|
|
552
535
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
553
536
|
while (1) switch (_context6.prev = _context6.next) {
|
|
554
537
|
case 0:
|
|
@@ -589,10 +572,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
589
572
|
return [p.id, p];
|
|
590
573
|
}));
|
|
591
574
|
mergedCache = [];
|
|
592
|
-
|
|
575
|
+
_iterator = _createForOfIteratorHelper(cachedProducts);
|
|
593
576
|
try {
|
|
594
|
-
for (
|
|
595
|
-
p =
|
|
577
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
578
|
+
p = _step.value;
|
|
596
579
|
if (updatedMap.has(p.id)) {
|
|
597
580
|
mergedCache.push(updatedMap.get(p.id));
|
|
598
581
|
updatedMap.delete(p.id);
|
|
@@ -602,20 +585,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
602
585
|
}
|
|
603
586
|
// 剩余的是新增商品(create 场景)
|
|
604
587
|
} catch (err) {
|
|
605
|
-
|
|
588
|
+
_iterator.e(err);
|
|
606
589
|
} finally {
|
|
607
|
-
|
|
590
|
+
_iterator.f();
|
|
608
591
|
}
|
|
609
|
-
|
|
592
|
+
_iterator2 = _createForOfIteratorHelper(updatedMap.values());
|
|
610
593
|
try {
|
|
611
|
-
for (
|
|
612
|
-
_p =
|
|
594
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
595
|
+
_p = _step2.value;
|
|
613
596
|
mergedCache.push(_p);
|
|
614
597
|
}
|
|
615
598
|
} catch (err) {
|
|
616
|
-
|
|
599
|
+
_iterator2.e(err);
|
|
617
600
|
} finally {
|
|
618
|
-
|
|
601
|
+
_iterator2.f();
|
|
619
602
|
}
|
|
620
603
|
this.productsPriceCache.set(cacheKey, mergedCache);
|
|
621
604
|
this.logInfo('增量更新完成', {
|
|
@@ -850,25 +833,25 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
850
833
|
}
|
|
851
834
|
if (productIds.length === 0 && collectionIds.length === 0) return [];
|
|
852
835
|
var result = new Set();
|
|
853
|
-
var
|
|
854
|
-
|
|
836
|
+
var _iterator3 = _createForOfIteratorHelper(productIds),
|
|
837
|
+
_step3;
|
|
855
838
|
try {
|
|
856
|
-
for (
|
|
857
|
-
var id =
|
|
839
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
840
|
+
var id = _step3.value;
|
|
858
841
|
if (this.store.map.has(id)) result.add(id);
|
|
859
842
|
}
|
|
860
843
|
} catch (err) {
|
|
861
|
-
|
|
844
|
+
_iterator3.e(err);
|
|
862
845
|
} finally {
|
|
863
|
-
|
|
846
|
+
_iterator3.f();
|
|
864
847
|
}
|
|
865
848
|
if (collectionIds.length === 0) return Array.from(result);
|
|
866
849
|
var collectionIdSet = new Set(collectionIds);
|
|
867
|
-
var
|
|
868
|
-
|
|
850
|
+
var _iterator4 = _createForOfIteratorHelper(this.getProductsRef()),
|
|
851
|
+
_step4;
|
|
869
852
|
try {
|
|
870
|
-
for (
|
|
871
|
-
var product =
|
|
853
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
854
|
+
var product = _step4.value;
|
|
872
855
|
if (result.has(product.id)) continue;
|
|
873
856
|
if (!Array.isArray(product.collection)) continue;
|
|
874
857
|
var isInCollection = product.collection.some(function (collection) {
|
|
@@ -877,9 +860,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
877
860
|
if (isInCollection) result.add(product.id);
|
|
878
861
|
}
|
|
879
862
|
} catch (err) {
|
|
880
|
-
|
|
863
|
+
_iterator4.e(err);
|
|
881
864
|
} finally {
|
|
882
|
-
|
|
865
|
+
_iterator4.f();
|
|
883
866
|
}
|
|
884
867
|
return Array.from(result);
|
|
885
868
|
}
|
|
@@ -1158,11 +1141,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1158
1141
|
key: "fetchProductsByHttp",
|
|
1159
1142
|
value: (function () {
|
|
1160
1143
|
var _fetchProductsByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
1161
|
-
var
|
|
1144
|
+
var _ref10, _ref10$category_ids, category_ids, _ref10$product_ids, product_ids, _ref10$collection, collection, customer_id, cacheId, startTime, _this$otherParams3, _productsData$data, productsData, productList, duration, _duration2, errorMessage;
|
|
1162
1145
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1163
1146
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1164
1147
|
case 0:
|
|
1165
|
-
|
|
1148
|
+
_ref10 = params || {}, _ref10$category_ids = _ref10.category_ids, category_ids = _ref10$category_ids === void 0 ? [] : _ref10$category_ids, _ref10$product_ids = _ref10.product_ids, product_ids = _ref10$product_ids === void 0 ? [] : _ref10$product_ids, _ref10$collection = _ref10.collection, collection = _ref10$collection === void 0 ? [] : _ref10$collection, customer_id = _ref10.customer_id, cacheId = _ref10.cacheId;
|
|
1166
1149
|
this.logInfo('fetchProductsByHttp: 开始请求', {
|
|
1167
1150
|
categoryIdsCount: category_ids.length,
|
|
1168
1151
|
productIdsCount: product_ids.length,
|
|
@@ -1310,18 +1293,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1310
1293
|
key: "getProductsRefByIds",
|
|
1311
1294
|
value: function getProductsRefByIds(ids) {
|
|
1312
1295
|
var products = [];
|
|
1313
|
-
var
|
|
1314
|
-
|
|
1296
|
+
var _iterator5 = _createForOfIteratorHelper(ids),
|
|
1297
|
+
_step5;
|
|
1315
1298
|
try {
|
|
1316
|
-
for (
|
|
1317
|
-
var id =
|
|
1299
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1300
|
+
var id = _step5.value;
|
|
1318
1301
|
var product = this.store.map.get(id);
|
|
1319
1302
|
if (product) products.push(product);
|
|
1320
1303
|
}
|
|
1321
1304
|
} catch (err) {
|
|
1322
|
-
|
|
1305
|
+
_iterator5.e(err);
|
|
1323
1306
|
} finally {
|
|
1324
|
-
|
|
1307
|
+
_iterator5.f();
|
|
1325
1308
|
}
|
|
1326
1309
|
return products;
|
|
1327
1310
|
}
|
|
@@ -1360,7 +1343,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1360
1343
|
key: "removeProductsByIds",
|
|
1361
1344
|
value: (function () {
|
|
1362
1345
|
var _removeProductsByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(ids) {
|
|
1363
|
-
var idSet,
|
|
1346
|
+
var idSet, _iterator6, _step6, _id, _iterator7, _step7, id, errorMessage, _iterator8, _step8, _step8$value, dateKey, cachedProducts;
|
|
1364
1347
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1365
1348
|
while (1) switch (_context14.prev = _context14.next) {
|
|
1366
1349
|
case 0:
|
|
@@ -1372,31 +1355,31 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1372
1355
|
this.store.list = this.store.list.filter(function (p) {
|
|
1373
1356
|
return !idSet.has(p.id);
|
|
1374
1357
|
});
|
|
1375
|
-
|
|
1358
|
+
_iterator6 = _createForOfIteratorHelper(ids);
|
|
1376
1359
|
try {
|
|
1377
|
-
for (
|
|
1378
|
-
_id =
|
|
1360
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1361
|
+
_id = _step6.value;
|
|
1379
1362
|
this.store.map.delete(_id);
|
|
1380
1363
|
}
|
|
1381
1364
|
} catch (err) {
|
|
1382
|
-
|
|
1365
|
+
_iterator6.e(err);
|
|
1383
1366
|
} finally {
|
|
1384
|
-
|
|
1367
|
+
_iterator6.f();
|
|
1385
1368
|
}
|
|
1386
1369
|
if (!this.dbManager) {
|
|
1387
1370
|
_context14.next = 30;
|
|
1388
1371
|
break;
|
|
1389
1372
|
}
|
|
1390
1373
|
_context14.prev = 6;
|
|
1391
|
-
|
|
1374
|
+
_iterator7 = _createForOfIteratorHelper(ids);
|
|
1392
1375
|
_context14.prev = 8;
|
|
1393
|
-
|
|
1376
|
+
_iterator7.s();
|
|
1394
1377
|
case 10:
|
|
1395
|
-
if ((
|
|
1378
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
1396
1379
|
_context14.next = 16;
|
|
1397
1380
|
break;
|
|
1398
1381
|
}
|
|
1399
|
-
id =
|
|
1382
|
+
id = _step7.value;
|
|
1400
1383
|
_context14.next = 14;
|
|
1401
1384
|
return this.dbManager.delete(INDEXDB_STORE_NAME, id);
|
|
1402
1385
|
case 14:
|
|
@@ -1408,10 +1391,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1408
1391
|
case 18:
|
|
1409
1392
|
_context14.prev = 18;
|
|
1410
1393
|
_context14.t0 = _context14["catch"](8);
|
|
1411
|
-
|
|
1394
|
+
_iterator7.e(_context14.t0);
|
|
1412
1395
|
case 21:
|
|
1413
1396
|
_context14.prev = 21;
|
|
1414
|
-
|
|
1397
|
+
_iterator7.f();
|
|
1415
1398
|
return _context14.finish(21);
|
|
1416
1399
|
case 24:
|
|
1417
1400
|
_context14.next = 30;
|
|
@@ -1425,18 +1408,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1425
1408
|
error: errorMessage
|
|
1426
1409
|
});
|
|
1427
1410
|
case 30:
|
|
1428
|
-
|
|
1411
|
+
_iterator8 = _createForOfIteratorHelper(this.productsPriceCache.entries());
|
|
1429
1412
|
try {
|
|
1430
|
-
for (
|
|
1431
|
-
|
|
1413
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1414
|
+
_step8$value = _slicedToArray(_step8.value, 2), dateKey = _step8$value[0], cachedProducts = _step8$value[1];
|
|
1432
1415
|
this.productsPriceCache.set(dateKey, cachedProducts.filter(function (p) {
|
|
1433
1416
|
return !idSet.has(p.id);
|
|
1434
1417
|
}));
|
|
1435
1418
|
}
|
|
1436
1419
|
} catch (err) {
|
|
1437
|
-
|
|
1420
|
+
_iterator8.e(err);
|
|
1438
1421
|
} finally {
|
|
1439
|
-
|
|
1422
|
+
_iterator8.f();
|
|
1440
1423
|
}
|
|
1441
1424
|
this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
|
|
1442
1425
|
this.logInfo('removeProductsByIds 完成', {
|
|
@@ -1676,17 +1659,17 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1676
1659
|
value: function syncProductsMap() {
|
|
1677
1660
|
var t0 = performance.now();
|
|
1678
1661
|
this.store.map.clear();
|
|
1679
|
-
var
|
|
1680
|
-
|
|
1662
|
+
var _iterator9 = _createForOfIteratorHelper(this.store.list),
|
|
1663
|
+
_step9;
|
|
1681
1664
|
try {
|
|
1682
|
-
for (
|
|
1683
|
-
var product =
|
|
1665
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1666
|
+
var product = _step9.value;
|
|
1684
1667
|
this.store.map.set(product.id, product);
|
|
1685
1668
|
}
|
|
1686
1669
|
} catch (err) {
|
|
1687
|
-
|
|
1670
|
+
_iterator9.e(err);
|
|
1688
1671
|
} finally {
|
|
1689
|
-
|
|
1672
|
+
_iterator9.f();
|
|
1690
1673
|
}
|
|
1691
1674
|
perfMark('syncProductsMap', performance.now() - t0, {
|
|
1692
1675
|
count: this.store.map.size
|
|
@@ -1898,7 +1881,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1898
1881
|
key: "processProductSyncMessages",
|
|
1899
1882
|
value: (function () {
|
|
1900
1883
|
var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1901
|
-
var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache,
|
|
1884
|
+
var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator10, _step10, 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;
|
|
1902
1885
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1903
1886
|
while (1) switch (_context20.prev = _context20.next) {
|
|
1904
1887
|
case 0:
|
|
@@ -1918,15 +1901,15 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1918
1901
|
sseRefreshIds = [];
|
|
1919
1902
|
priceRefreshIds = [];
|
|
1920
1903
|
shouldClearPriceCache = false;
|
|
1921
|
-
|
|
1904
|
+
_iterator10 = _createForOfIteratorHelper(messages);
|
|
1922
1905
|
_context20.prev = 11;
|
|
1923
|
-
|
|
1906
|
+
_iterator10.s();
|
|
1924
1907
|
case 13:
|
|
1925
|
-
if ((
|
|
1908
|
+
if ((_step10 = _iterator10.n()).done) {
|
|
1926
1909
|
_context20.next = 36;
|
|
1927
1910
|
break;
|
|
1928
1911
|
}
|
|
1929
|
-
msg =
|
|
1912
|
+
msg = _step10.value;
|
|
1930
1913
|
channelKey = msg._channelKey || msg.module || 'product';
|
|
1931
1914
|
if (!(channelKey === 'product')) {
|
|
1932
1915
|
_context20.next = 33;
|
|
@@ -1992,10 +1975,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1992
1975
|
case 38:
|
|
1993
1976
|
_context20.prev = 38;
|
|
1994
1977
|
_context20.t0 = _context20["catch"](11);
|
|
1995
|
-
|
|
1978
|
+
_iterator10.e(_context20.t0);
|
|
1996
1979
|
case 41:
|
|
1997
1980
|
_context20.prev = 41;
|
|
1998
|
-
|
|
1981
|
+
_iterator10.f();
|
|
1999
1982
|
return _context20.finish(41);
|
|
2000
1983
|
case 44:
|
|
2001
1984
|
uniqueDeleteIds = _toConsumableArray(new Set(deleteIds));
|
|
@@ -2166,7 +2149,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2166
2149
|
key: "applyBodyUpdatesToStore",
|
|
2167
2150
|
value: (function () {
|
|
2168
2151
|
var _applyBodyUpdatesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(bodyUpdates) {
|
|
2169
|
-
var updatedCount, newCount, appliedIds,
|
|
2152
|
+
var updatedCount, newCount, appliedIds, _iterator11, _step11, _step11$value, id, body;
|
|
2170
2153
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2171
2154
|
while (1) switch (_context22.prev = _context22.next) {
|
|
2172
2155
|
case 0:
|
|
@@ -2184,19 +2167,19 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2184
2167
|
}
|
|
2185
2168
|
return p;
|
|
2186
2169
|
});
|
|
2187
|
-
|
|
2170
|
+
_iterator11 = _createForOfIteratorHelper(bodyUpdates);
|
|
2188
2171
|
try {
|
|
2189
|
-
for (
|
|
2190
|
-
|
|
2172
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
2173
|
+
_step11$value = _slicedToArray(_step11.value, 2), id = _step11$value[0], body = _step11$value[1];
|
|
2191
2174
|
if (!appliedIds.has(id)) {
|
|
2192
2175
|
this.store.list.push(body);
|
|
2193
2176
|
newCount++;
|
|
2194
2177
|
}
|
|
2195
2178
|
}
|
|
2196
2179
|
} catch (err) {
|
|
2197
|
-
|
|
2180
|
+
_iterator11.e(err);
|
|
2198
2181
|
} finally {
|
|
2199
|
-
|
|
2182
|
+
_iterator11.f();
|
|
2200
2183
|
}
|
|
2201
2184
|
this.syncProductsMap();
|
|
2202
2185
|
_context22.next = 10;
|
|
@@ -2229,21 +2212,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2229
2212
|
key: "mergeProductsToStore",
|
|
2230
2213
|
value: (function () {
|
|
2231
2214
|
var _mergeProductsToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(freshProducts) {
|
|
2232
|
-
var freshMap,
|
|
2215
|
+
var freshMap, _iterator12, _step12, p, updatedList, newCount, _iterator13, _step13, _p2, updatedCount;
|
|
2233
2216
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2234
2217
|
while (1) switch (_context23.prev = _context23.next) {
|
|
2235
2218
|
case 0:
|
|
2236
2219
|
freshMap = new Map();
|
|
2237
|
-
|
|
2220
|
+
_iterator12 = _createForOfIteratorHelper(freshProducts);
|
|
2238
2221
|
try {
|
|
2239
|
-
for (
|
|
2240
|
-
p =
|
|
2222
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
2223
|
+
p = _step12.value;
|
|
2241
2224
|
freshMap.set(p.id, p);
|
|
2242
2225
|
}
|
|
2243
2226
|
} catch (err) {
|
|
2244
|
-
|
|
2227
|
+
_iterator12.e(err);
|
|
2245
2228
|
} finally {
|
|
2246
|
-
|
|
2229
|
+
_iterator12.f();
|
|
2247
2230
|
}
|
|
2248
2231
|
updatedList = this.store.list.map(function (p) {
|
|
2249
2232
|
if (freshMap.has(p.id)) {
|
|
@@ -2254,16 +2237,16 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2254
2237
|
return p;
|
|
2255
2238
|
}); // freshMap 中剩余的是新商品(create 场景)
|
|
2256
2239
|
newCount = freshMap.size;
|
|
2257
|
-
|
|
2240
|
+
_iterator13 = _createForOfIteratorHelper(freshMap.values());
|
|
2258
2241
|
try {
|
|
2259
|
-
for (
|
|
2260
|
-
_p2 =
|
|
2242
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
2243
|
+
_p2 = _step13.value;
|
|
2261
2244
|
updatedList.push(_p2);
|
|
2262
2245
|
}
|
|
2263
2246
|
} catch (err) {
|
|
2264
|
-
|
|
2247
|
+
_iterator13.e(err);
|
|
2265
2248
|
} finally {
|
|
2266
|
-
|
|
2249
|
+
_iterator13.f();
|
|
2267
2250
|
}
|
|
2268
2251
|
updatedCount = freshProducts.length - newCount;
|
|
2269
2252
|
this.store.list = updatedList;
|