@pisell/pisellos 2.1.121 → 2.1.123
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/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +6 -0
- package/dist/modules/Order/index.js +39 -1
- package/dist/modules/Order/types.d.ts +4 -0
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +10 -6
- package/dist/modules/ProductList/index.js +2 -2
- package/dist/modules/Quotation/index.js +6 -3
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +97 -21
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/dist/solution/ScanOrder/utils.d.ts +11 -0
- package/dist/solution/ScanOrder/utils.js +67 -0
- package/dist/solution/VenueBooking/index.d.ts +10 -0
- package/dist/solution/VenueBooking/index.js +104 -13
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +6 -0
- package/lib/modules/Order/index.js +18 -1
- package/lib/modules/Order/types.d.ts +4 -0
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +13 -5
- package/lib/modules/ProductList/index.js +2 -2
- package/lib/modules/Quotation/index.js +3 -0
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +72 -4
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/lib/solution/ScanOrder/utils.d.ts +11 -0
- package/lib/solution/ScanOrder/utils.js +42 -0
- package/lib/solution/VenueBooking/index.d.ts +10 -0
- package/lib/solution/VenueBooking/index.js +67 -4
- package/package.json +1 -1
|
@@ -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";
|
|
@@ -76,6 +76,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
76
76
|
removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
77
77
|
submitTempOrder<T = any>(params?: {
|
|
78
78
|
cacheId?: string;
|
|
79
|
+
platform?: string;
|
|
80
|
+
businessCode?: string;
|
|
81
|
+
channel?: string;
|
|
82
|
+
type?: string;
|
|
79
83
|
}): Promise<T>;
|
|
80
84
|
createOrder(params: CommitOrderParams['query']): {
|
|
81
85
|
type: "virtual" | "appointment_booking";
|
|
@@ -108,4 +112,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
108
112
|
createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
|
|
109
113
|
submitScanOrder<T = any>(params: SubmitScanOrderParams): Promise<T>;
|
|
110
114
|
scanOrderMore<T = any>(params: ScanOrderMoreParams): Promise<T>;
|
|
115
|
+
getOrderInfoByRemote(order_id: number): Promise<void>;
|
|
116
|
+
getLastOrderInfo(): Record<string, any> | undefined;
|
|
111
117
|
}
|
|
@@ -741,7 +741,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
741
741
|
effectiveCacheId = (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId;
|
|
742
742
|
payload = buildSubmitPayload({
|
|
743
743
|
tempOrder: tempOrder,
|
|
744
|
-
cacheId: effectiveCacheId
|
|
744
|
+
cacheId: effectiveCacheId,
|
|
745
|
+
platform: params === null || params === void 0 ? void 0 : params.platform,
|
|
746
|
+
businessCode: params === null || params === void 0 ? void 0 : params.businessCode,
|
|
747
|
+
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
748
|
+
type: params === null || params === void 0 ? void 0 : params.type
|
|
745
749
|
});
|
|
746
750
|
if (!tempOrder.order_id) {
|
|
747
751
|
_context10.next = 12;
|
|
@@ -1095,7 +1099,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1095
1099
|
return _scanOrderMore.apply(this, arguments);
|
|
1096
1100
|
}
|
|
1097
1101
|
return scanOrderMore;
|
|
1102
|
+
}() // TODO 获取详情的接口
|
|
1103
|
+
}, {
|
|
1104
|
+
key: "getOrderInfoByRemote",
|
|
1105
|
+
value: function () {
|
|
1106
|
+
var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(order_id) {
|
|
1107
|
+
var res;
|
|
1108
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1109
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1110
|
+
case 0:
|
|
1111
|
+
_context15.next = 2;
|
|
1112
|
+
return this.request.get("/order/sales/".concat(order_id), {
|
|
1113
|
+
with: ['products', 'scheduleEvents']
|
|
1114
|
+
});
|
|
1115
|
+
case 2:
|
|
1116
|
+
res = _context15.sent;
|
|
1117
|
+
if (res.data.code === 200 && this.store.tempOrder) {
|
|
1118
|
+
this.store.tempOrder.lastOrderInfo = res.data.data;
|
|
1119
|
+
}
|
|
1120
|
+
case 4:
|
|
1121
|
+
case "end":
|
|
1122
|
+
return _context15.stop();
|
|
1123
|
+
}
|
|
1124
|
+
}, _callee15, this);
|
|
1125
|
+
}));
|
|
1126
|
+
function getOrderInfoByRemote(_x15) {
|
|
1127
|
+
return _getOrderInfoByRemote.apply(this, arguments);
|
|
1128
|
+
}
|
|
1129
|
+
return getOrderInfoByRemote;
|
|
1098
1130
|
}()
|
|
1131
|
+
}, {
|
|
1132
|
+
key: "getLastOrderInfo",
|
|
1133
|
+
value: function getLastOrderInfo() {
|
|
1134
|
+
var _this$store;
|
|
1135
|
+
return (_this$store = this.store) === null || _this$store === void 0 || (_this$store = _this$store.tempOrder) === null || _this$store === void 0 ? void 0 : _this$store.lastOrderInfo;
|
|
1136
|
+
}
|
|
1099
1137
|
}], [{
|
|
1100
1138
|
key: "populateSavedAmounts",
|
|
1101
1139
|
value:
|
|
@@ -212,6 +212,10 @@ export interface OrderModuleAPI {
|
|
|
212
212
|
persistTempOrder: () => void;
|
|
213
213
|
submitTempOrder: <T = any>(params?: {
|
|
214
214
|
cacheId?: string;
|
|
215
|
+
platform?: string;
|
|
216
|
+
businessCode?: string;
|
|
217
|
+
channel?: string;
|
|
218
|
+
type?: string;
|
|
215
219
|
}) => Promise<T>;
|
|
216
220
|
loadDiscountConfig: (params: {
|
|
217
221
|
customerId: number;
|
|
@@ -36,6 +36,10 @@ export declare function buildSubmitPayload(params: {
|
|
|
36
36
|
tempOrder: ScanOrderTempOrder;
|
|
37
37
|
cacheId?: string;
|
|
38
38
|
now?: Date;
|
|
39
|
+
platform?: string;
|
|
40
|
+
businessCode?: string;
|
|
41
|
+
channel?: string;
|
|
42
|
+
type?: string;
|
|
39
43
|
}): ScanOrderSubmitPayload;
|
|
40
44
|
export declare function formatV1Product(products: ScanOrderSubmitProduct[]): {
|
|
41
45
|
bundle: any[];
|
|
@@ -219,11 +219,15 @@ export function createDefaultTempOrder(params) {
|
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
221
|
export function buildSubmitPayload(params) {
|
|
222
|
-
var _tempOrder$is_price_i, _tempOrder$is_deposit;
|
|
222
|
+
var _ref, _ref2, _ref3, _tempOrder$is_price_i, _tempOrder$is_deposit;
|
|
223
223
|
var tempOrder = params.tempOrder,
|
|
224
224
|
cacheId = params.cacheId,
|
|
225
225
|
_params$now = params.now,
|
|
226
|
-
now = _params$now === void 0 ? new Date() : _params$now
|
|
226
|
+
now = _params$now === void 0 ? new Date() : _params$now,
|
|
227
|
+
platform = params.platform,
|
|
228
|
+
businessCode = params.businessCode,
|
|
229
|
+
channel = params.channel,
|
|
230
|
+
type = params.type;
|
|
227
231
|
var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
228
232
|
var summary = tempOrder.summary || createEmptySummary();
|
|
229
233
|
var relationId = tempOrder.relation_id;
|
|
@@ -260,12 +264,12 @@ export function buildSubmitPayload(params) {
|
|
|
260
264
|
_surcharges = tempOrder.surcharges,
|
|
261
265
|
tempOrderRest = _objectWithoutProperties(tempOrder, _excluded2);
|
|
262
266
|
return _objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
263
|
-
platform: normalizeSubmitPlatform(tempOrder.platform),
|
|
267
|
+
platform: normalizeSubmitPlatform(platform !== null && platform !== void 0 ? platform : tempOrder.platform),
|
|
264
268
|
request_unique_idempotency_token: cacheId,
|
|
265
|
-
type: tempOrder.type
|
|
266
|
-
business_code: tempOrder.business_code
|
|
269
|
+
type: (_ref = type !== null && type !== void 0 ? type : tempOrder.type) !== null && _ref !== void 0 ? _ref : 'table-order',
|
|
270
|
+
business_code: (_ref2 = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code) !== null && _ref2 !== void 0 ? _ref2 : 'table-order',
|
|
267
271
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
268
|
-
order_sales_channel: tempOrder.order_sales_channel
|
|
272
|
+
order_sales_channel: (_ref3 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref3 !== void 0 ? _ref3 : 'online_store',
|
|
269
273
|
status: tempOrder.status || 'normal',
|
|
270
274
|
payment_status: tempOrder.payment_status || 'payment_processing',
|
|
271
275
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
@@ -85,7 +85,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
85
85
|
key: "loadProducts",
|
|
86
86
|
value: function () {
|
|
87
87
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
|
|
88
|
-
var _this$otherParams;
|
|
88
|
+
var _this$otherParams, _this$otherParams2;
|
|
89
89
|
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, userPlugin, customer_id, _userPlugin$get, productsData, sortedList;
|
|
90
90
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
91
91
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -129,7 +129,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
129
129
|
with_count: with_count,
|
|
130
130
|
// client_schedule_ids: schedule_ids,
|
|
131
131
|
schedule_date: schedule_date,
|
|
132
|
-
application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel,
|
|
132
|
+
application_code: ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel) === 'online_store' ? 'online-store' : (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel,
|
|
133
133
|
with_schedule: with_schedule,
|
|
134
134
|
schedule_datetime: schedule_datetime,
|
|
135
135
|
is_eject: 1
|
|
@@ -78,18 +78,21 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
78
78
|
case 0:
|
|
79
79
|
query = {};
|
|
80
80
|
if (params !== null && params !== void 0 && params.channel) query.channel = params.channel;
|
|
81
|
-
|
|
81
|
+
if ((params === null || params === void 0 ? void 0 : params.channel) === 'online-store') {
|
|
82
|
+
query.channel = 'online_store';
|
|
83
|
+
}
|
|
84
|
+
_context2.next = 5;
|
|
82
85
|
return this.request.get('/quotation/available', query, {
|
|
83
86
|
useCache: false
|
|
84
87
|
});
|
|
85
|
-
case
|
|
88
|
+
case 5:
|
|
86
89
|
res = _context2.sent;
|
|
87
90
|
list = (res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || [];
|
|
88
91
|
list.sort(function (a, b) {
|
|
89
92
|
return a.sort - b.sort;
|
|
90
93
|
});
|
|
91
94
|
this.store.list = list;
|
|
92
|
-
case
|
|
95
|
+
case 9:
|
|
93
96
|
case "end":
|
|
94
97
|
return _context2.stop();
|
|
95
98
|
}
|
|
@@ -27,6 +27,8 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
27
27
|
private itemRuleConfigsPromise;
|
|
28
28
|
private itemRulePrefillApplied;
|
|
29
29
|
private itemRuleRuntimeConfig;
|
|
30
|
+
/** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
|
|
31
|
+
private enabledReservationRuleProducts;
|
|
30
32
|
private getScanOrderLoggerContext;
|
|
31
33
|
private serializeError;
|
|
32
34
|
private addScanOrderLog;
|
|
@@ -22,8 +22,9 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
22
22
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
23
|
import { BaseModule } from "../../modules/BaseModule";
|
|
24
24
|
import { ScanOrderHooks } from "./types";
|
|
25
|
-
import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, createEmptySummary, getProductIdentityIndex, getSafeProductNum, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, toNonNegativeInt, toNonNegativeNumber, toPriceString, toBoolean, toPositiveString } from "./utils";
|
|
25
|
+
import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, createEmptySummary, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toNonNegativeNumber, toPriceString, toBoolean, toPositiveString } from "./utils";
|
|
26
26
|
import { createModule } from "../BookingByStep/types";
|
|
27
|
+
import { ProductList } from "../../modules/ProductList";
|
|
27
28
|
import dayjs from 'dayjs';
|
|
28
29
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
29
30
|
export * from "./types";
|
|
@@ -61,6 +62,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
61
62
|
_defineProperty(_assertThisInitialized(_this), "itemRuleConfigsPromise", null);
|
|
62
63
|
_defineProperty(_assertThisInitialized(_this), "itemRulePrefillApplied", false);
|
|
63
64
|
_defineProperty(_assertThisInitialized(_this), "itemRuleRuntimeConfig", {});
|
|
65
|
+
/** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
|
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "enabledReservationRuleProducts", []);
|
|
64
67
|
return _this;
|
|
65
68
|
}
|
|
66
69
|
_createClass(ScanOrderImpl, [{
|
|
@@ -632,7 +635,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
632
635
|
key: "submitScanOrder",
|
|
633
636
|
value: function () {
|
|
634
637
|
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
635
|
-
var _tempOrder$products, result, tempOrder;
|
|
638
|
+
var _this$otherParams4, _this$otherParams5, _this$otherParams6, _this$otherParams7, _tempOrder$products, result, tempOrder;
|
|
636
639
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
637
640
|
while (1) switch (_context9.prev = _context9.next) {
|
|
638
641
|
case 0:
|
|
@@ -649,7 +652,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
649
652
|
case 6:
|
|
650
653
|
_context9.next = 8;
|
|
651
654
|
return this.store.order.submitTempOrder({
|
|
652
|
-
cacheId: this.cacheId
|
|
655
|
+
cacheId: this.cacheId,
|
|
656
|
+
platform: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform,
|
|
657
|
+
businessCode: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode,
|
|
658
|
+
channel: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.channel,
|
|
659
|
+
type: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.type
|
|
653
660
|
});
|
|
654
661
|
case 8:
|
|
655
662
|
result = _context9.sent;
|
|
@@ -1519,7 +1526,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1519
1526
|
}, {
|
|
1520
1527
|
key: "normalizeResourceState",
|
|
1521
1528
|
value: function normalizeResourceState(config, hasOrderId) {
|
|
1522
|
-
var _this$
|
|
1529
|
+
var _this$otherParams8;
|
|
1523
1530
|
var orderNumberPrefix = Array.isArray(config === null || config === void 0 ? void 0 : config.order_number_prefix) ? (config === null || config === void 0 ? void 0 : config.order_number_prefix) || [] : [];
|
|
1524
1531
|
var tableMaxNumber = Number((config === null || config === void 0 ? void 0 : config.table_max_number) || 1);
|
|
1525
1532
|
var orderCount = toNonNegativeNumber(config === null || config === void 0 ? void 0 : config.order_count);
|
|
@@ -1528,7 +1535,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1528
1535
|
var relationId = toPositiveString(config === null || config === void 0 ? void 0 : config.relation_id);
|
|
1529
1536
|
var tableFormId = toPositiveString(config === null || config === void 0 ? void 0 : config.table_form_id);
|
|
1530
1537
|
// 是否允许加餐
|
|
1531
|
-
var allowSnack = ((_this$
|
|
1538
|
+
var allowSnack = ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 || (_this$otherParams8 = _this$otherParams8.dineInConfig) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8['workflow.allow_add_items']) || false;
|
|
1532
1539
|
// 开启同桌验证 - 本期没有这个配置,默认关掉
|
|
1533
1540
|
var deskmateValid = false;
|
|
1534
1541
|
var isExclusive = tableMaxNumber > 0 ? tableMaxNumber <= 1 : false;
|
|
@@ -1647,7 +1654,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1647
1654
|
key: "checkResourceAvailable",
|
|
1648
1655
|
value: function () {
|
|
1649
1656
|
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(resourceId, hasOrderId) {
|
|
1650
|
-
var _this$
|
|
1657
|
+
var _this$otherParams9, _this$otherParams9$ge, _config$table_form_re, _config$table_form_re2, _this$otherParams10, _this$store$order4, openData, dineInConfig, shopClosedInfo, config, resourceState, availabilityInfo, tempOrder, reservationLinkIds, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, _this$store$order5;
|
|
1651
1658
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1652
1659
|
while (1) switch (_context27.prev = _context27.next) {
|
|
1653
1660
|
case 0:
|
|
@@ -1656,7 +1663,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1656
1663
|
});
|
|
1657
1664
|
_context27.prev = 1;
|
|
1658
1665
|
_context27.next = 4;
|
|
1659
|
-
return (_this$
|
|
1666
|
+
return (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9$ge = _this$otherParams9.getOpenData) === null || _this$otherParams9$ge === void 0 ? void 0 : _this$otherParams9$ge.call(_this$otherParams9, {
|
|
1660
1667
|
scope: 'board',
|
|
1661
1668
|
target: 'dine_in+scan_to_order',
|
|
1662
1669
|
section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
|
|
@@ -1710,29 +1717,98 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1710
1717
|
partyroom_booking: config === null || config === void 0 || (_config$table_form_re2 = config.table_form_record) === null || _config$table_form_re2 === void 0 ? void 0 : _config$table_form_re2.partyroom_booking
|
|
1711
1718
|
};
|
|
1712
1719
|
tempOrder = this.ensureTempOrder();
|
|
1713
|
-
tempOrder.relation_id = resourceId || ((_this$
|
|
1720
|
+
tempOrder.relation_id = resourceId || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.relation_id);
|
|
1714
1721
|
tempOrder.table_form_id = resourceState.tableFormId;
|
|
1715
1722
|
tempOrder.resource_id = resourceId;
|
|
1723
|
+
reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['reservation.enabled_reservation_rules']);
|
|
1724
|
+
if (!(reservationLinkIds.length === 0)) {
|
|
1725
|
+
_context27.next = 31;
|
|
1726
|
+
break;
|
|
1727
|
+
}
|
|
1728
|
+
this.enabledReservationRuleProducts = [];
|
|
1729
|
+
if (this.store.resource) delete this.store.resource.requestEntryPax;
|
|
1730
|
+
_context27.next = 42;
|
|
1731
|
+
break;
|
|
1732
|
+
case 31:
|
|
1733
|
+
tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
|
|
1734
|
+
delete tempOrder.metadata.table_occupancy_duration;
|
|
1735
|
+
reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
|
|
1736
|
+
_context27.next = 36;
|
|
1737
|
+
return reservationProductList.initialize(this.core, {
|
|
1738
|
+
store: {
|
|
1739
|
+
list: [],
|
|
1740
|
+
selectProducts: []
|
|
1741
|
+
},
|
|
1742
|
+
otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
|
|
1743
|
+
fatherModule: this.name,
|
|
1744
|
+
openCache: Boolean(this.cacheId),
|
|
1745
|
+
cacheId: this.cacheId
|
|
1746
|
+
})
|
|
1747
|
+
});
|
|
1748
|
+
case 36:
|
|
1749
|
+
scheduleDate = dayjs().format('YYYY-MM-DD');
|
|
1750
|
+
scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
1751
|
+
_context27.next = 40;
|
|
1752
|
+
return reservationProductList.loadProducts({
|
|
1753
|
+
product_ids: reservationLinkIds,
|
|
1754
|
+
schedule_date: scheduleDate,
|
|
1755
|
+
schedule_datetime: scheduleDatetime,
|
|
1756
|
+
cacheId: this.cacheId
|
|
1757
|
+
});
|
|
1758
|
+
case 40:
|
|
1759
|
+
loaded = _context27.sent;
|
|
1760
|
+
if (Array.isArray(loaded)) {
|
|
1761
|
+
this.enabledReservationRuleProducts = loaded;
|
|
1762
|
+
occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
|
|
1763
|
+
if (occupancyMinutes !== undefined) {
|
|
1764
|
+
tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
|
|
1765
|
+
}
|
|
1766
|
+
if (hasCustomCapacityProduct(loaded)) {
|
|
1767
|
+
availabilityInfo.requestEntryPax = 1;
|
|
1768
|
+
if (this.store.resource) this.store.resource.requestEntryPax = 1;
|
|
1769
|
+
} else if (this.store.resource) {
|
|
1770
|
+
delete this.store.resource.requestEntryPax;
|
|
1771
|
+
}
|
|
1772
|
+
} else {
|
|
1773
|
+
this.enabledReservationRuleProducts = [];
|
|
1774
|
+
if (this.store.resource) delete this.store.resource.requestEntryPax;
|
|
1775
|
+
void this.addScanOrderLog({
|
|
1776
|
+
level: 'error',
|
|
1777
|
+
title: '[ScanOrder] enabled_reservation_rules product query failed',
|
|
1778
|
+
payload: {
|
|
1779
|
+
linkIds: reservationLinkIds,
|
|
1780
|
+
error: this.serializeError(loaded)
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
case 42:
|
|
1716
1785
|
(_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || _this$store$order4.persistTempOrder();
|
|
1717
1786
|
|
|
1718
1787
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
1719
1788
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
1720
|
-
_context27.next =
|
|
1789
|
+
_context27.next = 46;
|
|
1721
1790
|
break;
|
|
1722
1791
|
}
|
|
1723
|
-
_context27.next =
|
|
1792
|
+
_context27.next = 46;
|
|
1724
1793
|
return this.addNewOrder();
|
|
1725
|
-
case
|
|
1794
|
+
case 46:
|
|
1726
1795
|
// 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
|
|
1727
1796
|
if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
|
|
1728
1797
|
tempOrder.order_id = resourceState.lastOrderId;
|
|
1729
1798
|
}
|
|
1730
|
-
|
|
1799
|
+
if (!tempOrder.order_id) {
|
|
1800
|
+
_context27.next = 50;
|
|
1801
|
+
break;
|
|
1802
|
+
}
|
|
1803
|
+
_context27.next = 50;
|
|
1804
|
+
return (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getOrderInfoByRemote(tempOrder.order_id);
|
|
1805
|
+
case 50:
|
|
1806
|
+
_context27.next = 52;
|
|
1731
1807
|
return this.refreshItemRuleQuantityLimits();
|
|
1732
|
-
case
|
|
1733
|
-
_context27.next =
|
|
1808
|
+
case 52:
|
|
1809
|
+
_context27.next = 54;
|
|
1734
1810
|
return this.refreshCartValidationPassed();
|
|
1735
|
-
case
|
|
1811
|
+
case 54:
|
|
1736
1812
|
this.logMethodSuccess('checkResourceAvailable', {
|
|
1737
1813
|
resourceId: resourceId,
|
|
1738
1814
|
mode: availabilityInfo.mode,
|
|
@@ -1748,18 +1824,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1748
1824
|
isFull: resourceState.isFull
|
|
1749
1825
|
});
|
|
1750
1826
|
return _context27.abrupt("return", availabilityInfo);
|
|
1751
|
-
case
|
|
1752
|
-
_context27.prev =
|
|
1827
|
+
case 58:
|
|
1828
|
+
_context27.prev = 58;
|
|
1753
1829
|
_context27.t0 = _context27["catch"](1);
|
|
1754
1830
|
this.logMethodError('checkResourceAvailable', _context27.t0, {
|
|
1755
1831
|
resourceId: resourceId
|
|
1756
1832
|
});
|
|
1757
1833
|
throw _context27.t0;
|
|
1758
|
-
case
|
|
1834
|
+
case 62:
|
|
1759
1835
|
case "end":
|
|
1760
1836
|
return _context27.stop();
|
|
1761
1837
|
}
|
|
1762
|
-
}, _callee27, this, [[1,
|
|
1838
|
+
}, _callee27, this, [[1, 58]]);
|
|
1763
1839
|
}));
|
|
1764
1840
|
function checkResourceAvailable(_x10, _x11) {
|
|
1765
1841
|
return _checkResourceAvailable.apply(this, arguments);
|
|
@@ -1802,14 +1878,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1802
1878
|
key: "getProductList",
|
|
1803
1879
|
value: function () {
|
|
1804
1880
|
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1805
|
-
var _this$
|
|
1881
|
+
var _this$otherParams11;
|
|
1806
1882
|
var menu_list_ids, _this$store$products, res, formattedRes;
|
|
1807
1883
|
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
1808
1884
|
while (1) switch (_context29.prev = _context29.next) {
|
|
1809
1885
|
case 0:
|
|
1810
1886
|
this.logMethodStart('getProductList');
|
|
1811
1887
|
// 可以直接通过配置里的 menu 读取
|
|
1812
|
-
menu_list_ids = ((_this$
|
|
1888
|
+
menu_list_ids = ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 || (_this$otherParams11 = _this$otherParams11.dineInConfig) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11['menu.associated_menus'].map(function (n) {
|
|
1813
1889
|
return Number(n.value);
|
|
1814
1890
|
})) || [];
|
|
1815
1891
|
_context29.prev = 2;
|
|
@@ -121,6 +121,7 @@ export interface ScanOrderTempOrder {
|
|
|
121
121
|
holder: Record<string, any> | null;
|
|
122
122
|
summary: ScanOrderSummary;
|
|
123
123
|
metadata: Record<string, any>;
|
|
124
|
+
lastOrderInfo?: Record<string, any>;
|
|
124
125
|
}
|
|
125
126
|
export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platform' | 'products' | 'created_at' | 'summary' | 'surcharges'> {
|
|
126
127
|
platform: 'H5' | 'PC';
|
|
@@ -141,6 +142,8 @@ export interface ScanOrderAvailabilityInfo {
|
|
|
141
142
|
errorTips?: string;
|
|
142
143
|
policy?: string | null;
|
|
143
144
|
partyroom_booking?: string | null;
|
|
145
|
+
/** 预约规则关联商品存在 custom 容量时,由 checkResourceAvailable 置为 1 */
|
|
146
|
+
requestEntryPax?: number;
|
|
144
147
|
}
|
|
145
148
|
export interface ScanOrderTableSnackConfig {
|
|
146
149
|
snack?: boolean | number | string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderSummary, ScanOrderTempOrder } from './types';
|
|
2
2
|
import type { CartItemSummary, ItemRuleBusinessData, PaxInfo, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
3
3
|
import type { StrategyConfig } from '../../model/strategy/type';
|
|
4
|
+
import type { ProductData } from '../../modules/Product/types';
|
|
4
5
|
/**
|
|
5
6
|
* 构建金额全为 0 的空 summary。
|
|
6
7
|
* 作为尚未计算金额时的兜底默认值,避免下游因 undefined 报错。
|
|
@@ -91,3 +92,13 @@ export declare function getProductIdentityIndex(products: ScanOrderOrderProduct[
|
|
|
91
92
|
* - 保留 _origin 供后续业务流程(如促销规则)使用
|
|
92
93
|
*/
|
|
93
94
|
export declare function normalizeOrderProduct(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): ScanOrderOrderProduct;
|
|
95
|
+
/**
|
|
96
|
+
* 从 reservation.enabled_reservation_rules 中收集 type=link 的商品 id。
|
|
97
|
+
*/
|
|
98
|
+
export declare function collectLinkProductIdsFromReservationRules(rules: unknown): number[];
|
|
99
|
+
/**
|
|
100
|
+
* 返回列表中第一个带有效 duration.value(分钟)的商品时长。
|
|
101
|
+
*/
|
|
102
|
+
export declare function pickFirstDurationMinutesFromProducts(products: ProductData[]): number | undefined;
|
|
103
|
+
/** 是否存在 capacity.type === 'custom' 的商品 */
|
|
104
|
+
export declare function hasCustomCapacityProduct(products: ProductData[]): boolean;
|
|
@@ -394,4 +394,71 @@ export function normalizeOrderProduct(product) {
|
|
|
394
394
|
metadata: metadata,
|
|
395
395
|
_origin: product._origin
|
|
396
396
|
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* 从 reservation.enabled_reservation_rules 中收集 type=link 的商品 id。
|
|
401
|
+
*/
|
|
402
|
+
export function collectLinkProductIdsFromReservationRules(rules) {
|
|
403
|
+
if (!Array.isArray(rules)) return [];
|
|
404
|
+
var ids = [];
|
|
405
|
+
var _iterator6 = _createForOfIteratorHelper(rules),
|
|
406
|
+
_step6;
|
|
407
|
+
try {
|
|
408
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
409
|
+
var entry = _step6.value;
|
|
410
|
+
if (!entry || _typeof(entry) !== 'object') continue;
|
|
411
|
+
var rec = entry;
|
|
412
|
+
if (rec.type !== 'link') continue;
|
|
413
|
+
if (!Array.isArray(rec.value)) continue;
|
|
414
|
+
var _iterator7 = _createForOfIteratorHelper(rec.value),
|
|
415
|
+
_step7;
|
|
416
|
+
try {
|
|
417
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
418
|
+
var v = _step7.value;
|
|
419
|
+
var n = Number(v);
|
|
420
|
+
if (Number.isFinite(n) && n > 0) ids.push(Math.floor(n));
|
|
421
|
+
}
|
|
422
|
+
} catch (err) {
|
|
423
|
+
_iterator7.e(err);
|
|
424
|
+
} finally {
|
|
425
|
+
_iterator7.f();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
} catch (err) {
|
|
429
|
+
_iterator6.e(err);
|
|
430
|
+
} finally {
|
|
431
|
+
_iterator6.f();
|
|
432
|
+
}
|
|
433
|
+
return _toConsumableArray(new Set(ids));
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* 返回列表中第一个带有效 duration.value(分钟)的商品时长。
|
|
438
|
+
*/
|
|
439
|
+
export function pickFirstDurationMinutesFromProducts(products) {
|
|
440
|
+
var _iterator8 = _createForOfIteratorHelper(products),
|
|
441
|
+
_step8;
|
|
442
|
+
try {
|
|
443
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
444
|
+
var _product$duration;
|
|
445
|
+
var product = _step8.value;
|
|
446
|
+
var value = product === null || product === void 0 || (_product$duration = product.duration) === null || _product$duration === void 0 ? void 0 : _product$duration.value;
|
|
447
|
+
var n = Number(value);
|
|
448
|
+
if (Number.isFinite(n) && n > 0) return Math.floor(n);
|
|
449
|
+
}
|
|
450
|
+
} catch (err) {
|
|
451
|
+
_iterator8.e(err);
|
|
452
|
+
} finally {
|
|
453
|
+
_iterator8.f();
|
|
454
|
+
}
|
|
455
|
+
return undefined;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** 是否存在 capacity.type === 'custom' 的商品 */
|
|
459
|
+
export function hasCustomCapacityProduct(products) {
|
|
460
|
+
return products.some(function (p) {
|
|
461
|
+
var _p$capacity;
|
|
462
|
+
return (p === null || p === void 0 || (_p$capacity = p.capacity) === null || _p$capacity === void 0 ? void 0 : _p$capacity.type) === 'custom';
|
|
463
|
+
});
|
|
397
464
|
}
|
|
@@ -159,5 +159,15 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
159
159
|
private refreshCartValidationPassed;
|
|
160
160
|
setItemRuleRuntimeConfig(config?: VenueBookingItemRuleRuntimeConfig): Promise<void>;
|
|
161
161
|
getOtherParams(): Record<string, any>;
|
|
162
|
+
private static readonly UI_STATE_KEY_PREFIX;
|
|
163
|
+
private getUIStateBucketKey;
|
|
164
|
+
private readUIStateBucket;
|
|
165
|
+
private writeUIStateBucket;
|
|
166
|
+
setUIState(key: string, value: any): void;
|
|
167
|
+
getUIState<T = any>(key: string): T | undefined;
|
|
168
|
+
deleteUIState(key: string): void;
|
|
162
169
|
checkOpenDataAvailability(): Promise<OpenDataAvailabilityResult>;
|
|
170
|
+
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
171
|
+
cover?: boolean;
|
|
172
|
+
}): Promise<void>;
|
|
163
173
|
}
|