@pisell/pisellos 2.3.218 → 2.3.220

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 (32) hide show
  1. package/dist/modules/OpenData/types.d.ts +3 -0
  2. package/dist/modules/Order/index.d.ts +1 -1
  3. package/dist/modules/Order/index.js +6 -3
  4. package/dist/modules/Order/types.d.ts +1 -1
  5. package/dist/modules/Order/utils.d.ts +4 -0
  6. package/dist/modules/Order/utils.js +105 -53
  7. package/dist/modules/Product/index.d.ts +1 -1
  8. package/dist/solution/BaseSales/index.d.ts +2 -0
  9. package/dist/solution/BaseSales/index.js +65 -37
  10. package/dist/solution/BaseSales/types.d.ts +2 -0
  11. package/dist/solution/BookingByStep/index.d.ts +1 -1
  12. package/dist/solution/BookingTicket/index.d.ts +16 -0
  13. package/dist/solution/BookingTicket/index.js +679 -332
  14. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +78 -0
  15. package/dist/solution/BookingTicket/utils/redeemArrival.js +175 -0
  16. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  17. package/lib/modules/OpenData/types.d.ts +3 -0
  18. package/lib/modules/Order/index.d.ts +1 -1
  19. package/lib/modules/Order/index.js +4 -1
  20. package/lib/modules/Order/types.d.ts +1 -1
  21. package/lib/modules/Order/utils.d.ts +4 -0
  22. package/lib/modules/Order/utils.js +45 -1
  23. package/lib/modules/Product/index.d.ts +1 -1
  24. package/lib/solution/BaseSales/index.d.ts +2 -0
  25. package/lib/solution/BaseSales/index.js +27 -6
  26. package/lib/solution/BaseSales/types.d.ts +2 -0
  27. package/lib/solution/BookingByStep/index.d.ts +1 -1
  28. package/lib/solution/BookingTicket/index.d.ts +16 -0
  29. package/lib/solution/BookingTicket/index.js +171 -5
  30. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +78 -0
  31. package/lib/solution/BookingTicket/utils/redeemArrival.js +156 -0
  32. package/package.json +1 -1
@@ -0,0 +1,78 @@
1
+ import type LoggerManager from '../../../plugins/app-types/logger';
2
+ import type { OrderTempOrder } from '../../../modules/Order/types';
3
+ export interface ArrivalWindow {
4
+ earlyMinutes: number;
5
+ lateMinutes: number;
6
+ }
7
+ export declare function readArrivalWindow(config?: Record<string, any> | null): ArrivalWindow | undefined;
8
+ type TicketOrder = Pick<OrderTempOrder, 'vouchers' | 'bookings'>;
9
+ export declare function applyRedeemArrival(order: TicketOrder, ids: Set<string>, now: Date, window?: ArrivalWindow, onSkip?: (reason: string) => void): {
10
+ vouchers: any[];
11
+ bookings: any[];
12
+ } | undefined;
13
+ export declare function createArrivalLogger(logger: Pick<LoggerManager, 'addLog'> | undefined, order: OrderTempOrder | null | undefined, voucherIds: Array<string | number>): (stage: string, details?: Record<string, unknown>, failed?: boolean) => void;
14
+ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary: OrderTempOrder['summary']): {
15
+ _os_pos_receipt_auto_print_payment_statuses: never[];
16
+ platform: string;
17
+ payment_status?: string | undefined;
18
+ created_at?: string | undefined;
19
+ request_unique_idempotency_token?: string | undefined;
20
+ form_record_ids?: {
21
+ form_id: string | number;
22
+ form_record_id: string | number;
23
+ }[] | undefined;
24
+ products: import("../../../modules/Order/types").OrderSubmitProduct[];
25
+ notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
26
+ summary?: import("../../../modules/Order/types").OrderSummary | undefined;
27
+ small_ticket_data_flag?: number | undefined;
28
+ holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
29
+ metadata: Record<string, any>;
30
+ note: string;
31
+ order_id: number | null;
32
+ external_sale_number: string;
33
+ order_number: string | null;
34
+ shop_order_number: string | null;
35
+ shop_full_order_number: string | null;
36
+ type: string;
37
+ business_code?: string | undefined;
38
+ sales_channel: string;
39
+ order_sales_channel: string;
40
+ status: string;
41
+ shipping_status: string;
42
+ customer_id: number | null;
43
+ customer_name: string;
44
+ country_calling_code: string;
45
+ phone: string;
46
+ email: string;
47
+ is_price_include_tax: number;
48
+ tax_title: string;
49
+ tax_country_code: string;
50
+ currency_code: string;
51
+ currency_symbol: string;
52
+ currency_format: string;
53
+ is_deposit: number;
54
+ deposit_amount: string;
55
+ shop_discount: string;
56
+ surcharge_fee: string;
57
+ buzzer?: string | undefined;
58
+ delivery_type?: string | undefined;
59
+ table_number?: Record<string, any> | undefined;
60
+ schedule_date: string;
61
+ bookings: any[];
62
+ payments: any[];
63
+ refunds?: any[] | undefined;
64
+ surcharges: any[];
65
+ relation_forms: any[];
66
+ contacts: any[];
67
+ contacts_info: Record<string, any> | null;
68
+ holder: Record<string, any> | null;
69
+ order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
70
+ };
71
+ export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
72
+ schedule_event_id: any;
73
+ previous_start: any;
74
+ previous_end: any;
75
+ start: any;
76
+ end: any;
77
+ }[];
78
+ export {};
@@ -0,0 +1,175 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["vouchers"];
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
8
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
9
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
15
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
+ import dayjs from 'dayjs';
18
+ import { OS_POS_RECEIPT_AUTO_PRINT_PAYMENT_STATUSES_FIELD } from "../../../utils/pos-receipt-auto-print";
19
+ import { buildSubmitPayload, redeemEventKey } from "../../../modules/Order/utils";
20
+ export function readArrivalWindow(config) {
21
+ var enabled = config === null || config === void 0 ? void 0 : config['fulfillment.enable_adjust_session_on_arrival'];
22
+ if (enabled !== true && enabled !== 1 && enabled !== '1') return;
23
+ var minutes = function minutes(value) {
24
+ var number = Number(value);
25
+ return Number.isFinite(number) ? Math.max(0, Math.floor(number)) : 0;
26
+ };
27
+ var earlyMinutes = minutes(config === null || config === void 0 ? void 0 : config['fulfillment.max_earlier_shift_minutes']);
28
+ var lateMinutes = minutes(config === null || config === void 0 ? void 0 : config['fulfillment.max_later_shift_minutes']);
29
+ // 两个方向都没有可调整的分钟数时,核销和打印沿用关闭开关时的流程。
30
+ if (earlyMinutes === 0 && lateMinutes === 0) return;
31
+ return {
32
+ earlyMinutes: earlyMinutes,
33
+ lateMinutes: lateMinutes
34
+ };
35
+ }
36
+ function shiftedSession(booking, now, window) {
37
+ if (!window || !booking.start_date || !booking.start_time || !booking.end_time) return null;
38
+ var start = dayjs("".concat(booking.start_date, " ").concat(booking.start_time));
39
+ var end = dayjs("".concat(booking.end_date || booking.start_date, " ").concat(booking.end_time));
40
+ if (!start.isValid() || !end.isValid() || end.isBefore(start)) return null;
41
+ var delta = dayjs(now).startOf('minute').diff(start, 'minute');
42
+ var minutes = Math.max(-window.earlyMinutes, Math.min(window.lateMinutes, delta));
43
+ if (!Number.isFinite(minutes)) return null;
44
+ if (!minutes) return;
45
+ var shiftedStart = start.add(minutes, 'minute');
46
+ var shiftedEnd = end.add(minutes, 'minute');
47
+ return {
48
+ start_date: shiftedStart.format('YYYY-MM-DD'),
49
+ start_time: shiftedStart.format(booking.start_time.length > 5 ? 'HH:mm:ss' : 'HH:mm'),
50
+ end_date: shiftedEnd.format('YYYY-MM-DD'),
51
+ end_time: shiftedEnd.format(booking.end_time.length > 5 ? 'HH:mm:ss' : 'HH:mm')
52
+ };
53
+ }
54
+ export function applyRedeemArrival(order, ids, now, window, onSkip) {
55
+ var _order$bookings, _order$vouchers;
56
+ if (!window || !((_order$bookings = order.bookings) !== null && _order$bookings !== void 0 && _order$bookings.length) || !((_order$vouchers = order.vouchers) !== null && _order$vouchers !== void 0 && _order$vouchers.length)) {
57
+ onSkip === null || onSkip === void 0 || onSkip('missing_window_or_booking_data');
58
+ return;
59
+ }
60
+ var selected = new Set();
61
+ var _iterator = _createForOfIteratorHelper(order.vouchers),
62
+ _step;
63
+ try {
64
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
65
+ var voucher = _step.value;
66
+ var event = redeemEventKey(voucher === null || voucher === void 0 ? void 0 : voucher.schedule_event_id);
67
+ if (event && ids.has(String(voucher.voucher_id))) selected.add(event);
68
+ }
69
+ } catch (err) {
70
+ _iterator.e(err);
71
+ } finally {
72
+ _iterator.f();
73
+ }
74
+ var alreadyMarked = false;
75
+ var invalidSession = false;
76
+ var changes = new Map();
77
+ var bookings = order.bookings.map(function (booking) {
78
+ var _booking$metadata;
79
+ var event = redeemEventKey(booking === null || booking === void 0 ? void 0 : booking.schedule_event_id);
80
+ if (!event || !selected.has(event) || String(booking.parent_id) === '0') return booking;
81
+ if (Number((_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.is_change_by_redeem) === 1) {
82
+ alreadyMarked = true;
83
+ return booking;
84
+ }
85
+ var shift = shiftedSession(booking, now, window);
86
+ if (shift === null) {
87
+ invalidSession = true;
88
+ return booking;
89
+ }
90
+ // 准点核销的偏移量为零,也要打标,避免下一张票改变这个时段。
91
+ changes.set(event, shift);
92
+ return _objectSpread(_objectSpread(_objectSpread({}, booking), shift), {}, {
93
+ metadata: _objectSpread(_objectSpread({}, booking.metadata), {}, {
94
+ is_change_by_redeem: 1
95
+ })
96
+ });
97
+ });
98
+ if (!changes.size) {
99
+ onSkip === null || onSkip === void 0 || onSkip(invalidSession ? 'invalid_booking_time' : alreadyMarked ? 'already_marked' : 'no_linked_booking');
100
+ return;
101
+ }
102
+ var vouchers = order.vouchers.map(function (voucher) {
103
+ var event = redeemEventKey(voucher === null || voucher === void 0 ? void 0 : voucher.schedule_event_id);
104
+ var shift = event && changes.get(event);
105
+ if (!shift) return voucher;
106
+ return _objectSpread(_objectSpread({}, voucher), {}, {
107
+ start_date: shift.start_date,
108
+ expire_date: shift.end_date,
109
+ start_time: shift.start_time,
110
+ end_time: shift.end_time
111
+ });
112
+ });
113
+ return {
114
+ vouchers: vouchers,
115
+ bookings: bookings
116
+ };
117
+ }
118
+ export function createArrivalLogger(logger, order, voucherIds) {
119
+ return function (stage) {
120
+ var details = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
121
+ var failed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
122
+ try {
123
+ logger === null || logger === void 0 || logger.addLog({
124
+ type: failed ? 'error' : 'info',
125
+ title: '[BookingTicket] updateTicketArrival',
126
+ metadata: _objectSpread({
127
+ stage: stage,
128
+ order_id: order === null || order === void 0 ? void 0 : order.order_id,
129
+ external_sale_number: order === null || order === void 0 ? void 0 : order.external_sale_number,
130
+ voucher_ids: voucherIds
131
+ }, details)
132
+ });
133
+ } catch (_unused) {
134
+ // 日志不可用时,核销和预约调时仍按原流程执行。
135
+ }
136
+ };
137
+ }
138
+ export function buildArrivalCheckoutQuery(order, summary) {
139
+ var _buildSubmitPayload = buildSubmitPayload({
140
+ tempOrder: order,
141
+ platform: order.platform,
142
+ businessCode: order.business_code,
143
+ type: order.type,
144
+ summary: summary
145
+ }),
146
+ _localVouchers = _buildSubmitPayload.vouchers,
147
+ payload = _objectWithoutProperties(_buildSubmitPayload, _excluded);
148
+ return _objectSpread(_objectSpread({}, payload), {}, _defineProperty({}, OS_POS_RECEIPT_AUTO_PRINT_PAYMENT_STATUSES_FIELD, []));
149
+ }
150
+ export function describeChangedBookings(before, after) {
151
+ var changes = [];
152
+ var _iterator2 = _createForOfIteratorHelper(after.entries()),
153
+ _step2;
154
+ try {
155
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
156
+ var _step2$value = _slicedToArray(_step2.value, 2),
157
+ index = _step2$value[0],
158
+ booking = _step2$value[1];
159
+ var previous = before[index];
160
+ if (booking === previous) continue;
161
+ changes.push({
162
+ schedule_event_id: booking.schedule_event_id,
163
+ previous_start: previous.start_time,
164
+ previous_end: previous.end_time,
165
+ start: booking.start_time,
166
+ end: booking.end_time
167
+ });
168
+ }
169
+ } catch (err) {
170
+ _iterator2.e(err);
171
+ } finally {
172
+ _iterator2.f();
173
+ }
174
+ return changes;
175
+ }
@@ -1 +1,46 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _examples.ITEM_REWARD_STRATEGY;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "PromotionAdapter", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _adapter.PromotionAdapter;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "PromotionEvaluator", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _evaluator.PromotionEvaluator;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "default", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _adapter.default;
40
+ }
41
+ });
42
+ var _evaluator = require("./evaluator");
43
+ var _adapter = _interopRequireWildcard(require("./adapter"));
44
+ var _examples = require("./examples");
45
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -106,6 +106,9 @@ export interface OpenDataConfig {
106
106
  'sale.short_number_prefix'?: string | null;
107
107
  'sale.sale_number_prefix'?: string | null;
108
108
  'sale.enabled_item_rules'?: number[];
109
+ 'fulfillment.enable_adjust_session_on_arrival'?: boolean | 0 | 1;
110
+ 'fulfillment.max_earlier_shift_minutes'?: number | string;
111
+ 'fulfillment.max_later_shift_minutes'?: number | string;
109
112
  'fulfillment.enable_pickup'?: boolean;
110
113
  'fulfillment.handover_mode'?: string[];
111
114
  'fulfillment.takeaway_fees_rules'?: number[];
@@ -642,7 +642,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
642
642
  generateIdempotencyToken(): string;
643
643
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
644
644
  createOrder(params: CommitOrderParams['query']): {
645
- type: "appointment_booking" | "virtual";
645
+ type: "virtual" | "appointment_booking";
646
646
  platform: string;
647
647
  sales_channel: string;
648
648
  order_sales_channel: string;
@@ -5001,6 +5001,9 @@ class OrderModule extends _BaseModule.BaseModule {
5001
5001
  metadata: {
5002
5002
  ...(targetBooking.metadata || {}),
5003
5003
  ...(updates.metadata || {}),
5004
+ ...(Number(targetBooking.metadata?.is_change_by_redeem) === 1 ? {
5005
+ is_change_by_redeem: 1
5006
+ } : {}),
5004
5007
  unique_identification_number: bookingUid
5005
5008
  }
5006
5009
  };
@@ -6217,7 +6220,7 @@ class OrderModule extends _BaseModule.BaseModule {
6217
6220
  if (options?.ensureIdentity !== false) {
6218
6221
  this.ensureExternalSaleNumber(nextTempOrder);
6219
6222
  }
6220
- nextTempOrder.vouchers = raw.vouchers || [];
6223
+ nextTempOrder.vouchers = (0, _utils.restoreRedeemVoucherTimes)(nextTempOrder, raw.vouchers || []);
6221
6224
  return nextTempOrder;
6222
6225
  }
6223
6226
  isSyntheticDraftOrderIdForRuntime(record, options) {
@@ -668,7 +668,7 @@ export interface SubmitSalesOrderParams {
668
668
  holder_relations?: OrderHolderRelation[];
669
669
  bookings: OrderSubmitBooking[];
670
670
  payments: any[];
671
- vouchers: any[];
671
+ vouchers?: any[];
672
672
  surcharges?: any[];
673
673
  relation_forms: any[];
674
674
  form_record_ids?: OrderSubmitFormRecord[];
@@ -210,6 +210,10 @@ export declare const getAllDiscountList: (cartItem: CartItem) => any;
210
210
  export { createUuidV4 };
211
211
  export declare function isTempOrder(data: any): data is OrderTempOrder;
212
212
  export declare function formatDateTime(date: Date): string;
213
+ /** 旧票券可能没有事件 ID;缺失或占位值不能用于关联预约。 */
214
+ export declare function redeemEventKey(value: unknown): string | undefined;
215
+ /** checkout 提交子预约的标记;重新加载订单时,从已调时的子预约恢复关联票券的票面时段。 */
216
+ export declare function restoreRedeemVoucherTimes(order: Pick<OrderTempOrder, 'bookings'>, vouchers: any[]): any[];
213
217
  export declare function normalizeBookingIsAll(booking: Record<string, any>): 0 | 1;
214
218
  export declare function normalizeBookingSubType(booking: Record<string, any>): string;
215
219
  export declare function normalizeSubmitBooking<T extends {
@@ -79,6 +79,7 @@ exports.normalizeSubmitBooking = normalizeSubmitBooking;
79
79
  exports.normalizeSubmitCollectPaxValue = normalizeSubmitCollectPaxValue;
80
80
  exports.normalizeVirtualCurrencySnapshotItem = normalizeVirtualCurrencySnapshotItem;
81
81
  exports.productRequiresFormSubject = productRequiresFormSubject;
82
+ exports.redeemEventKey = redeemEventKey;
82
83
  exports.resolveEffectivePerUnitDiscount = resolveEffectivePerUnitDiscount;
83
84
  exports.resolveIsFormSubject = resolveIsFormSubject;
84
85
  Object.defineProperty(exports, "resolveManualDiscountMessage", {
@@ -110,6 +111,7 @@ Object.defineProperty(exports, "resolveSafeProductNum", {
110
111
  exports.resolveSubmitCollectPax = resolveSubmitCollectPax;
111
112
  exports.resolveSubmitOrderType = resolveSubmitOrderType;
112
113
  exports.resolveTableOccupancyDuration = resolveTableOccupancyDuration;
114
+ exports.restoreRedeemVoucherTimes = restoreRedeemVoucherTimes;
113
115
  Object.defineProperty(exports, "shouldBuildManualProductDiscount", {
114
116
  enumerable: true,
115
117
  get: function () {
@@ -1372,7 +1374,49 @@ function normalizeSubmitProduct(product, formatOptions = {}) {
1372
1374
  payment_price: formatOptions.virtualSettlementMode ? virtualPrice : submitProduct.payment_price ?? submitProduct.selling_price
1373
1375
  };
1374
1376
  }
1375
- const SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type', 'holder', 'is_fulfillment_timing', 'fulfillment_timing'];
1377
+
1378
+ /** 旧票券可能没有事件 ID;缺失或占位值不能用于关联预约。 */
1379
+ function redeemEventKey(value) {
1380
+ if (typeof value !== 'number' && typeof value !== 'string') return;
1381
+ const key = String(value).trim();
1382
+ return /^[1-9]\d*$/.test(key) ? key : undefined;
1383
+ }
1384
+
1385
+ /** checkout 提交子预约的标记;重新加载订单时,从已调时的子预约恢复关联票券的票面时段。 */
1386
+ function restoreRedeemVoucherTimes(order, vouchers) {
1387
+ if (!Array.isArray(vouchers) || !vouchers.length) return vouchers;
1388
+ const markedBookings = new Map();
1389
+ for (const booking of order.bookings || []) {
1390
+ const event = redeemEventKey(booking?.schedule_event_id);
1391
+ if (event && Number(booking.metadata?.is_change_by_redeem) === 1) markedBookings.set(event, booking);
1392
+ }
1393
+ if (!markedBookings.size) return vouchers;
1394
+ let restored = vouchers;
1395
+ vouchers.forEach((voucher, index) => {
1396
+ const event = redeemEventKey(voucher?.schedule_event_id);
1397
+ const booking = event && markedBookings.get(event);
1398
+ if (!booking || !booking.start_time || !booking.end_time) return;
1399
+ const times = {
1400
+ start_time: booking.start_time,
1401
+ end_time: booking.end_time,
1402
+ ...(booking.start_date && {
1403
+ start_date: booking.start_date
1404
+ }),
1405
+ ...(booking.end_date && {
1406
+ expire_date: booking.end_date
1407
+ })
1408
+ };
1409
+ const timeChanged = Object.entries(times).some(([key, value]) => voucher[key] !== value);
1410
+ if (!timeChanged) return;
1411
+ if (restored === vouchers) restored = vouchers.slice();
1412
+ restored[index] = {
1413
+ ...voucher,
1414
+ ...times
1415
+ };
1416
+ });
1417
+ return restored;
1418
+ }
1419
+ const SUBMIT_BOOKING_METADATA_WHITELIST = ['is_change_by_redeem', 'unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type', 'holder', 'is_fulfillment_timing', 'fulfillment_timing'];
1376
1420
  function normalizeBookingIsAll(booking) {
1377
1421
  return booking.is_all === true || booking.is_all === 1 || booking.is_all === '1' || booking.is_all === 'true' ? 1 : 0;
1378
1422
  }
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "normal" | "session" | "duration";
53
53
  }
@@ -55,6 +55,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
55
55
  protected store: BaseSalesState;
56
56
  protected otherParams: Record<string, any>;
57
57
  getInventory(): InventoryController | undefined;
58
+ /** Retail and standard POS opt in per sales instance; other hosts retain their member flow. */
59
+ isMemberCartConsistencyEnabled(): boolean;
58
60
  prepareCheckout(signal?: AbortSignal): Promise<CheckoutRuntimeSnapshot | undefined>;
59
61
  protected cacheId: string | undefined;
60
62
  /**
@@ -23,6 +23,7 @@ Object.keys(_types).forEach(function (key) {
23
23
  });
24
24
  });
25
25
  var _Order = require("../../modules/Order");
26
+ var _discountProductLineIdentity = require("../../modules/Order/utils/discountProductLineIdentity");
26
27
  var _pickupTiming = require("../../modules/Order/pickupTiming");
27
28
  var _pickupTiming2 = require("./pickupTiming");
28
29
  var _fulfillmentItemRules = require("./fulfillmentItemRules");
@@ -156,6 +157,14 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
156
157
  return previous && isBaseSalesManualProductDiscountProduct(previous) ? previous : product;
157
158
  });
158
159
  }
160
+
161
+ /** Rules may split a coupon quantity into rows that still share the original UID. */
162
+ function applyDiscountProductLines(tempOrder, products, discounts, enableMemberCartConsistency) {
163
+ tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, products);
164
+ if (!enableMemberCartConsistency) return;
165
+ (0, _discountProductLineIdentity.ensureUniqueProductLineUids)(tempOrder, discounts);
166
+ (0, _discountProductLineIdentity.consolidateDiscountFreeProductLines)(tempOrder);
167
+ }
159
168
  function isBaseSalesHistoricalDiscountEntry(discount) {
160
169
  return Boolean(discount?.isEditMode || discount?.isDisabled || discount?.order_discount_id != null);
161
170
  }
@@ -517,6 +526,11 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
517
526
  getInventory() {
518
527
  return this.otherParams.inventory;
519
528
  }
529
+
530
+ /** Retail and standard POS opt in per sales instance; other hosts retain their member flow. */
531
+ isMemberCartConsistencyEnabled() {
532
+ return this.otherParams.enableMemberCartConsistency === true;
533
+ }
520
534
  async prepareCheckout(signal) {
521
535
  const inventory = this.getInventory();
522
536
  const hooks = this.otherParams.checkoutHooks;
@@ -2322,7 +2336,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2322
2336
  }
2323
2337
  async loadDiscountConfig(params) {
2324
2338
  if (!this.store.order) throw new Error('order 模块未初始化');
2325
- const tempOrder = this.store.order.ensureTempOrder();
2339
+ let tempOrder = this.store.order.ensureTempOrder();
2326
2340
  const orderStore = this.store.order.store || {};
2327
2341
  const discountModule = orderStore.discount;
2328
2342
  const rulesModule = orderStore.rules;
@@ -2337,7 +2351,11 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2337
2351
  let requestEpoch = this.store.order.getCustomerWalletPrepareConfigEpoch?.();
2338
2352
  const isCurrentRequest = () => {
2339
2353
  const currentTempOrder = this.store.order?.getTempOrder?.();
2340
- return Boolean(currentTempOrder && (requestEpoch === undefined || this.store.order?.getCustomerWalletPrepareConfigEpoch?.() === requestEpoch) && this.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && this.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
2354
+ const current = Boolean(currentTempOrder && (requestEpoch === undefined || this.store.order?.getCustomerWalletPrepareConfigEpoch?.() === requestEpoch) && this.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && this.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
2355
+ // Cart edits can replace the object while member configuration is pending.
2356
+ // Keep the logical-order guard, but apply coupons to its latest rows.
2357
+ if (current && this.isMemberCartConsistencyEnabled()) tempOrder = currentTempOrder;
2358
+ return current;
2341
2359
  };
2342
2360
  const getCurrentResult = () => {
2343
2361
  const currentTempOrder = this.store.order?.getTempOrder?.();
@@ -2466,7 +2484,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2466
2484
  discountList: nextDiscountList
2467
2485
  };
2468
2486
  if (result.productList) {
2469
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2487
+ applyDiscountProductLines(tempOrder, result.productList, result.discountList || nextDiscountList, this.isMemberCartConsistencyEnabled());
2470
2488
  }
2471
2489
  for (const product of tempOrder.products || []) {
2472
2490
  const productUid = product.metadata?.unique_identification_number;
@@ -2559,7 +2577,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2559
2577
  preserveEntitlementSelection: false
2560
2578
  }) || result;
2561
2579
  if (result.productList) {
2562
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2580
+ applyDiscountProductLines(tempOrder, result.productList, result.discountList || nextDiscountList, this.isMemberCartConsistencyEnabled());
2563
2581
  }
2564
2582
  if (result.discountList) {
2565
2583
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
@@ -2686,7 +2704,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2686
2704
  discountList: updated
2687
2705
  };
2688
2706
  if (result?.productList) {
2689
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2707
+ applyDiscountProductLines(tempOrder, result.productList, result.discountList || updated, this.isMemberCartConsistencyEnabled());
2690
2708
  }
2691
2709
  if (result?.discountList) {
2692
2710
  nextDiscountList = result.discountList;
@@ -2774,7 +2792,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2774
2792
  const orderStore = this.store.order.store || {};
2775
2793
  const discountModule = orderStore.discount;
2776
2794
  if (result.productList) {
2777
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2795
+ applyDiscountProductLines(tempOrder, result.productList, result.discountList || this.getDiscountList(), this.isMemberCartConsistencyEnabled());
2778
2796
  }
2779
2797
  if (result.discountList) {
2780
2798
  _Order.OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
@@ -4416,6 +4434,9 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
4416
4434
  const currentOrderCustomerId = this.getCurrentOrderCustomerId();
4417
4435
  const resolvedChannels = paramsList.map(params => this.getPriceQueryChannel(params.channel));
4418
4436
  const authoritativeProducts = await this.resolveProductBookingPriceGroups(paramsList, currentOrderCustomerId);
4437
+ if (paramsList.some((params, index) => params.requireAuthoritativePrice && !authoritativeProducts[index])) {
4438
+ throw new Error('The current customer product price is unavailable. Please retry before paying.');
4439
+ }
4419
4440
  const plans = paramsList.map((params, index) => {
4420
4441
  if (!isPos) return null;
4421
4442
  const product = authoritativeProducts[index];
@@ -305,6 +305,8 @@ export interface BaseSalesQuotationDurationConfig {
305
305
  }
306
306
  export interface BaseSalesCalculateProductBookingPriceParams {
307
307
  product: Record<string, any>;
308
+ /** Fail closed when the current customer price cannot be resolved; no old-line fallback. */
309
+ requireAuthoritativePrice?: boolean;
308
310
  booking?: {
309
311
  start_date?: string;
310
312
  start_time?: string;
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 1 | 2 | 3 | 5 | 6 | 4;
345
+ weekNum: 0 | 1 | 2 | 6 | 4 | 5 | 3;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -32,6 +32,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
32
32
  private orderCustomerDiscountRefreshCustomerId;
33
33
  private orderCustomerDiscountRefreshTarget;
34
34
  private orderCustomerPromotionRefreshInFlight;
35
+ private orderCustomerRefreshTask;
36
+ private orderCustomerRefreshRevision;
35
37
  private orderCustomerContactRequest;
36
38
  private readonly customerResolveRequests;
37
39
  protected loadOpenDataInFlight: Promise<OpenDataConfig> | null;
@@ -283,6 +285,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
283
285
  setOrderCustomer(customer: ICustomer | null, options?: {
284
286
  source?: OrderCustomerChangePayload['source'];
285
287
  }): void;
288
+ /** Shared by customer changes and an explicit retry; keep the selected customer/cart intact. */
289
+ private refreshMemberCartContext;
290
+ retryOrderCustomerRefresh(): Promise<void>;
286
291
  private resetOrderCustomerContactInfo;
287
292
  /** Explicit edits, including clearing the contact, must win over a pending default. */
288
293
  updateTempOrderContactsInfo(contact: Record<string, any> | null): Record<string, any> | null;
@@ -321,6 +326,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
321
326
  private buildOrderCustomerPayload;
322
327
  protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
323
328
  protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
329
+ /** Wait before reading cart rows: member coupons can split or consolidate them. */
330
+ waitForOrderCustomerRefresh(): Promise<void>;
324
331
  protected prepareProductPriceQueryContext(customerId?: number | string): Promise<void>;
325
332
  protected preferAuthoritativeProductQueryPrice(): boolean;
326
333
  /**
@@ -600,11 +607,20 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
600
607
  private getDeviceTaskPlugin;
601
608
  handlePrintWristband(params: {
602
609
  voucher_ids: number[];
610
+ voucher_times?: Record<string, {
611
+ start_time: string;
612
+ end_time: string;
613
+ }>;
603
614
  }): Promise<void>;
615
+ private redeemStatusWrite?;
616
+ private arrivalQueue;
617
+ private getRedeemArrivalWindow;
618
+ isRedeemArrivalEnabled(): boolean;
604
619
  handleRedeem(params: {
605
620
  voucher_ids: number[];
606
621
  is_checkin: boolean;
607
622
  }): Promise<any>;
623
+ updateTicketArrival(voucherIds: Array<string | number>): Promise<any>;
608
624
  /**
609
625
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
610
626
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。