@pisell/pisellos 2.3.128 → 2.3.130

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 (160) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +3 -1
  3. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  4. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
  7. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
  8. package/dist/modules/Customer/index.js +6 -3
  9. package/dist/modules/Customer/types.d.ts +2 -0
  10. package/dist/modules/Discount/availability.d.ts +7 -0
  11. package/dist/modules/Discount/availability.js +49 -0
  12. package/dist/modules/Discount/entitlementPass.d.ts +34 -0
  13. package/dist/modules/Discount/entitlementPass.js +147 -0
  14. package/dist/modules/Discount/index.d.ts +2 -2
  15. package/dist/modules/Discount/index.js +37 -151
  16. package/dist/modules/Discount/types.d.ts +36 -5
  17. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  18. package/dist/modules/FulfillmentTiming/index.js +407 -0
  19. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  20. package/dist/modules/FulfillmentTiming/types.js +1 -0
  21. package/dist/modules/OpenData/types.d.ts +6 -0
  22. package/dist/modules/Order/index.d.ts +12 -0
  23. package/dist/modules/Order/index.js +498 -247
  24. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  25. package/dist/modules/Order/pickupTiming.js +53 -0
  26. package/dist/modules/Order/types.d.ts +5 -1
  27. package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
  28. package/dist/modules/Order/utils.d.ts +1 -1
  29. package/dist/modules/Order/utils.js +117 -66
  30. package/dist/modules/Payment/index.js +9 -10
  31. package/dist/modules/Payment/types.d.ts +21 -1
  32. package/dist/modules/Payment/types.js +2 -0
  33. package/dist/modules/Payment/walletpass.d.ts +1 -1
  34. package/dist/modules/Payment/walletpass.js +80 -47
  35. package/dist/modules/Rules/index.d.ts +2 -2
  36. package/dist/modules/Rules/index.js +480 -186
  37. package/dist/modules/Rules/types.d.ts +4 -0
  38. package/dist/modules/Schedule/index.d.ts +8 -0
  39. package/dist/modules/Schedule/index.js +141 -39
  40. package/dist/modules/index.d.ts +1 -0
  41. package/dist/modules/index.js +1 -0
  42. package/dist/plugins/request.d.ts +7 -0
  43. package/dist/server/modules/order/types.d.ts +2 -0
  44. package/dist/server/utils/small-ticket.d.ts +1 -85
  45. package/dist/server/utils/small-ticket.js +2 -2542
  46. package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
  47. package/dist/shared/payment/loadPaymentMethods.js +66 -0
  48. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
  49. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +142 -0
  50. package/dist/shared/receipt/small-ticket.d.ts +85 -0
  51. package/dist/shared/receipt/small-ticket.js +2576 -0
  52. package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  53. package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
  54. package/dist/solution/BaseSales/index.d.ts +25 -0
  55. package/dist/solution/BaseSales/index.js +1226 -1040
  56. package/dist/solution/BaseSales/pickupTiming.d.ts +43 -0
  57. package/dist/solution/BaseSales/pickupTiming.js +589 -0
  58. package/dist/solution/BaseSales/types.d.ts +2 -2
  59. package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
  60. package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  61. package/dist/solution/BookingByStep/index.d.ts +1 -1
  62. package/dist/solution/BookingTicket/index.d.ts +4 -5
  63. package/dist/solution/BookingTicket/index.js +60 -63
  64. package/dist/solution/BookingTicket/types.d.ts +5 -1
  65. package/dist/solution/BookingTicket/utils/cartView.js +3 -1
  66. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  67. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
  68. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  69. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  70. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
  71. package/dist/solution/OrderInvoicePreview/index.d.ts +56 -0
  72. package/dist/solution/OrderInvoicePreview/index.js +269 -0
  73. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  74. package/dist/solution/ShopDiscount/index.js +99 -42
  75. package/dist/solution/ShopDiscount/utils.d.ts +4 -2
  76. package/dist/solution/ShopDiscount/utils.js +43 -23
  77. package/dist/solution/UnifiedBookingSales/index.d.ts +13 -4
  78. package/dist/solution/UnifiedBookingSales/index.js +874 -709
  79. package/dist/solution/index.d.ts +1 -0
  80. package/dist/solution/index.js +2 -1
  81. package/lib/index.d.ts +2 -0
  82. package/lib/index.js +21 -1
  83. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  84. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
  85. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
  86. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
  87. package/lib/modules/Customer/index.js +5 -1
  88. package/lib/modules/Customer/types.d.ts +2 -0
  89. package/lib/modules/Discount/availability.d.ts +7 -0
  90. package/lib/modules/Discount/availability.js +43 -0
  91. package/lib/modules/Discount/entitlementPass.d.ts +34 -0
  92. package/lib/modules/Discount/entitlementPass.js +141 -0
  93. package/lib/modules/Discount/index.d.ts +2 -2
  94. package/lib/modules/Discount/index.js +23 -129
  95. package/lib/modules/Discount/types.d.ts +36 -5
  96. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  97. package/lib/modules/FulfillmentTiming/index.js +359 -0
  98. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  99. package/lib/modules/FulfillmentTiming/types.js +5 -0
  100. package/lib/modules/OpenData/types.d.ts +6 -0
  101. package/lib/modules/Order/index.d.ts +12 -0
  102. package/lib/modules/Order/index.js +252 -48
  103. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  104. package/lib/modules/Order/pickupTiming.js +61 -0
  105. package/lib/modules/Order/types.d.ts +5 -1
  106. package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
  107. package/lib/modules/Order/utils.d.ts +1 -1
  108. package/lib/modules/Order/utils.js +51 -7
  109. package/lib/modules/Payment/index.js +3 -4
  110. package/lib/modules/Payment/types.d.ts +21 -1
  111. package/lib/modules/Payment/types.js +1 -0
  112. package/lib/modules/Payment/walletpass.d.ts +1 -1
  113. package/lib/modules/Payment/walletpass.js +29 -9
  114. package/lib/modules/Rules/index.d.ts +2 -2
  115. package/lib/modules/Rules/index.js +357 -110
  116. package/lib/modules/Rules/types.d.ts +4 -0
  117. package/lib/modules/Schedule/index.d.ts +8 -0
  118. package/lib/modules/Schedule/index.js +68 -12
  119. package/lib/modules/index.d.ts +1 -0
  120. package/lib/modules/index.js +11 -0
  121. package/lib/plugins/request.d.ts +7 -0
  122. package/lib/server/modules/order/types.d.ts +2 -0
  123. package/lib/server/utils/small-ticket.d.ts +1 -85
  124. package/lib/server/utils/small-ticket.js +9 -2305
  125. package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
  126. package/lib/shared/payment/loadPaymentMethods.js +40 -0
  127. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
  128. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +86 -0
  129. package/lib/shared/receipt/small-ticket.d.ts +85 -0
  130. package/lib/shared/receipt/small-ticket.js +2342 -0
  131. package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  132. package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
  133. package/lib/solution/BaseSales/index.d.ts +25 -0
  134. package/lib/solution/BaseSales/index.js +102 -3
  135. package/lib/solution/BaseSales/pickupTiming.d.ts +43 -0
  136. package/lib/solution/BaseSales/pickupTiming.js +269 -0
  137. package/lib/solution/BaseSales/types.d.ts +2 -2
  138. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
  139. package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  140. package/lib/solution/BookingByStep/index.d.ts +1 -1
  141. package/lib/solution/BookingTicket/index.d.ts +4 -5
  142. package/lib/solution/BookingTicket/index.js +36 -33
  143. package/lib/solution/BookingTicket/types.d.ts +5 -1
  144. package/lib/solution/BookingTicket/utils/cartView.js +3 -1
  145. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  146. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
  147. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  148. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  149. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
  150. package/lib/solution/OrderInvoicePreview/index.d.ts +56 -0
  151. package/lib/solution/OrderInvoicePreview/index.js +192 -0
  152. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  153. package/lib/solution/ShopDiscount/index.js +55 -9
  154. package/lib/solution/ShopDiscount/utils.d.ts +4 -2
  155. package/lib/solution/ShopDiscount/utils.js +42 -25
  156. package/lib/solution/UnifiedBookingSales/index.d.ts +13 -4
  157. package/lib/solution/UnifiedBookingSales/index.js +132 -48
  158. package/lib/solution/index.d.ts +1 -0
  159. package/lib/solution/index.js +11 -0
  160. package/package.json +1 -1
@@ -0,0 +1,46 @@
1
+ export type PickupTimingSelectionMode = 'asap' | 'scheduled';
2
+ export type PickupTimingSource = 'asap' | 'schedule' | 'pos_manual';
3
+ export interface PickupTimingBookingInput {
4
+ mode: PickupTimingSelectionMode;
5
+ source: PickupTimingSource;
6
+ /** Store-local calendar date and minute; the caller validates availability. */
7
+ date: string;
8
+ time: string;
9
+ /** Absolute timestamp disambiguates a repeated local minute at a DST change. */
10
+ instant?: string;
11
+ timezone?: string;
12
+ frozen?: boolean;
13
+ }
14
+ export interface PickupTimingBookingMetadata {
15
+ unique_identification_number: string;
16
+ is_fulfillment_timing: true;
17
+ fulfillment_timing: {
18
+ method: 'pick_up';
19
+ mode: PickupTimingSelectionMode;
20
+ source: PickupTimingSource;
21
+ instant?: string;
22
+ timezone?: string;
23
+ frozen?: boolean;
24
+ };
25
+ [key: string]: any;
26
+ }
27
+ export interface PickupTimingBooking {
28
+ schedule_id: number | string;
29
+ start_date: string;
30
+ end_date: string;
31
+ start_time: string;
32
+ end_time: string;
33
+ select_date: string;
34
+ duration: 0;
35
+ is_all: 0;
36
+ sub_type: 'minutes';
37
+ like_status: string;
38
+ resources: [];
39
+ metadata: PickupTimingBookingMetadata;
40
+ schedule_event_id?: number | string;
41
+ [key: string]: any;
42
+ }
43
+ /** The explicit marker is the only authority; unlinked ordinary bookings remain ordinary. */
44
+ export declare function isFulfillmentTimingBooking(booking: unknown): boolean;
45
+ /** Update an independent pickup appointment without changing its persisted row identity. */
46
+ export declare function buildPickupTimingBooking(input: PickupTimingBookingInput, existing?: Record<string, any> | null): PickupTimingBooking;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildPickupTimingBooking = buildPickupTimingBooking;
7
+ exports.isFulfillmentTimingBooking = isFulfillmentTimingBooking;
8
+ var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
9
+ /** The explicit marker is the only authority; unlinked ordinary bookings remain ordinary. */
10
+ function isFulfillmentTimingBooking(booking) {
11
+ return booking?.metadata?.is_fulfillment_timing === true;
12
+ }
13
+
14
+ /** Update an independent pickup appointment without changing its persisted row identity. */
15
+ function buildPickupTimingBooking(input, existing) {
16
+ const booking = {
17
+ ...(existing || {})
18
+ };
19
+ const metadata = {
20
+ ...(booking.metadata || {})
21
+ };
22
+ // A fulfillment appointment never becomes a product/resource/holder purchase line.
23
+ for (const key of ['product_uid', 'product', 'holder', 'holder_id', 'collect_pax', 'capacity']) {
24
+ delete booking[key];
25
+ delete metadata[key];
26
+ }
27
+ delete metadata.booking_uid;
28
+ return {
29
+ ...booking,
30
+ schedule_id: booking.schedule_id || 0,
31
+ start_date: input.date,
32
+ end_date: input.date,
33
+ start_time: input.time,
34
+ end_time: input.time,
35
+ select_date: input.date,
36
+ duration: 0,
37
+ is_all: 0,
38
+ sub_type: 'minutes',
39
+ like_status: booking.like_status || 'common',
40
+ resources: [],
41
+ metadata: {
42
+ ...metadata,
43
+ unique_identification_number: String(metadata.unique_identification_number || (0, _orderCollectionIdentity.createUuidV4)()),
44
+ is_fulfillment_timing: true,
45
+ fulfillment_timing: {
46
+ method: 'pick_up',
47
+ mode: input.mode,
48
+ source: input.source,
49
+ ...(input.instant !== undefined ? {
50
+ instant: input.instant
51
+ } : {}),
52
+ ...(input.timezone !== undefined ? {
53
+ timezone: input.timezone
54
+ } : {}),
55
+ ...(input.frozen !== undefined ? {
56
+ frozen: input.frozen
57
+ } : {})
58
+ }
59
+ }
60
+ };
61
+ }
@@ -7,9 +7,10 @@ import type { SubmitPayloadEnhancer } from './utils';
7
7
  import type { PaymentItem } from '../Payment/types';
8
8
  import type { ICustomer } from '../AccountList/types';
9
9
  import type { OrderProductDiscountItem } from '../../server/modules/order/types';
10
+ import type { PickupTimingBooking, PickupTimingBookingInput } from './pickupTiming';
10
11
  export type { OrderProductDiscountItem } from '../../server/modules/order/types';
11
12
  export type PickupReferenceMode = 'counter_pickup' | 'table_service';
12
- export type ShopServiceType = 'dine_in' | 'takeaway';
13
+ export type ShopServiceType = 'dine_in' | 'takeaway' | 'pick_up' | 'delivery';
13
14
  export interface ShopServiceData {
14
15
  pickup_reference_mode?: PickupReferenceMode;
15
16
  service_type?: ShopServiceType | '';
@@ -863,6 +864,9 @@ export interface OrderModuleAPI {
863
864
  updateTempOrderCustomer: (customer: UpdateTempOrderCustomerInput) => OrderSnapshot['customer'];
864
865
  updateTempOrderPickupReferenceMode: (mode: PickupReferenceMode) => ShopServiceData;
865
866
  updateTempOrderServiceType: (serviceType: ShopServiceType) => ShopServiceData;
867
+ getPickupTimingBooking: () => PickupTimingBooking | null;
868
+ setPickupTimingBooking: (input: PickupTimingBookingInput) => PickupTimingBooking;
869
+ clearPickupTimingBooking: () => void;
866
870
  updateTempOrderBuzzer: (buzzer: string) => string;
867
871
  updateTempOrderContactsInfo: (contactsInfo: Record<string, any> | null) => Record<string, any> | null;
868
872
  addProductToOrder: (product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions) => Promise<OrderProduct[]>;
@@ -17,6 +17,7 @@ exports.normalizeOrderCollections = normalizeOrderCollections;
17
17
  exports.repairDuplicateProductLineIdentities = repairDuplicateProductLineIdentities;
18
18
  exports.setOrderCollectionUid = setOrderCollectionUid;
19
19
  var _lodashEs = require("lodash-es");
20
+ var _entitlementPass = require("../../Discount/entitlementPass");
20
21
  const IDENTITY_CONFIG = {
21
22
  product: {
22
23
  persistentIdField: 'order_detail_id',
@@ -81,20 +82,22 @@ function setOrderCollectionUid(kind, item, uid) {
81
82
  delete record[uidField];
82
83
  return record;
83
84
  }
84
- function getGoodPassResourceId(product) {
85
- const goodPass = (product.discount_list || []).find(item => {
86
- const type = item?.type || item?.tag || item?.discount?.type || item?.discount?.tag;
87
- return type === 'good_pass';
88
- });
89
- if (!goodPass) return null;
90
- const resourceId = goodPass.discount?.resource_id ?? goodPass.resource_id ?? goodPass.discount_id ?? goodPass.id;
91
- return isBlankOrderCollectionIdentity(resourceId) ? null : String(resourceId);
85
+ function getFullCoveragePassIdentity(product) {
86
+ const pass = (product.discount_list || []).find(item => (0, _entitlementPass.isFullCoveragePass)(item));
87
+ if (!pass) return null;
88
+ const resourceId = pass.discount?.resource_id ?? pass.resource_id ?? pass.discount_id ?? pass.id;
89
+ if (isBlankOrderCollectionIdentity(resourceId)) return null;
90
+ return {
91
+ type: String(pass.type || pass.tag),
92
+ resourceId: String(resourceId)
93
+ };
92
94
  }
93
95
  function buildSplitProductUid(originalUid, product, duplicateOrdinal) {
94
96
  const encodedOriginalUid = encodeURIComponent(originalUid);
95
- const resourceId = getGoodPassResourceId(product);
96
- if (resourceId) {
97
- return `os-split:product:${encodedOriginalUid}:good-pass:${encodeURIComponent(resourceId)}:${duplicateOrdinal}`;
97
+ const passIdentity = getFullCoveragePassIdentity(product);
98
+ if (passIdentity) {
99
+ const passType = passIdentity.type === 'good_pass' ? 'good-pass' : 'entitlement-pass';
100
+ return `os-split:product:${encodedOriginalUid}:${passType}:${encodeURIComponent(passIdentity.resourceId)}:${duplicateOrdinal}`;
98
101
  }
99
102
  return `os-split:product:${encodedOriginalUid}:duplicate:${duplicateOrdinal}`;
100
103
  }
@@ -171,7 +171,7 @@ export declare function resolveManualOverrideLineOriginalPrice(params: {
171
171
  * // => -4
172
172
  */
173
173
  export declare function resolveEffectivePerUnitDiscount(product: Record<string, any>): number;
174
- export declare function createDefaultOrderRulesHooks(): RulesParamsHooks;
174
+ export declare function createDefaultOrderRulesHooks(getBookings?: () => OrderTempOrder['bookings']): RulesParamsHooks;
175
175
  /**
176
176
  * 通过 session 类商品的开始时间结束时间生成商品的时长
177
177
  * @param {CartItem} cartItem
@@ -129,6 +129,7 @@ Object.defineProperty(exports, "syncManualProductDiscountProductNum", {
129
129
  }
130
130
  });
131
131
  var _dayjs = _interopRequireDefault(require("dayjs"));
132
+ var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
132
133
  var _decimal = _interopRequireDefault(require("decimal.js"));
133
134
  var _weighedProduct = require("./utils/weighedProduct");
134
135
  var _manualProductDiscount = require("./utils/manualProductDiscount");
@@ -136,7 +137,9 @@ var _utils = require("../Holder/utils");
136
137
  var _utils2 = require("../../solution/ScanOrder/utils");
137
138
  var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
138
139
  var _salesNotes = require("./salesNotes");
140
+ var _pickupTiming = require("./pickupTiming");
139
141
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
142
+ _dayjs.default.extend(_customParseFormat.default);
140
143
  const POINT_CARD_SNAPSHOT_TAG = 'point_card';
141
144
  const VIRTUAL_CURRENCY_SNAPSHOT_TAG = 'virtual_currency';
142
145
  function isPlainObject(value) {
@@ -713,6 +716,24 @@ function resolveSubmitBundleMapId(bundle) {
713
716
  }
714
717
  return undefined;
715
718
  }
719
+ function ensureSubmitDiscountIdentity(discount) {
720
+ if (!discount || typeof discount !== 'object' || Array.isArray(discount)) {
721
+ return discount;
722
+ }
723
+ const discountRecord = discount;
724
+ const metadata = discountRecord.metadata && typeof discountRecord.metadata === 'object' && !Array.isArray(discountRecord.metadata) ? discountRecord.metadata : {};
725
+ const uniqueIdentificationNumber = metadata.unique_identification_number;
726
+ if (uniqueIdentificationNumber !== undefined && uniqueIdentificationNumber !== null && String(uniqueIdentificationNumber).trim() !== '') {
727
+ return discount;
728
+ }
729
+ return {
730
+ ...discountRecord,
731
+ metadata: {
732
+ ...metadata,
733
+ unique_identification_number: (0, _orderCollectionIdentity.createUuidV4)()
734
+ }
735
+ };
736
+ }
716
737
  function collectSubmitProductDiscountList(product) {
717
738
  const submitDiscountList = Array.isArray(product?.discount_list) ? [...product.discount_list] : [];
718
739
  for (const bundle of product?.product_bundle || []) {
@@ -734,7 +755,7 @@ function collectSubmitProductDiscountList(product) {
734
755
  });
735
756
  }
736
757
  }
737
- return normalizeOrderProductDiscountList(submitDiscountList);
758
+ return normalizeOrderProductDiscountList(submitDiscountList.map(ensureSubmitDiscountIdentity));
738
759
  }
739
760
 
740
761
  /**
@@ -801,7 +822,23 @@ function resolveEffectivePerUnitDiscount(product) {
801
822
  if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice)) return fromList;
802
823
  return fromList + (originalPrice - finalPrice);
803
824
  }
804
- function createDefaultOrderRulesHooks() {
825
+ function createDefaultOrderRulesHooks(getBookings) {
826
+ const getProductStartDate = product => {
827
+ const productUid = String(product.metadata?.unique_identification_number ?? product.unique_identification_number ?? '');
828
+ const bookingUid = String(product.booking_uid ?? product.metadata?.booking_uid ?? '');
829
+ // 每次读取当前 bookings,覆盖改期、订单回显以及直接调用 Rules 的选券入口。
830
+ const bookings = getBookings?.() || [];
831
+ const booking = bookings.find(item => productUid && String(item?.product_uid ?? item?.metadata?.product_uid ?? '') === productUid) || bookings.find(item => bookingUid && String(item?.metadata?.unique_identification_number ?? item?.booking_uid ?? '') === bookingUid);
832
+ if (booking) {
833
+ // 严格解析并保留 Invalid Date,让公共时间校验拒绝缺失/非法时间,避免回退到当前时间。
834
+ return (0, _dayjs.default)(`${booking.start_date} ${booking.start_time}`, ['YYYY-MM-DD HH:mm', 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD H:mm', 'YYYY-MM-DD H:mm:ss'], true);
835
+ }
836
+ if (getBookings && (bookingUid || product.booking_id || product.metadata?.booking_id)) {
837
+ return (0, _dayjs.default)('');
838
+ }
839
+ const legacyStartDate = product.metadata?.start_date || product.metadata?.startDate;
840
+ return legacyStartDate ? (0, _dayjs.default)(legacyStartDate) : undefined;
841
+ };
805
842
  const toUnitPriceString = (totalLike, num) => {
806
843
  const effectiveNum = Number(num) > 0 ? Number(num) : 1;
807
844
  return new _decimal.default(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
@@ -889,7 +926,7 @@ function createDefaultOrderRulesHooks() {
889
926
  // 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
890
927
  isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
891
928
  holder_id: product.metadata?.holder_id,
892
- startDate: product.metadata?.start_date || product.metadata?.startDate,
929
+ startDate: getProductStartDate(product),
893
930
  main_product_selling_price: metadataAny.main_product_selling_price !== undefined ? new _decimal.default(Number(metadataAny.main_product_selling_price) || 0).minus(optionSum).toDecimalPlaces(2).toString() : undefined,
894
931
  inPromotion: metadataAny._promotion?.inPromotion === true,
895
932
  _promotion: metadataAny._promotion
@@ -1263,7 +1300,7 @@ function normalizeSubmitProduct(product, formatOptions = {}) {
1263
1300
  payment_price: formatOptions.virtualSettlementMode ? virtualPrice : submitProduct.payment_price ?? submitProduct.selling_price
1264
1301
  };
1265
1302
  }
1266
- const SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type', 'holder'];
1303
+ const SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type', 'holder', 'is_fulfillment_timing', 'fulfillment_timing'];
1267
1304
  function normalizeBookingIsAll(booking) {
1268
1305
  return booking.is_all === true || booking.is_all === 1 || booking.is_all === '1' || booking.is_all === 'true' ? 1 : 0;
1269
1306
  }
@@ -1282,7 +1319,9 @@ function normalizeSubmitBooking(booking) {
1282
1319
  cleanMetadata[key] = rawMetadata[key];
1283
1320
  }
1284
1321
  }
1285
- if (cleanMetadata.holder_id === undefined) cleanMetadata.holder_id = null;
1322
+ if (cleanMetadata.holder_id === undefined && !(0, _pickupTiming.isFulfillmentTimingBooking)(booking)) {
1323
+ cleanMetadata.holder_id = null;
1324
+ }
1286
1325
  const bookingRecord = booking;
1287
1326
  const startDate = bookingRecord.start_date;
1288
1327
  const shouldRestoreSelectDate = bookingRecord.select_date === undefined || bookingRecord.select_date === null || bookingRecord.select_date === '';
@@ -1294,6 +1333,10 @@ function normalizeSubmitBooking(booking) {
1294
1333
  } : {}),
1295
1334
  is_all: normalizeBookingIsAll(bookingRecord),
1296
1335
  sub_type: normalizeBookingSubType(bookingRecord),
1336
+ ...((0, _pickupTiming.isFulfillmentTimingBooking)(booking) ? {
1337
+ like_status: bookingRecord.like_status || 'common',
1338
+ schedule_id: bookingRecord.schedule_id || 0
1339
+ } : {}),
1297
1340
  metadata: cleanMetadata
1298
1341
  };
1299
1342
  }
@@ -1379,6 +1422,7 @@ function hasBoundBookingResource(bookings) {
1379
1422
  if (!Array.isArray(bookings)) return false;
1380
1423
  return bookings.some(booking => {
1381
1424
  if (!booking || typeof booking !== 'object') return false;
1425
+ if ((0, _pickupTiming.isFulfillmentTimingBooking)(booking)) return false;
1382
1426
  if (Number(booking.parent_id) === 0) return false;
1383
1427
  const resources = booking.resources;
1384
1428
  if (!Array.isArray(resources)) return false;
@@ -1414,7 +1458,7 @@ function resolveSubmitOrderType(params) {
1414
1458
  return 'table-order';
1415
1459
  }
1416
1460
  if (currentType) return currentType;
1417
- if (Array.isArray(bookings) && bookings.length > 0) {
1461
+ if (Array.isArray(bookings) && bookings.some(booking => !(0, _pickupTiming.isFulfillmentTimingBooking)(booking))) {
1418
1462
  return businessCode === 'dine_in' ? 'table-order' : 'appointment_booking';
1419
1463
  }
1420
1464
  return 'virtual';
@@ -1499,7 +1543,7 @@ function buildSubmitPayload(params) {
1499
1543
  delivery_type: tempOrder.delivery_type || 'nil',
1500
1544
  schedule_date: scheduleDate,
1501
1545
  // created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
1502
- bookings: (tempOrder.bookings || []).filter(booking => Number(booking.parent_id) !== 0).map(booking => normalizeSubmitBooking(booking)),
1546
+ bookings: (tempOrder.bookings || []).filter(booking => (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0).map(booking => normalizeSubmitBooking(booking)),
1503
1547
  payments: tempOrder.payments || [],
1504
1548
  relation_forms: tempOrder.relation_forms || [],
1505
1549
  // contacts: tempOrder.contacts || [],
@@ -9,6 +9,7 @@ var _exportNames = {
9
9
  };
10
10
  exports.PaymentModule = void 0;
11
11
  exports.generateRequestUniqueId = generateRequestUniqueId;
12
+ var _loadPaymentMethods = require("../../shared/payment/loadPaymentMethods");
12
13
  var _BaseModule = require("../BaseModule");
13
14
  var _types = require("./types");
14
15
  Object.keys(_types).forEach(function (key) {
@@ -282,12 +283,10 @@ class PaymentModule extends _BaseModule.BaseModule {
282
283
  async getPayMethodListAsync() {
283
284
  this.logInfo('Starting getPayMethodListAsync');
284
285
  try {
285
- const response = await this.request.get('/pay/custom-payment/all', {
286
+ const payMethods = await (0, _loadPaymentMethods.loadPaymentMethods)(this.request, {
287
+ transport: 'os-server',
286
288
  filterPaymentMethods: true
287
- }, {
288
- osServer: true
289
289
  });
290
- const payMethods = response?.data || response || [];
291
290
  this.logInfo('getPayMethodListAsync completed successfully', {
292
291
  payMethods
293
292
  });
@@ -412,6 +412,8 @@ export interface WalletAssetsBehaviorOptions {
412
412
  export interface RefreshWalletAssetsOptions {
413
413
  /** 商品/金额变化默认保留并重验选择;客户变化由实现层强制清空。 */
414
414
  preserveSelection?: boolean;
415
+ /** 客户变化时,仅保留与本次扫码匹配的搜索结果;其他搜索缓存仍会清空。 */
416
+ retainSearchResultCodes?: string[];
415
417
  }
416
418
  export interface SelectWalletAssetOptions {
417
419
  selected: boolean;
@@ -419,6 +421,8 @@ export interface SelectWalletAssetOptions {
419
421
  }
420
422
  export interface ScanWalletAssetResult {
421
423
  type: SearchIdentificationCodeResult['type'];
424
+ /** walletCode 时保留完整 Wallet Detail,供客户解析与客户选择器使用。 */
425
+ data?: WalletDetailSearchData;
422
426
  asset?: any;
423
427
  selected: boolean;
424
428
  state: WalletAssetsState;
@@ -864,6 +868,8 @@ export interface SearchIdentificationCodeParams extends WalletDeductionRecommend
864
868
  * 搜索识别码响应数据
865
869
  */
866
870
  export interface SearchIdentificationCodeResponse {
871
+ /** 业务是否成功 */
872
+ status?: boolean;
867
873
  /** 响应状态码 */
868
874
  code?: number;
869
875
  /** 响应消息 */
@@ -871,12 +877,26 @@ export interface SearchIdentificationCodeResponse {
871
877
  /** 响应数据 */
872
878
  data?: SearchIdentificationCodeItem[];
873
879
  }
880
+ /** Wallet code 精确搜索返回的 Wallet Detail。 */
881
+ export interface WalletDetailSearchData {
882
+ id?: string | number;
883
+ customer_id?: string | number;
884
+ customer?: Record<string, any> | null;
885
+ is_cross_shop_wallet?: boolean | 0 | 1;
886
+ [key: string]: any;
887
+ }
888
+ export interface WalletDetailSearchResponse {
889
+ status?: boolean;
890
+ code?: number;
891
+ message?: string;
892
+ data?: WalletDetailSearchData | null;
893
+ }
874
894
  /**
875
895
  * 搜索识别码结果类型
876
896
  */
877
897
  export type SearchIdentificationCodeResult = {
878
898
  type: 'walletCode';
879
- data: SearchIdentificationCodeItem[];
899
+ data: WalletDetailSearchData;
880
900
  } | {
881
901
  type: 'normalCode';
882
902
  data: SearchIdentificationCodeItem[];
@@ -221,6 +221,7 @@ let PaymentHooks = exports.PaymentHooks = /*#__PURE__*/function (PaymentHooks) {
221
221
  /**
222
222
  * 搜索识别码响应数据
223
223
  */
224
+ /** Wallet code 精确搜索返回的 Wallet Detail。 */
224
225
  /**
225
226
  * 搜索识别码结果类型
226
227
  */
@@ -96,7 +96,7 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
96
96
  * 搜索识别码信息
97
97
  * 通过识别码搜索相关的钱包通行证信息
98
98
  * 基于 WalletDeductionRecommendParams 参数结构
99
- * 特殊逻辑:当识别码长度为9位且前3位为"000"时,调用 /wallet/detail/search 接口
99
+ * 特殊逻辑:WL 或指定 200 格式的 Wallet Code 调用 /wallet/detail/search 接口。
100
100
  */
101
101
  searchIdentificationCodeAsync(params: SearchIdentificationCodeParams, config?: {
102
102
  noCache?: boolean;
@@ -705,7 +705,7 @@ class WalletPassPaymentImpl {
705
705
  * 搜索识别码信息
706
706
  * 通过识别码搜索相关的钱包通行证信息
707
707
  * 基于 WalletDeductionRecommendParams 参数结构
708
- * 特殊逻辑:当识别码长度为9位且前3位为"000"时,调用 /wallet/detail/search 接口
708
+ * 特殊逻辑:WL 或指定 200 格式的 Wallet Code 调用 /wallet/detail/search 接口。
709
709
  */
710
710
  async searchIdentificationCodeAsync(params, config = {}) {
711
711
  try {
@@ -725,6 +725,7 @@ class WalletPassPaymentImpl {
725
725
  const walletDetailParams = {
726
726
  code: code,
727
727
  with_customer: 1,
728
+ with_franchisor_data: 1,
728
729
  with: ['wallet']
729
730
  };
730
731
  this.paymentModule.logInfo('[WalletPass] 搜索钱包识别码', {
@@ -733,15 +734,18 @@ class WalletPassPaymentImpl {
733
734
  with: walletDetailParams.with
734
735
  });
735
736
  const response = await this.paymentModule.request.post('/wallet/detail/search', walletDetailParams);
736
- const searchResults = response?.data || [];
737
+ const walletDetail = response?.data;
738
+ if (response?.status !== true || response?.code !== 200 || !walletDetail || typeof walletDetail !== 'object' || Array.isArray(walletDetail)) {
739
+ throw new Error(response?.message || 'Wallet detail search failed');
740
+ }
737
741
  this.paymentModule.logInfo('[WalletPass] 钱包识别码搜索完成', {
738
742
  code: code,
739
- results_count: searchResults.length,
743
+ results_count: 1,
740
744
  type: 'walletCode'
741
745
  });
742
746
  return {
743
747
  type: 'walletCode',
744
- data: searchResults
748
+ data: walletDetail
745
749
  };
746
750
  }
747
751
 
@@ -830,9 +834,16 @@ class WalletPassPaymentImpl {
830
834
  const previousCustomerId = this.walletAssetsState.customerId;
831
835
  const customerChanged = String(previousCustomerId ?? '') !== String(nextCustomerId ?? '');
832
836
  const preserveSelection = options.preserveSelection !== false && !customerChanged;
837
+ const retainedSearchCodeKeys = new Set((options.retainSearchResultCodes || []).map(normalizeWalletAssetCode).filter(Boolean));
838
+ const retainedSearchResults = customerChanged && retainedSearchCodeKeys.size > 0 ? this.searchResults.filter(item => isWalletPaymentAsset(item) && getWalletAssetCodeKeys(item).some(code => retainedSearchCodeKeys.has(code))) : [];
833
839
  if (customerChanged) {
834
840
  this.clearSearchResults();
841
+ if (retainedSearchResults.length > 0) {
842
+ this.searchResults = mergeWalletAssets(retainedSearchResults);
843
+ this.queuePendingAutoSelectForAssets(retainedSearchResults);
844
+ }
835
845
  }
846
+ const preserveSearchContext = preserveSelection || retainedSearchResults.length > 0;
836
847
  const committedKeys = new Set(this.walletAssetsState.committedIds.map(id => String(id)));
837
848
  const committedItems = this.walletAssetsState.items.filter(item => committedKeys.has(getWalletAssetKey(item)));
838
849
  const selectedIds = preserveSelection ? [...this.walletAssetsState.selectedIds] : [];
@@ -901,8 +912,8 @@ class WalletPassPaymentImpl {
901
912
  error: null
902
913
  });
903
914
  try {
904
- const searchedWalletAssetCodes = preserveSelection ? this.getSearchedWalletAssetCodes() : [];
905
- const useAggregateRecalculate = preserveSelection && (selectedIds.length > 0 || searchedWalletAssetCodes.length > 0);
915
+ const searchedWalletAssetCodes = preserveSearchContext ? this.getSearchedWalletAssetCodes() : [];
916
+ const useAggregateRecalculate = preserveSearchContext && (selectedIds.length > 0 || searchedWalletAssetCodes.length > 0);
906
917
  const aggregateResult = useAggregateRecalculate ? await this.aggregateRecalculateWalletAssetsAsync(businessData, selectedIds) : null;
907
918
  const result = aggregateResult || (await this.initializeWalletDataFromBusinessAsync(businessData));
908
919
  if (requestSequence !== this.walletAssetsRequestSequence) {
@@ -920,7 +931,7 @@ class WalletPassPaymentImpl {
920
931
  this.searchResults = this.searchResults.filter(item => !missingSelectedKeys.has(getWalletAssetKey(item)));
921
932
  }
922
933
  }
923
- const searchedWalletAssets = preserveSelection ? this.syncSearchedWalletAssets([...(result.transformList || []), ...(result.noApplicableVoucher || [])]) : [];
934
+ const searchedWalletAssets = preserveSearchContext ? this.syncSearchedWalletAssets([...(result.transformList || []), ...(result.noApplicableVoucher || [])]) : [];
924
935
  if (requestSequence !== this.walletAssetsRequestSequence) {
925
936
  return this.getWalletAssetsState();
926
937
  }
@@ -1122,14 +1133,23 @@ class WalletPassPaymentImpl {
1122
1133
  code: normalizedCode,
1123
1134
  prepare_payments: this.formatWalletPassList2PreparePayments(this.walletAssetsState.selectedItems)
1124
1135
  });
1136
+ if (result.type === 'walletCode') {
1137
+ return {
1138
+ type: 'walletCode',
1139
+ data: result.data,
1140
+ asset: result.data,
1141
+ selected: false,
1142
+ state: this.getWalletAssetsState()
1143
+ };
1144
+ }
1125
1145
  const paymentAssets = this.formatSearchedWalletPaymentAssets(result.data.filter(isWalletPaymentAsset));
1126
1146
  if (paymentAssets.length > 0) {
1127
1147
  this.searchResults = mergeWalletAssets(this.searchResults, paymentAssets);
1128
1148
  }
1129
1149
  const asset = paymentAssets.find(item => String(item?.code || '') === normalizedCode) || paymentAssets[0];
1130
- if (!asset || result.type === 'walletCode') {
1150
+ if (!asset) {
1131
1151
  return {
1132
- type: result.type,
1152
+ type: 'normalCode',
1133
1153
  asset,
1134
1154
  selected: false,
1135
1155
  state: this.getWalletAssetsState()
@@ -16,8 +16,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
16
16
  getWalletPassEvaluator(): import("../..").WalletPassEvaluator | undefined;
17
17
  private normalizeHolderRecordIds;
18
18
  /**
19
- * 特定 form Holder 卡只授权给绑定同一 Holder Record 的商品行。
20
- * required/isNeedHolder 仅控制是否强制选择 Holder,不参与优惠资格。
19
+ * 商品未开启 Holder 选择时跳过匹配;已开启时,特定 form Holder 卡
20
+ * 只适用于同一 Holder Record,是否必填不影响匹配规则。
21
21
  */
22
22
  private checkHolderMatch;
23
23
  isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, orderTotalAmount, holders, isFormSubject, }: {