@pisell/pisellos 2.2.274 → 2.2.276
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/core/index.d.ts +2 -0
- package/dist/core/index.js +7 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/OpenData/index.d.ts +2 -0
- package/dist/modules/OpenData/index.js +8 -0
- package/dist/modules/Order/index.d.ts +28 -8
- package/dist/modules/Order/index.js +907 -588
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/payment-utils.js +225 -0
- package/dist/modules/Order/types.d.ts +35 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
- package/dist/modules/Order/utils.js +10 -6
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +78 -49
- package/dist/modules/Payment/types.d.ts +104 -25
- package/dist/modules/Payment/types.js +17 -0
- package/dist/modules/Payment/walletpass.d.ts +38 -1
- package/dist/modules/Payment/walletpass.js +917 -114
- package/dist/modules/Rules/index.d.ts +3 -0
- package/dist/modules/Rules/index.js +100 -70
- package/dist/server/index.d.ts +25 -0
- package/dist/server/index.js +1993 -1061
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +70 -4
- package/dist/server/modules/order/index.js +1816 -728
- package/dist/server/modules/order/types.d.ts +25 -3
- package/dist/server/modules/order/types.js +7 -1
- package/dist/solution/BaseSales/index.d.ts +104 -5
- package/dist/solution/BaseSales/index.js +1767 -436
- package/dist/solution/BaseSales/types.d.ts +55 -1
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +94 -32
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +7 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +21 -5
- package/dist/solution/BookingTicket/index.js +139 -56
- package/dist/solution/BookingTicket/types.d.ts +1 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
- package/dist/solution/Sales/index.d.ts +2 -0
- package/dist/solution/Sales/index.js +26 -4
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +30 -19
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +2 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/OpenData/index.d.ts +2 -0
- package/lib/modules/OpenData/index.js +5 -0
- package/lib/modules/Order/index.d.ts +28 -8
- package/lib/modules/Order/index.js +252 -84
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/payment-utils.js +224 -0
- package/lib/modules/Order/types.d.ts +35 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
- package/lib/modules/Order/utils.js +11 -4
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +33 -12
- package/lib/modules/Payment/types.d.ts +104 -25
- package/lib/modules/Payment/types.js +1 -0
- package/lib/modules/Payment/walletpass.d.ts +38 -1
- package/lib/modules/Payment/walletpass.js +730 -21
- package/lib/modules/Rules/index.d.ts +3 -0
- package/lib/modules/Rules/index.js +38 -9
- package/lib/server/index.d.ts +25 -0
- package/lib/server/index.js +726 -31
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +70 -4
- package/lib/server/modules/order/index.js +818 -69
- package/lib/server/modules/order/types.d.ts +25 -3
- package/lib/server/modules/order/types.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +104 -5
- package/lib/solution/BaseSales/index.js +858 -27
- package/lib/solution/BaseSales/types.d.ts +55 -1
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +66 -12
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +21 -5
- package/lib/solution/BookingTicket/index.js +64 -13
- package/lib/solution/BookingTicket/types.d.ts +1 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
- package/lib/solution/Sales/index.d.ts +2 -0
- package/lib/solution/Sales/index.js +20 -6
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +8 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
|
@@ -39,6 +39,7 @@ var import_dayjs = __toESM(require("dayjs"));
|
|
|
39
39
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
40
40
|
var import_types = require("./types");
|
|
41
41
|
__reExport(Sales_exports, require("./types"), module.exports);
|
|
42
|
+
var UNPAID_PAYMENT_STATUSES = /* @__PURE__ */ new Set(["unpaid", "partially_paid", "payment_processing"]);
|
|
42
43
|
var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
43
44
|
// LoggerManager 实例
|
|
44
45
|
constructor(name, version) {
|
|
@@ -258,6 +259,9 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
258
259
|
var _a;
|
|
259
260
|
return String(((_a = booking.order) == null ? void 0 : _a.payment_status) ?? "");
|
|
260
261
|
}
|
|
262
|
+
isUnpaidBooking(booking) {
|
|
263
|
+
return UNPAID_PAYMENT_STATUSES.has(this.getBookingOrderPaymentStatus(booking));
|
|
264
|
+
}
|
|
261
265
|
countBookingOrders(bookings) {
|
|
262
266
|
const orderIds = /* @__PURE__ */ new Set();
|
|
263
267
|
bookings.forEach((booking) => {
|
|
@@ -312,8 +316,9 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
312
316
|
* 2) 若无 active,返回已超时且仍占用中的预约(允许并发多条)
|
|
313
317
|
* 3) 若仍无,返回最近一组未来预约(同 start_time 的并发预约全部返回)
|
|
314
318
|
* 4) 最后兜底返回一条(避免资源有历史预约时完全无反馈)
|
|
319
|
+
* - includeAllFuture 时,保留选中预约并返回当天全部后续预约;仅详情接口启用。
|
|
315
320
|
*/
|
|
316
|
-
pickBookingsForCurrentPoint(current, bookings) {
|
|
321
|
+
pickBookingsForCurrentPoint(current, bookings, options = {}) {
|
|
317
322
|
if (bookings.length === 0)
|
|
318
323
|
return [];
|
|
319
324
|
const currentDayStart = current.startOf("day");
|
|
@@ -330,6 +335,13 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
330
335
|
const appendNextStartGroupIfNeeded = (selectedBookings) => {
|
|
331
336
|
if (selectedBookings.length === 0)
|
|
332
337
|
return selectedBookings;
|
|
338
|
+
if (options.includeAllFuture) {
|
|
339
|
+
const allFutureBookings = dayScopedBookings.filter((booking) => {
|
|
340
|
+
const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
|
|
341
|
+
return startAt.isValid() && startAt.isAfter(current);
|
|
342
|
+
});
|
|
343
|
+
return [...selectedBookings, ...allFutureBookings];
|
|
344
|
+
}
|
|
333
345
|
const shouldAppendNextGroup = selectedBookings.some(
|
|
334
346
|
(booking) => booking.status === "reserved" || booking.status === "occupied"
|
|
335
347
|
);
|
|
@@ -380,6 +392,8 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
380
392
|
return startAt.isValid() && startAt.isAfter(current) && startAt.isSame(current, "day");
|
|
381
393
|
});
|
|
382
394
|
if (upcoming.length > 0) {
|
|
395
|
+
if (options.includeAllFuture)
|
|
396
|
+
return upcoming;
|
|
383
397
|
const firstStartAt = this.toBookingDateTime(upcoming[0].start_date, upcoming[0].start_time).valueOf();
|
|
384
398
|
const upcomingStartGroup = upcoming.filter((booking) => {
|
|
385
399
|
const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
|
|
@@ -631,12 +645,11 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
631
645
|
const completedBookingList = matchedBookingList.filter(
|
|
632
646
|
(booking) => this.getBookingAppointmentStatus(booking) === "completed"
|
|
633
647
|
);
|
|
634
|
-
const unpaidBookingList = matchedBookingList.filter(
|
|
635
|
-
(booking) => this.getBookingOrderPaymentStatus(booking) === "unpaid" || this.getBookingOrderPaymentStatus(booking) === "payment_processing"
|
|
636
|
-
);
|
|
648
|
+
const unpaidBookingList = matchedBookingList.filter((booking) => this.isUnpaidBooking(booking));
|
|
637
649
|
const bookings = this.pickBookingsForCurrentPoint(
|
|
638
650
|
current,
|
|
639
|
-
this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList)
|
|
651
|
+
this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList),
|
|
652
|
+
{ includeAllFuture: true }
|
|
640
653
|
);
|
|
641
654
|
const completedBookings = completedBookingList.map((booking) => {
|
|
642
655
|
return {
|
|
@@ -652,7 +665,8 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
652
665
|
});
|
|
653
666
|
const unpaidBookings = this.pickBookingsForCurrentPoint(
|
|
654
667
|
current,
|
|
655
|
-
this.normalizeResourceBookings(current, deviceCurrent, unpaidBookingList)
|
|
668
|
+
this.normalizeResourceBookings(current, deviceCurrent, unpaidBookingList),
|
|
669
|
+
{ includeAllFuture: true }
|
|
656
670
|
);
|
|
657
671
|
const orderCount = this.countBookingOrders(statsBookingList);
|
|
658
672
|
const bookingCount = statsBookingList.length;
|
|
@@ -48,6 +48,10 @@ var import_utils2 = require("../../modules/Order/utils");
|
|
|
48
48
|
var import_dayjs = __toESM(require("dayjs"));
|
|
49
49
|
var import_itemRule = require("../../model/strategy/adapter/itemRule");
|
|
50
50
|
__reExport(ScanOrder_exports, require("./types"), module.exports);
|
|
51
|
+
function isItemRewardProductDiscount(discount) {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
54
|
+
}
|
|
51
55
|
var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
52
56
|
constructor(name, version) {
|
|
53
57
|
super(name, version);
|
|
@@ -742,6 +746,10 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
742
746
|
for (const product of tempOrder.products) {
|
|
743
747
|
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
744
748
|
continue;
|
|
749
|
+
if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
|
|
750
|
+
product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
745
753
|
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
746
754
|
var _a2;
|
|
747
755
|
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
@@ -152,6 +152,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
152
152
|
private recalculateOrderPricesFromQuotation;
|
|
153
153
|
scanCode(code: string, customerId?: number): Promise<{
|
|
154
154
|
isAvailable: boolean;
|
|
155
|
+
isAccepted?: boolean | undefined;
|
|
155
156
|
discountList: import("../../modules/Discount").Discount[];
|
|
156
157
|
type: "server" | "clientCalc";
|
|
157
158
|
unavailableReason?: import("../../modules/Rules/types").UnavailableReason | undefined;
|
|
@@ -65,6 +65,10 @@ var OPEN_DATA_SECTION_CODES = [
|
|
|
65
65
|
"workflow",
|
|
66
66
|
"checkout"
|
|
67
67
|
];
|
|
68
|
+
function isItemRewardProductDiscount(discount) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
71
|
+
}
|
|
68
72
|
function cloneCustomDepositData(customDepositData) {
|
|
69
73
|
if (!customDepositData || typeof customDepositData !== "object")
|
|
70
74
|
return void 0;
|
|
@@ -1339,6 +1343,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1339
1343
|
for (const product of tempOrder.products) {
|
|
1340
1344
|
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
1341
1345
|
continue;
|
|
1346
|
+
if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
|
|
1347
|
+
product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1342
1350
|
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
1343
1351
|
var _a2;
|
|
1344
1352
|
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export interface PisellCore {
|
|
|
47
47
|
getModule: <T extends Module>(name: string) => T | null;
|
|
48
48
|
getModuleExports: <T = any>(name: string) => T | null;
|
|
49
49
|
hasModule: (name: string) => boolean;
|
|
50
|
+
getModuleNames: () => string[];
|
|
50
51
|
effects: {
|
|
51
52
|
on: (event: string, callback: (payload: any) => void) => () => void;
|
|
52
53
|
once: (event: string, callback: (payload: any) => void) => () => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PaymentNumberAppDataGetter = (key: string) => unknown;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the synchronous fallback without caching runtime device data.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData: PaymentNumberAppDataGetter): string;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the latest device segment when a new payment number is generated.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolvePaymentNumberDevicePrefix(getAppData: PaymentNumberAppDataGetter): Promise<string>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/payment-number.ts
|
|
20
|
+
var payment_number_exports = {};
|
|
21
|
+
__export(payment_number_exports, {
|
|
22
|
+
resolvePaymentNumberDevicePrefix: () => resolvePaymentNumberDevicePrefix,
|
|
23
|
+
resolvePaymentNumberDevicePrefixFromDeviceId: () => resolvePaymentNumberDevicePrefixFromDeviceId
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(payment_number_exports);
|
|
26
|
+
function normalizeNonEmptyString(value) {
|
|
27
|
+
if (value === void 0 || value === null)
|
|
28
|
+
return null;
|
|
29
|
+
if (typeof value !== "string" && typeof value !== "number")
|
|
30
|
+
return null;
|
|
31
|
+
if (typeof value === "number" && !Number.isFinite(value))
|
|
32
|
+
return null;
|
|
33
|
+
const normalized = String(value).trim();
|
|
34
|
+
return normalized || null;
|
|
35
|
+
}
|
|
36
|
+
function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData) {
|
|
37
|
+
try {
|
|
38
|
+
const deviceId = normalizeNonEmptyString(getAppData("device_id"));
|
|
39
|
+
if (deviceId && deviceId !== "0")
|
|
40
|
+
return deviceId.slice(-2);
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
return "LOCAL";
|
|
44
|
+
}
|
|
45
|
+
async function resolvePaymentNumberDevicePrefix(getAppData) {
|
|
46
|
+
try {
|
|
47
|
+
const getAsyncIotDeviceInfo = getAppData("async_iot_device_info");
|
|
48
|
+
if (typeof getAsyncIotDeviceInfo === "function") {
|
|
49
|
+
const info = await getAsyncIotDeviceInfo();
|
|
50
|
+
const shortNumber = normalizeNonEmptyString(
|
|
51
|
+
info == null ? void 0 : info.short_number
|
|
52
|
+
);
|
|
53
|
+
if (shortNumber && shortNumber !== "0")
|
|
54
|
+
return shortNumber;
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
return resolvePaymentNumberDevicePrefixFromDeviceId(getAppData);
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
resolvePaymentNumberDevicePrefix,
|
|
63
|
+
resolvePaymentNumberDevicePrefixFromDeviceId
|
|
64
|
+
});
|