@pisell/private-materials 6.12.452 → 6.12.454

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 (60) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/meta.js +1 -1
  5. package/build/lowcode/render/default/view.js +6 -6
  6. package/build/lowcode/view.js +6 -6
  7. package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +1 -0
  8. package/es/components/bigSale/components/ProductList/index.js +1 -0
  9. package/es/components/bigSale/components/TimeBar/index.js +1 -0
  10. package/es/components/bigSale/dialog.js +1 -0
  11. package/es/components/bigSale/hooks/useBigSaleContext.js +1 -0
  12. package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +1 -0
  13. package/es/components/bigSale/index.js +1 -0
  14. package/es/components/bigSale/templates/Kiosk/index.js +1 -0
  15. package/es/components/kiosk/components/Shell/useKioskMemberAction.js +1 -0
  16. package/es/components/kiosk/sales/KioskSaleSession.js +1 -0
  17. package/es/components/kiosk/sales/useCheckout.js +1 -0
  18. package/es/components/kiosk/sales/useSaleSessionExit.js +1 -0
  19. package/es/components/scanOrder/components/Check/index.js +60 -14
  20. package/es/components/scanOrder/utils/freePayment.js +89 -0
  21. package/es/components/scanOrder/utils/freePayment.test.cjs +74 -0
  22. package/es/components/scanOrder/utils/paymentLog.js +24 -0
  23. package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +1 -0
  24. package/es/components/venueBookingSales/checkout/VenueBookingHolderStep.js +1 -0
  25. package/es/components/venueBookingSales/checkout/useVenueBookingCheckout.js +1 -0
  26. package/es/components/venueBookingSales/checkout/useVenueCustomerAccess.js +1 -0
  27. package/es/components/venueBookingSales/checkout/useVenueKioskCheckout.js +1 -0
  28. package/es/components/venueBookingSales/extras/VenueExtraDetailModal.js +1 -0
  29. package/es/components/venueBookingSales/useVenueBookingSession.js +1 -0
  30. package/es/index.js +2 -0
  31. package/es/plus/multiCurrencySettlement/index.js +1 -1
  32. package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
  33. package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
  34. package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
  35. package/es/plus/pisellReservation/index.js +17 -0
  36. package/es/plus/pisellReservation/utils/calendarBookingSelection.js +4 -4
  37. package/es/plus/saasDevice/devicePasscodes/model.js +4 -4
  38. package/es/plus/saleDetail/Base.js +1 -0
  39. package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +1 -0
  40. package/es/plus/saleDetail/components/DetailActions/PrintAction.js +1 -0
  41. package/es/plus/saleDetail/components/DetailActions/index.js +1 -0
  42. package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +1 -0
  43. package/es/plus/saleDetail/index.js +1 -0
  44. package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +1 -0
  45. package/es/plus/saleDetail/tmpl/B/index.js +1 -0
  46. package/es/plus/salesSdk/index.js +54 -0
  47. package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
  48. package/es/plus/salesSdk/utils/bookingDate.js +1 -1
  49. package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
  50. package/es/plus/walletPassGallery/components/timelineSection/index.js +4 -4
  51. package/es/pro/Login2.0/AuthModal.d.ts +1 -1
  52. package/es/pro/Login2.0/index.d.ts +2 -2
  53. package/es/pro/Login2.0/shared/types.d.ts +1 -1
  54. package/es/pro/skuDetailModal/flow/calendarEntry.js +2 -2
  55. package/lib/components/scanOrder/components/Check/index.js +60 -14
  56. package/lib/components/scanOrder/utils/freePayment.js +90 -0
  57. package/lib/components/scanOrder/utils/freePayment.test.cjs +74 -0
  58. package/lib/components/scanOrder/utils/paymentLog.js +25 -0
  59. package/package.json +5 -5
  60. package/es/private-materials/lowcode/authmodal/meta.d.ts +0 -1
@@ -1,9 +1,9 @@
1
1
  import dayjs from "dayjs";
2
- import utcPlugin from "dayjs/plugin/utc";
3
- import timezonePlugin from "dayjs/plugin/timezone";
2
+ import utc from "dayjs/plugin/utc";
3
+ import timezone from "dayjs/plugin/timezone";
4
4
  //#region src/plus/pisellReservation/utils/calendarBookingSelection.ts
5
- dayjs.extend(utcPlugin);
6
- dayjs.extend(timezonePlugin);
5
+ dayjs.extend(utc);
6
+ dayjs.extend(timezone);
7
7
  /** Resolve the same shop clock used by the POS host; previews use the device clock. */
8
8
  function resolveReservationTimeZone(utils) {
9
9
  var _utils$getStore$getSt, _utils$getStore, _utils$getStore$getSt2, _utils$store, _utils$store$getState, _utils$getApp, _utils$getApp$getStor, _utils$getApp$getStor2, _core$tenant, _core$core, _core$core2, _state$core, _state$core2, _utils$getData, _state$global, _state$global2, _state$global3;
@@ -1,10 +1,10 @@
1
1
  import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
2
2
  import dayjs from "dayjs";
3
- import utcPlugin from "dayjs/plugin/utc";
4
- import timezonePlugin from "dayjs/plugin/timezone";
3
+ import utc from "dayjs/plugin/utc";
4
+ import timezone from "dayjs/plugin/timezone";
5
5
  //#region src/plus/saasDevice/devicePasscodes/model.ts
6
- dayjs.extend(utcPlugin);
7
- dayjs.extend(timezonePlugin);
6
+ dayjs.extend(utc);
7
+ dayjs.extend(timezone);
8
8
  const INITIAL_DEVICE_PASSCODE_STATE = {
9
9
  deviceIds: [],
10
10
  devicesById: {}
@@ -13,6 +13,7 @@ import { useSalesSdkCustomer } from "../salesSdk/hooks/useSalesSdkCustomer.js";
13
13
  import locales_default from "./locales.js";
14
14
  import { useSalesSdkBookingContext } from "../salesSdk/context/SalesSdkBookingContext.js";
15
15
  import { useSalesSdkSummary } from "../salesSdk/hooks/useSalesSdkSummary.js";
16
+ import "../salesSdk/index.js";
16
17
  import locales_default$1 from "./components/LineItem/locales.js";
17
18
  import { SaleOrderActionBoundary } from "./actions/index.js";
18
19
  import { SaleDetailTemplateRenderer } from "./tmpl/index.js";
@@ -2,6 +2,7 @@ import useEngineContext from "../../../../../hooks/useEngineContext.js";
2
2
  import { _objectSpread2 } from "../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
3
3
  import { resolveContactsInfo } from "../utils.js";
4
4
  import { useSalesSdkBookingContext } from "../../../../salesSdk/context/SalesSdkBookingContext.js";
5
+ import "../../../../salesSdk/index.js";
5
6
  import { useMemo } from "react";
6
7
  import { useMemoizedFn } from "ahooks";
7
8
  //#region src/plus/saleDetail/components/Client/hooks/useClientSelectorProps.ts
@@ -4,6 +4,7 @@ import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.
4
4
  import { _objectWithoutProperties } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
5
5
  import useLogger from "../../../../hooks/useLogger.js";
6
6
  import { useSalesSdk } from "../../../salesSdk/hooks/useSalesSdk.js";
7
+ import "../../../salesSdk/index.js";
7
8
  import { invokeLocalReceiptPrint, resolveLocalReceiptPrintModule, resolveSaleDetailOrderIdFromSales } from "./utils.js";
8
9
  import { getRemotePrintActions, getWristbandList } from "../../serve.js";
9
10
  import { EBizPrintType } from "./types.js";
@@ -10,6 +10,7 @@ import { useSalesSdk } from "../../../salesSdk/hooks/useSalesSdk.js";
10
10
  import { useSalesSdkCart } from "../../../salesSdk/hooks/useSalesSdkCart.js";
11
11
  import { useSalesSdkGlobalScanActivity } from "../../../salesSdk/context/SalesSdkGlobalScanActivityContext.js";
12
12
  import { useSalesSdkSummary } from "../../../salesSdk/hooks/useSalesSdkSummary.js";
13
+ import "../../../salesSdk/index.js";
13
14
  import { resolveSaleDetailTempOrder } from "../../utils.js";
14
15
  import { getNumericAmount, getSalesHostModule, resolveSaleDetailOrderIdFromSales, resolveSaleDetailOrderIdFromSalesResult, shouldCloseDialogAfterCheckout, updateLocalOrder } from "./utils.js";
15
16
  import { deriveSaleOrderSubmitState } from "../../actions/state.js";
@@ -5,6 +5,7 @@ import { isAppliedPaymentRecord } from "../../../salesSdk/utils/paymentStatus.js
5
5
  import { useSalesSdk } from "../../../salesSdk/hooks/useSalesSdk.js";
6
6
  import { useSalesSdkCart } from "../../../salesSdk/hooks/useSalesSdkCart.js";
7
7
  import { useSalesSdkSummary } from "../../../salesSdk/hooks/useSalesSdkSummary.js";
8
+ import "../../../salesSdk/index.js";
8
9
  import { resolveSaleDetailTempOrder } from "../../utils.js";
9
10
  import React, { memo, useMemo } from "react";
10
11
  import { formatAmount, locales } from "@pisell/utils";
@@ -5,6 +5,7 @@ import { useSalesSdk } from "../salesSdk/hooks/useSalesSdk.js";
5
5
  import { SalesSdkProvider } from "../salesSdk/context/SalesSdkProvider.js";
6
6
  import { SalesSdkDishProvider } from "../salesSdk/context/SalesSdkDishContext.js";
7
7
  import { SalesSdkBookingContextProvider } from "../salesSdk/context/SalesSdkBookingContext.js";
8
+ import "../salesSdk/index.js";
8
9
  import Base_default from "./Base.js";
9
10
  import { resolveSaleDetailOsProps } from "./osProps.js";
10
11
  import React, { forwardRef, useImperativeHandle } from "react";
@@ -1,6 +1,7 @@
1
1
  import useStableInstanceId from "../../../../../../hooks/useStableInstanceId.js";
2
2
  import { useSalesSdkDish } from "../../../../../salesSdk/hooks/useSalesSdkDish.js";
3
3
  import { useCurrentSalesSdkDish } from "../../../../../salesSdk/hooks/useCurrentSalesSdkDish.js";
4
+ import "../../../../../salesSdk/index.js";
4
5
  import { SaleDetailStatusOverview } from "../shared/StatusOverview.js";
5
6
  import { DishGroupView } from "./DishGroupView.js";
6
7
  import dayjs from "dayjs";
@@ -1,6 +1,7 @@
1
1
  import useEngineContext from "../../../../hooks/useEngineContext.js";
2
2
  import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
3
3
  import { useCurrentSalesSdkDish } from "../../../salesSdk/hooks/useCurrentSalesSdkDish.js";
4
+ import "../../../salesSdk/index.js";
4
5
  import { getInternalNotesByScheduleEvent } from "../../serve.js";
5
6
  import { TEMPLATE_B_PAY_ACTIONS, TEMPLATE_B_SUMMARY_ACTIONS } from "../../components/DetailActions/configs/index.js";
6
7
  import { DetailActions } from "../../components/DetailActions/index.js";
@@ -0,0 +1,54 @@
1
+ import "./hosts/createInstanceHostBridge.js";
2
+ import "./holderConfirm/createHolderConfirmBridge.js";
3
+ import "./giftSelect/createGiftSelectBridge.js";
4
+ import "./context/SalesSdkHostBridgesContext.js";
5
+ import "./utils/formatHolderOptions.js";
6
+ import "./utils/enrichCartLineHolderDisplay.js";
7
+ import "./context/SalesSdkHolderContext.js";
8
+ import "../multiCurrencySettlement/index.js";
9
+ import "./utils/customerAuthGate.js";
10
+ import "./context/SalesSdkBusinessAvailabilityContext.js";
11
+ import "./utils/appendPromotionTags.js";
12
+ import "./utils/productSkuOptions.js";
13
+ import "./context/SalesSdkUIHostsContext.js";
14
+ import "./utils/runAddProductFlow.js";
15
+ import "./components/showAddToCartToast.js";
16
+ import "./utils/resolveAddProductDebounceKey.js";
17
+ import "./utils/identity.js";
18
+ import "./utils/resolveInCartQuantityForAddToast.js";
19
+ import "./utils/addProductWithFlowDebounced.js";
20
+ import "./utils/bookingDate.js";
21
+ import "./utils/holderSubmitValidation.js";
22
+ import "./utils/removeOrderProducts.js";
23
+ import "./selectors.js";
24
+ import "./utils/enrich.js";
25
+ import "./giftSelect/createOpenGiftSelectHost.js";
26
+ import "./utils/ensureHoldersBeforeSubmit.js";
27
+ import "./hooks/useSalesSdk.js";
28
+ import "./bookingEditService/BookingEditServiceDrawer.js";
29
+ import "./hosts/BookingEditHostRenderer.js";
30
+ import "./hosts/CustomerAuthHostRenderer.js";
31
+ import "./hooks/useSalesSdkCart.js";
32
+ import "./hooks/useSalesSdkCustomer.js";
33
+ import "./normalProductDetail/NormalProductDetailHostRenderer.js";
34
+ import "./hosts/createOpenBookingEditHost.js";
35
+ import "./hosts/createOpenMultiDaySelectHost.js";
36
+ import "./hosts/createOpenHolderSelectHost.js";
37
+ import "./hosts/createOpenCustomerAuthHost.js";
38
+ import "./demo/hosts/legacyOpenProductDetail.js";
39
+ import "./hosts/createCompositeOpenProductDetailHost.js";
40
+ import "./normalProductDetail/createOpenNormalProductDetailHost.js";
41
+ import "./normalProductDetail/createOpenBookingSelectionFlowHost.js";
42
+ import "./giftSelect/GiftSelectModal.js";
43
+ import "./giftSelect/GiftSelectHostRenderer.js";
44
+ import "./allergy/AllergySelectionModal.js";
45
+ import "./context/SalesSdkProvider.js";
46
+ import "./context/SalesSdkDishContext.js";
47
+ import "./context/SalesSdkBookingContext.js";
48
+ import "./hooks/useSalesSdkSummary.js";
49
+ import "./hooks/useSalesSdkProducts.js";
50
+ import "./demo/index.js";
51
+ import "./hooks/useSalesSdkDish.js";
52
+ import "./hooks/useCurrentSalesSdkDish.js";
53
+ import "./hooks/useSyncOsModule.js";
54
+ export {};
@@ -407,4 +407,4 @@ function createAddProductWithFlowDebounced(deps) {
407
407
  };
408
408
  }
409
409
  //#endregion
410
- export { createAddProductWithFlowDebounced };
410
+ export { createAddProductWithFlowDebounced, shouldBypassAddProductDebounce };
@@ -31,4 +31,4 @@ function subscribeBookingDateChange(bookingTicket, callback) {
31
31
  return typeof off === "function" ? off : () => {};
32
32
  }
33
33
  //#endregion
34
- export { formatBookingDateTime, subscribeBookingDateChange };
34
+ export { BOOKING_CONTEXT_DATE_EVENT, formatBookingDateTime, subscribeBookingDateChange };
@@ -102,4 +102,4 @@ function buildHolderListRequestKey(params) {
102
102
  });
103
103
  }
104
104
  //#endregion
105
- export { buildHolderListRequestKey, buildHolderListRequestParams, enrichCartBookingHolderDisplay, enrichCartProductHolderDisplay, resolveHolderDisplayConfig };
105
+ export { buildHolderListRequestKey, buildHolderListRequestParams, enrichCartBookingHolderDisplay, enrichCartProductHolderDisplay, pickHolderIdFromBooking, resolveHolderDisplayConfig };
@@ -7,12 +7,12 @@ import React, { useCallback, useEffect, useMemo, useRef } from "react";
7
7
  import { locales } from "@pisell/utils";
8
8
  import { Button, PisellEmpty, PisellModal, PisellStatisticList, Skeleton, Timeline, usePisellConfig } from "@pisell/materials";
9
9
  import { useRequest } from "ahooks";
10
- import utcPlugin from "dayjs/plugin/utc";
11
- import timezonePlugin from "dayjs/plugin/timezone";
10
+ import utc from "dayjs/plugin/utc";
11
+ import timezone from "dayjs/plugin/timezone";
12
12
  import "./index.less";
13
13
  //#region src/plus/walletPassGallery/components/timelineSection/index.tsx
14
- dayjs.extend(timezonePlugin);
15
- dayjs.extend(utcPlugin);
14
+ dayjs.extend(timezone);
15
+ dayjs.extend(utc);
16
16
  const stateTimeUnix = 1723255863;
17
17
  const POLL_INTERVAL = 2e3;
18
18
  const POLL_MAX_TIMES = 5;
@@ -14,4 +14,4 @@ interface AuthModalProps {
14
14
  */
15
15
  declare const AuthModal: React.FC<AuthModalProps>;
16
16
  //#endregion
17
- export { AuthModal, AuthModalProps };
17
+ export { AuthModal };
@@ -1,4 +1,4 @@
1
- import { AuthMethodType, VerificationMethod } from "./shared/types.js";
1
+ import { AuthMethodType, EmailAuthConfig, EmailRegistrationVerification, LoginFormData, OAuthConfig, PhoneAuthConfig, RegisterFormData, UIConfig, VerificationMethod } from "./shared/types.js";
2
2
  import { Login2, Login2Config, Login2Events, Login2Props } from "./Login2.js";
3
3
  import { Register2, Register2Config, Register2Events, Register2Props } from "./Register2.js";
4
- import { AuthModal, AuthModalProps } from "./AuthModal.js";
4
+ import { AuthModal } from "./AuthModal.js";
@@ -226,4 +226,4 @@ interface RegisterFormData {
226
226
  verification_token?: string;
227
227
  }
228
228
  //#endregion
229
- export { AuthMethodType, EmailAuthConfig, LegalTermsConfig, LoginFormData, LoginMethodItem, OAuthConfig, PhoneAuthConfig, RegisterFormData, RegistrationMethodItem, UIConfig, VerificationMethod };
229
+ export { AuthMethodType, EmailAuthConfig, EmailRegistrationVerification, LegalTermsConfig, LoginFormData, LoginMethodItem, OAuthConfig, PhoneAuthConfig, RegisterFormData, RegistrationMethodItem, UIConfig, VerificationMethod };
@@ -1,9 +1,9 @@
1
1
  import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
2
2
  import { isMultiDayProduct } from "../../../components/booking/info2/service/addService/utils.js";
3
3
  import dayjs from "dayjs";
4
- import utcPlugin from "dayjs/plugin/utc";
4
+ import utc from "dayjs/plugin/utc";
5
5
  //#region src/pro/skuDetailModal/flow/calendarEntry.ts
6
- dayjs.extend(utcPlugin);
6
+ dayjs.extend(utc);
7
7
  /** Calendar timestamps belong to the shop clock, rather than the browser clock. */
8
8
  function calendarDateTime(value) {
9
9
  const matched = value.match(/(Z|([+-])(\d{2}):(\d{2}))$/i);
@@ -4,6 +4,8 @@ const require_materialWarning = require("../../../../utils/materialWarning.js");
4
4
  const require_hooks = require("../../hooks.js");
5
5
  const require_context = require("../../context.js");
6
6
  const require_index = require("../Cart/index.js");
7
+ const require_paymentLog = require("../../utils/paymentLog.js");
8
+ const require_freePayment = require("../../utils/freePayment.js");
7
9
  const require_index$1 = require("../FulfillmentMode/index.js");
8
10
  const require_index$2 = require("../ManualPickupRefModal/index.js");
9
11
  let react = require("react");
@@ -28,7 +30,6 @@ function Check() {
28
30
  const getConfig = (0, react.useCallback)(require_asyncToGenerator._asyncToGenerator(function* () {
29
31
  var _otherParams$dineInCo, _otherParams$channel;
30
32
  const otherParams = yield runModuleAction("getOtherParams");
31
- console.log("otherParams >>>>> ", otherParams);
32
33
  setDineInConfig((_otherParams$dineInCo = otherParams === null || otherParams === void 0 ? void 0 : otherParams.dineInConfig) !== null && _otherParams$dineInCo !== void 0 ? _otherParams$dineInCo : {});
33
34
  setChannel((_otherParams$channel = otherParams === null || otherParams === void 0 ? void 0 : otherParams.channel) !== null && _otherParams$channel !== void 0 ? _otherParams$channel : "");
34
35
  }), [runModuleAction]);
@@ -89,7 +90,7 @@ function Check() {
89
90
  try {
90
91
  yield action();
91
92
  } catch (error) {
92
- console.error("[scanOrder] submit action failed", error);
93
+ require_paymentLog.logScanOrder(utils, "submit action failed", require_paymentLog.scanOrderError(error), "error");
93
94
  if (!handleMenuValidationFailure(error)) showSubmitFailedTip(error === null || error === void 0 ? void 0 : error.message);
94
95
  } finally {
95
96
  submittingRef.current = false;
@@ -116,15 +117,33 @@ function Check() {
116
117
  }, []);
117
118
  const doSubmit = function() {
118
119
  var _ref3 = require_asyncToGenerator._asyncToGenerator(function* () {
119
- if (((viewModel === null || viewModel === void 0 ? void 0 : viewModel.cartItems) || []).length === 0) {
120
+ const items = (viewModel === null || viewModel === void 0 ? void 0 : viewModel.cartItems) || [];
121
+ if (items.length === 0) {
120
122
  showCheckStepEmptyCartTip();
121
123
  return;
122
124
  }
123
125
  try {
124
- var _res$data;
126
+ var _viewModel$summary, _res$data, _res$data2, _res$data3, _res$data4, _res$data5, _res$data6, _res$data7, _res$data8, _res$data$order_wait_, _res$data9, _viewModel$summary2, _res$data10, _viewModel$summary3, _res$data11;
127
+ require_paymentLog.logScanOrder(utils, "下单开始", {
128
+ channel,
129
+ entryMode,
130
+ requirePaymentOnSubmit: dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig["sale.require_payment_on_submit"],
131
+ displayedTotalAmount: viewModel === null || viewModel === void 0 || (_viewModel$summary = viewModel.summary) === null || _viewModel$summary === void 0 ? void 0 : _viewModel$summary.total_amount,
132
+ itemCount: items.length
133
+ });
125
134
  yield runModuleAction("updateTempOrderNote", note);
126
135
  const res = yield runModuleAction("submitScanOrder");
127
- console.log("submitScanOrder >>>>> ", res);
136
+ require_paymentLog.logScanOrder(utils, "下单接口返回", {
137
+ status: res === null || res === void 0 ? void 0 : res.status,
138
+ code: res === null || res === void 0 ? void 0 : res.code,
139
+ orderId: res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.order_id,
140
+ orderWaitPayAmount: res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.order_wait_pay_amount,
141
+ orderWaitPayAmountType: typeof (res === null || res === void 0 || (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.order_wait_pay_amount),
142
+ expectAmount: res === null || res === void 0 || (_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : _res$data4.expect_amount,
143
+ totalAmount: res === null || res === void 0 || (_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : _res$data5.total_amount,
144
+ paymentStatus: res === null || res === void 0 || (_res$data6 = res.data) === null || _res$data6 === void 0 ? void 0 : _res$data6.payment_status,
145
+ message: res === null || res === void 0 ? void 0 : res.message
146
+ }, (res === null || res === void 0 ? void 0 : res.status) === false || !(res === null || res === void 0 || (_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.order_id) ? "error" : "info");
128
147
  if ((res === null || res === void 0 ? void 0 : res.status) === false) {
129
148
  if (handleMenuValidationFailure(res)) return;
130
149
  if ((res === null || res === void 0 ? void 0 : res.code) === 6008) {
@@ -134,7 +153,7 @@ function Check() {
134
153
  showSubmitFailedTip(res === null || res === void 0 ? void 0 : res.message);
135
154
  return;
136
155
  }
137
- const orderId = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.order_id;
156
+ const orderId = res === null || res === void 0 || (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.order_id;
138
157
  const shouldPayOnSubmit = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig["sale.require_payment_on_submit"]) && !isAdditionalOrder;
139
158
  if (!orderId) {
140
159
  showSubmitFailedTip(res === null || res === void 0 ? void 0 : res.message);
@@ -146,21 +165,48 @@ function Check() {
146
165
  "scan_to_order_2": "mobile_order",
147
166
  "scan_to_order_3": "scantoorder3"
148
167
  }[channel] || channel;
168
+ const paymentAmount = (_res$data$order_wait_ = res === null || res === void 0 || (_res$data9 = res.data) === null || _res$data9 === void 0 ? void 0 : _res$data9.order_wait_pay_amount) !== null && _res$data$order_wait_ !== void 0 ? _res$data$order_wait_ : viewModel === null || viewModel === void 0 || (_viewModel$summary2 = viewModel.summary) === null || _viewModel$summary2 === void 0 ? void 0 : _viewModel$summary2.total_amount;
169
+ require_paymentLog.logScanOrder(utils, "下单后支付分支", {
170
+ orderId,
171
+ channel,
172
+ saleChannel,
173
+ isAdditionalOrder,
174
+ requirePaymentOnSubmit: dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig["sale.require_payment_on_submit"],
175
+ shouldPayOnSubmit: Boolean(shouldPayOnSubmit),
176
+ serverAmount: res === null || res === void 0 || (_res$data10 = res.data) === null || _res$data10 === void 0 ? void 0 : _res$data10.order_wait_pay_amount,
177
+ displayedTotalAmount: viewModel === null || viewModel === void 0 || (_viewModel$summary3 = viewModel.summary) === null || _viewModel$summary3 === void 0 ? void 0 : _viewModel$summary3.total_amount,
178
+ paymentAmount,
179
+ paymentAmountType: typeof paymentAmount,
180
+ amountSource: (res === null || res === void 0 || (_res$data11 = res.data) === null || _res$data11 === void 0 ? void 0 : _res$data11.order_wait_pay_amount) != null ? "response.order_wait_pay_amount" : "viewModel.summary.total_amount",
181
+ branch: shouldPayOnSubmit ? require_freePayment.isZeroPaymentAmount(paymentAmount) ? "free-pay" : "pisell1.payment" : "order-details",
182
+ hasFreePayBranch: true
183
+ });
149
184
  if (shouldPayOnSubmit) {
150
- var _res$data2, _viewModel$summary;
185
+ if (yield require_freePayment.handleScanOrderFreePayment({
186
+ orderId,
187
+ amount: paymentAmount,
188
+ utils,
189
+ restoreOrder: () => runModuleAction("restoreOrder"),
190
+ showFailure: showSubmitFailedTip
191
+ })) return;
151
192
  utils.action({
152
193
  type: "pisell1.payment",
153
194
  data: {
154
195
  order_id: orderId,
155
- total_amount: (res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.order_wait_pay_amount) || (viewModel === null || viewModel === void 0 || (_viewModel$summary = viewModel.summary) === null || _viewModel$summary === void 0 ? void 0 : _viewModel$summary.total_amount),
196
+ total_amount: paymentAmount,
156
197
  sale_channel: saleChannel
157
198
  },
158
199
  callback: function() {
159
200
  var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (_e) {
201
+ require_paymentLog.logScanOrder(utils, "支付回调", {
202
+ orderId,
203
+ type: _e === null || _e === void 0 ? void 0 : _e.type,
204
+ status: _e === null || _e === void 0 ? void 0 : _e.status
205
+ });
160
206
  try {
161
207
  yield runModuleAction("restoreOrder");
162
208
  } catch (error) {
163
- console.warn("[scanOrder] restoreOrder after payment failed", error);
209
+ require_paymentLog.logScanOrder(utils, "restoreOrder after payment failed", require_paymentLog.scanOrderError(error), "error");
164
210
  }
165
211
  });
166
212
  return function callback(_x2) {
@@ -173,7 +219,7 @@ function Check() {
173
219
  try {
174
220
  yield runModuleAction("restoreOrder");
175
221
  } catch (error) {
176
- console.warn("[scanOrder] restoreOrder before redirect failed", error);
222
+ require_paymentLog.logScanOrder(utils, "restoreOrder before redirect failed", require_paymentLog.scanOrderError(error), "error");
177
223
  }
178
224
  const link = `/order/details?id=${orderId}`;
179
225
  if (utils === null || utils === void 0 || (_utils$history = utils.history) === null || _utils$history === void 0 ? void 0 : _utils$history.replace) utils.history.replace(link);
@@ -182,12 +228,12 @@ function Check() {
182
228
  try {
183
229
  yield runModuleAction("restoreOrder");
184
230
  } catch (error) {
185
- console.warn("[scanOrder] restoreOrder after payment failed", error);
231
+ require_paymentLog.logScanOrder(utils, "restoreOrder after payment failed", require_paymentLog.scanOrderError(error), "error");
186
232
  }
187
233
  }
188
234
  yield refreshViewModel();
189
235
  } catch (error) {
190
- console.error("[scanOrder] submitScanOrder failed", error);
236
+ require_paymentLog.logScanOrder(utils, "submitScanOrder failed", require_paymentLog.scanOrderError(error), "error");
191
237
  if (handleMenuValidationFailure(error)) return;
192
238
  if ((error === null || error === void 0 ? void 0 : error.code) === 670005) showSubmitFailedTip(String(_pisell_utils.locales.getText("pisell2.scan.order.settled.cannot.add.tip") || ""));
193
239
  else if ((error === null || error === void 0 ? void 0 : error.code) === 670007 && (entryContext === null || entryContext === void 0 ? void 0 : entryContext.resource_id)) {
@@ -235,7 +281,7 @@ function Check() {
235
281
  return;
236
282
  }
237
283
  } catch (error) {
238
- console.error("[scanOrder] checkManualPickupRef failed", error);
284
+ require_paymentLog.logScanOrder(utils, "checkManualPickupRef failed", require_paymentLog.scanOrderError(error), "error");
239
285
  antd.message.error((error === null || error === void 0 ? void 0 : error.message) || "Submit order failed");
240
286
  require_materialWarning.sendMaterialWarning({
241
287
  level: "error",
@@ -256,7 +302,7 @@ function Check() {
256
302
  try {
257
303
  yield runModuleAction("setPickupRef", value);
258
304
  } catch (error) {
259
- console.error("[scanOrder] setPickupRef failed", error);
305
+ require_paymentLog.logScanOrder(utils, "setPickupRef failed", require_paymentLog.scanOrderError(error), "error");
260
306
  antd.message.error((error === null || error === void 0 ? void 0 : error.message) || "Submit order failed");
261
307
  return;
262
308
  }
@@ -0,0 +1,90 @@
1
+ const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
2
+ const require_asyncToGenerator = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
3
+ const require_paymentLog = require("./paymentLog.js");
4
+ //#region src/components/scanOrder/utils/freePayment.ts
5
+ function isZeroPaymentAmount(amount) {
6
+ return (typeof amount === "number" || typeof amount === "string") && String(amount).trim() !== "" && Number(amount) === 0;
7
+ }
8
+ /** Confirm free payment before callers clear their order or navigate away. */
9
+ function confirmFreePaymentIfNeeded(_x) {
10
+ return _confirmFreePaymentIfNeeded.apply(this, arguments);
11
+ }
12
+ function _confirmFreePaymentIfNeeded() {
13
+ _confirmFreePaymentIfNeeded = require_asyncToGenerator._asyncToGenerator(function* (options) {
14
+ if (options.enabled === false || !isZeroPaymentAmount(options.amount)) return { kind: "not-required" };
15
+ const response = yield options.freePay(String(options.orderId));
16
+ return (response === null || response === void 0 ? void 0 : response.status) ? {
17
+ kind: "paid",
18
+ response
19
+ } : {
20
+ kind: "failed",
21
+ response
22
+ };
23
+ });
24
+ return _confirmFreePaymentIfNeeded.apply(this, arguments);
25
+ }
26
+ /** Returns true when free payment handled the checkout (including business failure). */
27
+ function handleScanOrderFreePayment(_x3) {
28
+ return _handleScanOrderFreePayment.apply(this, arguments);
29
+ }
30
+ function _handleScanOrderFreePayment() {
31
+ _handleScanOrderFreePayment = require_asyncToGenerator._asyncToGenerator(function* (options) {
32
+ var _result$response, _result$response2, _result$response3, _utils$history, _utils$history2;
33
+ const { orderId, amount, utils, restoreOrder, showFailure } = options;
34
+ const result = yield confirmFreePaymentIfNeeded({
35
+ orderId,
36
+ amount,
37
+ freePay: function() {
38
+ var _ref = require_asyncToGenerator._asyncToGenerator(function* (id) {
39
+ const url = `/h5/pay/order/free-pay/${id}`;
40
+ require_paymentLog.logScanOrder(utils, "免费支付请求", {
41
+ orderId,
42
+ amount,
43
+ url
44
+ });
45
+ try {
46
+ return yield utils.request.post(url, {});
47
+ } catch (error) {
48
+ require_paymentLog.logScanOrder(utils, "免费支付请求异常", require_objectSpread2._objectSpread2({
49
+ orderId,
50
+ amount,
51
+ url
52
+ }, require_paymentLog.scanOrderError(error)), "error");
53
+ throw error;
54
+ }
55
+ });
56
+ return function freePay(_x2) {
57
+ return _ref.apply(this, arguments);
58
+ };
59
+ }()
60
+ });
61
+ if (result.kind === "not-required") return false;
62
+ require_paymentLog.logScanOrder(utils, "免费支付接口返回", {
63
+ orderId,
64
+ amount,
65
+ kind: result.kind,
66
+ status: (_result$response = result.response) === null || _result$response === void 0 ? void 0 : _result$response.status,
67
+ code: (_result$response2 = result.response) === null || _result$response2 === void 0 ? void 0 : _result$response2.code,
68
+ message: (_result$response3 = result.response) === null || _result$response3 === void 0 ? void 0 : _result$response3.message
69
+ }, result.kind === "failed" ? "error" : "info");
70
+ if (result.kind === "failed") {
71
+ var _result$response4;
72
+ showFailure((_result$response4 = result.response) === null || _result$response4 === void 0 ? void 0 : _result$response4.message);
73
+ return true;
74
+ }
75
+ try {
76
+ yield restoreOrder();
77
+ } catch (error) {
78
+ require_paymentLog.logScanOrder(utils, "免费支付后清理订单失败", require_objectSpread2._objectSpread2({ orderId }, require_paymentLog.scanOrderError(error)), "error");
79
+ }
80
+ const link = `/payment-finish/success?amount=0&order_id=${encodeURIComponent(String(orderId))}`;
81
+ if ((_utils$history = utils.history) === null || _utils$history === void 0 ? void 0 : _utils$history.replace) utils.history.replace(link);
82
+ else if ((_utils$history2 = utils.history) === null || _utils$history2 === void 0 ? void 0 : _utils$history2.push) utils.history.push(link);
83
+ else location.replace(link);
84
+ return true;
85
+ });
86
+ return _handleScanOrderFreePayment.apply(this, arguments);
87
+ }
88
+ //#endregion
89
+ exports.handleScanOrderFreePayment = handleScanOrderFreePayment;
90
+ exports.isZeroPaymentAmount = isZeroPaymentAmount;
@@ -0,0 +1,74 @@
1
+ const assert = require('node:assert/strict');
2
+ const { readFileSync } = require('node:fs');
3
+ const { join } = require('node:path');
4
+ const test = require('node:test');
5
+ const ts = require('typescript');
6
+ const vm = require('node:vm');
7
+ const transpile = (source) => ts.transpileModule(source, {
8
+ compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
9
+ }).outputText;
10
+ const logger = {};
11
+ new Function('exports', transpile(readFileSync(join(__dirname, 'paymentLog.ts'), 'utf8')))(logger);
12
+ const api = {};
13
+ new Function('exports', 'require', transpile(readFileSync(join(__dirname, 'freePayment.ts'), 'utf8')))(api, () => logger);
14
+
15
+ test('only explicit zero amounts call free payment; failures and exceptions stay failures', async () => {
16
+ for (const amount of [0, '0.00', '0']) {
17
+ let id;
18
+ assert.equal((await api.confirmFreePaymentIfNeeded({ orderId: 123, amount, freePay: async (value) => { id = value; return { status: true }; } })).kind, 'paid');
19
+ assert.equal(id, '123');
20
+ }
21
+ for (const amount of [undefined, null, '', ' ', false, 'invalid', 10, -1]) {
22
+ assert.equal((await api.confirmFreePaymentIfNeeded({ orderId: 123, amount, freePay: async () => { throw new Error('must not call'); } })).kind, 'not-required');
23
+ }
24
+ assert.equal((await api.confirmFreePaymentIfNeeded({ orderId: 123, amount: 0, enabled: false })).kind, 'not-required');
25
+ assert.equal((await api.confirmFreePaymentIfNeeded({ orderId: 123, amount: 0, freePay: async () => ({ status: false }) })).kind, 'failed');
26
+ await assert.rejects(api.confirmFreePaymentIfNeeded({ orderId: 123, amount: 0, freePay: async () => { throw new Error('offline'); } }), /offline/);
27
+ });
28
+
29
+ const file = join(__dirname, '../components/Check/index.tsx');
30
+ const parsed = ts.createSourceFile(file, readFileSync(file, 'utf8'), ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
31
+ let submit;
32
+ function visit(node) {
33
+ if (ts.isVariableDeclaration(node) && node.name.getText(parsed) === 'doSubmit') submit = node.initializer.getText(parsed);
34
+ ts.forEachChild(node, visit);
35
+ }
36
+ visit(parsed);
37
+
38
+ test('scan order zero bypasses modal, positive preserves channel, failed free payment keeps order', async () => {
39
+ for (const [amount, success, payOnSubmit] of [[0, true, true], ['0.00', true, true], [5, true, true], [0, false, true], [0, true, false]]) {
40
+ const events = [];
41
+ const ctx = {
42
+ logScanOrder: logger.logScanOrder, scanOrderError: logger.scanOrderError,
43
+ viewModel: { cartItems: [{}], summary: { total_amount: 99 } }, note: '', channel: 'scan_to_order', entryMode: 'default', isAdditionalOrder: false,
44
+ dineInConfig: { 'sale.require_payment_on_submit': payOnSubmit },
45
+ runModuleAction: async (name) => { events.push(name); return name === 'submitScanOrder' ? { status: true, data: { order_id: 123, order_wait_pay_amount: amount } } : undefined; },
46
+ clearStepCache() {}, refreshViewModel: async () => {},
47
+ utils: { request: { post: async (url, body) => { assert.equal(url, '/h5/pay/order/free-pay/123'); assert.equal(Object.keys(body).length, 0); events.push('free-pay'); return { status: success }; } }, action: (a) => { assert.equal(a.data.sale_channel, 'table-order'); events.push('modal'); }, history: { replace: (path) => events.push(path) } },
48
+ console: { log() {}, warn() {}, error() {} },
49
+ showSubmitFailedTip: () => events.push('failure'),
50
+ isZeroPaymentAmount: api.isZeroPaymentAmount,
51
+ handleScanOrderFreePayment: api.handleScanOrderFreePayment,
52
+ };
53
+ await vm.runInNewContext(transpile('const run = ' + submit + '; run();'), ctx);
54
+ if (!payOnSubmit) { assert(!events.includes('free-pay')); assert(events.includes('/order/details?id=123')); }
55
+ else if (Number(amount) > 0) { assert(events.includes('modal')); assert(!events.includes('free-pay')); }
56
+ else {
57
+ assert(events.includes('free-pay')); assert(!events.includes('modal'));
58
+ if (success) assert(events.includes('/payment-finish/success?amount=0&order_id=123'));
59
+ else { assert(events.includes('failure')); assert(!events.includes('restoreOrder')); }
60
+ }
61
+ }
62
+ });
63
+
64
+
65
+ test('logging uses host addLog and does not interrupt checkout when it fails', async () => {
66
+ const entries = [];
67
+ logger.logScanOrder({ getApp: () => ({ logger: { addLog: entry => entries.push(entry) } }) }, 'request', { orderId: 1 }, 'error');
68
+ assert.equal(entries[0].type, 'error');
69
+ assert.equal(entries[0].metadata.orderId, 1);
70
+ logger.logScanOrder({}, 'no logger');
71
+ logger.logScanOrder({ getApp: () => { throw new Error('unavailable'); } }, 'failure');
72
+ logger.logScanOrder({ getApp: () => ({ logger: { addLog: () => Promise.reject(new Error('offline')) } }) }, 'async failure');
73
+ await new Promise(resolve => setImmediate(resolve));
74
+ });
@@ -0,0 +1,25 @@
1
+ //#region src/components/scanOrder/utils/paymentLog.ts
2
+ /** Logging must never interrupt checkout, including when the host has no logger. */
3
+ function logScanOrder(utils, title, metadata = {}, type = "info") {
4
+ try {
5
+ var _utils$getApp, _utils$getApp$addLog;
6
+ const result = (_utils$getApp = utils.getApp) === null || _utils$getApp === void 0 || (_utils$getApp = _utils$getApp.call(utils)) === null || _utils$getApp === void 0 || (_utils$getApp = _utils$getApp.logger) === null || _utils$getApp === void 0 || (_utils$getApp$addLog = _utils$getApp.addLog) === null || _utils$getApp$addLog === void 0 ? void 0 : _utils$getApp$addLog.call(_utils$getApp, {
7
+ type,
8
+ title: `[scanOrder] ${title}`,
9
+ metadata
10
+ });
11
+ if (result && typeof result.catch === "function") result.catch(() => {});
12
+ } catch (_unused) {}
13
+ }
14
+ function scanOrderError(error) {
15
+ var _error$message, _error$response;
16
+ return {
17
+ message: (_error$message = error === null || error === void 0 ? void 0 : error.message) !== null && _error$message !== void 0 ? _error$message : String(error),
18
+ code: error === null || error === void 0 ? void 0 : error.code,
19
+ status: error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status,
20
+ stack: error === null || error === void 0 ? void 0 : error.stack
21
+ };
22
+ }
23
+ //#endregion
24
+ exports.logScanOrder = logScanOrder;
25
+ exports.scanOrderError = scanOrderError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.12.452",
3
+ "version": "6.12.454",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -74,11 +74,11 @@
74
74
  "react-zoom-pan-pinch": "^3.7.0",
75
75
  "styled-components": "^6.0.0-rc.3",
76
76
  "use-sync-external-store": "^1.6.0",
77
- "@pisell/date-picker": "3.0.12",
78
- "@pisell/utils": "3.0.7",
79
77
  "@pisell/pi-payment-sdk": "0.0.4",
80
- "@pisell/icon": "0.0.11",
81
- "@pisell/materials": "6.12.99"
78
+ "@pisell/utils": "3.0.7",
79
+ "@pisell/date-picker": "3.0.12",
80
+ "@pisell/materials": "6.12.99",
81
+ "@pisell/icon": "0.0.11"
82
82
  },
83
83
  "peerDependencies": {
84
84
  "react": "^18.0.0",
@@ -1 +0,0 @@
1
- export { };