@pisell/pisellos 2.1.45 → 2.1.47

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 (40) hide show
  1. package/dist/modules/Cart/utils/cartProduct.js +41 -26
  2. package/dist/modules/Discount/index.d.ts +2 -0
  3. package/dist/modules/Discount/index.js +69 -36
  4. package/dist/modules/Discount/types.d.ts +14 -0
  5. package/dist/modules/Order/index.js +4 -1
  6. package/dist/modules/Order/utils.d.ts +1 -0
  7. package/dist/modules/Order/utils.js +9 -0
  8. package/dist/modules/Product/index.d.ts +1 -1
  9. package/dist/modules/Rules/index.d.ts +7 -0
  10. package/dist/modules/Rules/index.js +1050 -192
  11. package/dist/modules/Rules/types.d.ts +4 -1
  12. package/dist/solution/BookingByStep/index.js +1 -0
  13. package/dist/solution/Checkout/index.d.ts +1 -0
  14. package/dist/solution/Checkout/index.js +69 -28
  15. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  16. package/dist/solution/ShopDiscount/index.js +81 -20
  17. package/dist/solution/ShopDiscount/types.d.ts +4 -1
  18. package/dist/solution/ShopDiscount/utils.d.ts +55 -0
  19. package/dist/solution/ShopDiscount/utils.js +418 -3
  20. package/lib/modules/Cart/utils/cartProduct.js +35 -22
  21. package/lib/modules/Discount/index.d.ts +2 -0
  22. package/lib/modules/Discount/index.js +19 -4
  23. package/lib/modules/Discount/types.d.ts +14 -0
  24. package/lib/modules/Order/index.js +2 -0
  25. package/lib/modules/Order/utils.d.ts +1 -0
  26. package/lib/modules/Order/utils.js +11 -0
  27. package/lib/modules/Product/index.d.ts +1 -1
  28. package/lib/modules/Rules/index.d.ts +7 -0
  29. package/lib/modules/Rules/index.js +809 -175
  30. package/lib/modules/Rules/types.d.ts +4 -1
  31. package/lib/solution/BookingByStep/index.js +4 -0
  32. package/lib/solution/BookingTicket/index.js +0 -6
  33. package/lib/solution/Checkout/index.d.ts +1 -0
  34. package/lib/solution/Checkout/index.js +58 -16
  35. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  36. package/lib/solution/ShopDiscount/index.js +56 -10
  37. package/lib/solution/ShopDiscount/types.d.ts +4 -1
  38. package/lib/solution/ShopDiscount/utils.d.ts +55 -0
  39. package/lib/solution/ShopDiscount/utils.js +257 -3
  40. package/package.json +1 -1
@@ -40,6 +40,7 @@ type ProductDetail = {
40
40
  num?: number;
41
41
  quantity: number;
42
42
  vouchersApplicable?: boolean;
43
+ startDate?: any;
43
44
  };
44
45
  export interface RulesParamsHooks {
45
46
  getProduct: (product: Record<string, any>) => ProductDetail;
@@ -50,8 +51,10 @@ export interface RulesParamsHooks {
50
51
  origin_total?: number;
51
52
  price?: string | number;
52
53
  variant?: any[];
53
- original_price?: number;
54
+ original_price?: number | string;
54
55
  quantity?: number;
56
+ bundle?: any[];
57
+ main_product_selling_price?: string | number;
55
58
  }) => Record<string, any>;
56
59
  }
57
60
  export {};
@@ -2313,6 +2313,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2313
2313
  }
2314
2314
  });
2315
2315
  });
2316
+ this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateBookingDate"), {});
2316
2317
  }
2317
2318
  }, {
2318
2319
  key: "getScheduleDataByIds",
@@ -48,6 +48,7 @@ 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;
@@ -371,10 +371,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
371
371
  }
372
372
  return initializeCheckoutAsync;
373
373
  }())
374
+ }, {
375
+ key: "getHolderIdFromBooking",
376
+ value: function getHolderIdFromBooking(obj) {
377
+ var _obj$holder;
378
+ if (!obj) return undefined;
379
+ var ret = obj.holder_id || ((_obj$holder = obj.holder) === null || _obj$holder === void 0 ? void 0 : _obj$holder.form_record);
380
+ if (Array.isArray(ret)) {
381
+ return ret.length > 0 ? Number(ret[0]) : undefined;
382
+ }
383
+ return Number(ret) || undefined;
384
+ }
374
385
  }, {
375
386
  key: "getProductListByOrder",
376
387
  value: function getProductListByOrder() {
377
- var _this$store$currentOr, _this$store$currentOr2;
388
+ var _this$store$currentOr,
389
+ _this3 = this,
390
+ _this$store$currentOr2;
378
391
  if (!this.store.currentOrder) {
379
392
  return [];
380
393
  }
@@ -383,22 +396,50 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
383
396
  return pre + (item.amount || 0);
384
397
  }, 0);
385
398
  };
386
- var productList = ((_this$store$currentOr = this.store.currentOrder.order_info) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.original_order_data.bookings) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.map(function (item) {
387
- return {
388
- product_id: item.product.product_id,
389
- product_variant_id: item.product.product_variant_id,
390
- quantity: item.product.num,
391
- selling_price: item.product.calculated_selling_price
392
- };
393
- })) || [];
394
- var relationProducts = ((_this$store$currentOr2 = this.store.currentOrder.order_info) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.original_order_data) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.relation_products) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.map(function (item) {
395
- return {
396
- product_id: item.product_id,
397
- product_variant_id: item.product_variant_id,
398
- quantity: item.num,
399
- selling_price: item.source_product_price
400
- };
401
- })) || [];
399
+ var formatProduct = function formatProduct(items) {
400
+ return items.map(function (item) {
401
+ var _item$is_charge_tax;
402
+ return {
403
+ product_id: item.product_id,
404
+ product_variant_id: item.product_variant_id,
405
+ quantity: item.num,
406
+ // 商品是否含税:1;0
407
+ is_charge_tax: (_item$is_charge_tax = item.is_charge_tax) !== null && _item$is_charge_tax !== void 0 ? _item$is_charge_tax : 0,
408
+ // 若商品不含税,计算得到的税费,单位(元)
409
+ tax_fee: item.tax_fee,
410
+ // 整个商品折扣后的总金额
411
+ selling_price: item.calculated_selling_price,
412
+ // 使用者id
413
+ holder_id: item.holder_id,
414
+ // 整个商品折扣前的总金额
415
+ original_price: item.calculated_original_price,
416
+ // 主商品折扣前金额,不包含套餐子商品
417
+ main_product_original_price: item.price,
418
+ // 主商品折扣后金额,不包含套餐子商品
419
+ main_product_selling_price: item.main_product_selling_price,
420
+ product_bundle: item.product_bundle.map(function (bundle) {
421
+ return {
422
+ bundle_id: bundle.bundle_id,
423
+ bundle_product_id: bundle.bundle_product_id,
424
+ bundle_variant_id: bundle.bundle_variant_id,
425
+ price_type: bundle.price_type,
426
+ price_type_ext: bundle.price_type_ext,
427
+ // 套餐子商品总价,不包含折扣金额
428
+ bundle_sum_price: bundle.bundle_sum_price,
429
+ // 套餐子商品折扣后金额
430
+ bundle_selling_price: bundle.bundle_selling_price,
431
+ num: bundle.num
432
+ };
433
+ })
434
+ };
435
+ }) || [];
436
+ };
437
+ var productList = formatProduct(((_this$store$currentOr = this.store.currentOrder.order_info) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.original_order_data) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.bookings) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.map(function (item) {
438
+ return _objectSpread(_objectSpread({}, item.product), {}, {
439
+ holder_id: _this3.getHolderIdFromBooking(item)
440
+ });
441
+ })) || []);
442
+ var relationProducts = formatProduct(((_this$store$currentOr2 = this.store.currentOrder.order_info) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.original_order_data) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.relation_products) || []);
402
443
  return [].concat(_toConsumableArray(productList), _toConsumableArray(relationProducts));
403
444
  }
404
445
  }, {
@@ -1542,7 +1583,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1542
1583
  key: "updateVoucherPaymentItemsAsync",
1543
1584
  value: (function () {
1544
1585
  var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(voucherPaymentItems) {
1545
- var _this3 = this;
1586
+ var _this4 = this;
1546
1587
  var paymentItems, allPaymentItemsSynced, remainingAmount, remainingValue, isOrderSynced, orderPaymentType, voucherPaymentItemsWithType, currentOrderId, isCurrentOrderReal, updatedOrder;
1547
1588
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1548
1589
  while (1) switch (_context18.prev = _context18.next) {
@@ -1594,8 +1635,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1594
1635
 
1595
1636
  // 从 otherParams 获取 metadata 字段
1596
1637
  var metadata = _objectSpread(_objectSpread({}, item.metadata), {}, {
1597
- rounding_rule: _this3.otherParams.order_rounding_setting,
1598
- shop_wallet_pass_id: _this3.otherParams.shop_wallet_pass_id
1638
+ rounding_rule: _this4.otherParams.order_rounding_setting,
1639
+ shop_wallet_pass_id: _this4.otherParams.shop_wallet_pass_id
1599
1640
  });
1600
1641
  return _objectSpread(_objectSpread({}, item), {}, {
1601
1642
  order_payment_type: orderPaymentType,
@@ -3140,7 +3181,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3140
3181
  key: "updateStateAmountToRemaining",
3141
3182
  value: (function () {
3142
3183
  var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
3143
- var _this4 = this;
3184
+ var _this5 = this;
3144
3185
  var checkOrder,
3145
3186
  _yield$this$fetchOrde3,
3146
3187
  paymentItems,
@@ -3236,7 +3277,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3236
3277
  hasStateChanged = true;
3237
3278
  setTimeout(function () {
3238
3279
  // 发出 stateAmount 变更事件
3239
- _this4.core.effects.emit("".concat(_this4.name, ":onStateAmountChanged"), {
3280
+ _this5.core.effects.emit("".concat(_this5.name, ":onStateAmountChanged"), {
3240
3281
  oldAmount: currentStateAmount,
3241
3282
  newAmount: remainingAmount,
3242
3283
  timestamp: Date.now(),
@@ -3257,7 +3298,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3257
3298
 
3258
3299
  // 发出 balanceDueAmount 变更事件
3259
3300
  setTimeout(function () {
3260
- _this4.core.effects.emit("".concat(_this4.name, ":onBalanceDueAmountChanged"), {
3301
+ _this5.core.effects.emit("".concat(_this5.name, ":onBalanceDueAmountChanged"), {
3261
3302
  oldAmount: currentBalanceDueAmount,
3262
3303
  newAmount: remainingAmount,
3263
3304
  timestamp: Date.now(),
@@ -3555,7 +3596,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3555
3596
  key: "syncOrderToBackendWithReturn",
3556
3597
  value: (function () {
3557
3598
  var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3558
- var _this5 = this,
3599
+ var _this6 = this,
3559
3600
  _this$store$currentOr23,
3560
3601
  _this$store$currentOr24,
3561
3602
  _this$store$currentCu2,
@@ -3636,8 +3677,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3636
3677
  var _item$metadata, _item$metadata2;
3637
3678
  return _objectSpread(_objectSpread({}, item), {}, {
3638
3679
  metadata: _objectSpread(_objectSpread({}, item.metadata), {}, {
3639
- rounding_rule: ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.rounding_rule) || _this5.otherParams.order_rounding_setting,
3640
- shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) || _this5.otherParams.shop_wallet_pass_id
3680
+ rounding_rule: ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.rounding_rule) || _this6.otherParams.order_rounding_setting,
3681
+ shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) || _this6.otherParams.shop_wallet_pass_id
3641
3682
  })
3642
3683
  });
3643
3684
  }); // 确定最终的定金金额:优先使用手动设置的值,否则从支付项中计算
@@ -4344,7 +4385,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4344
4385
  }, {
4345
4386
  key: "resetStoreState",
4346
4387
  value: function resetStoreState() {
4347
- var _this6 = this;
4388
+ var _this7 = this;
4348
4389
  try {
4349
4390
  var prevOrderInfo = this.store.currentOrder ? {
4350
4391
  uuid: this.store.currentOrder.uuid,
@@ -4379,7 +4420,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4379
4420
  // 使用 setTimeout 确保事件处理不会阻塞状态重置
4380
4421
  if (prevOrderInfo) {
4381
4422
  setTimeout(function () {
4382
- _this6.core.effects.emit("".concat(_this6.name, ":onOrderCleared"), {
4423
+ _this7.core.effects.emit("".concat(_this7.name, ":onOrderCleared"), {
4383
4424
  previousOrder: prevOrderInfo,
4384
4425
  timestamp: Date.now()
4385
4426
  });
@@ -18,6 +18,8 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
18
18
  private initializePlugins;
19
19
  private registerDependentModules;
20
20
  private registerEventListeners;
21
+ getCurrentBookingTime(): string | null;
22
+ private filterDiscountListByBookingTime;
21
23
  setCustomer(customer: Customer): Promise<void>;
22
24
  calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
23
25
  productList: Record<string, any>[];
@@ -27,6 +27,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
27
27
  import { BaseModule } from "../../modules/BaseModule";
28
28
  import { DiscountModule } from "../../modules/Discount";
29
29
  import { RulesModule } from "../../modules/Rules";
30
+ import { filterDiscountListByBookingTime as _filterDiscountListByBookingTime, isAllNormalProduct } from "./utils";
30
31
  import Decimal from 'decimal.js';
31
32
  import { isBoolean } from 'lodash-es';
32
33
  export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
@@ -50,7 +51,9 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
50
51
  productList: [],
51
52
  discount: null,
52
53
  rules: null,
53
- originalDiscountList: []
54
+ originalDiscountList: [],
55
+ currentBookingTime: "",
56
+ filteredDiscountList: []
54
57
  };
55
58
  return _this;
56
59
  }
@@ -207,6 +210,55 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
207
210
 
208
211
  // =========== 公共 API ===========
209
212
 
213
+ // 设置预约时间
214
+ // public async setBookingTime(bookingTime: string | null): Promise<void> {
215
+ // if (this.store.currentBookingTime !== bookingTime) {
216
+ // this.store.currentBookingTime = bookingTime;
217
+ //
218
+ // // 更新过滤后的优惠券列表
219
+ // await this.updateFilteredDiscountList();
220
+ // }
221
+ // }
222
+
223
+ // 获取当前预约时间
224
+ }, {
225
+ key: "getCurrentBookingTime",
226
+ value: function getCurrentBookingTime() {
227
+ return this.store.currentBookingTime;
228
+ }
229
+
230
+ // 根据预约时间过滤优惠券列表
231
+ }, {
232
+ key: "filterDiscountListByBookingTime",
233
+ value: function filterDiscountListByBookingTime(discountList, bookingTime) {
234
+ // 如果全部是普通商品,不需要过滤,直接返回当前数据
235
+ if (isAllNormalProduct(this.store.productList || [])) {
236
+ return discountList;
237
+ }
238
+
239
+ // 否则使用 bookingTime 进行过滤
240
+ return _filterDiscountListByBookingTime(discountList, bookingTime);
241
+ }
242
+
243
+ // 更新过滤后的优惠券列表
244
+ // private async updateFilteredDiscountList(): Promise<void> {
245
+ // const originalList = this.store.originalDiscountList;
246
+ // const filteredList = this.filterDiscountListByBookingTime(originalList, this.store.currentBookingTime);
247
+ //
248
+ // this.store.filteredDiscountList = filteredList;
249
+ //
250
+ // // 更新 DiscountModule 中的优惠券列表
251
+ // this.setDiscountList(filteredList);
252
+ //
253
+ // if (this.store.productList?.length) {
254
+ // const result = this.calcDiscount(this.store.productList);
255
+ // await this.core.effects.emit(
256
+ // ShopDiscountHooks.onLoadPrepareCalcResult,
257
+ // result,
258
+ // );
259
+ // }
260
+ // }
261
+
210
262
  // 设置客户
211
263
  }, {
212
264
  key: "setCustomer",
@@ -497,7 +549,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
497
549
  if (index !== -1) {
498
550
  editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
499
551
  amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
500
- savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.num) || 1).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
552
+ savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
501
553
  });
502
554
  } else {
503
555
  var _discount$discount2, _discount$discount3, _discount$discount4;
@@ -508,7 +560,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
508
560
  name: discount.name || discount.discount.title.auto,
509
561
  isEditMode: true,
510
562
  limited_relation_product_data: {},
511
- savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.num) || 1),
563
+ savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1),
512
564
  isAvailable: true,
513
565
  id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
514
566
  format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
@@ -529,17 +581,20 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
529
581
  var targetProduct = productList.find(function (n) {
530
582
  return n.id === id;
531
583
  });
584
+ if (!targetProduct) return false;
532
585
  var product = (_this3$hooks2 = _this3.hooks) === null || _this3$hooks2 === void 0 ? void 0 : _this3$hooks2.getProduct(targetProduct);
533
586
  // 如果 product.total 是小于等于0有可能是她已经用过商品券或者折扣卡导致的,或者本身就是负数价格,所以此时还需要判断 origin_total 是否小于等于0
534
587
  // 如果 product.vouchersApplicable是布尔值,并且是 false,也当做免费商品处理,此商品不可用优惠券或折扣卡
535
588
  return Number(product === null || product === void 0 ? void 0 : product.total) <= 0 && (Number(product === null || product === void 0 ? void 0 : product.origin_total) <= 0 || !(product !== null && product !== void 0 && product.origin_total)) || isBoolean(product === null || product === void 0 ? void 0 : product.vouchersApplicable) && !(product !== null && product !== void 0 && product.vouchersApplicable);
536
589
  };
537
- var allUsedProductIds = newDiscountList.map(function (n) {
590
+ var allUsedProductIds = newDiscountList.filter(function (item) {
591
+ return !(item !== null && item !== void 0 && item.isEditMode);
592
+ }).map(function (n) {
538
593
  var _n$appliedProductDeta;
539
- return n.isSelected ? (_n$appliedProductDeta = n.appliedProductDetails) === null || _n$appliedProductDeta === void 0 ? void 0 : _n$appliedProductDeta.map(function (n) {
594
+ return n.isSelected ? ((_n$appliedProductDeta = n.appliedProductDetails) === null || _n$appliedProductDeta === void 0 ? void 0 : _n$appliedProductDeta.map(function (n) {
540
595
  var _n$discount;
541
596
  return (_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.product_id;
542
- }) : [];
597
+ })) || n.product_id : [];
543
598
  }).flat();
544
599
  newDiscountList.forEach(function (item) {
545
600
  var _item$applicableProdu;
@@ -652,7 +707,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
652
707
  key: "loadPrepareConfig",
653
708
  value: function () {
654
709
  var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
655
- var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, _result3;
710
+ var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
656
711
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
657
712
  while (1) switch (_context9.prev = _context9.next) {
658
713
  case 0:
@@ -678,31 +733,37 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
678
733
  newGoodPassList = goodPassList === null || goodPassList === void 0 ? void 0 : goodPassList.filter(function (n) {
679
734
  return !scanDiscountIds.includes(n.id);
680
735
  });
681
- newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || []));
736
+ newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
682
737
  this.store.originalDiscountList = newDiscountList;
683
- this.setDiscountList(newDiscountList || []);
738
+ _context9.next = 12;
739
+ return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.setOriginalDiscountList(newDiscountList);
740
+ case 12:
741
+ // 根据当前预约时间过滤优惠券列表
742
+ filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
743
+ this.store.filteredDiscountList = filteredDiscountList;
744
+ this.setDiscountList(filteredDiscountList || []);
684
745
  if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
685
- _context9.next = 15;
746
+ _context9.next = 19;
686
747
  break;
687
748
  }
688
749
  _result3 = this.calcDiscount(this.store.productList);
689
- _context9.next = 15;
750
+ _context9.next = 19;
690
751
  return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
691
- case 15:
692
- _context9.next = 17;
693
- return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
694
- case 17:
695
- _context9.next = 22;
696
- break;
697
752
  case 19:
698
- _context9.prev = 19;
753
+ _context9.next = 21;
754
+ return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
755
+ case 21:
756
+ _context9.next = 26;
757
+ break;
758
+ case 23:
759
+ _context9.prev = 23;
699
760
  _context9.t0 = _context9["catch"](0);
700
761
  console.error('[ShopDiscount] 加载准备配置出错:', _context9.t0);
701
- case 22:
762
+ case 26:
702
763
  case "end":
703
764
  return _context9.stop();
704
765
  }
705
- }, _callee9, this, [[0, 19]]);
766
+ }, _callee9, this, [[0, 23]]);
706
767
  }));
707
768
  function loadPrepareConfig(_x9) {
708
769
  return _loadPrepareConfig.apply(this, arguments);
@@ -1,5 +1,6 @@
1
- import { DiscountModule, Discount } from '../../modules/Discount';
1
+ import { DiscountModule } from '../../modules/Discount';
2
2
  import { RulesModule } from '../../modules/Rules';
3
+ import { Discount } from "../../modules/Discount/types";
3
4
  export declare enum ShopDiscountHooks {
4
5
  onInited = "shopDiscount:onInited",
5
6
  onDestroy = "shopDiscount:onDestroy",
@@ -23,6 +24,8 @@ export interface ShopDiscountState {
23
24
  rules: RulesModule | null;
24
25
  productList: Record<string, any>[];
25
26
  originalDiscountList: Discount[];
27
+ currentBookingTime: string | null;
28
+ filteredDiscountList: Discount[];
26
29
  }
27
30
  export interface SetDiscountSelectedParams {
28
31
  discountId: number;
@@ -1,5 +1,7 @@
1
1
  import { Discount } from "../../modules/Discount/types";
2
2
  export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
3
+ export declare const isNormalProductByDurationSchedule: (item: any) => boolean;
4
+ export declare const isAllNormalProduct: (items: any[]) => boolean;
3
5
  /**
4
6
  * 获取折扣金额 基于折扣卡类型计算
5
7
  * 商品券:直接返回商品价格
@@ -10,3 +12,56 @@ export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
10
12
  * @returns
11
13
  */
12
14
  export declare const getDiscountAmount: (discount: Discount, total: number, price: number) => number;
15
+ export declare const getDiscountListAmountTotal: (discount: Discount[]) => any;
16
+ /**
17
+ * 获取折扣金额 计算每个折扣的金额
18
+ * @param discount
19
+ * @returns
20
+ */
21
+ export declare const getDiscountListAmount: (discount: Discount[]) => any;
22
+ export interface ScheduleItem {
23
+ id: number;
24
+ name: string | {
25
+ [key: string]: string;
26
+ };
27
+ type: 'standard' | 'time-slots' | 'designation';
28
+ start_time: string | null;
29
+ end_time: string | null;
30
+ repeat_type: 'none' | 'daily' | 'weekly';
31
+ repeat_rule: {
32
+ end: {
33
+ type: 'never' | 'date' | 'occurrence';
34
+ end_date: string | null;
35
+ occurrence: number | null;
36
+ };
37
+ frequency: number;
38
+ excluded_date: Array<{
39
+ start: string;
40
+ end: string;
41
+ }>;
42
+ included_date: Array<{
43
+ start: string;
44
+ end: string;
45
+ }>;
46
+ frequency_date: number[];
47
+ } | null;
48
+ designation: Array<{
49
+ start_date: string;
50
+ start_time: string;
51
+ end_date: string;
52
+ end_time: string;
53
+ }> | null;
54
+ is_all: number;
55
+ time_slot: Array<{
56
+ start_time: string;
57
+ end_time: string;
58
+ }>;
59
+ }
60
+ export declare const getDateIsInSchedule: (dateTime: string, scheduleList: ScheduleItem[]) => boolean;
61
+ /**
62
+ * 根据预约时间过滤优惠券列表
63
+ * @param discountList 优惠券列表
64
+ * @param bookingTime 预约时间 (格式: YYYY-MM-DD HH:mm:ss)
65
+ * @returns 过滤后的优惠券列表
66
+ */
67
+ export declare const filterDiscountListByBookingTime: (discountList: Discount[], bookingTime: string | null) => Discount[];