@pisell/pisellos 2.1.152 → 2.1.153
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 +6 -5
- package/dist/solution/ScanOrder/index.js +529 -400
- 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 +6 -5
- package/lib/solution/ScanOrder/index.js +114 -56
- 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)
|
|
@@ -1361,10 +1423,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
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
1438
|
var hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
|
|
1370
1439
|
var resourceCapacityValue = hasCollectPaxForCapacity ? normalizeSubmitCollectPaxValue(rawCollectPax) : resolveResourceCapacity();
|
|
@@ -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',
|
|
@@ -1415,9 +1484,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1415
1484
|
var nextProducts = _toConsumableArray(payload.products || []);
|
|
1416
1485
|
// 加餐(已有 order_id)走 scanOrderMore,原单已含 booking 规则行,勿再追加虚拟规则商品
|
|
1417
1486
|
if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
|
|
1418
|
-
var _ruleProduct$price,
|
|
1487
|
+
var _ruleProduct$price, _ref6, _ruleProduct$original, _ruleProduct$is_gst;
|
|
1419
1488
|
var sellingPrice = String((_ruleProduct$price = ruleProduct.price) !== null && _ruleProduct$price !== void 0 ? _ruleProduct$price : '0.00');
|
|
1420
|
-
var originalPrice = String((
|
|
1489
|
+
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
1490
|
nextProducts.push({
|
|
1422
1491
|
product_id: ruleProduct.id,
|
|
1423
1492
|
product_variant_id: 0,
|
|
@@ -1446,18 +1515,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1446
1515
|
}, {
|
|
1447
1516
|
key: "submitScanOrder",
|
|
1448
1517
|
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 (
|
|
1518
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1519
|
+
var _this$store$resource, _this$otherParams5, _this$otherParams6, _this$otherParams7, _this$otherParams8, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
|
|
1520
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1521
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1453
1522
|
case 0:
|
|
1454
1523
|
this.logMethodStart('submitScanOrder');
|
|
1455
|
-
|
|
1456
|
-
|
|
1524
|
+
_context18.prev = 1;
|
|
1525
|
+
_context18.next = 4;
|
|
1457
1526
|
return this.validateBeforeSubmitByItemRule();
|
|
1458
1527
|
case 4:
|
|
1459
1528
|
if (this.store.order) {
|
|
1460
|
-
|
|
1529
|
+
_context18.next = 6;
|
|
1461
1530
|
break;
|
|
1462
1531
|
}
|
|
1463
1532
|
throw new Error('scanOrder解决方案需要 order 模块支持');
|
|
@@ -1477,32 +1546,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1477
1546
|
}
|
|
1478
1547
|
this.store.order.persistTempOrder();
|
|
1479
1548
|
enhancePayload = this.buildSubmitPayloadEnhancer();
|
|
1480
|
-
|
|
1549
|
+
_context18.next = 17;
|
|
1481
1550
|
return this.store.order.submitTempOrder({
|
|
1482
1551
|
cacheId: this.cacheId,
|
|
1483
|
-
platform: (_this$
|
|
1484
|
-
businessCode: (_this$
|
|
1485
|
-
channel: (_this$
|
|
1486
|
-
type: (_this$
|
|
1552
|
+
platform: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform,
|
|
1553
|
+
businessCode: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode,
|
|
1554
|
+
channel: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.channel,
|
|
1555
|
+
type: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.type,
|
|
1487
1556
|
enhancePayload: enhancePayload
|
|
1488
1557
|
});
|
|
1489
1558
|
case 17:
|
|
1490
|
-
result =
|
|
1559
|
+
result = _context18.sent;
|
|
1491
1560
|
tempOrder = this.store.order.getTempOrder();
|
|
1492
1561
|
this.logMethodSuccess('submitScanOrder', {
|
|
1493
1562
|
productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
|
|
1494
1563
|
});
|
|
1495
|
-
return
|
|
1564
|
+
return _context18.abrupt("return", result);
|
|
1496
1565
|
case 23:
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
this.logMethodError('submitScanOrder',
|
|
1500
|
-
throw
|
|
1566
|
+
_context18.prev = 23;
|
|
1567
|
+
_context18.t0 = _context18["catch"](1);
|
|
1568
|
+
this.logMethodError('submitScanOrder', _context18.t0);
|
|
1569
|
+
throw _context18.t0;
|
|
1501
1570
|
case 27:
|
|
1502
1571
|
case "end":
|
|
1503
|
-
return
|
|
1572
|
+
return _context18.stop();
|
|
1504
1573
|
}
|
|
1505
|
-
},
|
|
1574
|
+
}, _callee18, this, [[1, 23]]);
|
|
1506
1575
|
}));
|
|
1507
1576
|
function submitScanOrder() {
|
|
1508
1577
|
return _submitScanOrder.apply(this, arguments);
|
|
@@ -1512,48 +1581,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1512
1581
|
}, {
|
|
1513
1582
|
key: "addProductToOrder",
|
|
1514
1583
|
value: function () {
|
|
1515
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1584
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(product) {
|
|
1516
1585
|
var products;
|
|
1517
|
-
return _regeneratorRuntime().wrap(function
|
|
1518
|
-
while (1) switch (
|
|
1586
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1587
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1519
1588
|
case 0:
|
|
1520
1589
|
this.logMethodStart('addProductToOrder', {
|
|
1521
1590
|
product_id: product.product_id,
|
|
1522
1591
|
product_variant_id: product.product_variant_id
|
|
1523
1592
|
});
|
|
1524
|
-
|
|
1593
|
+
_context19.prev = 1;
|
|
1525
1594
|
if (this.store.order) {
|
|
1526
|
-
|
|
1595
|
+
_context19.next = 4;
|
|
1527
1596
|
break;
|
|
1528
1597
|
}
|
|
1529
1598
|
throw new Error('order 模块未初始化');
|
|
1530
1599
|
case 4:
|
|
1531
|
-
|
|
1600
|
+
_context19.next = 6;
|
|
1532
1601
|
return this.store.order.addProductToOrder(product);
|
|
1533
1602
|
case 6:
|
|
1534
|
-
products =
|
|
1535
|
-
|
|
1603
|
+
products = _context19.sent;
|
|
1604
|
+
_context19.next = 9;
|
|
1536
1605
|
return this.refreshItemRuleQuantityLimits();
|
|
1537
1606
|
case 9:
|
|
1538
|
-
|
|
1607
|
+
_context19.next = 11;
|
|
1539
1608
|
return this.refreshCartValidationPassed();
|
|
1540
1609
|
case 11:
|
|
1541
1610
|
this.logMethodSuccess('addProductToOrder', {
|
|
1542
1611
|
productCount: products.length
|
|
1543
1612
|
});
|
|
1544
|
-
return
|
|
1613
|
+
return _context19.abrupt("return", products);
|
|
1545
1614
|
case 15:
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
this.logMethodError('addProductToOrder',
|
|
1549
|
-
throw
|
|
1615
|
+
_context19.prev = 15;
|
|
1616
|
+
_context19.t0 = _context19["catch"](1);
|
|
1617
|
+
this.logMethodError('addProductToOrder', _context19.t0);
|
|
1618
|
+
throw _context19.t0;
|
|
1550
1619
|
case 19:
|
|
1551
1620
|
case "end":
|
|
1552
|
-
return
|
|
1621
|
+
return _context19.stop();
|
|
1553
1622
|
}
|
|
1554
|
-
},
|
|
1623
|
+
}, _callee19, this, [[1, 15]]);
|
|
1555
1624
|
}));
|
|
1556
|
-
function addProductToOrder(
|
|
1625
|
+
function addProductToOrder(_x11) {
|
|
1557
1626
|
return _addProductToOrder.apply(this, arguments);
|
|
1558
1627
|
}
|
|
1559
1628
|
return addProductToOrder;
|
|
@@ -1561,48 +1630,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1561
1630
|
}, {
|
|
1562
1631
|
key: "updateProductInOrder",
|
|
1563
1632
|
value: function () {
|
|
1564
|
-
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1633
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1565
1634
|
var products;
|
|
1566
|
-
return _regeneratorRuntime().wrap(function
|
|
1567
|
-
while (1) switch (
|
|
1635
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1636
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1568
1637
|
case 0:
|
|
1569
1638
|
this.logMethodStart('updateProductInOrder', {
|
|
1570
1639
|
product_id: params.product_id,
|
|
1571
1640
|
product_variant_id: params.product_variant_id
|
|
1572
1641
|
});
|
|
1573
|
-
|
|
1642
|
+
_context20.prev = 1;
|
|
1574
1643
|
if (this.store.order) {
|
|
1575
|
-
|
|
1644
|
+
_context20.next = 4;
|
|
1576
1645
|
break;
|
|
1577
1646
|
}
|
|
1578
1647
|
throw new Error('order 模块未初始化');
|
|
1579
1648
|
case 4:
|
|
1580
|
-
|
|
1649
|
+
_context20.next = 6;
|
|
1581
1650
|
return this.store.order.updateProductInOrder(params);
|
|
1582
1651
|
case 6:
|
|
1583
|
-
products =
|
|
1584
|
-
|
|
1652
|
+
products = _context20.sent;
|
|
1653
|
+
_context20.next = 9;
|
|
1585
1654
|
return this.refreshItemRuleQuantityLimits();
|
|
1586
1655
|
case 9:
|
|
1587
|
-
|
|
1656
|
+
_context20.next = 11;
|
|
1588
1657
|
return this.refreshCartValidationPassed();
|
|
1589
1658
|
case 11:
|
|
1590
1659
|
this.logMethodSuccess('updateProductInOrder', {
|
|
1591
1660
|
productCount: products.length
|
|
1592
1661
|
});
|
|
1593
|
-
return
|
|
1662
|
+
return _context20.abrupt("return", products);
|
|
1594
1663
|
case 15:
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
this.logMethodError('updateProductInOrder',
|
|
1598
|
-
throw
|
|
1664
|
+
_context20.prev = 15;
|
|
1665
|
+
_context20.t0 = _context20["catch"](1);
|
|
1666
|
+
this.logMethodError('updateProductInOrder', _context20.t0);
|
|
1667
|
+
throw _context20.t0;
|
|
1599
1668
|
case 19:
|
|
1600
1669
|
case "end":
|
|
1601
|
-
return
|
|
1670
|
+
return _context20.stop();
|
|
1602
1671
|
}
|
|
1603
|
-
},
|
|
1672
|
+
}, _callee20, this, [[1, 15]]);
|
|
1604
1673
|
}));
|
|
1605
|
-
function updateProductInOrder(
|
|
1674
|
+
function updateProductInOrder(_x12) {
|
|
1606
1675
|
return _updateProductInOrder.apply(this, arguments);
|
|
1607
1676
|
}
|
|
1608
1677
|
return updateProductInOrder;
|
|
@@ -1614,16 +1683,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1614
1683
|
}, {
|
|
1615
1684
|
key: "setOrderProductLineNote",
|
|
1616
1685
|
value: (function () {
|
|
1617
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1686
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identity, note) {
|
|
1618
1687
|
var params, products;
|
|
1619
|
-
return _regeneratorRuntime().wrap(function
|
|
1620
|
-
while (1) switch (
|
|
1688
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1689
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1621
1690
|
case 0:
|
|
1622
1691
|
this.logMethodStart('setOrderProductLineNote', {
|
|
1623
1692
|
product_id: identity.product_id,
|
|
1624
1693
|
product_variant_id: identity.product_variant_id
|
|
1625
1694
|
});
|
|
1626
|
-
|
|
1695
|
+
_context21.prev = 1;
|
|
1627
1696
|
params = {
|
|
1628
1697
|
product_id: identity.product_id,
|
|
1629
1698
|
product_variant_id: identity.product_variant_id,
|
|
@@ -1636,26 +1705,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1636
1705
|
params.product_option_item = identity.product_option_item;
|
|
1637
1706
|
}
|
|
1638
1707
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
1639
|
-
|
|
1708
|
+
_context21.next = 8;
|
|
1640
1709
|
return this.updateProductInOrder(params);
|
|
1641
1710
|
case 8:
|
|
1642
|
-
products =
|
|
1711
|
+
products = _context21.sent;
|
|
1643
1712
|
this.logMethodSuccess('setOrderProductLineNote', {
|
|
1644
1713
|
productCount: products.length
|
|
1645
1714
|
});
|
|
1646
|
-
return
|
|
1715
|
+
return _context21.abrupt("return", products);
|
|
1647
1716
|
case 13:
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
this.logMethodError('setOrderProductLineNote',
|
|
1651
|
-
throw
|
|
1717
|
+
_context21.prev = 13;
|
|
1718
|
+
_context21.t0 = _context21["catch"](1);
|
|
1719
|
+
this.logMethodError('setOrderProductLineNote', _context21.t0);
|
|
1720
|
+
throw _context21.t0;
|
|
1652
1721
|
case 17:
|
|
1653
1722
|
case "end":
|
|
1654
|
-
return
|
|
1723
|
+
return _context21.stop();
|
|
1655
1724
|
}
|
|
1656
|
-
},
|
|
1725
|
+
}, _callee21, this, [[1, 13]]);
|
|
1657
1726
|
}));
|
|
1658
|
-
function setOrderProductLineNote(
|
|
1727
|
+
function setOrderProductLineNote(_x13, _x14) {
|
|
1659
1728
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
1660
1729
|
}
|
|
1661
1730
|
return setOrderProductLineNote;
|
|
@@ -1663,48 +1732,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1663
1732
|
}, {
|
|
1664
1733
|
key: "removeProductFromOrder",
|
|
1665
1734
|
value: function () {
|
|
1666
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1735
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(identity) {
|
|
1667
1736
|
var products;
|
|
1668
|
-
return _regeneratorRuntime().wrap(function
|
|
1669
|
-
while (1) switch (
|
|
1737
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1738
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1670
1739
|
case 0:
|
|
1671
1740
|
this.logMethodStart('removeProductFromOrder', {
|
|
1672
1741
|
product_id: identity.product_id,
|
|
1673
1742
|
product_variant_id: identity.product_variant_id
|
|
1674
1743
|
});
|
|
1675
|
-
|
|
1744
|
+
_context22.prev = 1;
|
|
1676
1745
|
if (this.store.order) {
|
|
1677
|
-
|
|
1746
|
+
_context22.next = 4;
|
|
1678
1747
|
break;
|
|
1679
1748
|
}
|
|
1680
1749
|
throw new Error('order 模块未初始化');
|
|
1681
1750
|
case 4:
|
|
1682
|
-
|
|
1751
|
+
_context22.next = 6;
|
|
1683
1752
|
return this.store.order.removeProductFromOrder(identity);
|
|
1684
1753
|
case 6:
|
|
1685
|
-
products =
|
|
1686
|
-
|
|
1754
|
+
products = _context22.sent;
|
|
1755
|
+
_context22.next = 9;
|
|
1687
1756
|
return this.refreshItemRuleQuantityLimits();
|
|
1688
1757
|
case 9:
|
|
1689
|
-
|
|
1758
|
+
_context22.next = 11;
|
|
1690
1759
|
return this.refreshCartValidationPassed();
|
|
1691
1760
|
case 11:
|
|
1692
1761
|
this.logMethodSuccess('removeProductFromOrder', {
|
|
1693
1762
|
productCount: products.length
|
|
1694
1763
|
});
|
|
1695
|
-
return
|
|
1764
|
+
return _context22.abrupt("return", products);
|
|
1696
1765
|
case 15:
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
this.logMethodError('removeProductFromOrder',
|
|
1700
|
-
throw
|
|
1766
|
+
_context22.prev = 15;
|
|
1767
|
+
_context22.t0 = _context22["catch"](1);
|
|
1768
|
+
this.logMethodError('removeProductFromOrder', _context22.t0);
|
|
1769
|
+
throw _context22.t0;
|
|
1701
1770
|
case 19:
|
|
1702
1771
|
case "end":
|
|
1703
|
-
return
|
|
1772
|
+
return _context22.stop();
|
|
1704
1773
|
}
|
|
1705
|
-
},
|
|
1774
|
+
}, _callee22, this, [[1, 15]]);
|
|
1706
1775
|
}));
|
|
1707
|
-
function removeProductFromOrder(
|
|
1776
|
+
function removeProductFromOrder(_x15) {
|
|
1708
1777
|
return _removeProductFromOrder.apply(this, arguments);
|
|
1709
1778
|
}
|
|
1710
1779
|
return removeProductFromOrder;
|
|
@@ -1712,26 +1781,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1712
1781
|
}, {
|
|
1713
1782
|
key: "loadRuntimeConfigs",
|
|
1714
1783
|
value: function () {
|
|
1715
|
-
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1784
|
+
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1716
1785
|
var itemRuleConfigs;
|
|
1717
|
-
return _regeneratorRuntime().wrap(function
|
|
1718
|
-
while (1) switch (
|
|
1786
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1787
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1719
1788
|
case 0:
|
|
1720
|
-
|
|
1789
|
+
_context23.next = 2;
|
|
1721
1790
|
return this.ensureItemRuleConfigsLoaded();
|
|
1722
1791
|
case 2:
|
|
1723
|
-
itemRuleConfigs =
|
|
1792
|
+
itemRuleConfigs = _context23.sent;
|
|
1724
1793
|
this.logMethodSuccess('loadRuntimeConfigs', {
|
|
1725
1794
|
itemRuleCount: itemRuleConfigs.length
|
|
1726
1795
|
});
|
|
1727
|
-
return
|
|
1796
|
+
return _context23.abrupt("return", {
|
|
1728
1797
|
itemRuleConfigs: itemRuleConfigs
|
|
1729
1798
|
});
|
|
1730
1799
|
case 5:
|
|
1731
1800
|
case "end":
|
|
1732
|
-
return
|
|
1801
|
+
return _context23.stop();
|
|
1733
1802
|
}
|
|
1734
|
-
},
|
|
1803
|
+
}, _callee23, this);
|
|
1735
1804
|
}));
|
|
1736
1805
|
function loadRuntimeConfigs() {
|
|
1737
1806
|
return _loadRuntimeConfigs.apply(this, arguments);
|
|
@@ -1741,15 +1810,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1741
1810
|
}, {
|
|
1742
1811
|
key: "syncItemRuleConfigsFromDineInConfig",
|
|
1743
1812
|
value: function () {
|
|
1744
|
-
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1813
|
+
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(dineInConfig) {
|
|
1745
1814
|
var enableItemRules, strategyModelIds, itemRuleConfigs;
|
|
1746
|
-
return _regeneratorRuntime().wrap(function
|
|
1747
|
-
while (1) switch (
|
|
1815
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1816
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1748
1817
|
case 0:
|
|
1749
1818
|
enableItemRules = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enable_item_rules']);
|
|
1750
1819
|
strategyModelIds = normalizeEnabledItemRuleIds(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enabled_item_rules']);
|
|
1751
1820
|
if (!(!enableItemRules || !strategyModelIds.length)) {
|
|
1752
|
-
|
|
1821
|
+
_context24.next = 8;
|
|
1753
1822
|
break;
|
|
1754
1823
|
}
|
|
1755
1824
|
this.itemRuleConfigs = [];
|
|
@@ -1760,12 +1829,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1760
1829
|
strategyModelIds: [],
|
|
1761
1830
|
itemRuleCount: 0
|
|
1762
1831
|
});
|
|
1763
|
-
return
|
|
1832
|
+
return _context24.abrupt("return", []);
|
|
1764
1833
|
case 8:
|
|
1765
|
-
|
|
1834
|
+
_context24.next = 10;
|
|
1766
1835
|
return this.fetchItemRuleConfigsByModelIds(strategyModelIds);
|
|
1767
1836
|
case 10:
|
|
1768
|
-
itemRuleConfigs =
|
|
1837
|
+
itemRuleConfigs = _context24.sent;
|
|
1769
1838
|
this.itemRuleConfigs = itemRuleConfigs;
|
|
1770
1839
|
this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
|
|
1771
1840
|
this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
|
|
@@ -1774,14 +1843,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1774
1843
|
strategyModelIds: strategyModelIds,
|
|
1775
1844
|
itemRuleCount: itemRuleConfigs.length
|
|
1776
1845
|
});
|
|
1777
|
-
return
|
|
1846
|
+
return _context24.abrupt("return", itemRuleConfigs);
|
|
1778
1847
|
case 16:
|
|
1779
1848
|
case "end":
|
|
1780
|
-
return
|
|
1849
|
+
return _context24.stop();
|
|
1781
1850
|
}
|
|
1782
|
-
},
|
|
1851
|
+
}, _callee24, this);
|
|
1783
1852
|
}));
|
|
1784
|
-
function syncItemRuleConfigsFromDineInConfig(
|
|
1853
|
+
function syncItemRuleConfigsFromDineInConfig(_x16) {
|
|
1785
1854
|
return _syncItemRuleConfigsFromDineInConfig.apply(this, arguments);
|
|
1786
1855
|
}
|
|
1787
1856
|
return syncItemRuleConfigsFromDineInConfig;
|
|
@@ -1789,22 +1858,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1789
1858
|
}, {
|
|
1790
1859
|
key: "fetchItemRuleConfigsByModelIds",
|
|
1791
1860
|
value: function () {
|
|
1792
|
-
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1861
|
+
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(strategyModelIds) {
|
|
1793
1862
|
var result, configs;
|
|
1794
|
-
return _regeneratorRuntime().wrap(function
|
|
1795
|
-
while (1) switch (
|
|
1863
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1864
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1796
1865
|
case 0:
|
|
1797
1866
|
this.logMethodStart('fetchItemRuleConfigsByModelIds', {
|
|
1798
1867
|
strategyModelIds: strategyModelIds
|
|
1799
1868
|
});
|
|
1800
1869
|
if (strategyModelIds.length) {
|
|
1801
|
-
|
|
1870
|
+
_context25.next = 3;
|
|
1802
1871
|
break;
|
|
1803
1872
|
}
|
|
1804
|
-
return
|
|
1873
|
+
return _context25.abrupt("return", []);
|
|
1805
1874
|
case 3:
|
|
1806
|
-
|
|
1807
|
-
|
|
1875
|
+
_context25.prev = 3;
|
|
1876
|
+
_context25.next = 6;
|
|
1808
1877
|
return this.request.get('/promotion', {
|
|
1809
1878
|
skip: 1,
|
|
1810
1879
|
num: 99,
|
|
@@ -1812,7 +1881,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1812
1881
|
ids: strategyModelIds
|
|
1813
1882
|
});
|
|
1814
1883
|
case 6:
|
|
1815
|
-
result =
|
|
1884
|
+
result = _context25.sent;
|
|
1816
1885
|
configs = [];
|
|
1817
1886
|
if (result.code === 200) {
|
|
1818
1887
|
configs = result.data.list.map(function (item) {
|
|
@@ -1823,22 +1892,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1823
1892
|
strategyModelIds: strategyModelIds,
|
|
1824
1893
|
strategyCount: configs.length
|
|
1825
1894
|
});
|
|
1826
|
-
return
|
|
1895
|
+
return _context25.abrupt("return", configs);
|
|
1827
1896
|
case 13:
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
this.logMethodError('fetchItemRuleConfigsByModelIds',
|
|
1897
|
+
_context25.prev = 13;
|
|
1898
|
+
_context25.t0 = _context25["catch"](3);
|
|
1899
|
+
this.logMethodError('fetchItemRuleConfigsByModelIds', _context25.t0, {
|
|
1831
1900
|
strategyModelIds: strategyModelIds
|
|
1832
1901
|
});
|
|
1833
1902
|
// A:策略加载失败时不阻塞下单
|
|
1834
|
-
return
|
|
1903
|
+
return _context25.abrupt("return", []);
|
|
1835
1904
|
case 17:
|
|
1836
1905
|
case "end":
|
|
1837
|
-
return
|
|
1906
|
+
return _context25.stop();
|
|
1838
1907
|
}
|
|
1839
|
-
},
|
|
1908
|
+
}, _callee25, this, [[3, 13]]);
|
|
1840
1909
|
}));
|
|
1841
|
-
function fetchItemRuleConfigsByModelIds(
|
|
1910
|
+
function fetchItemRuleConfigsByModelIds(_x17) {
|
|
1842
1911
|
return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
|
|
1843
1912
|
}
|
|
1844
1913
|
return fetchItemRuleConfigsByModelIds;
|
|
@@ -1846,22 +1915,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1846
1915
|
}, {
|
|
1847
1916
|
key: "buildPrefillProductSourceMap",
|
|
1848
1917
|
value: function () {
|
|
1849
|
-
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1918
|
+
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1850
1919
|
var sourceMap, productList, visited, collectFromValue;
|
|
1851
|
-
return _regeneratorRuntime().wrap(function
|
|
1852
|
-
while (1) switch (
|
|
1920
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1921
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1853
1922
|
case 0:
|
|
1854
1923
|
sourceMap = new Map();
|
|
1855
|
-
|
|
1856
|
-
|
|
1924
|
+
_context26.prev = 1;
|
|
1925
|
+
_context26.next = 4;
|
|
1857
1926
|
return this.getProductList();
|
|
1858
1927
|
case 4:
|
|
1859
|
-
productList =
|
|
1928
|
+
productList = _context26.sent;
|
|
1860
1929
|
if (Array.isArray(productList)) {
|
|
1861
|
-
|
|
1930
|
+
_context26.next = 7;
|
|
1862
1931
|
break;
|
|
1863
1932
|
}
|
|
1864
|
-
return
|
|
1933
|
+
return _context26.abrupt("return", sourceMap);
|
|
1865
1934
|
case 7:
|
|
1866
1935
|
visited = new Set();
|
|
1867
1936
|
collectFromValue = function collectFromValue(value) {
|
|
@@ -1888,8 +1957,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1888
1957
|
var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
|
|
1889
1958
|
var productId = Number(rawProductId);
|
|
1890
1959
|
if (Number.isFinite(productId) && productId > 0) {
|
|
1891
|
-
var
|
|
1892
|
-
var productVariantId = Number((
|
|
1960
|
+
var _ref7, _node$product_variant;
|
|
1961
|
+
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
1962
|
var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
|
|
1894
1963
|
var key = buildProductKey(productId, normalizedVariantId);
|
|
1895
1964
|
if (!sourceMap.has(key)) {
|
|
@@ -1904,19 +1973,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1904
1973
|
}
|
|
1905
1974
|
};
|
|
1906
1975
|
collectFromValue(productList);
|
|
1907
|
-
|
|
1976
|
+
_context26.next = 15;
|
|
1908
1977
|
break;
|
|
1909
1978
|
case 12:
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
this.logMethodError('buildPrefillProductSourceMap',
|
|
1979
|
+
_context26.prev = 12;
|
|
1980
|
+
_context26.t0 = _context26["catch"](1);
|
|
1981
|
+
this.logMethodError('buildPrefillProductSourceMap', _context26.t0);
|
|
1913
1982
|
case 15:
|
|
1914
|
-
return
|
|
1983
|
+
return _context26.abrupt("return", sourceMap);
|
|
1915
1984
|
case 16:
|
|
1916
1985
|
case "end":
|
|
1917
|
-
return
|
|
1986
|
+
return _context26.stop();
|
|
1918
1987
|
}
|
|
1919
|
-
},
|
|
1988
|
+
}, _callee26, this, [[1, 12]]);
|
|
1920
1989
|
}));
|
|
1921
1990
|
function buildPrefillProductSourceMap() {
|
|
1922
1991
|
return _buildPrefillProductSourceMap.apply(this, arguments);
|
|
@@ -1931,58 +2000,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1931
2000
|
}, {
|
|
1932
2001
|
key: "ensureItemRuleConfigsLoaded",
|
|
1933
2002
|
value: function () {
|
|
1934
|
-
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2003
|
+
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
1935
2004
|
var _this6 = this;
|
|
1936
2005
|
var loadedConfigs;
|
|
1937
|
-
return _regeneratorRuntime().wrap(function
|
|
1938
|
-
while (1) switch (
|
|
2006
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2007
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1939
2008
|
case 0:
|
|
1940
2009
|
if (!(this.itemRuleConfigs.length > 0)) {
|
|
1941
|
-
|
|
2010
|
+
_context28.next = 2;
|
|
1942
2011
|
break;
|
|
1943
2012
|
}
|
|
1944
|
-
return
|
|
2013
|
+
return _context28.abrupt("return", this.itemRuleConfigs);
|
|
1945
2014
|
case 2:
|
|
1946
2015
|
if (!this.itemRuleConfigsPromise) {
|
|
1947
|
-
|
|
2016
|
+
_context28.next = 4;
|
|
1948
2017
|
break;
|
|
1949
2018
|
}
|
|
1950
|
-
return
|
|
2019
|
+
return _context28.abrupt("return", this.itemRuleConfigsPromise);
|
|
1951
2020
|
case 4:
|
|
1952
|
-
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2021
|
+
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
1953
2022
|
var runtimeConfig, staticConfigs;
|
|
1954
|
-
return _regeneratorRuntime().wrap(function
|
|
1955
|
-
while (1) switch (
|
|
2023
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2024
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1956
2025
|
case 0:
|
|
1957
2026
|
runtimeConfig = _this6.getItemRuleRuntimeConfig();
|
|
1958
2027
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
1959
2028
|
if (!(staticConfigs.length > 0)) {
|
|
1960
|
-
|
|
2029
|
+
_context27.next = 6;
|
|
1961
2030
|
break;
|
|
1962
2031
|
}
|
|
1963
2032
|
_this6.itemRuleConfigs = staticConfigs;
|
|
1964
2033
|
_this6.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
1965
|
-
return
|
|
2034
|
+
return _context27.abrupt("return", _this6.itemRuleConfigs);
|
|
1966
2035
|
case 6:
|
|
1967
2036
|
_this6.itemRuleConfigs = [];
|
|
1968
2037
|
_this6.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1969
|
-
return
|
|
2038
|
+
return _context27.abrupt("return", _this6.itemRuleConfigs);
|
|
1970
2039
|
case 9:
|
|
1971
2040
|
case "end":
|
|
1972
|
-
return
|
|
2041
|
+
return _context27.stop();
|
|
1973
2042
|
}
|
|
1974
|
-
},
|
|
2043
|
+
}, _callee27);
|
|
1975
2044
|
}))();
|
|
1976
|
-
|
|
2045
|
+
_context28.next = 7;
|
|
1977
2046
|
return this.itemRuleConfigsPromise;
|
|
1978
2047
|
case 7:
|
|
1979
|
-
loadedConfigs =
|
|
1980
|
-
return
|
|
2048
|
+
loadedConfigs = _context28.sent;
|
|
2049
|
+
return _context28.abrupt("return", loadedConfigs);
|
|
1981
2050
|
case 9:
|
|
1982
2051
|
case "end":
|
|
1983
|
-
return
|
|
2052
|
+
return _context28.stop();
|
|
1984
2053
|
}
|
|
1985
|
-
},
|
|
2054
|
+
}, _callee28, this);
|
|
1986
2055
|
}));
|
|
1987
2056
|
function ensureItemRuleConfigsLoaded() {
|
|
1988
2057
|
return _ensureItemRuleConfigsLoaded.apply(this, arguments);
|
|
@@ -1992,22 +2061,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1992
2061
|
}, {
|
|
1993
2062
|
key: "refreshItemRuleQuantityLimits",
|
|
1994
2063
|
value: function () {
|
|
1995
|
-
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2064
|
+
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1996
2065
|
var strategyConfigs, businessData, limits;
|
|
1997
|
-
return _regeneratorRuntime().wrap(function
|
|
1998
|
-
while (1) switch (
|
|
2066
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2067
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1999
2068
|
case 0:
|
|
2000
|
-
|
|
2001
|
-
|
|
2069
|
+
_context29.prev = 0;
|
|
2070
|
+
_context29.next = 3;
|
|
2002
2071
|
return this.ensureItemRuleConfigsLoaded();
|
|
2003
2072
|
case 3:
|
|
2004
|
-
strategyConfigs =
|
|
2073
|
+
strategyConfigs = _context29.sent;
|
|
2005
2074
|
if (strategyConfigs.length) {
|
|
2006
|
-
|
|
2075
|
+
_context29.next = 7;
|
|
2007
2076
|
break;
|
|
2008
2077
|
}
|
|
2009
2078
|
this.store.itemRuleQuantityLimits = [];
|
|
2010
|
-
return
|
|
2079
|
+
return _context29.abrupt("return", []);
|
|
2011
2080
|
case 7:
|
|
2012
2081
|
businessData = buildItemRuleBusinessData({
|
|
2013
2082
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -2019,18 +2088,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2019
2088
|
this.logMethodSuccess('refreshItemRuleQuantityLimits', {
|
|
2020
2089
|
limitCount: limits.length
|
|
2021
2090
|
});
|
|
2022
|
-
return
|
|
2091
|
+
return _context29.abrupt("return", limits);
|
|
2023
2092
|
case 14:
|
|
2024
|
-
|
|
2025
|
-
|
|
2093
|
+
_context29.prev = 14;
|
|
2094
|
+
_context29.t0 = _context29["catch"](0);
|
|
2026
2095
|
this.store.itemRuleQuantityLimits = [];
|
|
2027
|
-
this.logMethodError('refreshItemRuleQuantityLimits',
|
|
2028
|
-
return
|
|
2096
|
+
this.logMethodError('refreshItemRuleQuantityLimits', _context29.t0);
|
|
2097
|
+
return _context29.abrupt("return", []);
|
|
2029
2098
|
case 19:
|
|
2030
2099
|
case "end":
|
|
2031
|
-
return
|
|
2100
|
+
return _context29.stop();
|
|
2032
2101
|
}
|
|
2033
|
-
},
|
|
2102
|
+
}, _callee29, this, [[0, 14]]);
|
|
2034
2103
|
}));
|
|
2035
2104
|
function refreshItemRuleQuantityLimits() {
|
|
2036
2105
|
return _refreshItemRuleQuantityLimits.apply(this, arguments);
|
|
@@ -2040,32 +2109,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2040
2109
|
}, {
|
|
2041
2110
|
key: "applyPrefillByItemRule",
|
|
2042
2111
|
value: function () {
|
|
2043
|
-
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2112
|
+
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2044
2113
|
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 (
|
|
2114
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2115
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2047
2116
|
case 0:
|
|
2048
2117
|
if (!this.itemRulePrefillApplied) {
|
|
2049
|
-
|
|
2118
|
+
_context30.next = 2;
|
|
2050
2119
|
break;
|
|
2051
2120
|
}
|
|
2052
|
-
return
|
|
2121
|
+
return _context30.abrupt("return");
|
|
2053
2122
|
case 2:
|
|
2054
2123
|
if (this.store.order) {
|
|
2055
|
-
|
|
2124
|
+
_context30.next = 4;
|
|
2056
2125
|
break;
|
|
2057
2126
|
}
|
|
2058
|
-
return
|
|
2127
|
+
return _context30.abrupt("return");
|
|
2059
2128
|
case 4:
|
|
2060
|
-
|
|
2129
|
+
_context30.next = 6;
|
|
2061
2130
|
return this.ensureItemRuleConfigsLoaded();
|
|
2062
2131
|
case 6:
|
|
2063
|
-
strategyConfigs =
|
|
2132
|
+
strategyConfigs = _context30.sent;
|
|
2064
2133
|
if (strategyConfigs.length) {
|
|
2065
|
-
|
|
2134
|
+
_context30.next = 9;
|
|
2066
2135
|
break;
|
|
2067
2136
|
}
|
|
2068
|
-
return
|
|
2137
|
+
return _context30.abrupt("return");
|
|
2069
2138
|
case 9:
|
|
2070
2139
|
businessData = buildItemRuleBusinessData({
|
|
2071
2140
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -2074,24 +2143,24 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2074
2143
|
});
|
|
2075
2144
|
prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
|
|
2076
2145
|
if (prefillItems.length) {
|
|
2077
|
-
|
|
2146
|
+
_context30.next = 14;
|
|
2078
2147
|
break;
|
|
2079
2148
|
}
|
|
2080
2149
|
this.itemRulePrefillApplied = true;
|
|
2081
|
-
return
|
|
2150
|
+
return _context30.abrupt("return");
|
|
2082
2151
|
case 14:
|
|
2083
|
-
|
|
2152
|
+
_context30.next = 16;
|
|
2084
2153
|
return this.buildPrefillProductSourceMap();
|
|
2085
2154
|
case 16:
|
|
2086
|
-
productSourceMap =
|
|
2155
|
+
productSourceMap = _context30.sent;
|
|
2087
2156
|
tempOrder = this.ensureTempOrder();
|
|
2088
2157
|
hasChanges = false;
|
|
2089
2158
|
_iterator6 = _createForOfIteratorHelper(prefillItems);
|
|
2090
|
-
|
|
2159
|
+
_context30.prev = 20;
|
|
2091
2160
|
_iterator6.s();
|
|
2092
2161
|
case 22:
|
|
2093
2162
|
if ((_step6 = _iterator6.n()).done) {
|
|
2094
|
-
|
|
2163
|
+
_context30.next = 47;
|
|
2095
2164
|
break;
|
|
2096
2165
|
}
|
|
2097
2166
|
prefillItem = _step6.value;
|
|
@@ -2099,16 +2168,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2099
2168
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
2100
2169
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
2101
2170
|
if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
|
|
2102
|
-
|
|
2171
|
+
_context30.next = 29;
|
|
2103
2172
|
break;
|
|
2104
2173
|
}
|
|
2105
|
-
return
|
|
2174
|
+
return _context30.abrupt("continue", 45);
|
|
2106
2175
|
case 29:
|
|
2107
2176
|
if (!Number.isNaN(productVariantId)) {
|
|
2108
|
-
|
|
2177
|
+
_context30.next = 31;
|
|
2109
2178
|
break;
|
|
2110
2179
|
}
|
|
2111
|
-
return
|
|
2180
|
+
return _context30.abrupt("continue", 45);
|
|
2112
2181
|
case 31:
|
|
2113
2182
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
2114
2183
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
@@ -2116,7 +2185,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2116
2185
|
product_variant_id: productVariantId
|
|
2117
2186
|
});
|
|
2118
2187
|
if (!(productIndex === -1)) {
|
|
2119
|
-
|
|
2188
|
+
_context30.next = 38;
|
|
2120
2189
|
break;
|
|
2121
2190
|
}
|
|
2122
2191
|
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 +2205,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2136
2205
|
})
|
|
2137
2206
|
})));
|
|
2138
2207
|
hasChanges = true;
|
|
2139
|
-
return
|
|
2208
|
+
return _context30.abrupt("continue", 45);
|
|
2140
2209
|
case 38:
|
|
2141
2210
|
targetProduct = tempOrder.products[productIndex];
|
|
2142
2211
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
@@ -2157,34 +2226,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2157
2226
|
hasChanges = true;
|
|
2158
2227
|
}
|
|
2159
2228
|
case 45:
|
|
2160
|
-
|
|
2229
|
+
_context30.next = 22;
|
|
2161
2230
|
break;
|
|
2162
2231
|
case 47:
|
|
2163
|
-
|
|
2232
|
+
_context30.next = 52;
|
|
2164
2233
|
break;
|
|
2165
2234
|
case 49:
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
_iterator6.e(
|
|
2235
|
+
_context30.prev = 49;
|
|
2236
|
+
_context30.t0 = _context30["catch"](20);
|
|
2237
|
+
_iterator6.e(_context30.t0);
|
|
2169
2238
|
case 52:
|
|
2170
|
-
|
|
2239
|
+
_context30.prev = 52;
|
|
2171
2240
|
_iterator6.f();
|
|
2172
|
-
return
|
|
2241
|
+
return _context30.finish(52);
|
|
2173
2242
|
case 55:
|
|
2174
2243
|
if (!hasChanges) {
|
|
2175
|
-
|
|
2244
|
+
_context30.next = 60;
|
|
2176
2245
|
break;
|
|
2177
2246
|
}
|
|
2178
2247
|
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
2179
2248
|
this.store.order.applyDiscount();
|
|
2180
|
-
|
|
2249
|
+
_context30.next = 59;
|
|
2181
2250
|
return this.store.order.recalculateSummary({
|
|
2182
2251
|
createIfMissing: true
|
|
2183
2252
|
});
|
|
2184
2253
|
case 59:
|
|
2185
2254
|
this.store.order.persistTempOrder();
|
|
2186
2255
|
case 60:
|
|
2187
|
-
|
|
2256
|
+
_context30.next = 62;
|
|
2188
2257
|
return this.refreshItemRuleQuantityLimits();
|
|
2189
2258
|
case 62:
|
|
2190
2259
|
this.itemRulePrefillApplied = true;
|
|
@@ -2194,9 +2263,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2194
2263
|
});
|
|
2195
2264
|
case 64:
|
|
2196
2265
|
case "end":
|
|
2197
|
-
return
|
|
2266
|
+
return _context30.stop();
|
|
2198
2267
|
}
|
|
2199
|
-
},
|
|
2268
|
+
}, _callee30, this, [[20, 49, 52, 55]]);
|
|
2200
2269
|
}));
|
|
2201
2270
|
function applyPrefillByItemRule() {
|
|
2202
2271
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -2206,31 +2275,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2206
2275
|
}, {
|
|
2207
2276
|
key: "applyItemRulePrefill",
|
|
2208
2277
|
value: function () {
|
|
2209
|
-
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2210
|
-
var _this$store$
|
|
2211
|
-
return _regeneratorRuntime().wrap(function
|
|
2212
|
-
while (1) switch (
|
|
2278
|
+
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2279
|
+
var _this$store$order5, _this$store$order5$ge;
|
|
2280
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2281
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2213
2282
|
case 0:
|
|
2214
|
-
if (!((_this$store$
|
|
2215
|
-
|
|
2283
|
+
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))) {
|
|
2284
|
+
_context31.next = 2;
|
|
2216
2285
|
break;
|
|
2217
2286
|
}
|
|
2218
|
-
return
|
|
2287
|
+
return _context31.abrupt("return");
|
|
2219
2288
|
case 2:
|
|
2220
2289
|
this.logMethodStart('applyItemRulePrefill');
|
|
2221
|
-
|
|
2290
|
+
_context31.next = 5;
|
|
2222
2291
|
return this.applyPrefillByItemRule();
|
|
2223
2292
|
case 5:
|
|
2224
|
-
|
|
2293
|
+
_context31.next = 7;
|
|
2225
2294
|
return this.refreshItemRuleQuantityLimits();
|
|
2226
2295
|
case 7:
|
|
2227
|
-
|
|
2296
|
+
_context31.next = 9;
|
|
2228
2297
|
return this.refreshCartValidationPassed();
|
|
2229
2298
|
case 9:
|
|
2230
2299
|
case "end":
|
|
2231
|
-
return
|
|
2300
|
+
return _context31.stop();
|
|
2232
2301
|
}
|
|
2233
|
-
},
|
|
2302
|
+
}, _callee31, this);
|
|
2234
2303
|
}));
|
|
2235
2304
|
function applyItemRulePrefill() {
|
|
2236
2305
|
return _applyItemRulePrefill.apply(this, arguments);
|
|
@@ -2240,20 +2309,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2240
2309
|
}, {
|
|
2241
2310
|
key: "evaluateCartValidationByItemRule",
|
|
2242
2311
|
value: function () {
|
|
2243
|
-
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2312
|
+
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
2244
2313
|
var strategyConfigs, businessData;
|
|
2245
|
-
return _regeneratorRuntime().wrap(function
|
|
2246
|
-
while (1) switch (
|
|
2314
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2315
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2247
2316
|
case 0:
|
|
2248
|
-
|
|
2317
|
+
_context32.next = 2;
|
|
2249
2318
|
return this.ensureItemRuleConfigsLoaded();
|
|
2250
2319
|
case 2:
|
|
2251
|
-
strategyConfigs =
|
|
2320
|
+
strategyConfigs = _context32.sent;
|
|
2252
2321
|
if (strategyConfigs.length) {
|
|
2253
|
-
|
|
2322
|
+
_context32.next = 5;
|
|
2254
2323
|
break;
|
|
2255
2324
|
}
|
|
2256
|
-
return
|
|
2325
|
+
return _context32.abrupt("return", {
|
|
2257
2326
|
passed: true,
|
|
2258
2327
|
failures: []
|
|
2259
2328
|
});
|
|
@@ -2263,12 +2332,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2263
2332
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
2264
2333
|
itemRuleConfigs: this.itemRuleConfigs
|
|
2265
2334
|
});
|
|
2266
|
-
return
|
|
2335
|
+
return _context32.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
|
|
2267
2336
|
case 7:
|
|
2268
2337
|
case "end":
|
|
2269
|
-
return
|
|
2338
|
+
return _context32.stop();
|
|
2270
2339
|
}
|
|
2271
|
-
},
|
|
2340
|
+
}, _callee32, this);
|
|
2272
2341
|
}));
|
|
2273
2342
|
function evaluateCartValidationByItemRule() {
|
|
2274
2343
|
return _evaluateCartValidationByItemRule.apply(this, arguments);
|
|
@@ -2278,20 +2347,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2278
2347
|
}, {
|
|
2279
2348
|
key: "validateBeforeSubmitByItemRule",
|
|
2280
2349
|
value: function () {
|
|
2281
|
-
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2350
|
+
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2282
2351
|
var validationResult, firstFailure, errorMessage, error;
|
|
2283
|
-
return _regeneratorRuntime().wrap(function
|
|
2284
|
-
while (1) switch (
|
|
2352
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2353
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2285
2354
|
case 0:
|
|
2286
|
-
|
|
2355
|
+
_context33.next = 2;
|
|
2287
2356
|
return this.evaluateCartValidationByItemRule();
|
|
2288
2357
|
case 2:
|
|
2289
|
-
validationResult =
|
|
2358
|
+
validationResult = _context33.sent;
|
|
2290
2359
|
if (!validationResult.passed) {
|
|
2291
|
-
|
|
2360
|
+
_context33.next = 5;
|
|
2292
2361
|
break;
|
|
2293
2362
|
}
|
|
2294
|
-
return
|
|
2363
|
+
return _context33.abrupt("return");
|
|
2295
2364
|
case 5:
|
|
2296
2365
|
firstFailure = validationResult.failures[0];
|
|
2297
2366
|
errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
|
|
@@ -2300,9 +2369,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2300
2369
|
throw error;
|
|
2301
2370
|
case 10:
|
|
2302
2371
|
case "end":
|
|
2303
|
-
return
|
|
2372
|
+
return _context33.stop();
|
|
2304
2373
|
}
|
|
2305
|
-
},
|
|
2374
|
+
}, _callee33, this);
|
|
2306
2375
|
}));
|
|
2307
2376
|
function validateBeforeSubmitByItemRule() {
|
|
2308
2377
|
return _validateBeforeSubmitByItemRule.apply(this, arguments);
|
|
@@ -2312,10 +2381,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2312
2381
|
}, {
|
|
2313
2382
|
key: "refreshCartValidationPassed",
|
|
2314
2383
|
value: function () {
|
|
2315
|
-
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2384
|
+
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2316
2385
|
var previous, nextState, validationResult, changed;
|
|
2317
|
-
return _regeneratorRuntime().wrap(function
|
|
2318
|
-
while (1) switch (
|
|
2386
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2387
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2319
2388
|
case 0:
|
|
2320
2389
|
previous = this.store.cartValidation || {
|
|
2321
2390
|
passed: null,
|
|
@@ -2325,20 +2394,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2325
2394
|
passed: null,
|
|
2326
2395
|
failures: []
|
|
2327
2396
|
};
|
|
2328
|
-
|
|
2329
|
-
|
|
2397
|
+
_context34.prev = 2;
|
|
2398
|
+
_context34.next = 5;
|
|
2330
2399
|
return this.evaluateCartValidationByItemRule();
|
|
2331
2400
|
case 5:
|
|
2332
|
-
validationResult =
|
|
2401
|
+
validationResult = _context34.sent;
|
|
2333
2402
|
nextState = {
|
|
2334
2403
|
passed: validationResult.passed,
|
|
2335
2404
|
failures: validationResult.failures || []
|
|
2336
2405
|
};
|
|
2337
|
-
|
|
2406
|
+
_context34.next = 12;
|
|
2338
2407
|
break;
|
|
2339
2408
|
case 9:
|
|
2340
|
-
|
|
2341
|
-
|
|
2409
|
+
_context34.prev = 9;
|
|
2410
|
+
_context34.t0 = _context34["catch"](2);
|
|
2342
2411
|
nextState = {
|
|
2343
2412
|
passed: false,
|
|
2344
2413
|
failures: []
|
|
@@ -2347,21 +2416,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2347
2416
|
this.store.cartValidation = nextState;
|
|
2348
2417
|
changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
|
|
2349
2418
|
if (!changed) {
|
|
2350
|
-
|
|
2419
|
+
_context34.next = 17;
|
|
2351
2420
|
break;
|
|
2352
2421
|
}
|
|
2353
|
-
|
|
2422
|
+
_context34.next = 17;
|
|
2354
2423
|
return this.core.effects.emit(ScanOrderHooks.onCartValidationChanged, {
|
|
2355
2424
|
cartValidation: nextState,
|
|
2356
2425
|
cartValidationPassed: nextState.passed
|
|
2357
2426
|
});
|
|
2358
2427
|
case 17:
|
|
2359
|
-
return
|
|
2428
|
+
return _context34.abrupt("return", nextState.passed);
|
|
2360
2429
|
case 18:
|
|
2361
2430
|
case "end":
|
|
2362
|
-
return
|
|
2431
|
+
return _context34.stop();
|
|
2363
2432
|
}
|
|
2364
|
-
},
|
|
2433
|
+
}, _callee34, this, [[2, 9]]);
|
|
2365
2434
|
}));
|
|
2366
2435
|
function refreshCartValidationPassed() {
|
|
2367
2436
|
return _refreshCartValidationPassed.apply(this, arguments);
|
|
@@ -2371,14 +2440,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2371
2440
|
}, {
|
|
2372
2441
|
key: "setItemRuleRuntimeConfig",
|
|
2373
2442
|
value: function () {
|
|
2374
|
-
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2443
|
+
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2375
2444
|
var _this$itemRuleRuntime, _this$itemRuleRuntime2;
|
|
2376
2445
|
var config,
|
|
2377
|
-
|
|
2378
|
-
return _regeneratorRuntime().wrap(function
|
|
2379
|
-
while (1) switch (
|
|
2446
|
+
_args35 = arguments;
|
|
2447
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2448
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2380
2449
|
case 0:
|
|
2381
|
-
config =
|
|
2450
|
+
config = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : {};
|
|
2382
2451
|
this.logMethodStart('setItemRuleRuntimeConfig');
|
|
2383
2452
|
this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
|
|
2384
2453
|
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 +2459,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2390
2459
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
2391
2460
|
}
|
|
2392
2461
|
this.itemRulePrefillApplied = false;
|
|
2393
|
-
|
|
2462
|
+
_context35.next = 7;
|
|
2394
2463
|
return this.refreshItemRuleQuantityLimits();
|
|
2395
2464
|
case 7:
|
|
2396
|
-
|
|
2465
|
+
_context35.next = 9;
|
|
2397
2466
|
return this.refreshCartValidationPassed();
|
|
2398
2467
|
case 9:
|
|
2399
2468
|
this.logMethodSuccess('setItemRuleRuntimeConfig', {
|
|
@@ -2401,9 +2470,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2401
2470
|
});
|
|
2402
2471
|
case 10:
|
|
2403
2472
|
case "end":
|
|
2404
|
-
return
|
|
2473
|
+
return _context35.stop();
|
|
2405
2474
|
}
|
|
2406
|
-
},
|
|
2475
|
+
}, _callee35, this);
|
|
2407
2476
|
}));
|
|
2408
2477
|
function setItemRuleRuntimeConfig() {
|
|
2409
2478
|
return _setItemRuleRuntimeConfig.apply(this, arguments);
|
|
@@ -2413,14 +2482,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2413
2482
|
}, {
|
|
2414
2483
|
key: "normalizeResourceState",
|
|
2415
2484
|
value: function normalizeResourceState(detail, resourceSelectType, hasOrderId) {
|
|
2416
|
-
var _detail$form_record, _this$
|
|
2485
|
+
var _detail$form_record, _this$otherParams9, _detail$resource_capa, _detail$resource_capa2;
|
|
2417
2486
|
var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
|
|
2418
2487
|
var lastOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.last_order_id);
|
|
2419
2488
|
var relationId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_record_id);
|
|
2420
2489
|
var tableFormId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_id);
|
|
2421
2490
|
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
2491
|
// 是否允许加餐
|
|
2423
|
-
var allowSnack = ((_this$
|
|
2492
|
+
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
2493
|
// 开启同桌验证 - 本期没有这个配置,默认关掉
|
|
2425
2494
|
var deskmateValid = false;
|
|
2426
2495
|
var isExclusive = resourceSelectType === 'single';
|
|
@@ -2502,27 +2571,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2502
2571
|
}, {
|
|
2503
2572
|
key: "fetchResourceOccupyDetailByResourceId",
|
|
2504
2573
|
value: function () {
|
|
2505
|
-
var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2506
|
-
var _this$
|
|
2574
|
+
var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId) {
|
|
2575
|
+
var _this$otherParams10, _this$otherParams10$g, _response$data$occupy, _response$data;
|
|
2507
2576
|
var formRecordId, shopId, response;
|
|
2508
|
-
return _regeneratorRuntime().wrap(function
|
|
2509
|
-
while (1) switch (
|
|
2577
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2578
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2510
2579
|
case 0:
|
|
2511
2580
|
formRecordId = Number(resourceId);
|
|
2512
2581
|
if (!(!Number.isFinite(formRecordId) || formRecordId <= 0)) {
|
|
2513
|
-
|
|
2582
|
+
_context36.next = 3;
|
|
2514
2583
|
break;
|
|
2515
2584
|
}
|
|
2516
2585
|
throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
|
|
2517
2586
|
case 3:
|
|
2518
|
-
shopId = (_this$
|
|
2587
|
+
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
2588
|
if (shopId) {
|
|
2520
|
-
|
|
2589
|
+
_context36.next = 6;
|
|
2521
2590
|
break;
|
|
2522
2591
|
}
|
|
2523
2592
|
throw new Error('[ScanOrder] 无法获取 shop_id');
|
|
2524
2593
|
case 6:
|
|
2525
|
-
|
|
2594
|
+
_context36.next = 8;
|
|
2526
2595
|
return this.request.get('/order/resource/occupy-detail', {
|
|
2527
2596
|
shop_id: shopId,
|
|
2528
2597
|
'form_record_ids[]': formRecordId,
|
|
@@ -2531,21 +2600,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2531
2600
|
with_resource_form_info: 1
|
|
2532
2601
|
});
|
|
2533
2602
|
case 8:
|
|
2534
|
-
response =
|
|
2603
|
+
response = _context36.sent;
|
|
2535
2604
|
if (response !== null && response !== void 0 && response.status) {
|
|
2536
|
-
|
|
2605
|
+
_context36.next = 11;
|
|
2537
2606
|
break;
|
|
2538
2607
|
}
|
|
2539
2608
|
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
|
|
2540
2609
|
case 11:
|
|
2541
|
-
return
|
|
2610
|
+
return _context36.abrupt("return", (_response$data$occupy = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.occupy_details) === null || _response$data === void 0 ? void 0 : _response$data[0]) !== null && _response$data$occupy !== void 0 ? _response$data$occupy : null);
|
|
2542
2611
|
case 12:
|
|
2543
2612
|
case "end":
|
|
2544
|
-
return
|
|
2613
|
+
return _context36.stop();
|
|
2545
2614
|
}
|
|
2546
|
-
},
|
|
2615
|
+
}, _callee36, this);
|
|
2547
2616
|
}));
|
|
2548
|
-
function fetchResourceOccupyDetailByResourceId(
|
|
2617
|
+
function fetchResourceOccupyDetailByResourceId(_x18) {
|
|
2549
2618
|
return _fetchResourceOccupyDetailByResourceId.apply(this, arguments);
|
|
2550
2619
|
}
|
|
2551
2620
|
return fetchResourceOccupyDetailByResourceId;
|
|
@@ -2555,37 +2624,90 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2555
2624
|
}, {
|
|
2556
2625
|
key: "checkResourceAvailable",
|
|
2557
2626
|
value: function () {
|
|
2558
|
-
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2559
|
-
var
|
|
2560
|
-
|
|
2561
|
-
|
|
2627
|
+
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(resourceId) {
|
|
2628
|
+
var hasOrderId,
|
|
2629
|
+
normalizedResourceId,
|
|
2630
|
+
_this$otherParams$bus,
|
|
2631
|
+
_this$otherParams11,
|
|
2632
|
+
_this$otherParams$cha,
|
|
2633
|
+
_this$otherParams12,
|
|
2634
|
+
_this$otherParams13,
|
|
2635
|
+
_this$otherParams13$g,
|
|
2636
|
+
_occupyDetail$form_re,
|
|
2637
|
+
_occupyDetail$form_re2,
|
|
2638
|
+
_this$otherParams14,
|
|
2639
|
+
_this$store$order6,
|
|
2640
|
+
_this$store$order8,
|
|
2641
|
+
_this$store$order8$ge,
|
|
2642
|
+
_this$otherParams15,
|
|
2643
|
+
businessCode,
|
|
2644
|
+
channel,
|
|
2645
|
+
openDataTarget,
|
|
2646
|
+
openData,
|
|
2647
|
+
dineInConfig,
|
|
2648
|
+
closedBehaviorValue,
|
|
2649
|
+
closedMessage,
|
|
2650
|
+
basicUnavailableMessage,
|
|
2651
|
+
pauseMessage,
|
|
2652
|
+
makeShopClosed,
|
|
2653
|
+
operatingHourIds,
|
|
2654
|
+
outsideOperatingHours,
|
|
2655
|
+
scheduleList,
|
|
2656
|
+
now,
|
|
2657
|
+
tempOrder,
|
|
2658
|
+
reservationLinkIds,
|
|
2659
|
+
pendingRequestEntryPax,
|
|
2660
|
+
pendingRequestPaxMin,
|
|
2661
|
+
pendingRequestPaxMax,
|
|
2662
|
+
reservationProductList,
|
|
2663
|
+
scheduleDate,
|
|
2664
|
+
scheduleDatetime,
|
|
2665
|
+
loaded,
|
|
2666
|
+
occupancyMinutes,
|
|
2667
|
+
paxBounds,
|
|
2668
|
+
error,
|
|
2669
|
+
occupyDetail,
|
|
2670
|
+
resourceSelectType,
|
|
2671
|
+
resourceState,
|
|
2672
|
+
availabilityInfo,
|
|
2673
|
+
_this$store$order7,
|
|
2674
|
+
_res$data,
|
|
2675
|
+
res,
|
|
2676
|
+
entryPaxNumber,
|
|
2677
|
+
lastOrderInfo,
|
|
2678
|
+
historicalItems,
|
|
2679
|
+
_args37 = arguments;
|
|
2680
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2681
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2562
2682
|
case 0:
|
|
2683
|
+
hasOrderId = _args37.length > 1 && _args37[1] !== undefined ? _args37[1] : false;
|
|
2684
|
+
normalizedResourceId = String(resourceId !== null && resourceId !== void 0 ? resourceId : '').trim();
|
|
2563
2685
|
this.logMethodStart('checkResourceAvailable', {
|
|
2564
|
-
resourceId:
|
|
2686
|
+
resourceId: normalizedResourceId
|
|
2565
2687
|
});
|
|
2566
|
-
|
|
2567
|
-
businessCode = String((_this$otherParams$bus = (_this$
|
|
2568
|
-
channel = String((_this$otherParams$cha = (_this$
|
|
2688
|
+
_context37.prev = 3;
|
|
2689
|
+
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();
|
|
2690
|
+
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
2691
|
openDataTarget = businessCode && channel ? "".concat(businessCode, "+").concat(channel) : 'dine_in+scan_to_order';
|
|
2570
|
-
|
|
2571
|
-
return (_this$
|
|
2692
|
+
_context37.next = 9;
|
|
2693
|
+
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
2694
|
scope: 'board',
|
|
2573
2695
|
target: openDataTarget,
|
|
2574
2696
|
section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
|
|
2575
2697
|
});
|
|
2576
|
-
case
|
|
2577
|
-
openData =
|
|
2698
|
+
case 9:
|
|
2699
|
+
openData = _context37.sent;
|
|
2578
2700
|
if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
|
|
2579
|
-
|
|
2701
|
+
_context37.next = 12;
|
|
2580
2702
|
break;
|
|
2581
2703
|
}
|
|
2582
2704
|
throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
|
|
2583
|
-
case
|
|
2705
|
+
case 12:
|
|
2584
2706
|
dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
|
|
2585
2707
|
this.otherParams.dineInConfig = dineInConfig;
|
|
2586
|
-
|
|
2708
|
+
_context37.next = 16;
|
|
2587
2709
|
return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
|
|
2588
|
-
case
|
|
2710
|
+
case 16:
|
|
2589
2711
|
closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
|
|
2590
2712
|
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
2713
|
basicUnavailableMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.unavailable_message']) || closedMessage;
|
|
@@ -2602,21 +2724,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2602
2724
|
};
|
|
2603
2725
|
}; // 1. 基础开关 basic.enable 关闭
|
|
2604
2726
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
|
|
2605
|
-
|
|
2727
|
+
_context37.next = 23;
|
|
2606
2728
|
break;
|
|
2607
2729
|
}
|
|
2608
|
-
return
|
|
2609
|
-
case
|
|
2730
|
+
return _context37.abrupt("return", makeShopClosed(basicUnavailableMessage));
|
|
2731
|
+
case 23:
|
|
2610
2732
|
if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
|
|
2611
|
-
|
|
2733
|
+
_context37.next = 26;
|
|
2612
2734
|
break;
|
|
2613
2735
|
}
|
|
2614
2736
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
|
|
2615
|
-
|
|
2737
|
+
_context37.next = 26;
|
|
2616
2738
|
break;
|
|
2617
2739
|
}
|
|
2618
|
-
return
|
|
2619
|
-
case
|
|
2740
|
+
return _context37.abrupt("return", makeShopClosed(pauseMessage));
|
|
2741
|
+
case 26:
|
|
2620
2742
|
// 3. 营业时间 operating_hours 闸门
|
|
2621
2743
|
operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
|
|
2622
2744
|
return Number(id);
|
|
@@ -2632,27 +2754,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2632
2754
|
}
|
|
2633
2755
|
}
|
|
2634
2756
|
if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
|
|
2635
|
-
|
|
2757
|
+
_context37.next = 31;
|
|
2636
2758
|
break;
|
|
2637
2759
|
}
|
|
2638
|
-
return
|
|
2639
|
-
case
|
|
2760
|
+
return _context37.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
|
|
2761
|
+
case 31:
|
|
2640
2762
|
// Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
|
|
2641
2763
|
// (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
|
|
2642
2764
|
tempOrder = this.ensureTempOrder();
|
|
2643
2765
|
reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
|
|
2644
|
-
if (!(reservationLinkIds.length === 0)) {
|
|
2645
|
-
|
|
2766
|
+
if (!(!normalizedResourceId || reservationLinkIds.length === 0)) {
|
|
2767
|
+
_context37.next = 37;
|
|
2646
2768
|
break;
|
|
2647
2769
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2770
|
+
_context37.next = 36;
|
|
2771
|
+
return this.prepareRetailAvailability({
|
|
2772
|
+
tempOrder: tempOrder,
|
|
2773
|
+
hasOrderId: hasOrderId,
|
|
2774
|
+
resourceId: normalizedResourceId,
|
|
2775
|
+
reason: !normalizedResourceId ? 'missing_resource_id' : 'missing_enabled_resource_rules'
|
|
2776
|
+
});
|
|
2777
|
+
case 36:
|
|
2778
|
+
return _context37.abrupt("return", _context37.sent);
|
|
2779
|
+
case 37:
|
|
2652
2780
|
tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
|
|
2653
2781
|
delete tempOrder.metadata.table_occupancy_duration;
|
|
2654
2782
|
reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
|
|
2655
|
-
|
|
2783
|
+
_context37.next = 42;
|
|
2656
2784
|
return reservationProductList.initialize(this.core, {
|
|
2657
2785
|
store: {
|
|
2658
2786
|
list: [],
|
|
@@ -2664,18 +2792,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2664
2792
|
cacheId: this.cacheId
|
|
2665
2793
|
})
|
|
2666
2794
|
});
|
|
2667
|
-
case
|
|
2795
|
+
case 42:
|
|
2668
2796
|
scheduleDate = dayjs().format('YYYY-MM-DD');
|
|
2669
2797
|
scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
2670
|
-
|
|
2798
|
+
_context37.next = 46;
|
|
2671
2799
|
return reservationProductList.loadProducts({
|
|
2672
2800
|
product_ids: reservationLinkIds,
|
|
2673
2801
|
schedule_date: scheduleDate,
|
|
2674
2802
|
schedule_datetime: scheduleDatetime,
|
|
2675
2803
|
cacheId: this.cacheId
|
|
2676
2804
|
});
|
|
2677
|
-
case
|
|
2678
|
-
loaded =
|
|
2805
|
+
case 46:
|
|
2806
|
+
loaded = _context37.sent;
|
|
2679
2807
|
if (Array.isArray(loaded)) {
|
|
2680
2808
|
this.enabledReservationRuleProducts = loaded;
|
|
2681
2809
|
occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
|
|
@@ -2692,18 +2820,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2692
2820
|
this.enabledReservationRuleProducts = [];
|
|
2693
2821
|
error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
|
|
2694
2822
|
this.logMethodError('loadReservationRuleProducts', error, {
|
|
2695
|
-
resourceId:
|
|
2823
|
+
resourceId: normalizedResourceId,
|
|
2696
2824
|
reservationLinkIds: reservationLinkIds,
|
|
2697
2825
|
scheduleDate: scheduleDate,
|
|
2698
2826
|
scheduleDatetime: scheduleDatetime,
|
|
2699
2827
|
cacheId: this.cacheId
|
|
2700
2828
|
});
|
|
2701
2829
|
}
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2830
|
+
|
|
2831
|
+
// Step2: 请求新的资源占用详情接口
|
|
2832
|
+
_context37.next = 50;
|
|
2833
|
+
return this.fetchResourceOccupyDetailByResourceId(normalizedResourceId);
|
|
2834
|
+
case 50:
|
|
2835
|
+
occupyDetail = _context37.sent;
|
|
2707
2836
|
// Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
|
|
2708
2837
|
// 计算当前桌台的 resourceSelectType(single/multiple/capacity)
|
|
2709
2838
|
resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id)); // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
|
|
@@ -2736,44 +2865,44 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2736
2865
|
} : {}), this.store.resource.requestPaxMax !== undefined ? {
|
|
2737
2866
|
requestPaxMax: this.store.resource.requestPaxMax
|
|
2738
2867
|
} : {});
|
|
2739
|
-
tempOrder.relation_id =
|
|
2868
|
+
tempOrder.relation_id = normalizedResourceId || ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.relation_id);
|
|
2740
2869
|
tempOrder.table_form_id = resourceState.tableFormId;
|
|
2741
|
-
tempOrder.resource_id =
|
|
2742
|
-
(_this$store$
|
|
2870
|
+
tempOrder.resource_id = normalizedResourceId;
|
|
2871
|
+
(_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || _this$store$order6.persistTempOrder();
|
|
2743
2872
|
|
|
2744
2873
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
2745
2874
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
2746
|
-
|
|
2875
|
+
_context37.next = 65;
|
|
2747
2876
|
break;
|
|
2748
2877
|
}
|
|
2749
|
-
|
|
2878
|
+
_context37.next = 65;
|
|
2750
2879
|
return this.addNewOrder();
|
|
2751
|
-
case
|
|
2880
|
+
case 65:
|
|
2752
2881
|
// 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
|
|
2753
2882
|
if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
|
|
2754
2883
|
tempOrder.order_id = resourceState.lastOrderId;
|
|
2755
2884
|
}
|
|
2756
2885
|
if (!tempOrder.order_id) {
|
|
2757
|
-
|
|
2886
|
+
_context37.next = 74;
|
|
2758
2887
|
break;
|
|
2759
2888
|
}
|
|
2760
|
-
|
|
2761
|
-
return (_this$store$
|
|
2762
|
-
case
|
|
2763
|
-
res =
|
|
2889
|
+
_context37.next = 69;
|
|
2890
|
+
return (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getOrderInfoByRemote(tempOrder.order_id);
|
|
2891
|
+
case 69:
|
|
2892
|
+
res = _context37.sent;
|
|
2764
2893
|
// 找到下单的时候输入的 entryPaxNumber
|
|
2765
2894
|
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
2895
|
var _p$metadata;
|
|
2767
2896
|
return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
|
|
2768
2897
|
})) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
|
|
2769
2898
|
if (!entryPaxNumber) {
|
|
2770
|
-
|
|
2899
|
+
_context37.next = 74;
|
|
2771
2900
|
break;
|
|
2772
2901
|
}
|
|
2773
|
-
|
|
2902
|
+
_context37.next = 74;
|
|
2774
2903
|
return this.setEntryPaxNumber(entryPaxNumber);
|
|
2775
|
-
case
|
|
2776
|
-
lastOrderInfo = (_this$store$
|
|
2904
|
+
case 74:
|
|
2905
|
+
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);
|
|
2777
2906
|
historicalItems = hasOrderId && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
|
|
2778
2907
|
if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
|
|
2779
2908
|
acc.push(_objectSpread({
|
|
@@ -2784,13 +2913,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2784
2913
|
} : {}));
|
|
2785
2914
|
return acc;
|
|
2786
2915
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
2787
|
-
|
|
2916
|
+
_context37.next = 78;
|
|
2788
2917
|
return this.setItemRuleRuntimeConfig({
|
|
2789
|
-
serviceType: (_this$
|
|
2918
|
+
serviceType: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode,
|
|
2790
2919
|
submissionIndex: hasOrderId ? 1 : 0,
|
|
2791
2920
|
historicalItems: historicalItems
|
|
2792
2921
|
});
|
|
2793
|
-
case
|
|
2922
|
+
case 78:
|
|
2794
2923
|
// operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
|
|
2795
2924
|
// 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
|
|
2796
2925
|
if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
|
|
@@ -2799,7 +2928,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2799
2928
|
availabilityInfo.closed_behavior = closedBehaviorValue;
|
|
2800
2929
|
}
|
|
2801
2930
|
this.logMethodSuccess('checkResourceAvailable', {
|
|
2802
|
-
resourceId:
|
|
2931
|
+
resourceId: normalizedResourceId,
|
|
2803
2932
|
mode: availabilityInfo.mode,
|
|
2804
2933
|
orderId: availabilityInfo.order_id,
|
|
2805
2934
|
relationId: availabilityInfo.relation_id,
|
|
@@ -2811,21 +2940,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2811
2940
|
isExclusive: resourceState.isExclusive,
|
|
2812
2941
|
isFull: resourceState.isFull
|
|
2813
2942
|
});
|
|
2814
|
-
return
|
|
2815
|
-
case
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
this.logMethodError('checkResourceAvailable',
|
|
2819
|
-
resourceId:
|
|
2943
|
+
return _context37.abrupt("return", availabilityInfo);
|
|
2944
|
+
case 83:
|
|
2945
|
+
_context37.prev = 83;
|
|
2946
|
+
_context37.t0 = _context37["catch"](3);
|
|
2947
|
+
this.logMethodError('checkResourceAvailable', _context37.t0.message, {
|
|
2948
|
+
resourceId: normalizedResourceId
|
|
2820
2949
|
});
|
|
2821
|
-
throw
|
|
2822
|
-
case
|
|
2950
|
+
throw _context37.t0;
|
|
2951
|
+
case 87:
|
|
2823
2952
|
case "end":
|
|
2824
|
-
return
|
|
2953
|
+
return _context37.stop();
|
|
2825
2954
|
}
|
|
2826
|
-
},
|
|
2955
|
+
}, _callee37, this, [[3, 83]]);
|
|
2827
2956
|
}));
|
|
2828
|
-
function checkResourceAvailable(
|
|
2957
|
+
function checkResourceAvailable(_x19) {
|
|
2829
2958
|
return _checkResourceAvailable.apply(this, arguments);
|
|
2830
2959
|
}
|
|
2831
2960
|
return checkResourceAvailable;
|
|
@@ -2833,10 +2962,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2833
2962
|
}, {
|
|
2834
2963
|
key: "getAdditionalOrderInfo",
|
|
2835
2964
|
value: function () {
|
|
2836
|
-
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2965
|
+
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
2837
2966
|
var result;
|
|
2838
|
-
return _regeneratorRuntime().wrap(function
|
|
2839
|
-
while (1) switch (
|
|
2967
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
2968
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
2840
2969
|
case 0:
|
|
2841
2970
|
this.logMethodStart('getAdditionalOrderInfo');
|
|
2842
2971
|
result = {
|
|
@@ -2850,12 +2979,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2850
2979
|
orderId: result.orderId,
|
|
2851
2980
|
orderStatus: result.orderStatus
|
|
2852
2981
|
});
|
|
2853
|
-
return
|
|
2982
|
+
return _context38.abrupt("return", result);
|
|
2854
2983
|
case 4:
|
|
2855
2984
|
case "end":
|
|
2856
|
-
return
|
|
2985
|
+
return _context38.stop();
|
|
2857
2986
|
}
|
|
2858
|
-
},
|
|
2987
|
+
}, _callee38, this);
|
|
2859
2988
|
}));
|
|
2860
2989
|
function getAdditionalOrderInfo() {
|
|
2861
2990
|
return _getAdditionalOrderInfo.apply(this, arguments);
|
|
@@ -2865,25 +2994,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2865
2994
|
}, {
|
|
2866
2995
|
key: "getProductList",
|
|
2867
2996
|
value: function () {
|
|
2868
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2869
|
-
var _this$
|
|
2997
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
2998
|
+
var _this$otherParams16;
|
|
2870
2999
|
var menu_list_ids, res, productList, formattedRes;
|
|
2871
|
-
return _regeneratorRuntime().wrap(function
|
|
2872
|
-
while (1) switch (
|
|
3000
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3001
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
2873
3002
|
case 0:
|
|
2874
3003
|
this.logMethodStart('getProductList');
|
|
2875
3004
|
// 可以直接通过配置里的 menu 读取
|
|
2876
|
-
menu_list_ids = ((_this$
|
|
3005
|
+
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
3006
|
return Number(n.value);
|
|
2878
3007
|
})) || [];
|
|
2879
|
-
|
|
3008
|
+
_context39.prev = 2;
|
|
2880
3009
|
if (this.store.products) {
|
|
2881
|
-
|
|
3010
|
+
_context39.next = 5;
|
|
2882
3011
|
break;
|
|
2883
3012
|
}
|
|
2884
3013
|
throw new Error('products 模块未初始化');
|
|
2885
3014
|
case 5:
|
|
2886
|
-
|
|
3015
|
+
_context39.next = 7;
|
|
2887
3016
|
return this.store.products.loadProducts({
|
|
2888
3017
|
menu_list_ids: menu_list_ids,
|
|
2889
3018
|
cacheId: this.cacheId,
|
|
@@ -2891,7 +3020,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2891
3020
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
2892
3021
|
});
|
|
2893
3022
|
case 7:
|
|
2894
|
-
res =
|
|
3023
|
+
res = _context39.sent;
|
|
2895
3024
|
productList = this.assertProductListLoaded('getProductList', res, {
|
|
2896
3025
|
menu_list_ids: menu_list_ids,
|
|
2897
3026
|
cacheId: this.cacheId
|
|
@@ -2900,22 +3029,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2900
3029
|
this.logMethodSuccess('getProductList', {
|
|
2901
3030
|
menuCount: menu_list_ids.length
|
|
2902
3031
|
});
|
|
2903
|
-
return
|
|
3032
|
+
return _context39.abrupt("return", formattedRes);
|
|
2904
3033
|
case 14:
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
if (!(
|
|
2908
|
-
this.logMethodError('getProductList',
|
|
3034
|
+
_context39.prev = 14;
|
|
3035
|
+
_context39.t0 = _context39["catch"](2);
|
|
3036
|
+
if (!(_context39.t0 !== null && _context39.t0 !== void 0 && _context39.t0.__scanOrderLogged)) {
|
|
3037
|
+
this.logMethodError('getProductList', _context39.t0, {
|
|
2909
3038
|
menu_list_ids: menu_list_ids,
|
|
2910
3039
|
cacheId: this.cacheId
|
|
2911
3040
|
});
|
|
2912
3041
|
}
|
|
2913
|
-
throw
|
|
3042
|
+
throw _context39.t0;
|
|
2914
3043
|
case 18:
|
|
2915
3044
|
case "end":
|
|
2916
|
-
return
|
|
3045
|
+
return _context39.stop();
|
|
2917
3046
|
}
|
|
2918
|
-
},
|
|
3047
|
+
}, _callee39, this, [[2, 14]]);
|
|
2919
3048
|
}));
|
|
2920
3049
|
function getProductList() {
|
|
2921
3050
|
return _getProductList.apply(this, arguments);
|
|
@@ -2930,15 +3059,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2930
3059
|
}, {
|
|
2931
3060
|
key: "setOtherParams",
|
|
2932
3061
|
value: function () {
|
|
2933
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2934
|
-
var
|
|
2935
|
-
|
|
3062
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
3063
|
+
var _ref9,
|
|
3064
|
+
_ref9$cover,
|
|
2936
3065
|
cover,
|
|
2937
|
-
|
|
2938
|
-
return _regeneratorRuntime().wrap(function
|
|
2939
|
-
while (1) switch (
|
|
3066
|
+
_args40 = arguments;
|
|
3067
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3068
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
2940
3069
|
case 0:
|
|
2941
|
-
|
|
3070
|
+
_ref9 = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {}, _ref9$cover = _ref9.cover, cover = _ref9$cover === void 0 ? false : _ref9$cover;
|
|
2942
3071
|
if (cover) {
|
|
2943
3072
|
this.otherParams = params;
|
|
2944
3073
|
} else {
|
|
@@ -2946,9 +3075,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2946
3075
|
}
|
|
2947
3076
|
case 2:
|
|
2948
3077
|
case "end":
|
|
2949
|
-
return
|
|
3078
|
+
return _context40.stop();
|
|
2950
3079
|
}
|
|
2951
|
-
},
|
|
3080
|
+
}, _callee40, this);
|
|
2952
3081
|
}));
|
|
2953
3082
|
function setOtherParams(_x20) {
|
|
2954
3083
|
return _setOtherParams.apply(this, arguments);
|
|
@@ -3040,10 +3169,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3040
3169
|
}, {
|
|
3041
3170
|
key: "setEntryPaxNumber",
|
|
3042
3171
|
value: function () {
|
|
3043
|
-
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3172
|
+
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(number) {
|
|
3044
3173
|
var pax, t;
|
|
3045
|
-
return _regeneratorRuntime().wrap(function
|
|
3046
|
-
while (1) switch (
|
|
3174
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3175
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3047
3176
|
case 0:
|
|
3048
3177
|
pax = normalizeSubmitCollectPaxValue(number);
|
|
3049
3178
|
this.store.entryPaxNumber = pax;
|
|
@@ -3064,16 +3193,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3064
3193
|
}
|
|
3065
3194
|
});
|
|
3066
3195
|
this.itemRulePrefillApplied = false;
|
|
3067
|
-
|
|
3196
|
+
_context41.next = 7;
|
|
3068
3197
|
return this.refreshItemRuleQuantityLimits();
|
|
3069
3198
|
case 7:
|
|
3070
|
-
|
|
3199
|
+
_context41.next = 9;
|
|
3071
3200
|
return this.refreshCartValidationPassed();
|
|
3072
3201
|
case 9:
|
|
3073
3202
|
case "end":
|
|
3074
|
-
return
|
|
3203
|
+
return _context41.stop();
|
|
3075
3204
|
}
|
|
3076
|
-
},
|
|
3205
|
+
}, _callee41, this);
|
|
3077
3206
|
}));
|
|
3078
3207
|
function setEntryPaxNumber(_x21) {
|
|
3079
3208
|
return _setEntryPaxNumber.apply(this, arguments);
|
|
@@ -3091,9 +3220,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3091
3220
|
}, {
|
|
3092
3221
|
key: "getFulfillmentModes",
|
|
3093
3222
|
value: function getFulfillmentModes() {
|
|
3094
|
-
var _this$
|
|
3223
|
+
var _this$otherParams17;
|
|
3095
3224
|
this.logMethodStart('getFulfillmentModes');
|
|
3096
|
-
var dineInConfig = ((_this$
|
|
3225
|
+
var dineInConfig = ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.dineInConfig) || {};
|
|
3097
3226
|
var result = {
|
|
3098
3227
|
enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
|
|
3099
3228
|
enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
|
|
@@ -3107,9 +3236,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3107
3236
|
}, {
|
|
3108
3237
|
key: "checkManualPickupRef",
|
|
3109
3238
|
value: function checkManualPickupRef() {
|
|
3110
|
-
var _this$
|
|
3239
|
+
var _this$otherParams18;
|
|
3111
3240
|
this.logMethodStart('checkManualPickupRef');
|
|
3112
|
-
var dineInConfig = ((_this$
|
|
3241
|
+
var dineInConfig = ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.dineInConfig) || {};
|
|
3113
3242
|
var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
|
|
3114
3243
|
var manualInputType = dineInConfig['fulfillment.manual_input_type'];
|
|
3115
3244
|
var enabled = refMode === 'manual_input';
|