@pisell/private-materials 6.11.674 → 6.11.676

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 (57) 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 +18 -18
  6. package/build/lowcode/view.js +18 -18
  7. package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +1 -0
  8. package/es/components/bigSale/components/TimeBar/index.js +1 -0
  9. package/es/components/bigSale/dialog.js +1 -0
  10. package/es/components/bigSale/hooks/useBigSaleContext.js +1 -0
  11. package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +1 -0
  12. package/es/components/bigSale/index.js +1 -0
  13. package/es/components/bigSale/templates/Kiosk/index.js +1 -0
  14. package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +1 -0
  15. package/es/index.js +2 -0
  16. package/es/plus/multiCurrencySettlement/index.js +1 -1
  17. package/es/plus/piPaymentOld/ui/eftpos/amount.js +6 -3
  18. package/es/plus/piPaymentOld/ui/eftpos/pages/DevicePage.js +9 -21
  19. package/es/plus/piPaymentUI/eftpos/amount.js +6 -3
  20. package/es/plus/piPaymentUI/eftpos/pages/DevicePage.js +9 -21
  21. package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
  22. package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
  23. package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
  24. package/es/plus/pisellReservation/index.js +17 -0
  25. package/es/plus/saasDevice/devicePasscodes/model.js +4 -4
  26. package/es/plus/saleDetail/Base.js +1 -0
  27. package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +1 -0
  28. package/es/plus/saleDetail/components/DetailActions/index.js +1 -0
  29. package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +1 -0
  30. package/es/plus/saleDetail/index.js +1 -0
  31. package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +1 -0
  32. package/es/plus/saleDetail/tmpl/B/index.js +1 -0
  33. package/es/plus/salesSdk/index.js +53 -0
  34. package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
  35. package/es/plus/salesSdk/utils/bookingDate.js +1 -1
  36. package/es/plus/salesSdk/utils/customerAuthGate.js +1 -1
  37. package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
  38. package/es/plus/walletPassGallery/components/timelineSection/index.js +4 -4
  39. package/es/pro/Login2.0/AuthModal.d.ts +1 -1
  40. package/es/pro/Login2.0/index.d.ts +2 -2
  41. package/es/pro/Login2.0/shared/types.d.ts +1 -1
  42. package/es/pro/skuDetailModal/flow/modules/autoResolution.js +19 -3
  43. package/es/pro/skuDetailModal/flow/modules/time/index.js +78 -38
  44. package/es/pro/skuDetailModal/flow/modules/time/posCustomTime.js +17 -8
  45. package/es/pro/skuDetailModal/flow/types.d.ts +4 -0
  46. package/es/pro/skuDetailModal/index.js +36 -28
  47. package/lib/plus/piPaymentOld/ui/eftpos/amount.js +6 -2
  48. package/lib/plus/piPaymentOld/ui/eftpos/pages/DevicePage.js +9 -22
  49. package/lib/plus/piPaymentUI/eftpos/amount.js +6 -2
  50. package/lib/plus/piPaymentUI/eftpos/pages/DevicePage.js +9 -22
  51. package/lib/pro/skuDetailModal/flow/modules/autoResolution.js +19 -2
  52. package/lib/pro/skuDetailModal/flow/modules/time/index.js +76 -36
  53. package/lib/pro/skuDetailModal/flow/modules/time/posCustomTime.js +18 -9
  54. package/lib/pro/skuDetailModal/flow/types.d.ts +4 -0
  55. package/lib/pro/skuDetailModal/index.js +36 -28
  56. package/package.json +2 -2
  57. package/es/private-materials/lowcode/authmodal/meta.d.ts +0 -1
@@ -10,8 +10,8 @@ import { resolveSelectionFlowQueryPartySize } from "../../availabilityModel.js";
10
10
  import { buildDraftCacheItem, getModuleOptions, getUnsupportedBookingFlowReason, isSameCalendarDay, isSameDateValue } from "../shared/index.js";
11
11
  import TimeResourceSelector from "../../../../../components/eventBooking/components/timeResourceSelector/index.js";
12
12
  import { resolveAvailabilityStatus } from "../../../../../components/eventBooking/components/bookingAvailabilityCalendar/utils.js";
13
- import { validateAvailabilityTimeAutoResolution } from "../autoResolution.js";
14
- import { getAvailabilityCandidateDurationMinutes, getPosFlexibleDurationPresetCandidates, getSessionPresetCandidates, isFlexibleDurationValue, isSameAvailabilityCandidateRange, resolvePosCustomTimeBaseMinutes, resolvePosCustomTimeCandidate, resolvePosCustomTimeDefaultDurationMinutes, resolvePosCustomTimeDefaultStartTime, resolvePosFlexibleDurationInitialCandidate, resolvePosFlexibleDurationRequestIntent, shouldApplyPosFlexibleDurationOverride, shouldResetPosFlexibleTimeForDate, shouldShowPosCustomTimeCandidateCards } from "./posCustomTime.js";
13
+ import { resolveFirstPosSessionAutoCandidate, validateAvailabilityTimeAutoResolution } from "../autoResolution.js";
14
+ import { getAvailabilityCandidateDurationMinutes, getPosFlexibleDurationPresetCandidates, getSessionPresetCandidates, isFlexibleDurationValue, isSameAvailabilityCandidateRange, resolvePosCustomTimeBaseMinutes, resolvePosCustomTimeCandidate, resolvePosDurationFallbackDurationMinutes, resolvePosDurationFallbackStartTime, resolvePosFlexibleDurationInitialCandidate, resolvePosFlexibleDurationRequestIntent, shouldApplyPosFlexibleDurationOverride, shouldResetPosFlexibleTimeForDate, shouldShowPosCustomTimeCandidateCards } from "./posCustomTime.js";
15
15
  import dayjs from "dayjs";
16
16
  import React, { useEffect, useMemo } from "react";
17
17
  import { Alert, Space } from "antd";
@@ -95,7 +95,8 @@ const getProductDurationMinutes = (context) => {
95
95
  const product = context.draft.productData;
96
96
  if (isSessionProduct(product) || (product === null || product === void 0 || (_product$cartDetailVa = product.cartDetailValue) === null || _product$cartDetailVa === void 0 ? void 0 : _product$cartDetailVa.session) || (product === null || product === void 0 || (_product$_extend = product._extend) === null || _product$_extend === void 0 || (_product$_extend = _product$_extend.other) === null || _product$_extend === void 0 ? void 0 : _product$_extend.session)) return null;
97
97
  const duration = (_normalizeDurationMin = normalizeDurationMinutesValue(product === null || product === void 0 ? void 0 : product.duration)) !== null && _normalizeDurationMin !== void 0 ? _normalizeDurationMin : normalizeDurationMinutesValue(product === null || product === void 0 ? void 0 : product.service_duration);
98
- return duration ? Math.floor(duration) : null;
98
+ const normalizedDuration = duration ? Math.floor(duration) : 0;
99
+ return normalizedDuration > 0 ? normalizedDuration : null;
99
100
  };
100
101
  const isPosDurationAvailabilityContext = (context) => {
101
102
  var _product$cartDetailVa2, _product$_extend2;
@@ -162,9 +163,29 @@ const finalizeCandidateWithoutResourceStep = function() {
162
163
  return _ref3.apply(this, arguments);
163
164
  };
164
165
  }();
166
+ const clearPosSessionAutoResolutionSelection = (context, module) => {
167
+ if (context.draft.booking.startTime == null && context.draft.booking.endTime == null && context.draft.booking.duration == null && context.draft.booking.selectedCandidate == null && context.draft.booking.commitCandidate == null) return;
168
+ context.updateDraft({ booking: {
169
+ startTime: null,
170
+ endTime: null,
171
+ duration: null,
172
+ selectedCandidate: void 0,
173
+ commitCandidate: void 0
174
+ } }, {
175
+ changedFields: [
176
+ "booking.startTime",
177
+ "booking.endTime",
178
+ "booking.duration",
179
+ "booking.selectedCandidate",
180
+ "booking.commitCandidate"
181
+ ],
182
+ sourceModuleKey: module.key,
183
+ sourceModuleType: "time"
184
+ });
185
+ };
165
186
  const refreshAvailabilityTimes = function() {
166
187
  var _ref5 = _asyncToGenerator(function* (context, module, options = {}) {
167
- var _context$getModuleDat2, _ref4;
188
+ var _context$getModuleDat3, _ref4, _context$services$isP2, _context$services2;
168
189
  const { durationOverride, startTimeOverride, selectionIntent = "restore" } = options;
169
190
  const availability = context.services.availability;
170
191
  const allowUnavailable = context.services.allowUnavailableBookingSelection === true;
@@ -178,6 +199,8 @@ const refreshAvailabilityTimes = function() {
178
199
  const previousTimeData = context.getModuleData(module.key);
179
200
  const posCustomTimeHydrationKey = posCustomTimeAvailability && draftRequestedDuration && draftRequestedStartTime ? `${selectedDate}|${draftRequestedStartTime}|${draftRequestedDuration}` : void 0;
180
201
  const product = context.draft.productData;
202
+ const flexibleDuration = isFlexibleDurationValue(product === null || product === void 0 ? void 0 : product.duration);
203
+ const fixedDuration = getProductDurationMinutes(context);
181
204
  const effectiveSelectionIntent = resolvePosFlexibleDurationRequestIntent({
182
205
  selectionIntent,
183
206
  previousSelectionIntent: previousTimeData === null || previousTimeData === void 0 ? void 0 : previousTimeData.posCustomTimeSelectionIntent,
@@ -188,8 +211,9 @@ const refreshAvailabilityTimes = function() {
188
211
  selectionIntent: effectiveSelectionIntent,
189
212
  isEditMode: context.services.selectionFlowMode === "edit"
190
213
  });
191
- const requestedDuration = suppressFlexiblePresetOverride ? void 0 : draftRequestedDuration;
192
- const requestedStartTime = suppressFlexiblePresetOverride ? void 0 : draftRequestedStartTime;
214
+ const isPosDurationCreateRestore = posDurationAvailability && context.services.selectionFlowMode === "create" && effectiveSelectionIntent === "restore";
215
+ const requestedDuration = suppressFlexiblePresetOverride ? void 0 : isPosDurationCreateRestore && !flexibleDuration ? fixedDuration !== null && fixedDuration !== void 0 ? fixedDuration : void 0 : draftRequestedDuration;
216
+ const requestedStartTime = suppressFlexiblePresetOverride || isPosDurationCreateRestore ? void 0 : draftRequestedStartTime;
193
217
  context.setModuleData(module.key, {
194
218
  requestId,
195
219
  timeSlots: [],
@@ -205,42 +229,55 @@ const refreshAvailabilityTimes = function() {
205
229
  partySize: resolveSelectionFlowQueryPartySize(context.draft, availability.partySize)
206
230
  }, requestedDuration ? _objectSpread2({ durationMinutesByProductId: { [String(availability.productId)]: requestedDuration } }, requestedStartTime ? { durationStartTimesByProductId: { [String(availability.productId)]: [requestedStartTime] } } : {}) : {}))).find((item) => String(item.productId) === String(availability.productId));
207
231
  const candidates = (group === null || group === void 0 ? void 0 : group.ranges) || [];
208
- if (posDurationAvailability && effectiveSelectionIntent === "restore" && isFlexibleDurationValue(product === null || product === void 0 ? void 0 : product.duration) && candidates.length === 0) {
209
- var _context$hostContext, _moduleOptions$slice, _context$draft$bookin2, _normalizeDurationMin3;
232
+ const posDurationFallbackStartTime = posDurationAvailability ? resolvePosDurationFallbackStartTime({
233
+ presentationPlatform: context.services.presentationPlatform,
234
+ selectionFlowMode: context.services.selectionFlowMode,
235
+ allowUnavailableBookingSelection: allowUnavailable,
236
+ selectionIntent: effectiveSelectionIntent,
237
+ groupKind: group === null || group === void 0 ? void 0 : group.kind,
238
+ candidateCount: candidates.length,
239
+ hasValidDuration: flexibleDuration || fixedDuration !== null,
240
+ selectedDate,
241
+ selectionFlowOpenedAt: context.services.selectionFlowOpenedAt
242
+ }) : null;
243
+ if (posDurationFallbackStartTime) {
244
+ var _context$getModuleDat, _context$hostContext, _moduleOptions$slice, _context$draft$bookin2, _normalizeDurationMin3;
245
+ if (((_context$getModuleDat = context.getModuleData(module.key)) === null || _context$getModuleDat === void 0 ? void 0 : _context$getModuleDat.requestId) !== requestId) return;
210
246
  const moduleOptions = getModuleOptions(module);
211
247
  const configuredSlice = (_context$hostContext = context.hostContext) === null || _context$hostContext === void 0 || (_context$hostContext = _context$hostContext.bookingConfig) === null || _context$hostContext === void 0 || (_context$hostContext = _context$hostContext.config) === null || _context$hostContext === void 0 || (_context$hostContext = _context$hostContext.basic) === null || _context$hostContext === void 0 ? void 0 : _context$hostContext.service_time;
212
248
  const fallbackSlice = (_moduleOptions$slice = moduleOptions.slice) !== null && _moduleOptions$slice !== void 0 ? _moduleOptions$slice : typeof configuredSlice === "object" ? configuredSlice === null || configuredSlice === void 0 ? void 0 : configuredSlice.value : configuredSlice;
213
249
  const baseDurationMinutes = resolvePosCustomTimeBaseMinutes(getProductDurationMinutes(context), group === null || group === void 0 ? void 0 : group.slotStepMinutes, fallbackSlice);
214
- const resetForSelectedDate = shouldResetPosFlexibleTimeForDate((_context$draft$bookin2 = context.draft.booking.selectedCandidate) !== null && _context$draft$bookin2 !== void 0 ? _context$draft$bookin2 : previousTimeData === null || previousTimeData === void 0 ? void 0 : previousTimeData.selectedCandidate, selectedDate);
215
- const nextStartTime = resolvePosCustomTimeDefaultStartTime(resetForSelectedDate ? null : context.draft.booking.startTime, baseDurationMinutes);
216
- const nextDuration = resolvePosCustomTimeDefaultDurationMinutes(resetForSelectedDate ? product === null || product === void 0 ? void 0 : product.duration : (_normalizeDurationMin3 = normalizeDurationMinutesValue(context.draft.booking.duration)) !== null && _normalizeDurationMin3 !== void 0 ? _normalizeDurationMin3 : context.draft.booking.duration, baseDurationMinutes);
250
+ const nextDuration = resolvePosDurationFallbackDurationMinutes({
251
+ isFlexibleDuration: flexibleDuration,
252
+ productDurationMinutes: fixedDuration,
253
+ durationValue: shouldResetPosFlexibleTimeForDate((_context$draft$bookin2 = context.draft.booking.selectedCandidate) !== null && _context$draft$bookin2 !== void 0 ? _context$draft$bookin2 : previousTimeData === null || previousTimeData === void 0 ? void 0 : previousTimeData.selectedCandidate, selectedDate) ? product === null || product === void 0 ? void 0 : product.duration : (_normalizeDurationMin3 = normalizeDurationMinutesValue(context.draft.booking.duration)) !== null && _normalizeDurationMin3 !== void 0 ? _normalizeDurationMin3 : context.draft.booking.duration,
254
+ baseDurationMinutes
255
+ });
217
256
  const changedFields = [];
218
- if (nextStartTime !== context.draft.booking.startTime) changedFields.push("booking.startTime");
257
+ if (posDurationFallbackStartTime !== context.draft.booking.startTime) changedFields.push("booking.startTime");
219
258
  if (nextDuration !== context.draft.booking.duration) changedFields.push("booking.duration");
220
259
  if (context.draft.booking.selectedCandidate) changedFields.push("booking.selectedCandidate");
221
260
  if (context.draft.booking.commitCandidate) changedFields.push("booking.commitCandidate");
222
- if (changedFields.length > 0 && nextStartTime) {
223
- context.updateDraft({ booking: {
224
- startTime: nextStartTime,
225
- duration: nextDuration,
226
- selectedCandidate: void 0,
227
- commitCandidate: void 0
228
- } }, {
229
- changedFields,
230
- sourceModuleKey: module.key,
231
- sourceModuleType: "time"
232
- });
233
- yield refreshAvailabilityTimes(context, module, {
234
- durationOverride: nextDuration,
235
- startTimeOverride: nextStartTime,
236
- selectionIntent: "fallback"
237
- });
238
- return;
239
- }
261
+ if (changedFields.length > 0) context.updateDraft({ booking: {
262
+ startTime: posDurationFallbackStartTime,
263
+ duration: nextDuration,
264
+ selectedCandidate: void 0,
265
+ commitCandidate: void 0
266
+ } }, {
267
+ changedFields,
268
+ sourceModuleKey: module.key,
269
+ sourceModuleType: "time"
270
+ });
271
+ yield refreshAvailabilityTimes(context, module, {
272
+ durationOverride: nextDuration,
273
+ startTimeOverride: posDurationFallbackStartTime,
274
+ selectionIntent: "fallback"
275
+ });
276
+ return;
240
277
  }
241
278
  if (candidates.length === 0) {
242
- var _context$getModuleDat;
243
- if (((_context$getModuleDat = context.getModuleData(module.key)) === null || _context$getModuleDat === void 0 ? void 0 : _context$getModuleDat.requestId) !== requestId) return;
279
+ var _context$getModuleDat2, _context$services$isP, _context$services;
280
+ if (((_context$getModuleDat2 = context.getModuleData(module.key)) === null || _context$getModuleDat2 === void 0 ? void 0 : _context$getModuleDat2.requestId) !== requestId) return;
244
281
  context.setModuleData(module.key, {
245
282
  requestId,
246
283
  timeSlots: [],
@@ -249,6 +286,7 @@ const refreshAvailabilityTimes = function() {
249
286
  posCustomTimeHydrationKey,
250
287
  posCustomTimeSelectionIntent: effectiveSelectionIntent === "restore" ? void 0 : effectiveSelectionIntent
251
288
  });
289
+ if (posSessionAvailability && ((_context$services$isP = (_context$services = context.services).isPosAutoResolutionActive) === null || _context$services$isP === void 0 ? void 0 : _context$services$isP.call(_context$services)) === true) clearPosSessionAutoResolutionSelection(context, module);
252
290
  return;
253
291
  }
254
292
  const result = yield availability.queryBookingAvailability(availability.contextId, {
@@ -257,7 +295,7 @@ const refreshAvailabilityTimes = function() {
257
295
  candidates,
258
296
  partySize: resolveSelectionFlowQueryPartySize(context.draft, availability.partySize)
259
297
  });
260
- if (((_context$getModuleDat2 = context.getModuleData(module.key)) === null || _context$getModuleDat2 === void 0 ? void 0 : _context$getModuleDat2.requestId) !== requestId) return;
298
+ if (((_context$getModuleDat3 = context.getModuleData(module.key)) === null || _context$getModuleDat3 === void 0 ? void 0 : _context$getModuleDat3.requestId) !== requestId) return;
261
299
  const timeGroup = result.data.find((item) => String(item === null || item === void 0 ? void 0 : item.productId) === String(availability.productId));
262
300
  const times = Array.isArray(timeGroup === null || timeGroup === void 0 ? void 0 : timeGroup.times) ? timeGroup.times : [];
263
301
  const existingCandidate = context.draft.booking.selectedCandidate;
@@ -300,9 +338,10 @@ const refreshAvailabilityTimes = function() {
300
338
  const selectableCandidates = normallySelectableCandidates.length > 0 || !allowUnavailable ? normallySelectableCandidates : times;
301
339
  const shouldPreserveRequestedPosStart = posCustomTimeAvailability && Boolean(requestedPosStartTime && requestedPosDuration);
302
340
  const displayCandidates = posSessionAvailability ? getSessionPresetCandidates(times) : posDurationAvailability && isFlexibleDurationValue(product === null || product === void 0 ? void 0 : product.duration) ? getPosFlexibleDurationPresetCandidates(times, requestedCustomRange, customSelectionIntent, Boolean(!customSelectionIntent && existingCandidate && existingCandidate.date === selectedDate && (previousTimeData === null || previousTimeData === void 0 ? void 0 : previousTimeData.timeSlots.some((slot) => String(slot.id) === String(existingCandidate.key))))) : times;
341
+ const restrictPosSessionAutoResolution = posSessionAvailability && ((_context$services$isP2 = (_context$services2 = context.services).isPosAutoResolutionActive) === null || _context$services$isP2 === void 0 ? void 0 : _context$services$isP2.call(_context$services2)) === true;
303
342
  const fallbackCandidate = shouldPreserveRequestedPosStart ? void 0 : selectableCandidates[0];
304
343
  const preferPosFlexiblePreset = posDurationAvailability && isFlexibleDurationValue(product === null || product === void 0 ? void 0 : product.duration) && !customSelectionIntent && context.services.selectionFlowMode !== "edit" && (selectionIntent === "fallback" || !existingCandidate || existingCandidate.date !== selectedDate);
305
- const initialCandidate = posDurationAvailability && isFlexibleDurationValue(product === null || product === void 0 ? void 0 : product.duration) ? resolvePosFlexibleDurationInitialCandidate({
344
+ const initialCandidate = restrictPosSessionAutoResolution ? resolveFirstPosSessionAutoCandidate(displayCandidates) : posDurationAvailability && isFlexibleDurationValue(product === null || product === void 0 ? void 0 : product.duration) ? resolvePosFlexibleDurationInitialCandidate({
306
345
  presetCandidates: displayCandidates,
307
346
  restoredCandidate,
308
347
  fallbackCandidate,
@@ -325,6 +364,7 @@ const refreshAvailabilityTimes = function() {
325
364
  posCustomTimeHydrationKey,
326
365
  posCustomTimeSelectionIntent: effectiveSelectionIntent === "restore" ? void 0 : effectiveSelectionIntent
327
366
  });
367
+ if (restrictPosSessionAutoResolution && !initialCandidate) clearPosSessionAutoResolutionSelection(context, module);
328
368
  const shouldWriteInitialCandidate = Boolean(initialCandidate) && (posCustomTimeAvailability || !existingCandidate || initialCandidate.key !== existingCandidate.key);
329
369
  if (initialCandidate && shouldWriteInitialCandidate) {
330
370
  const startAt = dayjs(initialCandidate.startAt);
@@ -376,9 +416,9 @@ const normalizeSelectionDuration = (duration) => {
376
416
  return null;
377
417
  };
378
418
  const buildTimeCacheItem = (context, startTime, duration) => {
379
- var _context$getModuleDat3;
419
+ var _context$getModuleDat4;
380
420
  const resourceModule = context.steps.flatMap((step) => step.modules).find((item) => item.type === "resource");
381
- const cacheItem = buildDraftCacheItem(context, resourceModule ? (_context$getModuleDat3 = context.getModuleData(resourceModule.key)) === null || _context$getModuleDat3 === void 0 ? void 0 : _context$getModuleDat3.cacheItem : void 0);
421
+ const cacheItem = buildDraftCacheItem(context, resourceModule ? (_context$getModuleDat4 = context.getModuleData(resourceModule.key)) === null || _context$getModuleDat4 === void 0 ? void 0 : _context$getModuleDat4.cacheItem : void 0);
382
422
  return _objectSpread2(_objectSpread2({}, cacheItem), {}, { _extend: _objectSpread2(_objectSpread2({}, (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {}), {}, {
383
423
  start_time: startTime,
384
424
  duration
@@ -432,9 +472,9 @@ const getFlexibleDuration = (timeObj) => {
432
472
  return (timeObj === null || timeObj === void 0 || (_timeObj$durationSlic = timeObj.durationSlicesBasedOnTime) === null || _timeObj$durationSlic === void 0 || (_timeObj$durationSlic = _timeObj$durationSlic.find((item) => typeof (item === null || item === void 0 ? void 0 : item.value) === "string" && item.value.startsWith("flexible_") && !item.disabled)) === null || _timeObj$durationSlic === void 0 ? void 0 : _timeObj$durationSlic.value) || (timeObj === null || timeObj === void 0 || (_timeObj$durationSlic2 = timeObj.durationSlicesBasedOnTime) === null || _timeObj$durationSlic2 === void 0 || (_timeObj$durationSlic2 = _timeObj$durationSlic2.find((item) => typeof (item === null || item === void 0 ? void 0 : item.value) === "string" && item.value.startsWith("flexible_"))) === null || _timeObj$durationSlic2 === void 0 ? void 0 : _timeObj$durationSlic2.value);
433
473
  };
434
474
  const resolveInitialDuration = (context) => {
435
- var _context$services$get, _context$services, _serviceCacheItem$_ex, _serviceCacheItem$_ex2, _context$draft$produc, _context$draft$produc2, _timeObj$durationSlic3, _ref6, _configuredOption$val, _timeObj$durationSlic4;
475
+ var _context$services$get, _context$services3, _serviceCacheItem$_ex, _serviceCacheItem$_ex2, _context$draft$produc, _context$draft$produc2, _timeObj$durationSlic3, _ref6, _configuredOption$val, _timeObj$durationSlic4;
436
476
  if (hasDurationValue(context.draft.booking.duration)) return context.draft.booking.duration;
437
- const serviceCacheItem = (_context$services$get = (_context$services = context.services).getCurrentCacheItem) === null || _context$services$get === void 0 ? void 0 : _context$services$get.call(_context$services);
477
+ const serviceCacheItem = (_context$services$get = (_context$services3 = context.services).getCurrentCacheItem) === null || _context$services$get === void 0 ? void 0 : _context$services$get.call(_context$services3);
438
478
  const existingDuration = normalizeSelectionDuration((_serviceCacheItem$_ex = serviceCacheItem === null || serviceCacheItem === void 0 || (_serviceCacheItem$_ex2 = serviceCacheItem._extend) === null || _serviceCacheItem$_ex2 === void 0 ? void 0 : _serviceCacheItem$_ex2.duration) !== null && _serviceCacheItem$_ex !== void 0 ? _serviceCacheItem$_ex : (_context$draft$produc = context.draft.productData) === null || _context$draft$produc === void 0 || (_context$draft$produc = _context$draft$produc._extend) === null || _context$draft$produc === void 0 ? void 0 : _context$draft$produc.duration);
439
479
  if (hasDurationValue(existingDuration)) return existingDuration;
440
480
  const { timeObj } = getTimeRuntime(context, context.draft.booking.startTime, null);
@@ -20,19 +20,23 @@ const resolvePosCustomTimeBaseMinutes = (...values) => {
20
20
  }
21
21
  return 30;
22
22
  };
23
- const resolvePosCustomTimeDefaultStartTime = (currentValue, sliceMinutes, now) => {
23
+ const resolvePosCustomTimeDefaultStartTime = (currentValue, _sliceMinutes, now) => {
24
24
  if (typeof currentValue === "string") {
25
25
  const matched = currentValue.trim().match(/^([01]\d|2[0-3]):([0-5]\d)(?::[0-5]\d)?$/);
26
26
  if (matched) return `${matched[1]}:${matched[2]}`;
27
27
  }
28
28
  const current = now === void 0 ? dayjs() : dayjs(now);
29
29
  if (!current.isValid()) return null;
30
- const step = Math.min(resolvePosCustomTimeBaseMinutes(sliceMinutes), 1440);
31
- const minuteOfDay = current.hour() * 60 + current.minute();
32
- const alignedMinute = Math.floor(minuteOfDay / step) * step;
33
- const hours = Math.floor(alignedMinute / 60);
34
- const minutes = alignedMinute % 60;
35
- return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}`;
30
+ return current.format("HH:mm");
31
+ };
32
+ const resolvePosDurationFallbackStartTime = (params) => {
33
+ if (params.presentationPlatform !== "pos" || params.selectionFlowMode !== "create" || params.allowUnavailableBookingSelection !== true || params.selectionIntent !== "restore" || params.groupKind !== "duration" || params.candidateCount !== 0 || !params.hasValidDuration || !params.selectionFlowOpenedAt) return null;
34
+ const openedAt = dayjs(params.selectionFlowOpenedAt);
35
+ const current = params.now === void 0 ? dayjs() : dayjs(params.now);
36
+ if (!openedAt.isValid() || !current.isValid()) return null;
37
+ const openedDate = openedAt.format("YYYY-MM-DD");
38
+ if (params.selectedDate !== openedDate || params.selectedDate !== current.format("YYYY-MM-DD")) return null;
39
+ return resolvePosCustomTimeDefaultStartTime(null, 1, params.selectionFlowOpenedAt);
36
40
  };
37
41
  const shouldResetPosFlexibleTimeForDate = (candidate, selectedDate) => Boolean(candidate && candidate.date !== selectedDate);
38
42
  const resolvePosCustomTimeDefaultDurationMinutes = (currentValue, baseDurationMinutes) => {
@@ -46,6 +50,11 @@ const resolvePosCustomTimeDefaultDurationMinutes = (currentValue, baseDurationMi
46
50
  if (Number.isFinite(currentMinutes) && currentMinutes > 0) return Math.max(1, Math.floor(currentMinutes));
47
51
  return resolvePosCustomTimeBaseMinutes(baseDurationMinutes);
48
52
  };
53
+ const resolvePosDurationFallbackDurationMinutes = (params) => {
54
+ if (params.isFlexibleDuration) return resolvePosCustomTimeDefaultDurationMinutes(params.durationValue, params.baseDurationMinutes);
55
+ const productDurationMinutes = Math.floor(Number(params.productDurationMinutes));
56
+ return Number.isFinite(productDurationMinutes) && productDurationMinutes > 0 ? productDurationMinutes : null;
57
+ };
49
58
  const shouldShowPosCustomTimeCandidateCards = (params) => params.isSessionAvailability || params.isDurationAvailability && params.candidateCount > 0;
50
59
  const getAvailabilityCandidateDurationMinutes = (candidate) => {
51
60
  const startAt = dayjs(candidate.startAt);
@@ -77,4 +86,4 @@ const resolvePosFlexibleDurationInitialCandidate = (params) => {
77
86
  return params.restoredCandidate || params.fallbackCandidate;
78
87
  };
79
88
  //#endregion
80
- export { getAvailabilityCandidateDurationMinutes, getPosFlexibleDurationPresetCandidates, getSessionPresetCandidates, isFlexibleDurationValue, isSameAvailabilityCandidateRange, resolvePosCustomTimeBaseMinutes, resolvePosCustomTimeCandidate, resolvePosCustomTimeDefaultDurationMinutes, resolvePosCustomTimeDefaultStartTime, resolvePosFlexibleDurationInitialCandidate, resolvePosFlexibleDurationRequestIntent, shouldApplyPosFlexibleDurationOverride, shouldResetPosFlexibleTimeForDate, shouldShowPosCustomTimeCandidateCards };
89
+ export { getAvailabilityCandidateDurationMinutes, getPosFlexibleDurationPresetCandidates, getSessionPresetCandidates, isFlexibleDurationValue, isSameAvailabilityCandidateRange, resolvePosCustomTimeBaseMinutes, resolvePosCustomTimeCandidate, resolvePosDurationFallbackDurationMinutes, resolvePosDurationFallbackStartTime, resolvePosFlexibleDurationInitialCandidate, resolvePosFlexibleDurationRequestIntent, shouldApplyPosFlexibleDurationOverride, shouldResetPosFlexibleTimeForDate, shouldShowPosCustomTimeCandidateCards };
@@ -189,6 +189,10 @@ interface SelectionFlowAvailabilityService {
189
189
  interface SelectionFlowServices {
190
190
  /** 当前 Host 打开 Flow 的业务模式;编辑专属 module 通过它决定是否参与。 */
191
191
  selectionFlowMode?: 'create' | 'edit';
192
+ /** 本次 POS create 首屏是否仍处于自动推导阶段;进入人工流程后立即关闭。 */
193
+ isPosAutoResolutionActive?: () => boolean;
194
+ /** 当前 SKU Detail 弹窗打开时的稳定时间锚点,供 POS 当天兜底使用。 */
195
+ selectionFlowOpenedAt?: string;
192
196
  /** POS 旧 Edit service 是否应在资源步骤展示可编辑 Price。 */
193
197
  showServicePrice?: boolean;
194
198
  /**
@@ -208,6 +208,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, variant }, ref) => {
208
208
  });
209
209
  const openParamsRef = useRef(null);
210
210
  const openTaskIdRef = useRef(0);
211
+ const selectionFlowOpenedAtRef = useRef(null);
211
212
  const flowDateHydrationVersionRef = useRef(0);
212
213
  /**
213
214
  * 左侧可滚动容器 ref
@@ -617,13 +618,30 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, variant }, ref) => {
617
618
  if (isSkuOnlyDraftChange(previousDraft, draft)) React.startTransition(projectDraftToModal);
618
619
  else projectDraftToModal();
619
620
  }, [productData]);
620
- const selectionFlowServices = useMemo(() => {
621
+ const isPosCreateAutoResolutionEligible = useMemo(() => {
621
622
  var _openParamsRef$curren6;
622
- return _objectSpread2(_objectSpread2({}, ((_openParamsRef$curren6 = openParamsRef.current) === null || _openParamsRef$curren6 === void 0 ? void 0 : _openParamsRef$curren6.selectionFlowServices) || {}), {}, {
623
+ return isCustomSelectionFlow && isPosCreateAutoResolutionCandidate({
624
+ platform: actualSelectionFlowPlatform,
625
+ selectionFlowMode: (_openParamsRef$curren6 = openParamsRef.current) === null || _openParamsRef$curren6 === void 0 || (_openParamsRef$curren6 = _openParamsRef$curren6.selectionFlowServices) === null || _openParamsRef$curren6 === void 0 ? void 0 : _openParamsRef$curren6.selectionFlowMode,
626
+ steps: compiledSelectionFlowSteps
627
+ });
628
+ }, [
629
+ actualSelectionFlowPlatform,
630
+ compiledSelectionFlowSteps,
631
+ isCustomSelectionFlow
632
+ ]);
633
+ const selectionFlowServices = useMemo(() => {
634
+ var _openParamsRef$curren7;
635
+ return _objectSpread2(_objectSpread2({}, ((_openParamsRef$curren7 = openParamsRef.current) === null || _openParamsRef$curren7 === void 0 ? void 0 : _openParamsRef$curren7.selectionFlowServices) || {}), {}, {
636
+ isPosAutoResolutionActive: () => {
637
+ var _selectionFlowRef$cur3;
638
+ return isPosCreateAutoResolutionEligible && !posAutoResolutionAbandonedRef.current && ((_selectionFlowRef$cur3 = selectionFlowRef.current) === null || _selectionFlowRef$cur3 === void 0 ? void 0 : _selectionFlowRef$cur3.getState().currentStepIndex) === 0;
639
+ },
640
+ selectionFlowOpenedAt: selectionFlowOpenedAtRef.current || void 0,
623
641
  hydrateProductDataForDate: hydrateFlowProductDataForDate,
624
642
  getCurrentCacheItem: () => {
625
- var _selectionFlowRef$cur3;
626
- return ((_selectionFlowRef$cur3 = selectionFlowRef.current) === null || _selectionFlowRef$cur3 === void 0 ? void 0 : _selectionFlowRef$cur3.getState().draft.productData) || productData;
643
+ var _selectionFlowRef$cur4;
644
+ return ((_selectionFlowRef$cur4 = selectionFlowRef.current) === null || _selectionFlowRef$cur4 === void 0 ? void 0 : _selectionFlowRef$cur4.getState().draft.productData) || productData;
627
645
  },
628
646
  skuSelectionConfig,
629
647
  skuSelectionSkuCardConfig,
@@ -639,6 +657,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, variant }, ref) => {
639
657
  hydrateFlowProductDataForDate,
640
658
  isKioskPlatform,
641
659
  isMobile,
660
+ isPosCreateAutoResolutionEligible,
642
661
  productData,
643
662
  skuDetailConfig === null || skuDetailConfig === void 0 ? void 0 : skuDetailConfig.allowUnavailableBookingSelection,
644
663
  skuDetailConfig === null || skuDetailConfig === void 0 ? void 0 : skuDetailConfig.allowNoResourceBookingSelection,
@@ -707,18 +726,6 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, variant }, ref) => {
707
726
  effectiveSelectionFlowSteps,
708
727
  selectionFlowProcedureSteps
709
728
  ]);
710
- const isPosCreateAutoResolutionEligible = useMemo(() => {
711
- var _openParamsRef$curren7;
712
- return isCustomSelectionFlow && isPosCreateAutoResolutionCandidate({
713
- platform: actualSelectionFlowPlatform,
714
- selectionFlowMode: (_openParamsRef$curren7 = openParamsRef.current) === null || _openParamsRef$curren7 === void 0 || (_openParamsRef$curren7 = _openParamsRef$curren7.selectionFlowServices) === null || _openParamsRef$curren7 === void 0 ? void 0 : _openParamsRef$curren7.selectionFlowMode,
715
- steps: compiledSelectionFlowSteps
716
- });
717
- }, [
718
- actualSelectionFlowPlatform,
719
- compiledSelectionFlowSteps,
720
- isCustomSelectionFlow
721
- ]);
722
729
  const posAutoResolutionDraftKey = useMemo(() => getPosAutoResolutionDraftKey(latestSelectionFlowDraft), [latestSelectionFlowDraft]);
723
730
  useEffect(() => {
724
731
  const runId = posAutoResolutionRunRef.current + 1;
@@ -753,9 +760,9 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, variant }, ref) => {
753
760
  });
754
761
  const maxStepIndex = useMemo(() => Math.max(0, procedureSteps.length - 1), [procedureSteps]);
755
762
  useLayoutEffect(() => {
756
- var _selectionFlowRef$cur4, _selectionFlowRef$cur5, _procedureRef$current, _procedureRef$current2;
763
+ var _selectionFlowRef$cur5, _selectionFlowRef$cur6, _procedureRef$current, _procedureRef$current2;
757
764
  if (procedureSteps.length === 0) return;
758
- const sourceStepIndex = isCustomSelectionFlow ? (_selectionFlowRef$cur4 = (_selectionFlowRef$cur5 = selectionFlowRef.current) === null || _selectionFlowRef$cur5 === void 0 ? void 0 : _selectionFlowRef$cur5.getState().currentStepIndex) !== null && _selectionFlowRef$cur4 !== void 0 ? _selectionFlowRef$cur4 : currentStep : currentStep;
765
+ const sourceStepIndex = isCustomSelectionFlow ? (_selectionFlowRef$cur5 = (_selectionFlowRef$cur6 = selectionFlowRef.current) === null || _selectionFlowRef$cur6 === void 0 ? void 0 : _selectionFlowRef$cur6.getState().currentStepIndex) !== null && _selectionFlowRef$cur5 !== void 0 ? _selectionFlowRef$cur5 : currentStep : currentStep;
759
766
  const nextStepIndex = Math.min(Math.max(0, sourceStepIndex), procedureSteps.length - 1);
760
767
  if (currentStep !== nextStepIndex) setCurrentStep(nextStepIndex);
761
768
  (_procedureRef$current = procedureRef.current) === null || _procedureRef$current === void 0 || (_procedureRef$current2 = _procedureRef$current.goToStep) === null || _procedureRef$current2 === void 0 || _procedureRef$current2.call(_procedureRef$current, nextStepIndex);
@@ -793,6 +800,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, variant }, ref) => {
793
800
  open: function() {
794
801
  var _ref16 = _asyncToGenerator(function* (data) {
795
802
  var _skuDetailConfig$enab, _skuDetailConfig$isSh, _skuDetailConfig$isSh2, _skuDetailConfig$isSh3, _skuDetailConfig$isSh4, _skuDetailConfig$isSh5, _skuDetailConfig$hide, _skuDetailConfig$isSh6, _skuDetailConfig$isSh7, _skuDetailConfig$isSh8, _skuDetailConfig$exte, _skuDetailConfig$useC, _skuDetailConfig$cust, _skuDetailConfig$isCa, _skuDetailConfig, _skuDetailConfig2, _data$bundle_group, _data$_extend, _data$_extend2, _data$discount_list, _ref14, _data$_extend3, _data$_extend4, _data$_extend5, _data$discount_list$f, _data$discount_list2, _ref15, _data$_extend$priceOv, _data$_extend7;
803
+ selectionFlowOpenedAtRef.current = dayjs().toISOString();
796
804
  const currentTaskId = openTaskIdRef.current + 1;
797
805
  openTaskIdRef.current = currentTaskId;
798
806
  flowDateHydrationVersionRef.current += 1;
@@ -1385,7 +1393,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, variant }, ref) => {
1385
1393
  };
1386
1394
  const handleConfirm = function() {
1387
1395
  var _ref17 = _asyncToGenerator(function* (flowDraft) {
1388
- var _bookingState$booking2, _selectionFlowRef$cur6, _selectionFlowService2;
1396
+ var _bookingState$booking2, _selectionFlowRef$cur7, _selectionFlowService2;
1389
1397
  if (isCustomSelectionFlow && !flowDraft) {
1390
1398
  var _snapshot$currentStep;
1391
1399
  const flow = selectionFlowRef.current;
@@ -1498,7 +1506,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, variant }, ref) => {
1498
1506
  console.log("sku_detail_modal_validate_error>>>>>", error);
1499
1507
  return false;
1500
1508
  }
1501
- const flowSnapshot = flowDraft ? (_selectionFlowRef$cur6 = selectionFlowRef.current) === null || _selectionFlowRef$cur6 === void 0 ? void 0 : _selectionFlowRef$cur6.getState() : void 0;
1509
+ const flowSnapshot = flowDraft ? (_selectionFlowRef$cur7 = selectionFlowRef.current) === null || _selectionFlowRef$cur7 === void 0 ? void 0 : _selectionFlowRef$cur7.getState() : void 0;
1502
1510
  const activeFlowModuleTypes = flowSnapshot === null || flowSnapshot === void 0 ? void 0 : flowSnapshot.steps.flatMap((step) => step.modules.map((module) => module.type));
1503
1511
  const requiresBookingPrice = Boolean(flowDraft && (activeFlowModuleTypes === null || activeFlowModuleTypes === void 0 ? void 0 : activeFlowModuleTypes.includes("bookingPrice")));
1504
1512
  const expectedBookingPriceRequestKey = flowDraft ? resolveSelectionFlowBookingPriceRequestKey(flowDraft, selectionFlowServices.bookingPrice) : void 0;
@@ -1652,8 +1660,8 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, variant }, ref) => {
1652
1660
  if (isWeighingProduct$1) return;
1653
1661
  if (value && value > 0) {
1654
1662
  if (value !== quantity && isCustomSelectionFlow && isKioskPlatform) {
1655
- var _selectionFlowRef$cur7;
1656
- const snapshot = (_selectionFlowRef$cur7 = selectionFlowRef.current) === null || _selectionFlowRef$cur7 === void 0 ? void 0 : _selectionFlowRef$cur7.getState();
1663
+ var _selectionFlowRef$cur8;
1664
+ const snapshot = (_selectionFlowRef$cur8 = selectionFlowRef.current) === null || _selectionFlowRef$cur8 === void 0 ? void 0 : _selectionFlowRef$cur8.getState();
1657
1665
  const reviewStepIndex = snapshot ? getLateQuantityReviewStepIndex(snapshot.steps, snapshot.currentStepIndex) : null;
1658
1666
  if (reviewStepIndex != null) lateQuantityReviewStepIndexRef.current = reviewStepIndex;
1659
1667
  }
@@ -1929,9 +1937,9 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, variant }, ref) => {
1929
1937
  if (openTaskIdRef.current !== selectionFlowInstanceKey) return;
1930
1938
  setCompiledSelectionFlowSteps(steps);
1931
1939
  if (steps.length === 0 && typeof ((_openParamsRef$curren8 = openParamsRef.current) === null || _openParamsRef$curren8 === void 0 ? void 0 : _openParamsRef$curren8.onSelectionFlowNotApplicable) === "function") {
1932
- var _selectionFlowRef$cur8;
1940
+ var _selectionFlowRef$cur9;
1933
1941
  const onNotApplicable = openParamsRef.current.onSelectionFlowNotApplicable;
1934
- const latestProductData = ((_selectionFlowRef$cur8 = selectionFlowRef.current) === null || _selectionFlowRef$cur8 === void 0 ? void 0 : _selectionFlowRef$cur8.getState().draft.productData) || productData;
1942
+ const latestProductData = ((_selectionFlowRef$cur9 = selectionFlowRef.current) === null || _selectionFlowRef$cur9 === void 0 ? void 0 : _selectionFlowRef$cur9.getState().draft.productData) || productData;
1935
1943
  if (latestProductData) {
1936
1944
  if (onNotApplicable({
1937
1945
  productData: latestProductData,
@@ -2090,15 +2098,15 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, variant }, ref) => {
2090
2098
  defaultCurrent: currentStep,
2091
2099
  layoutMode: "ratio",
2092
2100
  onPrev: () => {
2093
- var _selectionFlowRef$cur9;
2101
+ var _selectionFlowRef$cur10;
2094
2102
  if (!isCustomSelectionFlow) return;
2095
- return ((_selectionFlowRef$cur9 = selectionFlowRef.current) === null || _selectionFlowRef$cur9 === void 0 ? void 0 : _selectionFlowRef$cur9.back()) ? void 0 : false;
2103
+ return ((_selectionFlowRef$cur10 = selectionFlowRef.current) === null || _selectionFlowRef$cur10 === void 0 ? void 0 : _selectionFlowRef$cur10.back()) ? void 0 : false;
2096
2104
  },
2097
2105
  onStepsChange: (result) => {
2098
2106
  const nextStep = Math.min(Number(result.currentStep || 0), maxStepIndex);
2099
2107
  if (isCustomSelectionFlow) {
2100
- var _selectionFlowRef$cur10;
2101
- setCurrentStep(((_selectionFlowRef$cur10 = selectionFlowRef.current) === null || _selectionFlowRef$cur10 === void 0 ? void 0 : _selectionFlowRef$cur10.getState().currentStepIndex) || 0);
2108
+ var _selectionFlowRef$cur11;
2109
+ setCurrentStep(((_selectionFlowRef$cur11 = selectionFlowRef.current) === null || _selectionFlowRef$cur11 === void 0 ? void 0 : _selectionFlowRef$cur11.getState().currentStepIndex) || 0);
2102
2110
  return;
2103
2111
  }
2104
2112
  setCurrentStep(nextStep);
@@ -17,8 +17,11 @@ const decimal = (value) => {
17
17
  const readerSurcharge = (reader) => {
18
18
  var _ref, _ref2, _ref3, _setting$surcharge_ra, _ref4, _ref5, _setting$surcharge_fi;
19
19
  const setting = (reader === null || reader === void 0 ? void 0 : reader.setting) || {};
20
- /** useOriginSurcharge 表示业务方自行计算,卡机默认费率不得叠加。 */
21
- if (setting.useOriginSurcharge) return {
20
+ /**
21
+ * useOriginSurcharge 表示由卡机收取原始手续费;surcharge=false 表示商户已关闭
22
+ * Pisell 手续费。两种场景都不得继续使用 Reader 中可能残留的历史费率。
23
+ */
24
+ if (setting.useOriginSurcharge || setting.surcharge === false) return {
22
25
  rate: 0,
23
26
  fixed: 0
24
27
  };
@@ -63,4 +66,5 @@ const updateEftposDraftAmount = (draft, input) => {
63
66
  });
64
67
  };
65
68
  //#endregion
69
+ exports.buildPaymentAmountQuote = buildPaymentAmountQuote;
66
70
  exports.updateEftposDraftAmount = updateEftposDraftAmount;
@@ -1,27 +1,18 @@
1
1
  const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
2
2
  const require_index = require("../contracts/index.js");
3
+ const require_amount = require("../amount.js");
3
4
  let react = require("react");
4
5
  react = require_runtime.__toESM(react);
5
6
  let _pisell_utils = require("@pisell/utils");
6
- let decimal_js = require("decimal.js");
7
- decimal_js = require_runtime.__toESM(decimal_js);
8
7
  let _pisell_icon_es_ChevronRight = require("@pisell/icon/es/ChevronRight");
9
8
  _pisell_icon_es_ChevronRight = require_runtime.__toESM(_pisell_icon_es_ChevronRight);
10
9
  //#region src/plus/piPaymentOld/ui/eftpos/pages/DevicePage.tsx
11
- /** 转成 Decimal。 */
12
- const toDecimal = (value) => {
13
- try {
14
- return new decimal_js.default(value === void 0 || value === null || value === "" ? 0 : value);
15
- } catch (_error) {
16
- return new decimal_js.default(0);
17
- }
18
- };
19
10
  /** 从 reader setting 计算设备列表展示金额。 */
20
11
  const resolveReaderPay = (reader, options) => {
21
- var _ref, _ref2, _ref3, _setting$surcharge_ra, _ref4, _ref5, _setting$surcharge_fi;
22
12
  /** pay/setting 均来自不同版本后端,读取时需要保持兼容。 */
23
13
  const pay = reader.pay;
24
- if (pay) {
14
+ const setting = reader.setting || {};
15
+ if (pay && !setting.useOriginSurcharge && setting.surcharge !== false) {
25
16
  var _pay$surRate, _pay$surMoney, _pay$surcharge;
26
17
  return {
27
18
  totalUnit: String(pay.totalUnit || pay.total || ""),
@@ -30,17 +21,13 @@ const resolveReaderPay = (reader, options) => {
30
21
  surcharge: String((_pay$surcharge = pay.surcharge) !== null && _pay$surcharge !== void 0 ? _pay$surcharge : "")
31
22
  };
32
23
  }
33
- const setting = reader.setting || {};
34
- const amount = toDecimal(options === null || options === void 0 ? void 0 : options.amount);
35
- const rate = setting.useOriginSurcharge ? new decimal_js.default(0) : toDecimal((_ref = (_ref2 = (_ref3 = (_setting$surcharge_ra = setting.surcharge_rate) !== null && _setting$surcharge_ra !== void 0 ? _setting$surcharge_ra : setting.surRate) !== null && _ref3 !== void 0 ? _ref3 : setting.constant_rate) !== null && _ref2 !== void 0 ? _ref2 : setting.surcharge) !== null && _ref !== void 0 ? _ref : 0);
36
- const fixed = setting.useOriginSurcharge ? new decimal_js.default(0) : toDecimal((_ref4 = (_ref5 = (_setting$surcharge_fi = setting.surcharge_fixed) !== null && _setting$surcharge_fi !== void 0 ? _setting$surcharge_fi : setting.surMoney) !== null && _ref5 !== void 0 ? _ref5 : setting.constant_money) !== null && _ref4 !== void 0 ? _ref4 : 0);
37
- /** 设备卡片展示的总手续费与最终扣款额,只用于选择前的预览。 */
38
- const surcharge = amount.mul(rate.div(100)).add(fixed);
24
+ /** 设备预览与选择 Reader 后的实际支付报价必须使用同一套金额规则。 */
25
+ const quote = require_amount.buildPaymentAmountQuote(options === null || options === void 0 ? void 0 : options.amount, options === null || options === void 0 ? void 0 : options.surcharge, reader);
39
26
  return {
40
- totalUnit: amount.add(surcharge).toFixed(2, decimal_js.default.ROUND_HALF_UP),
41
- surRate: rate.toString(),
42
- surMoney: fixed.toFixed(2, decimal_js.default.ROUND_HALF_UP),
43
- surcharge: surcharge.toFixed(2, decimal_js.default.ROUND_HALF_UP)
27
+ totalUnit: quote.total,
28
+ surRate: quote.surchargeRate,
29
+ surMoney: quote.surchargeFixed,
30
+ surcharge: quote.surchargeTotal
44
31
  };
45
32
  };
46
33
  /** 获取 MX51 pairing id。 */
@@ -17,8 +17,11 @@ const decimal = (value) => {
17
17
  const readerSurcharge = (reader) => {
18
18
  var _ref, _ref2, _ref3, _setting$surcharge_ra, _ref4, _ref5, _setting$surcharge_fi;
19
19
  const setting = (reader === null || reader === void 0 ? void 0 : reader.setting) || {};
20
- /** useOriginSurcharge 表示业务方自行计算,卡机默认费率不得叠加。 */
21
- if (setting.useOriginSurcharge) return {
20
+ /**
21
+ * useOriginSurcharge 表示由卡机收取原始手续费;surcharge=false 表示商户已关闭
22
+ * Pisell 手续费。两种场景都不得继续使用 Reader 中可能残留的历史费率。
23
+ */
24
+ if (setting.useOriginSurcharge || setting.surcharge === false) return {
22
25
  rate: 0,
23
26
  fixed: 0
24
27
  };
@@ -63,4 +66,5 @@ const updateEftposDraftAmount = (draft, input) => {
63
66
  });
64
67
  };
65
68
  //#endregion
69
+ exports.buildPaymentAmountQuote = buildPaymentAmountQuote;
66
70
  exports.updateEftposDraftAmount = updateEftposDraftAmount;
@@ -1,27 +1,18 @@
1
1
  const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
2
2
  const require_index = require("../contracts/index.js");
3
+ const require_amount = require("../amount.js");
3
4
  let react = require("react");
4
5
  react = require_runtime.__toESM(react);
5
6
  let _pisell_utils = require("@pisell/utils");
6
- let decimal_js = require("decimal.js");
7
- decimal_js = require_runtime.__toESM(decimal_js);
8
7
  let _pisell_icon_es_ChevronRight = require("@pisell/icon/es/ChevronRight");
9
8
  _pisell_icon_es_ChevronRight = require_runtime.__toESM(_pisell_icon_es_ChevronRight);
10
9
  //#region src/plus/piPaymentUI/eftpos/pages/DevicePage.tsx
11
- /** 转成 Decimal。 */
12
- const toDecimal = (value) => {
13
- try {
14
- return new decimal_js.default(value === void 0 || value === null || value === "" ? 0 : value);
15
- } catch (_error) {
16
- return new decimal_js.default(0);
17
- }
18
- };
19
10
  /** 从 reader setting 计算设备列表展示金额。 */
20
11
  const resolveReaderPay = (reader, options) => {
21
- var _ref, _ref2, _ref3, _setting$surcharge_ra, _ref4, _ref5, _setting$surcharge_fi;
22
12
  /** pay/setting 均来自不同版本后端,读取时需要保持兼容。 */
23
13
  const pay = reader.pay;
24
- if (pay) {
14
+ const setting = reader.setting || {};
15
+ if (pay && !setting.useOriginSurcharge && setting.surcharge !== false) {
25
16
  var _pay$surRate, _pay$surMoney, _pay$surcharge;
26
17
  return {
27
18
  totalUnit: String(pay.totalUnit || pay.total || ""),
@@ -30,17 +21,13 @@ const resolveReaderPay = (reader, options) => {
30
21
  surcharge: String((_pay$surcharge = pay.surcharge) !== null && _pay$surcharge !== void 0 ? _pay$surcharge : "")
31
22
  };
32
23
  }
33
- const setting = reader.setting || {};
34
- const amount = toDecimal(options === null || options === void 0 ? void 0 : options.amount);
35
- const rate = setting.useOriginSurcharge ? new decimal_js.default(0) : toDecimal((_ref = (_ref2 = (_ref3 = (_setting$surcharge_ra = setting.surcharge_rate) !== null && _setting$surcharge_ra !== void 0 ? _setting$surcharge_ra : setting.surRate) !== null && _ref3 !== void 0 ? _ref3 : setting.constant_rate) !== null && _ref2 !== void 0 ? _ref2 : setting.surcharge) !== null && _ref !== void 0 ? _ref : 0);
36
- const fixed = setting.useOriginSurcharge ? new decimal_js.default(0) : toDecimal((_ref4 = (_ref5 = (_setting$surcharge_fi = setting.surcharge_fixed) !== null && _setting$surcharge_fi !== void 0 ? _setting$surcharge_fi : setting.surMoney) !== null && _ref5 !== void 0 ? _ref5 : setting.constant_money) !== null && _ref4 !== void 0 ? _ref4 : 0);
37
- /** 设备卡片展示的总手续费与最终扣款额,只用于选择前的预览。 */
38
- const surcharge = amount.mul(rate.div(100)).add(fixed);
24
+ /** 设备预览与选择 Reader 后的实际支付报价必须使用同一套金额规则。 */
25
+ const quote = require_amount.buildPaymentAmountQuote(options === null || options === void 0 ? void 0 : options.amount, options === null || options === void 0 ? void 0 : options.surcharge, reader);
39
26
  return {
40
- totalUnit: amount.add(surcharge).toFixed(2, decimal_js.default.ROUND_HALF_UP),
41
- surRate: rate.toString(),
42
- surMoney: fixed.toFixed(2, decimal_js.default.ROUND_HALF_UP),
43
- surcharge: surcharge.toFixed(2, decimal_js.default.ROUND_HALF_UP)
27
+ totalUnit: quote.total,
28
+ surRate: quote.surchargeRate,
29
+ surMoney: quote.surchargeFixed,
30
+ surcharge: quote.surchargeTotal
44
31
  };
45
32
  };
46
33
  /** 获取 MX51 pairing id。 */