@pisell/pisellos 2.1.152 → 2.1.154
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/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +11 -6
- package/dist/solution/ScanOrder/index.js +750 -428
- package/dist/solution/ScanOrder/types.d.ts +20 -1
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +13 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +11 -6
- package/lib/solution/ScanOrder/index.js +324 -101
- package/lib/solution/ScanOrder/types.d.ts +20 -1
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +11 -0
- package/package.json +1 -1
|
@@ -1335,8 +1335,70 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1335
1335
|
combined_resource: isCombined ? combined : null
|
|
1336
1336
|
};
|
|
1337
1337
|
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1338
|
+
}, {
|
|
1339
|
+
key: "prepareRetailAvailability",
|
|
1340
|
+
value: function () {
|
|
1341
|
+
var _prepareRetailAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
1342
|
+
var _this$store$order4, _this$otherParams4;
|
|
1343
|
+
var tempOrder, hasOrderId, resourceId, reason, resourceState, availabilityInfo;
|
|
1344
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1345
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1346
|
+
case 0:
|
|
1347
|
+
tempOrder = params.tempOrder, hasOrderId = params.hasOrderId, resourceId = params.resourceId, reason = params.reason;
|
|
1348
|
+
this.enabledReservationRuleProducts = [];
|
|
1349
|
+
tempOrder.bookings = [];
|
|
1350
|
+
tempOrder.order_id = null;
|
|
1351
|
+
delete tempOrder.relation_id;
|
|
1352
|
+
delete tempOrder.table_form_id;
|
|
1353
|
+
delete tempOrder.resource_id;
|
|
1354
|
+
delete tempOrder.table_number;
|
|
1355
|
+
tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
|
|
1356
|
+
delete tempOrder.metadata.table_occupancy_duration;
|
|
1357
|
+
resourceState = {
|
|
1358
|
+
mode: 'idle',
|
|
1359
|
+
deskmate_valid: false,
|
|
1360
|
+
allowSnack: false,
|
|
1361
|
+
deskmateValid: false,
|
|
1362
|
+
isExclusive: false,
|
|
1363
|
+
isFull: false,
|
|
1364
|
+
raw: null
|
|
1365
|
+
};
|
|
1366
|
+
this.store.resource = resourceState;
|
|
1367
|
+
(_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || _this$store$order4.persistTempOrder();
|
|
1368
|
+
_context17.next = 15;
|
|
1369
|
+
return this.addNewOrder();
|
|
1370
|
+
case 15:
|
|
1371
|
+
_context17.next = 17;
|
|
1372
|
+
return this.setItemRuleRuntimeConfig({
|
|
1373
|
+
serviceType: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode,
|
|
1374
|
+
submissionIndex: hasOrderId ? 1 : 0,
|
|
1375
|
+
historicalItems: []
|
|
1376
|
+
});
|
|
1377
|
+
case 17:
|
|
1378
|
+
availabilityInfo = {
|
|
1379
|
+
mode: 'idle',
|
|
1380
|
+
deskmate_valid: false
|
|
1381
|
+
};
|
|
1382
|
+
this.logMethodSuccess('checkResourceAvailable', {
|
|
1383
|
+
resourceId: resourceId,
|
|
1384
|
+
mode: availabilityInfo.mode,
|
|
1385
|
+
retailMode: true,
|
|
1386
|
+
retailReason: reason,
|
|
1387
|
+
persistedRelationId: tempOrder.relation_id,
|
|
1388
|
+
persistedResourceId: tempOrder.resource_id
|
|
1389
|
+
});
|
|
1390
|
+
return _context17.abrupt("return", availabilityInfo);
|
|
1391
|
+
case 20:
|
|
1392
|
+
case "end":
|
|
1393
|
+
return _context17.stop();
|
|
1394
|
+
}
|
|
1395
|
+
}, _callee17, this);
|
|
1396
|
+
}));
|
|
1397
|
+
function prepareRetailAvailability(_x10) {
|
|
1398
|
+
return _prepareRetailAvailability.apply(this, arguments);
|
|
1399
|
+
}
|
|
1400
|
+
return prepareRetailAvailability;
|
|
1401
|
+
}() // ScanOrder 提交 payload enhancer:
|
|
1340
1402
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
1341
1403
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
1342
1404
|
// - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
|
|
@@ -1349,25 +1411,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1349
1411
|
var resourceState = this.store.resource;
|
|
1350
1412
|
var resourceSelectType = resourceState === null || resourceState === void 0 ? void 0 : resourceState.resourceSelectType;
|
|
1351
1413
|
|
|
1352
|
-
//
|
|
1353
|
-
var
|
|
1414
|
+
// ScanOrder 的 booking 容量只由预约规则决定:single 占用整张桌台,multiple 占用 1 个容量位。
|
|
1415
|
+
var resolveBookingCapacityValue = function resolveBookingCapacityValue() {
|
|
1354
1416
|
if (resourceSelectType === 'single') {
|
|
1355
1417
|
var _resourceState$table_;
|
|
1356
1418
|
var raw = resourceState === null || resourceState === void 0 || (_resourceState$table_ = resourceState.table_form_record) === null || _resourceState$table_ === void 0 ? void 0 : _resourceState$table_.capacity;
|
|
1357
1419
|
var num = Number(raw);
|
|
1358
|
-
if (Number.isFinite(num) && num > 0) return num;
|
|
1420
|
+
if (Number.isFinite(num) && num > 0) return Math.max(1, Math.floor(num));
|
|
1359
1421
|
return 1;
|
|
1360
1422
|
}
|
|
1361
1423
|
return 1;
|
|
1362
1424
|
};
|
|
1363
1425
|
return function (payload, _ref3) {
|
|
1364
|
-
var _tempOrder$resource_i, _tempOrder$metadata,
|
|
1426
|
+
var _ref4, _tempOrder$resource_i, _tempOrder$metadata, _ref5, _pickOriginal, _resourceState$table_2, _resourceState$relati, _pickFirstCustomCapac;
|
|
1365
1427
|
var bookingUuid = _ref3.bookingUuid,
|
|
1366
1428
|
tempOrder = _ref3.tempOrder;
|
|
1367
|
-
var resourceId = (_tempOrder$resource_i = tempOrder.resource_id) !== null && _tempOrder$resource_i !== void 0 ? _tempOrder$resource_i : resourceState === null || resourceState === void 0 ? void 0 : resourceState.relationId;
|
|
1429
|
+
var resourceId = String((_ref4 = (_tempOrder$resource_i = tempOrder.resource_id) !== null && _tempOrder$resource_i !== void 0 ? _tempOrder$resource_i : resourceState === null || resourceState === void 0 ? void 0 : resourceState.relationId) !== null && _ref4 !== void 0 ? _ref4 : '').trim();
|
|
1430
|
+
var hasReservationBookingContext = Boolean(ruleProduct && resourceState && resourceId && (tempOrder.relation_id || resourceState.relationId) && (tempOrder.table_form_id || resourceState.tableFormId));
|
|
1431
|
+
if (!hasReservationBookingContext) {
|
|
1432
|
+
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
1433
|
+
bookings: [],
|
|
1434
|
+
products: _toConsumableArray(payload.products || [])
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1368
1437
|
var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
|
|
1369
|
-
var
|
|
1370
|
-
var
|
|
1438
|
+
var hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
|
|
1439
|
+
var bookingCapacityValue = resolveBookingCapacityValue();
|
|
1371
1440
|
var pickOriginal = function pickOriginal(value) {
|
|
1372
1441
|
if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
|
|
1373
1442
|
var original = value.original;
|
|
@@ -1375,7 +1444,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1375
1444
|
}
|
|
1376
1445
|
return undefined;
|
|
1377
1446
|
};
|
|
1378
|
-
var mainField = (
|
|
1447
|
+
var mainField = (_ref5 = (_pickOriginal = pickOriginal(tempOrder.table_number)) !== null && _pickOriginal !== void 0 ? _pickOriginal : pickOriginal(resourceState === null || resourceState === void 0 || (_resourceState$table_2 = resourceState.table_form_record) === null || _resourceState$table_2 === void 0 ? void 0 : _resourceState$table_2.name)) !== null && _ref5 !== void 0 ? _ref5 : '';
|
|
1379
1448
|
var resourceEntry = resourceState && resourceId ? {
|
|
1380
1449
|
relation_type: 'form',
|
|
1381
1450
|
like_status: 'common',
|
|
@@ -1383,21 +1452,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1383
1452
|
main_field: mainField,
|
|
1384
1453
|
form_id: resourceState.tableFormId,
|
|
1385
1454
|
relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
|
|
1386
|
-
capacity:
|
|
1455
|
+
capacity: bookingCapacityValue,
|
|
1387
1456
|
metadata: _this5.buildScanOrderResourceMetadata({
|
|
1388
1457
|
resourceState: resourceState,
|
|
1389
1458
|
resourceName: mainField
|
|
1390
1459
|
})
|
|
1391
1460
|
} : undefined;
|
|
1392
1461
|
var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
|
|
1393
|
-
// 有 collect_pax 时 booking/resource capacity 与 number 都代表本次 pax;否则使用资源占用兜底值。
|
|
1394
|
-
var bookingCapacityValue = resourceCapacityValue;
|
|
1395
1462
|
var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
|
|
1396
1463
|
var nextBookings = (payload.bookings || []).map(function (booking, idx) {
|
|
1464
|
+
var metadata = _objectSpread({}, booking.metadata || {});
|
|
1465
|
+
if (hasExplicitCollectPax) {
|
|
1466
|
+
metadata.collect_pax = normalizeSubmitCollectPaxValue(rawCollectPax);
|
|
1467
|
+
} else {
|
|
1468
|
+
delete metadata.collect_pax;
|
|
1469
|
+
}
|
|
1397
1470
|
return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
|
|
1398
1471
|
number: bookingCapacityValue,
|
|
1399
1472
|
appointment_status: 'started',
|
|
1400
|
-
metadata: _objectSpread(_objectSpread(_objectSpread({},
|
|
1473
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, metadata), resourceSelectType ? {
|
|
1401
1474
|
resource_select_type: resourceSelectType
|
|
1402
1475
|
} : {}), resourceSelectType ? {
|
|
1403
1476
|
capacity: [{
|
|
@@ -1415,9 +1488,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1415
1488
|
var nextProducts = _toConsumableArray(payload.products || []);
|
|
1416
1489
|
// 加餐(已有 order_id)走 scanOrderMore,原单已含 booking 规则行,勿再追加虚拟规则商品
|
|
1417
1490
|
if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
|
|
1418
|
-
var _ruleProduct$price,
|
|
1491
|
+
var _ruleProduct$price, _ref6, _ruleProduct$original, _ruleProduct$is_gst;
|
|
1419
1492
|
var sellingPrice = String((_ruleProduct$price = ruleProduct.price) !== null && _ruleProduct$price !== void 0 ? _ruleProduct$price : '0.00');
|
|
1420
|
-
var originalPrice = String((
|
|
1493
|
+
var originalPrice = String((_ref6 = (_ruleProduct$original = ruleProduct.original_price) !== null && _ruleProduct$original !== void 0 ? _ruleProduct$original : ruleProduct.price) !== null && _ref6 !== void 0 ? _ref6 : '0.00');
|
|
1421
1494
|
nextProducts.push({
|
|
1422
1495
|
product_id: ruleProduct.id,
|
|
1423
1496
|
product_variant_id: 0,
|
|
@@ -1446,28 +1519,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1446
1519
|
}, {
|
|
1447
1520
|
key: "submitScanOrder",
|
|
1448
1521
|
value: function () {
|
|
1449
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1450
|
-
var _this$store$resource, _this$
|
|
1451
|
-
return _regeneratorRuntime().wrap(function
|
|
1452
|
-
while (1) switch (
|
|
1522
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1523
|
+
var _this$store$resource, _this$otherParams5, _this$otherParams6, _this$otherParams7, _this$otherParams8, _tempOrder$products, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
|
|
1524
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1525
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1453
1526
|
case 0:
|
|
1454
1527
|
this.logMethodStart('submitScanOrder');
|
|
1455
|
-
|
|
1456
|
-
|
|
1528
|
+
_context18.prev = 1;
|
|
1529
|
+
_context18.next = 4;
|
|
1457
1530
|
return this.validateBeforeSubmitByItemRule();
|
|
1458
1531
|
case 4:
|
|
1459
1532
|
if (this.store.order) {
|
|
1460
|
-
|
|
1533
|
+
_context18.next = 6;
|
|
1461
1534
|
break;
|
|
1462
1535
|
}
|
|
1463
1536
|
throw new Error('scanOrder解决方案需要 order 模块支持');
|
|
1464
1537
|
case 6:
|
|
1465
|
-
pax = normalizeSubmitCollectPaxValue(this.store.entryPaxNumber);
|
|
1466
|
-
this.store.entryPaxNumber = pax;
|
|
1467
1538
|
tempOrderForSubmit = this.store.order.ensureTempOrder();
|
|
1468
|
-
tempOrderForSubmit.metadata = _objectSpread(_objectSpread({}, tempOrderForSubmit.metadata), {}, {
|
|
1469
|
-
collect_pax: pax
|
|
1470
|
-
});
|
|
1471
1539
|
tempOrderForSubmit.delivery_type = 'shop_service';
|
|
1472
1540
|
resourceTableName = (_this$store$resource = this.store.resource) === null || _this$store$resource === void 0 || (_this$store$resource = _this$store$resource.table_form_record) === null || _this$store$resource === void 0 ? void 0 : _this$store$resource.name;
|
|
1473
1541
|
if (resourceTableName && _typeof(resourceTableName) === 'object') {
|
|
@@ -1477,32 +1545,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1477
1545
|
}
|
|
1478
1546
|
this.store.order.persistTempOrder();
|
|
1479
1547
|
enhancePayload = this.buildSubmitPayloadEnhancer();
|
|
1480
|
-
|
|
1548
|
+
_context18.next = 14;
|
|
1481
1549
|
return this.store.order.submitTempOrder({
|
|
1482
1550
|
cacheId: this.cacheId,
|
|
1483
|
-
platform: (_this$
|
|
1484
|
-
businessCode: (_this$
|
|
1485
|
-
channel: (_this$
|
|
1486
|
-
type: (_this$
|
|
1551
|
+
platform: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform,
|
|
1552
|
+
businessCode: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode,
|
|
1553
|
+
channel: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.channel,
|
|
1554
|
+
type: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.type,
|
|
1487
1555
|
enhancePayload: enhancePayload
|
|
1488
1556
|
});
|
|
1489
|
-
case
|
|
1490
|
-
result =
|
|
1557
|
+
case 14:
|
|
1558
|
+
result = _context18.sent;
|
|
1491
1559
|
tempOrder = this.store.order.getTempOrder();
|
|
1492
1560
|
this.logMethodSuccess('submitScanOrder', {
|
|
1493
1561
|
productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
|
|
1494
1562
|
});
|
|
1495
|
-
return
|
|
1496
|
-
case
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
this.logMethodError('submitScanOrder',
|
|
1500
|
-
throw
|
|
1501
|
-
case
|
|
1563
|
+
return _context18.abrupt("return", result);
|
|
1564
|
+
case 20:
|
|
1565
|
+
_context18.prev = 20;
|
|
1566
|
+
_context18.t0 = _context18["catch"](1);
|
|
1567
|
+
this.logMethodError('submitScanOrder', _context18.t0);
|
|
1568
|
+
throw _context18.t0;
|
|
1569
|
+
case 24:
|
|
1502
1570
|
case "end":
|
|
1503
|
-
return
|
|
1571
|
+
return _context18.stop();
|
|
1504
1572
|
}
|
|
1505
|
-
},
|
|
1573
|
+
}, _callee18, this, [[1, 20]]);
|
|
1506
1574
|
}));
|
|
1507
1575
|
function submitScanOrder() {
|
|
1508
1576
|
return _submitScanOrder.apply(this, arguments);
|
|
@@ -1512,48 +1580,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1512
1580
|
}, {
|
|
1513
1581
|
key: "addProductToOrder",
|
|
1514
1582
|
value: function () {
|
|
1515
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1583
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(product) {
|
|
1516
1584
|
var products;
|
|
1517
|
-
return _regeneratorRuntime().wrap(function
|
|
1518
|
-
while (1) switch (
|
|
1585
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1586
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1519
1587
|
case 0:
|
|
1520
1588
|
this.logMethodStart('addProductToOrder', {
|
|
1521
1589
|
product_id: product.product_id,
|
|
1522
1590
|
product_variant_id: product.product_variant_id
|
|
1523
1591
|
});
|
|
1524
|
-
|
|
1592
|
+
_context19.prev = 1;
|
|
1525
1593
|
if (this.store.order) {
|
|
1526
|
-
|
|
1594
|
+
_context19.next = 4;
|
|
1527
1595
|
break;
|
|
1528
1596
|
}
|
|
1529
1597
|
throw new Error('order 模块未初始化');
|
|
1530
1598
|
case 4:
|
|
1531
|
-
|
|
1599
|
+
_context19.next = 6;
|
|
1532
1600
|
return this.store.order.addProductToOrder(product);
|
|
1533
1601
|
case 6:
|
|
1534
|
-
products =
|
|
1535
|
-
|
|
1602
|
+
products = _context19.sent;
|
|
1603
|
+
_context19.next = 9;
|
|
1536
1604
|
return this.refreshItemRuleQuantityLimits();
|
|
1537
1605
|
case 9:
|
|
1538
|
-
|
|
1606
|
+
_context19.next = 11;
|
|
1539
1607
|
return this.refreshCartValidationPassed();
|
|
1540
1608
|
case 11:
|
|
1541
1609
|
this.logMethodSuccess('addProductToOrder', {
|
|
1542
1610
|
productCount: products.length
|
|
1543
1611
|
});
|
|
1544
|
-
return
|
|
1612
|
+
return _context19.abrupt("return", products);
|
|
1545
1613
|
case 15:
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
this.logMethodError('addProductToOrder',
|
|
1549
|
-
throw
|
|
1614
|
+
_context19.prev = 15;
|
|
1615
|
+
_context19.t0 = _context19["catch"](1);
|
|
1616
|
+
this.logMethodError('addProductToOrder', _context19.t0);
|
|
1617
|
+
throw _context19.t0;
|
|
1550
1618
|
case 19:
|
|
1551
1619
|
case "end":
|
|
1552
|
-
return
|
|
1620
|
+
return _context19.stop();
|
|
1553
1621
|
}
|
|
1554
|
-
},
|
|
1622
|
+
}, _callee19, this, [[1, 15]]);
|
|
1555
1623
|
}));
|
|
1556
|
-
function addProductToOrder(
|
|
1624
|
+
function addProductToOrder(_x11) {
|
|
1557
1625
|
return _addProductToOrder.apply(this, arguments);
|
|
1558
1626
|
}
|
|
1559
1627
|
return addProductToOrder;
|
|
@@ -1561,48 +1629,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1561
1629
|
}, {
|
|
1562
1630
|
key: "updateProductInOrder",
|
|
1563
1631
|
value: function () {
|
|
1564
|
-
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1632
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1565
1633
|
var products;
|
|
1566
|
-
return _regeneratorRuntime().wrap(function
|
|
1567
|
-
while (1) switch (
|
|
1634
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1635
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1568
1636
|
case 0:
|
|
1569
1637
|
this.logMethodStart('updateProductInOrder', {
|
|
1570
1638
|
product_id: params.product_id,
|
|
1571
1639
|
product_variant_id: params.product_variant_id
|
|
1572
1640
|
});
|
|
1573
|
-
|
|
1641
|
+
_context20.prev = 1;
|
|
1574
1642
|
if (this.store.order) {
|
|
1575
|
-
|
|
1643
|
+
_context20.next = 4;
|
|
1576
1644
|
break;
|
|
1577
1645
|
}
|
|
1578
1646
|
throw new Error('order 模块未初始化');
|
|
1579
1647
|
case 4:
|
|
1580
|
-
|
|
1648
|
+
_context20.next = 6;
|
|
1581
1649
|
return this.store.order.updateProductInOrder(params);
|
|
1582
1650
|
case 6:
|
|
1583
|
-
products =
|
|
1584
|
-
|
|
1651
|
+
products = _context20.sent;
|
|
1652
|
+
_context20.next = 9;
|
|
1585
1653
|
return this.refreshItemRuleQuantityLimits();
|
|
1586
1654
|
case 9:
|
|
1587
|
-
|
|
1655
|
+
_context20.next = 11;
|
|
1588
1656
|
return this.refreshCartValidationPassed();
|
|
1589
1657
|
case 11:
|
|
1590
1658
|
this.logMethodSuccess('updateProductInOrder', {
|
|
1591
1659
|
productCount: products.length
|
|
1592
1660
|
});
|
|
1593
|
-
return
|
|
1661
|
+
return _context20.abrupt("return", products);
|
|
1594
1662
|
case 15:
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
this.logMethodError('updateProductInOrder',
|
|
1598
|
-
throw
|
|
1663
|
+
_context20.prev = 15;
|
|
1664
|
+
_context20.t0 = _context20["catch"](1);
|
|
1665
|
+
this.logMethodError('updateProductInOrder', _context20.t0);
|
|
1666
|
+
throw _context20.t0;
|
|
1599
1667
|
case 19:
|
|
1600
1668
|
case "end":
|
|
1601
|
-
return
|
|
1669
|
+
return _context20.stop();
|
|
1602
1670
|
}
|
|
1603
|
-
},
|
|
1671
|
+
}, _callee20, this, [[1, 15]]);
|
|
1604
1672
|
}));
|
|
1605
|
-
function updateProductInOrder(
|
|
1673
|
+
function updateProductInOrder(_x12) {
|
|
1606
1674
|
return _updateProductInOrder.apply(this, arguments);
|
|
1607
1675
|
}
|
|
1608
1676
|
return updateProductInOrder;
|
|
@@ -1614,16 +1682,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1614
1682
|
}, {
|
|
1615
1683
|
key: "setOrderProductLineNote",
|
|
1616
1684
|
value: (function () {
|
|
1617
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1685
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identity, note) {
|
|
1618
1686
|
var params, products;
|
|
1619
|
-
return _regeneratorRuntime().wrap(function
|
|
1620
|
-
while (1) switch (
|
|
1687
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1688
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1621
1689
|
case 0:
|
|
1622
1690
|
this.logMethodStart('setOrderProductLineNote', {
|
|
1623
1691
|
product_id: identity.product_id,
|
|
1624
1692
|
product_variant_id: identity.product_variant_id
|
|
1625
1693
|
});
|
|
1626
|
-
|
|
1694
|
+
_context21.prev = 1;
|
|
1627
1695
|
params = {
|
|
1628
1696
|
product_id: identity.product_id,
|
|
1629
1697
|
product_variant_id: identity.product_variant_id,
|
|
@@ -1636,26 +1704,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1636
1704
|
params.product_option_item = identity.product_option_item;
|
|
1637
1705
|
}
|
|
1638
1706
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
1639
|
-
|
|
1707
|
+
_context21.next = 8;
|
|
1640
1708
|
return this.updateProductInOrder(params);
|
|
1641
1709
|
case 8:
|
|
1642
|
-
products =
|
|
1710
|
+
products = _context21.sent;
|
|
1643
1711
|
this.logMethodSuccess('setOrderProductLineNote', {
|
|
1644
1712
|
productCount: products.length
|
|
1645
1713
|
});
|
|
1646
|
-
return
|
|
1714
|
+
return _context21.abrupt("return", products);
|
|
1647
1715
|
case 13:
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
this.logMethodError('setOrderProductLineNote',
|
|
1651
|
-
throw
|
|
1716
|
+
_context21.prev = 13;
|
|
1717
|
+
_context21.t0 = _context21["catch"](1);
|
|
1718
|
+
this.logMethodError('setOrderProductLineNote', _context21.t0);
|
|
1719
|
+
throw _context21.t0;
|
|
1652
1720
|
case 17:
|
|
1653
1721
|
case "end":
|
|
1654
|
-
return
|
|
1722
|
+
return _context21.stop();
|
|
1655
1723
|
}
|
|
1656
|
-
},
|
|
1724
|
+
}, _callee21, this, [[1, 13]]);
|
|
1657
1725
|
}));
|
|
1658
|
-
function setOrderProductLineNote(
|
|
1726
|
+
function setOrderProductLineNote(_x13, _x14) {
|
|
1659
1727
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
1660
1728
|
}
|
|
1661
1729
|
return setOrderProductLineNote;
|
|
@@ -1663,48 +1731,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1663
1731
|
}, {
|
|
1664
1732
|
key: "removeProductFromOrder",
|
|
1665
1733
|
value: function () {
|
|
1666
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1734
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(identity) {
|
|
1667
1735
|
var products;
|
|
1668
|
-
return _regeneratorRuntime().wrap(function
|
|
1669
|
-
while (1) switch (
|
|
1736
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1737
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1670
1738
|
case 0:
|
|
1671
1739
|
this.logMethodStart('removeProductFromOrder', {
|
|
1672
1740
|
product_id: identity.product_id,
|
|
1673
1741
|
product_variant_id: identity.product_variant_id
|
|
1674
1742
|
});
|
|
1675
|
-
|
|
1743
|
+
_context22.prev = 1;
|
|
1676
1744
|
if (this.store.order) {
|
|
1677
|
-
|
|
1745
|
+
_context22.next = 4;
|
|
1678
1746
|
break;
|
|
1679
1747
|
}
|
|
1680
1748
|
throw new Error('order 模块未初始化');
|
|
1681
1749
|
case 4:
|
|
1682
|
-
|
|
1750
|
+
_context22.next = 6;
|
|
1683
1751
|
return this.store.order.removeProductFromOrder(identity);
|
|
1684
1752
|
case 6:
|
|
1685
|
-
products =
|
|
1686
|
-
|
|
1753
|
+
products = _context22.sent;
|
|
1754
|
+
_context22.next = 9;
|
|
1687
1755
|
return this.refreshItemRuleQuantityLimits();
|
|
1688
1756
|
case 9:
|
|
1689
|
-
|
|
1757
|
+
_context22.next = 11;
|
|
1690
1758
|
return this.refreshCartValidationPassed();
|
|
1691
1759
|
case 11:
|
|
1692
1760
|
this.logMethodSuccess('removeProductFromOrder', {
|
|
1693
1761
|
productCount: products.length
|
|
1694
1762
|
});
|
|
1695
|
-
return
|
|
1763
|
+
return _context22.abrupt("return", products);
|
|
1696
1764
|
case 15:
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
this.logMethodError('removeProductFromOrder',
|
|
1700
|
-
throw
|
|
1765
|
+
_context22.prev = 15;
|
|
1766
|
+
_context22.t0 = _context22["catch"](1);
|
|
1767
|
+
this.logMethodError('removeProductFromOrder', _context22.t0);
|
|
1768
|
+
throw _context22.t0;
|
|
1701
1769
|
case 19:
|
|
1702
1770
|
case "end":
|
|
1703
|
-
return
|
|
1771
|
+
return _context22.stop();
|
|
1704
1772
|
}
|
|
1705
|
-
},
|
|
1773
|
+
}, _callee22, this, [[1, 15]]);
|
|
1706
1774
|
}));
|
|
1707
|
-
function removeProductFromOrder(
|
|
1775
|
+
function removeProductFromOrder(_x15) {
|
|
1708
1776
|
return _removeProductFromOrder.apply(this, arguments);
|
|
1709
1777
|
}
|
|
1710
1778
|
return removeProductFromOrder;
|
|
@@ -1712,26 +1780,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1712
1780
|
}, {
|
|
1713
1781
|
key: "loadRuntimeConfigs",
|
|
1714
1782
|
value: function () {
|
|
1715
|
-
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1783
|
+
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1716
1784
|
var itemRuleConfigs;
|
|
1717
|
-
return _regeneratorRuntime().wrap(function
|
|
1718
|
-
while (1) switch (
|
|
1785
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1786
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1719
1787
|
case 0:
|
|
1720
|
-
|
|
1788
|
+
_context23.next = 2;
|
|
1721
1789
|
return this.ensureItemRuleConfigsLoaded();
|
|
1722
1790
|
case 2:
|
|
1723
|
-
itemRuleConfigs =
|
|
1791
|
+
itemRuleConfigs = _context23.sent;
|
|
1724
1792
|
this.logMethodSuccess('loadRuntimeConfigs', {
|
|
1725
1793
|
itemRuleCount: itemRuleConfigs.length
|
|
1726
1794
|
});
|
|
1727
|
-
return
|
|
1795
|
+
return _context23.abrupt("return", {
|
|
1728
1796
|
itemRuleConfigs: itemRuleConfigs
|
|
1729
1797
|
});
|
|
1730
1798
|
case 5:
|
|
1731
1799
|
case "end":
|
|
1732
|
-
return
|
|
1800
|
+
return _context23.stop();
|
|
1733
1801
|
}
|
|
1734
|
-
},
|
|
1802
|
+
}, _callee23, this);
|
|
1735
1803
|
}));
|
|
1736
1804
|
function loadRuntimeConfigs() {
|
|
1737
1805
|
return _loadRuntimeConfigs.apply(this, arguments);
|
|
@@ -1741,15 +1809,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1741
1809
|
}, {
|
|
1742
1810
|
key: "syncItemRuleConfigsFromDineInConfig",
|
|
1743
1811
|
value: function () {
|
|
1744
|
-
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1812
|
+
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(dineInConfig) {
|
|
1745
1813
|
var enableItemRules, strategyModelIds, itemRuleConfigs;
|
|
1746
|
-
return _regeneratorRuntime().wrap(function
|
|
1747
|
-
while (1) switch (
|
|
1814
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1815
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1748
1816
|
case 0:
|
|
1749
1817
|
enableItemRules = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enable_item_rules']);
|
|
1750
1818
|
strategyModelIds = normalizeEnabledItemRuleIds(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enabled_item_rules']);
|
|
1751
1819
|
if (!(!enableItemRules || !strategyModelIds.length)) {
|
|
1752
|
-
|
|
1820
|
+
_context24.next = 8;
|
|
1753
1821
|
break;
|
|
1754
1822
|
}
|
|
1755
1823
|
this.itemRuleConfigs = [];
|
|
@@ -1760,12 +1828,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1760
1828
|
strategyModelIds: [],
|
|
1761
1829
|
itemRuleCount: 0
|
|
1762
1830
|
});
|
|
1763
|
-
return
|
|
1831
|
+
return _context24.abrupt("return", []);
|
|
1764
1832
|
case 8:
|
|
1765
|
-
|
|
1833
|
+
_context24.next = 10;
|
|
1766
1834
|
return this.fetchItemRuleConfigsByModelIds(strategyModelIds);
|
|
1767
1835
|
case 10:
|
|
1768
|
-
itemRuleConfigs =
|
|
1836
|
+
itemRuleConfigs = _context24.sent;
|
|
1769
1837
|
this.itemRuleConfigs = itemRuleConfigs;
|
|
1770
1838
|
this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
|
|
1771
1839
|
this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
|
|
@@ -1774,14 +1842,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1774
1842
|
strategyModelIds: strategyModelIds,
|
|
1775
1843
|
itemRuleCount: itemRuleConfigs.length
|
|
1776
1844
|
});
|
|
1777
|
-
return
|
|
1845
|
+
return _context24.abrupt("return", itemRuleConfigs);
|
|
1778
1846
|
case 16:
|
|
1779
1847
|
case "end":
|
|
1780
|
-
return
|
|
1848
|
+
return _context24.stop();
|
|
1781
1849
|
}
|
|
1782
|
-
},
|
|
1850
|
+
}, _callee24, this);
|
|
1783
1851
|
}));
|
|
1784
|
-
function syncItemRuleConfigsFromDineInConfig(
|
|
1852
|
+
function syncItemRuleConfigsFromDineInConfig(_x16) {
|
|
1785
1853
|
return _syncItemRuleConfigsFromDineInConfig.apply(this, arguments);
|
|
1786
1854
|
}
|
|
1787
1855
|
return syncItemRuleConfigsFromDineInConfig;
|
|
@@ -1789,22 +1857,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1789
1857
|
}, {
|
|
1790
1858
|
key: "fetchItemRuleConfigsByModelIds",
|
|
1791
1859
|
value: function () {
|
|
1792
|
-
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1860
|
+
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(strategyModelIds) {
|
|
1793
1861
|
var result, configs;
|
|
1794
|
-
return _regeneratorRuntime().wrap(function
|
|
1795
|
-
while (1) switch (
|
|
1862
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1863
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1796
1864
|
case 0:
|
|
1797
1865
|
this.logMethodStart('fetchItemRuleConfigsByModelIds', {
|
|
1798
1866
|
strategyModelIds: strategyModelIds
|
|
1799
1867
|
});
|
|
1800
1868
|
if (strategyModelIds.length) {
|
|
1801
|
-
|
|
1869
|
+
_context25.next = 3;
|
|
1802
1870
|
break;
|
|
1803
1871
|
}
|
|
1804
|
-
return
|
|
1872
|
+
return _context25.abrupt("return", []);
|
|
1805
1873
|
case 3:
|
|
1806
|
-
|
|
1807
|
-
|
|
1874
|
+
_context25.prev = 3;
|
|
1875
|
+
_context25.next = 6;
|
|
1808
1876
|
return this.request.get('/promotion', {
|
|
1809
1877
|
skip: 1,
|
|
1810
1878
|
num: 99,
|
|
@@ -1812,7 +1880,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1812
1880
|
ids: strategyModelIds
|
|
1813
1881
|
});
|
|
1814
1882
|
case 6:
|
|
1815
|
-
result =
|
|
1883
|
+
result = _context25.sent;
|
|
1816
1884
|
configs = [];
|
|
1817
1885
|
if (result.code === 200) {
|
|
1818
1886
|
configs = result.data.list.map(function (item) {
|
|
@@ -1823,22 +1891,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1823
1891
|
strategyModelIds: strategyModelIds,
|
|
1824
1892
|
strategyCount: configs.length
|
|
1825
1893
|
});
|
|
1826
|
-
return
|
|
1894
|
+
return _context25.abrupt("return", configs);
|
|
1827
1895
|
case 13:
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
this.logMethodError('fetchItemRuleConfigsByModelIds',
|
|
1896
|
+
_context25.prev = 13;
|
|
1897
|
+
_context25.t0 = _context25["catch"](3);
|
|
1898
|
+
this.logMethodError('fetchItemRuleConfigsByModelIds', _context25.t0, {
|
|
1831
1899
|
strategyModelIds: strategyModelIds
|
|
1832
1900
|
});
|
|
1833
1901
|
// A:策略加载失败时不阻塞下单
|
|
1834
|
-
return
|
|
1902
|
+
return _context25.abrupt("return", []);
|
|
1835
1903
|
case 17:
|
|
1836
1904
|
case "end":
|
|
1837
|
-
return
|
|
1905
|
+
return _context25.stop();
|
|
1838
1906
|
}
|
|
1839
|
-
},
|
|
1907
|
+
}, _callee25, this, [[3, 13]]);
|
|
1840
1908
|
}));
|
|
1841
|
-
function fetchItemRuleConfigsByModelIds(
|
|
1909
|
+
function fetchItemRuleConfigsByModelIds(_x17) {
|
|
1842
1910
|
return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
|
|
1843
1911
|
}
|
|
1844
1912
|
return fetchItemRuleConfigsByModelIds;
|
|
@@ -1846,22 +1914,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1846
1914
|
}, {
|
|
1847
1915
|
key: "buildPrefillProductSourceMap",
|
|
1848
1916
|
value: function () {
|
|
1849
|
-
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1917
|
+
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1850
1918
|
var sourceMap, productList, visited, collectFromValue;
|
|
1851
|
-
return _regeneratorRuntime().wrap(function
|
|
1852
|
-
while (1) switch (
|
|
1919
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1920
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1853
1921
|
case 0:
|
|
1854
1922
|
sourceMap = new Map();
|
|
1855
|
-
|
|
1856
|
-
|
|
1923
|
+
_context26.prev = 1;
|
|
1924
|
+
_context26.next = 4;
|
|
1857
1925
|
return this.getProductList();
|
|
1858
1926
|
case 4:
|
|
1859
|
-
productList =
|
|
1927
|
+
productList = _context26.sent;
|
|
1860
1928
|
if (Array.isArray(productList)) {
|
|
1861
|
-
|
|
1929
|
+
_context26.next = 7;
|
|
1862
1930
|
break;
|
|
1863
1931
|
}
|
|
1864
|
-
return
|
|
1932
|
+
return _context26.abrupt("return", sourceMap);
|
|
1865
1933
|
case 7:
|
|
1866
1934
|
visited = new Set();
|
|
1867
1935
|
collectFromValue = function collectFromValue(value) {
|
|
@@ -1888,8 +1956,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1888
1956
|
var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
|
|
1889
1957
|
var productId = Number(rawProductId);
|
|
1890
1958
|
if (Number.isFinite(productId) && productId > 0) {
|
|
1891
|
-
var
|
|
1892
|
-
var productVariantId = Number((
|
|
1959
|
+
var _ref7, _node$product_variant;
|
|
1960
|
+
var productVariantId = Number((_ref7 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref7 !== void 0 ? _ref7 : 0);
|
|
1893
1961
|
var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
|
|
1894
1962
|
var key = buildProductKey(productId, normalizedVariantId);
|
|
1895
1963
|
if (!sourceMap.has(key)) {
|
|
@@ -1904,19 +1972,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1904
1972
|
}
|
|
1905
1973
|
};
|
|
1906
1974
|
collectFromValue(productList);
|
|
1907
|
-
|
|
1975
|
+
_context26.next = 15;
|
|
1908
1976
|
break;
|
|
1909
1977
|
case 12:
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
this.logMethodError('buildPrefillProductSourceMap',
|
|
1978
|
+
_context26.prev = 12;
|
|
1979
|
+
_context26.t0 = _context26["catch"](1);
|
|
1980
|
+
this.logMethodError('buildPrefillProductSourceMap', _context26.t0);
|
|
1913
1981
|
case 15:
|
|
1914
|
-
return
|
|
1982
|
+
return _context26.abrupt("return", sourceMap);
|
|
1915
1983
|
case 16:
|
|
1916
1984
|
case "end":
|
|
1917
|
-
return
|
|
1985
|
+
return _context26.stop();
|
|
1918
1986
|
}
|
|
1919
|
-
},
|
|
1987
|
+
}, _callee26, this, [[1, 12]]);
|
|
1920
1988
|
}));
|
|
1921
1989
|
function buildPrefillProductSourceMap() {
|
|
1922
1990
|
return _buildPrefillProductSourceMap.apply(this, arguments);
|
|
@@ -1931,58 +1999,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1931
1999
|
}, {
|
|
1932
2000
|
key: "ensureItemRuleConfigsLoaded",
|
|
1933
2001
|
value: function () {
|
|
1934
|
-
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2002
|
+
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
1935
2003
|
var _this6 = this;
|
|
1936
2004
|
var loadedConfigs;
|
|
1937
|
-
return _regeneratorRuntime().wrap(function
|
|
1938
|
-
while (1) switch (
|
|
2005
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2006
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1939
2007
|
case 0:
|
|
1940
2008
|
if (!(this.itemRuleConfigs.length > 0)) {
|
|
1941
|
-
|
|
2009
|
+
_context28.next = 2;
|
|
1942
2010
|
break;
|
|
1943
2011
|
}
|
|
1944
|
-
return
|
|
2012
|
+
return _context28.abrupt("return", this.itemRuleConfigs);
|
|
1945
2013
|
case 2:
|
|
1946
2014
|
if (!this.itemRuleConfigsPromise) {
|
|
1947
|
-
|
|
2015
|
+
_context28.next = 4;
|
|
1948
2016
|
break;
|
|
1949
2017
|
}
|
|
1950
|
-
return
|
|
2018
|
+
return _context28.abrupt("return", this.itemRuleConfigsPromise);
|
|
1951
2019
|
case 4:
|
|
1952
|
-
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2020
|
+
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
1953
2021
|
var runtimeConfig, staticConfigs;
|
|
1954
|
-
return _regeneratorRuntime().wrap(function
|
|
1955
|
-
while (1) switch (
|
|
2022
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2023
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1956
2024
|
case 0:
|
|
1957
2025
|
runtimeConfig = _this6.getItemRuleRuntimeConfig();
|
|
1958
2026
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
1959
2027
|
if (!(staticConfigs.length > 0)) {
|
|
1960
|
-
|
|
2028
|
+
_context27.next = 6;
|
|
1961
2029
|
break;
|
|
1962
2030
|
}
|
|
1963
2031
|
_this6.itemRuleConfigs = staticConfigs;
|
|
1964
2032
|
_this6.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
1965
|
-
return
|
|
2033
|
+
return _context27.abrupt("return", _this6.itemRuleConfigs);
|
|
1966
2034
|
case 6:
|
|
1967
2035
|
_this6.itemRuleConfigs = [];
|
|
1968
2036
|
_this6.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1969
|
-
return
|
|
2037
|
+
return _context27.abrupt("return", _this6.itemRuleConfigs);
|
|
1970
2038
|
case 9:
|
|
1971
2039
|
case "end":
|
|
1972
|
-
return
|
|
2040
|
+
return _context27.stop();
|
|
1973
2041
|
}
|
|
1974
|
-
},
|
|
2042
|
+
}, _callee27);
|
|
1975
2043
|
}))();
|
|
1976
|
-
|
|
2044
|
+
_context28.next = 7;
|
|
1977
2045
|
return this.itemRuleConfigsPromise;
|
|
1978
2046
|
case 7:
|
|
1979
|
-
loadedConfigs =
|
|
1980
|
-
return
|
|
2047
|
+
loadedConfigs = _context28.sent;
|
|
2048
|
+
return _context28.abrupt("return", loadedConfigs);
|
|
1981
2049
|
case 9:
|
|
1982
2050
|
case "end":
|
|
1983
|
-
return
|
|
2051
|
+
return _context28.stop();
|
|
1984
2052
|
}
|
|
1985
|
-
},
|
|
2053
|
+
}, _callee28, this);
|
|
1986
2054
|
}));
|
|
1987
2055
|
function ensureItemRuleConfigsLoaded() {
|
|
1988
2056
|
return _ensureItemRuleConfigsLoaded.apply(this, arguments);
|
|
@@ -1992,22 +2060,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1992
2060
|
}, {
|
|
1993
2061
|
key: "refreshItemRuleQuantityLimits",
|
|
1994
2062
|
value: function () {
|
|
1995
|
-
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2063
|
+
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1996
2064
|
var strategyConfigs, businessData, limits;
|
|
1997
|
-
return _regeneratorRuntime().wrap(function
|
|
1998
|
-
while (1) switch (
|
|
2065
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2066
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1999
2067
|
case 0:
|
|
2000
|
-
|
|
2001
|
-
|
|
2068
|
+
_context29.prev = 0;
|
|
2069
|
+
_context29.next = 3;
|
|
2002
2070
|
return this.ensureItemRuleConfigsLoaded();
|
|
2003
2071
|
case 3:
|
|
2004
|
-
strategyConfigs =
|
|
2072
|
+
strategyConfigs = _context29.sent;
|
|
2005
2073
|
if (strategyConfigs.length) {
|
|
2006
|
-
|
|
2074
|
+
_context29.next = 7;
|
|
2007
2075
|
break;
|
|
2008
2076
|
}
|
|
2009
2077
|
this.store.itemRuleQuantityLimits = [];
|
|
2010
|
-
return
|
|
2078
|
+
return _context29.abrupt("return", []);
|
|
2011
2079
|
case 7:
|
|
2012
2080
|
businessData = buildItemRuleBusinessData({
|
|
2013
2081
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -2019,18 +2087,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2019
2087
|
this.logMethodSuccess('refreshItemRuleQuantityLimits', {
|
|
2020
2088
|
limitCount: limits.length
|
|
2021
2089
|
});
|
|
2022
|
-
return
|
|
2090
|
+
return _context29.abrupt("return", limits);
|
|
2023
2091
|
case 14:
|
|
2024
|
-
|
|
2025
|
-
|
|
2092
|
+
_context29.prev = 14;
|
|
2093
|
+
_context29.t0 = _context29["catch"](0);
|
|
2026
2094
|
this.store.itemRuleQuantityLimits = [];
|
|
2027
|
-
this.logMethodError('refreshItemRuleQuantityLimits',
|
|
2028
|
-
return
|
|
2095
|
+
this.logMethodError('refreshItemRuleQuantityLimits', _context29.t0);
|
|
2096
|
+
return _context29.abrupt("return", []);
|
|
2029
2097
|
case 19:
|
|
2030
2098
|
case "end":
|
|
2031
|
-
return
|
|
2099
|
+
return _context29.stop();
|
|
2032
2100
|
}
|
|
2033
|
-
},
|
|
2101
|
+
}, _callee29, this, [[0, 14]]);
|
|
2034
2102
|
}));
|
|
2035
2103
|
function refreshItemRuleQuantityLimits() {
|
|
2036
2104
|
return _refreshItemRuleQuantityLimits.apply(this, arguments);
|
|
@@ -2040,32 +2108,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2040
2108
|
}, {
|
|
2041
2109
|
key: "applyPrefillByItemRule",
|
|
2042
2110
|
value: function () {
|
|
2043
|
-
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2111
|
+
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2044
2112
|
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator6, _step6, _prefillItem$product_, _targetProduct$_origi, _targetProduct$_origi2, _targetProduct$_origi3, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
|
|
2045
|
-
return _regeneratorRuntime().wrap(function
|
|
2046
|
-
while (1) switch (
|
|
2113
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2114
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2047
2115
|
case 0:
|
|
2048
2116
|
if (!this.itemRulePrefillApplied) {
|
|
2049
|
-
|
|
2117
|
+
_context30.next = 2;
|
|
2050
2118
|
break;
|
|
2051
2119
|
}
|
|
2052
|
-
return
|
|
2120
|
+
return _context30.abrupt("return");
|
|
2053
2121
|
case 2:
|
|
2054
2122
|
if (this.store.order) {
|
|
2055
|
-
|
|
2123
|
+
_context30.next = 4;
|
|
2056
2124
|
break;
|
|
2057
2125
|
}
|
|
2058
|
-
return
|
|
2126
|
+
return _context30.abrupt("return");
|
|
2059
2127
|
case 4:
|
|
2060
|
-
|
|
2128
|
+
_context30.next = 6;
|
|
2061
2129
|
return this.ensureItemRuleConfigsLoaded();
|
|
2062
2130
|
case 6:
|
|
2063
|
-
strategyConfigs =
|
|
2131
|
+
strategyConfigs = _context30.sent;
|
|
2064
2132
|
if (strategyConfigs.length) {
|
|
2065
|
-
|
|
2133
|
+
_context30.next = 9;
|
|
2066
2134
|
break;
|
|
2067
2135
|
}
|
|
2068
|
-
return
|
|
2136
|
+
return _context30.abrupt("return");
|
|
2069
2137
|
case 9:
|
|
2070
2138
|
businessData = buildItemRuleBusinessData({
|
|
2071
2139
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -2074,24 +2142,24 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2074
2142
|
});
|
|
2075
2143
|
prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
|
|
2076
2144
|
if (prefillItems.length) {
|
|
2077
|
-
|
|
2145
|
+
_context30.next = 14;
|
|
2078
2146
|
break;
|
|
2079
2147
|
}
|
|
2080
2148
|
this.itemRulePrefillApplied = true;
|
|
2081
|
-
return
|
|
2149
|
+
return _context30.abrupt("return");
|
|
2082
2150
|
case 14:
|
|
2083
|
-
|
|
2151
|
+
_context30.next = 16;
|
|
2084
2152
|
return this.buildPrefillProductSourceMap();
|
|
2085
2153
|
case 16:
|
|
2086
|
-
productSourceMap =
|
|
2154
|
+
productSourceMap = _context30.sent;
|
|
2087
2155
|
tempOrder = this.ensureTempOrder();
|
|
2088
2156
|
hasChanges = false;
|
|
2089
2157
|
_iterator6 = _createForOfIteratorHelper(prefillItems);
|
|
2090
|
-
|
|
2158
|
+
_context30.prev = 20;
|
|
2091
2159
|
_iterator6.s();
|
|
2092
2160
|
case 22:
|
|
2093
2161
|
if ((_step6 = _iterator6.n()).done) {
|
|
2094
|
-
|
|
2162
|
+
_context30.next = 47;
|
|
2095
2163
|
break;
|
|
2096
2164
|
}
|
|
2097
2165
|
prefillItem = _step6.value;
|
|
@@ -2099,16 +2167,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2099
2167
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
2100
2168
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
2101
2169
|
if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
|
|
2102
|
-
|
|
2170
|
+
_context30.next = 29;
|
|
2103
2171
|
break;
|
|
2104
2172
|
}
|
|
2105
|
-
return
|
|
2173
|
+
return _context30.abrupt("continue", 45);
|
|
2106
2174
|
case 29:
|
|
2107
2175
|
if (!Number.isNaN(productVariantId)) {
|
|
2108
|
-
|
|
2176
|
+
_context30.next = 31;
|
|
2109
2177
|
break;
|
|
2110
2178
|
}
|
|
2111
|
-
return
|
|
2179
|
+
return _context30.abrupt("continue", 45);
|
|
2112
2180
|
case 31:
|
|
2113
2181
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
2114
2182
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
@@ -2116,7 +2184,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2116
2184
|
product_variant_id: productVariantId
|
|
2117
2185
|
});
|
|
2118
2186
|
if (!(productIndex === -1)) {
|
|
2119
|
-
|
|
2187
|
+
_context30.next = 38;
|
|
2120
2188
|
break;
|
|
2121
2189
|
}
|
|
2122
2190
|
sellingPrice = toPriceString((_sourceItem$price = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _sourceItem$price !== void 0 ? _sourceItem$price : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.selling_price, '0.00');
|
|
@@ -2136,7 +2204,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2136
2204
|
})
|
|
2137
2205
|
})));
|
|
2138
2206
|
hasChanges = true;
|
|
2139
|
-
return
|
|
2207
|
+
return _context30.abrupt("continue", 45);
|
|
2140
2208
|
case 38:
|
|
2141
2209
|
targetProduct = tempOrder.products[productIndex];
|
|
2142
2210
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
@@ -2157,34 +2225,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2157
2225
|
hasChanges = true;
|
|
2158
2226
|
}
|
|
2159
2227
|
case 45:
|
|
2160
|
-
|
|
2228
|
+
_context30.next = 22;
|
|
2161
2229
|
break;
|
|
2162
2230
|
case 47:
|
|
2163
|
-
|
|
2231
|
+
_context30.next = 52;
|
|
2164
2232
|
break;
|
|
2165
2233
|
case 49:
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
_iterator6.e(
|
|
2234
|
+
_context30.prev = 49;
|
|
2235
|
+
_context30.t0 = _context30["catch"](20);
|
|
2236
|
+
_iterator6.e(_context30.t0);
|
|
2169
2237
|
case 52:
|
|
2170
|
-
|
|
2238
|
+
_context30.prev = 52;
|
|
2171
2239
|
_iterator6.f();
|
|
2172
|
-
return
|
|
2240
|
+
return _context30.finish(52);
|
|
2173
2241
|
case 55:
|
|
2174
2242
|
if (!hasChanges) {
|
|
2175
|
-
|
|
2243
|
+
_context30.next = 60;
|
|
2176
2244
|
break;
|
|
2177
2245
|
}
|
|
2178
2246
|
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
2179
2247
|
this.store.order.applyDiscount();
|
|
2180
|
-
|
|
2248
|
+
_context30.next = 59;
|
|
2181
2249
|
return this.store.order.recalculateSummary({
|
|
2182
2250
|
createIfMissing: true
|
|
2183
2251
|
});
|
|
2184
2252
|
case 59:
|
|
2185
2253
|
this.store.order.persistTempOrder();
|
|
2186
2254
|
case 60:
|
|
2187
|
-
|
|
2255
|
+
_context30.next = 62;
|
|
2188
2256
|
return this.refreshItemRuleQuantityLimits();
|
|
2189
2257
|
case 62:
|
|
2190
2258
|
this.itemRulePrefillApplied = true;
|
|
@@ -2194,9 +2262,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2194
2262
|
});
|
|
2195
2263
|
case 64:
|
|
2196
2264
|
case "end":
|
|
2197
|
-
return
|
|
2265
|
+
return _context30.stop();
|
|
2198
2266
|
}
|
|
2199
|
-
},
|
|
2267
|
+
}, _callee30, this, [[20, 49, 52, 55]]);
|
|
2200
2268
|
}));
|
|
2201
2269
|
function applyPrefillByItemRule() {
|
|
2202
2270
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -2206,31 +2274,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2206
2274
|
}, {
|
|
2207
2275
|
key: "applyItemRulePrefill",
|
|
2208
2276
|
value: function () {
|
|
2209
|
-
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2210
|
-
var _this$store$
|
|
2211
|
-
return _regeneratorRuntime().wrap(function
|
|
2212
|
-
while (1) switch (
|
|
2277
|
+
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2278
|
+
var _this$store$order5, _this$store$order5$ge;
|
|
2279
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2280
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2213
2281
|
case 0:
|
|
2214
|
-
if (!((_this$store$
|
|
2215
|
-
|
|
2282
|
+
if (!((_this$store$order5 = this.store.order) !== null && _this$store$order5 !== void 0 && (_this$store$order5$ge = _this$store$order5.getLastOrderInfo) !== null && _this$store$order5$ge !== void 0 && _this$store$order5$ge.call(_this$store$order5))) {
|
|
2283
|
+
_context31.next = 2;
|
|
2216
2284
|
break;
|
|
2217
2285
|
}
|
|
2218
|
-
return
|
|
2286
|
+
return _context31.abrupt("return");
|
|
2219
2287
|
case 2:
|
|
2220
2288
|
this.logMethodStart('applyItemRulePrefill');
|
|
2221
|
-
|
|
2289
|
+
_context31.next = 5;
|
|
2222
2290
|
return this.applyPrefillByItemRule();
|
|
2223
2291
|
case 5:
|
|
2224
|
-
|
|
2292
|
+
_context31.next = 7;
|
|
2225
2293
|
return this.refreshItemRuleQuantityLimits();
|
|
2226
2294
|
case 7:
|
|
2227
|
-
|
|
2295
|
+
_context31.next = 9;
|
|
2228
2296
|
return this.refreshCartValidationPassed();
|
|
2229
2297
|
case 9:
|
|
2230
2298
|
case "end":
|
|
2231
|
-
return
|
|
2299
|
+
return _context31.stop();
|
|
2232
2300
|
}
|
|
2233
|
-
},
|
|
2301
|
+
}, _callee31, this);
|
|
2234
2302
|
}));
|
|
2235
2303
|
function applyItemRulePrefill() {
|
|
2236
2304
|
return _applyItemRulePrefill.apply(this, arguments);
|
|
@@ -2240,20 +2308,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2240
2308
|
}, {
|
|
2241
2309
|
key: "evaluateCartValidationByItemRule",
|
|
2242
2310
|
value: function () {
|
|
2243
|
-
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2311
|
+
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
2244
2312
|
var strategyConfigs, businessData;
|
|
2245
|
-
return _regeneratorRuntime().wrap(function
|
|
2246
|
-
while (1) switch (
|
|
2313
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2314
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2247
2315
|
case 0:
|
|
2248
|
-
|
|
2316
|
+
_context32.next = 2;
|
|
2249
2317
|
return this.ensureItemRuleConfigsLoaded();
|
|
2250
2318
|
case 2:
|
|
2251
|
-
strategyConfigs =
|
|
2319
|
+
strategyConfigs = _context32.sent;
|
|
2252
2320
|
if (strategyConfigs.length) {
|
|
2253
|
-
|
|
2321
|
+
_context32.next = 5;
|
|
2254
2322
|
break;
|
|
2255
2323
|
}
|
|
2256
|
-
return
|
|
2324
|
+
return _context32.abrupt("return", {
|
|
2257
2325
|
passed: true,
|
|
2258
2326
|
failures: []
|
|
2259
2327
|
});
|
|
@@ -2263,12 +2331,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2263
2331
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
2264
2332
|
itemRuleConfigs: this.itemRuleConfigs
|
|
2265
2333
|
});
|
|
2266
|
-
return
|
|
2334
|
+
return _context32.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
|
|
2267
2335
|
case 7:
|
|
2268
2336
|
case "end":
|
|
2269
|
-
return
|
|
2337
|
+
return _context32.stop();
|
|
2270
2338
|
}
|
|
2271
|
-
},
|
|
2339
|
+
}, _callee32, this);
|
|
2272
2340
|
}));
|
|
2273
2341
|
function evaluateCartValidationByItemRule() {
|
|
2274
2342
|
return _evaluateCartValidationByItemRule.apply(this, arguments);
|
|
@@ -2278,20 +2346,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2278
2346
|
}, {
|
|
2279
2347
|
key: "validateBeforeSubmitByItemRule",
|
|
2280
2348
|
value: function () {
|
|
2281
|
-
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2349
|
+
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2282
2350
|
var validationResult, firstFailure, errorMessage, error;
|
|
2283
|
-
return _regeneratorRuntime().wrap(function
|
|
2284
|
-
while (1) switch (
|
|
2351
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2352
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2285
2353
|
case 0:
|
|
2286
|
-
|
|
2354
|
+
_context33.next = 2;
|
|
2287
2355
|
return this.evaluateCartValidationByItemRule();
|
|
2288
2356
|
case 2:
|
|
2289
|
-
validationResult =
|
|
2357
|
+
validationResult = _context33.sent;
|
|
2290
2358
|
if (!validationResult.passed) {
|
|
2291
|
-
|
|
2359
|
+
_context33.next = 5;
|
|
2292
2360
|
break;
|
|
2293
2361
|
}
|
|
2294
|
-
return
|
|
2362
|
+
return _context33.abrupt("return");
|
|
2295
2363
|
case 5:
|
|
2296
2364
|
firstFailure = validationResult.failures[0];
|
|
2297
2365
|
errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
|
|
@@ -2300,9 +2368,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2300
2368
|
throw error;
|
|
2301
2369
|
case 10:
|
|
2302
2370
|
case "end":
|
|
2303
|
-
return
|
|
2371
|
+
return _context33.stop();
|
|
2304
2372
|
}
|
|
2305
|
-
},
|
|
2373
|
+
}, _callee33, this);
|
|
2306
2374
|
}));
|
|
2307
2375
|
function validateBeforeSubmitByItemRule() {
|
|
2308
2376
|
return _validateBeforeSubmitByItemRule.apply(this, arguments);
|
|
@@ -2312,10 +2380,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2312
2380
|
}, {
|
|
2313
2381
|
key: "refreshCartValidationPassed",
|
|
2314
2382
|
value: function () {
|
|
2315
|
-
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2383
|
+
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2316
2384
|
var previous, nextState, validationResult, changed;
|
|
2317
|
-
return _regeneratorRuntime().wrap(function
|
|
2318
|
-
while (1) switch (
|
|
2385
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2386
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2319
2387
|
case 0:
|
|
2320
2388
|
previous = this.store.cartValidation || {
|
|
2321
2389
|
passed: null,
|
|
@@ -2325,20 +2393,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2325
2393
|
passed: null,
|
|
2326
2394
|
failures: []
|
|
2327
2395
|
};
|
|
2328
|
-
|
|
2329
|
-
|
|
2396
|
+
_context34.prev = 2;
|
|
2397
|
+
_context34.next = 5;
|
|
2330
2398
|
return this.evaluateCartValidationByItemRule();
|
|
2331
2399
|
case 5:
|
|
2332
|
-
validationResult =
|
|
2400
|
+
validationResult = _context34.sent;
|
|
2333
2401
|
nextState = {
|
|
2334
2402
|
passed: validationResult.passed,
|
|
2335
2403
|
failures: validationResult.failures || []
|
|
2336
2404
|
};
|
|
2337
|
-
|
|
2405
|
+
_context34.next = 12;
|
|
2338
2406
|
break;
|
|
2339
2407
|
case 9:
|
|
2340
|
-
|
|
2341
|
-
|
|
2408
|
+
_context34.prev = 9;
|
|
2409
|
+
_context34.t0 = _context34["catch"](2);
|
|
2342
2410
|
nextState = {
|
|
2343
2411
|
passed: false,
|
|
2344
2412
|
failures: []
|
|
@@ -2347,21 +2415,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2347
2415
|
this.store.cartValidation = nextState;
|
|
2348
2416
|
changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
|
|
2349
2417
|
if (!changed) {
|
|
2350
|
-
|
|
2418
|
+
_context34.next = 17;
|
|
2351
2419
|
break;
|
|
2352
2420
|
}
|
|
2353
|
-
|
|
2421
|
+
_context34.next = 17;
|
|
2354
2422
|
return this.core.effects.emit(ScanOrderHooks.onCartValidationChanged, {
|
|
2355
2423
|
cartValidation: nextState,
|
|
2356
2424
|
cartValidationPassed: nextState.passed
|
|
2357
2425
|
});
|
|
2358
2426
|
case 17:
|
|
2359
|
-
return
|
|
2427
|
+
return _context34.abrupt("return", nextState.passed);
|
|
2360
2428
|
case 18:
|
|
2361
2429
|
case "end":
|
|
2362
|
-
return
|
|
2430
|
+
return _context34.stop();
|
|
2363
2431
|
}
|
|
2364
|
-
},
|
|
2432
|
+
}, _callee34, this, [[2, 9]]);
|
|
2365
2433
|
}));
|
|
2366
2434
|
function refreshCartValidationPassed() {
|
|
2367
2435
|
return _refreshCartValidationPassed.apply(this, arguments);
|
|
@@ -2371,14 +2439,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2371
2439
|
}, {
|
|
2372
2440
|
key: "setItemRuleRuntimeConfig",
|
|
2373
2441
|
value: function () {
|
|
2374
|
-
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2442
|
+
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2375
2443
|
var _this$itemRuleRuntime, _this$itemRuleRuntime2;
|
|
2376
2444
|
var config,
|
|
2377
|
-
|
|
2378
|
-
return _regeneratorRuntime().wrap(function
|
|
2379
|
-
while (1) switch (
|
|
2445
|
+
_args35 = arguments;
|
|
2446
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2447
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2380
2448
|
case 0:
|
|
2381
|
-
config =
|
|
2449
|
+
config = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : {};
|
|
2382
2450
|
this.logMethodStart('setItemRuleRuntimeConfig');
|
|
2383
2451
|
this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
|
|
2384
2452
|
pax: _objectSpread(_objectSpread({}, ((_this$itemRuleRuntime = this.itemRuleRuntimeConfig) === null || _this$itemRuleRuntime === void 0 ? void 0 : _this$itemRuleRuntime.pax) || {}), (config === null || config === void 0 ? void 0 : config.pax) || {}),
|
|
@@ -2390,10 +2458,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2390
2458
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
2391
2459
|
}
|
|
2392
2460
|
this.itemRulePrefillApplied = false;
|
|
2393
|
-
|
|
2461
|
+
_context35.next = 7;
|
|
2394
2462
|
return this.refreshItemRuleQuantityLimits();
|
|
2395
2463
|
case 7:
|
|
2396
|
-
|
|
2464
|
+
_context35.next = 9;
|
|
2397
2465
|
return this.refreshCartValidationPassed();
|
|
2398
2466
|
case 9:
|
|
2399
2467
|
this.logMethodSuccess('setItemRuleRuntimeConfig', {
|
|
@@ -2401,9 +2469,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2401
2469
|
});
|
|
2402
2470
|
case 10:
|
|
2403
2471
|
case "end":
|
|
2404
|
-
return
|
|
2472
|
+
return _context35.stop();
|
|
2405
2473
|
}
|
|
2406
|
-
},
|
|
2474
|
+
}, _callee35, this);
|
|
2407
2475
|
}));
|
|
2408
2476
|
function setItemRuleRuntimeConfig() {
|
|
2409
2477
|
return _setItemRuleRuntimeConfig.apply(this, arguments);
|
|
@@ -2413,14 +2481,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2413
2481
|
}, {
|
|
2414
2482
|
key: "normalizeResourceState",
|
|
2415
2483
|
value: function normalizeResourceState(detail, resourceSelectType, hasOrderId) {
|
|
2416
|
-
var _detail$form_record, _this$
|
|
2484
|
+
var _detail$form_record, _this$otherParams9, _detail$resource_capa, _detail$resource_capa2;
|
|
2417
2485
|
var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
|
|
2418
2486
|
var lastOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.last_order_id);
|
|
2419
2487
|
var relationId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_record_id);
|
|
2420
2488
|
var tableFormId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_id);
|
|
2421
2489
|
var formRecord = (_detail$form_record = detail === null || detail === void 0 ? void 0 : detail.form_record) !== null && _detail$form_record !== void 0 ? _detail$form_record : null;
|
|
2422
2490
|
// 是否允许加餐
|
|
2423
|
-
var allowSnack = ((_this$
|
|
2491
|
+
var allowSnack = ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9 = _this$otherParams9.dineInConfig) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9['sale.allow_add_items']) || false;
|
|
2424
2492
|
// 开启同桌验证 - 本期没有这个配置,默认关掉
|
|
2425
2493
|
var deskmateValid = false;
|
|
2426
2494
|
var isExclusive = resourceSelectType === 'single';
|
|
@@ -2500,29 +2568,29 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2500
2568
|
return matched === null || matched === void 0 ? void 0 : matched.type;
|
|
2501
2569
|
}
|
|
2502
2570
|
}, {
|
|
2503
|
-
key: "
|
|
2571
|
+
key: "fetchResourceOccupyDetailsByResourceId",
|
|
2504
2572
|
value: function () {
|
|
2505
|
-
var
|
|
2506
|
-
var _this$
|
|
2573
|
+
var _fetchResourceOccupyDetailsByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId) {
|
|
2574
|
+
var _this$otherParams10, _this$otherParams10$g, _response$data$occupy, _response$data;
|
|
2507
2575
|
var formRecordId, shopId, response;
|
|
2508
|
-
return _regeneratorRuntime().wrap(function
|
|
2509
|
-
while (1) switch (
|
|
2576
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2577
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2510
2578
|
case 0:
|
|
2511
2579
|
formRecordId = Number(resourceId);
|
|
2512
2580
|
if (!(!Number.isFinite(formRecordId) || formRecordId <= 0)) {
|
|
2513
|
-
|
|
2581
|
+
_context36.next = 3;
|
|
2514
2582
|
break;
|
|
2515
2583
|
}
|
|
2516
2584
|
throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
|
|
2517
2585
|
case 3:
|
|
2518
|
-
shopId = (_this$
|
|
2586
|
+
shopId = (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 || (_this$otherParams10$g = _this$otherParams10.getStateData) === null || _this$otherParams10$g === void 0 ? void 0 : _this$otherParams10$g.call(_this$otherParams10, 'shop_id');
|
|
2519
2587
|
if (shopId) {
|
|
2520
|
-
|
|
2588
|
+
_context36.next = 6;
|
|
2521
2589
|
break;
|
|
2522
2590
|
}
|
|
2523
2591
|
throw new Error('[ScanOrder] 无法获取 shop_id');
|
|
2524
2592
|
case 6:
|
|
2525
|
-
|
|
2593
|
+
_context36.next = 8;
|
|
2526
2594
|
return this.request.get('/order/resource/occupy-detail', {
|
|
2527
2595
|
shop_id: shopId,
|
|
2528
2596
|
'form_record_ids[]': formRecordId,
|
|
@@ -2531,61 +2599,173 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2531
2599
|
with_resource_form_info: 1
|
|
2532
2600
|
});
|
|
2533
2601
|
case 8:
|
|
2534
|
-
response =
|
|
2602
|
+
response = _context36.sent;
|
|
2535
2603
|
if (response !== null && response !== void 0 && response.status) {
|
|
2536
|
-
|
|
2604
|
+
_context36.next = 11;
|
|
2537
2605
|
break;
|
|
2538
2606
|
}
|
|
2539
2607
|
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
|
|
2540
2608
|
case 11:
|
|
2541
|
-
return
|
|
2609
|
+
return _context36.abrupt("return", (_response$data$occupy = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.occupy_details) !== null && _response$data$occupy !== void 0 ? _response$data$occupy : []);
|
|
2542
2610
|
case 12:
|
|
2543
2611
|
case "end":
|
|
2544
|
-
return
|
|
2612
|
+
return _context36.stop();
|
|
2545
2613
|
}
|
|
2546
|
-
},
|
|
2614
|
+
}, _callee36, this);
|
|
2547
2615
|
}));
|
|
2548
|
-
function
|
|
2549
|
-
return
|
|
2616
|
+
function fetchResourceOccupyDetailsByResourceId(_x18) {
|
|
2617
|
+
return _fetchResourceOccupyDetailsByResourceId.apply(this, arguments);
|
|
2618
|
+
}
|
|
2619
|
+
return fetchResourceOccupyDetailsByResourceId;
|
|
2620
|
+
}()
|
|
2621
|
+
}, {
|
|
2622
|
+
key: "resolveAdditionalOrderFromOccupyDetail",
|
|
2623
|
+
value: function resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
|
|
2624
|
+
var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
|
|
2625
|
+
if (currentOrderId) {
|
|
2626
|
+
return {
|
|
2627
|
+
matched: true,
|
|
2628
|
+
order_id: currentOrderId
|
|
2629
|
+
};
|
|
2630
|
+
}
|
|
2631
|
+
var orderListIds = (Array.isArray(detail === null || detail === void 0 ? void 0 : detail.order_list) ? (detail === null || detail === void 0 ? void 0 : detail.order_list) || [] : []).map(function (order) {
|
|
2632
|
+
return toPositiveString(order === null || order === void 0 ? void 0 : order.id);
|
|
2633
|
+
}).filter(Boolean);
|
|
2634
|
+
if (resourceSelectType !== 'single') {
|
|
2635
|
+
return {
|
|
2636
|
+
matched: false,
|
|
2637
|
+
reason: 'no_order'
|
|
2638
|
+
};
|
|
2639
|
+
}
|
|
2640
|
+
if (!orderListIds.length) {
|
|
2641
|
+
return {
|
|
2642
|
+
matched: false,
|
|
2643
|
+
reason: 'no_order'
|
|
2644
|
+
};
|
|
2550
2645
|
}
|
|
2551
|
-
|
|
2552
|
-
|
|
2646
|
+
if (!allowAddItems) {
|
|
2647
|
+
return {
|
|
2648
|
+
matched: false,
|
|
2649
|
+
reason: 'add_items_disabled'
|
|
2650
|
+
};
|
|
2651
|
+
}
|
|
2652
|
+
if (orderListIds.length === 1) {
|
|
2653
|
+
return {
|
|
2654
|
+
matched: true,
|
|
2655
|
+
order_id: orderListIds[0]
|
|
2656
|
+
};
|
|
2657
|
+
}
|
|
2658
|
+
if (orderListIds.length > 1) {
|
|
2659
|
+
return {
|
|
2660
|
+
matched: false,
|
|
2661
|
+
reason: 'multiple_orders'
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
return {
|
|
2665
|
+
matched: false,
|
|
2666
|
+
reason: 'no_order'
|
|
2667
|
+
};
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
// 检测当前链接是否可用
|
|
2553
2671
|
// 通过 resource_id + 店铺配置
|
|
2554
2672
|
// hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
|
|
2555
2673
|
}, {
|
|
2556
2674
|
key: "checkResourceAvailable",
|
|
2557
2675
|
value: function () {
|
|
2558
|
-
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2559
|
-
var
|
|
2560
|
-
|
|
2561
|
-
|
|
2676
|
+
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(resourceId) {
|
|
2677
|
+
var hasOrderId,
|
|
2678
|
+
normalizedResourceId,
|
|
2679
|
+
_this$otherParams$bus,
|
|
2680
|
+
_this$otherParams11,
|
|
2681
|
+
_this$otherParams$cha,
|
|
2682
|
+
_this$otherParams12,
|
|
2683
|
+
_this$otherParams13,
|
|
2684
|
+
_this$otherParams13$g,
|
|
2685
|
+
_occupyDetails$,
|
|
2686
|
+
_occupyDetail$form_re,
|
|
2687
|
+
_occupyDetail$form_re2,
|
|
2688
|
+
_this$otherParams14,
|
|
2689
|
+
_this$store$order6,
|
|
2690
|
+
_this$store$order8,
|
|
2691
|
+
_this$store$order8$ge,
|
|
2692
|
+
_this$otherParams15,
|
|
2693
|
+
businessCode,
|
|
2694
|
+
channel,
|
|
2695
|
+
openDataTarget,
|
|
2696
|
+
openData,
|
|
2697
|
+
dineInConfig,
|
|
2698
|
+
closedBehaviorValue,
|
|
2699
|
+
closedMessage,
|
|
2700
|
+
basicUnavailableMessage,
|
|
2701
|
+
pauseMessage,
|
|
2702
|
+
makeShopClosed,
|
|
2703
|
+
operatingHourIds,
|
|
2704
|
+
outsideOperatingHours,
|
|
2705
|
+
scheduleList,
|
|
2706
|
+
now,
|
|
2707
|
+
tempOrder,
|
|
2708
|
+
reservationLinkIds,
|
|
2709
|
+
pendingRequestEntryPax,
|
|
2710
|
+
pendingRequestPaxMin,
|
|
2711
|
+
pendingRequestPaxMax,
|
|
2712
|
+
reservationProductList,
|
|
2713
|
+
scheduleDate,
|
|
2714
|
+
scheduleDatetime,
|
|
2715
|
+
loaded,
|
|
2716
|
+
occupancyMinutes,
|
|
2717
|
+
paxBounds,
|
|
2718
|
+
error,
|
|
2719
|
+
occupyDetails,
|
|
2720
|
+
occupyDetail,
|
|
2721
|
+
resourceSelectType,
|
|
2722
|
+
allowAddItems,
|
|
2723
|
+
additionalOrderResult,
|
|
2724
|
+
_occupyDetail$order_l,
|
|
2725
|
+
multipleOrdersState,
|
|
2726
|
+
_availabilityInfo,
|
|
2727
|
+
resourceState,
|
|
2728
|
+
additionalOrderId,
|
|
2729
|
+
availabilityInfo,
|
|
2730
|
+
isAdditionalOrderMode,
|
|
2731
|
+
_this$store$order7,
|
|
2732
|
+
_res$data,
|
|
2733
|
+
res,
|
|
2734
|
+
entryPaxNumber,
|
|
2735
|
+
lastOrderInfo,
|
|
2736
|
+
historicalItems,
|
|
2737
|
+
_args37 = arguments;
|
|
2738
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2739
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2562
2740
|
case 0:
|
|
2741
|
+
hasOrderId = _args37.length > 1 && _args37[1] !== undefined ? _args37[1] : false;
|
|
2742
|
+
normalizedResourceId = String(resourceId !== null && resourceId !== void 0 ? resourceId : '').trim();
|
|
2563
2743
|
this.logMethodStart('checkResourceAvailable', {
|
|
2564
|
-
resourceId:
|
|
2744
|
+
resourceId: normalizedResourceId
|
|
2565
2745
|
});
|
|
2566
|
-
|
|
2567
|
-
businessCode = String((_this$otherParams$bus = (_this$
|
|
2568
|
-
channel = String((_this$otherParams$cha = (_this$
|
|
2746
|
+
_context37.prev = 3;
|
|
2747
|
+
businessCode = String((_this$otherParams$bus = (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : '').trim();
|
|
2748
|
+
channel = String((_this$otherParams$cha = (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
|
|
2569
2749
|
openDataTarget = businessCode && channel ? "".concat(businessCode, "+").concat(channel) : 'dine_in+scan_to_order';
|
|
2570
|
-
|
|
2571
|
-
return (_this$
|
|
2750
|
+
_context37.next = 9;
|
|
2751
|
+
return (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 || (_this$otherParams13$g = _this$otherParams13.getOpenData) === null || _this$otherParams13$g === void 0 ? void 0 : _this$otherParams13$g.call(_this$otherParams13, {
|
|
2572
2752
|
scope: 'board',
|
|
2573
2753
|
target: openDataTarget,
|
|
2574
2754
|
section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
|
|
2575
2755
|
});
|
|
2576
|
-
case
|
|
2577
|
-
openData =
|
|
2756
|
+
case 9:
|
|
2757
|
+
openData = _context37.sent;
|
|
2578
2758
|
if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
|
|
2579
|
-
|
|
2759
|
+
_context37.next = 12;
|
|
2580
2760
|
break;
|
|
2581
2761
|
}
|
|
2582
2762
|
throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
|
|
2583
|
-
case
|
|
2763
|
+
case 12:
|
|
2584
2764
|
dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
|
|
2585
2765
|
this.otherParams.dineInConfig = dineInConfig;
|
|
2586
|
-
|
|
2766
|
+
_context37.next = 16;
|
|
2587
2767
|
return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
|
|
2588
|
-
case
|
|
2768
|
+
case 16:
|
|
2589
2769
|
closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
|
|
2590
2770
|
closedMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.closed_message']);
|
|
2591
2771
|
basicUnavailableMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.unavailable_message']) || closedMessage;
|
|
@@ -2602,21 +2782,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2602
2782
|
};
|
|
2603
2783
|
}; // 1. 基础开关 basic.enable 关闭
|
|
2604
2784
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
|
|
2605
|
-
|
|
2785
|
+
_context37.next = 23;
|
|
2606
2786
|
break;
|
|
2607
2787
|
}
|
|
2608
|
-
return
|
|
2609
|
-
case
|
|
2788
|
+
return _context37.abrupt("return", makeShopClosed(basicUnavailableMessage));
|
|
2789
|
+
case 23:
|
|
2610
2790
|
if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
|
|
2611
|
-
|
|
2791
|
+
_context37.next = 26;
|
|
2612
2792
|
break;
|
|
2613
2793
|
}
|
|
2614
2794
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
|
|
2615
|
-
|
|
2795
|
+
_context37.next = 26;
|
|
2616
2796
|
break;
|
|
2617
2797
|
}
|
|
2618
|
-
return
|
|
2619
|
-
case
|
|
2798
|
+
return _context37.abrupt("return", makeShopClosed(pauseMessage));
|
|
2799
|
+
case 26:
|
|
2620
2800
|
// 3. 营业时间 operating_hours 闸门
|
|
2621
2801
|
operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
|
|
2622
2802
|
return Number(id);
|
|
@@ -2632,27 +2812,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2632
2812
|
}
|
|
2633
2813
|
}
|
|
2634
2814
|
if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
|
|
2635
|
-
|
|
2815
|
+
_context37.next = 31;
|
|
2636
2816
|
break;
|
|
2637
2817
|
}
|
|
2638
|
-
return
|
|
2639
|
-
case
|
|
2818
|
+
return _context37.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
|
|
2819
|
+
case 31:
|
|
2640
2820
|
// Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
|
|
2641
2821
|
// (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
|
|
2642
2822
|
tempOrder = this.ensureTempOrder();
|
|
2643
2823
|
reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
|
|
2644
|
-
if (!(reservationLinkIds.length === 0)) {
|
|
2645
|
-
|
|
2824
|
+
if (!(!normalizedResourceId || reservationLinkIds.length === 0)) {
|
|
2825
|
+
_context37.next = 37;
|
|
2646
2826
|
break;
|
|
2647
2827
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2828
|
+
_context37.next = 36;
|
|
2829
|
+
return this.prepareRetailAvailability({
|
|
2830
|
+
tempOrder: tempOrder,
|
|
2831
|
+
hasOrderId: hasOrderId,
|
|
2832
|
+
resourceId: normalizedResourceId,
|
|
2833
|
+
reason: !normalizedResourceId ? 'missing_resource_id' : 'missing_enabled_resource_rules'
|
|
2834
|
+
});
|
|
2835
|
+
case 36:
|
|
2836
|
+
return _context37.abrupt("return", _context37.sent);
|
|
2837
|
+
case 37:
|
|
2652
2838
|
tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
|
|
2653
2839
|
delete tempOrder.metadata.table_occupancy_duration;
|
|
2654
2840
|
reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
|
|
2655
|
-
|
|
2841
|
+
_context37.next = 42;
|
|
2656
2842
|
return reservationProductList.initialize(this.core, {
|
|
2657
2843
|
store: {
|
|
2658
2844
|
list: [],
|
|
@@ -2664,18 +2850,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2664
2850
|
cacheId: this.cacheId
|
|
2665
2851
|
})
|
|
2666
2852
|
});
|
|
2667
|
-
case
|
|
2853
|
+
case 42:
|
|
2668
2854
|
scheduleDate = dayjs().format('YYYY-MM-DD');
|
|
2669
2855
|
scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
2670
|
-
|
|
2856
|
+
_context37.next = 46;
|
|
2671
2857
|
return reservationProductList.loadProducts({
|
|
2672
2858
|
product_ids: reservationLinkIds,
|
|
2673
2859
|
schedule_date: scheduleDate,
|
|
2674
2860
|
schedule_datetime: scheduleDatetime,
|
|
2675
2861
|
cacheId: this.cacheId
|
|
2676
2862
|
});
|
|
2677
|
-
case
|
|
2678
|
-
loaded =
|
|
2863
|
+
case 46:
|
|
2864
|
+
loaded = _context37.sent;
|
|
2679
2865
|
if (Array.isArray(loaded)) {
|
|
2680
2866
|
this.enabledReservationRuleProducts = loaded;
|
|
2681
2867
|
occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
|
|
@@ -2692,22 +2878,60 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2692
2878
|
this.enabledReservationRuleProducts = [];
|
|
2693
2879
|
error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
|
|
2694
2880
|
this.logMethodError('loadReservationRuleProducts', error, {
|
|
2695
|
-
resourceId:
|
|
2881
|
+
resourceId: normalizedResourceId,
|
|
2696
2882
|
reservationLinkIds: reservationLinkIds,
|
|
2697
2883
|
scheduleDate: scheduleDate,
|
|
2698
2884
|
scheduleDatetime: scheduleDatetime,
|
|
2699
2885
|
cacheId: this.cacheId
|
|
2700
2886
|
});
|
|
2701
2887
|
}
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2888
|
+
|
|
2889
|
+
// Step2: 请求新的资源占用详情接口。occupy_details 第一维是资源,不是订单。
|
|
2890
|
+
_context37.next = 50;
|
|
2891
|
+
return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
|
|
2892
|
+
case 50:
|
|
2893
|
+
occupyDetails = _context37.sent;
|
|
2894
|
+
occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null; // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
|
|
2708
2895
|
// 计算当前桌台的 resourceSelectType(single/multiple/capacity)
|
|
2709
|
-
resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
|
|
2896
|
+
resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
|
|
2897
|
+
allowAddItems = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.allow_add_items']);
|
|
2898
|
+
additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
|
|
2899
|
+
if (!(additionalOrderResult.reason === 'multiple_orders')) {
|
|
2900
|
+
_context37.next = 61;
|
|
2901
|
+
break;
|
|
2902
|
+
}
|
|
2903
|
+
multipleOrdersState = _objectSpread(_objectSpread({}, this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId)), {}, {
|
|
2904
|
+
mode: 'multiple_orders'
|
|
2905
|
+
});
|
|
2906
|
+
this.store.resource = multipleOrdersState;
|
|
2907
|
+
_availabilityInfo = {
|
|
2908
|
+
mode: 'multiple_orders',
|
|
2909
|
+
deskmate_valid: multipleOrdersState.deskmate_valid,
|
|
2910
|
+
relation_id: multipleOrdersState.relationId,
|
|
2911
|
+
table_form_id: multipleOrdersState.tableFormId,
|
|
2912
|
+
table_form_record: multipleOrdersState.table_form_record
|
|
2913
|
+
};
|
|
2914
|
+
this.logMethodSuccess('checkResourceAvailable', {
|
|
2915
|
+
resourceId: normalizedResourceId,
|
|
2916
|
+
mode: _availabilityInfo.mode,
|
|
2917
|
+
orderListCount: (occupyDetail === null || occupyDetail === void 0 || (_occupyDetail$order_l = occupyDetail.order_list) === null || _occupyDetail$order_l === void 0 ? void 0 : _occupyDetail$order_l.length) || 0,
|
|
2918
|
+
resourceSelectType: resourceSelectType
|
|
2919
|
+
});
|
|
2920
|
+
return _context37.abrupt("return", _availabilityInfo);
|
|
2921
|
+
case 61:
|
|
2922
|
+
// Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
|
|
2710
2923
|
resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
|
|
2924
|
+
additionalOrderId = additionalOrderResult.order_id;
|
|
2925
|
+
if (additionalOrderId) {
|
|
2926
|
+
resourceState.mode = 'additional_order';
|
|
2927
|
+
resourceState.order_id = additionalOrderId;
|
|
2928
|
+
} else if (additionalOrderResult.reason === 'add_items_disabled') {
|
|
2929
|
+
resourceState.mode = 'resource_busy';
|
|
2930
|
+
resourceState.order_id = '0';
|
|
2931
|
+
} else if (resourceSelectType === 'multiple' && resourceState.isFull) {
|
|
2932
|
+
resourceState.mode = 'resource_busy';
|
|
2933
|
+
resourceState.order_id = '0';
|
|
2934
|
+
}
|
|
2711
2935
|
this.store.resource = resourceState;
|
|
2712
2936
|
|
|
2713
2937
|
// Step5: 把预约规则商品阶段暂存的 requestEntryPax 等注入 store.resource
|
|
@@ -2736,45 +2960,45 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2736
2960
|
} : {}), this.store.resource.requestPaxMax !== undefined ? {
|
|
2737
2961
|
requestPaxMax: this.store.resource.requestPaxMax
|
|
2738
2962
|
} : {});
|
|
2739
|
-
tempOrder.relation_id =
|
|
2963
|
+
tempOrder.relation_id = normalizedResourceId || ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.relation_id);
|
|
2740
2964
|
tempOrder.table_form_id = resourceState.tableFormId;
|
|
2741
|
-
tempOrder.resource_id =
|
|
2742
|
-
(_this$store$
|
|
2965
|
+
tempOrder.resource_id = normalizedResourceId;
|
|
2966
|
+
(_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || _this$store$order6.persistTempOrder();
|
|
2743
2967
|
|
|
2744
2968
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
2745
2969
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
2746
|
-
|
|
2970
|
+
_context37.next = 76;
|
|
2747
2971
|
break;
|
|
2748
2972
|
}
|
|
2749
|
-
|
|
2973
|
+
_context37.next = 76;
|
|
2750
2974
|
return this.addNewOrder();
|
|
2751
|
-
case
|
|
2752
|
-
// 如果是加单模式,tempOrder
|
|
2753
|
-
if (
|
|
2754
|
-
tempOrder.order_id =
|
|
2975
|
+
case 76:
|
|
2976
|
+
isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code'; // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
|
|
2977
|
+
if (isAdditionalOrderMode) {
|
|
2978
|
+
tempOrder.order_id = additionalOrderId;
|
|
2755
2979
|
}
|
|
2756
2980
|
if (!tempOrder.order_id) {
|
|
2757
|
-
|
|
2981
|
+
_context37.next = 86;
|
|
2758
2982
|
break;
|
|
2759
2983
|
}
|
|
2760
|
-
|
|
2761
|
-
return (_this$store$
|
|
2762
|
-
case
|
|
2763
|
-
res =
|
|
2984
|
+
_context37.next = 81;
|
|
2985
|
+
return (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getOrderInfoByRemote(tempOrder.order_id);
|
|
2986
|
+
case 81:
|
|
2987
|
+
res = _context37.sent;
|
|
2764
2988
|
// 找到下单的时候输入的 entryPaxNumber
|
|
2765
2989
|
entryPaxNumber = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.bookings) === null || _res$data === void 0 || (_res$data = _res$data.find(function (p) {
|
|
2766
2990
|
var _p$metadata;
|
|
2767
2991
|
return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
|
|
2768
2992
|
})) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
|
|
2769
2993
|
if (!entryPaxNumber) {
|
|
2770
|
-
|
|
2994
|
+
_context37.next = 86;
|
|
2771
2995
|
break;
|
|
2772
2996
|
}
|
|
2773
|
-
|
|
2997
|
+
_context37.next = 86;
|
|
2774
2998
|
return this.setEntryPaxNumber(entryPaxNumber);
|
|
2775
|
-
case
|
|
2776
|
-
lastOrderInfo = (_this$store$
|
|
2777
|
-
historicalItems =
|
|
2999
|
+
case 86:
|
|
3000
|
+
lastOrderInfo = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 || (_this$store$order8$ge = _this$store$order8.getLastOrderInfo) === null || _this$store$order8$ge === void 0 ? void 0 : _this$store$order8$ge.call(_this$store$order8);
|
|
3001
|
+
historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
|
|
2778
3002
|
if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
|
|
2779
3003
|
acc.push(_objectSpread({
|
|
2780
3004
|
product_id: p.product_id,
|
|
@@ -2784,13 +3008,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2784
3008
|
} : {}));
|
|
2785
3009
|
return acc;
|
|
2786
3010
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
2787
|
-
|
|
3011
|
+
_context37.next = 90;
|
|
2788
3012
|
return this.setItemRuleRuntimeConfig({
|
|
2789
|
-
serviceType: (_this$
|
|
2790
|
-
submissionIndex:
|
|
3013
|
+
serviceType: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode,
|
|
3014
|
+
submissionIndex: isAdditionalOrderMode ? 1 : 0,
|
|
2791
3015
|
historicalItems: historicalItems
|
|
2792
3016
|
});
|
|
2793
|
-
case
|
|
3017
|
+
case 90:
|
|
2794
3018
|
// operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
|
|
2795
3019
|
// 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
|
|
2796
3020
|
if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
|
|
@@ -2799,7 +3023,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2799
3023
|
availabilityInfo.closed_behavior = closedBehaviorValue;
|
|
2800
3024
|
}
|
|
2801
3025
|
this.logMethodSuccess('checkResourceAvailable', {
|
|
2802
|
-
resourceId:
|
|
3026
|
+
resourceId: normalizedResourceId,
|
|
2803
3027
|
mode: availabilityInfo.mode,
|
|
2804
3028
|
orderId: availabilityInfo.order_id,
|
|
2805
3029
|
relationId: availabilityInfo.relation_id,
|
|
@@ -2811,21 +3035,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2811
3035
|
isExclusive: resourceState.isExclusive,
|
|
2812
3036
|
isFull: resourceState.isFull
|
|
2813
3037
|
});
|
|
2814
|
-
return
|
|
2815
|
-
case
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
this.logMethodError('checkResourceAvailable',
|
|
2819
|
-
resourceId:
|
|
3038
|
+
return _context37.abrupt("return", availabilityInfo);
|
|
3039
|
+
case 95:
|
|
3040
|
+
_context37.prev = 95;
|
|
3041
|
+
_context37.t0 = _context37["catch"](3);
|
|
3042
|
+
this.logMethodError('checkResourceAvailable', _context37.t0.message, {
|
|
3043
|
+
resourceId: normalizedResourceId
|
|
2820
3044
|
});
|
|
2821
|
-
throw
|
|
2822
|
-
case
|
|
3045
|
+
throw _context37.t0;
|
|
3046
|
+
case 99:
|
|
2823
3047
|
case "end":
|
|
2824
|
-
return
|
|
3048
|
+
return _context37.stop();
|
|
2825
3049
|
}
|
|
2826
|
-
},
|
|
3050
|
+
}, _callee37, this, [[3, 95]]);
|
|
2827
3051
|
}));
|
|
2828
|
-
function checkResourceAvailable(
|
|
3052
|
+
function checkResourceAvailable(_x19) {
|
|
2829
3053
|
return _checkResourceAvailable.apply(this, arguments);
|
|
2830
3054
|
}
|
|
2831
3055
|
return checkResourceAvailable;
|
|
@@ -2833,10 +3057,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2833
3057
|
}, {
|
|
2834
3058
|
key: "getAdditionalOrderInfo",
|
|
2835
3059
|
value: function () {
|
|
2836
|
-
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3060
|
+
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
2837
3061
|
var result;
|
|
2838
|
-
return _regeneratorRuntime().wrap(function
|
|
2839
|
-
while (1) switch (
|
|
3062
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3063
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
2840
3064
|
case 0:
|
|
2841
3065
|
this.logMethodStart('getAdditionalOrderInfo');
|
|
2842
3066
|
result = {
|
|
@@ -2850,12 +3074,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2850
3074
|
orderId: result.orderId,
|
|
2851
3075
|
orderStatus: result.orderStatus
|
|
2852
3076
|
});
|
|
2853
|
-
return
|
|
3077
|
+
return _context38.abrupt("return", result);
|
|
2854
3078
|
case 4:
|
|
2855
3079
|
case "end":
|
|
2856
|
-
return
|
|
3080
|
+
return _context38.stop();
|
|
2857
3081
|
}
|
|
2858
|
-
},
|
|
3082
|
+
}, _callee38, this);
|
|
2859
3083
|
}));
|
|
2860
3084
|
function getAdditionalOrderInfo() {
|
|
2861
3085
|
return _getAdditionalOrderInfo.apply(this, arguments);
|
|
@@ -2865,25 +3089,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2865
3089
|
}, {
|
|
2866
3090
|
key: "getProductList",
|
|
2867
3091
|
value: function () {
|
|
2868
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2869
|
-
var _this$
|
|
3092
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
3093
|
+
var _this$otherParams16;
|
|
2870
3094
|
var menu_list_ids, res, productList, formattedRes;
|
|
2871
|
-
return _regeneratorRuntime().wrap(function
|
|
2872
|
-
while (1) switch (
|
|
3095
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3096
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
2873
3097
|
case 0:
|
|
2874
3098
|
this.logMethodStart('getProductList');
|
|
2875
3099
|
// 可以直接通过配置里的 menu 读取
|
|
2876
|
-
menu_list_ids = ((_this$
|
|
3100
|
+
menu_list_ids = ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 || (_this$otherParams16 = _this$otherParams16.dineInConfig) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16['menu.associated_menus'].map(function (n) {
|
|
2877
3101
|
return Number(n.value);
|
|
2878
3102
|
})) || [];
|
|
2879
|
-
|
|
3103
|
+
_context39.prev = 2;
|
|
2880
3104
|
if (this.store.products) {
|
|
2881
|
-
|
|
3105
|
+
_context39.next = 5;
|
|
2882
3106
|
break;
|
|
2883
3107
|
}
|
|
2884
3108
|
throw new Error('products 模块未初始化');
|
|
2885
3109
|
case 5:
|
|
2886
|
-
|
|
3110
|
+
_context39.next = 7;
|
|
2887
3111
|
return this.store.products.loadProducts({
|
|
2888
3112
|
menu_list_ids: menu_list_ids,
|
|
2889
3113
|
cacheId: this.cacheId,
|
|
@@ -2891,7 +3115,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2891
3115
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
2892
3116
|
});
|
|
2893
3117
|
case 7:
|
|
2894
|
-
res =
|
|
3118
|
+
res = _context39.sent;
|
|
2895
3119
|
productList = this.assertProductListLoaded('getProductList', res, {
|
|
2896
3120
|
menu_list_ids: menu_list_ids,
|
|
2897
3121
|
cacheId: this.cacheId
|
|
@@ -2900,22 +3124,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2900
3124
|
this.logMethodSuccess('getProductList', {
|
|
2901
3125
|
menuCount: menu_list_ids.length
|
|
2902
3126
|
});
|
|
2903
|
-
return
|
|
3127
|
+
return _context39.abrupt("return", formattedRes);
|
|
2904
3128
|
case 14:
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
if (!(
|
|
2908
|
-
this.logMethodError('getProductList',
|
|
3129
|
+
_context39.prev = 14;
|
|
3130
|
+
_context39.t0 = _context39["catch"](2);
|
|
3131
|
+
if (!(_context39.t0 !== null && _context39.t0 !== void 0 && _context39.t0.__scanOrderLogged)) {
|
|
3132
|
+
this.logMethodError('getProductList', _context39.t0, {
|
|
2909
3133
|
menu_list_ids: menu_list_ids,
|
|
2910
3134
|
cacheId: this.cacheId
|
|
2911
3135
|
});
|
|
2912
3136
|
}
|
|
2913
|
-
throw
|
|
3137
|
+
throw _context39.t0;
|
|
2914
3138
|
case 18:
|
|
2915
3139
|
case "end":
|
|
2916
|
-
return
|
|
3140
|
+
return _context39.stop();
|
|
2917
3141
|
}
|
|
2918
|
-
},
|
|
3142
|
+
}, _callee39, this, [[2, 14]]);
|
|
2919
3143
|
}));
|
|
2920
3144
|
function getProductList() {
|
|
2921
3145
|
return _getProductList.apply(this, arguments);
|
|
@@ -2930,15 +3154,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2930
3154
|
}, {
|
|
2931
3155
|
key: "setOtherParams",
|
|
2932
3156
|
value: function () {
|
|
2933
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2934
|
-
var
|
|
2935
|
-
|
|
3157
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
3158
|
+
var _ref9,
|
|
3159
|
+
_ref9$cover,
|
|
2936
3160
|
cover,
|
|
2937
|
-
|
|
2938
|
-
return _regeneratorRuntime().wrap(function
|
|
2939
|
-
while (1) switch (
|
|
3161
|
+
_args40 = arguments;
|
|
3162
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3163
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
2940
3164
|
case 0:
|
|
2941
|
-
|
|
3165
|
+
_ref9 = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {}, _ref9$cover = _ref9.cover, cover = _ref9$cover === void 0 ? false : _ref9$cover;
|
|
2942
3166
|
if (cover) {
|
|
2943
3167
|
this.otherParams = params;
|
|
2944
3168
|
} else {
|
|
@@ -2946,9 +3170,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2946
3170
|
}
|
|
2947
3171
|
case 2:
|
|
2948
3172
|
case "end":
|
|
2949
|
-
return
|
|
3173
|
+
return _context40.stop();
|
|
2950
3174
|
}
|
|
2951
|
-
},
|
|
3175
|
+
}, _callee40, this);
|
|
2952
3176
|
}));
|
|
2953
3177
|
function setOtherParams(_x20) {
|
|
2954
3178
|
return _setOtherParams.apply(this, arguments);
|
|
@@ -3040,10 +3264,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3040
3264
|
}, {
|
|
3041
3265
|
key: "setEntryPaxNumber",
|
|
3042
3266
|
value: function () {
|
|
3043
|
-
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3267
|
+
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(number) {
|
|
3044
3268
|
var pax, t;
|
|
3045
|
-
return _regeneratorRuntime().wrap(function
|
|
3046
|
-
while (1) switch (
|
|
3269
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3270
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3047
3271
|
case 0:
|
|
3048
3272
|
pax = normalizeSubmitCollectPaxValue(number);
|
|
3049
3273
|
this.store.entryPaxNumber = pax;
|
|
@@ -3064,16 +3288,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3064
3288
|
}
|
|
3065
3289
|
});
|
|
3066
3290
|
this.itemRulePrefillApplied = false;
|
|
3067
|
-
|
|
3291
|
+
_context41.next = 7;
|
|
3068
3292
|
return this.refreshItemRuleQuantityLimits();
|
|
3069
3293
|
case 7:
|
|
3070
|
-
|
|
3294
|
+
_context41.next = 9;
|
|
3071
3295
|
return this.refreshCartValidationPassed();
|
|
3072
3296
|
case 9:
|
|
3073
3297
|
case "end":
|
|
3074
|
-
return
|
|
3298
|
+
return _context41.stop();
|
|
3075
3299
|
}
|
|
3076
|
-
},
|
|
3300
|
+
}, _callee41, this);
|
|
3077
3301
|
}));
|
|
3078
3302
|
function setEntryPaxNumber(_x21) {
|
|
3079
3303
|
return _setEntryPaxNumber.apply(this, arguments);
|
|
@@ -3085,15 +3309,113 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3085
3309
|
value: function getEntryPaxNumber() {
|
|
3086
3310
|
return this.store.entryPaxNumber;
|
|
3087
3311
|
}
|
|
3312
|
+
}, {
|
|
3313
|
+
key: "syncAdditionalOrderFromResource",
|
|
3314
|
+
value: function () {
|
|
3315
|
+
var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(resourceId) {
|
|
3316
|
+
var _ref10, _ref11, _ref12, _this$store$resource2, _this$store$resource3, _occupyDetails$2, _this$store$resource4, _this$otherParams17, _this$store$order9;
|
|
3317
|
+
var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result;
|
|
3318
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3319
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3320
|
+
case 0:
|
|
3321
|
+
tempOrder = this.ensureTempOrder();
|
|
3322
|
+
normalizedResourceId = String((_ref10 = (_ref11 = (_ref12 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref12 !== void 0 ? _ref12 : (_this$store$resource2 = this.store.resource) === null || _this$store$resource2 === void 0 ? void 0 : _this$store$resource2.relationId) !== null && _ref11 !== void 0 ? _ref11 : (_this$store$resource3 = this.store.resource) === null || _this$store$resource3 === void 0 ? void 0 : _this$store$resource3.relation_id) !== null && _ref10 !== void 0 ? _ref10 : '').trim();
|
|
3323
|
+
this.logMethodStart('syncAdditionalOrderFromResource', {
|
|
3324
|
+
resourceId: normalizedResourceId
|
|
3325
|
+
});
|
|
3326
|
+
if (normalizedResourceId) {
|
|
3327
|
+
_context42.next = 7;
|
|
3328
|
+
break;
|
|
3329
|
+
}
|
|
3330
|
+
_result = {
|
|
3331
|
+
matched: false,
|
|
3332
|
+
reason: 'missing_resource_id'
|
|
3333
|
+
};
|
|
3334
|
+
this.logMethodSuccess('syncAdditionalOrderFromResource', _result);
|
|
3335
|
+
return _context42.abrupt("return", _result);
|
|
3336
|
+
case 7:
|
|
3337
|
+
_context42.next = 9;
|
|
3338
|
+
return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
|
|
3339
|
+
case 9:
|
|
3340
|
+
occupyDetails = _context42.sent;
|
|
3341
|
+
occupyDetail = (_occupyDetails$2 = occupyDetails[0]) !== null && _occupyDetails$2 !== void 0 ? _occupyDetails$2 : null;
|
|
3342
|
+
resourceSelectType = ((_this$store$resource4 = this.store.resource) === null || _this$store$resource4 === void 0 ? void 0 : _this$store$resource4.resourceSelectType) || this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
|
|
3343
|
+
allowAddItems = toBoolean((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 || (_this$otherParams17 = _this$otherParams17.dineInConfig) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17['sale.allow_add_items']);
|
|
3344
|
+
result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
|
|
3345
|
+
if (!(!result.matched || !result.order_id)) {
|
|
3346
|
+
_context42.next = 17;
|
|
3347
|
+
break;
|
|
3348
|
+
}
|
|
3349
|
+
this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
|
|
3350
|
+
resourceId: normalizedResourceId,
|
|
3351
|
+
resourceSelectType: resourceSelectType,
|
|
3352
|
+
allowAddItems: allowAddItems
|
|
3353
|
+
}));
|
|
3354
|
+
return _context42.abrupt("return", result);
|
|
3355
|
+
case 17:
|
|
3356
|
+
tempOrder.order_id = result.order_id;
|
|
3357
|
+
tempOrder.resource_id = normalizedResourceId;
|
|
3358
|
+
tempOrder.relation_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
|
|
3359
|
+
tempOrder.table_form_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
|
|
3360
|
+
(_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || _this$store$order9.persistTempOrder();
|
|
3361
|
+
this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
|
|
3362
|
+
resourceId: normalizedResourceId,
|
|
3363
|
+
resourceSelectType: resourceSelectType,
|
|
3364
|
+
allowAddItems: allowAddItems
|
|
3365
|
+
}));
|
|
3366
|
+
return _context42.abrupt("return", result);
|
|
3367
|
+
case 24:
|
|
3368
|
+
case "end":
|
|
3369
|
+
return _context42.stop();
|
|
3370
|
+
}
|
|
3371
|
+
}, _callee42, this);
|
|
3372
|
+
}));
|
|
3373
|
+
function syncAdditionalOrderFromResource(_x22) {
|
|
3374
|
+
return _syncAdditionalOrderFromResource.apply(this, arguments);
|
|
3375
|
+
}
|
|
3376
|
+
return syncAdditionalOrderFromResource;
|
|
3377
|
+
}() // 读取预约规则商品的资源选择类型:single=单个预约,multiple=多个预约,capacity=容量型预约
|
|
3378
|
+
// 依赖 checkResourceAvailable 已根据预约规则商品与 occupy-detail 的 form_id 计算并缓存 store.resource
|
|
3379
|
+
}, {
|
|
3380
|
+
key: "getReservationResourceSelectType",
|
|
3381
|
+
value: function getReservationResourceSelectType() {
|
|
3382
|
+
var _this$store$resource5;
|
|
3383
|
+
this.logMethodStart('getReservationResourceSelectType');
|
|
3384
|
+
var resourceSelectType = (_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.resourceSelectType;
|
|
3385
|
+
var result = _objectSpread(_objectSpread({}, resourceSelectType ? {
|
|
3386
|
+
resourceSelectType: resourceSelectType
|
|
3387
|
+
} : {}), {}, {
|
|
3388
|
+
isSingleReservation: resourceSelectType === 'single',
|
|
3389
|
+
isMultipleReservation: resourceSelectType === 'multiple',
|
|
3390
|
+
isCapacityReservation: resourceSelectType === 'capacity'
|
|
3391
|
+
});
|
|
3392
|
+
this.logMethodSuccess('getReservationResourceSelectType', result);
|
|
3393
|
+
return result;
|
|
3394
|
+
}
|
|
3395
|
+
|
|
3396
|
+
// 判定后台是否开启允许加餐
|
|
3397
|
+
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
3398
|
+
}, {
|
|
3399
|
+
key: "checkAllowAddItems",
|
|
3400
|
+
value: function checkAllowAddItems() {
|
|
3401
|
+
var _this$otherParams18;
|
|
3402
|
+
this.logMethodStart('checkAllowAddItems');
|
|
3403
|
+
var dineInConfig = ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.dineInConfig) || {};
|
|
3404
|
+
var result = {
|
|
3405
|
+
enabled: toBoolean(dineInConfig['sale.allow_add_items'])
|
|
3406
|
+
};
|
|
3407
|
+
this.logMethodSuccess('checkAllowAddItems', result);
|
|
3408
|
+
return result;
|
|
3409
|
+
}
|
|
3088
3410
|
|
|
3089
3411
|
// 读取取餐/送餐开关
|
|
3090
3412
|
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
3091
3413
|
}, {
|
|
3092
3414
|
key: "getFulfillmentModes",
|
|
3093
3415
|
value: function getFulfillmentModes() {
|
|
3094
|
-
var _this$
|
|
3416
|
+
var _this$otherParams19;
|
|
3095
3417
|
this.logMethodStart('getFulfillmentModes');
|
|
3096
|
-
var dineInConfig = ((_this$
|
|
3418
|
+
var dineInConfig = ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.dineInConfig) || {};
|
|
3097
3419
|
var result = {
|
|
3098
3420
|
enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
|
|
3099
3421
|
enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
|
|
@@ -3107,9 +3429,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3107
3429
|
}, {
|
|
3108
3430
|
key: "checkManualPickupRef",
|
|
3109
3431
|
value: function checkManualPickupRef() {
|
|
3110
|
-
var _this$
|
|
3432
|
+
var _this$otherParams20;
|
|
3111
3433
|
this.logMethodStart('checkManualPickupRef');
|
|
3112
|
-
var dineInConfig = ((_this$
|
|
3434
|
+
var dineInConfig = ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.dineInConfig) || {};
|
|
3113
3435
|
var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
|
|
3114
3436
|
var manualInputType = dineInConfig['fulfillment.manual_input_type'];
|
|
3115
3437
|
var enabled = refMode === 'manual_input';
|