@pisell/pisellos 2.2.8 → 2.2.9

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 (35) hide show
  1. package/dist/modules/Discount/index.d.ts +1 -0
  2. package/dist/modules/Discount/index.js +1 -1
  3. package/dist/modules/Payment/cash.js +1 -1
  4. package/dist/modules/Payment/eftpos.js +1 -1
  5. package/dist/modules/Payment/index.js +102 -32
  6. package/dist/modules/Payment/types.d.ts +21 -2
  7. package/dist/modules/Payment/walletpass.js +5 -2
  8. package/dist/modules/Rules/index.d.ts +9 -2
  9. package/dist/modules/Rules/index.js +39 -6
  10. package/dist/modules/Rules/types.d.ts +4 -0
  11. package/dist/solution/BookingByStep/index.d.ts +1 -1
  12. package/dist/solution/Checkout/index.d.ts +2 -0
  13. package/dist/solution/Checkout/index.js +217 -72
  14. package/dist/solution/Checkout/types.d.ts +2 -0
  15. package/dist/solution/ShopDiscount/index.d.ts +3 -0
  16. package/dist/solution/ShopDiscount/index.js +16 -5
  17. package/dist/solution/ShopDiscount/types.d.ts +5 -0
  18. package/lib/modules/Discount/index.d.ts +1 -0
  19. package/lib/modules/Discount/index.js +1 -1
  20. package/lib/modules/Payment/cash.js +1 -1
  21. package/lib/modules/Payment/eftpos.js +1 -1
  22. package/lib/modules/Payment/index.js +71 -11
  23. package/lib/modules/Payment/types.d.ts +21 -2
  24. package/lib/modules/Payment/walletpass.js +6 -4
  25. package/lib/modules/Rules/index.d.ts +9 -2
  26. package/lib/modules/Rules/index.js +40 -9
  27. package/lib/modules/Rules/types.d.ts +4 -0
  28. package/lib/solution/BookingByStep/index.d.ts +1 -1
  29. package/lib/solution/Checkout/index.d.ts +2 -0
  30. package/lib/solution/Checkout/index.js +121 -10
  31. package/lib/solution/Checkout/types.d.ts +2 -0
  32. package/lib/solution/ShopDiscount/index.d.ts +3 -0
  33. package/lib/solution/ShopDiscount/index.js +12 -4
  34. package/lib/solution/ShopDiscount/types.d.ts +5 -0
  35. package/package.json +1 -1
@@ -50,7 +50,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
50
50
  productList: [],
51
51
  discount: null,
52
52
  rules: null,
53
- originalDiscountList: []
53
+ originalDiscountList: [],
54
+ holders: []
54
55
  };
55
56
  return _this;
56
57
  }
@@ -233,7 +234,14 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
233
234
  return _setCustomer.apply(this, arguments);
234
235
  }
235
236
  return setCustomer;
236
- }() // 计算优惠券
237
+ }() // 设置holders
238
+ }, {
239
+ key: "setHolders",
240
+ value: function setHolders(holders) {
241
+ this.store.holders = holders;
242
+ }
243
+
244
+ // 计算优惠券
237
245
  }, {
238
246
  key: "calcDiscount",
239
247
  value: function calcDiscount(productList, options) {
@@ -247,7 +255,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
247
255
  }
248
256
  var _ref = rulesModule.calcDiscount({
249
257
  productList: productList,
250
- discountList: this.getDiscountList()
258
+ discountList: this.getDiscountList(),
259
+ holders: this.store.holders || []
251
260
  }, options) || {
252
261
  productList: productList,
253
262
  discountList: this.getDiscountList()
@@ -385,7 +394,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
385
394
  _ref2 = rulesModule.isDiscountListAvailable({
386
395
  productList: this.store.productList || [],
387
396
  oldDiscountList: this.getDiscountList(),
388
- newDiscountList: withScanList
397
+ newDiscountList: withScanList,
398
+ holders: this.store.holders || []
389
399
  }) || {
390
400
  isAvailable: false,
391
401
  productList: this.store.productList || [],
@@ -665,7 +675,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
665
675
  customer_id: customerId,
666
676
  action: 'create',
667
677
  with_good_pass: 1,
668
- with_discount_card: 1
678
+ with_discount_card: 1,
679
+ with_wallet_pass_holder: 1
669
680
  });
670
681
  case 4:
671
682
  goodPassList = _context9.sent;
@@ -23,6 +23,11 @@ export interface ShopDiscountState {
23
23
  rules: RulesModule | null;
24
24
  productList: Record<string, any>[];
25
25
  originalDiscountList: Discount[];
26
+ holders?: {
27
+ form_record_id: number;
28
+ form_id?: number;
29
+ main_field?: string;
30
+ }[];
26
31
  }
27
32
  export interface SetDiscountSelectedParams {
28
33
  discountId: number;
@@ -19,6 +19,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
19
19
  with_good_pass: 0 | 1;
20
20
  with_discount_card: 0 | 1;
21
21
  customer_id: number;
22
+ with_wallet_pass_holder: 0 | 1;
22
23
  }): Promise<Discount[]>;
23
24
  batchSearch(code: string, customerId?: number): Promise<Discount[]>;
24
25
  filterEnabledDiscountList(discountList: Discount[]): Discount[];
@@ -96,7 +96,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
96
96
  tags: ["good_pass", "product_discount_card"],
97
97
  available: 1,
98
98
  relation_product: 1,
99
- with: ["extensionData"],
99
+ with: ["extensionData", "holder.detail"],
100
100
  order_behavior_count: 1,
101
101
  order_behavior_count_customer_id: customerId || 1
102
102
  });
@@ -35,7 +35,7 @@ var CashPaymentImpl = class {
35
35
  const paymentItem = {
36
36
  amount: amount.toString(),
37
37
  code: cashMethod.code,
38
- id: cashMethod.id,
38
+ custom_payment_id: cashMethod.id,
39
39
  name: cashMethod.name,
40
40
  type: cashMethod.type,
41
41
  voucher_id: ""
@@ -34,7 +34,7 @@ var EftposPaymentImpl = class {
34
34
  const paymentItem = {
35
35
  amount: amount.toString(),
36
36
  code: eftposMethod.code,
37
- id: eftposMethod.id,
37
+ custom_payment_id: eftposMethod.id,
38
38
  name: eftposMethod.name,
39
39
  type: eftposMethod.type,
40
40
  voucher_id: ""
@@ -41,6 +41,15 @@ function formatAmount(amount) {
41
41
  return "0.00";
42
42
  }
43
43
  }
44
+ function formatDateTime(date) {
45
+ const year = date.getFullYear();
46
+ const month = String(date.getMonth() + 1).padStart(2, "0");
47
+ const day = String(date.getDate()).padStart(2, "0");
48
+ const hours = String(date.getHours()).padStart(2, "0");
49
+ const minutes = String(date.getMinutes()).padStart(2, "0");
50
+ const seconds = String(date.getSeconds()).padStart(2, "0");
51
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
52
+ }
44
53
  function generateRequestUniqueId() {
45
54
  const now = /* @__PURE__ */ new Date();
46
55
  const year = now.getFullYear();
@@ -308,7 +317,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
308
317
  */
309
318
  async getPaymentOrderByUuidAsync(orderUuid) {
310
319
  try {
311
- return await this.dbManager.get("order", orderUuid);
320
+ return await this.dbManager.get("order", orderUuid, true);
312
321
  } catch (error) {
313
322
  console.error("[PaymentModule] 获取支付订单失败", error);
314
323
  return null;
@@ -337,8 +346,35 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
337
346
  is_deposit: params.is_deposit || 0,
338
347
  deposit_amount: params.deposit_amount || "0.00"
339
348
  };
349
+ if (params.existPayment && params.existPayment.length > 0) {
350
+ const currentTime = formatDateTime(/* @__PURE__ */ new Date());
351
+ newOrder.payment = params.existPayment.map((payment) => ({
352
+ ...payment,
353
+ isSynced: true,
354
+ // 标记为已同步
355
+ status: payment.status || "active",
356
+ // 如果云端支付项已有时间戳,则保留;否则使用当前时间
357
+ created_at: payment.created_at || currentTime,
358
+ updated_at: payment.updated_at || currentTime
359
+ }));
360
+ this.recalculateOrderAmount(newOrder);
361
+ this.logInfo("创建订单时包含云端支付项", {
362
+ orderId: params.order_id,
363
+ existPaymentCount: params.existPayment.length,
364
+ totalAmount: newOrder.total_amount,
365
+ expectAmount: newOrder.expect_amount,
366
+ paymentDetails: params.existPayment.map((p) => ({
367
+ uuid: p.uuid,
368
+ code: p.code,
369
+ amount: p.amount,
370
+ status: p.status,
371
+ created_at: p.created_at,
372
+ updated_at: p.updated_at
373
+ }))
374
+ });
375
+ }
340
376
  const dbAddStartTime = Date.now();
341
- await this.dbManager.add("order", newOrder);
377
+ await this.dbManager.add("order", newOrder, true);
342
378
  const dbAddDuration = Date.now() - dbAddStartTime;
343
379
  this.logInfo("Database add operation completed", {
344
380
  operation: "dbManager.add",
@@ -502,7 +538,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
502
538
  * 为某个订单添加支付项(新方法)
503
539
  */
504
540
  async addPaymentItemAsync(orderUuid, paymentItem) {
505
- var _a, _b, _c;
541
+ var _a, _b, _c, _d;
506
542
  this.logInfo("Starting addPaymentItemAsync", {
507
543
  orderUuid,
508
544
  paymentAmount: paymentItem.amount,
@@ -510,7 +546,14 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
510
546
  orderPaymentType: paymentItem.order_payment_type
511
547
  });
512
548
  try {
549
+ this.logInfo("准备获取订单", {
550
+ orderUuid
551
+ });
513
552
  const order = await this.getPaymentOrderByUuidAsync(orderUuid);
553
+ this.logInfo("获取订单信息成功", {
554
+ orderUuid,
555
+ order
556
+ });
514
557
  if (!order) {
515
558
  throw new Error(`Order not found: ${orderUuid}`);
516
559
  }
@@ -538,10 +581,16 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
538
581
  });
539
582
  throw new Error(warningMessage);
540
583
  }
541
- const paymentUuid = (0, import_utils.getUniqueId)("payment_");
584
+ let paymentUuid;
585
+ if ((_a = paymentItem.metadata) == null ? void 0 : _a.unique_payment_number) {
586
+ paymentUuid = paymentItem.metadata.unique_payment_number;
587
+ } else {
588
+ paymentUuid = (0, import_utils.getUniqueId)("payment_");
589
+ }
590
+ const currentTime = formatDateTime(/* @__PURE__ */ new Date());
542
591
  const newPaymentItem = {
543
592
  uuid: paymentUuid,
544
- id: paymentItem.id || 0,
593
+ custom_payment_id: paymentItem.custom_payment_id || 0,
545
594
  name: paymentItem.name,
546
595
  code: paymentItem.code,
547
596
  type: paymentItem.type,
@@ -553,6 +602,10 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
553
602
  // 新支付项默认为活跃状态
554
603
  order_payment_type: paymentItem.order_payment_type || "normal",
555
604
  // 默认为正常支付
605
+ created_at: currentTime,
606
+ // 创建时间
607
+ updated_at: currentTime,
608
+ // 更新时间
556
609
  metadata: {
557
610
  ...paymentItem.metadata,
558
611
  // 保留传入的所有 metadata 字段
@@ -562,23 +615,30 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
562
615
  };
563
616
  order.payment.push(newPaymentItem);
564
617
  this.recalculateOrderAmount(order);
565
- await this.dbManager.update("order", order);
566
- await this.core.effects.emit(`${this.name}:onPaymentAdded`, {
618
+ this.logInfo("开始更新订单支付项", {
619
+ orderUuid,
620
+ order
621
+ });
622
+ await this.dbManager.update("order", order, true);
623
+ this.logInfo("更新订单支付项完成", {
624
+ orderUuid
625
+ });
626
+ this.core.effects.emit(import_types.PaymentHooks.OnPaymentAdded, {
567
627
  orderUuid,
568
628
  payment: newPaymentItem
569
629
  });
570
630
  this.logInfo("addPaymentItemAsync completed successfully", {
571
631
  orderUuid,
572
632
  paymentUuid: newPaymentItem.uuid,
573
- uniquePaymentNumber: (_a = newPaymentItem.metadata) == null ? void 0 : _a.unique_payment_number,
633
+ uniquePaymentNumber: (_b = newPaymentItem.metadata) == null ? void 0 : _b.unique_payment_number,
574
634
  newExpectAmount: order.expect_amount,
575
635
  paymentAmount: newPaymentItem.amount,
576
636
  paymentCode: newPaymentItem.code,
577
637
  orderPaymentType: newPaymentItem.order_payment_type,
578
638
  metadataFields: Object.keys(newPaymentItem.metadata || {}),
579
639
  // 现金支付找零信息
580
- actualPaidAmount: (_b = newPaymentItem.metadata) == null ? void 0 : _b.actual_paid_amount,
581
- changeGivenAmount: (_c = newPaymentItem.metadata) == null ? void 0 : _c.change_given_amount
640
+ actualPaidAmount: (_c = newPaymentItem.metadata) == null ? void 0 : _c.actual_paid_amount,
641
+ changeGivenAmount: (_d = newPaymentItem.metadata) == null ? void 0 : _d.change_given_amount
582
642
  });
583
643
  } catch (error) {
584
644
  console.error("[PaymentModule] 添加支付项失败", error);
@@ -797,7 +857,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
797
857
  uuid: payment.uuid,
798
858
  amount: payment.amount,
799
859
  code: payment.code,
800
- id: payment.id,
860
+ custom_payment_id: payment.custom_payment_id,
801
861
  name: payment.name,
802
862
  type: payment.type,
803
863
  voucher_id: payment.voucher_id,
@@ -96,7 +96,7 @@ export interface PaymentItem {
96
96
  /** 支付类型,跟支付列表上对应的支付方式保持一致 */
97
97
  code: string;
98
98
  /** 支付类型id,跟支付列表上对应的支付方式保持一致 */
99
- id: number;
99
+ custom_payment_id: number;
100
100
  /** 支付类型名称,跟支付列表上对应的支付方式保持一致 */
101
101
  name: string;
102
102
  /** 支付类型type,跟支付列表上对应的支付方式保持一致 */
@@ -138,6 +138,10 @@ export interface PaymentItem {
138
138
  statusCode?: number;
139
139
  timestamp: number;
140
140
  };
141
+ /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss) */
142
+ created_at?: string;
143
+ /** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss) */
144
+ updated_at?: string;
141
145
  }
142
146
  /**
143
147
  * 订单信息
@@ -200,6 +204,8 @@ export interface PushOrderParams {
200
204
  deposit_amount?: string;
201
205
  /** 原始订单数据(可选,由 Checkout 模块传入) */
202
206
  order_info?: any;
207
+ /** 云端已存在的支付项(可选,用于处理订单在其他设备或云端生成的场景) */
208
+ existPayment?: PaymentItem[];
203
209
  }
204
210
  /**
205
211
  * 更新订单参数
@@ -219,7 +225,7 @@ export interface PaymentItemInput {
219
225
  /** 支付类型,跟支付列表上对应的支付方式保持一致 */
220
226
  code: string;
221
227
  /** 支付类型id,跟支付列表上对应的支付方式保持一致 */
222
- id: number;
228
+ custom_payment_id: number;
223
229
  /** 支付类型名称,跟支付列表上对应的支付方式保持一致 */
224
230
  name: string;
225
231
  /** 支付类型type,跟支付列表上对应的支付方式保持一致 */
@@ -248,6 +254,10 @@ export interface PaymentItemInput {
248
254
  /** 找零金额(现金支付时的找零金额) */
249
255
  change_given_amount?: number;
250
256
  };
257
+ /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
258
+ created_at?: string;
259
+ /** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
260
+ updated_at?: string;
251
261
  }
252
262
  /**
253
263
  * 推送支付项参数
@@ -598,6 +608,8 @@ export interface WalletDeductionRecommendParams {
598
608
  expect_columns?: string[];
599
609
  /** 客户id */
600
610
  customer_id?: number;
611
+ /** 客户holder_id */
612
+ holder_id?: number;
601
613
  /** 订单总计金额 */
602
614
  order_expect_amount: number;
603
615
  /** 订单小计金额 */
@@ -616,6 +628,8 @@ export interface WalletDeductionRecommendParams {
616
628
  quantity: number;
617
629
  /** 商品使用了所有优惠后的最终价格 */
618
630
  selling_price: number;
631
+ /** 客户holder_id */
632
+ holder_id?: number;
619
633
  }[];
620
634
  /** 预备支付 */
621
635
  prepare_payments?: {
@@ -633,6 +647,10 @@ export interface WalletDeductionRecommendParams {
633
647
  export interface WalletInitBusinessData {
634
648
  /** 客户ID(可选) */
635
649
  customer_id?: number;
650
+ /** 客户 holder */
651
+ holder?: {
652
+ form_record: number[];
653
+ };
636
654
  /** 金额信息 */
637
655
  amountInfo: {
638
656
  totalAmount: string;
@@ -648,6 +666,7 @@ export interface WalletInitBusinessData {
648
666
  product_variant_id: string;
649
667
  quantity: number;
650
668
  selling_price: number;
669
+ holder_id?: number;
651
670
  }[];
652
671
  order_wait_pay_amount?: number;
653
672
  /** 订单ID */
@@ -50,14 +50,15 @@ var WalletPassPaymentImpl = class {
50
50
  * 根据业务数据生成标准的钱包API参数,并存储在模块中
51
51
  */
52
52
  generateWalletParams(businessData) {
53
- var _a;
54
- const { customer_id, amountInfo, products, order_wait_pay_amount, payment_order_id } = businessData;
53
+ var _a, _b;
54
+ const { customer_id, holder, amountInfo, products, order_wait_pay_amount, payment_order_id } = businessData;
55
55
  const totalAmount = Number(amountInfo.totalAmount);
56
56
  const subTotal = Number(amountInfo.subTotal);
57
57
  const walletParams = {
58
58
  sale_channel: "pos",
59
59
  customer_id: customer_id || 0,
60
60
  // 提供默认值,确保类型为 number
61
+ holder_id: ((_a = holder == null ? void 0 : holder.form_record) == null ? void 0 : _a[0]) || void 0,
61
62
  order_expect_amount: totalAmount,
62
63
  // 订单小计金额
63
64
  order_product_amount: subTotal,
@@ -71,10 +72,11 @@ var WalletPassPaymentImpl = class {
71
72
  this.walletParams = walletParams;
72
73
  this.paymentModule.logInfo("[WalletPass] 钱包默认参数已生成并存储", {
73
74
  customer_id: walletParams.customer_id,
75
+ holder_id: walletParams.holder_id,
74
76
  order_expect_amount: walletParams.order_expect_amount,
75
77
  order_product_amount: walletParams.order_product_amount,
76
78
  order_wait_pay_amount: walletParams.order_wait_pay_amount,
77
- products_count: ((_a = walletParams.products) == null ? void 0 : _a.length) || 0
79
+ products_count: ((_b = walletParams.products) == null ? void 0 : _b.length) || 0
78
80
  });
79
81
  return walletParams;
80
82
  }
@@ -387,7 +389,7 @@ var WalletPassPaymentImpl = class {
387
389
  const paymentItem = {
388
390
  amount: amount.toString(),
389
391
  code: walletMethod.code,
390
- id: walletMethod.id,
392
+ custom_payment_id: walletMethod.id,
391
393
  name: walletMethod.name,
392
394
  type: walletMethod.type,
393
395
  voucher_id: voucherId || ""
@@ -12,18 +12,25 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
12
12
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
13
13
  setRulesList(rulesList: Rules[]): Promise<void>;
14
14
  getRulesList(): Rules[];
15
- isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, }: {
15
+ private checkHolderMatch;
16
+ isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, }: {
16
17
  oldDiscountList: Discount[];
17
18
  newDiscountList: Discount[];
18
19
  productList: any[];
20
+ holders: {
21
+ form_record_id: number;
22
+ }[];
19
23
  }): {
20
24
  isAvailable: boolean;
21
25
  discountList: Discount[];
22
26
  productList: any[];
23
27
  };
24
- calcDiscount({ discountList, productList, }: {
28
+ calcDiscount({ discountList, productList, holders, }: {
25
29
  discountList: Discount[];
26
30
  productList: any[];
31
+ holders: {
32
+ form_record_id: number;
33
+ }[];
27
34
  }, options?: {
28
35
  isSelected?: boolean;
29
36
  discountId?: number;
@@ -37,6 +37,7 @@ var import_utils = require("../../solution/ShopDiscount/utils");
37
37
  var import_utils2 = require("../Cart/utils");
38
38
  var import_decimal = __toESM(require("decimal.js"));
39
39
  var import_lodash_es = require("lodash-es");
40
+ var flatItem;
40
41
  var RulesModule = class extends import_BaseModule.BaseModule {
41
42
  constructor(name, version) {
42
43
  super(name, version);
@@ -56,11 +57,23 @@ var RulesModule = class extends import_BaseModule.BaseModule {
56
57
  getRulesList() {
57
58
  return this.store.rulesList;
58
59
  }
60
+ // 检查 holder 是否匹配
61
+ checkHolderMatch(discount, product, holders) {
62
+ var _a;
63
+ if (((_a = discount.holder) == null ? void 0 : _a.holder_type) !== "form")
64
+ return true;
65
+ const orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : void 0;
66
+ const productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
67
+ if (!orderHolderId && !productHolderId)
68
+ return true;
69
+ return (productHolderId || orderHolderId) === discount.holder.holder_id;
70
+ }
59
71
  // 判断discountList 是否可以对当前productList生效
60
72
  isDiscountListAvailable({
61
73
  oldDiscountList,
62
74
  newDiscountList,
63
- productList
75
+ productList,
76
+ holders
64
77
  }) {
65
78
  if (!newDiscountList || newDiscountList.length === 0) {
66
79
  return {
@@ -87,7 +100,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
87
100
  ]), "product_id");
88
101
  const result = this.calcDiscount({
89
102
  discountList: mergedDiscountList,
90
- productList: [...productList]
103
+ productList: [...productList],
104
+ holders
91
105
  }, {
92
106
  scan: true
93
107
  });
@@ -115,7 +129,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
115
129
  }
116
130
  calcDiscount({
117
131
  discountList,
118
- productList
132
+ productList,
133
+ holders
119
134
  }, options) {
120
135
  const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
121
136
  const editModeDiscount = [];
@@ -197,12 +212,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
197
212
  sortedProductList.forEach((originProduct) => {
198
213
  const product = this.hooks.getProduct(originProduct);
199
214
  addModeDiscount.forEach((discount) => {
200
- var _a, _b, _c, _d;
215
+ var _a, _b, _c, _d, _e, _f;
201
216
  const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
202
- const isLimitedProduct = limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id);
203
- const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount2.tag || discount2.type))));
217
+ const isHolderMatch = this.checkHolderMatch(
218
+ discount,
219
+ {
220
+ holder_id: ((flatItem == null ? void 0 : flatItem.type) === "bundle" ? (_a = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _a.holder_id : (_b = flatItem == null ? void 0 : flatItem.product) == null ? void 0 : _b.holder_id) || product.holder_id
221
+ },
222
+ holders
223
+ );
224
+ const isLimitedProduct = (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
225
+ const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_c = product == null ? void 0 : product.discount_list) == null ? void 0 : _c.length) && ((_d = product == null ? void 0 : product.discount_list) == null ? void 0 : _d.every((discount2) => discount2.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount2.tag || discount2.type))));
204
226
  if (isAvailableProduct && isLimitedProduct) {
205
- (_c = discountApplicability.get(discount.id)) == null ? void 0 : _c.push(product.id);
227
+ (_e = discountApplicability.get(discount.id)) == null ? void 0 : _e.push(product.id);
206
228
  const applicableProducts = discountApplicableProducts.get(discount.id) || [];
207
229
  const discountType = discount.tag || discount.type;
208
230
  const productData = {
@@ -210,7 +232,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
210
232
  type: discountType,
211
233
  tag: discountType,
212
234
  discount: {
213
- discount_card_type: (_d = discount == null ? void 0 : discount.metadata) == null ? void 0 : _d.discount_card_type,
235
+ discount_card_type: (_f = discount == null ? void 0 : discount.metadata) == null ? void 0 : _f.discount_card_type,
214
236
  fixed_amount: product.price,
215
237
  resource_id: discount.id,
216
238
  title: discount.format_title,
@@ -236,7 +258,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
236
258
  return;
237
259
  }
238
260
  const applicableDiscounts = sortedDiscountList.filter((discount) => {
239
- var _a2;
261
+ var _a2, _b2, _c2;
240
262
  if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
241
263
  return false;
242
264
  if ((Number(product.total) <= 0 || !product.total) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
@@ -248,6 +270,15 @@ var RulesModule = class extends import_BaseModule.BaseModule {
248
270
  if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
249
271
  return false;
250
272
  const limitedData = discount.limited_relation_product_data;
273
+ const isHolderMatch = this.checkHolderMatch(
274
+ discount,
275
+ {
276
+ holder_id: ((flatItem == null ? void 0 : flatItem.type) === "bundle" ? (_b2 = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _b2.holder_id : (_c2 = flatItem == null ? void 0 : flatItem.product) == null ? void 0 : _c2.holder_id) || product.holder_id
277
+ },
278
+ holders
279
+ );
280
+ if (!isHolderMatch)
281
+ return false;
251
282
  if (limitedData.type === "product_all") {
252
283
  return true;
253
284
  } else if (limitedData.product_ids && limitedData.product_ids.includes(product.id)) {
@@ -22,6 +22,9 @@ export interface RulesModuleAPI {
22
22
  calcDiscount: (params: {
23
23
  discountList: any[];
24
24
  productList: any[];
25
+ holders: {
26
+ form_record_id: number;
27
+ }[];
25
28
  }) => DiscountResult;
26
29
  }
27
30
  type ProductDetail = {
@@ -40,6 +43,7 @@ type ProductDetail = {
40
43
  num?: number;
41
44
  quantity: number;
42
45
  vouchersApplicable?: boolean;
46
+ holder_id?: number;
43
47
  };
44
48
  export interface RulesParamsHooks {
45
49
  getProduct: (product: Record<string, any>) => ProductDetail;
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  };
343
343
  setOtherData(key: string, value: any): void;
344
344
  getOtherData(key: string): any;
345
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
345
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
346
346
  /**
347
347
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
348
348
  *
@@ -48,11 +48,13 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
48
48
  * 初始化结账流程
49
49
  */
50
50
  initializeCheckoutAsync(params: CheckoutInitParams): Promise<void>;
51
+ getHolderIdFromBooking(obj: any): number | undefined;
51
52
  getProductListByOrder(): {
52
53
  product_id: number;
53
54
  product_variant_id: string;
54
55
  quantity: number;
55
56
  selling_price: number;
57
+ holder_id?: number;
56
58
  }[];
57
59
  initWalletData(params?: {
58
60
  order_wait_pay_amount: number;