@pisell/pisellos 0.10.2 → 0.10.4

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 (139) 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 +0 -9
  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/BaseModule.d.ts +1 -0
  14. package/dist/modules/BaseModule.js +24 -28
  15. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
  16. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
  17. package/dist/modules/OpenData/index.d.ts +2 -0
  18. package/dist/modules/OpenData/index.js +8 -0
  19. package/dist/modules/Order/index.d.ts +41 -10
  20. package/dist/modules/Order/index.js +943 -546
  21. package/dist/modules/Order/payment-utils.d.ts +26 -0
  22. package/dist/modules/Order/payment-utils.js +225 -0
  23. package/dist/modules/Order/types.d.ts +43 -2
  24. package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
  25. package/dist/modules/Order/utils.js +10 -6
  26. package/dist/modules/Payment/index.d.ts +2 -0
  27. package/dist/modules/Payment/index.js +79 -50
  28. package/dist/modules/Payment/types.d.ts +107 -28
  29. package/dist/modules/Payment/types.js +20 -3
  30. package/dist/modules/Payment/walletpass.d.ts +38 -1
  31. package/dist/modules/Payment/walletpass.js +917 -114
  32. package/dist/modules/ProductList/index.js +1 -1
  33. package/dist/modules/Rules/index.d.ts +3 -0
  34. package/dist/modules/Rules/index.js +130 -99
  35. package/dist/server/index.d.ts +16 -0
  36. package/dist/server/index.js +2084 -1188
  37. package/dist/server/modules/index.d.ts +1 -1
  38. package/dist/server/modules/order/index.d.ts +70 -4
  39. package/dist/server/modules/order/index.js +1816 -728
  40. package/dist/server/modules/order/types.d.ts +25 -3
  41. package/dist/server/modules/order/types.js +7 -1
  42. package/dist/solution/BaseSales/index.d.ts +114 -14
  43. package/dist/solution/BaseSales/index.js +1848 -478
  44. package/dist/solution/BaseSales/types.d.ts +55 -1
  45. package/dist/solution/BaseSales/types.js +2 -1
  46. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  47. package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
  48. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  49. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
  50. package/dist/solution/BookingByStep/index.d.ts +1 -1
  51. package/dist/solution/BookingTicket/index.d.ts +8 -16
  52. package/dist/solution/BookingTicket/index.js +138 -52
  53. package/dist/solution/BookingTicket/types.d.ts +1 -0
  54. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
  55. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  56. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
  57. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  58. package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
  59. package/dist/solution/Sales/index.d.ts +1 -0
  60. package/dist/solution/Sales/index.js +10 -2
  61. package/dist/solution/ScanOrder/index.js +31 -20
  62. package/dist/solution/UnifiedBookingSales/index.d.ts +3 -0
  63. package/dist/solution/UnifiedBookingSales/index.js +392 -304
  64. package/dist/solution/UnifiedBookingSales/types.d.ts +7 -0
  65. package/dist/solution/VenueBooking/index.d.ts +1 -0
  66. package/dist/solution/VenueBooking/index.js +34 -24
  67. package/dist/types/index.d.ts +1 -0
  68. package/dist/utils/payment-number.d.ts +9 -0
  69. package/dist/utils/payment-number.js +69 -0
  70. package/lib/core/index.d.ts +2 -0
  71. package/lib/core/index.js +4 -0
  72. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  73. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  74. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  75. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  76. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  77. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  78. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  79. package/lib/model/strategy/adapter/promotion/index.js +2 -0
  80. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  81. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  82. package/lib/modules/BaseModule.d.ts +1 -0
  83. package/lib/modules/BaseModule.js +24 -37
  84. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  85. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  86. package/lib/modules/OpenData/index.d.ts +2 -0
  87. package/lib/modules/OpenData/index.js +5 -0
  88. package/lib/modules/Order/index.d.ts +41 -10
  89. package/lib/modules/Order/index.js +322 -86
  90. package/lib/modules/Order/payment-utils.d.ts +26 -0
  91. package/lib/modules/Order/payment-utils.js +224 -0
  92. package/lib/modules/Order/types.d.ts +43 -2
  93. package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
  94. package/lib/modules/Order/utils.js +11 -4
  95. package/lib/modules/Payment/index.d.ts +2 -0
  96. package/lib/modules/Payment/index.js +34 -13
  97. package/lib/modules/Payment/types.d.ts +107 -28
  98. package/lib/modules/Payment/types.js +4 -3
  99. package/lib/modules/Payment/walletpass.d.ts +38 -1
  100. package/lib/modules/Payment/walletpass.js +730 -21
  101. package/lib/modules/ProductList/index.js +9 -1
  102. package/lib/modules/Rules/index.d.ts +3 -0
  103. package/lib/modules/Rules/index.js +39 -10
  104. package/lib/server/index.d.ts +16 -0
  105. package/lib/server/index.js +677 -28
  106. package/lib/server/modules/index.d.ts +1 -1
  107. package/lib/server/modules/order/index.d.ts +70 -4
  108. package/lib/server/modules/order/index.js +818 -69
  109. package/lib/server/modules/order/types.d.ts +25 -3
  110. package/lib/server/modules/order/types.js +1 -0
  111. package/lib/solution/BaseSales/index.d.ts +114 -14
  112. package/lib/solution/BaseSales/index.js +907 -58
  113. package/lib/solution/BaseSales/types.d.ts +55 -1
  114. package/lib/solution/BaseSales/types.js +2 -1
  115. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  116. package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
  117. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  118. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
  119. package/lib/solution/BookingByStep/index.d.ts +1 -1
  120. package/lib/solution/BookingTicket/index.d.ts +8 -16
  121. package/lib/solution/BookingTicket/index.js +63 -9
  122. package/lib/solution/BookingTicket/types.d.ts +1 -0
  123. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
  124. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  125. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
  126. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  127. package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
  128. package/lib/solution/Sales/index.d.ts +1 -0
  129. package/lib/solution/Sales/index.js +5 -3
  130. package/lib/solution/ScanOrder/index.js +8 -0
  131. package/lib/solution/UnifiedBookingSales/index.d.ts +3 -0
  132. package/lib/solution/UnifiedBookingSales/index.js +48 -2
  133. package/lib/solution/UnifiedBookingSales/types.d.ts +7 -0
  134. package/lib/solution/VenueBooking/index.d.ts +1 -0
  135. package/lib/solution/VenueBooking/index.js +13 -6
  136. package/lib/types/index.d.ts +1 -0
  137. package/lib/utils/payment-number.d.ts +9 -0
  138. package/lib/utils/payment-number.js +64 -0
  139. package/package.json +1 -1
@@ -0,0 +1,63 @@
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/solution/BookingTicket/utils/weighingProductSku.ts
20
+ var weighingProductSku_exports = {};
21
+ __export(weighingProductSku_exports, {
22
+ buildProductSkuFromCacheItem: () => buildProductSkuFromCacheItem
23
+ });
24
+ module.exports = __toCommonJS(weighingProductSku_exports);
25
+ var WEIGHT_UNIT_MAP = {
26
+ KILOGRAMS: "kg",
27
+ GRAMS: "g",
28
+ POUNDS: "lb",
29
+ OUNCES: "oz"
30
+ };
31
+ function isRecord(value) {
32
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
33
+ }
34
+ function buildProductSkuFromCacheItem(cacheItem) {
35
+ var _a, _b, _c, _d;
36
+ const currentSku = isRecord(cacheItem == null ? void 0 : cacheItem.product_sku) ? cacheItem.product_sku : void 0;
37
+ const weighing = isRecord((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.weighing) ? (_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.weighing : void 0;
38
+ const hasRuntimeWeighingSku = Number((currentSku == null ? void 0 : currentSku.open_sold_weight) || 0) === 1 && ((currentSku == null ? void 0 : currentSku.weight) !== void 0 || (currentSku == null ? void 0 : currentSku.net_weight) !== void 0 || (currentSku == null ? void 0 : currentSku.weight_source) !== void 0);
39
+ const isWeighingSku = Number((currentSku == null ? void 0 : currentSku.open_sold_weight) || 0) === 1;
40
+ if (!isWeighingSku && !weighing)
41
+ return void 0;
42
+ if (hasRuntimeWeighingSku)
43
+ return { ...currentSku };
44
+ if (!weighing)
45
+ return currentSku ? { ...currentSku } : void 0;
46
+ return {
47
+ ...currentSku || {},
48
+ open_sold_weight: 1,
49
+ unit_data_snapshot: weighing.scalePriceProduct,
50
+ unit: WEIGHT_UNIT_MAP[String(weighing.unit)] || weighing.unit,
51
+ unit_weight: weighing.unit_weight ?? "1.000",
52
+ unit_price: weighing.unit_price,
53
+ weight_source: weighing.mode,
54
+ tare_name: ((_c = weighing.tare) == null ? void 0 : _c.label) ?? "",
55
+ tare_weight: ((_d = weighing.tare) == null ? void 0 : _d.value) ?? 0,
56
+ weight: weighing.weight ?? 0,
57
+ net_weight: weighing.net_weight ?? 0
58
+ };
59
+ }
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ buildProductSkuFromCacheItem
63
+ });
@@ -83,6 +83,7 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
83
83
  private getBookingAppointmentStatus;
84
84
  private isBookingIncludedInStats;
85
85
  private getBookingOrderPaymentStatus;
86
+ private isUnpaidBooking;
86
87
  private countBookingOrders;
87
88
  private countCompletedBookings;
88
89
  private groupBookingsByResource;
@@ -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) => {
@@ -631,9 +635,7 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
631
635
  const completedBookingList = matchedBookingList.filter(
632
636
  (booking) => this.getBookingAppointmentStatus(booking) === "completed"
633
637
  );
634
- const unpaidBookingList = matchedBookingList.filter(
635
- (booking) => this.getBookingOrderPaymentStatus(booking) === "unpaid" || this.getBookingOrderPaymentStatus(booking) === "payment_processing"
636
- );
638
+ const unpaidBookingList = matchedBookingList.filter((booking) => this.isUnpaidBooking(booking));
637
639
  const bookings = this.pickBookingsForCurrentPoint(
638
640
  current,
639
641
  this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList)
@@ -47,6 +47,10 @@ var import_utils2 = require("../../modules/Order/utils");
47
47
  var import_dayjs = __toESM(require("dayjs"));
48
48
  var import_itemRule = require("../../model/strategy/adapter/itemRule");
49
49
  __reExport(ScanOrder_exports, require("./types"), module.exports);
50
+ function isItemRewardProductDiscount(discount) {
51
+ var _a, _b;
52
+ 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";
53
+ }
50
54
  var _ScanOrderImpl = class extends import_BaseSales.BaseSalesImpl {
51
55
  constructor(name, version) {
52
56
  super(name, version);
@@ -699,6 +703,10 @@ var _ScanOrderImpl = class extends import_BaseSales.BaseSalesImpl {
699
703
  for (const product of tempOrder.products) {
700
704
  if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
701
705
  continue;
706
+ if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
707
+ product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
708
+ continue;
709
+ }
702
710
  product.discount_list = (product.discount_list || []).filter((pd) => {
703
711
  var _a2;
704
712
  const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
@@ -63,6 +63,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
63
63
  private openDataTarget;
64
64
  private loadOpenDataInFlight;
65
65
  private loadOpenDataInFlightTarget;
66
+ protected isSessionStoragePersistEnabled(): boolean;
67
+ protected shouldUseSessionStorageForSubModule(moduleName?: string): boolean;
66
68
  /**
67
69
  * Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
68
70
  * 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
@@ -72,6 +74,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
72
74
  protected getDefaultCheckoutSmallTicketDataFlag(): number;
73
75
  protected getRegisteredModuleNames(): readonly string[];
74
76
  protected createSubModule(moduleName: string): Module | null;
77
+ addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
75
78
  /**
76
79
  * Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
77
80
  * business/channel target so a reused solution instance cannot leak another entry's menus.
@@ -447,6 +447,15 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
447
447
  this.loadOpenDataInFlight = null;
448
448
  this.loadOpenDataInFlightTarget = null;
449
449
  }
450
+ isSessionStoragePersistEnabled() {
451
+ var _a;
452
+ return Boolean(
453
+ this.cacheId && ((_a = this.otherParams) == null ? void 0 : _a.enableSessionStoragePersist) === true
454
+ );
455
+ }
456
+ shouldUseSessionStorageForSubModule(moduleName) {
457
+ return this.isSessionStoragePersistEnabled() && moduleName === "order";
458
+ }
450
459
  /**
451
460
  * Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
452
461
  * 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
@@ -472,6 +481,35 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
472
481
  }
473
482
  return super.createSubModule(moduleName);
474
483
  }
484
+ async addNewOrder() {
485
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
486
+ const sessionRecord = this.isSessionStoragePersistEnabled() ? (_b = (_a = this.store.order) == null ? void 0 : _a.consumeSessionStorageRestore) == null ? void 0 : _b.call(_a) : null;
487
+ if (!sessionRecord)
488
+ return super.addNewOrder();
489
+ await this.loadSalesDetail({
490
+ preloadedSalesDetail: sessionRecord,
491
+ hydrateSource: "sessionStorage"
492
+ });
493
+ const tempOrder = await super.addNewOrder();
494
+ (_c = this.store.order) == null ? void 0 : _c.persistTempOrder();
495
+ const customerId = Number(
496
+ tempOrder.customer_id || ((_d = tempOrder.customer) == null ? void 0 : _d.id) || ((_f = (_e = tempOrder._extend) == null ? void 0 : _e.customerSnapshot) == null ? void 0 : _f.id) || ((_h = (_g = tempOrder._extend) == null ? void 0 : _g.customerSnapshot) == null ? void 0 : _h.customer_id) || 0
497
+ );
498
+ if (customerId > 1) {
499
+ try {
500
+ await this.loadDiscountConfig({
501
+ customerId,
502
+ action: tempOrder.order_id ? "edit" : "create"
503
+ });
504
+ } catch (error) {
505
+ console.warn(
506
+ "[UnifiedBookingSales] Failed to refresh discounts after session restore",
507
+ error
508
+ );
509
+ }
510
+ }
511
+ return ((_i = this.store.order) == null ? void 0 : _i.getTempOrder()) || tempOrder;
512
+ }
475
513
  /**
476
514
  * Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
477
515
  * business/channel target so a reused solution instance cannot leak another entry's menus.
@@ -517,8 +555,16 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
517
555
  }
518
556
  }
519
557
  async getOpenData() {
520
- var _a;
521
- return ((_a = this.store.openData) == null ? void 0 : _a.getOpenData()) || null;
558
+ var _a, _b, _c;
559
+ const businessCode = String(((_a = this.otherParams) == null ? void 0 : _a.businessCode) || "").trim();
560
+ const channel = String(((_b = this.otherParams) == null ? void 0 : _b.channel) || "").trim();
561
+ if (!businessCode || !channel)
562
+ return null;
563
+ const target = `${businessCode}+${channel}`;
564
+ const cachedData = ((_c = this.store.openData) == null ? void 0 : _c.getOpenData()) || null;
565
+ if (cachedData && this.openDataTarget === target)
566
+ return cachedData;
567
+ return this.loadOpenData({ businessCode, channel });
522
568
  }
523
569
  /**
524
570
  * Loads the product catalog used by both UI and Planner. Schedule data is requested with each
@@ -11,6 +11,13 @@ export declare enum UnifiedBookingSalesHooks {
11
11
  export interface UnifiedBookingSalesState extends BookingTicketState {
12
12
  resourcePlanner: ResourcePlannerModule;
13
13
  }
14
+ export interface UnifiedBookingSalesOtherParams extends Record<string, any> {
15
+ /**
16
+ * Persist the active order workspace in sessionStorage, partitioned by cacheId.
17
+ * Disabled by default and ignored when cacheId is missing.
18
+ */
19
+ enableSessionStoragePersist?: boolean;
20
+ }
14
21
  /** Explicit OpenData target used by page-level UnifiedBookingSales skins. */
15
22
  export interface UnifiedBookingSalesLoadOpenDataParams {
16
23
  businessCode: string;
@@ -167,6 +167,7 @@ export declare class VenueBookingImpl extends BaseSalesImpl implements Module {
167
167
  private recalculateOrderPricesFromQuotation;
168
168
  scanCode(code: string, customerId?: number): Promise<{
169
169
  isAvailable: boolean;
170
+ isAccepted?: boolean | undefined;
170
171
  discountList: import("../../modules/Discount").Discount[];
171
172
  type: "server" | "clientCalc";
172
173
  unavailableReason?: import("../../modules/Rules/types").UnavailableReason | undefined;
@@ -67,6 +67,10 @@ var OPEN_DATA_SECTION_CODES = [
67
67
  "workflow",
68
68
  "checkout"
69
69
  ];
70
+ function isItemRewardProductDiscount(discount) {
71
+ var _a, _b;
72
+ 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";
73
+ }
70
74
  function cloneCustomDepositData(customDepositData) {
71
75
  if (!customDepositData || typeof customDepositData !== "object")
72
76
  return void 0;
@@ -1432,7 +1436,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1432
1436
  }
1433
1437
  /** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
1434
1438
  async setDiscountSelected(params) {
1435
- var _a, _b, _c, _d, _e, _f, _g;
1439
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1436
1440
  this.logMethodStart("setDiscountSelected", params);
1437
1441
  try {
1438
1442
  if (!this.store.order)
@@ -1488,9 +1492,12 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1488
1492
  nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
1489
1493
  );
1490
1494
  for (const product of tempOrder.products) {
1491
- const origin = this.readProductOriginFromTempOrder(tempOrder, product);
1492
- if (origin == null ? void 0 : origin.isManualDiscount)
1495
+ if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
1496
+ continue;
1497
+ if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
1498
+ product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
1493
1499
  continue;
1500
+ }
1494
1501
  product.discount_list = (product.discount_list || []).filter((pd) => {
1495
1502
  var _a2;
1496
1503
  const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
@@ -1501,7 +1508,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1501
1508
  0
1502
1509
  );
1503
1510
  const optionSum = (0, import_utils3.sumOptionUnitPrice)((0, import_utils3.getProductSkuOptions)(product));
1504
- const sourcePrice = ((_c = product.metadata) == null ? void 0 : _c.source_product_price) ?? (((_d = product.metadata) == null ? void 0 : _d.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
1511
+ const sourcePrice = ((_d = product.metadata) == null ? void 0 : _d.source_product_price) ?? (((_e = product.metadata) == null ? void 0 : _e.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
1505
1512
  const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
1506
1513
  const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
1507
1514
  if (product.metadata) {
@@ -1519,8 +1526,8 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1519
1526
  const afterApplyTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
1520
1527
  await this.store.order.recalculateSummary({ createIfMissing: true });
1521
1528
  this.store.order.persistTempOrder();
1522
- const finalSummary = ((_e = this.store.order.getTempOrder()) == null ? void 0 : _e.summary) || null;
1523
- const finalProduct = ((_g = (_f = this.store.order.getTempOrder()) == null ? void 0 : _f.products) == null ? void 0 : _g[0]) || null;
1529
+ const finalSummary = ((_f = this.store.order.getTempOrder()) == null ? void 0 : _f.summary) || null;
1530
+ const finalProduct = ((_h = (_g = this.store.order.getTempOrder()) == null ? void 0 : _g.products) == null ? void 0 : _h[0]) || null;
1524
1531
  this.logMethodSuccess("setDiscountSelected", params);
1525
1532
  const finalTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
1526
1533
  return this.store.order.getDiscountList();
@@ -48,6 +48,7 @@ export interface PisellCore {
48
48
  getModule: <T extends Module>(name: string) => T | null;
49
49
  getModuleExports: <T = any>(name: string) => T | null;
50
50
  hasModule: (name: string) => boolean;
51
+ getModuleNames: () => string[];
51
52
  effects: {
52
53
  on: (event: string, callback: (payload: any) => void) => () => void;
53
54
  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": "0.10.2",
4
+ "version": "0.10.4",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",