@pisell/pisellos 2.2.264 → 2.2.266

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 (126) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
  14. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  15. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  16. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
  17. package/dist/modules/Discount/index.d.ts +5 -2
  18. package/dist/modules/Discount/index.js +30 -7
  19. package/dist/modules/Discount/types.d.ts +4 -0
  20. package/dist/modules/Order/index.d.ts +41 -10
  21. package/dist/modules/Order/index.js +1379 -810
  22. package/dist/modules/Order/payment-utils.d.ts +26 -0
  23. package/dist/modules/Order/payment-utils.js +225 -0
  24. package/dist/modules/Order/types.d.ts +49 -1
  25. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  26. package/dist/modules/Order/utils/orderCollectionIdentity.js +410 -0
  27. package/dist/modules/Order/utils.d.ts +4 -3
  28. package/dist/modules/Order/utils.js +61 -64
  29. package/dist/modules/Payment/index.d.ts +2 -0
  30. package/dist/modules/Payment/index.js +78 -49
  31. package/dist/modules/Payment/types.d.ts +26 -24
  32. package/dist/modules/Payment/types.js +2 -0
  33. package/dist/modules/Product/types.d.ts +22 -0
  34. package/dist/modules/ProductList/index.d.ts +1 -1
  35. package/dist/modules/ProductList/index.js +4 -2
  36. package/dist/modules/ProductList/types.d.ts +2 -0
  37. package/dist/modules/Rules/index.d.ts +2 -8
  38. package/dist/modules/Rules/index.js +55 -9
  39. package/dist/modules/Rules/types.d.ts +10 -1
  40. package/dist/server/index.d.ts +71 -0
  41. package/dist/server/index.js +2504 -1187
  42. package/dist/server/modules/order/index.d.ts +56 -5
  43. package/dist/server/modules/order/index.js +1718 -834
  44. package/dist/server/modules/order/types.d.ts +15 -3
  45. package/dist/server/modules/order/types.js +1 -1
  46. package/dist/server/modules/products/index.d.ts +31 -8
  47. package/dist/server/modules/products/index.js +549 -390
  48. package/dist/server/modules/products/types.d.ts +18 -0
  49. package/dist/solution/BaseSales/index.d.ts +67 -4
  50. package/dist/solution/BaseSales/index.js +1476 -792
  51. package/dist/solution/BaseSales/types.d.ts +6 -1
  52. package/dist/solution/BaseSales/types.js +1 -1
  53. package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
  54. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
  55. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  56. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
  57. package/dist/solution/BookingByStep/index.d.ts +1 -1
  58. package/dist/solution/BookingTicket/index.js +94 -54
  59. package/dist/solution/BookingTicket/types.d.ts +2 -0
  60. package/dist/solution/Sales/index.d.ts +1 -0
  61. package/dist/solution/Sales/index.js +10 -2
  62. package/dist/solution/ShopDiscount/index.js +15 -14
  63. package/dist/utils/payment-number.d.ts +9 -0
  64. package/dist/utils/payment-number.js +69 -0
  65. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  66. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  67. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  68. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  69. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  70. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  71. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  72. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  73. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  74. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  75. package/lib/model/strategy/adapter/index.d.ts +4 -0
  76. package/lib/model/strategy/adapter/index.js +13 -2
  77. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
  78. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
  79. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  80. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
  81. package/lib/modules/Discount/index.d.ts +5 -2
  82. package/lib/modules/Discount/index.js +23 -3
  83. package/lib/modules/Discount/types.d.ts +4 -0
  84. package/lib/modules/Order/index.d.ts +41 -10
  85. package/lib/modules/Order/index.js +514 -122
  86. package/lib/modules/Order/payment-utils.d.ts +26 -0
  87. package/lib/modules/Order/payment-utils.js +224 -0
  88. package/lib/modules/Order/types.d.ts +49 -1
  89. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  90. package/lib/modules/Order/utils/orderCollectionIdentity.js +418 -0
  91. package/lib/modules/Order/utils.d.ts +4 -3
  92. package/lib/modules/Order/utils.js +26 -20
  93. package/lib/modules/Payment/index.d.ts +2 -0
  94. package/lib/modules/Payment/index.js +33 -12
  95. package/lib/modules/Payment/types.d.ts +26 -24
  96. package/lib/modules/Product/types.d.ts +22 -0
  97. package/lib/modules/ProductList/index.d.ts +1 -1
  98. package/lib/modules/ProductList/index.js +4 -2
  99. package/lib/modules/ProductList/types.d.ts +2 -0
  100. package/lib/modules/Rules/index.d.ts +2 -8
  101. package/lib/modules/Rules/index.js +57 -6
  102. package/lib/modules/Rules/types.d.ts +10 -1
  103. package/lib/server/index.d.ts +71 -0
  104. package/lib/server/index.js +1002 -52
  105. package/lib/server/modules/order/index.d.ts +56 -5
  106. package/lib/server/modules/order/index.js +798 -148
  107. package/lib/server/modules/order/types.d.ts +15 -3
  108. package/lib/server/modules/products/index.d.ts +31 -8
  109. package/lib/server/modules/products/index.js +134 -35
  110. package/lib/server/modules/products/types.d.ts +18 -0
  111. package/lib/solution/BaseSales/index.d.ts +67 -4
  112. package/lib/solution/BaseSales/index.js +496 -50
  113. package/lib/solution/BaseSales/types.d.ts +6 -1
  114. package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
  115. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
  116. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  117. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
  118. package/lib/solution/BookingByStep/index.d.ts +1 -1
  119. package/lib/solution/BookingTicket/index.js +39 -11
  120. package/lib/solution/BookingTicket/types.d.ts +2 -0
  121. package/lib/solution/Sales/index.d.ts +1 -0
  122. package/lib/solution/Sales/index.js +5 -3
  123. package/lib/solution/ShopDiscount/index.js +2 -1
  124. package/lib/utils/payment-number.d.ts +9 -0
  125. package/lib/utils/payment-number.js +64 -0
  126. package/package.json +1 -1
@@ -31,6 +31,9 @@ var import_cash = require("./cash");
31
31
  var import_eftpos = require("./eftpos");
32
32
  var import_walletpass = require("./walletpass");
33
33
  var import_decimal = require("decimal.js");
34
+ var import_payment_utils = require("../Order/payment-utils");
35
+ var import_utils2 = require("../Order/utils");
36
+ var import_payment_number = require("../../utils/payment-number");
34
37
  __reExport(Payment_exports, require("./types"), module.exports);
35
38
  function formatAmount(amount) {
36
39
  try {
@@ -112,15 +115,15 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
112
115
  this.store = options.store;
113
116
  this.otherParams = options.otherParams || {};
114
117
  this.request = core.getPlugin("request");
115
- const appPlugin = core.getPlugin("app");
118
+ this.appPlugin = core.getPlugin("app");
116
119
  this.window = core.getPlugin("window");
117
120
  if (!this.request) {
118
121
  throw new Error("支付模块需要 request 插件支持");
119
122
  }
120
- if (!appPlugin) {
123
+ if (!this.appPlugin) {
121
124
  throw new Error("支付模块需要 app 插件支持");
122
125
  }
123
- this.app = appPlugin.getApp();
126
+ this.app = this.appPlugin.getApp();
124
127
  this.dbManager = this.app.dbManager;
125
128
  this.logger = this.app.logger;
126
129
  this.registerNetworkHandlers();
@@ -136,6 +139,14 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
136
139
  updateOtherParams(params) {
137
140
  this.otherParams = params || {};
138
141
  }
142
+ getPaymentNumberAppData(key) {
143
+ var _a, _b, _c, _d, _e, _f, _g;
144
+ const getData = (_b = (_a = this.appPlugin) == null ? void 0 : _a.getData) == null ? void 0 : _b.call(_a);
145
+ if (typeof getData === "function")
146
+ return getData(key);
147
+ const coreData = (_g = (_e = (_d = (_c = this.app) == null ? void 0 : _c.models) == null ? void 0 : _d.getStore) == null ? void 0 : (_f = _e.call(_d)).getDataByModel) == null ? void 0 : _g.call(_f, "core", "core");
148
+ return coreData == null ? void 0 : coreData[key];
149
+ }
139
150
  /**
140
151
  * 记录信息日志
141
152
  */
@@ -521,15 +532,20 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
521
532
  });
522
533
  throw new Error(warningMessage);
523
534
  }
524
- let paymentUuid;
525
- if ((_a = paymentItem.metadata) == null ? void 0 : _a.unique_payment_number) {
526
- paymentUuid = paymentItem.metadata.unique_payment_number;
527
- } else {
528
- paymentUuid = (0, import_utils.getUniqueId)("payment_");
529
- }
535
+ const paymentUuid = paymentItem.uuid || ((_a = paymentItem.metadata) == null ? void 0 : _a.unique_payment_number) || (0, import_utils.getUniqueId)("payment_");
530
536
  const currentTime = formatDateTime(/* @__PURE__ */ new Date());
537
+ const hasPaymentNumber = String(paymentItem.payment_number || "").trim() !== "";
538
+ const paymentNumberDevicePrefix = hasPaymentNumber ? "LOCAL" : await (0, import_payment_number.resolvePaymentNumberDevicePrefix)(
539
+ (key) => this.getPaymentNumberAppData(key)
540
+ );
541
+ const paymentNumber = (0, import_payment_utils.ensureOrderPaymentNumber)(
542
+ paymentItem,
543
+ paymentNumberDevicePrefix,
544
+ import_utils2.createUuidV4
545
+ ).payment_number;
531
546
  const newPaymentItem = {
532
547
  uuid: paymentUuid,
548
+ payment_number: paymentNumber,
533
549
  custom_payment_id: normalizeCustomPaymentId(paymentItem),
534
550
  name: paymentItem.name,
535
551
  code: paymentItem.code,
@@ -549,10 +565,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
549
565
  updated_at: currentTime,
550
566
  // 更新时间
551
567
  metadata: {
552
- ...paymentItem.metadata,
568
+ ...paymentItem.metadata
553
569
  // 保留传入的所有 metadata 字段
554
- unique_payment_number: paymentUuid
555
- // 设置唯一支付号为支付项的 uuid
556
570
  }
557
571
  };
558
572
  order.payment.push(newPaymentItem);
@@ -767,6 +781,12 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
767
781
  if ("amount" in formattedParams && formattedParams.amount !== void 0) {
768
782
  formattedParams.amount = formatAmount(formattedParams.amount);
769
783
  }
784
+ if (formattedParams.metadata && typeof formattedParams.metadata === "object") {
785
+ formattedParams.metadata = {
786
+ ...paymentItem.metadata || {},
787
+ ...formattedParams.metadata
788
+ };
789
+ }
770
790
  Object.assign(paymentItem, formattedParams);
771
791
  this.recalculateOrderAmount(order);
772
792
  await this.dbManager.update("order", order);
@@ -824,6 +844,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
824
844
  const paymentData = {
825
845
  payments: order.payment.map((payment) => ({
826
846
  uuid: payment.uuid,
847
+ payment_number: payment.payment_number,
827
848
  amount: payment.amount,
828
849
  code: payment.code,
829
850
  custom_payment_id: payment.custom_payment_id,
@@ -87,12 +87,30 @@ export interface PaymentMethod {
87
87
  /** 其他配置信息 */
88
88
  [key: string]: any;
89
89
  }
90
+ /** 支付项扩展元数据 */
91
+ export interface PaymentItemMetadata {
92
+ /** 钱箱 ID */
93
+ shop_wallet_pass_id?: string;
94
+ /** 三方支付交易流水号 */
95
+ unique_payment_number?: string;
96
+ /** 刷卡机设备快照;PaymentModule 不解析内部字段 */
97
+ card_reader_snapshot?: Record<string, unknown>;
98
+ /** rounding 规则 */
99
+ rounding_rule?: any;
100
+ /** 实付金额(现金支付时的实际给出金额) */
101
+ actual_paid_amount?: number;
102
+ /** 找零金额(现金支付时的找零金额) */
103
+ change_given_amount?: number;
104
+ [key: string]: unknown;
105
+ }
90
106
  /**
91
107
  * 支付项
92
108
  */
93
109
  export interface PaymentItem {
94
110
  /** 当前支付项的唯一 ID */
95
111
  uuid: string;
112
+ /** 支付项稳定唯一号 */
113
+ payment_number?: string;
96
114
  /** 当前支付方式付出去多少钱 */
97
115
  amount: string;
98
116
  /** 支付类型,跟支付列表上对应的支付方式保持一致 */
@@ -110,18 +128,7 @@ export interface PaymentItem {
110
128
  /** Wallet Pass 本次使用值 */
111
129
  wallet_pass_use_value?: string | number | null;
112
130
  /** 拓展参数字段 */
113
- metadata?: {
114
- /** 钱箱 ID */
115
- shop_wallet_pass_id?: string;
116
- /** 唯一支付号 */
117
- unique_payment_number?: string;
118
- /** rouding规则 */
119
- rounding_rule?: any;
120
- /** 实付金额(现金支付时的实际给出金额) */
121
- actual_paid_amount?: number;
122
- /** 找零金额(现金支付时的找零金额) */
123
- change_given_amount?: number;
124
- };
131
+ metadata?: PaymentItemMetadata;
125
132
  /** rouding金额 */
126
133
  rounding_amount?: string;
127
134
  /** 三方支付手续费 */
@@ -228,6 +235,10 @@ export interface UpdateOrderParams {
228
235
  * 支付项输入类型(允许 amount 为数字)
229
236
  */
230
237
  export interface PaymentItemInput {
238
+ /** 调用方已有的支付项运行态 UUID;存在时复用为 payment_number 的唯一号段 */
239
+ uuid?: string;
240
+ /** 支付项稳定唯一号 */
241
+ payment_number?: string;
231
242
  /** 当前支付方式付出去多少钱 */
232
243
  amount: string | number;
233
244
  /** 支付类型,跟支付列表上对应的支付方式保持一致 */
@@ -256,18 +267,7 @@ export interface PaymentItemInput {
256
267
  /** 订单支付类型 */
257
268
  order_payment_type?: 'normal' | 'deposit';
258
269
  /** 扩展参数字段 */
259
- metadata?: {
260
- /** 钱箱 ID */
261
- shop_wallet_pass_id?: string;
262
- /** 唯一支付号 */
263
- unique_payment_number?: string;
264
- /** rounding规则 */
265
- rounding_rule?: any;
266
- /** 实付金额(现金支付时的实际给出金额) */
267
- actual_paid_amount?: number;
268
- /** 找零金额(现金支付时的找零金额) */
269
- change_given_amount?: number;
270
- };
270
+ metadata?: PaymentItemMetadata;
271
271
  /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
272
272
  created_at?: string;
273
273
  /** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
@@ -302,6 +302,8 @@ export interface PaymentUpdateFields {
302
302
  voucher_id?: string;
303
303
  /** 该支付项是否已经同步给后端服务器(只有网络请求成功后才为true) */
304
304
  isSynced?: boolean;
305
+ /** 支付项扩展元数据;更新时与原 metadata 浅合并 */
306
+ metadata?: PaymentItemMetadata;
305
307
  /** 同步错误信息(业务错误时记录错误信息,用于区分"未同步"和"同步失败") */
306
308
  syncError?: {
307
309
  error: string;
@@ -9,6 +9,26 @@ export interface ProductCollection {
9
9
  /** 商品集合封面 */
10
10
  cover: string;
11
11
  }
12
+ /**
13
+ * 商品 Data Variant 记录,结构与后端 data_variant 表对齐。
14
+ */
15
+ export interface ProductDataVariant {
16
+ /** 变体记录 id */
17
+ id: number;
18
+ /** 店铺 id */
19
+ shop_id: number;
20
+ /** 所属模块,商品场景固定为 product */
21
+ module: string;
22
+ /** 模块数据 id,商品场景对应 product.id */
23
+ module_data_id: number;
24
+ /** 关联 data_variant_rule.id */
25
+ data_variant_rule_id: number;
26
+ /** 命中策略后覆盖到商品上的字段 */
27
+ data: Record<string, any>;
28
+ created_at: string | null;
29
+ updated_at: string | null;
30
+ deleted_at: string | null;
31
+ }
12
32
  /**
13
33
  * 商品基本信息接口
14
34
  */
@@ -214,6 +234,8 @@ export interface ProductData {
214
234
  bundle_group_count: number;
215
235
  /** 选项组数量 */
216
236
  option_group_count: number;
237
+ /** 智能定价变体列表,/product/query with dataVariants 返回 */
238
+ data_variants?: ProductDataVariant[];
217
239
  /** 服务时长 */
218
240
  service_times?: any;
219
241
  }
@@ -26,7 +26,7 @@ export declare class ProductList extends BaseModule implements Module {
26
26
  * const products = await productList.getAddTimeProducts({ schedule_date: '2026-06-16' });
27
27
  */
28
28
  getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<any>;
29
- loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, }?: ProductListLoadProductsParams, options?: {
29
+ loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, strategy_context, }?: ProductListLoadProductsParams, options?: {
30
30
  callback?: (result: any) => void;
31
31
  subscriberId?: string;
32
32
  }): Promise<any>;
@@ -95,7 +95,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
95
95
  cacheId,
96
96
  with_schedule,
97
97
  extension_type,
98
- status = "published"
98
+ status = "published",
99
+ strategy_context
99
100
  } = {}, options) {
100
101
  var _a, _b;
101
102
  let userPlugin = this.core.getPlugin("user");
@@ -135,7 +136,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
135
136
  is_eject: 1,
136
137
  with_schedule,
137
138
  schedule_datetime,
138
- extension_type
139
+ extension_type,
140
+ strategy_context
139
141
  },
140
142
  { osServer: true, callback: options == null ? void 0 : options.callback, subscriberId: options == null ? void 0 : options.subscriberId, customToast: () => {
141
143
  } }
@@ -12,6 +12,8 @@ export interface ProductListLoadProductsParams {
12
12
  with_schedule?: number;
13
13
  extension_type?: string[];
14
14
  status?: string;
15
+ /** 智能定价条件上下文,仅影响策略命中,不参与商品集合筛选 */
16
+ strategy_context?: Record<string, any>;
15
17
  }
16
18
  export interface ProductListData {
17
19
  list: ProductData[];
@@ -1,8 +1,7 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, UnavailableReason } from './types';
3
+ import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, RulesCalcDiscountOptions, UnavailableReason } from './types';
4
4
  import { Discount } from '../Discount/types';
5
- import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
6
5
  import { WindowPlugin } from '../../plugins';
7
6
  export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
8
7
  protected defaultName: string;
@@ -46,12 +45,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
46
45
  }[];
47
46
  isFormSubject: RulesFormSubject;
48
47
  orderTotalAmount: number;
49
- }, options?: {
50
- isSelected?: boolean;
51
- discountId?: number;
52
- selectedList?: SetDiscountSelectedParams[];
53
- scan?: boolean;
54
- }): DiscountResult;
48
+ }, options?: RulesCalcDiscountOptions): DiscountResult;
55
49
  /**
56
50
  * 检查优惠是否符合 PackageSubItemUsageRules 配置
57
51
  * @param discount 优惠券
@@ -219,6 +219,36 @@ var RulesModule = class extends import_BaseModule.BaseModule {
219
219
  var _a;
220
220
  const resolveIsFormSubject = (product) => typeof isFormSubject === "function" ? Boolean(isFormSubject(product)) : Boolean(isFormSubject);
221
221
  const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
222
+ const reapplyBookingDiscountProductUids = new Set(
223
+ ((options == null ? void 0 : options.reapplyBookingDiscountProductUids) || []).filter((uid) => uid !== void 0 && uid !== null && uid !== "").map(String)
224
+ );
225
+ const getOriginProductUid = (originProduct) => {
226
+ var _a2;
227
+ const uid = ((_a2 = originProduct == null ? void 0 : originProduct.metadata) == null ? void 0 : _a2.unique_identification_number) ?? (originProduct == null ? void 0 : originProduct.unique_identification_number);
228
+ if (uid === void 0 || uid === null || uid === "")
229
+ return void 0;
230
+ return String(uid);
231
+ };
232
+ const shouldReapplyBookingDiscount = (originProduct, selectedDiscount) => {
233
+ if (!selectedDiscount)
234
+ return false;
235
+ const uid = getOriginProductUid(originProduct);
236
+ if (!uid || !reapplyBookingDiscountProductUids.has(uid))
237
+ return false;
238
+ const discountType = selectedDiscount.tag || selectedDiscount.type;
239
+ return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ["good_pass", "discount_card", "product_discount_card"].includes(discountType);
240
+ };
241
+ const resolveReapplyEditModeDiscountPercent = (originProduct, selectedDiscount) => {
242
+ var _a2;
243
+ if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount))
244
+ return void 0;
245
+ const discountType = (selectedDiscount == null ? void 0 : selectedDiscount.tag) || (selectedDiscount == null ? void 0 : selectedDiscount.type);
246
+ if (discountType !== "discount_card" && discountType !== "product_discount_card") {
247
+ return void 0;
248
+ }
249
+ const percent = Number((_a2 = selectedDiscount.discount) == null ? void 0 : _a2.percent);
250
+ return Number.isFinite(percent) ? percent : void 0;
251
+ };
222
252
  const editModeDiscount = [];
223
253
  const addModeDiscount = [];
224
254
  discountList.forEach((discount) => {
@@ -242,9 +272,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
242
272
  }
243
273
  });
244
274
  }
245
- const filteredDiscountList = addModeDiscount.filter((discount) => {
246
- return !discount.isManualSelect;
247
- });
248
275
  const hasDiscountInput = editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options == null ? void 0 : options.discountId) || Boolean((_a = options == null ? void 0 : options.selectedList) == null ? void 0 : _a.length) || Boolean(options == null ? void 0 : options.scan);
249
276
  if (!hasDiscountInput) {
250
277
  return {
@@ -252,6 +279,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
252
279
  productList
253
280
  };
254
281
  }
282
+ const canUseEditModeDiscountForReapply = (discount) => {
283
+ const discountType = discount.tag || discount.type;
284
+ return reapplyBookingDiscountProductUids.size > 0 && discount.isEditMode === true && discount.isSelected === true && ["good_pass", "discount_card", "product_discount_card"].includes(discountType);
285
+ };
286
+ const filteredDiscountList = [
287
+ ...addModeDiscount.filter((discount) => !discount.isManualSelect),
288
+ ...editModeDiscount.filter(canUseEditModeDiscountForReapply)
289
+ ];
255
290
  const flattenProductsWithBundle = (productList2) => {
256
291
  const flattened = [];
257
292
  productList2.forEach((originProduct) => {
@@ -753,9 +788,18 @@ var RulesModule = class extends import_BaseModule.BaseModule {
753
788
  if (this.isItemRewardProductDiscount(product))
754
789
  return false;
755
790
  const discountType = discount.tag || discount.type;
791
+ const currentOriginUid = getOriginProductUid(originProduct);
792
+ const isReapplyEditModeDiscountForProduct = discount.isEditMode && reapplyBookingDiscountProductUids.size > 0 && currentOriginUid && reapplyBookingDiscountProductUids.has(String(currentOriginUid)) && discount.isSelected === true;
793
+ if (discount.isEditMode && reapplyBookingDiscountProductUids.size > 0) {
794
+ const uid = currentOriginUid;
795
+ if (!uid || !reapplyBookingDiscountProductUids.has(uid))
796
+ return false;
797
+ if (!discount.isSelected)
798
+ return false;
799
+ }
756
800
  if (["good_pass", "discount_card", "product_discount_card"].includes(
757
801
  discountType
758
- )) {
802
+ ) && !isReapplyEditModeDiscountForProduct) {
759
803
  if (discount.config === void 0 || !((_a3 = discount == null ? void 0 : discount.config) == null ? void 0 : _a3.isAvailable)) {
760
804
  return false;
761
805
  }
@@ -974,7 +1018,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
974
1018
  }
975
1019
  return;
976
1020
  }
977
- if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === "undefined" && !(options == null ? void 0 : options.scan) && !isEditModeAddNewProduct) {
1021
+ const shouldReapplyBookingDiscountForProduct = shouldReapplyBookingDiscount(originProduct, selectedDiscount);
1022
+ if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === "undefined" && !(options == null ? void 0 : options.scan) && !isEditModeAddNewProduct && !shouldReapplyBookingDiscountForProduct) {
978
1023
  return;
979
1024
  }
980
1025
  const isNeedSplit = (selectedDiscount.tag || selectedDiscount.type) === "good_pass";
@@ -1030,10 +1075,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1030
1075
  let productDiscountDifference;
1031
1076
  let discountedOptions = product.options;
1032
1077
  let optionDiscountAmount = 0;
1078
+ let reapplyDiscountPercent;
1033
1079
  if (isOrderLevel && productAllocation) {
1034
1080
  amount = productAllocation.discountAmount;
1035
1081
  productDiscountDifference = productAllocation.difference;
1036
1082
  mainProductSellingPrice = Math.max(new import_decimal.default(product.price).minus(amount).toNumber(), 0);
1083
+ } else if (resolveReapplyEditModeDiscountPercent(originProduct, selectedDiscount2) !== void 0) {
1084
+ const percent = resolveReapplyEditModeDiscountPercent(originProduct, selectedDiscount2);
1085
+ reapplyDiscountPercent = new import_decimal.default(percent).toFixed(2);
1086
+ mainProductSellingPrice = new import_decimal.default(product.price || 0).mul(new import_decimal.default(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
1087
+ amount = new import_decimal.default(product.price).minus(mainProductSellingPrice).toNumber();
1037
1088
  } else {
1038
1089
  mainProductSellingPrice = (0, import_utils.getDiscountAmount)(
1039
1090
  selectedDiscount2,
@@ -1068,7 +1119,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1068
1119
  title: selectedDiscount2.format_title,
1069
1120
  original_amount: product.price,
1070
1121
  product_id: originProduct.id || originProduct.product_id,
1071
- percent: selectedDiscount2.par_value,
1122
+ percent: reapplyDiscountPercent ?? selectedDiscount2.par_value,
1072
1123
  discount_product_id: selectedDiscount2.product_id
1073
1124
  },
1074
1125
  // 前端使用的num数量,为了计算优惠金额
@@ -1,4 +1,5 @@
1
1
  import { Discount } from '../Discount/types';
2
+ import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
2
3
  export declare enum UnavailableReason {
3
4
  TimeLimit = "time_limit",
4
5
  ProductNotApplicable = "product_not_applicable",
@@ -23,6 +24,14 @@ export interface DiscountResult {
23
24
  discountList: any[];
24
25
  }
25
26
  export type RulesFormSubject = boolean | ((product: any) => boolean);
27
+ export interface RulesCalcDiscountOptions {
28
+ isSelected?: boolean;
29
+ discountId?: number;
30
+ selectedList?: SetDiscountSelectedParams[];
31
+ scan?: boolean;
32
+ /** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
33
+ reapplyBookingDiscountProductUids?: string[];
34
+ }
26
35
  export interface RulesModuleAPI {
27
36
  setRulesList: (rulesList: Rules[]) => Promise<void>;
28
37
  clear: () => Promise<void>;
@@ -34,7 +43,7 @@ export interface RulesModuleAPI {
34
43
  }[];
35
44
  isFormSubject: RulesFormSubject;
36
45
  orderTotalAmount: number;
37
- }) => DiscountResult;
46
+ }, options?: RulesCalcDiscountOptions) => DiscountResult;
38
47
  }
39
48
  type ProductDetail = {
40
49
  isClient?: boolean;
@@ -47,6 +47,8 @@ declare class Server {
47
47
  private prefixRouterGet;
48
48
  router: Router;
49
49
  private productQuerySubscribers;
50
+ /** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
51
+ private productQueryScheduleTimers;
50
52
  private orderQuerySubscribers;
51
53
  private bookingQuerySubscribers;
52
54
  private bookingRemoteQuerySubscribers;
@@ -55,6 +57,7 @@ declare class Server {
55
57
  private readonly BOOKING_REMOTE_CACHE_MAX_ENTRIES;
56
58
  private salesSearchSubscribers;
57
59
  private deviceTaskActionsRegistered;
60
+ private localPaymentUpdateQueues;
58
61
  private floorPlanQuerySubscribers;
59
62
  private moduleRegistry;
60
63
  constructor(core: PisellCore);
@@ -118,6 +121,8 @@ declare class Server {
118
121
  private handleSyncSalesTask;
119
122
  private runCheckoutSync;
120
123
  private omitCheckoutSyncMode;
124
+ private buildRemoteCheckoutData;
125
+ private mergeCheckoutSyncPayments;
121
126
  private persistSyncedCheckoutOrder;
122
127
  /**
123
128
  * 将普通层 QuotationModule 的报价单计算能力桥接到 Server Products 模块。
@@ -210,6 +215,48 @@ declare class Server {
210
215
  * 根据 subscriberId 移除商品查询订阅者
211
216
  */
212
217
  removeProductQuerySubscriber(subscriberId?: string): void;
218
+ /**
219
+ * 构建商品 query 响应 data 段,附带智能定价 schedule_time_points 元数据。
220
+ */
221
+ private buildProductQueryResultPayload;
222
+ /**
223
+ * 是否启用商品 query 订阅的 schedule 时间点定时重算。
224
+ * strategy_context.enable_schedule_reload === false 时关闭。
225
+ */
226
+ private shouldScheduleProductQueryReload;
227
+ /**
228
+ * 清除指定 subscriber 的全部 schedule 定时器,防止重复 query 或 unsubscribe 后泄漏。
229
+ */
230
+ private clearSubscriberScheduleTimers;
231
+ /**
232
+ * 从 productQueryScheduleTimers 移除已触发的 timer 引用。
233
+ */
234
+ private removeScheduleTimerRef;
235
+ /**
236
+ * 计算 schedule 变价时间点到当前时刻的延迟(ms)。已过期返回 -1。
237
+ */
238
+ private computeScheduleTimePointDelayMs;
239
+ /**
240
+ * 定时重算前刷新 subscriber schedule 上下文:使用执行瞬间时间,禁止沿用首次 query 的 schedule_datetime。
241
+ */
242
+ private refreshSubscriberScheduleAtExecution;
243
+ /**
244
+ * 为 subscriber 注册智能定价 scheduleTimePoints 定时重算。
245
+ * 必须先 clearSubscriberScheduleTimers,再调用本方法。
246
+ */
247
+ private scheduleSubscriberTimePointReloads;
248
+ /**
249
+ * schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
250
+ */
251
+ private onScheduleTimePointTimerFire;
252
+ /**
253
+ * 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
254
+ */
255
+ private recomputeAndNotifySubscriber;
256
+ /**
257
+ * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
258
+ */
259
+ private syncProductQueryScheduleTimers;
213
260
  /**
214
261
  * 处理商品查询请求
215
262
  * 存储订阅者信息,便于数据变更时推送最新结果
@@ -409,6 +456,18 @@ declare class Server {
409
456
  */
410
457
  private handleUpdateLocalOrder;
411
458
  private handleOrderSalesCheckout;
459
+ private handleOrderSalesDraft;
460
+ private createLocalPaymentOperationId;
461
+ private buildLocalPaymentOrderLogContext;
462
+ private isValidLocalPaymentDecimal;
463
+ private getInvalidLocalPaymentSurchargeFields;
464
+ private buildLocalPaymentSurchargeUpdate;
465
+ private handleGetLocalPayment;
466
+ private handleUpdateLocalPayment;
467
+ private runLocalPaymentUpdateInQueue;
468
+ private processLocalPaymentUpdate;
469
+ private processSuccessfulLocalPayment;
470
+ private sanitizeLocalRecoveryOrder;
412
471
  private handleOrderCheckout;
413
472
  private getDeviceTaskPlugin;
414
473
  private getIdGeneratorPlugin;
@@ -436,6 +495,7 @@ declare class Server {
436
495
  private syncMachinecodeRedeemStatusToLocalOrder;
437
496
  private handleOrderCheckoutSubmit;
438
497
  private handleSyncCheckoutSubmit;
498
+ private handleOrderDraftSubmit;
439
499
  private handlePendingSyncCheckoutOrder;
440
500
  private buildPendingSyncCheckoutOrder;
441
501
  private shouldBuildSmallTicketData;
@@ -445,6 +505,11 @@ declare class Server {
445
505
  private sumPaidOrderPayments;
446
506
  private toAmountNumber;
447
507
  private buildSmallTicketProductMap;
508
+ private collectSalesDetailProductIds;
509
+ private buildSalesDetailProductSnapshotMap;
510
+ private withProductCatalogSnapshots;
511
+ private withBundleCatalogSnapshots;
512
+ private withSalesDetailProductSnapshots;
448
513
  private withPendingSyncProductTitles;
449
514
  private buildProductTitleSnapshot;
450
515
  private getProductTitleSnapshotCurrentLocale;
@@ -565,6 +630,12 @@ declare class Server {
565
630
  * @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
566
631
  */
567
632
  private computeProductQueryResult;
633
+ /**
634
+ * 构建商品格式化上下文。
635
+ *
636
+ * 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
637
+ */
638
+ private buildProductFormatterContext;
568
639
  /**
569
640
  * 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
570
641
  * 由 ProductsModule 的 onProductsSyncCompleted 事件触发