@pisell/private-materials 6.11.152 → 6.11.153

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.
@@ -977,7 +977,8 @@ var Footer = function Footer(props) {
977
977
  orderTotalList: orderTotalList,
978
978
  total: total,
979
979
  showDetail: showDetail
980
- }
980
+ },
981
+ existPayment: existPayment
981
982
  }; // 这里再做个比对 如果 新的 modalData 和 paymentModalData 一致,则不更新
982
983
  if (!(JSON.stringify(modalData) === JSON.stringify(paymentModalData))) {
983
984
  _context7.next = 12;
@@ -2215,7 +2215,7 @@ var PaymentModal = function PaymentModal(_ref19) {
2215
2215
  unsubscribeRef.current = checkout.core.effects.on('checkout:onOrderSynced', executeIfActive( /*#__PURE__*/function () {
2216
2216
  var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(data) {
2217
2217
  var _data$response, _responseData$payment2;
2218
- var currentOrderId, orderInfo, responseData, paymentStatus, orderTotalAmount, gapAmount, currentChangeGivenAmount, failureReason, _responseData$payment3, params, statusClassName, autoCloseConfig, enabledAutoPrint, _interaction$utils6, _interaction$utils6$a, isToastMode, paymentResult;
2218
+ var currentOrderId, orderInfo, responseData, paymentStatus, orderTotalAmount, gapAmount, currentChangeGivenAmount, failureReason, _orderPrintList, canPrintFlag, _orderPrintList2, lastPrintTime, now, _responseData$payment3, params, statusClassName, autoCloseConfig, enabledAutoPrint, _interaction$utils6, _interaction$utils6$a, isToastMode, paymentResult;
2219
2219
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2220
2220
  while (1) switch (_context22.prev = _context22.next) {
2221
2221
  case 0:
@@ -2267,53 +2267,69 @@ var PaymentModal = function PaymentModal(_ref19) {
2267
2267
  }
2268
2268
  });
2269
2269
  } else {
2270
+ // 构造一个防重复池子
2271
+ if (!window.orderPrintList) {
2272
+ window.orderPrintList = {};
2273
+ }
2274
+ canPrintFlag = true; // 如果订单打印过,看是否间隔两秒内,如果是则不打印
2275
+ if ((_orderPrintList = window.orderPrintList) !== null && _orderPrintList !== void 0 && _orderPrintList[responseData.order_id]) {
2276
+ lastPrintTime = (_orderPrintList2 = window.orderPrintList) === null || _orderPrintList2 === void 0 ? void 0 : _orderPrintList2[responseData.order_id];
2277
+ now = new Date().getTime();
2278
+ if (now - lastPrintTime < 2000) {
2279
+ canPrintFlag = false;
2280
+ }
2281
+ }
2282
+ window.orderPrintList[responseData.order_id] = new Date().getTime();
2270
2283
  // 打印订单完整信息
2271
2284
  console.log('print_order_onOrderSynced>>>>', responseData);
2272
2285
  logger === null || logger === void 0 || logger.addLog({
2273
2286
  type: 'info',
2274
2287
  title: 'print_order_onOrderSynced',
2275
2288
  metadata: {
2276
- responseData: responseData
2289
+ responseData: responseData,
2290
+ canPrintFlag: canPrintFlag
2277
2291
  }
2278
2292
  });
2279
- try {
2280
- params = {
2281
- type: '99',
2282
- // 打印订单全部信息
2283
- data: {
2284
- order_id: responseData.order_id,
2285
- machine_code_print_info: responseData === null || responseData === void 0 ? void 0 : responseData.machine_code_print_info,
2286
- small_ticket_data: responseData === null || responseData === void 0 || (_responseData$payment3 = responseData.payment_info) === null || _responseData$payment3 === void 0 ? void 0 : _responseData$payment3.small_ticket_data,
2287
- machine_code_print_info_v2: responseData === null || responseData === void 0 ? void 0 : responseData.machine_code_print_info_v2
2288
- }
2289
- };
2290
- console.log('print_order_onOrderSynced_params>>>>', params);
2291
- logger === null || logger === void 0 || logger.addLog({
2292
- type: 'info',
2293
- title: 'print_order_onOrderSynced_params',
2294
- metadata: {
2295
- params: params
2296
- }
2297
- });
2298
- nativePrint(params, function (res) {
2299
- console.log('print_order_onOrderSynced_res>>>>', res);
2293
+ if (canPrintFlag) {
2294
+ try {
2295
+ params = {
2296
+ type: '99',
2297
+ // 打印订单全部信息
2298
+ data: {
2299
+ order_id: responseData.order_id,
2300
+ machine_code_print_info: responseData === null || responseData === void 0 ? void 0 : responseData.machine_code_print_info,
2301
+ small_ticket_data: responseData === null || responseData === void 0 || (_responseData$payment3 = responseData.payment_info) === null || _responseData$payment3 === void 0 ? void 0 : _responseData$payment3.small_ticket_data,
2302
+ machine_code_print_info_v2: responseData === null || responseData === void 0 ? void 0 : responseData.machine_code_print_info_v2
2303
+ }
2304
+ };
2305
+ console.log('print_order_onOrderSynced_params>>>>', params);
2300
2306
  logger === null || logger === void 0 || logger.addLog({
2301
2307
  type: 'info',
2302
- title: 'print_order_onOrderSynced_res',
2308
+ title: 'print_order_onOrderSynced_params',
2303
2309
  metadata: {
2304
- res: res
2310
+ params: params
2305
2311
  }
2306
2312
  });
2307
- });
2308
- } catch (error) {
2309
- console.error('print_order_onOrderSynced_error>>>>', error);
2310
- logger === null || logger === void 0 || logger.addLog({
2311
- type: 'info',
2312
- title: 'print_order_onOrderSynced_error',
2313
- metadata: {
2314
- error: error
2315
- }
2316
- });
2313
+ nativePrint(params, function (res) {
2314
+ console.log('print_order_onOrderSynced_res>>>>', res);
2315
+ logger === null || logger === void 0 || logger.addLog({
2316
+ type: 'info',
2317
+ title: 'print_order_onOrderSynced_res',
2318
+ metadata: {
2319
+ res: res
2320
+ }
2321
+ });
2322
+ });
2323
+ } catch (error) {
2324
+ console.error('print_order_onOrderSynced_error>>>>', error);
2325
+ logger === null || logger === void 0 || logger.addLog({
2326
+ type: 'info',
2327
+ title: 'print_order_onOrderSynced_error',
2328
+ metadata: {
2329
+ error: error
2330
+ }
2331
+ });
2332
+ }
2317
2333
  }
2318
2334
  }
2319
2335
 
@@ -716,7 +716,8 @@ var Footer = (props) => {
716
716
  orderTotalList,
717
717
  total,
718
718
  showDetail
719
- }
719
+ },
720
+ existPayment
720
721
  };
721
722
  if (JSON.stringify(modalData) === JSON.stringify(paymentModalData)) {
722
723
  return;
@@ -1560,7 +1560,7 @@ var PaymentModal = ({
1560
1560
  unsubscribeRef.current = checkout.core.effects.on(
1561
1561
  "checkout:onOrderSynced",
1562
1562
  executeIfActive(async (data2) => {
1563
- var _a2, _b2, _c2, _d2, _e2;
1563
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
1564
1564
  const currentOrderId = checkout.getCurrentOrderId();
1565
1565
  const orderInfo2 = checkout.getCurrentOrderInfo();
1566
1566
  if (!orderInfo2 || !(orderInfo2 == null ? void 0 : orderInfo2.orderId)) return;
@@ -1588,52 +1588,67 @@ var PaymentModal = ({
1588
1588
  }
1589
1589
  });
1590
1590
  } else {
1591
+ if (!window.orderPrintList) {
1592
+ window.orderPrintList = {};
1593
+ }
1594
+ let canPrintFlag = true;
1595
+ if ((_c2 = window.orderPrintList) == null ? void 0 : _c2[responseData.order_id]) {
1596
+ const lastPrintTime = (_d2 = window.orderPrintList) == null ? void 0 : _d2[responseData.order_id];
1597
+ const now = (/* @__PURE__ */ new Date()).getTime();
1598
+ if (now - lastPrintTime < 2e3) {
1599
+ canPrintFlag = false;
1600
+ }
1601
+ }
1602
+ window.orderPrintList[responseData.order_id] = (/* @__PURE__ */ new Date()).getTime();
1591
1603
  console.log("print_order_onOrderSynced>>>>", responseData);
1592
1604
  logger == null ? void 0 : logger.addLog({
1593
1605
  type: "info",
1594
1606
  title: "print_order_onOrderSynced",
1595
1607
  metadata: {
1596
- responseData
1608
+ responseData,
1609
+ canPrintFlag
1597
1610
  }
1598
1611
  });
1599
- try {
1600
- const params = {
1601
- type: "99",
1602
- // 打印订单全部信息
1603
- data: {
1604
- order_id: responseData.order_id,
1605
- machine_code_print_info: responseData == null ? void 0 : responseData.machine_code_print_info,
1606
- small_ticket_data: (_c2 = responseData == null ? void 0 : responseData.payment_info) == null ? void 0 : _c2.small_ticket_data,
1607
- machine_code_print_info_v2: responseData == null ? void 0 : responseData.machine_code_print_info_v2
1608
- }
1609
- };
1610
- console.log("print_order_onOrderSynced_params>>>>", params);
1611
- logger == null ? void 0 : logger.addLog({
1612
- type: "info",
1613
- title: "print_order_onOrderSynced_params",
1614
- metadata: {
1615
- params
1616
- }
1617
- });
1618
- nativePrint(params, (res) => {
1619
- console.log("print_order_onOrderSynced_res>>>>", res);
1612
+ if (canPrintFlag) {
1613
+ try {
1614
+ const params = {
1615
+ type: "99",
1616
+ // 打印订单全部信息
1617
+ data: {
1618
+ order_id: responseData.order_id,
1619
+ machine_code_print_info: responseData == null ? void 0 : responseData.machine_code_print_info,
1620
+ small_ticket_data: (_e2 = responseData == null ? void 0 : responseData.payment_info) == null ? void 0 : _e2.small_ticket_data,
1621
+ machine_code_print_info_v2: responseData == null ? void 0 : responseData.machine_code_print_info_v2
1622
+ }
1623
+ };
1624
+ console.log("print_order_onOrderSynced_params>>>>", params);
1620
1625
  logger == null ? void 0 : logger.addLog({
1621
1626
  type: "info",
1622
- title: "print_order_onOrderSynced_res",
1627
+ title: "print_order_onOrderSynced_params",
1623
1628
  metadata: {
1624
- res
1629
+ params
1625
1630
  }
1626
1631
  });
1627
- });
1628
- } catch (error) {
1629
- console.error("print_order_onOrderSynced_error>>>>", error);
1630
- logger == null ? void 0 : logger.addLog({
1631
- type: "info",
1632
- title: "print_order_onOrderSynced_error",
1633
- metadata: {
1634
- error
1635
- }
1636
- });
1632
+ nativePrint(params, (res) => {
1633
+ console.log("print_order_onOrderSynced_res>>>>", res);
1634
+ logger == null ? void 0 : logger.addLog({
1635
+ type: "info",
1636
+ title: "print_order_onOrderSynced_res",
1637
+ metadata: {
1638
+ res
1639
+ }
1640
+ });
1641
+ });
1642
+ } catch (error) {
1643
+ console.error("print_order_onOrderSynced_error>>>>", error);
1644
+ logger == null ? void 0 : logger.addLog({
1645
+ type: "info",
1646
+ title: "print_order_onOrderSynced_error",
1647
+ metadata: {
1648
+ error
1649
+ }
1650
+ });
1651
+ }
1637
1652
  }
1638
1653
  }
1639
1654
  const statusClassName = (0, import_PaymentResultToastUtils.calculateStatusClassName)(paymentStatus);
@@ -1645,7 +1660,7 @@ var PaymentModal = ({
1645
1660
  if (isWebPos) {
1646
1661
  enabledAutoPrint = false;
1647
1662
  } else {
1648
- enabledAutoPrint = await ((_e2 = (_d2 = interaction == null ? void 0 : interaction.utils) == null ? void 0 : _d2.asyncDataManager) == null ? void 0 : _e2.call(_d2, {
1663
+ enabledAutoPrint = await ((_g2 = (_f2 = interaction == null ? void 0 : interaction.utils) == null ? void 0 : _f2.asyncDataManager) == null ? void 0 : _g2.call(_f2, {
1649
1664
  module: "get",
1650
1665
  key: "auto_print_receipt"
1651
1666
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.11.152",
3
+ "version": "6.11.153",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -67,10 +67,10 @@
67
67
  "react-infinite-scroll-component": "^6.1.0",
68
68
  "react-resizable": "^3.0.5",
69
69
  "styled-components": "^6.0.0-rc.3",
70
+ "@pisell/date-picker": "3.0.8",
70
71
  "@pisell/utils": "3.0.2",
71
- "@pisell/icon": "0.0.11",
72
72
  "@pisell/materials": "6.11.48",
73
- "@pisell/date-picker": "3.0.8"
73
+ "@pisell/icon": "0.0.11"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "react": "^18.0.0",