@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.
Files changed (117) hide show
  1. package/dist/core/index.d.ts +2 -0
  2. package/dist/core/index.js +7 -0
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +1 -1
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  12. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  13. package/dist/modules/OpenData/index.d.ts +2 -0
  14. package/dist/modules/OpenData/index.js +8 -0
  15. package/dist/modules/Order/index.d.ts +28 -8
  16. package/dist/modules/Order/index.js +907 -588
  17. package/dist/modules/Order/payment-utils.d.ts +26 -0
  18. package/dist/modules/Order/payment-utils.js +225 -0
  19. package/dist/modules/Order/types.d.ts +35 -1
  20. package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
  21. package/dist/modules/Order/utils.js +10 -6
  22. package/dist/modules/Payment/index.d.ts +2 -0
  23. package/dist/modules/Payment/index.js +78 -49
  24. package/dist/modules/Payment/types.d.ts +104 -25
  25. package/dist/modules/Payment/types.js +17 -0
  26. package/dist/modules/Payment/walletpass.d.ts +38 -1
  27. package/dist/modules/Payment/walletpass.js +917 -114
  28. package/dist/modules/Rules/index.d.ts +3 -0
  29. package/dist/modules/Rules/index.js +100 -70
  30. package/dist/server/index.d.ts +25 -0
  31. package/dist/server/index.js +1993 -1061
  32. package/dist/server/modules/index.d.ts +1 -1
  33. package/dist/server/modules/order/index.d.ts +70 -4
  34. package/dist/server/modules/order/index.js +1816 -728
  35. package/dist/server/modules/order/types.d.ts +25 -3
  36. package/dist/server/modules/order/types.js +7 -1
  37. package/dist/solution/BaseSales/index.d.ts +104 -5
  38. package/dist/solution/BaseSales/index.js +1767 -436
  39. package/dist/solution/BaseSales/types.d.ts +55 -1
  40. package/dist/solution/BaseSales/types.js +2 -1
  41. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  42. package/dist/solution/BaseSales/utils/cartPromotion.js +94 -32
  43. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  44. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +7 -4
  45. package/dist/solution/BookingByStep/index.d.ts +1 -1
  46. package/dist/solution/BookingTicket/index.d.ts +21 -5
  47. package/dist/solution/BookingTicket/index.js +139 -56
  48. package/dist/solution/BookingTicket/types.d.ts +1 -0
  49. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  50. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
  51. package/dist/solution/Sales/index.d.ts +2 -0
  52. package/dist/solution/Sales/index.js +26 -4
  53. package/dist/solution/ScanOrder/index.js +31 -20
  54. package/dist/solution/VenueBooking/index.d.ts +1 -0
  55. package/dist/solution/VenueBooking/index.js +30 -19
  56. package/dist/types/index.d.ts +1 -0
  57. package/dist/utils/payment-number.d.ts +9 -0
  58. package/dist/utils/payment-number.js +69 -0
  59. package/lib/core/index.d.ts +2 -0
  60. package/lib/core/index.js +4 -0
  61. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  62. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  63. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  64. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  65. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  66. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  67. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  68. package/lib/model/strategy/adapter/promotion/index.js +2 -0
  69. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  70. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  71. package/lib/modules/OpenData/index.d.ts +2 -0
  72. package/lib/modules/OpenData/index.js +5 -0
  73. package/lib/modules/Order/index.d.ts +28 -8
  74. package/lib/modules/Order/index.js +252 -84
  75. package/lib/modules/Order/payment-utils.d.ts +26 -0
  76. package/lib/modules/Order/payment-utils.js +224 -0
  77. package/lib/modules/Order/types.d.ts +35 -1
  78. package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
  79. package/lib/modules/Order/utils.js +11 -4
  80. package/lib/modules/Payment/index.d.ts +2 -0
  81. package/lib/modules/Payment/index.js +33 -12
  82. package/lib/modules/Payment/types.d.ts +104 -25
  83. package/lib/modules/Payment/types.js +1 -0
  84. package/lib/modules/Payment/walletpass.d.ts +38 -1
  85. package/lib/modules/Payment/walletpass.js +730 -21
  86. package/lib/modules/Rules/index.d.ts +3 -0
  87. package/lib/modules/Rules/index.js +38 -9
  88. package/lib/server/index.d.ts +25 -0
  89. package/lib/server/index.js +726 -31
  90. package/lib/server/modules/index.d.ts +1 -1
  91. package/lib/server/modules/order/index.d.ts +70 -4
  92. package/lib/server/modules/order/index.js +818 -69
  93. package/lib/server/modules/order/types.d.ts +25 -3
  94. package/lib/server/modules/order/types.js +1 -0
  95. package/lib/solution/BaseSales/index.d.ts +104 -5
  96. package/lib/solution/BaseSales/index.js +858 -27
  97. package/lib/solution/BaseSales/types.d.ts +55 -1
  98. package/lib/solution/BaseSales/types.js +2 -1
  99. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  100. package/lib/solution/BaseSales/utils/cartPromotion.js +66 -12
  101. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  102. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -3
  103. package/lib/solution/BookingByStep/index.d.ts +1 -1
  104. package/lib/solution/BookingTicket/index.d.ts +21 -5
  105. package/lib/solution/BookingTicket/index.js +64 -13
  106. package/lib/solution/BookingTicket/types.d.ts +1 -0
  107. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  108. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
  109. package/lib/solution/Sales/index.d.ts +2 -0
  110. package/lib/solution/Sales/index.js +20 -6
  111. package/lib/solution/ScanOrder/index.js +8 -0
  112. package/lib/solution/VenueBooking/index.d.ts +1 -0
  113. package/lib/solution/VenueBooking/index.js +8 -0
  114. package/lib/types/index.d.ts +1 -0
  115. package/lib/utils/payment-number.d.ts +9 -0
  116. package/lib/utils/payment-number.js +64 -0
  117. 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;
@@ -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
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.274",
4
+ "version": "2.2.276",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",