@pisell/pisellos 0.0.554 → 0.0.556
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.
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -1411,13 +1411,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1411
1411
|
var resourceState = this.store.resource;
|
|
1412
1412
|
var resourceSelectType = resourceState === null || resourceState === void 0 ? void 0 : resourceState.resourceSelectType;
|
|
1413
1413
|
|
|
1414
|
-
//
|
|
1415
|
-
var
|
|
1414
|
+
// ScanOrder 的 booking 容量只由预约规则决定:single 占用整张桌台,multiple 占用 1 个容量位。
|
|
1415
|
+
var resolveBookingCapacityValue = function resolveBookingCapacityValue() {
|
|
1416
1416
|
if (resourceSelectType === 'single') {
|
|
1417
1417
|
var _resourceState$table_;
|
|
1418
1418
|
var raw = resourceState === null || resourceState === void 0 || (_resourceState$table_ = resourceState.table_form_record) === null || _resourceState$table_ === void 0 ? void 0 : _resourceState$table_.capacity;
|
|
1419
1419
|
var num = Number(raw);
|
|
1420
|
-
if (Number.isFinite(num) && num > 0) return num;
|
|
1420
|
+
if (Number.isFinite(num) && num > 0) return Math.max(1, Math.floor(num));
|
|
1421
1421
|
return 1;
|
|
1422
1422
|
}
|
|
1423
1423
|
return 1;
|
|
@@ -1435,8 +1435,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1435
1435
|
});
|
|
1436
1436
|
}
|
|
1437
1437
|
var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
|
|
1438
|
-
var
|
|
1439
|
-
var
|
|
1438
|
+
var hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
|
|
1439
|
+
var bookingCapacityValue = resolveBookingCapacityValue();
|
|
1440
1440
|
var pickOriginal = function pickOriginal(value) {
|
|
1441
1441
|
if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
|
|
1442
1442
|
var original = value.original;
|
|
@@ -1452,21 +1452,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1452
1452
|
main_field: mainField,
|
|
1453
1453
|
form_id: resourceState.tableFormId,
|
|
1454
1454
|
relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
|
|
1455
|
-
capacity:
|
|
1455
|
+
capacity: bookingCapacityValue,
|
|
1456
1456
|
metadata: _this5.buildScanOrderResourceMetadata({
|
|
1457
1457
|
resourceState: resourceState,
|
|
1458
1458
|
resourceName: mainField
|
|
1459
1459
|
})
|
|
1460
1460
|
} : undefined;
|
|
1461
1461
|
var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
|
|
1462
|
-
// 有 collect_pax 时 booking/resource capacity 与 number 都代表本次 pax;否则使用资源占用兜底值。
|
|
1463
|
-
var bookingCapacityValue = resourceCapacityValue;
|
|
1464
1462
|
var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
|
|
1465
1463
|
var nextBookings = (payload.bookings || []).map(function (booking, idx) {
|
|
1464
|
+
var metadata = _objectSpread({}, booking.metadata || {});
|
|
1465
|
+
if (hasExplicitCollectPax) {
|
|
1466
|
+
metadata.collect_pax = normalizeSubmitCollectPaxValue(rawCollectPax);
|
|
1467
|
+
} else {
|
|
1468
|
+
delete metadata.collect_pax;
|
|
1469
|
+
}
|
|
1466
1470
|
return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
|
|
1467
1471
|
number: bookingCapacityValue,
|
|
1468
1472
|
appointment_status: 'started',
|
|
1469
|
-
metadata: _objectSpread(_objectSpread(_objectSpread({},
|
|
1473
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, metadata), resourceSelectType ? {
|
|
1470
1474
|
resource_select_type: resourceSelectType
|
|
1471
1475
|
} : {}), resourceSelectType ? {
|
|
1472
1476
|
capacity: [{
|
|
@@ -1516,7 +1520,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1516
1520
|
key: "submitScanOrder",
|
|
1517
1521
|
value: function () {
|
|
1518
1522
|
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1519
|
-
var _this$store$resource, _this$otherParams5, _this$otherParams6, _this$otherParams7, _this$otherParams8, _tempOrder$products,
|
|
1523
|
+
var _this$store$resource, _this$otherParams5, _this$otherParams6, _this$otherParams7, _this$otherParams8, _tempOrder$products, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
|
|
1520
1524
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1521
1525
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1522
1526
|
case 0:
|
|
@@ -1531,12 +1535,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1531
1535
|
}
|
|
1532
1536
|
throw new Error('scanOrder解决方案需要 order 模块支持');
|
|
1533
1537
|
case 6:
|
|
1534
|
-
pax = normalizeSubmitCollectPaxValue(this.store.entryPaxNumber);
|
|
1535
|
-
this.store.entryPaxNumber = pax;
|
|
1536
1538
|
tempOrderForSubmit = this.store.order.ensureTempOrder();
|
|
1537
|
-
tempOrderForSubmit.metadata = _objectSpread(_objectSpread({}, tempOrderForSubmit.metadata), {}, {
|
|
1538
|
-
collect_pax: pax
|
|
1539
|
-
});
|
|
1540
1539
|
tempOrderForSubmit.delivery_type = 'shop_service';
|
|
1541
1540
|
resourceTableName = (_this$store$resource = this.store.resource) === null || _this$store$resource === void 0 || (_this$store$resource = _this$store$resource.table_form_record) === null || _this$store$resource === void 0 ? void 0 : _this$store$resource.name;
|
|
1542
1541
|
if (resourceTableName && _typeof(resourceTableName) === 'object') {
|
|
@@ -1546,7 +1545,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1546
1545
|
}
|
|
1547
1546
|
this.store.order.persistTempOrder();
|
|
1548
1547
|
enhancePayload = this.buildSubmitPayloadEnhancer();
|
|
1549
|
-
_context18.next =
|
|
1548
|
+
_context18.next = 14;
|
|
1550
1549
|
return this.store.order.submitTempOrder({
|
|
1551
1550
|
cacheId: this.cacheId,
|
|
1552
1551
|
platform: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform,
|
|
@@ -1555,23 +1554,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1555
1554
|
type: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.type,
|
|
1556
1555
|
enhancePayload: enhancePayload
|
|
1557
1556
|
});
|
|
1558
|
-
case
|
|
1557
|
+
case 14:
|
|
1559
1558
|
result = _context18.sent;
|
|
1560
1559
|
tempOrder = this.store.order.getTempOrder();
|
|
1561
1560
|
this.logMethodSuccess('submitScanOrder', {
|
|
1562
1561
|
productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
|
|
1563
1562
|
});
|
|
1564
1563
|
return _context18.abrupt("return", result);
|
|
1565
|
-
case
|
|
1566
|
-
_context18.prev =
|
|
1564
|
+
case 20:
|
|
1565
|
+
_context18.prev = 20;
|
|
1567
1566
|
_context18.t0 = _context18["catch"](1);
|
|
1568
1567
|
this.logMethodError('submitScanOrder', _context18.t0);
|
|
1569
1568
|
throw _context18.t0;
|
|
1570
|
-
case
|
|
1569
|
+
case 24:
|
|
1571
1570
|
case "end":
|
|
1572
1571
|
return _context18.stop();
|
|
1573
1572
|
}
|
|
1574
|
-
}, _callee18, this, [[1,
|
|
1573
|
+
}, _callee18, this, [[1, 20]]);
|
|
1575
1574
|
}));
|
|
1576
1575
|
function submitScanOrder() {
|
|
1577
1576
|
return _submitScanOrder.apply(this, arguments);
|
|
@@ -2621,7 +2620,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2621
2620
|
}()
|
|
2622
2621
|
}, {
|
|
2623
2622
|
key: "resolveAdditionalOrderFromOccupyDetail",
|
|
2624
|
-
value: function resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType) {
|
|
2623
|
+
value: function resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
|
|
2625
2624
|
var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
|
|
2626
2625
|
if (currentOrderId) {
|
|
2627
2626
|
return {
|
|
@@ -2629,15 +2628,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2629
2628
|
order_id: currentOrderId
|
|
2630
2629
|
};
|
|
2631
2630
|
}
|
|
2631
|
+
var orderListIds = (Array.isArray(detail === null || detail === void 0 ? void 0 : detail.order_list) ? (detail === null || detail === void 0 ? void 0 : detail.order_list) || [] : []).map(function (order) {
|
|
2632
|
+
return toPositiveString(order === null || order === void 0 ? void 0 : order.id);
|
|
2633
|
+
}).filter(Boolean);
|
|
2632
2634
|
if (resourceSelectType !== 'single') {
|
|
2633
2635
|
return {
|
|
2634
2636
|
matched: false,
|
|
2635
2637
|
reason: 'no_order'
|
|
2636
2638
|
};
|
|
2637
2639
|
}
|
|
2638
|
-
|
|
2639
|
-
return
|
|
2640
|
-
|
|
2640
|
+
if (!orderListIds.length) {
|
|
2641
|
+
return {
|
|
2642
|
+
matched: false,
|
|
2643
|
+
reason: 'no_order'
|
|
2644
|
+
};
|
|
2645
|
+
}
|
|
2646
|
+
if (!allowAddItems) {
|
|
2647
|
+
return {
|
|
2648
|
+
matched: false,
|
|
2649
|
+
reason: 'add_items_disabled'
|
|
2650
|
+
};
|
|
2651
|
+
}
|
|
2641
2652
|
if (orderListIds.length === 1) {
|
|
2642
2653
|
return {
|
|
2643
2654
|
matched: true,
|
|
@@ -2708,6 +2719,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2708
2719
|
occupyDetails,
|
|
2709
2720
|
occupyDetail,
|
|
2710
2721
|
resourceSelectType,
|
|
2722
|
+
allowAddItems,
|
|
2711
2723
|
additionalOrderResult,
|
|
2712
2724
|
_occupyDetail$order_l,
|
|
2713
2725
|
multipleOrdersState,
|
|
@@ -2882,9 +2894,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2882
2894
|
occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null; // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
|
|
2883
2895
|
// 计算当前桌台的 resourceSelectType(single/multiple/capacity)
|
|
2884
2896
|
resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
|
|
2885
|
-
|
|
2897
|
+
allowAddItems = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.allow_add_items']);
|
|
2898
|
+
additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
|
|
2886
2899
|
if (!(additionalOrderResult.reason === 'multiple_orders')) {
|
|
2887
|
-
_context37.next =
|
|
2900
|
+
_context37.next = 61;
|
|
2888
2901
|
break;
|
|
2889
2902
|
}
|
|
2890
2903
|
multipleOrdersState = _objectSpread(_objectSpread({}, this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId)), {}, {
|
|
@@ -2905,13 +2918,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2905
2918
|
resourceSelectType: resourceSelectType
|
|
2906
2919
|
});
|
|
2907
2920
|
return _context37.abrupt("return", _availabilityInfo);
|
|
2908
|
-
case
|
|
2921
|
+
case 61:
|
|
2909
2922
|
// Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
|
|
2910
2923
|
resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
|
|
2911
2924
|
additionalOrderId = additionalOrderResult.order_id;
|
|
2912
2925
|
if (additionalOrderId) {
|
|
2913
2926
|
resourceState.mode = 'additional_order';
|
|
2914
2927
|
resourceState.order_id = additionalOrderId;
|
|
2928
|
+
} else if (additionalOrderResult.reason === 'add_items_disabled') {
|
|
2929
|
+
resourceState.mode = 'resource_busy';
|
|
2930
|
+
resourceState.order_id = '0';
|
|
2931
|
+
} else if (resourceSelectType === 'multiple' && resourceState.isFull) {
|
|
2932
|
+
resourceState.mode = 'resource_busy';
|
|
2933
|
+
resourceState.order_id = '0';
|
|
2915
2934
|
}
|
|
2916
2935
|
this.store.resource = resourceState;
|
|
2917
2936
|
|
|
@@ -2948,23 +2967,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2948
2967
|
|
|
2949
2968
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
2950
2969
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
2951
|
-
_context37.next =
|
|
2970
|
+
_context37.next = 76;
|
|
2952
2971
|
break;
|
|
2953
2972
|
}
|
|
2954
|
-
_context37.next =
|
|
2973
|
+
_context37.next = 76;
|
|
2955
2974
|
return this.addNewOrder();
|
|
2956
|
-
case
|
|
2975
|
+
case 76:
|
|
2957
2976
|
isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code'; // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
|
|
2958
2977
|
if (isAdditionalOrderMode) {
|
|
2959
2978
|
tempOrder.order_id = additionalOrderId;
|
|
2960
2979
|
}
|
|
2961
2980
|
if (!tempOrder.order_id) {
|
|
2962
|
-
_context37.next =
|
|
2981
|
+
_context37.next = 86;
|
|
2963
2982
|
break;
|
|
2964
2983
|
}
|
|
2965
|
-
_context37.next =
|
|
2984
|
+
_context37.next = 81;
|
|
2966
2985
|
return (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getOrderInfoByRemote(tempOrder.order_id);
|
|
2967
|
-
case
|
|
2986
|
+
case 81:
|
|
2968
2987
|
res = _context37.sent;
|
|
2969
2988
|
// 找到下单的时候输入的 entryPaxNumber
|
|
2970
2989
|
entryPaxNumber = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.bookings) === null || _res$data === void 0 || (_res$data = _res$data.find(function (p) {
|
|
@@ -2972,12 +2991,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2972
2991
|
return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
|
|
2973
2992
|
})) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
|
|
2974
2993
|
if (!entryPaxNumber) {
|
|
2975
|
-
_context37.next =
|
|
2994
|
+
_context37.next = 86;
|
|
2976
2995
|
break;
|
|
2977
2996
|
}
|
|
2978
|
-
_context37.next =
|
|
2997
|
+
_context37.next = 86;
|
|
2979
2998
|
return this.setEntryPaxNumber(entryPaxNumber);
|
|
2980
|
-
case
|
|
2999
|
+
case 86:
|
|
2981
3000
|
lastOrderInfo = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 || (_this$store$order8$ge = _this$store$order8.getLastOrderInfo) === null || _this$store$order8$ge === void 0 ? void 0 : _this$store$order8$ge.call(_this$store$order8);
|
|
2982
3001
|
historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
|
|
2983
3002
|
if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
|
|
@@ -2989,13 +3008,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2989
3008
|
} : {}));
|
|
2990
3009
|
return acc;
|
|
2991
3010
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
2992
|
-
_context37.next =
|
|
3011
|
+
_context37.next = 90;
|
|
2993
3012
|
return this.setItemRuleRuntimeConfig({
|
|
2994
3013
|
serviceType: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode,
|
|
2995
3014
|
submissionIndex: isAdditionalOrderMode ? 1 : 0,
|
|
2996
3015
|
historicalItems: historicalItems
|
|
2997
3016
|
});
|
|
2998
|
-
case
|
|
3017
|
+
case 90:
|
|
2999
3018
|
// operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
|
|
3000
3019
|
// 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
|
|
3001
3020
|
if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
|
|
@@ -3017,18 +3036,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3017
3036
|
isFull: resourceState.isFull
|
|
3018
3037
|
});
|
|
3019
3038
|
return _context37.abrupt("return", availabilityInfo);
|
|
3020
|
-
case
|
|
3021
|
-
_context37.prev =
|
|
3039
|
+
case 95:
|
|
3040
|
+
_context37.prev = 95;
|
|
3022
3041
|
_context37.t0 = _context37["catch"](3);
|
|
3023
3042
|
this.logMethodError('checkResourceAvailable', _context37.t0.message, {
|
|
3024
3043
|
resourceId: normalizedResourceId
|
|
3025
3044
|
});
|
|
3026
3045
|
throw _context37.t0;
|
|
3027
|
-
case
|
|
3046
|
+
case 99:
|
|
3028
3047
|
case "end":
|
|
3029
3048
|
return _context37.stop();
|
|
3030
3049
|
}
|
|
3031
|
-
}, _callee37, this, [[3,
|
|
3050
|
+
}, _callee37, this, [[3, 95]]);
|
|
3032
3051
|
}));
|
|
3033
3052
|
function checkResourceAvailable(_x19) {
|
|
3034
3053
|
return _checkResourceAvailable.apply(this, arguments);
|
|
@@ -3294,8 +3313,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3294
3313
|
key: "syncAdditionalOrderFromResource",
|
|
3295
3314
|
value: function () {
|
|
3296
3315
|
var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(resourceId) {
|
|
3297
|
-
var _ref10, _ref11, _ref12, _this$store$resource2, _this$store$resource3, _occupyDetails$2, _this$store$resource4, _this$store$order9;
|
|
3298
|
-
var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, result;
|
|
3316
|
+
var _ref10, _ref11, _ref12, _this$store$resource2, _this$store$resource3, _occupyDetails$2, _this$store$resource4, _this$otherParams17, _this$store$order9;
|
|
3317
|
+
var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result;
|
|
3299
3318
|
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3300
3319
|
while (1) switch (_context42.prev = _context42.next) {
|
|
3301
3320
|
case 0:
|
|
@@ -3321,17 +3340,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3321
3340
|
occupyDetails = _context42.sent;
|
|
3322
3341
|
occupyDetail = (_occupyDetails$2 = occupyDetails[0]) !== null && _occupyDetails$2 !== void 0 ? _occupyDetails$2 : null;
|
|
3323
3342
|
resourceSelectType = ((_this$store$resource4 = this.store.resource) === null || _this$store$resource4 === void 0 ? void 0 : _this$store$resource4.resourceSelectType) || this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
|
|
3324
|
-
|
|
3343
|
+
allowAddItems = toBoolean((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 || (_this$otherParams17 = _this$otherParams17.dineInConfig) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17['sale.allow_add_items']);
|
|
3344
|
+
result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
|
|
3325
3345
|
if (!(!result.matched || !result.order_id)) {
|
|
3326
|
-
_context42.next =
|
|
3346
|
+
_context42.next = 17;
|
|
3327
3347
|
break;
|
|
3328
3348
|
}
|
|
3329
3349
|
this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
|
|
3330
3350
|
resourceId: normalizedResourceId,
|
|
3331
|
-
resourceSelectType: resourceSelectType
|
|
3351
|
+
resourceSelectType: resourceSelectType,
|
|
3352
|
+
allowAddItems: allowAddItems
|
|
3332
3353
|
}));
|
|
3333
3354
|
return _context42.abrupt("return", result);
|
|
3334
|
-
case
|
|
3355
|
+
case 17:
|
|
3335
3356
|
tempOrder.order_id = result.order_id;
|
|
3336
3357
|
tempOrder.resource_id = normalizedResourceId;
|
|
3337
3358
|
tempOrder.relation_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
|
|
@@ -3339,10 +3360,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3339
3360
|
(_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || _this$store$order9.persistTempOrder();
|
|
3340
3361
|
this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
|
|
3341
3362
|
resourceId: normalizedResourceId,
|
|
3342
|
-
resourceSelectType: resourceSelectType
|
|
3363
|
+
resourceSelectType: resourceSelectType,
|
|
3364
|
+
allowAddItems: allowAddItems
|
|
3343
3365
|
}));
|
|
3344
3366
|
return _context42.abrupt("return", result);
|
|
3345
|
-
case
|
|
3367
|
+
case 24:
|
|
3346
3368
|
case "end":
|
|
3347
3369
|
return _context42.stop();
|
|
3348
3370
|
}
|
|
@@ -3376,9 +3398,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3376
3398
|
}, {
|
|
3377
3399
|
key: "checkAllowAddItems",
|
|
3378
3400
|
value: function checkAllowAddItems() {
|
|
3379
|
-
var _this$
|
|
3401
|
+
var _this$otherParams18;
|
|
3380
3402
|
this.logMethodStart('checkAllowAddItems');
|
|
3381
|
-
var dineInConfig = ((_this$
|
|
3403
|
+
var dineInConfig = ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.dineInConfig) || {};
|
|
3382
3404
|
var result = {
|
|
3383
3405
|
enabled: toBoolean(dineInConfig['sale.allow_add_items'])
|
|
3384
3406
|
};
|
|
@@ -3391,9 +3413,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3391
3413
|
}, {
|
|
3392
3414
|
key: "getFulfillmentModes",
|
|
3393
3415
|
value: function getFulfillmentModes() {
|
|
3394
|
-
var _this$
|
|
3416
|
+
var _this$otherParams19;
|
|
3395
3417
|
this.logMethodStart('getFulfillmentModes');
|
|
3396
|
-
var dineInConfig = ((_this$
|
|
3418
|
+
var dineInConfig = ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.dineInConfig) || {};
|
|
3397
3419
|
var result = {
|
|
3398
3420
|
enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
|
|
3399
3421
|
enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
|
|
@@ -3407,9 +3429,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3407
3429
|
}, {
|
|
3408
3430
|
key: "checkManualPickupRef",
|
|
3409
3431
|
value: function checkManualPickupRef() {
|
|
3410
|
-
var _this$
|
|
3432
|
+
var _this$otherParams20;
|
|
3411
3433
|
this.logMethodStart('checkManualPickupRef');
|
|
3412
|
-
var dineInConfig = ((_this$
|
|
3434
|
+
var dineInConfig = ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.dineInConfig) || {};
|
|
3413
3435
|
var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
|
|
3414
3436
|
var manualInputType = dineInConfig['fulfillment.manual_input_type'];
|
|
3415
3437
|
var enabled = refMode === 'manual_input';
|
|
@@ -255,7 +255,7 @@ export interface ScanOrderReservationResourceSelectInfo {
|
|
|
255
255
|
export interface ScanOrderAllowAddItemsInfo {
|
|
256
256
|
enabled: boolean;
|
|
257
257
|
}
|
|
258
|
-
export type ScanOrderSyncAdditionalOrderReason = 'missing_resource_id' | 'no_order' | 'multiple_orders' | 'invalid_order_id';
|
|
258
|
+
export type ScanOrderSyncAdditionalOrderReason = 'missing_resource_id' | 'no_order' | 'multiple_orders' | 'add_items_disabled' | 'invalid_order_id';
|
|
259
259
|
export interface ScanOrderSyncAdditionalOrderResult {
|
|
260
260
|
matched: boolean;
|
|
261
261
|
order_id?: string;
|
|
@@ -867,13 +867,13 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
867
867
|
const ruleProduct = this.enabledReservationRuleProducts[0];
|
|
868
868
|
const resourceState = this.store.resource;
|
|
869
869
|
const resourceSelectType = resourceState == null ? void 0 : resourceState.resourceSelectType;
|
|
870
|
-
const
|
|
870
|
+
const resolveBookingCapacityValue = () => {
|
|
871
871
|
var _a;
|
|
872
872
|
if (resourceSelectType === "single") {
|
|
873
873
|
const raw = (_a = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _a.capacity;
|
|
874
874
|
const num = Number(raw);
|
|
875
875
|
if (Number.isFinite(num) && num > 0)
|
|
876
|
-
return num;
|
|
876
|
+
return Math.max(1, Math.floor(num));
|
|
877
877
|
return 1;
|
|
878
878
|
}
|
|
879
879
|
return 1;
|
|
@@ -892,8 +892,8 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
892
892
|
};
|
|
893
893
|
}
|
|
894
894
|
const rawCollectPax = (_a = tempOrder.metadata) == null ? void 0 : _a.collect_pax;
|
|
895
|
-
const
|
|
896
|
-
const
|
|
895
|
+
const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== void 0 && rawCollectPax !== "";
|
|
896
|
+
const bookingCapacityValue = resolveBookingCapacityValue();
|
|
897
897
|
const pickOriginal = (value) => {
|
|
898
898
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
899
899
|
const original = value.original;
|
|
@@ -909,35 +909,42 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
909
909
|
main_field: mainField,
|
|
910
910
|
form_id: resourceState.tableFormId,
|
|
911
911
|
relation_id: resourceState.relationId ?? resourceId,
|
|
912
|
-
capacity:
|
|
912
|
+
capacity: bookingCapacityValue,
|
|
913
913
|
metadata: this.buildScanOrderResourceMetadata({
|
|
914
914
|
resourceState,
|
|
915
915
|
resourceName: mainField
|
|
916
916
|
})
|
|
917
917
|
} : void 0;
|
|
918
918
|
const ruleProductUid = ruleProduct ? (0, import_utils2.createUuidV4)() : void 0;
|
|
919
|
-
const bookingCapacityValue = resourceCapacityValue;
|
|
920
919
|
const bookingCapacityDimensionId = (0, import_utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
|
|
921
|
-
const nextBookings = (payload.bookings || []).map((booking, idx) =>
|
|
922
|
-
...booking
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
920
|
+
const nextBookings = (payload.bookings || []).map((booking, idx) => {
|
|
921
|
+
const metadata = { ...booking.metadata || {} };
|
|
922
|
+
if (hasExplicitCollectPax) {
|
|
923
|
+
metadata.collect_pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(rawCollectPax);
|
|
924
|
+
} else {
|
|
925
|
+
delete metadata.collect_pax;
|
|
926
|
+
}
|
|
927
|
+
return {
|
|
928
|
+
...booking,
|
|
929
|
+
number: bookingCapacityValue,
|
|
930
|
+
appointment_status: "started",
|
|
931
|
+
metadata: {
|
|
932
|
+
...metadata,
|
|
933
|
+
...resourceSelectType ? { resource_select_type: resourceSelectType } : {},
|
|
934
|
+
...resourceSelectType ? {
|
|
935
|
+
capacity: [
|
|
936
|
+
{
|
|
937
|
+
id: bookingCapacityDimensionId,
|
|
938
|
+
value: bookingCapacityValue,
|
|
939
|
+
name: ""
|
|
940
|
+
}
|
|
941
|
+
]
|
|
942
|
+
} : {}
|
|
943
|
+
},
|
|
944
|
+
...idx === 0 && resourceEntry ? { resources: [resourceEntry] } : {},
|
|
945
|
+
...idx === 0 && ruleProductUid ? { product_uid: ruleProductUid } : {}
|
|
946
|
+
};
|
|
947
|
+
});
|
|
941
948
|
const nextProducts = [...payload.products || []];
|
|
942
949
|
if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
|
|
943
950
|
const sellingPrice = String(ruleProduct.price ?? "0.00");
|
|
@@ -974,10 +981,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
974
981
|
if (!this.store.order) {
|
|
975
982
|
throw new Error("scanOrder解决方案需要 order 模块支持");
|
|
976
983
|
}
|
|
977
|
-
const pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(this.store.entryPaxNumber);
|
|
978
|
-
this.store.entryPaxNumber = pax;
|
|
979
984
|
const tempOrderForSubmit = this.store.order.ensureTempOrder();
|
|
980
|
-
tempOrderForSubmit.metadata = { ...tempOrderForSubmit.metadata, collect_pax: pax };
|
|
981
985
|
tempOrderForSubmit.delivery_type = "shop_service";
|
|
982
986
|
const resourceTableName = (_b = (_a = this.store.resource) == null ? void 0 : _a.table_form_record) == null ? void 0 : _b.name;
|
|
983
987
|
if (resourceTableName && typeof resourceTableName === "object") {
|
|
@@ -1549,7 +1553,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1549
1553
|
}
|
|
1550
1554
|
return ((_c = response == null ? void 0 : response.data) == null ? void 0 : _c.occupy_details) ?? [];
|
|
1551
1555
|
}
|
|
1552
|
-
resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType) {
|
|
1556
|
+
resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
|
|
1553
1557
|
const currentOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.order_id);
|
|
1554
1558
|
if (currentOrderId) {
|
|
1555
1559
|
return {
|
|
@@ -1557,13 +1561,25 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1557
1561
|
order_id: currentOrderId
|
|
1558
1562
|
};
|
|
1559
1563
|
}
|
|
1564
|
+
const orderListIds = (Array.isArray(detail == null ? void 0 : detail.order_list) ? (detail == null ? void 0 : detail.order_list) || [] : []).map((order) => (0, import_utils.toPositiveString)(order == null ? void 0 : order.id)).filter(Boolean);
|
|
1560
1565
|
if (resourceSelectType !== "single") {
|
|
1561
1566
|
return {
|
|
1562
1567
|
matched: false,
|
|
1563
1568
|
reason: "no_order"
|
|
1564
1569
|
};
|
|
1565
1570
|
}
|
|
1566
|
-
|
|
1571
|
+
if (!orderListIds.length) {
|
|
1572
|
+
return {
|
|
1573
|
+
matched: false,
|
|
1574
|
+
reason: "no_order"
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
if (!allowAddItems) {
|
|
1578
|
+
return {
|
|
1579
|
+
matched: false,
|
|
1580
|
+
reason: "add_items_disabled"
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1567
1583
|
if (orderListIds.length === 1) {
|
|
1568
1584
|
return {
|
|
1569
1585
|
matched: true,
|
|
@@ -1706,9 +1722,11 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1706
1722
|
const resourceSelectType = this.resolveResourceSelectType(
|
|
1707
1723
|
(0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id)
|
|
1708
1724
|
);
|
|
1725
|
+
const allowAddItems = (0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["sale.allow_add_items"]);
|
|
1709
1726
|
const additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(
|
|
1710
1727
|
occupyDetail,
|
|
1711
|
-
resourceSelectType
|
|
1728
|
+
resourceSelectType,
|
|
1729
|
+
allowAddItems
|
|
1712
1730
|
);
|
|
1713
1731
|
if (additionalOrderResult.reason === "multiple_orders") {
|
|
1714
1732
|
const multipleOrdersState = {
|
|
@@ -1740,6 +1758,12 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1740
1758
|
if (additionalOrderId) {
|
|
1741
1759
|
resourceState.mode = "additional_order";
|
|
1742
1760
|
resourceState.order_id = additionalOrderId;
|
|
1761
|
+
} else if (additionalOrderResult.reason === "add_items_disabled") {
|
|
1762
|
+
resourceState.mode = "resource_busy";
|
|
1763
|
+
resourceState.order_id = "0";
|
|
1764
|
+
} else if (resourceSelectType === "multiple" && resourceState.isFull) {
|
|
1765
|
+
resourceState.mode = "resource_busy";
|
|
1766
|
+
resourceState.order_id = "0";
|
|
1743
1767
|
}
|
|
1744
1768
|
this.store.resource = resourceState;
|
|
1745
1769
|
if (pendingRequestEntryPax !== void 0) {
|
|
@@ -1972,7 +1996,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1972
1996
|
return this.store.entryPaxNumber;
|
|
1973
1997
|
}
|
|
1974
1998
|
async syncAdditionalOrderFromResource(resourceId) {
|
|
1975
|
-
var _a, _b, _c, _d;
|
|
1999
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1976
2000
|
const tempOrder = this.ensureTempOrder();
|
|
1977
2001
|
const normalizedResourceId = String(
|
|
1978
2002
|
resourceId ?? tempOrder.resource_id ?? ((_a = this.store.resource) == null ? void 0 : _a.relationId) ?? ((_b = this.store.resource) == null ? void 0 : _b.relation_id) ?? ""
|
|
@@ -1991,15 +2015,20 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1991
2015
|
const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
|
|
1992
2016
|
const occupyDetail = occupyDetails[0] ?? null;
|
|
1993
2017
|
const resourceSelectType = ((_c = this.store.resource) == null ? void 0 : _c.resourceSelectType) || this.resolveResourceSelectType((0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id));
|
|
2018
|
+
const allowAddItems = (0, import_utils.toBoolean)(
|
|
2019
|
+
(_e = (_d = this.otherParams) == null ? void 0 : _d.dineInConfig) == null ? void 0 : _e["sale.allow_add_items"]
|
|
2020
|
+
);
|
|
1994
2021
|
const result = this.resolveAdditionalOrderFromOccupyDetail(
|
|
1995
2022
|
occupyDetail,
|
|
1996
|
-
resourceSelectType
|
|
2023
|
+
resourceSelectType,
|
|
2024
|
+
allowAddItems
|
|
1997
2025
|
);
|
|
1998
2026
|
if (!result.matched || !result.order_id) {
|
|
1999
2027
|
this.logMethodSuccess("syncAdditionalOrderFromResource", {
|
|
2000
2028
|
...result,
|
|
2001
2029
|
resourceId: normalizedResourceId,
|
|
2002
|
-
resourceSelectType
|
|
2030
|
+
resourceSelectType,
|
|
2031
|
+
allowAddItems
|
|
2003
2032
|
});
|
|
2004
2033
|
return result;
|
|
2005
2034
|
}
|
|
@@ -2007,11 +2036,12 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
2007
2036
|
tempOrder.resource_id = normalizedResourceId;
|
|
2008
2037
|
tempOrder.relation_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
|
|
2009
2038
|
tempOrder.table_form_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
|
|
2010
|
-
(
|
|
2039
|
+
(_f = this.store.order) == null ? void 0 : _f.persistTempOrder();
|
|
2011
2040
|
this.logMethodSuccess("syncAdditionalOrderFromResource", {
|
|
2012
2041
|
...result,
|
|
2013
2042
|
resourceId: normalizedResourceId,
|
|
2014
|
-
resourceSelectType
|
|
2043
|
+
resourceSelectType,
|
|
2044
|
+
allowAddItems
|
|
2015
2045
|
});
|
|
2016
2046
|
return result;
|
|
2017
2047
|
}
|
|
@@ -255,7 +255,7 @@ export interface ScanOrderReservationResourceSelectInfo {
|
|
|
255
255
|
export interface ScanOrderAllowAddItemsInfo {
|
|
256
256
|
enabled: boolean;
|
|
257
257
|
}
|
|
258
|
-
export type ScanOrderSyncAdditionalOrderReason = 'missing_resource_id' | 'no_order' | 'multiple_orders' | 'invalid_order_id';
|
|
258
|
+
export type ScanOrderSyncAdditionalOrderReason = 'missing_resource_id' | 'no_order' | 'multiple_orders' | 'add_items_disabled' | 'invalid_order_id';
|
|
259
259
|
export interface ScanOrderSyncAdditionalOrderResult {
|
|
260
260
|
matched: boolean;
|
|
261
261
|
order_id?: string;
|