@pisell/private-materials 6.5.1 → 6.5.2

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.
@@ -31,6 +31,7 @@ import { useCustomer } from "../../../ticketBooking/hooks/pisellos/useCustomer";
31
31
  import { useMemoizedFn } from 'ahooks';
32
32
  import useEngineContext, { usePisellOS } from "../../../../hooks/useEngineContext";
33
33
  import useScanManager from "../../../ticketBooking/hooks/pisellos/useScanManager";
34
+ import { useShopDiscount } from "../../../appointmentBooking/hooks";
34
35
  // Toast 内容包装器,统一设置行高
35
36
  var createToastContent = function createToastContent(text) {
36
37
  return /*#__PURE__*/React.createElement("div", {
@@ -60,6 +61,7 @@ var ActionButtons = function ActionButtons(_ref) {
60
61
  _useState8 = _slicedToArray(_useState7, 2),
61
62
  showVoucherModal = _useState8[0],
62
63
  setShowVoucherModal = _useState8[1];
64
+ var shopDiscount = useShopDiscount();
63
65
  var context = useEngineContext();
64
66
  var _context$appHelper$ut = (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils,
65
67
  Toast = _context$appHelper$ut.Toast,
@@ -268,8 +270,8 @@ var ActionButtons = function ActionButtons(_ref) {
268
270
 
269
271
  // 清空所有内容并重置购物车
270
272
  var handleClearAllAndReset = function handleClearAllAndReset() {
271
- var _window;
272
- (_window = window) === null || _window === void 0 || (_window = _window.shopApi) === null || _window === void 0 || (_window = _window.bookingTicket) === null || _window === void 0 || _window.clearAllCart();
273
+ var _shopDiscount$clear;
274
+ // (window as any)?.shopApi?.bookingTicket?.clearAllCart();
273
275
  clearAllScanListenersTaskQueue();
274
276
  // 清空服务项目
275
277
  dispatch({
@@ -328,6 +330,8 @@ var ActionButtons = function ActionButtons(_ref) {
328
330
  // TODO: 如果需要重置更多信息,可以在这里添加
329
331
  // 比如重置优惠券、表单数据、宠物信息等
330
332
 
333
+ // 清空商品券
334
+ shopDiscount === null || shopDiscount === void 0 || (_shopDiscount$clear = shopDiscount.clear) === null || _shopDiscount$clear === void 0 || _shopDiscount$clear.call(shopDiscount);
331
335
  setShowClearModal(false);
332
336
  Toast === null || Toast === void 0 || Toast.success(createToastContent(locales.getText('pisell2.action-buttons.clear-success')));
333
337
  };
@@ -45,6 +45,8 @@ import { Iconfont } from '@pisell/materials';
45
45
  import { useCustomer } from "../../../ticketBooking/hooks/pisellos/useCustomer";
46
46
  import { useDebounceEffect, useMemoizedFn } from 'ahooks';
47
47
  import { cloneDeep } from 'lodash';
48
+ import { useShopDiscount } from "../../../appointmentBooking/hooks";
49
+
48
50
  /**
49
51
  * @title: 底部
50
52
  * @description:
@@ -654,12 +656,12 @@ var Footer = function Footer(props) {
654
656
  setPaymentCallback(function () {
655
657
  return function (paymentResult) {
656
658
  console.log('Payment result:', paymentResult);
659
+ setIsPaymentModalOpen(false);
657
660
  if ((paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.status) === 'success') {
658
661
  var _window5;
659
662
  console.log('Payment completed successfully');
660
663
  (_window5 = window) === null || _window5 === void 0 || (_window5 = _window5.shopApi) === null || _window5 === void 0 || (_window5 = _window5.bookingTicket) === null || _window5 === void 0 || _window5.clearAllCart();
661
664
  // 支付成功后关闭弹窗
662
- setIsPaymentModalOpen(false);
663
665
  setPaymentModalData(null);
664
666
  setPaymentCallback(null);
665
667
  } else if ((paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.status) === 'cancelled') {
@@ -669,13 +671,11 @@ var Footer = function Footer(props) {
669
671
  (_window6 = window) === null || _window6 === void 0 || (_window6 = _window6.shopApi) === null || _window6 === void 0 || (_window6 = _window6.booking) === null || _window6 === void 0 || _window6.voidBooking(res.order_id);
670
672
  }
671
673
  // 支付取消后关闭弹窗
672
- setIsPaymentModalOpen(false);
673
674
  setPaymentModalData(null);
674
675
  setPaymentCallback(null);
675
676
  } else {
676
677
  console.log('Payment status:', paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.status);
677
678
  // 其他状态也关闭弹窗
678
- setIsPaymentModalOpen(false);
679
679
  setPaymentModalData(null);
680
680
  setPaymentCallback(null);
681
681
  }
@@ -1656,12 +1656,15 @@ var Footer = function Footer(props) {
1656
1656
  changeCustomerToGlobalState: changeCustomerToGlobalState
1657
1657
  }),
1658
1658
  selectCustomer = _useCustomer.selectCustomer;
1659
+ var shopDiscount = useShopDiscount();
1659
1660
  var _useScanManager2 = useScanManager(),
1660
1661
  clearAllScanListenersTaskQueue = _useScanManager2.clearAllScanListenersTaskQueue;
1661
1662
  // 清空所有内容并重置购物车
1662
1663
  var handleClearAllAndReset = function handleClearAllAndReset() {
1663
- var _window7;
1664
- (_window7 = window) === null || _window7 === void 0 || (_window7 = _window7.shopApi) === null || _window7 === void 0 || (_window7 = _window7.bookingTicket) === null || _window7 === void 0 || _window7.clearAllCart();
1664
+ var _shopDiscount$clear;
1665
+ // setTimeout(() => {
1666
+ // (window as any)?.shopApi?.bookingTicket?.clearAllCart();
1667
+ // }, 0);
1665
1668
  clearAllScanListenersTaskQueue();
1666
1669
  // 清空服务项目
1667
1670
  dispatch({
@@ -1716,6 +1719,9 @@ var Footer = function Footer(props) {
1716
1719
  orderNote: ''
1717
1720
  }
1718
1721
  });
1722
+
1723
+ // 清空商品券
1724
+ shopDiscount === null || shopDiscount === void 0 || (_shopDiscount$clear = shopDiscount.clear) === null || _shopDiscount$clear === void 0 || _shopDiscount$clear.call(shopDiscount);
1719
1725
  };
1720
1726
  return /*#__PURE__*/React.createElement(Skeleton, {
1721
1727
  title: false,
@@ -1800,13 +1806,23 @@ var Footer = function Footer(props) {
1800
1806
  state: state,
1801
1807
  dispatch: dispatch,
1802
1808
  onClose: function onClose(reset) {
1803
- console.log('🔄 Footer: Closing PaymentModal');
1809
+ // console.log('🔄 Footer: Closing PaymentModal');
1804
1810
  setIsPaymentModalOpen(false);
1805
1811
  setPaymentModalData(null);
1806
1812
  setPaymentCallback(null);
1813
+ // if (reset) {
1814
+ // handleClearAllAndReset();
1815
+ // }
1807
1816
  if (reset) {
1808
- handleClearAllAndReset();
1817
+ setTimeout(function () {
1818
+ handleClearAllAndReset();
1819
+ }, 0);
1809
1820
  }
1821
+ // setPaymentModalData(null);
1822
+ // setPaymentCallback(null);
1823
+ // if (reset) {
1824
+ // handleClearAllAndReset();
1825
+ // }
1810
1826
  }
1811
1827
  }));
1812
1828
  };
@@ -1619,7 +1619,7 @@ var PaymentModal = function PaymentModal(_ref17) {
1619
1619
  // 获取 checkout 模块并处理订单数据
1620
1620
  checkout = pisellos === null || pisellos === void 0 ? void 0 : pisellos.getModule('checkout');
1621
1621
  if (!(checkout && data && !isLocalOrderCreated.current)) {
1622
- _context17.next = 20;
1622
+ _context17.next = 18;
1623
1623
  break;
1624
1624
  }
1625
1625
  isLocalOrderCreated.current = true;
@@ -1639,19 +1639,16 @@ var PaymentModal = function PaymentModal(_ref17) {
1639
1639
  order_rounding_setting: getData('order_rounding_setting'),
1640
1640
  shop_wallet_pass_id: shop_wallet_pass_id
1641
1641
  });
1642
- console.time('initCheckoutData');
1643
1642
  newData = cloneDeep(data); // setTotalAmount(newData.total.expectAmount);
1644
1643
  // 先往 checkout 解决方案推送一条 local 数据
1645
- _context17.next = 12;
1644
+ _context17.next = 11;
1646
1645
  return checkout.createLocalOrderAsync({
1647
1646
  orderData: newData.order_info,
1648
1647
  cartSummary: (_newData$subtotal_inf = newData.subtotal_info) === null || _newData$subtotal_inf === void 0 ? void 0 : _newData$subtotal_inf.subTotalList,
1649
1648
  autoPayment: true,
1650
1649
  totalInfo: newData.subtotal_info
1651
1650
  });
1652
- case 12:
1653
- console.timeEnd('initCheckoutData');
1654
-
1651
+ case 11:
1655
1652
  // 获取订单总金额
1656
1653
  _orderInfo2 = checkout.getCurrentOrderInfo();
1657
1654
  if (_orderInfo2 && _orderInfo2.totalAmount) {
@@ -1771,27 +1768,27 @@ var PaymentModal = function PaymentModal(_ref17) {
1771
1768
  // 可以在这里执行同步完成后的业务逻辑
1772
1769
  // 比如:通知其他系统、更新UI状态等
1773
1770
  });
1774
- _context17.next = 31;
1771
+ _context17.next = 29;
1775
1772
  break;
1776
- case 20:
1773
+ case 18:
1777
1774
  if (!isLocalOrderCreated.current) {
1778
- _context17.next = 31;
1775
+ _context17.next = 29;
1779
1776
  break;
1780
1777
  }
1781
1778
  // // 如果本地订单已创建,这时候还更新了 data,则需要销毁当前的订单数据,然后更新新的订单数据了
1782
1779
  console.log('🔄 PaymentModal: data changed, updating checkout data...');
1783
1780
  isLocalOrderCreated.current = false;
1784
- _context17.next = 25;
1781
+ _context17.next = 23;
1785
1782
  return checkout.cancelCurrentOrderAsync();
1786
- case 25:
1787
- _context17.next = 27;
1783
+ case 23:
1784
+ _context17.next = 25;
1788
1785
  return checkout.createLocalOrderAsync({
1789
1786
  orderData: data === null || data === void 0 ? void 0 : data.order_info,
1790
1787
  cartSummary: data === null || data === void 0 || (_data$subtotal_info = data.subtotal_info) === null || _data$subtotal_info === void 0 ? void 0 : _data$subtotal_info.subTotalList,
1791
1788
  autoPayment: true,
1792
1789
  totalInfo: data === null || data === void 0 ? void 0 : data.subtotal_info
1793
1790
  });
1794
- case 27:
1791
+ case 25:
1795
1792
  // 获取订单总金额
1796
1793
  _orderInfo3 = checkout.getCurrentOrderInfo();
1797
1794
  if (_orderInfo3 && _orderInfo3.totalAmount) {
@@ -1799,11 +1796,11 @@ var PaymentModal = function PaymentModal(_ref17) {
1799
1796
  }
1800
1797
  setOrderInfo(_orderInfo3);
1801
1798
  isLocalOrderCreated.current = true;
1802
- case 31:
1803
- _context17.next = 37;
1799
+ case 29:
1800
+ _context17.next = 35;
1804
1801
  break;
1805
- case 33:
1806
- _context17.prev = 33;
1802
+ case 31:
1803
+ _context17.prev = 31;
1807
1804
  _context17.t0 = _context17["catch"](0);
1808
1805
  console.error('Failed to initialize checkout data:', _context17.t0);
1809
1806
  logger === null || logger === void 0 || logger.addLog({
@@ -1813,11 +1810,11 @@ var PaymentModal = function PaymentModal(_ref17) {
1813
1810
  error: _context17.t0
1814
1811
  }
1815
1812
  });
1816
- case 37:
1813
+ case 35:
1817
1814
  case "end":
1818
1815
  return _context17.stop();
1819
1816
  }
1820
- }, _callee17, null, [[0, 33]]);
1817
+ }, _callee17, null, [[0, 31]]);
1821
1818
  }));
1822
1819
  return function initCheckoutData() {
1823
1820
  return _ref22.apply(this, arguments);
@@ -27,7 +27,7 @@ var globalPaymentResultToastContext = null;
27
27
  var DEFAULT_TOAST_CONFIG = {
28
28
  width: 680,
29
29
  mask: true,
30
- maskClosable: false,
30
+ maskClosable: true,
31
31
  closable: true,
32
32
  zIndex: 2000
33
33
  };
@@ -51,7 +51,7 @@ var PaymentResultToast = /*#__PURE__*/memo(function (props) {
51
51
  _props$mask = props.mask,
52
52
  mask = _props$mask === void 0 ? true : _props$mask,
53
53
  _props$maskClosable = props.maskClosable,
54
- maskClosable = _props$maskClosable === void 0 ? false : _props$maskClosable,
54
+ maskClosable = _props$maskClosable === void 0 ? true : _props$maskClosable,
55
55
  _props$closable = props.closable,
56
56
  closable = _props$closable === void 0 ? true : _props$closable,
57
57
  zIndex = props.zIndex;
@@ -270,7 +270,7 @@ var AddSerivce = function AddSerivce(props) {
270
270
  // 创建新的防抖定时器
271
271
  debounceTimersRef.current[productId] = setTimeout(function () {
272
272
  executeCacheValues(productId, cacheValues, item, callback);
273
- }, 0);
273
+ }, 200);
274
274
  });
275
275
  var handleSelectProduct = useMemoizedFn(function (item) {
276
276
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';
@@ -306,6 +306,8 @@ var TicketBooking = function TicketBooking(props) {
306
306
  openScan(function (data) {
307
307
  handleScan(data);
308
308
  });
309
+ }, []);
310
+ useEffect(function () {
309
311
  return function () {
310
312
  closeScan();
311
313
  };
@@ -434,7 +436,6 @@ var TicketBooking = function TicketBooking(props) {
434
436
  intervalSetTime: isInterval
435
437
  });
436
438
  };
437
- useEffect(function () {}, []);
438
439
  var getDataFromHost = function getDataFromHost() {
439
440
  try {
440
441
  var is_price_include_tax = getData('is_price_include_tax');
@@ -48,6 +48,7 @@ var import_useCustomer = require("../../../ticketBooking/hooks/pisellos/useCusto
48
48
  var import_ahooks = require("ahooks");
49
49
  var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
50
50
  var import_useScanManager = __toESM(require("../../../ticketBooking/hooks/pisellos/useScanManager"));
51
+ var import_hooks = require("../../../appointmentBooking/hooks");
51
52
  var createToastContent = (text) => /* @__PURE__ */ import_react.default.createElement("div", { className: "action-buttons-toast-content" }, text);
52
53
  var ActionButtons = ({
53
54
  state,
@@ -60,6 +61,7 @@ var ActionButtons = ({
60
61
  const [showPriceAdjustModal, setShowPriceAdjustModal] = (0, import_react.useState)(false);
61
62
  const [showCustomiseModal, setShowCustomiseModal] = (0, import_react.useState)(false);
62
63
  const [showVoucherModal, setShowVoucherModal] = (0, import_react.useState)(false);
64
+ const shopDiscount = (0, import_hooks.useShopDiscount)();
63
65
  const context = (0, import_useEngineContext.default)();
64
66
  const { Toast, getData, pisellosAllModule } = (_a = context.appHelper) == null ? void 0 : _a.utils;
65
67
  const pisellOS = (0, import_useEngineContext.usePisellOS)();
@@ -224,8 +226,7 @@ var ActionButtons = ({
224
226
  );
225
227
  };
226
228
  const handleClearAllAndReset = () => {
227
- var _a2, _b2;
228
- (_b2 = (_a2 = window == null ? void 0 : window.shopApi) == null ? void 0 : _a2.bookingTicket) == null ? void 0 : _b2.clearAllCart();
229
+ var _a2;
229
230
  clearAllScanListenersTaskQueue();
230
231
  dispatch({
231
232
  type: "setService",
@@ -263,6 +264,7 @@ var ActionButtons = ({
263
264
  orderNote: ""
264
265
  }
265
266
  });
267
+ (_a2 = shopDiscount == null ? void 0 : shopDiscount.clear) == null ? void 0 : _a2.call(shopDiscount);
266
268
  setShowClearModal(false);
267
269
  Toast == null ? void 0 : Toast.success(
268
270
  createToastContent(
@@ -59,6 +59,7 @@ var import_materials = require("@pisell/materials");
59
59
  var import_useCustomer = require("../../../ticketBooking/hooks/pisellos/useCustomer");
60
60
  var import_ahooks = require("ahooks");
61
61
  var import_lodash = require("lodash");
62
+ var import_hooks = require("../../../appointmentBooking/hooks");
62
63
  var Footer = (props) => {
63
64
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
64
65
  const { state, buttons, dispatch, source } = props;
@@ -482,10 +483,10 @@ var Footer = (props) => {
482
483
  setPaymentCallback(() => (paymentResult) => {
483
484
  var _a2, _b2, _c2, _d2;
484
485
  console.log("Payment result:", paymentResult);
486
+ setIsPaymentModalOpen(false);
485
487
  if ((paymentResult == null ? void 0 : paymentResult.status) === "success") {
486
488
  console.log("Payment completed successfully");
487
489
  (_b2 = (_a2 = window == null ? void 0 : window.shopApi) == null ? void 0 : _a2.bookingTicket) == null ? void 0 : _b2.clearAllCart();
488
- setIsPaymentModalOpen(false);
489
490
  setPaymentModalData(null);
490
491
  setPaymentCallback(null);
491
492
  } else if ((paymentResult == null ? void 0 : paymentResult.status) === "cancelled") {
@@ -493,12 +494,10 @@ var Footer = (props) => {
493
494
  if (res == null ? void 0 : res.order_id) {
494
495
  (_d2 = (_c2 = window == null ? void 0 : window.shopApi) == null ? void 0 : _c2.booking) == null ? void 0 : _d2.voidBooking(res.order_id);
495
496
  }
496
- setIsPaymentModalOpen(false);
497
497
  setPaymentModalData(null);
498
498
  setPaymentCallback(null);
499
499
  } else {
500
500
  console.log("Payment status:", paymentResult == null ? void 0 : paymentResult.status);
501
- setIsPaymentModalOpen(false);
502
501
  setPaymentModalData(null);
503
502
  setPaymentCallback(null);
504
503
  }
@@ -1195,10 +1194,10 @@ var Footer = (props) => {
1195
1194
  const { selectCustomer } = (0, import_useCustomer.useCustomer)({
1196
1195
  changeCustomerToGlobalState
1197
1196
  });
1197
+ const shopDiscount = (0, import_hooks.useShopDiscount)();
1198
1198
  const { clearAllScanListenersTaskQueue } = (0, import_useScanManager.default)();
1199
1199
  const handleClearAllAndReset = () => {
1200
- var _a2, _b2;
1201
- (_b2 = (_a2 = window == null ? void 0 : window.shopApi) == null ? void 0 : _a2.bookingTicket) == null ? void 0 : _b2.clearAllCart();
1200
+ var _a2;
1202
1201
  clearAllScanListenersTaskQueue();
1203
1202
  dispatch({
1204
1203
  type: "setService",
@@ -1236,6 +1235,7 @@ var Footer = (props) => {
1236
1235
  orderNote: ""
1237
1236
  }
1238
1237
  });
1238
+ (_a2 = shopDiscount == null ? void 0 : shopDiscount.clear) == null ? void 0 : _a2.call(shopDiscount);
1239
1239
  };
1240
1240
  return /* @__PURE__ */ import_react.default.createElement(import_antd.Skeleton, { title: false, round: true, loading: showFooter, active: true }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-footer-total" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-footer-left" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-footer-left-total" }, totalText), /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-footer-left-arrears" }, arrearsText)), /* @__PURE__ */ import_react.default.createElement(
1241
1241
  "span",
@@ -1325,12 +1325,13 @@ var Footer = (props) => {
1325
1325
  state,
1326
1326
  dispatch,
1327
1327
  onClose: (reset) => {
1328
- console.log("🔄 Footer: Closing PaymentModal");
1329
1328
  setIsPaymentModalOpen(false);
1330
1329
  setPaymentModalData(null);
1331
1330
  setPaymentCallback(null);
1332
1331
  if (reset) {
1333
- handleClearAllAndReset();
1332
+ setTimeout(() => {
1333
+ handleClearAllAndReset();
1334
+ }, 0);
1334
1335
  }
1335
1336
  }
1336
1337
  }
@@ -1223,7 +1223,6 @@ var PaymentModal = ({
1223
1223
  order_rounding_setting: getData("order_rounding_setting"),
1224
1224
  shop_wallet_pass_id
1225
1225
  });
1226
- console.time("initCheckoutData");
1227
1226
  const newData = (0, import_lodash.cloneDeep)(data);
1228
1227
  await checkout.createLocalOrderAsync({
1229
1228
  orderData: newData.order_info,
@@ -1231,7 +1230,6 @@ var PaymentModal = ({
1231
1230
  autoPayment: true,
1232
1231
  totalInfo: newData.subtotal_info
1233
1232
  });
1234
- console.timeEnd("initCheckoutData");
1235
1233
  const orderInfo2 = checkout.getCurrentOrderInfo();
1236
1234
  if (orderInfo2 && orderInfo2.totalAmount) {
1237
1235
  setTotalAmount(orderInfo2.totalAmount);
@@ -46,7 +46,7 @@ var globalPaymentResultToastContext = null;
46
46
  var DEFAULT_TOAST_CONFIG = {
47
47
  width: 680,
48
48
  mask: true,
49
- maskClosable: false,
49
+ maskClosable: true,
50
50
  closable: true,
51
51
  zIndex: 2e3
52
52
  };
@@ -78,7 +78,7 @@ var PaymentResultToast = (0, import_react.memo)((props) => {
78
78
  width,
79
79
  height,
80
80
  mask = true,
81
- maskClosable = false,
81
+ maskClosable = true,
82
82
  closable = true,
83
83
  zIndex
84
84
  } = props;
@@ -179,7 +179,7 @@ var AddSerivce = (props) => {
179
179
  }
180
180
  debounceTimersRef.current[productId] = setTimeout(() => {
181
181
  executeCacheValues(productId, cacheValues, item, callback);
182
- }, 0);
182
+ }, 200);
183
183
  }
184
184
  );
185
185
  const handleSelectProduct = (0, import_ahooks.useMemoizedFn)(
@@ -306,6 +306,8 @@ var TicketBooking = (props) => {
306
306
  openScan((data) => {
307
307
  handleScan(data);
308
308
  });
309
+ }, []);
310
+ (0, import_react.useEffect)(() => {
309
311
  return () => {
310
312
  closeScan();
311
313
  };
@@ -416,8 +418,6 @@ var TicketBooking = (props) => {
416
418
  intervalSetTime: isInterval
417
419
  });
418
420
  };
419
- (0, import_react.useEffect)(() => {
420
- }, []);
421
421
  const getDataFromHost = () => {
422
422
  try {
423
423
  const is_price_include_tax = getData("is_price_include_tax");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.5.1",
3
+ "version": "6.5.2",
4
4
  "scripts": {
5
5
  "dev": "father dev",
6
6
  "build": "father build",