@pisell/pisellos 0.10.88 → 0.10.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
- package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
- package/dist/modules/BookingContext/utils/index.d.ts +1 -0
- package/dist/modules/BookingContext/utils/index.js +1 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/dist/modules/BookingContext/utils/productExtend.js +132 -33
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +60 -14
- package/dist/modules/Date/types.d.ts +5 -0
- package/dist/modules/OpenData/salesSettings.js +1 -1
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/modules/OpenData/utils.d.ts +1 -1
- package/dist/modules/OpenData/utils.js +3 -2
- package/dist/modules/Order/index.d.ts +22 -7
- package/dist/modules/Order/index.js +1565 -1161
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/types.d.ts +33 -11
- package/dist/modules/Order/types.js +2 -2
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +185 -129
- package/dist/modules/Payment/walletpass.js +32 -6
- package/dist/modules/Product/types.d.ts +16 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +383 -24
- package/dist/modules/ResourcePlanner/types.d.ts +42 -0
- package/dist/modules/Rules/index.js +86 -54
- package/dist/modules/Schedule/index.d.ts +7 -1
- package/dist/modules/Schedule/index.js +155 -39
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/bookingReadValidation.d.ts +6 -0
- package/dist/modules/bookingReadValidation.js +72 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +1928 -1462
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +21 -0
- package/dist/server/modules/order/index.js +1399 -831
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/order/utils/filterOrders.js +20 -0
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1295 -769
- package/dist/server/modules/products/replication.d.ts +8 -0
- package/dist/server/modules/products/replication.js +69 -0
- package/dist/server/modules/products/types.d.ts +12 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/dist/shared/receipt/small-ticket.d.ts +1 -0
- package/dist/shared/receipt/small-ticket.js +58 -26
- package/dist/shared/receipt/templateVisibility.d.ts +3 -0
- package/dist/shared/receipt/templateVisibility.js +6 -2
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +22 -6
- package/dist/solution/BaseSales/index.js +1881 -1347
- package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/dist/solution/BaseSales/pickupTiming.js +35 -8
- package/dist/solution/BaseSales/types.d.ts +4 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +19 -3
- package/dist/solution/BookingByStep/index.js +681 -361
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.d.ts +6 -0
- package/dist/solution/BookingTicket/index.js +666 -593
- package/dist/solution/BookingTicket/types.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +7 -7
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
- package/dist/solution/OrderInvoicePreview/index.js +4 -3
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +230 -97
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
- package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
- package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
- package/lib/modules/BookingContext/utils/index.d.ts +1 -0
- package/lib/modules/BookingContext/utils/index.js +11 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/lib/modules/BookingContext/utils/productExtend.js +104 -5
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +28 -5
- package/lib/modules/Date/types.d.ts +5 -0
- package/lib/modules/OpenData/salesSettings.js +1 -1
- package/lib/modules/OpenData/types.d.ts +9 -0
- package/lib/modules/OpenData/utils.d.ts +1 -1
- package/lib/modules/OpenData/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +22 -7
- package/lib/modules/Order/index.js +457 -174
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/types.d.ts +33 -11
- package/lib/modules/Order/types.js +2 -2
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils.d.ts +4 -1
- package/lib/modules/Order/utils.js +51 -3
- package/lib/modules/Payment/walletpass.js +23 -1
- package/lib/modules/Product/types.d.ts +16 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +299 -9
- package/lib/modules/ResourcePlanner/types.d.ts +42 -0
- package/lib/modules/Rules/index.js +32 -3
- package/lib/modules/Schedule/index.d.ts +7 -1
- package/lib/modules/Schedule/index.js +68 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/bookingReadValidation.d.ts +6 -0
- package/lib/modules/bookingReadValidation.js +56 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.js +279 -30
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +21 -0
- package/lib/server/modules/order/index.js +344 -35
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/order/utils/filterOrders.js +18 -0
- package/lib/server/modules/products/index.d.ts +28 -7
- package/lib/server/modules/products/index.js +224 -62
- package/lib/server/modules/products/replication.d.ts +8 -0
- package/lib/server/modules/products/replication.js +30 -0
- package/lib/server/modules/products/types.d.ts +12 -1
- package/lib/server/modules/products/types.js +3 -0
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/lib/shared/receipt/small-ticket.d.ts +1 -0
- package/lib/shared/receipt/small-ticket.js +53 -25
- package/lib/shared/receipt/templateVisibility.d.ts +3 -0
- package/lib/shared/receipt/templateVisibility.js +6 -2
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +22 -6
- package/lib/solution/BaseSales/index.js +347 -59
- package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/lib/solution/BaseSales/pickupTiming.js +24 -3
- package/lib/solution/BaseSales/types.d.ts +4 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +19 -3
- package/lib/solution/BookingByStep/index.js +229 -17
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.d.ts +6 -0
- package/lib/solution/BookingTicket/index.js +40 -5
- package/lib/solution/BookingTicket/types.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +7 -7
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
- package/lib/solution/OrderInvoicePreview/index.js +1 -0
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +131 -22
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/lib/solution/UnifiedBookingSales/index.js +717 -144
- package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
- package/lib/utils/pos-receipt-auto-print.js +13 -0
- package/package.json +1 -1
|
@@ -36,9 +36,10 @@ import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleB
|
|
|
36
36
|
import { writeHostLog } from "../../utils/hostLogger";
|
|
37
37
|
import { ProductList } from "../../modules/ProductList";
|
|
38
38
|
import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
|
|
39
|
-
import { composeLinePrice, buildSubmitPayload, createUuidV4, getProductSkuOptions, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
39
|
+
import { composeLinePrice, buildSubmitPayload, createUuidV4, getProductSkuOptions, normalizeSubmitBooking, normalizeSubmitCollectPaxValue, resolveTableOccupancyDuration, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
40
40
|
import dayjs from 'dayjs';
|
|
41
41
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
42
|
+
import { prepareScanOrderMenuAvailability, ScanOrderMenuAvailabilityError } from "./menuAvailability";
|
|
42
43
|
export * from "./types";
|
|
43
44
|
function isItemRewardProductDiscount(discount) {
|
|
44
45
|
var _discount$metadata, _discount$metadata2;
|
|
@@ -1321,6 +1322,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1321
1322
|
}
|
|
1322
1323
|
return prepareRetailAvailability;
|
|
1323
1324
|
}() // ScanOrder 提交 payload enhancer:
|
|
1325
|
+
// - 新单有桌台上下文但无 booking 时,补建基础预约(通用 Order 已不再自动生成)
|
|
1324
1326
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
1325
1327
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
1326
1328
|
// - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
|
|
@@ -1347,7 +1349,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1347
1349
|
return function (payload, _ref3) {
|
|
1348
1350
|
var _resourceState$relati, _tempOrder$metadata, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati2, _pickFirstCustomCapac;
|
|
1349
1351
|
var bookingUuid = _ref3.bookingUuid,
|
|
1350
|
-
tempOrder = _ref3.tempOrder
|
|
1352
|
+
tempOrder = _ref3.tempOrder,
|
|
1353
|
+
now = _ref3.now;
|
|
1351
1354
|
var resourceId = String((_resourceState$relati = resourceState === null || resourceState === void 0 ? void 0 : resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : '').trim();
|
|
1352
1355
|
var hasReservationBookingContext = Boolean(ruleProduct && resourceState && resourceId && resourceState.relationId && resourceState.tableFormId);
|
|
1353
1356
|
if (!hasReservationBookingContext) {
|
|
@@ -1382,7 +1385,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1382
1385
|
} : undefined;
|
|
1383
1386
|
var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
|
|
1384
1387
|
var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
|
|
1385
|
-
var
|
|
1388
|
+
var bookings = payload.bookings || [];
|
|
1389
|
+
if (!tempOrder.order_id && bookings.length === 0) {
|
|
1390
|
+
var bookingStart = dayjs(now);
|
|
1391
|
+
var bookingDuration = resolveTableOccupancyDuration(tempOrder);
|
|
1392
|
+
var bookingEnd = bookingStart.add(bookingDuration, 'minute');
|
|
1393
|
+
bookings = [normalizeSubmitBooking({
|
|
1394
|
+
relation_id: 0,
|
|
1395
|
+
form_id: 0,
|
|
1396
|
+
start_time: bookingStart.format('HH:mm'),
|
|
1397
|
+
start_date: bookingStart.format('YYYY-MM-DD'),
|
|
1398
|
+
end_time: bookingEnd.format('HH:mm'),
|
|
1399
|
+
end_date: bookingEnd.format('YYYY-MM-DD'),
|
|
1400
|
+
duration: bookingDuration,
|
|
1401
|
+
metadata: {
|
|
1402
|
+
unique_identification_number: bookingUuid
|
|
1403
|
+
},
|
|
1404
|
+
select_date: bookingStart.format('YYYY-MM-DD'),
|
|
1405
|
+
is_all: false,
|
|
1406
|
+
like_status: 'common',
|
|
1407
|
+
schedule_id: 0,
|
|
1408
|
+
relation_type: '',
|
|
1409
|
+
number: 1
|
|
1410
|
+
})];
|
|
1411
|
+
}
|
|
1412
|
+
var nextBookings = bookings.map(function (booking, idx) {
|
|
1386
1413
|
var metadata = _objectSpread({}, booking.metadata || {});
|
|
1387
1414
|
if (hasExplicitCollectPax) {
|
|
1388
1415
|
metadata.collect_pax = normalizeSubmitCollectPaxValue(rawCollectPax);
|
|
@@ -1517,12 +1544,47 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1517
1544
|
return _submitScanOrderMore.apply(this, arguments);
|
|
1518
1545
|
}
|
|
1519
1546
|
return submitScanOrderMore;
|
|
1520
|
-
}()
|
|
1547
|
+
}() /** Read both current and legacy cart snapshots without changing the product catalog. */
|
|
1548
|
+
}, {
|
|
1549
|
+
key: "getMenuAvailabilityProductSources",
|
|
1550
|
+
value: function getMenuAvailabilityProductSources(tempOrder) {
|
|
1551
|
+
var _this$store$products, _this$store$products$;
|
|
1552
|
+
var products = tempOrder.products || [];
|
|
1553
|
+
var sources = _toConsumableArray(this.enabledReservationRuleProducts);
|
|
1554
|
+
var _iterator5 = _createForOfIteratorHelper(products),
|
|
1555
|
+
_step5;
|
|
1556
|
+
try {
|
|
1557
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1558
|
+
var _product$metadata3, _product$metadata4, _tempOrder$_extend;
|
|
1559
|
+
var product = _step5.value;
|
|
1560
|
+
var uid = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number;
|
|
1561
|
+
var origins = [product._origin, (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.origin, uid ? (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.productsByUid) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend[String(uid)]) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.origin : undefined];
|
|
1562
|
+
for (var _i3 = 0, _origins = origins; _i3 < _origins.length; _i3++) {
|
|
1563
|
+
var origin = _origins[_i3];
|
|
1564
|
+
if (origin && _typeof(origin) === 'object' && !Array.isArray(origin)) {
|
|
1565
|
+
sources.push(_objectSpread(_objectSpread({}, origin), {}, {
|
|
1566
|
+
product_id: product.product_id
|
|
1567
|
+
}));
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
} catch (err) {
|
|
1572
|
+
_iterator5.e(err);
|
|
1573
|
+
} finally {
|
|
1574
|
+
_iterator5.f();
|
|
1575
|
+
}
|
|
1576
|
+
var cachedSources = (_this$store$products = this.store.products) === null || _this$store$products === void 0 || (_this$store$products$ = _this$store$products.getRawProductPriceSources) === null || _this$store$products$ === void 0 ? void 0 : _this$store$products$.call(_this$store$products, products.map(function (product) {
|
|
1577
|
+
return Number(product.product_id);
|
|
1578
|
+
}));
|
|
1579
|
+
if (cachedSources) sources.push.apply(sources, _toConsumableArray(cachedSources.values()));
|
|
1580
|
+
return sources;
|
|
1581
|
+
}
|
|
1521
1582
|
}, {
|
|
1522
1583
|
key: "submitScanOrder",
|
|
1523
1584
|
value: function () {
|
|
1524
1585
|
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1525
|
-
var
|
|
1586
|
+
var _this6 = this;
|
|
1587
|
+
var _this$store$resource2, _resource$relationId, _this$otherParams13, _this$getPickupTiming, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, isAdditionalOrder, enhanceBookingPayload, ruleProduct, resource, willAppendRuleProduct, productsToPrepare, associatedMenus, validateMenuAvailability, enhancePayload, result, tempOrder;
|
|
1526
1588
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1527
1589
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1528
1590
|
case 0:
|
|
@@ -1551,44 +1613,102 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1551
1613
|
delete tempOrderForSubmit.table_number;
|
|
1552
1614
|
}
|
|
1553
1615
|
this.store.order.persistTempOrder();
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1616
|
+
isAdditionalOrder = this.isScanOrderMoreMode(tempOrderForSubmit);
|
|
1617
|
+
enhanceBookingPayload = this.buildSubmitPayloadEnhancer();
|
|
1618
|
+
ruleProduct = this.enabledReservationRuleProducts[0];
|
|
1619
|
+
resource = this.store.resource;
|
|
1620
|
+
willAppendRuleProduct = !tempOrderForSubmit.order_id && ruleProduct && String((_resource$relationId = resource === null || resource === void 0 ? void 0 : resource.relationId) !== null && _resource$relationId !== void 0 ? _resource$relationId : '').trim() && (resource === null || resource === void 0 ? void 0 : resource.tableFormId);
|
|
1621
|
+
productsToPrepare = isAdditionalOrder ? tempOrderForSubmit.products.filter(function (product) {
|
|
1622
|
+
var _product$metadata5;
|
|
1623
|
+
return ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.is_rule) !== true;
|
|
1624
|
+
}) : [].concat(_toConsumableArray(tempOrderForSubmit.products), _toConsumableArray(willAppendRuleProduct ? [{
|
|
1625
|
+
product_id: ruleProduct.id,
|
|
1626
|
+
metadata: {
|
|
1627
|
+
is_rule: true
|
|
1628
|
+
}
|
|
1629
|
+
}] : []));
|
|
1630
|
+
associatedMenus = (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 || (_this$otherParams13 = _this$otherParams13.dineInConfig) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13['menu.associated_menus'];
|
|
1631
|
+
if (Array.isArray(associatedMenus)) {
|
|
1632
|
+
_context18.next = 23;
|
|
1633
|
+
break;
|
|
1634
|
+
}
|
|
1635
|
+
throw new ScanOrderMenuAvailabilityError('SCAN_ORDER_MENU_VALIDATION_FAILED');
|
|
1636
|
+
case 23:
|
|
1637
|
+
_context18.next = 25;
|
|
1638
|
+
return prepareScanOrderMenuAvailability({
|
|
1639
|
+
request: this.request,
|
|
1640
|
+
menuIds: associatedMenus.map(function (menu) {
|
|
1641
|
+
return menu === null || menu === void 0 ? void 0 : menu.value;
|
|
1642
|
+
}),
|
|
1643
|
+
timezone: String((_this$getPickupTiming = this.getPickupTimingContextData('timezone')) !== null && _this$getPickupTiming !== void 0 ? _this$getPickupTiming : ''),
|
|
1644
|
+
products: productsToPrepare,
|
|
1645
|
+
productSources: this.getMenuAvailabilityProductSources(tempOrderForSubmit)
|
|
1646
|
+
});
|
|
1647
|
+
case 25:
|
|
1648
|
+
validateMenuAvailability = _context18.sent;
|
|
1649
|
+
enhancePayload = function enhancePayload(payload, context) {
|
|
1650
|
+
var enhancedPayload = enhanceBookingPayload(payload, context);
|
|
1651
|
+
var originalByUid = new Map(context.tempOrder.products.filter(function (product) {
|
|
1652
|
+
var _product$metadata6;
|
|
1653
|
+
return (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.unique_identification_number;
|
|
1654
|
+
}).map(function (product) {
|
|
1655
|
+
return [String(product.metadata.unique_identification_number), product];
|
|
1656
|
+
}));
|
|
1657
|
+
var outgoingProducts = isAdditionalOrder ? filterProductsForScanOrderMore(enhancedPayload.products) : enhancedPayload.products;
|
|
1658
|
+
// Serialization strips the prefill marker. Restore it only on validation
|
|
1659
|
+
// copies, by line UID, so a manually added row of the same product stays checked.
|
|
1660
|
+
var validationProducts = outgoingProducts.map(function (product) {
|
|
1661
|
+
var _product$metadata7, _original$metadata;
|
|
1662
|
+
var uid = (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number;
|
|
1663
|
+
var original = uid ? originalByUid.get(String(uid)) : undefined;
|
|
1664
|
+
return (original === null || original === void 0 || (_original$metadata = original.metadata) === null || _original$metadata === void 0 ? void 0 : _original$metadata.item_rule_prefill) === true ? _objectSpread(_objectSpread({}, product), {}, {
|
|
1665
|
+
metadata: _objectSpread(_objectSpread({}, product.metadata), {}, {
|
|
1666
|
+
item_rule_prefill: true
|
|
1667
|
+
})
|
|
1668
|
+
}) : product;
|
|
1669
|
+
});
|
|
1670
|
+
// Both checkout and add-on build their payload after async quotation. Check
|
|
1671
|
+
// the actual outgoing lines using a fresh clock, never the draft schedule_date.
|
|
1672
|
+
validateMenuAvailability(validationProducts, _this6.getMenuAvailabilityProductSources(context.tempOrder));
|
|
1673
|
+
return enhancedPayload;
|
|
1674
|
+
};
|
|
1675
|
+
if (!isAdditionalOrder) {
|
|
1676
|
+
_context18.next = 33;
|
|
1557
1677
|
break;
|
|
1558
1678
|
}
|
|
1559
|
-
_context18.next =
|
|
1679
|
+
_context18.next = 30;
|
|
1560
1680
|
return this.submitScanOrderMore({
|
|
1561
1681
|
tempOrder: tempOrderForSubmit,
|
|
1562
1682
|
enhancePayload: enhancePayload
|
|
1563
1683
|
});
|
|
1564
|
-
case
|
|
1684
|
+
case 30:
|
|
1565
1685
|
_context18.t0 = _context18.sent;
|
|
1566
|
-
_context18.next =
|
|
1686
|
+
_context18.next = 36;
|
|
1567
1687
|
break;
|
|
1568
|
-
case
|
|
1569
|
-
_context18.next =
|
|
1688
|
+
case 33:
|
|
1689
|
+
_context18.next = 35;
|
|
1570
1690
|
return this.submitSalesOrder({
|
|
1571
1691
|
enhancePayload: enhancePayload
|
|
1572
1692
|
});
|
|
1573
|
-
case
|
|
1693
|
+
case 35:
|
|
1574
1694
|
_context18.t0 = _context18.sent;
|
|
1575
|
-
case
|
|
1695
|
+
case 36:
|
|
1576
1696
|
result = _context18.t0;
|
|
1577
1697
|
tempOrder = this.store.order.getTempOrder();
|
|
1578
1698
|
this.logMethodSuccess('submitScanOrder', {
|
|
1579
1699
|
productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
|
|
1580
1700
|
});
|
|
1581
1701
|
return _context18.abrupt("return", result);
|
|
1582
|
-
case
|
|
1583
|
-
_context18.prev =
|
|
1702
|
+
case 42:
|
|
1703
|
+
_context18.prev = 42;
|
|
1584
1704
|
_context18.t1 = _context18["catch"](1);
|
|
1585
1705
|
this.logMethodError('submitScanOrder', _context18.t1);
|
|
1586
1706
|
throw _context18.t1;
|
|
1587
|
-
case
|
|
1707
|
+
case 46:
|
|
1588
1708
|
case "end":
|
|
1589
1709
|
return _context18.stop();
|
|
1590
1710
|
}
|
|
1591
|
-
}, _callee18, this, [[1,
|
|
1711
|
+
}, _callee18, this, [[1, 42]]);
|
|
1592
1712
|
}));
|
|
1593
1713
|
function submitScanOrder() {
|
|
1594
1714
|
return _submitScanOrder.apply(this, arguments);
|
|
@@ -1956,17 +2076,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1956
2076
|
if (visited.has(value)) return;
|
|
1957
2077
|
visited.add(value);
|
|
1958
2078
|
if (Array.isArray(value)) {
|
|
1959
|
-
var
|
|
1960
|
-
|
|
2079
|
+
var _iterator6 = _createForOfIteratorHelper(value),
|
|
2080
|
+
_step6;
|
|
1961
2081
|
try {
|
|
1962
|
-
for (
|
|
1963
|
-
var item =
|
|
2082
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
2083
|
+
var item = _step6.value;
|
|
1964
2084
|
collectFromValue(item);
|
|
1965
2085
|
}
|
|
1966
2086
|
} catch (err) {
|
|
1967
|
-
|
|
2087
|
+
_iterator6.e(err);
|
|
1968
2088
|
} finally {
|
|
1969
|
-
|
|
2089
|
+
_iterator6.f();
|
|
1970
2090
|
}
|
|
1971
2091
|
return;
|
|
1972
2092
|
}
|
|
@@ -1982,8 +2102,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1982
2102
|
sourceMap.set(key, node);
|
|
1983
2103
|
}
|
|
1984
2104
|
}
|
|
1985
|
-
for (var
|
|
1986
|
-
var childValue = _Object$values[
|
|
2105
|
+
for (var _i4 = 0, _Object$values = Object.values(node); _i4 < _Object$values.length; _i4++) {
|
|
2106
|
+
var childValue = _Object$values[_i4];
|
|
1987
2107
|
if (childValue && _typeof(childValue) === 'object') {
|
|
1988
2108
|
collectFromValue(childValue);
|
|
1989
2109
|
}
|
|
@@ -2012,17 +2132,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2012
2132
|
}, {
|
|
2013
2133
|
key: "getItemRuleRuntimeConfig",
|
|
2014
2134
|
value: function getItemRuleRuntimeConfig() {
|
|
2015
|
-
var _ref7, _runtimeConfig$channe, _runtimeConfig$custom, _this$
|
|
2135
|
+
var _ref7, _runtimeConfig$channe, _runtimeConfig$custom, _this$otherParams14;
|
|
2016
2136
|
var runtimeConfig = this.itemRuleRuntimeConfig || {};
|
|
2017
2137
|
return _objectSpread(_objectSpread({}, runtimeConfig), {}, {
|
|
2018
|
-
channel: (_ref7 = (_runtimeConfig$channe = runtimeConfig.channel) !== null && _runtimeConfig$channe !== void 0 ? _runtimeConfig$channe : (_runtimeConfig$custom = runtimeConfig.custom) === null || _runtimeConfig$custom === void 0 ? void 0 : _runtimeConfig$custom.channel) !== null && _ref7 !== void 0 ? _ref7 : (_this$
|
|
2138
|
+
channel: (_ref7 = (_runtimeConfig$channe = runtimeConfig.channel) !== null && _runtimeConfig$channe !== void 0 ? _runtimeConfig$channe : (_runtimeConfig$custom = runtimeConfig.custom) === null || _runtimeConfig$custom === void 0 ? void 0 : _runtimeConfig$custom.channel) !== null && _ref7 !== void 0 ? _ref7 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.channel
|
|
2019
2139
|
});
|
|
2020
2140
|
}
|
|
2021
2141
|
}, {
|
|
2022
2142
|
key: "ensureItemRuleConfigsLoaded",
|
|
2023
2143
|
value: function () {
|
|
2024
2144
|
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
2025
|
-
var
|
|
2145
|
+
var _this7 = this;
|
|
2026
2146
|
var loadedConfigs;
|
|
2027
2147
|
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2028
2148
|
while (1) switch (_context28.prev = _context28.next) {
|
|
@@ -2044,19 +2164,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2044
2164
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2045
2165
|
while (1) switch (_context27.prev = _context27.next) {
|
|
2046
2166
|
case 0:
|
|
2047
|
-
runtimeConfig =
|
|
2167
|
+
runtimeConfig = _this7.getItemRuleRuntimeConfig();
|
|
2048
2168
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
2049
2169
|
if (!(staticConfigs.length > 0)) {
|
|
2050
2170
|
_context27.next = 6;
|
|
2051
2171
|
break;
|
|
2052
2172
|
}
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
return _context27.abrupt("return",
|
|
2173
|
+
_this7.itemRuleConfigs = staticConfigs;
|
|
2174
|
+
_this7.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
2175
|
+
return _context27.abrupt("return", _this7.itemRuleConfigs);
|
|
2056
2176
|
case 6:
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
return _context27.abrupt("return",
|
|
2177
|
+
_this7.itemRuleConfigs = [];
|
|
2178
|
+
_this7.itemRuleEvaluator.setStrategyConfigs([]);
|
|
2179
|
+
return _context27.abrupt("return", _this7.itemRuleConfigs);
|
|
2060
2180
|
case 9:
|
|
2061
2181
|
case "end":
|
|
2062
2182
|
return _context27.stop();
|
|
@@ -2131,7 +2251,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2131
2251
|
key: "applyPrefillByItemRule",
|
|
2132
2252
|
value: function () {
|
|
2133
2253
|
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2134
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
2254
|
+
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator7, _step7, _prefillItem$product_, _origin2, _origin3, _origin4, prefillItem, productId, productVariantId, targetQuantity, sourceItem, sourceTitle, productTitle, displayFields, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasTitleChanged, hasOriginChanged;
|
|
2135
2255
|
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2136
2256
|
while (1) switch (_context30.prev = _context30.next) {
|
|
2137
2257
|
case 0:
|
|
@@ -2176,15 +2296,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2176
2296
|
productSourceMap = _context30.sent;
|
|
2177
2297
|
tempOrder = this.ensureScanOrderTempOrder();
|
|
2178
2298
|
hasChanges = false;
|
|
2179
|
-
|
|
2299
|
+
_iterator7 = _createForOfIteratorHelper(prefillItems);
|
|
2180
2300
|
_context30.prev = 20;
|
|
2181
|
-
|
|
2301
|
+
_iterator7.s();
|
|
2182
2302
|
case 22:
|
|
2183
|
-
if ((
|
|
2184
|
-
_context30.next =
|
|
2303
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
2304
|
+
_context30.next = 51;
|
|
2185
2305
|
break;
|
|
2186
2306
|
}
|
|
2187
|
-
prefillItem =
|
|
2307
|
+
prefillItem = _step7.value;
|
|
2188
2308
|
productId = Number(prefillItem.product_id);
|
|
2189
2309
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
2190
2310
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
@@ -2192,25 +2312,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2192
2312
|
_context30.next = 29;
|
|
2193
2313
|
break;
|
|
2194
2314
|
}
|
|
2195
|
-
return _context30.abrupt("continue",
|
|
2315
|
+
return _context30.abrupt("continue", 49);
|
|
2196
2316
|
case 29:
|
|
2197
2317
|
if (!Number.isNaN(productVariantId)) {
|
|
2198
2318
|
_context30.next = 31;
|
|
2199
2319
|
break;
|
|
2200
2320
|
}
|
|
2201
|
-
return _context30.abrupt("continue",
|
|
2321
|
+
return _context30.abrupt("continue", 49);
|
|
2202
2322
|
case 31:
|
|
2203
2323
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
2324
|
+
sourceTitle = (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.product_title) || (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.title) || (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.name);
|
|
2325
|
+
productTitle = typeof sourceTitle === 'string' ? {
|
|
2326
|
+
auto: sourceTitle
|
|
2327
|
+
} : sourceTitle; // 标准标题在归一化后补入,供购物车展示,并由 Order 在折扣重算时保留。
|
|
2328
|
+
displayFields = productTitle ? {
|
|
2329
|
+
product_title: productTitle
|
|
2330
|
+
} : {};
|
|
2204
2331
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
2205
2332
|
product_id: productId,
|
|
2206
2333
|
product_variant_id: productVariantId
|
|
2207
2334
|
});
|
|
2208
2335
|
if (!(productIndex === -1)) {
|
|
2209
|
-
_context30.next =
|
|
2336
|
+
_context30.next = 41;
|
|
2210
2337
|
break;
|
|
2211
2338
|
}
|
|
2212
2339
|
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');
|
|
2213
|
-
tempOrder.products.push(normalizeOrderProduct(_objectSpread(_objectSpread({}, sourceItem), {}, {
|
|
2340
|
+
tempOrder.products.push(_objectSpread(_objectSpread({}, normalizeOrderProduct(_objectSpread(_objectSpread({}, sourceItem), {}, {
|
|
2214
2341
|
product_id: productId,
|
|
2215
2342
|
product_variant_id: productVariantId,
|
|
2216
2343
|
num: targetQuantity,
|
|
@@ -2224,14 +2351,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2224
2351
|
item_rule_prefill: true,
|
|
2225
2352
|
item_rule_id: prefillItem.ruleId
|
|
2226
2353
|
})
|
|
2227
|
-
})));
|
|
2354
|
+
}))), displayFields));
|
|
2228
2355
|
hasChanges = true;
|
|
2229
|
-
return _context30.abrupt("continue",
|
|
2230
|
-
case
|
|
2356
|
+
return _context30.abrupt("continue", 49);
|
|
2357
|
+
case 41:
|
|
2231
2358
|
targetProduct = tempOrder.products[productIndex];
|
|
2232
2359
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
2233
2360
|
delta = targetQuantity - existedQuantity;
|
|
2234
|
-
nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), delta > 0 ? {
|
|
2361
|
+
nextProduct = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, targetProduct), displayFields), delta > 0 ? {
|
|
2235
2362
|
num: getSafeProductNum(existedQuantity + delta)
|
|
2236
2363
|
} : {}), {}, {
|
|
2237
2364
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
@@ -2241,52 +2368,53 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2241
2368
|
_origin: sourceItem ? _objectSpread(_objectSpread({}, targetProduct._origin || {}), sourceItem) : targetProduct._origin
|
|
2242
2369
|
});
|
|
2243
2370
|
hasQuantityChanged = delta > 0;
|
|
2371
|
+
hasTitleChanged = Boolean(productTitle && JSON.stringify(targetProduct.product_title) !== JSON.stringify(productTitle));
|
|
2244
2372
|
hasOriginChanged = Boolean(sourceItem && (!targetProduct._origin || ((_origin2 = targetProduct._origin) === null || _origin2 === void 0 ? void 0 : _origin2.name) !== (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.name) || ((_origin3 = targetProduct._origin) === null || _origin3 === void 0 ? void 0 : _origin3.title) !== (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.title) || ((_origin4 = targetProduct._origin) === null || _origin4 === void 0 ? void 0 : _origin4.price) !== (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price)));
|
|
2245
|
-
if (hasQuantityChanged || hasOriginChanged) {
|
|
2373
|
+
if (hasQuantityChanged || hasTitleChanged || hasOriginChanged) {
|
|
2246
2374
|
tempOrder.products[productIndex] = nextProduct;
|
|
2247
2375
|
hasChanges = true;
|
|
2248
2376
|
}
|
|
2249
|
-
case
|
|
2377
|
+
case 49:
|
|
2250
2378
|
_context30.next = 22;
|
|
2251
2379
|
break;
|
|
2252
|
-
case
|
|
2253
|
-
_context30.next =
|
|
2380
|
+
case 51:
|
|
2381
|
+
_context30.next = 56;
|
|
2254
2382
|
break;
|
|
2255
|
-
case
|
|
2256
|
-
_context30.prev =
|
|
2383
|
+
case 53:
|
|
2384
|
+
_context30.prev = 53;
|
|
2257
2385
|
_context30.t0 = _context30["catch"](20);
|
|
2258
|
-
|
|
2259
|
-
case
|
|
2260
|
-
_context30.prev =
|
|
2261
|
-
|
|
2262
|
-
return _context30.finish(
|
|
2263
|
-
case
|
|
2386
|
+
_iterator7.e(_context30.t0);
|
|
2387
|
+
case 56:
|
|
2388
|
+
_context30.prev = 56;
|
|
2389
|
+
_iterator7.f();
|
|
2390
|
+
return _context30.finish(56);
|
|
2391
|
+
case 59:
|
|
2264
2392
|
if (!hasChanges) {
|
|
2265
|
-
_context30.next =
|
|
2393
|
+
_context30.next = 64;
|
|
2266
2394
|
break;
|
|
2267
2395
|
}
|
|
2268
2396
|
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
2269
2397
|
this.store.order.applyDiscount();
|
|
2270
|
-
_context30.next =
|
|
2398
|
+
_context30.next = 63;
|
|
2271
2399
|
return this.store.order.recalculateSummary({
|
|
2272
2400
|
createIfMissing: true
|
|
2273
2401
|
});
|
|
2274
|
-
case
|
|
2402
|
+
case 63:
|
|
2275
2403
|
this.store.order.persistTempOrder();
|
|
2276
|
-
case
|
|
2277
|
-
_context30.next =
|
|
2404
|
+
case 64:
|
|
2405
|
+
_context30.next = 66;
|
|
2278
2406
|
return this.refreshItemRuleQuantityLimits();
|
|
2279
|
-
case
|
|
2407
|
+
case 66:
|
|
2280
2408
|
this.itemRulePrefillApplied = true;
|
|
2281
2409
|
this.logMethodSuccess('applyPrefillByItemRule', {
|
|
2282
2410
|
prefillCount: prefillItems.length,
|
|
2283
2411
|
hasChanges: hasChanges
|
|
2284
2412
|
});
|
|
2285
|
-
case
|
|
2413
|
+
case 68:
|
|
2286
2414
|
case "end":
|
|
2287
2415
|
return _context30.stop();
|
|
2288
2416
|
}
|
|
2289
|
-
}, _callee30, this, [[20,
|
|
2417
|
+
}, _callee30, this, [[20, 53, 56, 59]]);
|
|
2290
2418
|
}));
|
|
2291
2419
|
function applyPrefillByItemRule() {
|
|
2292
2420
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -2503,14 +2631,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2503
2631
|
}, {
|
|
2504
2632
|
key: "normalizeResourceState",
|
|
2505
2633
|
value: function normalizeResourceState(detail, resourceSelectType, hasOrderId) {
|
|
2506
|
-
var _detail$form_record, _this$
|
|
2634
|
+
var _detail$form_record, _this$otherParams15, _detail$resource_capa, _detail$resource_capa2;
|
|
2507
2635
|
var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
|
|
2508
2636
|
var lastOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.last_order_id);
|
|
2509
2637
|
var relationId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_record_id);
|
|
2510
2638
|
var tableFormId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_id);
|
|
2511
2639
|
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;
|
|
2512
2640
|
// 是否允许加餐
|
|
2513
|
-
var allowSnack = ((_this$
|
|
2641
|
+
var allowSnack = ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 || (_this$otherParams15 = _this$otherParams15.dineInConfig) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15['sale.allow_add_items']) || false;
|
|
2514
2642
|
// 开启同桌验证 - 本期没有这个配置,默认关掉
|
|
2515
2643
|
var deskmateValid = false;
|
|
2516
2644
|
var isExclusive = resourceSelectType === 'single';
|
|
@@ -2593,7 +2721,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2593
2721
|
key: "fetchResourceOccupyDetailsByResourceId",
|
|
2594
2722
|
value: function () {
|
|
2595
2723
|
var _fetchResourceOccupyDetailsByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId) {
|
|
2596
|
-
var _this$
|
|
2724
|
+
var _this$otherParams16, _this$otherParams16$g, _response$data$occupy, _response$data;
|
|
2597
2725
|
var formRecordId, shopId, response;
|
|
2598
2726
|
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2599
2727
|
while (1) switch (_context36.prev = _context36.next) {
|
|
@@ -2605,7 +2733,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2605
2733
|
}
|
|
2606
2734
|
throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
|
|
2607
2735
|
case 3:
|
|
2608
|
-
shopId = (_this$
|
|
2736
|
+
shopId = (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 || (_this$otherParams16$g = _this$otherParams16.getStateData) === null || _this$otherParams16$g === void 0 ? void 0 : _this$otherParams16$g.call(_this$otherParams16, 'shop_id');
|
|
2609
2737
|
if (shopId) {
|
|
2610
2738
|
_context36.next = 6;
|
|
2611
2739
|
break;
|
|
@@ -2699,18 +2827,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2699
2827
|
var hasOrderId,
|
|
2700
2828
|
normalizedResourceId,
|
|
2701
2829
|
_this$otherParams$bus,
|
|
2702
|
-
_this$otherParams16,
|
|
2703
|
-
_this$otherParams$cha,
|
|
2704
2830
|
_this$otherParams17,
|
|
2831
|
+
_this$otherParams$cha,
|
|
2705
2832
|
_this$otherParams18,
|
|
2706
|
-
_this$
|
|
2833
|
+
_this$otherParams19,
|
|
2834
|
+
_this$otherParams19$g,
|
|
2707
2835
|
_occupyDetails$,
|
|
2708
2836
|
_occupyDetail$form_re,
|
|
2709
2837
|
_occupyDetail$form_re2,
|
|
2710
2838
|
_this$store$order6,
|
|
2711
2839
|
_this$store$order7,
|
|
2712
2840
|
_this$store$order7$ge,
|
|
2713
|
-
_this$
|
|
2841
|
+
_this$otherParams20,
|
|
2714
2842
|
_this$store$resource3,
|
|
2715
2843
|
_this$store$resource4,
|
|
2716
2844
|
businessCode,
|
|
@@ -2764,11 +2892,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2764
2892
|
resourceId: normalizedResourceId
|
|
2765
2893
|
});
|
|
2766
2894
|
_context37.prev = 3;
|
|
2767
|
-
businessCode = String((_this$otherParams$bus = (_this$
|
|
2768
|
-
channel = String((_this$otherParams$cha = (_this$
|
|
2895
|
+
businessCode = String((_this$otherParams$bus = (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : '').trim();
|
|
2896
|
+
channel = String((_this$otherParams$cha = (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
|
|
2769
2897
|
openDataTarget = businessCode && channel ? "".concat(businessCode, "+").concat(channel) : 'dine_in+scan_to_order';
|
|
2770
2898
|
_context37.next = 9;
|
|
2771
|
-
return (_this$
|
|
2899
|
+
return (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 || (_this$otherParams19$g = _this$otherParams19.getOpenData) === null || _this$otherParams19$g === void 0 ? void 0 : _this$otherParams19$g.call(_this$otherParams19, {
|
|
2772
2900
|
scope: 'board',
|
|
2773
2901
|
target: openDataTarget,
|
|
2774
2902
|
section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
|
|
@@ -2997,7 +3125,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2997
3125
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
2998
3126
|
_context37.next = 84;
|
|
2999
3127
|
return this.setItemRuleRuntimeConfig({
|
|
3000
|
-
serviceType: (_this$
|
|
3128
|
+
serviceType: (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.businessCode,
|
|
3001
3129
|
submissionIndex: isAdditionalOrderMode ? 1 : 0,
|
|
3002
3130
|
historicalItems: historicalItems
|
|
3003
3131
|
});
|
|
@@ -3123,14 +3251,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3123
3251
|
key: "getProductList",
|
|
3124
3252
|
value: function () {
|
|
3125
3253
|
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
|
|
3126
|
-
var _this$
|
|
3254
|
+
var _this$otherParams21;
|
|
3127
3255
|
var associatedMenus, menu_list_ids, res, productList, formattedRes;
|
|
3128
3256
|
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3129
3257
|
while (1) switch (_context40.prev = _context40.next) {
|
|
3130
3258
|
case 0:
|
|
3131
3259
|
this.logMethodStart('getProductList');
|
|
3132
3260
|
// 可以直接通过配置里的 menu 读取
|
|
3133
|
-
associatedMenus = (_this$
|
|
3261
|
+
associatedMenus = (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 || (_this$otherParams21 = _this$otherParams21.dineInConfig) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21['menu.associated_menus'];
|
|
3134
3262
|
menu_list_ids = associatedMenus.map(function (n) {
|
|
3135
3263
|
return Number(n.value);
|
|
3136
3264
|
}) || [];
|
|
@@ -3361,8 +3489,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3361
3489
|
key: "syncAdditionalOrderFromResource",
|
|
3362
3490
|
value: function () {
|
|
3363
3491
|
var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(resourceId) {
|
|
3364
|
-
var _ref10, _ref11, _ref12, _this$store$resource5, _this$store$resource6, _occupyDetails$2, _this$store$resource7, _this$
|
|
3365
|
-
var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result;
|
|
3492
|
+
var _ref10, _ref11, _ref12, _this$store$resource5, _this$store$resource6, _occupyDetails$2, _this$store$resource7, _this$otherParams22, _this$store$resource8, _this$store$order8;
|
|
3493
|
+
var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result, resourceState;
|
|
3366
3494
|
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3367
3495
|
while (1) switch (_context43.prev = _context43.next) {
|
|
3368
3496
|
case 0:
|
|
@@ -3394,7 +3522,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3394
3522
|
occupyDetails = _context43.sent;
|
|
3395
3523
|
occupyDetail = (_occupyDetails$2 = occupyDetails[0]) !== null && _occupyDetails$2 !== void 0 ? _occupyDetails$2 : null;
|
|
3396
3524
|
resourceSelectType = ((_this$store$resource7 = this.store.resource) === null || _this$store$resource7 === void 0 ? void 0 : _this$store$resource7.resourceSelectType) || this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
|
|
3397
|
-
allowAddItems = toBoolean((_this$
|
|
3525
|
+
allowAddItems = toBoolean((_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 || (_this$otherParams22 = _this$otherParams22.dineInConfig) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22['sale.allow_add_items']);
|
|
3398
3526
|
result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
|
|
3399
3527
|
if (!(!result.matched || !result.order_id)) {
|
|
3400
3528
|
_context43.next = 19;
|
|
@@ -3411,6 +3539,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3411
3539
|
tempOrder.resource_id = normalizedResourceId;
|
|
3412
3540
|
tempOrder.relation_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
|
|
3413
3541
|
tempOrder.table_form_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
|
|
3542
|
+
// 冲突后转加餐需同步模式,否则重试仍会携带整单数据走 checkout。
|
|
3543
|
+
resourceState = (_this$store$resource8 = this.store.resource) !== null && _this$store$resource8 !== void 0 ? _this$store$resource8 : this.normalizeResourceState(occupyDetail, resourceSelectType, true);
|
|
3544
|
+
resourceState.mode = 'additional_order';
|
|
3545
|
+
resourceState.order_id = result.order_id;
|
|
3546
|
+
this.store.resource = resourceState;
|
|
3414
3547
|
(_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 || _this$store$order8.persistTempOrder();
|
|
3415
3548
|
this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
|
|
3416
3549
|
resourceId: normalizedResourceId,
|
|
@@ -3418,7 +3551,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3418
3551
|
allowAddItems: allowAddItems
|
|
3419
3552
|
}));
|
|
3420
3553
|
return _context43.abrupt("return", result);
|
|
3421
|
-
case
|
|
3554
|
+
case 30:
|
|
3422
3555
|
case "end":
|
|
3423
3556
|
return _context43.stop();
|
|
3424
3557
|
}
|
|
@@ -3433,9 +3566,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3433
3566
|
}, {
|
|
3434
3567
|
key: "getReservationResourceSelectType",
|
|
3435
3568
|
value: function getReservationResourceSelectType() {
|
|
3436
|
-
var _this$store$
|
|
3569
|
+
var _this$store$resource9;
|
|
3437
3570
|
this.logMethodStart('getReservationResourceSelectType');
|
|
3438
|
-
var resourceSelectType = (_this$store$
|
|
3571
|
+
var resourceSelectType = (_this$store$resource9 = this.store.resource) === null || _this$store$resource9 === void 0 ? void 0 : _this$store$resource9.resourceSelectType;
|
|
3439
3572
|
var result = _objectSpread(_objectSpread({}, resourceSelectType ? {
|
|
3440
3573
|
resourceSelectType: resourceSelectType
|
|
3441
3574
|
} : {}), {}, {
|
|
@@ -3452,9 +3585,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3452
3585
|
}, {
|
|
3453
3586
|
key: "checkAllowAddItems",
|
|
3454
3587
|
value: function checkAllowAddItems() {
|
|
3455
|
-
var _this$
|
|
3588
|
+
var _this$otherParams23;
|
|
3456
3589
|
this.logMethodStart('checkAllowAddItems');
|
|
3457
|
-
var dineInConfig = ((_this$
|
|
3590
|
+
var dineInConfig = ((_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.dineInConfig) || {};
|
|
3458
3591
|
var result = {
|
|
3459
3592
|
enabled: toBoolean(dineInConfig['sale.allow_add_items'])
|
|
3460
3593
|
};
|
|
@@ -3467,9 +3600,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3467
3600
|
}, {
|
|
3468
3601
|
key: "getFulfillmentModes",
|
|
3469
3602
|
value: function getFulfillmentModes() {
|
|
3470
|
-
var _this$
|
|
3603
|
+
var _this$otherParams24;
|
|
3471
3604
|
this.logMethodStart('getFulfillmentModes');
|
|
3472
|
-
var dineInConfig = ((_this$
|
|
3605
|
+
var dineInConfig = ((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.dineInConfig) || {};
|
|
3473
3606
|
var result = {
|
|
3474
3607
|
enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
|
|
3475
3608
|
enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
|
|
@@ -3483,9 +3616,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3483
3616
|
}, {
|
|
3484
3617
|
key: "checkManualPickupRef",
|
|
3485
3618
|
value: function checkManualPickupRef() {
|
|
3486
|
-
var _this$
|
|
3619
|
+
var _this$otherParams25;
|
|
3487
3620
|
this.logMethodStart('checkManualPickupRef');
|
|
3488
|
-
var dineInConfig = ((_this$
|
|
3621
|
+
var dineInConfig = ((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.dineInConfig) || {};
|
|
3489
3622
|
var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
|
|
3490
3623
|
var manualInputType = dineInConfig['fulfillment.manual_input_type'];
|
|
3491
3624
|
var enabled = refMode === 'manual_input';
|