@pisell/pisellos 2.1.135 → 2.1.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +61 -15
- package/dist/solution/VenueBooking/index.js +5 -2
- package/dist/solution/VenueBooking/types.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/resource.js +1 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +16 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +32 -1
- package/lib/solution/VenueBooking/index.js +1 -1
- package/lib/solution/VenueBooking/types.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/resource.js +1 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +13 -1
- package/package.json +1 -1
|
@@ -86,6 +86,8 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
86
86
|
onCustomerLogin(params: {
|
|
87
87
|
customerId: number;
|
|
88
88
|
}): Promise<void>;
|
|
89
|
+
private findReservationRuleResource;
|
|
90
|
+
private buildScanOrderResourceMetadata;
|
|
89
91
|
private buildSubmitPayloadEnhancer;
|
|
90
92
|
submitScanOrder<T = any>(): Promise<T>;
|
|
91
93
|
addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
@@ -1247,7 +1247,50 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1247
1247
|
return _onCustomerLogin.apply(this, arguments);
|
|
1248
1248
|
}
|
|
1249
1249
|
return onCustomerLogin;
|
|
1250
|
-
}()
|
|
1250
|
+
}()
|
|
1251
|
+
}, {
|
|
1252
|
+
key: "findReservationRuleResource",
|
|
1253
|
+
value: function findReservationRuleResource(formId) {
|
|
1254
|
+
if (formId == null) return undefined;
|
|
1255
|
+
var numericFormId = Number(formId);
|
|
1256
|
+
if (!Number.isFinite(numericFormId) || numericFormId <= 0) return undefined;
|
|
1257
|
+
var _iterator4 = _createForOfIteratorHelper(this.enabledReservationRuleProducts),
|
|
1258
|
+
_step4;
|
|
1259
|
+
try {
|
|
1260
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1261
|
+
var _product$product_reso;
|
|
1262
|
+
var product = _step4.value;
|
|
1263
|
+
var resources = product === null || product === void 0 || (_product$product_reso = product.product_resource) === null || _product$product_reso === void 0 ? void 0 : _product$product_reso.resources;
|
|
1264
|
+
if (!Array.isArray(resources)) continue;
|
|
1265
|
+
var matched = resources.find(function (resource) {
|
|
1266
|
+
return Number(resource === null || resource === void 0 ? void 0 : resource.id) === numericFormId;
|
|
1267
|
+
});
|
|
1268
|
+
if (matched) return matched;
|
|
1269
|
+
}
|
|
1270
|
+
} catch (err) {
|
|
1271
|
+
_iterator4.e(err);
|
|
1272
|
+
} finally {
|
|
1273
|
+
_iterator4.f();
|
|
1274
|
+
}
|
|
1275
|
+
return undefined;
|
|
1276
|
+
}
|
|
1277
|
+
}, {
|
|
1278
|
+
key: "buildScanOrderResourceMetadata",
|
|
1279
|
+
value: function buildScanOrderResourceMetadata(params) {
|
|
1280
|
+
var _ruleResource$title;
|
|
1281
|
+
var resourceState = params.resourceState,
|
|
1282
|
+
resourceName = params.resourceName;
|
|
1283
|
+
var ruleResource = this.findReservationRuleResource(resourceState.tableFormId);
|
|
1284
|
+
var combined = ruleResource === null || ruleResource === void 0 ? void 0 : ruleResource.combined_resource;
|
|
1285
|
+
var isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
|
|
1286
|
+
return {
|
|
1287
|
+
form_name: (_ruleResource$title = ruleResource === null || ruleResource === void 0 ? void 0 : ruleResource.title) !== null && _ruleResource$title !== void 0 ? _ruleResource$title : '',
|
|
1288
|
+
resource_name: resourceName,
|
|
1289
|
+
combined_resource: isCombined ? combined : null
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// ScanOrder 提交 payload enhancer:
|
|
1251
1294
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
1252
1295
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
1253
1296
|
// - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
|
|
@@ -1292,7 +1335,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1292
1335
|
form_id: resourceState.tableFormId,
|
|
1293
1336
|
relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
|
|
1294
1337
|
capacity: resolveResourceCapacity(),
|
|
1295
|
-
metadata: {
|
|
1338
|
+
metadata: _this5.buildScanOrderResourceMetadata({
|
|
1339
|
+
resourceState: resourceState,
|
|
1340
|
+
resourceName: mainField
|
|
1341
|
+
})
|
|
1296
1342
|
} : undefined;
|
|
1297
1343
|
var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
|
|
1298
1344
|
// 默认 resolveResourceCapacity(single 为桌台容量,其余多为 1);有 collect_pax 时 value 优先用人数
|
|
@@ -1776,17 +1822,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1776
1822
|
if (visited.has(value)) return;
|
|
1777
1823
|
visited.add(value);
|
|
1778
1824
|
if (Array.isArray(value)) {
|
|
1779
|
-
var
|
|
1780
|
-
|
|
1825
|
+
var _iterator5 = _createForOfIteratorHelper(value),
|
|
1826
|
+
_step5;
|
|
1781
1827
|
try {
|
|
1782
|
-
for (
|
|
1783
|
-
var item =
|
|
1828
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1829
|
+
var item = _step5.value;
|
|
1784
1830
|
collectFromValue(item);
|
|
1785
1831
|
}
|
|
1786
1832
|
} catch (err) {
|
|
1787
|
-
|
|
1833
|
+
_iterator5.e(err);
|
|
1788
1834
|
} finally {
|
|
1789
|
-
|
|
1835
|
+
_iterator5.f();
|
|
1790
1836
|
}
|
|
1791
1837
|
return;
|
|
1792
1838
|
}
|
|
@@ -1947,7 +1993,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1947
1993
|
key: "applyPrefillByItemRule",
|
|
1948
1994
|
value: function () {
|
|
1949
1995
|
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1950
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
1996
|
+
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator6, _step6, _prefillItem$product_, _targetProduct$_origi, _targetProduct$_origi2, _targetProduct$_origi3, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
|
|
1951
1997
|
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
1952
1998
|
while (1) switch (_context29.prev = _context29.next) {
|
|
1953
1999
|
case 0:
|
|
@@ -1992,15 +2038,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1992
2038
|
productSourceMap = _context29.sent;
|
|
1993
2039
|
tempOrder = this.ensureTempOrder();
|
|
1994
2040
|
hasChanges = false;
|
|
1995
|
-
|
|
2041
|
+
_iterator6 = _createForOfIteratorHelper(prefillItems);
|
|
1996
2042
|
_context29.prev = 20;
|
|
1997
|
-
|
|
2043
|
+
_iterator6.s();
|
|
1998
2044
|
case 22:
|
|
1999
|
-
if ((
|
|
2045
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
2000
2046
|
_context29.next = 47;
|
|
2001
2047
|
break;
|
|
2002
2048
|
}
|
|
2003
|
-
prefillItem =
|
|
2049
|
+
prefillItem = _step6.value;
|
|
2004
2050
|
productId = Number(prefillItem.product_id);
|
|
2005
2051
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
2006
2052
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
@@ -2071,10 +2117,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2071
2117
|
case 49:
|
|
2072
2118
|
_context29.prev = 49;
|
|
2073
2119
|
_context29.t0 = _context29["catch"](20);
|
|
2074
|
-
|
|
2120
|
+
_iterator6.e(_context29.t0);
|
|
2075
2121
|
case 52:
|
|
2076
2122
|
_context29.prev = 52;
|
|
2077
|
-
|
|
2123
|
+
_iterator6.f();
|
|
2078
2124
|
return _context29.finish(52);
|
|
2079
2125
|
case 55:
|
|
2080
2126
|
if (!hasChanges) {
|
|
@@ -44,7 +44,7 @@ import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
|
44
44
|
import { extractResourceIds, buildResourceProductMap } from "./utils/resource";
|
|
45
45
|
import { buildTimeSlotGrid, isBusinessHoursCrossDay, generateTimeLabels } from "./utils/timeSlot";
|
|
46
46
|
import { buildDateRangeSummary } from "./utils/dateSummary";
|
|
47
|
-
import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentityKey, buildVenueBookingEntry, buildPriceBreakdown } from "./utils/slotMerge";
|
|
47
|
+
import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentityKey, buildVenueBookingEntry, buildVenueResourceMetadata, buildPriceBreakdown } from "./utils/slotMerge";
|
|
48
48
|
import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
49
49
|
import { OrderModule } from "../../modules/Order";
|
|
50
50
|
import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
|
|
@@ -1627,7 +1627,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1627
1627
|
form_id: (_rawResource$form_id = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_id) !== null && _rawResource$form_id !== void 0 ? _rawResource$form_id : mapping.formId,
|
|
1628
1628
|
relation_id: resourceId,
|
|
1629
1629
|
capacity: 1,
|
|
1630
|
-
metadata: {
|
|
1630
|
+
metadata: buildVenueResourceMetadata({
|
|
1631
|
+
mapping: mapping,
|
|
1632
|
+
rawResource: rawResource
|
|
1633
|
+
})
|
|
1631
1634
|
};
|
|
1632
1635
|
if (childRawResources && childRawResources.length) {
|
|
1633
1636
|
resourceEntry.children = childRawResources.map(function (child) {
|
|
@@ -25,6 +25,10 @@ export interface BuildVenueBookingParams {
|
|
|
25
25
|
*/
|
|
26
26
|
childResources?: VenueResourceRawData[];
|
|
27
27
|
}
|
|
28
|
+
export declare function buildVenueResourceMetadata(params: {
|
|
29
|
+
mapping: ResourceProductMapping;
|
|
30
|
+
rawResource: VenueResourceRawData | undefined;
|
|
31
|
+
}): Record<string, any>;
|
|
28
32
|
export declare function buildVenueBookingEntry(params: BuildVenueBookingParams): Record<string, any>;
|
|
29
33
|
/**
|
|
30
34
|
* 从一条已合并的订单商品还原出独立的时段列表。
|
|
@@ -89,6 +89,18 @@ export function buildPriceBreakdown(params) {
|
|
|
89
89
|
}
|
|
90
90
|
return entries;
|
|
91
91
|
}
|
|
92
|
+
export function buildVenueResourceMetadata(params) {
|
|
93
|
+
var _mapping$formName, _rawResource$main_fie;
|
|
94
|
+
var mapping = params.mapping,
|
|
95
|
+
rawResource = params.rawResource;
|
|
96
|
+
var combined = rawResource === null || rawResource === void 0 ? void 0 : rawResource.combined_resource;
|
|
97
|
+
var isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
|
|
98
|
+
return {
|
|
99
|
+
form_name: (_mapping$formName = mapping.formName) !== null && _mapping$formName !== void 0 ? _mapping$formName : mapping.resourceName,
|
|
100
|
+
resource_name: (_rawResource$main_fie = rawResource === null || rawResource === void 0 ? void 0 : rawResource.main_field) !== null && _rawResource$main_fie !== void 0 ? _rawResource$main_fie : mapping.resourceName,
|
|
101
|
+
combined_resource: isCombined ? combined : null
|
|
102
|
+
};
|
|
103
|
+
}
|
|
92
104
|
export function buildVenueBookingEntry(params) {
|
|
93
105
|
var _rawResource$form_id;
|
|
94
106
|
var group = params.group,
|
|
@@ -109,7 +121,10 @@ export function buildVenueBookingEntry(params) {
|
|
|
109
121
|
form_id: (_rawResource$form_id = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_id) !== null && _rawResource$form_id !== void 0 ? _rawResource$form_id : mapping.formId,
|
|
110
122
|
relation_id: resourceId,
|
|
111
123
|
capacity: 1,
|
|
112
|
-
metadata: {
|
|
124
|
+
metadata: buildVenueResourceMetadata({
|
|
125
|
+
mapping: mapping,
|
|
126
|
+
rawResource: rawResource
|
|
127
|
+
})
|
|
113
128
|
};
|
|
114
129
|
if (childResources && childResources.length) {
|
|
115
130
|
resourceEntry.children = childResources.map(function (child) {
|
|
@@ -86,6 +86,8 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
86
86
|
onCustomerLogin(params: {
|
|
87
87
|
customerId: number;
|
|
88
88
|
}): Promise<void>;
|
|
89
|
+
private findReservationRuleResource;
|
|
90
|
+
private buildScanOrderResourceMetadata;
|
|
89
91
|
private buildSubmitPayloadEnhancer;
|
|
90
92
|
submitScanOrder<T = any>(): Promise<T>;
|
|
91
93
|
addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
@@ -746,6 +746,34 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
746
746
|
throw error;
|
|
747
747
|
}
|
|
748
748
|
}
|
|
749
|
+
findReservationRuleResource(formId) {
|
|
750
|
+
var _a;
|
|
751
|
+
if (formId == null)
|
|
752
|
+
return void 0;
|
|
753
|
+
const numericFormId = Number(formId);
|
|
754
|
+
if (!Number.isFinite(numericFormId) || numericFormId <= 0)
|
|
755
|
+
return void 0;
|
|
756
|
+
for (const product of this.enabledReservationRuleProducts) {
|
|
757
|
+
const resources = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources;
|
|
758
|
+
if (!Array.isArray(resources))
|
|
759
|
+
continue;
|
|
760
|
+
const matched = resources.find((resource) => Number(resource == null ? void 0 : resource.id) === numericFormId);
|
|
761
|
+
if (matched)
|
|
762
|
+
return matched;
|
|
763
|
+
}
|
|
764
|
+
return void 0;
|
|
765
|
+
}
|
|
766
|
+
buildScanOrderResourceMetadata(params) {
|
|
767
|
+
const { resourceState, resourceName } = params;
|
|
768
|
+
const ruleResource = this.findReservationRuleResource(resourceState.tableFormId);
|
|
769
|
+
const combined = ruleResource == null ? void 0 : ruleResource.combined_resource;
|
|
770
|
+
const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
|
|
771
|
+
return {
|
|
772
|
+
form_name: (ruleResource == null ? void 0 : ruleResource.title) ?? "",
|
|
773
|
+
resource_name: resourceName,
|
|
774
|
+
combined_resource: isCombined ? combined : null
|
|
775
|
+
};
|
|
776
|
+
}
|
|
749
777
|
// ScanOrder 提交 payload enhancer:
|
|
750
778
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
751
779
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
@@ -785,7 +813,10 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
785
813
|
form_id: resourceState.tableFormId,
|
|
786
814
|
relation_id: resourceState.relationId ?? resourceId,
|
|
787
815
|
capacity: resolveResourceCapacity(),
|
|
788
|
-
metadata: {
|
|
816
|
+
metadata: this.buildScanOrderResourceMetadata({
|
|
817
|
+
resourceState,
|
|
818
|
+
resourceName: mainField
|
|
819
|
+
})
|
|
789
820
|
} : void 0;
|
|
790
821
|
const ruleProductUid = ruleProduct ? (0, import_utils2.createUuidV4)() : void 0;
|
|
791
822
|
const rawCollectPax = (_b = tempOrder.metadata) == null ? void 0 : _b.collect_pax;
|
|
@@ -988,7 +988,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
988
988
|
form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
|
|
989
989
|
relation_id: resourceId,
|
|
990
990
|
capacity: 1,
|
|
991
|
-
metadata: {}
|
|
991
|
+
metadata: (0, import_slotMerge.buildVenueResourceMetadata)({ mapping, rawResource })
|
|
992
992
|
};
|
|
993
993
|
if (childRawResources && childRawResources.length) {
|
|
994
994
|
resourceEntry.children = childRawResources.map((child) => ({
|
|
@@ -25,6 +25,10 @@ export interface BuildVenueBookingParams {
|
|
|
25
25
|
*/
|
|
26
26
|
childResources?: VenueResourceRawData[];
|
|
27
27
|
}
|
|
28
|
+
export declare function buildVenueResourceMetadata(params: {
|
|
29
|
+
mapping: ResourceProductMapping;
|
|
30
|
+
rawResource: VenueResourceRawData | undefined;
|
|
31
|
+
}): Record<string, any>;
|
|
28
32
|
export declare function buildVenueBookingEntry(params: BuildVenueBookingParams): Record<string, any>;
|
|
29
33
|
/**
|
|
30
34
|
* 从一条已合并的订单商品还原出独立的时段列表。
|
|
@@ -32,6 +32,7 @@ __export(slotMerge_exports, {
|
|
|
32
32
|
buildPriceBreakdown: () => buildPriceBreakdown,
|
|
33
33
|
buildVenueBookingEntry: () => buildVenueBookingEntry,
|
|
34
34
|
buildVenueIdentityKey: () => buildVenueIdentityKey,
|
|
35
|
+
buildVenueResourceMetadata: () => buildVenueResourceMetadata,
|
|
35
36
|
expandMergedSlotToIndividual: () => expandMergedSlotToIndividual,
|
|
36
37
|
mergeConsecutiveSlots: () => mergeConsecutiveSlots
|
|
37
38
|
});
|
|
@@ -106,6 +107,16 @@ function buildPriceBreakdown(params) {
|
|
|
106
107
|
}
|
|
107
108
|
return entries;
|
|
108
109
|
}
|
|
110
|
+
function buildVenueResourceMetadata(params) {
|
|
111
|
+
const { mapping, rawResource } = params;
|
|
112
|
+
const combined = rawResource == null ? void 0 : rawResource.combined_resource;
|
|
113
|
+
const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
|
|
114
|
+
return {
|
|
115
|
+
form_name: mapping.formName ?? mapping.resourceName,
|
|
116
|
+
resource_name: (rawResource == null ? void 0 : rawResource.main_field) ?? mapping.resourceName,
|
|
117
|
+
combined_resource: isCombined ? combined : null
|
|
118
|
+
};
|
|
119
|
+
}
|
|
109
120
|
function buildVenueBookingEntry(params) {
|
|
110
121
|
const { group, resourceId, mapping, rawResource, bookingUuid, productUid, childResources } = params;
|
|
111
122
|
const startMoment = (0, import_dayjs.default)(group.startTime, "YYYY-MM-DD HH:mm");
|
|
@@ -119,7 +130,7 @@ function buildVenueBookingEntry(params) {
|
|
|
119
130
|
form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
|
|
120
131
|
relation_id: resourceId,
|
|
121
132
|
capacity: 1,
|
|
122
|
-
metadata: {}
|
|
133
|
+
metadata: buildVenueResourceMetadata({ mapping, rawResource })
|
|
123
134
|
};
|
|
124
135
|
if (childResources && childResources.length) {
|
|
125
136
|
resourceEntry.children = childResources.map((child) => ({
|
|
@@ -220,6 +231,7 @@ function expandMergedSlotToIndividual(product, slotDurationMinutes) {
|
|
|
220
231
|
buildPriceBreakdown,
|
|
221
232
|
buildVenueBookingEntry,
|
|
222
233
|
buildVenueIdentityKey,
|
|
234
|
+
buildVenueResourceMetadata,
|
|
223
235
|
expandMergedSlotToIndividual,
|
|
224
236
|
mergeConsecutiveSlots
|
|
225
237
|
});
|