@pisell/pisellos 0.0.499 → 0.0.500
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/modules/Order/index.js +18 -2
- package/dist/modules/Order/utils.d.ts +3 -0
- package/dist/modules/Order/utils.js +26 -1
- package/dist/solution/VenueBooking/utils/slotMerge.js +1 -2
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.js +15 -1
- package/lib/modules/Order/utils.d.ts +3 -0
- package/lib/modules/Order/utils.js +22 -3
- package/lib/solution/VenueBooking/utils/slotMerge.js +1 -2
- package/package.json +1 -1
|
@@ -141,10 +141,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
141
141
|
}, {
|
|
142
142
|
key: "registerDiscountModules",
|
|
143
143
|
value: function registerDiscountModules(options) {
|
|
144
|
+
var _targetCacheData;
|
|
145
|
+
var targetCacheData = {};
|
|
146
|
+
if (this.cacheId && this.window) {
|
|
147
|
+
var sessionData = this.window.sessionStorage.getItem(this.name);
|
|
148
|
+
if (sessionData) {
|
|
149
|
+
try {
|
|
150
|
+
var data = JSON.parse(sessionData);
|
|
151
|
+
targetCacheData = (data === null || data === void 0 ? void 0 : data[this.cacheId]) || {};
|
|
152
|
+
} catch (_unused) {
|
|
153
|
+
// sessionStorage 损坏则忽略,按空 initialState 走
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
144
157
|
var discount = new DiscountModule("".concat(this.name, "_discount"));
|
|
145
158
|
this.core.registerModule(discount, {
|
|
159
|
+
initialState: (_targetCacheData = targetCacheData) === null || _targetCacheData === void 0 ? void 0 : _targetCacheData[discount.name],
|
|
146
160
|
otherParams: {
|
|
147
|
-
fatherModule: this.name
|
|
161
|
+
fatherModule: this.name,
|
|
162
|
+
openCache: !!this.cacheId,
|
|
163
|
+
cacheId: this.cacheId
|
|
148
164
|
}
|
|
149
165
|
});
|
|
150
166
|
this.store.discount = discount;
|
|
@@ -404,7 +420,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
404
420
|
return;
|
|
405
421
|
}
|
|
406
422
|
this.store.tempOrder = parsedData;
|
|
407
|
-
} catch (
|
|
423
|
+
} catch (_unused2) {
|
|
408
424
|
var _this$window;
|
|
409
425
|
(_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.localStorage) === null || _this$window === void 0 || _this$window.removeItem(key);
|
|
410
426
|
}
|
|
@@ -25,6 +25,9 @@ export declare const getAllDiscountList: (cartItem: CartItem) => any;
|
|
|
25
25
|
export declare function createUuidV4(): string;
|
|
26
26
|
export declare function isTempOrder(data: any): data is ScanOrderTempOrder;
|
|
27
27
|
export declare function formatDateTime(date: Date): string;
|
|
28
|
+
export declare function normalizeSubmitBooking<T extends {
|
|
29
|
+
metadata?: Record<string, any>;
|
|
30
|
+
}>(booking: T): T;
|
|
28
31
|
export declare function createDefaultTempOrder(params: {
|
|
29
32
|
now: string;
|
|
30
33
|
summary?: ScanOrderSummary;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var _excluded = ["_origin", "identity_key"],
|
|
2
2
|
_excluded2 = ["created_at", "summary", "surcharges"];
|
|
3
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
6
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -133,6 +134,28 @@ function normalizeSubmitProduct(product) {
|
|
|
133
134
|
metadata: cleanMetadata
|
|
134
135
|
});
|
|
135
136
|
}
|
|
137
|
+
var SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax'];
|
|
138
|
+
export function normalizeSubmitBooking(booking) {
|
|
139
|
+
var rawMetadata = booking.metadata || {};
|
|
140
|
+
var cleanMetadata = {};
|
|
141
|
+
var _iterator = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
|
|
142
|
+
_step;
|
|
143
|
+
try {
|
|
144
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
145
|
+
var key = _step.value;
|
|
146
|
+
if (rawMetadata[key] !== undefined) {
|
|
147
|
+
cleanMetadata[key] = rawMetadata[key];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
} catch (err) {
|
|
151
|
+
_iterator.e(err);
|
|
152
|
+
} finally {
|
|
153
|
+
_iterator.f();
|
|
154
|
+
}
|
|
155
|
+
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
156
|
+
metadata: cleanMetadata
|
|
157
|
+
});
|
|
158
|
+
}
|
|
136
159
|
var DEFAULT_TABLE_OCCUPANCY_DURATION = 20;
|
|
137
160
|
function resolveTableOccupancyDuration(tempOrder) {
|
|
138
161
|
var _metadata$table_confi, _metadata$tableConfig, _metadata$resource_co, _metadata$resourceCon;
|
|
@@ -254,7 +277,9 @@ export function buildSubmitPayload(params) {
|
|
|
254
277
|
surcharge_fee: summary.surcharge_fee || tempOrder.surcharge_fee || '0.00',
|
|
255
278
|
note: tempOrder.note || '',
|
|
256
279
|
schedule_date: scheduleDate,
|
|
257
|
-
bookings: bookings
|
|
280
|
+
bookings: bookings.map(function (booking) {
|
|
281
|
+
return normalizeSubmitBooking(booking);
|
|
282
|
+
}),
|
|
258
283
|
payments: tempOrder.payments || [],
|
|
259
284
|
// discount_list: tempOrder.discount_list || [],
|
|
260
285
|
relation_forms: tempOrder.relation_forms || [],
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
});
|
|
@@ -131,10 +131,24 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
131
131
|
}
|
|
132
132
|
// ─── Discount: 子模块注册 ───
|
|
133
133
|
registerDiscountModules(options) {
|
|
134
|
+
let targetCacheData = {};
|
|
135
|
+
if (this.cacheId && this.window) {
|
|
136
|
+
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
137
|
+
if (sessionData) {
|
|
138
|
+
try {
|
|
139
|
+
const data = JSON.parse(sessionData);
|
|
140
|
+
targetCacheData = (data == null ? void 0 : data[this.cacheId]) || {};
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
134
145
|
const discount = new import_Discount.DiscountModule(`${this.name}_discount`);
|
|
135
146
|
this.core.registerModule(discount, {
|
|
147
|
+
initialState: targetCacheData == null ? void 0 : targetCacheData[discount.name],
|
|
136
148
|
otherParams: {
|
|
137
|
-
fatherModule: this.name
|
|
149
|
+
fatherModule: this.name,
|
|
150
|
+
openCache: !!this.cacheId,
|
|
151
|
+
cacheId: this.cacheId
|
|
138
152
|
}
|
|
139
153
|
});
|
|
140
154
|
this.store.discount = discount;
|
|
@@ -25,6 +25,9 @@ export declare const getAllDiscountList: (cartItem: CartItem) => any;
|
|
|
25
25
|
export declare function createUuidV4(): string;
|
|
26
26
|
export declare function isTempOrder(data: any): data is ScanOrderTempOrder;
|
|
27
27
|
export declare function formatDateTime(date: Date): string;
|
|
28
|
+
export declare function normalizeSubmitBooking<T extends {
|
|
29
|
+
metadata?: Record<string, any>;
|
|
30
|
+
}>(booking: T): T;
|
|
28
31
|
export declare function createDefaultTempOrder(params: {
|
|
29
32
|
now: string;
|
|
30
33
|
summary?: ScanOrderSummary;
|
|
@@ -38,7 +38,8 @@ __export(utils_exports, {
|
|
|
38
38
|
generateDuration: () => generateDuration,
|
|
39
39
|
getAllDiscountList: () => getAllDiscountList,
|
|
40
40
|
isTempOrder: () => isTempOrder,
|
|
41
|
-
mergeRelationForms: () => mergeRelationForms
|
|
41
|
+
mergeRelationForms: () => mergeRelationForms,
|
|
42
|
+
normalizeSubmitBooking: () => normalizeSubmitBooking
|
|
42
43
|
});
|
|
43
44
|
module.exports = __toCommonJS(utils_exports);
|
|
44
45
|
var import_dayjs = __toESM(require("dayjs"));
|
|
@@ -132,6 +133,23 @@ function normalizeSubmitProduct(product) {
|
|
|
132
133
|
metadata: cleanMetadata
|
|
133
134
|
};
|
|
134
135
|
}
|
|
136
|
+
var SUBMIT_BOOKING_METADATA_WHITELIST = [
|
|
137
|
+
"unique_identification_number",
|
|
138
|
+
"collect_pax"
|
|
139
|
+
];
|
|
140
|
+
function normalizeSubmitBooking(booking) {
|
|
141
|
+
const rawMetadata = booking.metadata || {};
|
|
142
|
+
const cleanMetadata = {};
|
|
143
|
+
for (const key of SUBMIT_BOOKING_METADATA_WHITELIST) {
|
|
144
|
+
if (rawMetadata[key] !== void 0) {
|
|
145
|
+
cleanMetadata[key] = rawMetadata[key];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
...booking,
|
|
150
|
+
metadata: cleanMetadata
|
|
151
|
+
};
|
|
152
|
+
}
|
|
135
153
|
var DEFAULT_TABLE_OCCUPANCY_DURATION = 20;
|
|
136
154
|
function resolveTableOccupancyDuration(tempOrder) {
|
|
137
155
|
var _a, _b, _c, _d;
|
|
@@ -255,7 +273,7 @@ function buildSubmitPayload(params) {
|
|
|
255
273
|
surcharge_fee: summary.surcharge_fee || tempOrder.surcharge_fee || "0.00",
|
|
256
274
|
note: tempOrder.note || "",
|
|
257
275
|
schedule_date: scheduleDate,
|
|
258
|
-
bookings,
|
|
276
|
+
bookings: bookings.map((booking) => normalizeSubmitBooking(booking)),
|
|
259
277
|
payments: tempOrder.payments || [],
|
|
260
278
|
// discount_list: tempOrder.discount_list || [],
|
|
261
279
|
relation_forms: tempOrder.relation_forms || [],
|
|
@@ -298,5 +316,6 @@ function formatV1Product(products) {
|
|
|
298
316
|
generateDuration,
|
|
299
317
|
getAllDiscountList,
|
|
300
318
|
isTempOrder,
|
|
301
|
-
mergeRelationForms
|
|
319
|
+
mergeRelationForms,
|
|
320
|
+
normalizeSubmitBooking
|
|
302
321
|
});
|