@pisell/pisellos 2.2.308 → 2.2.310

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 (130) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
  4. package/dist/modules/BookingContext/index.js +4 -4
  5. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
  6. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
  7. package/dist/modules/Customer/index.js +6 -3
  8. package/dist/modules/Customer/types.d.ts +2 -0
  9. package/dist/modules/Discount/availability.d.ts +7 -0
  10. package/dist/modules/Discount/availability.js +49 -0
  11. package/dist/modules/Discount/entitlementPass.d.ts +34 -0
  12. package/dist/modules/Discount/entitlementPass.js +147 -0
  13. package/dist/modules/Discount/index.d.ts +2 -2
  14. package/dist/modules/Discount/index.js +37 -151
  15. package/dist/modules/Discount/types.d.ts +36 -5
  16. package/dist/modules/OpenData/index.d.ts +1 -1
  17. package/dist/modules/OpenData/index.js +21 -12
  18. package/dist/modules/Order/index.d.ts +33 -4
  19. package/dist/modules/Order/index.js +830 -411
  20. package/dist/modules/Order/types.d.ts +17 -0
  21. package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
  22. package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
  23. package/dist/modules/Order/utils/weighedProduct.js +94 -0
  24. package/dist/modules/Order/utils.d.ts +14 -2
  25. package/dist/modules/Order/utils.js +280 -79
  26. package/dist/modules/Payment/index.d.ts +0 -5
  27. package/dist/modules/Payment/index.js +35 -85
  28. package/dist/modules/Payment/types.d.ts +21 -1
  29. package/dist/modules/Payment/types.js +2 -0
  30. package/dist/modules/Payment/walletpass.d.ts +1 -1
  31. package/dist/modules/Payment/walletpass.js +80 -47
  32. package/dist/modules/ProductList/index.js +18 -5
  33. package/dist/modules/Rules/index.d.ts +2 -2
  34. package/dist/modules/Rules/index.js +484 -188
  35. package/dist/modules/Rules/types.d.ts +6 -0
  36. package/dist/server/index.js +8 -5
  37. package/dist/server/modules/order/index.js +6 -0
  38. package/dist/server/modules/order/types.d.ts +12 -0
  39. package/dist/server/modules/payment/index.d.ts +25 -6
  40. package/dist/server/modules/payment/index.js +660 -133
  41. package/dist/server/utils/small-ticket.d.ts +8 -5
  42. package/dist/server/utils/small-ticket.js +1269 -199
  43. package/dist/solution/BaseSales/index.d.ts +11 -2
  44. package/dist/solution/BaseSales/index.js +1463 -1173
  45. package/dist/solution/BaseSales/types.d.ts +7 -3
  46. package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
  47. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
  48. package/dist/solution/BaseSales/utils.js +3 -2
  49. package/dist/solution/BookingTicket/index.d.ts +11 -2
  50. package/dist/solution/BookingTicket/index.js +663 -542
  51. package/dist/solution/BookingTicket/types.d.ts +5 -1
  52. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  53. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
  54. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  55. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  56. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
  57. package/dist/solution/ScanOrder/utils.js +3 -2
  58. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  59. package/dist/solution/ShopDiscount/index.js +99 -42
  60. package/dist/solution/ShopDiscount/utils.d.ts +4 -2
  61. package/dist/solution/ShopDiscount/utils.js +43 -23
  62. package/dist/solution/UnifiedBookingSales/index.d.ts +2 -2
  63. package/dist/solution/UnifiedBookingSales/index.js +5 -5
  64. package/dist/utils/os-private-payload.d.ts +5 -0
  65. package/dist/utils/os-private-payload.js +17 -0
  66. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  67. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
  68. package/lib/modules/BookingContext/index.js +3 -3
  69. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
  70. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
  71. package/lib/modules/Customer/index.js +5 -1
  72. package/lib/modules/Customer/types.d.ts +2 -0
  73. package/lib/modules/Discount/availability.d.ts +7 -0
  74. package/lib/modules/Discount/availability.js +43 -0
  75. package/lib/modules/Discount/entitlementPass.d.ts +34 -0
  76. package/lib/modules/Discount/entitlementPass.js +141 -0
  77. package/lib/modules/Discount/index.d.ts +2 -2
  78. package/lib/modules/Discount/index.js +23 -129
  79. package/lib/modules/Discount/types.d.ts +36 -5
  80. package/lib/modules/OpenData/index.d.ts +1 -1
  81. package/lib/modules/OpenData/index.js +11 -2
  82. package/lib/modules/Order/index.d.ts +33 -4
  83. package/lib/modules/Order/index.js +411 -81
  84. package/lib/modules/Order/types.d.ts +17 -0
  85. package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
  86. package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
  87. package/lib/modules/Order/utils/weighedProduct.js +89 -0
  88. package/lib/modules/Order/utils.d.ts +14 -2
  89. package/lib/modules/Order/utils.js +189 -5
  90. package/lib/modules/Payment/index.d.ts +0 -5
  91. package/lib/modules/Payment/index.js +3 -28
  92. package/lib/modules/Payment/types.d.ts +21 -1
  93. package/lib/modules/Payment/types.js +1 -0
  94. package/lib/modules/Payment/walletpass.d.ts +1 -1
  95. package/lib/modules/Payment/walletpass.js +29 -9
  96. package/lib/modules/ProductList/index.js +14 -1
  97. package/lib/modules/Rules/index.d.ts +2 -2
  98. package/lib/modules/Rules/index.js +361 -112
  99. package/lib/modules/Rules/types.d.ts +6 -0
  100. package/lib/server/index.js +8 -5
  101. package/lib/server/modules/order/index.js +6 -0
  102. package/lib/server/modules/order/types.d.ts +12 -0
  103. package/lib/server/modules/payment/index.d.ts +25 -6
  104. package/lib/server/modules/payment/index.js +350 -78
  105. package/lib/server/utils/small-ticket.d.ts +8 -5
  106. package/lib/server/utils/small-ticket.js +1009 -121
  107. package/lib/solution/BaseSales/index.d.ts +11 -2
  108. package/lib/solution/BaseSales/index.js +164 -30
  109. package/lib/solution/BaseSales/types.d.ts +7 -3
  110. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
  111. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
  112. package/lib/solution/BaseSales/utils.js +2 -1
  113. package/lib/solution/BookingTicket/index.d.ts +11 -2
  114. package/lib/solution/BookingTicket/index.js +103 -41
  115. package/lib/solution/BookingTicket/types.d.ts +5 -1
  116. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  117. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
  118. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  119. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  120. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
  121. package/lib/solution/ScanOrder/utils.js +2 -1
  122. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  123. package/lib/solution/ShopDiscount/index.js +55 -9
  124. package/lib/solution/ShopDiscount/utils.d.ts +4 -2
  125. package/lib/solution/ShopDiscount/utils.js +42 -25
  126. package/lib/solution/UnifiedBookingSales/index.d.ts +2 -2
  127. package/lib/solution/UnifiedBookingSales/index.js +5 -5
  128. package/lib/utils/os-private-payload.d.ts +5 -0
  129. package/lib/utils/os-private-payload.js +22 -0
  130. package/package.json +1 -1
@@ -44,7 +44,10 @@ interface ApplicableProductDetails {
44
44
  original_amount: string;
45
45
  num: number;
46
46
  metadata?: {
47
+ encoded?: string;
47
48
  product_discount_difference?: number;
49
+ /** 月卡扣除本单新增使用后的剩余次数;不限次数时为 null。 */
50
+ balance?: number | null;
48
51
  };
49
52
  discount?: {
50
53
  fixed_amount?: number;
@@ -63,6 +66,13 @@ interface UsageCreditsValue {
63
66
  max_per_week: number;
64
67
  max_per_month: number;
65
68
  }
69
+ export type IncludedUses = {
70
+ type: 'limited';
71
+ value: number;
72
+ } | {
73
+ type: 'unlimited';
74
+ value: null;
75
+ };
66
76
  export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
67
77
  export interface DiscountWithReason {
68
78
  discountList: Discount[];
@@ -107,30 +117,37 @@ interface ExtensionData {
107
117
  }
108
118
  export interface Discount {
109
119
  id: number;
120
+ shop_id?: number;
110
121
  product_name: string;
111
122
  encoded: string;
112
123
  code: string;
113
124
  tag: string;
114
- expire_time?: string;
125
+ expire_time?: string | null;
126
+ expire_date?: string | null;
127
+ end_time?: string | null;
115
128
  product_id: number;
116
129
  relation_type: string;
117
130
  par_value: string;
118
131
  used_par_value: string;
119
132
  limit_status: string;
120
133
  limited_relation_product_data: Limitedrelationproductdata;
121
- balance: string;
134
+ balance?: string | number | null;
135
+ available_num?: number;
136
+ available_products_info?: any[];
122
137
  format_title: Formattitle;
123
138
  metadata?: {
139
+ encoded?: string;
124
140
  discount_card_type?: 'fixed_amount' | 'percent';
125
141
  custom_product_bundle_map_id?: string;
126
142
  validity_type?: "custom_schedule_validity" | "fixed_validity";
127
- discount_calculation_mode: 'item_level' | 'order_level';
128
- holder: {
143
+ included_uses?: IncludedUses;
144
+ discount_calculation_mode?: 'item_level' | 'order_level';
145
+ holder?: {
129
146
  type: "customer" | "custom";
130
147
  };
131
148
  };
132
149
  product: Product;
133
- type: "product" | 'good_pass';
150
+ type?: "product" | 'good_pass' | 'entitlement_pass' | 'discount_card' | 'product_discount_card';
134
151
  resource_id?: number;
135
152
  savedAmount?: number;
136
153
  isEditMode?: boolean;
@@ -163,9 +180,17 @@ export interface Discount {
163
180
  applicableProductIds?: number[];
164
181
  applicableProductDetails: ApplicableProductDetails[];
165
182
  appliedProductDetails: ApplicableProductDetails[];
183
+ /** Entitlement Pass 编辑订单时已经提交的使用明细。 */
184
+ committedAppliedProductDetails?: ApplicableProductDetails[];
166
185
  isDisabledForProductUsed?: boolean;
167
186
  amount?: number;
168
187
  customer_id?: number | string | null;
188
+ holder?: {
189
+ holder_type?: 'customer' | 'form' | string;
190
+ holder_id?: number | string | Array<number | string>;
191
+ created_at?: string | null;
192
+ [key: string]: any;
193
+ };
169
194
  extension_data?: ExtensionData[];
170
195
  total_order_behavior_count?: number;
171
196
  today_order_behavior_count?: number;
@@ -180,6 +205,12 @@ export interface Discount {
180
205
  start_time?: string;
181
206
  discount_rule_uncheck_flag?: boolean;
182
207
  usageLimitFailKey?: string | null;
208
+ /** 本次规则计算的不可用原因;可用性恢复后清除。 */
209
+ reason?: string;
210
+ reasonCode?: string;
211
+ unified_messages?: {
212
+ title?: string | Record<string, string>;
213
+ };
183
214
  unified_available_status?: number | undefined | null;
184
215
  }
185
216
  export interface DiscountState {
@@ -33,7 +33,7 @@ export declare class OpenDataModule extends BaseModule implements Module {
33
33
  getOpenData(): OpenDataConfig | null;
34
34
  getInvoiceLayoutConfig(): InvoiceLayoutConfig;
35
35
  getInvoiceTemplateSettings(): InvoiceTemplateSettings;
36
- ensureInvoiceTemplateSettings(target: string): Promise<InvoiceTemplateSettings>;
36
+ ensureInvoiceTemplateSettings(target: string, openDataConfig?: OpenDataConfig): Promise<InvoiceTemplateSettings>;
37
37
  private commitInvoiceTemplateSettings;
38
38
  private resolveInvoiceTemplateSettings;
39
39
  private buildInvoiceTemplateCacheKey;
@@ -153,7 +153,8 @@ class OpenDataModule extends _BaseModule.BaseModule {
153
153
  this.fatherModule = this.otherParams.fatherModule;
154
154
  }
155
155
  shouldSkipInvoiceTemplateDocument() {
156
- return String(this.otherParams?.platform || '').trim().toLowerCase() === 'h5';
156
+ const platform = String(this.otherParams?.platform || '').trim().toLowerCase();
157
+ return platform === 'pc' || platform === 'h5';
157
158
  }
158
159
  async fetchOpenData(params) {
159
160
  const fetchRevision = ++this.fetchRevision;
@@ -211,8 +212,16 @@ class OpenDataModule extends _BaseModule.BaseModule {
211
212
  }
212
213
  return (0, _utils.getDefaultInvoiceTemplateSettings)();
213
214
  }
214
- async ensureInvoiceTemplateSettings(target) {
215
+ async ensureInvoiceTemplateSettings(target, openDataConfig) {
215
216
  const normalizedTarget = String(target || '').trim();
217
+ if (openDataConfig && openDataConfig !== this.store.data) {
218
+ // 部分解决方案会在初始化参数中直接收到已经拉取完成的 OpenData。
219
+ // 将它纳入模块状态后再解析 Document,避免为了 Invoice 重复请求 setting,
220
+ // 同时让后续同步 getter 能校验同一份 document id 与 target。
221
+ this.fetchRevision += 1;
222
+ this.store.data = openDataConfig;
223
+ this.store.lastFetchedAt = Date.now();
224
+ }
216
225
  const config = this.store.data;
217
226
  if (!normalizedTarget || !config) {
218
227
  return (0, _utils.getDefaultInvoiceTemplateSettings)();
@@ -3,7 +3,7 @@ import { BaseModule } from '../BaseModule';
3
3
  import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CancelOrderParams, ChangeBookingStatusParams, CheckoutOrderParams } from './types';
4
4
  import { CartItem } from '../Cart/types';
5
5
  import { type SubmitPayloadEnhancer } from './utils';
6
- import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } from './types';
6
+ import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
7
7
  import type { ICustomer } from '../AccountList/types';
8
8
  import type { Discount } from '../Discount/types';
9
9
  import { UnavailableReason } from '../Rules/types';
@@ -20,6 +20,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
20
20
  private openCache;
21
21
  private sessionStoragePersistEnabled;
22
22
  private sessionStorageRestoreRecord;
23
+ /** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
24
+ private customerWalletPrepareConfigEpoch;
25
+ /** Payment 可能早于 prepare/config 返回;先按实例 ID 暂存卡号等待 Snapshot。 */
26
+ private pointCardSnapshotCodeCandidates;
23
27
  private salesSummaryModuleName;
24
28
  private rulesHooksOverride?;
25
29
  private moduleHooksOverride?;
@@ -78,6 +82,11 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
78
82
  private logError;
79
83
  private registerDiscountModules;
80
84
  private createDefaultRulesHooks;
85
+ /**
86
+ * Stable across notifyTempOrderChanged's immutable copy, but changes when a
87
+ * different local/server order becomes current.
88
+ */
89
+ private getDiscountConfigOrderIdentityKey;
81
90
  loadDiscountConfig(params: {
82
91
  customerId: number;
83
92
  action?: 'create' | 'edit';
@@ -87,6 +96,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
87
96
  getDiscountList(): Discount[];
88
97
  getAvailableWalletIds(): number[];
89
98
  getVirtualCurrencyList(): import("../Discount/types").VirtualCurrencyAsset[];
99
+ getCustomerWalletPrepareConfigEpoch(): number;
90
100
  private syncScannedDiscountsToOriginalDiscountList;
91
101
  private ensureEditDiscountConfigForProductChange;
92
102
  scanCode(code: string, customerId?: number): Promise<{
@@ -100,6 +110,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
100
110
  }>;
101
111
  applyDiscount(options?: {
102
112
  reapplyBookingDiscountProductUids?: string[];
113
+ reapplyWeighedDiscountProductUids?: string[];
114
+ preferredEntitlementPassIds?: number[];
103
115
  }): void;
104
116
  /**
105
117
  * 注入促销评估器。
@@ -176,8 +188,19 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
176
188
  consumeSessionStorageRestore(): Record<string, any> | null;
177
189
  notifyTempOrderChanged(): void;
178
190
  private createDefaultTempOrderInstance;
179
- private clearTempOrderPointCardSnapshot;
180
- private writePointCardSnapshotFromPrepareConfig;
191
+ private clearTempOrderCustomerWalletSnapshots;
192
+ private clearCustomerWalletState;
193
+ private clearCustomerWalletRuntimeState;
194
+ private rememberPointCardSnapshotCodeCandidates;
195
+ private getRememberedPointCardSnapshotCodeCandidates;
196
+ private getPointCardSnapshotOrderIdentityKey;
197
+ private isPointCardSnapshotMergeContextCurrent;
198
+ private writeCustomerWalletSnapshotsFromPrepareConfig;
199
+ /**
200
+ * 将 Payment WalletPass 返回的实例 code 回填到当前订单 Snapshot。
201
+ * 这里只按资产 ID 补空值,不新增卡、不覆盖 prepare/config 冻结的余额。
202
+ */
203
+ mergePointCardSnapshotCodes(walletPassList: unknown, context?: PointCardSnapshotMergeContext): PointCardSnapshotItem[];
181
204
  private createExternalSaleNumber;
182
205
  private ensureExternalSaleNumber;
183
206
  private ensureRequestUniqueIdempotencyToken;
@@ -467,7 +490,12 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
467
490
  }>, options?: {
468
491
  skipEditDiscountConfigRefresh?: boolean;
469
492
  }): Promise<OrderProduct[]>;
493
+ private getFullCoveragePassDiscounts;
494
+ private hasEntitlementPassDiscount;
470
495
  private hasGoodPassDiscount;
496
+ private isPersistedProductLine;
497
+ private isRuntimeEntitlementAppend;
498
+ private hasSameEntitlementMergePriceConfig;
471
499
  private getBundleRuntimeIdentity;
472
500
  private preservePersistedBundlePriceFields;
473
501
  private applyOrderProductUpdateToTempOrder;
@@ -588,6 +616,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
588
616
  */
589
617
  createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
590
618
  submitSalesOrder<T = any>(params: SubmitSalesOrderParams): Promise<T>;
619
+ private isSalesCheckoutHandledByOsServer;
591
620
  /**
592
621
  * 发送支付链接邮件。
593
622
  *
@@ -634,4 +663,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
634
663
  getOrderInfo(order_id: number): Promise<any>;
635
664
  getVouchers(): any[];
636
665
  }
637
- export type { AddProductToOrderOptions, OrderMetaList, PointCardSnapshotItem, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
666
+ export type { AddProductToOrderOptions, OrderMetaList, PointCardSnapshotItem, VirtualCurrencySnapshotItem, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';