@pisell/pisellos 0.0.555 → 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.
|
@@ -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);
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
-
var promotion_exports = {};
|
|
31
|
-
__export(promotion_exports, {
|
|
32
|
-
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
-
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
-
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
-
default: () => import_adapter2.default
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
-
var import_evaluator = require("./evaluator");
|
|
40
|
-
var import_adapter = require("./adapter");
|
|
41
|
-
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
-
var import_examples = require("./examples");
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
-
PromotionAdapter,
|
|
47
|
-
PromotionEvaluator,
|
|
48
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
-
});
|
|
@@ -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") {
|