@pisell/pisellos 2.2.309 → 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 (121) hide show
  1. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  2. package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
  3. package/dist/modules/BookingContext/index.js +4 -4
  4. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
  5. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
  6. package/dist/modules/Customer/index.js +6 -3
  7. package/dist/modules/Customer/types.d.ts +2 -0
  8. package/dist/modules/Discount/availability.d.ts +7 -0
  9. package/dist/modules/Discount/availability.js +49 -0
  10. package/dist/modules/Discount/entitlementPass.d.ts +34 -0
  11. package/dist/modules/Discount/entitlementPass.js +147 -0
  12. package/dist/modules/Discount/index.d.ts +2 -2
  13. package/dist/modules/Discount/index.js +37 -151
  14. package/dist/modules/Discount/types.d.ts +36 -5
  15. package/dist/modules/OpenData/index.d.ts +1 -1
  16. package/dist/modules/OpenData/index.js +21 -12
  17. package/dist/modules/Order/index.d.ts +32 -4
  18. package/dist/modules/Order/index.js +733 -373
  19. package/dist/modules/Order/types.d.ts +17 -0
  20. package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
  21. package/dist/modules/Order/utils.d.ts +14 -2
  22. package/dist/modules/Order/utils.js +275 -76
  23. package/dist/modules/Payment/index.d.ts +0 -5
  24. package/dist/modules/Payment/index.js +35 -85
  25. package/dist/modules/Payment/types.d.ts +21 -1
  26. package/dist/modules/Payment/types.js +2 -0
  27. package/dist/modules/Payment/walletpass.d.ts +1 -1
  28. package/dist/modules/Payment/walletpass.js +80 -47
  29. package/dist/modules/ProductList/index.js +18 -5
  30. package/dist/modules/Rules/index.d.ts +2 -2
  31. package/dist/modules/Rules/index.js +480 -186
  32. package/dist/modules/Rules/types.d.ts +4 -0
  33. package/dist/server/index.js +8 -5
  34. package/dist/server/modules/order/index.js +6 -0
  35. package/dist/server/modules/order/types.d.ts +12 -0
  36. package/dist/server/modules/payment/index.d.ts +25 -6
  37. package/dist/server/modules/payment/index.js +660 -133
  38. package/dist/server/utils/small-ticket.d.ts +8 -5
  39. package/dist/server/utils/small-ticket.js +1269 -199
  40. package/dist/solution/BaseSales/index.d.ts +11 -2
  41. package/dist/solution/BaseSales/index.js +1463 -1173
  42. package/dist/solution/BaseSales/types.d.ts +7 -3
  43. package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
  44. package/dist/solution/BookingByStep/index.d.ts +1 -1
  45. package/dist/solution/BookingTicket/index.d.ts +12 -3
  46. package/dist/solution/BookingTicket/index.js +663 -542
  47. package/dist/solution/BookingTicket/types.d.ts +5 -1
  48. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  49. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
  50. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  51. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  52. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
  53. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  54. package/dist/solution/ShopDiscount/index.js +99 -42
  55. package/dist/solution/ShopDiscount/utils.d.ts +4 -2
  56. package/dist/solution/ShopDiscount/utils.js +43 -23
  57. package/dist/solution/UnifiedBookingSales/index.d.ts +2 -2
  58. package/dist/solution/UnifiedBookingSales/index.js +5 -5
  59. package/dist/utils/os-private-payload.d.ts +5 -0
  60. package/dist/utils/os-private-payload.js +17 -0
  61. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  62. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
  63. package/lib/modules/BookingContext/index.js +3 -3
  64. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
  65. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
  66. package/lib/modules/Customer/index.js +5 -1
  67. package/lib/modules/Customer/types.d.ts +2 -0
  68. package/lib/modules/Discount/availability.d.ts +7 -0
  69. package/lib/modules/Discount/availability.js +43 -0
  70. package/lib/modules/Discount/entitlementPass.d.ts +34 -0
  71. package/lib/modules/Discount/entitlementPass.js +141 -0
  72. package/lib/modules/Discount/index.d.ts +2 -2
  73. package/lib/modules/Discount/index.js +23 -129
  74. package/lib/modules/Discount/types.d.ts +36 -5
  75. package/lib/modules/OpenData/index.d.ts +1 -1
  76. package/lib/modules/OpenData/index.js +11 -2
  77. package/lib/modules/Order/index.d.ts +32 -4
  78. package/lib/modules/Order/index.js +341 -71
  79. package/lib/modules/Order/types.d.ts +17 -0
  80. package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
  81. package/lib/modules/Order/utils.d.ts +14 -2
  82. package/lib/modules/Order/utils.js +186 -3
  83. package/lib/modules/Payment/index.d.ts +0 -5
  84. package/lib/modules/Payment/index.js +3 -28
  85. package/lib/modules/Payment/types.d.ts +21 -1
  86. package/lib/modules/Payment/types.js +1 -0
  87. package/lib/modules/Payment/walletpass.d.ts +1 -1
  88. package/lib/modules/Payment/walletpass.js +29 -9
  89. package/lib/modules/ProductList/index.js +14 -1
  90. package/lib/modules/Rules/index.d.ts +2 -2
  91. package/lib/modules/Rules/index.js +357 -110
  92. package/lib/modules/Rules/types.d.ts +4 -0
  93. package/lib/server/index.js +8 -5
  94. package/lib/server/modules/order/index.js +6 -0
  95. package/lib/server/modules/order/types.d.ts +12 -0
  96. package/lib/server/modules/payment/index.d.ts +25 -6
  97. package/lib/server/modules/payment/index.js +350 -78
  98. package/lib/server/utils/small-ticket.d.ts +8 -5
  99. package/lib/server/utils/small-ticket.js +1009 -121
  100. package/lib/solution/BaseSales/index.d.ts +11 -2
  101. package/lib/solution/BaseSales/index.js +164 -30
  102. package/lib/solution/BaseSales/types.d.ts +7 -3
  103. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
  104. package/lib/solution/BookingByStep/index.d.ts +1 -1
  105. package/lib/solution/BookingTicket/index.d.ts +12 -3
  106. package/lib/solution/BookingTicket/index.js +103 -41
  107. package/lib/solution/BookingTicket/types.d.ts +5 -1
  108. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  109. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
  110. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  111. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  112. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
  113. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  114. package/lib/solution/ShopDiscount/index.js +55 -9
  115. package/lib/solution/ShopDiscount/utils.d.ts +4 -2
  116. package/lib/solution/ShopDiscount/utils.js +42 -25
  117. package/lib/solution/UnifiedBookingSales/index.d.ts +2 -2
  118. package/lib/solution/UnifiedBookingSales/index.js +5 -5
  119. package/lib/utils/os-private-payload.d.ts +5 -0
  120. package/lib/utils/os-private-payload.js +22 -0
  121. 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<{
@@ -101,6 +111,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
101
111
  applyDiscount(options?: {
102
112
  reapplyBookingDiscountProductUids?: string[];
103
113
  reapplyWeighedDiscountProductUids?: string[];
114
+ preferredEntitlementPassIds?: number[];
104
115
  }): void;
105
116
  /**
106
117
  * 注入促销评估器。
@@ -177,8 +188,19 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
177
188
  consumeSessionStorageRestore(): Record<string, any> | null;
178
189
  notifyTempOrderChanged(): void;
179
190
  private createDefaultTempOrderInstance;
180
- private clearTempOrderPointCardSnapshot;
181
- 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[];
182
204
  private createExternalSaleNumber;
183
205
  private ensureExternalSaleNumber;
184
206
  private ensureRequestUniqueIdempotencyToken;
@@ -468,7 +490,12 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
468
490
  }>, options?: {
469
491
  skipEditDiscountConfigRefresh?: boolean;
470
492
  }): Promise<OrderProduct[]>;
493
+ private getFullCoveragePassDiscounts;
494
+ private hasEntitlementPassDiscount;
471
495
  private hasGoodPassDiscount;
496
+ private isPersistedProductLine;
497
+ private isRuntimeEntitlementAppend;
498
+ private hasSameEntitlementMergePriceConfig;
472
499
  private getBundleRuntimeIdentity;
473
500
  private preservePersistedBundlePriceFields;
474
501
  private applyOrderProductUpdateToTempOrder;
@@ -589,6 +616,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
589
616
  */
590
617
  createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
591
618
  submitSalesOrder<T = any>(params: SubmitSalesOrderParams): Promise<T>;
619
+ private isSalesCheckoutHandledByOsServer;
592
620
  /**
593
621
  * 发送支付链接邮件。
594
622
  *
@@ -635,4 +663,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
635
663
  getOrderInfo(order_id: number): Promise<any>;
636
664
  getVouchers(): any[];
637
665
  }
638
- 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';