@pisell/pisellos 2.2.264 → 2.2.266

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 (126) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
  14. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  15. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  16. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
  17. package/dist/modules/Discount/index.d.ts +5 -2
  18. package/dist/modules/Discount/index.js +30 -7
  19. package/dist/modules/Discount/types.d.ts +4 -0
  20. package/dist/modules/Order/index.d.ts +41 -10
  21. package/dist/modules/Order/index.js +1379 -810
  22. package/dist/modules/Order/payment-utils.d.ts +26 -0
  23. package/dist/modules/Order/payment-utils.js +225 -0
  24. package/dist/modules/Order/types.d.ts +49 -1
  25. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  26. package/dist/modules/Order/utils/orderCollectionIdentity.js +410 -0
  27. package/dist/modules/Order/utils.d.ts +4 -3
  28. package/dist/modules/Order/utils.js +61 -64
  29. package/dist/modules/Payment/index.d.ts +2 -0
  30. package/dist/modules/Payment/index.js +78 -49
  31. package/dist/modules/Payment/types.d.ts +26 -24
  32. package/dist/modules/Payment/types.js +2 -0
  33. package/dist/modules/Product/types.d.ts +22 -0
  34. package/dist/modules/ProductList/index.d.ts +1 -1
  35. package/dist/modules/ProductList/index.js +4 -2
  36. package/dist/modules/ProductList/types.d.ts +2 -0
  37. package/dist/modules/Rules/index.d.ts +2 -8
  38. package/dist/modules/Rules/index.js +55 -9
  39. package/dist/modules/Rules/types.d.ts +10 -1
  40. package/dist/server/index.d.ts +71 -0
  41. package/dist/server/index.js +2504 -1187
  42. package/dist/server/modules/order/index.d.ts +56 -5
  43. package/dist/server/modules/order/index.js +1718 -834
  44. package/dist/server/modules/order/types.d.ts +15 -3
  45. package/dist/server/modules/order/types.js +1 -1
  46. package/dist/server/modules/products/index.d.ts +31 -8
  47. package/dist/server/modules/products/index.js +549 -390
  48. package/dist/server/modules/products/types.d.ts +18 -0
  49. package/dist/solution/BaseSales/index.d.ts +67 -4
  50. package/dist/solution/BaseSales/index.js +1476 -792
  51. package/dist/solution/BaseSales/types.d.ts +6 -1
  52. package/dist/solution/BaseSales/types.js +1 -1
  53. package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
  54. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
  55. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  56. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
  57. package/dist/solution/BookingByStep/index.d.ts +1 -1
  58. package/dist/solution/BookingTicket/index.js +94 -54
  59. package/dist/solution/BookingTicket/types.d.ts +2 -0
  60. package/dist/solution/Sales/index.d.ts +1 -0
  61. package/dist/solution/Sales/index.js +10 -2
  62. package/dist/solution/ShopDiscount/index.js +15 -14
  63. package/dist/utils/payment-number.d.ts +9 -0
  64. package/dist/utils/payment-number.js +69 -0
  65. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  66. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  67. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  68. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  69. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  70. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  71. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  72. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  73. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  74. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  75. package/lib/model/strategy/adapter/index.d.ts +4 -0
  76. package/lib/model/strategy/adapter/index.js +13 -2
  77. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
  78. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
  79. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  80. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
  81. package/lib/modules/Discount/index.d.ts +5 -2
  82. package/lib/modules/Discount/index.js +23 -3
  83. package/lib/modules/Discount/types.d.ts +4 -0
  84. package/lib/modules/Order/index.d.ts +41 -10
  85. package/lib/modules/Order/index.js +514 -122
  86. package/lib/modules/Order/payment-utils.d.ts +26 -0
  87. package/lib/modules/Order/payment-utils.js +224 -0
  88. package/lib/modules/Order/types.d.ts +49 -1
  89. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  90. package/lib/modules/Order/utils/orderCollectionIdentity.js +418 -0
  91. package/lib/modules/Order/utils.d.ts +4 -3
  92. package/lib/modules/Order/utils.js +26 -20
  93. package/lib/modules/Payment/index.d.ts +2 -0
  94. package/lib/modules/Payment/index.js +33 -12
  95. package/lib/modules/Payment/types.d.ts +26 -24
  96. package/lib/modules/Product/types.d.ts +22 -0
  97. package/lib/modules/ProductList/index.d.ts +1 -1
  98. package/lib/modules/ProductList/index.js +4 -2
  99. package/lib/modules/ProductList/types.d.ts +2 -0
  100. package/lib/modules/Rules/index.d.ts +2 -8
  101. package/lib/modules/Rules/index.js +57 -6
  102. package/lib/modules/Rules/types.d.ts +10 -1
  103. package/lib/server/index.d.ts +71 -0
  104. package/lib/server/index.js +1002 -52
  105. package/lib/server/modules/order/index.d.ts +56 -5
  106. package/lib/server/modules/order/index.js +798 -148
  107. package/lib/server/modules/order/types.d.ts +15 -3
  108. package/lib/server/modules/products/index.d.ts +31 -8
  109. package/lib/server/modules/products/index.js +134 -35
  110. package/lib/server/modules/products/types.d.ts +18 -0
  111. package/lib/solution/BaseSales/index.d.ts +67 -4
  112. package/lib/solution/BaseSales/index.js +496 -50
  113. package/lib/solution/BaseSales/types.d.ts +6 -1
  114. package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
  115. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
  116. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  117. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
  118. package/lib/solution/BookingByStep/index.d.ts +1 -1
  119. package/lib/solution/BookingTicket/index.js +39 -11
  120. package/lib/solution/BookingTicket/types.d.ts +2 -0
  121. package/lib/solution/Sales/index.d.ts +1 -0
  122. package/lib/solution/Sales/index.js +5 -3
  123. package/lib/solution/ShopDiscount/index.js +2 -1
  124. package/lib/utils/payment-number.d.ts +9 -0
  125. package/lib/utils/payment-number.js +64 -0
  126. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import type { Discount } from '../../modules/Discount/types';
1
2
  import { OrderModule, ProductList, QuotationModule, SalesSummaryModule, ScanOrderLoggerModule as BaseSalesLoggerModule, ScheduleModule } from '../../modules';
2
3
  import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderConfig as BaseSalesLoggerProviderConfig, ScanOrderLoggerProviderType as BaseSalesLoggerProviderType } from '../../modules/ScanOrderLogger/types';
3
4
  import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
@@ -85,6 +86,8 @@ export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
85
86
  booking_uid?: string;
86
87
  /** 多语言商品标题快照,随 tempOrder 提交到 checkout。 */
87
88
  product_title?: BaseSalesLocalizedText;
89
+ /** 商品封面图快照,随 tempOrder 提交到 checkout。 */
90
+ product_cover?: string;
88
91
  /**
89
92
  * 行级扩展 metadata。价格相关的权威字段:
90
93
  *
@@ -381,9 +384,11 @@ export interface BaseSalesLoggerRuntimeConfig {
381
384
  }
382
385
  export interface BaseSalesAddLogParams extends BaseSalesLogInput {
383
386
  }
384
- /** BaseSales.scanPromotionCode 对外的轻量结果(不含 discountList,UI resolve 后调 getDiscountList) */
387
+ /** BaseSales.scanPromotionCode 对外的轻量结果(UI 可用 getDiscountList scannedDiscountList 补 Holder) */
385
388
  export interface BaseSalesScanCodeResult {
386
389
  isAvailable: boolean;
387
390
  type?: 'server' | string;
388
391
  unavailableReason?: 'time_limit' | string;
392
+ /** batchSearch 原始结果;isAvailable=false 时 discountList 可能未写入 store,Holder 补全需读此字段 */
393
+ scannedDiscountList?: Discount[];
389
394
  }
@@ -37,4 +37,4 @@ export function createBaseSalesHook(moduleName, hookName) {
37
37
 
38
38
  /** `/order/resource/occupy-detail` 单条 `occupy_details[i]` */
39
39
 
40
- /** BaseSales.scanPromotionCode 对外的轻量结果(不含 discountList,UI resolve 后调 getDiscountList) */
40
+ /** BaseSales.scanPromotionCode 对外的轻量结果(UI 可用 getDiscountList scannedDiscountList 补 Holder) */
@@ -287,9 +287,10 @@ export function mergeIdenticalPromotionCartLines(products) {
287
287
  var unitPrice = String((_ref2 = (_line$metadata$source = (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.source_product_price) !== null && _line$metadata$source !== void 0 ? _line$metadata$source : line.selling_price) !== null && _ref2 !== void 0 ? _ref2 : '');
288
288
  var promoUnitPrice = String((_ref3 = (_promotion$finalPrice = promotion.finalPrice) !== null && _promotion$finalPrice !== void 0 ? _promotion$finalPrice : (_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.main_product_selling_price) !== null && _ref3 !== void 0 ? _ref3 : '');
289
289
  var noteSignature = getProductLineNoteSignature(line);
290
+ var lineMergeBoundary = getPromotionLineMergeBoundary(line);
290
291
  var bookingUid = (_line$booking_uid = line === null || line === void 0 ? void 0 : line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : line === null || line === void 0 || (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.booking_uid;
291
292
  var orderDetailId = (_line$order_detail_id = line === null || line === void 0 ? void 0 : line.order_detail_id) !== null && _line$order_detail_id !== void 0 ? _line$order_detail_id : line === null || line === void 0 ? void 0 : line.orderDetailId;
292
- var mergeKey = [line.product_id, (_line$product_variant = line.product_variant_id) !== null && _line$product_variant !== void 0 ? _line$product_variant : 0, fingerprint, noteSignature, bookingUid ? String(bookingUid) : '', orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '' ? String(orderDetailId) : '', promotion.strategyId, unitPrice, promoUnitPrice].join('#');
293
+ var mergeKey = [line.product_id, (_line$product_variant = line.product_variant_id) !== null && _line$product_variant !== void 0 ? _line$product_variant : 0, fingerprint, noteSignature, lineMergeBoundary, bookingUid ? String(bookingUid) : '', orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '' ? String(orderDetailId) : '', promotion.strategyId, unitPrice, promoUnitPrice].join('#');
293
294
  var hitIndex = indexByKey.get(mergeKey);
294
295
  if (hitIndex === undefined) {
295
296
  indexByKey.set(mergeKey, merged.length);
@@ -465,6 +466,16 @@ function getProductLineNoteSignature(product) {
465
466
  var uid = getOrderProductUid(product);
466
467
  return uid ? "note:".concat(uid) : "note:".concat(normalizedNote);
467
468
  }
469
+
470
+ /**
471
+ * 编辑订单时,历史行仍参与整车促销评估,但不能与本次新增行合并。
472
+ * 以历史行 uid 作为促销前后的行边界;新增行返回空边界,仍保留原有合并语义。
473
+ */
474
+ function getPromotionLineMergeBoundary(product) {
475
+ var _product$metadata3;
476
+ if ((product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.is_edit_for_runtime) !== true) return '';
477
+ return "edit:".concat(getOrderProductUid(product));
478
+ }
468
479
  function isPersistedGeneratedVoucher(product) {
469
480
  var _product$order_detail;
470
481
  var orderDetailId = (_product$order_detail = product === null || product === void 0 ? void 0 : product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : product === null || product === void 0 ? void 0 : product.orderDetailId;
@@ -505,17 +516,18 @@ export function buildConsolidateKeyForPromotion(item) {
505
516
  var _item$booking_uid, _item$metadata4, _item$order_detail_id, _item$product_variant3;
506
517
  var fingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
507
518
  var noteSignature = getProductLineNoteSignature(item);
519
+ var lineMergeBoundary = getPromotionLineMergeBoundary(item);
508
520
  var bookingUid = (_item$booking_uid = item === null || item === void 0 ? void 0 : item.booking_uid) !== null && _item$booking_uid !== void 0 ? _item$booking_uid : item === null || item === void 0 || (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.booking_uid;
509
521
  var orderDetailId = (_item$order_detail_id = item === null || item === void 0 ? void 0 : item.order_detail_id) !== null && _item$order_detail_id !== void 0 ? _item$order_detail_id : item === null || item === void 0 ? void 0 : item.orderDetailId;
510
522
  if (orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '') {
511
523
  var _item$product_variant;
512
- return [item.product_id, (_item$product_variant = item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0, fingerprint, noteSignature, String(orderDetailId)].join('#');
524
+ return [item.product_id, (_item$product_variant = item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0, fingerprint, noteSignature, lineMergeBoundary, String(orderDetailId)].join('#');
513
525
  }
514
526
  if (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '') {
515
527
  var _item$product_variant2;
516
- return [item.product_id, (_item$product_variant2 = item.product_variant_id) !== null && _item$product_variant2 !== void 0 ? _item$product_variant2 : 0, fingerprint, noteSignature, String(bookingUid)].join('#');
528
+ return [item.product_id, (_item$product_variant2 = item.product_variant_id) !== null && _item$product_variant2 !== void 0 ? _item$product_variant2 : 0, fingerprint, noteSignature, lineMergeBoundary, String(bookingUid)].join('#');
517
529
  }
518
- return [item.product_id, (_item$product_variant3 = item.product_variant_id) !== null && _item$product_variant3 !== void 0 ? _item$product_variant3 : 0, fingerprint, noteSignature].join('#');
530
+ return [item.product_id, (_item$product_variant3 = item.product_variant_id) !== null && _item$product_variant3 !== void 0 ? _item$product_variant3 : 0, fingerprint, noteSignature, lineMergeBoundary].join('#');
519
531
  }
520
532
  function consolidateMainProductsForPromotion(entries) {
521
533
  if (!Array.isArray(entries) || entries.length <= 1) {
@@ -886,13 +898,13 @@ export function resolveStrategyEligibleProducts(matched) {
886
898
  export function calculateUnfulfilledPromotions(processedProducts, applicableStrategiesResult, mainProducts) {
887
899
  var unfulfilledMap = new Map();
888
900
  var _loop2 = function _loop2() {
889
- var _product$metadata3, _ref13, _product$_originalPro, _product$metadata4, _product$num2;
901
+ var _product$metadata4, _ref13, _product$_originalPro, _product$metadata5, _product$num2;
890
902
  var product = processedProducts[i];
891
- var promotion = product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3._promotion;
903
+ var promotion = product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4._promotion;
892
904
  if (!promotion || promotion.inPromotion !== false) return 0; // continue
893
905
  var strategyId = promotion.strategyId;
894
906
  if (!strategyId) return 0; // continue
895
- var lookupUid = String((_ref13 = (_product$_originalPro = product === null || product === void 0 ? void 0 : product._originalProductUid) !== null && _product$_originalPro !== void 0 ? _product$_originalPro : product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.unique_identification_number) !== null && _ref13 !== void 0 ? _ref13 : '');
907
+ var lookupUid = String((_ref13 = (_product$_originalPro = product === null || product === void 0 ? void 0 : product._originalProductUid) !== null && _product$_originalPro !== void 0 ? _product$_originalPro : product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) !== null && _ref13 !== void 0 ? _ref13 : '');
896
908
  var originalIndex = mainProducts.findIndex(function (item) {
897
909
  return getOrderProductUid(item) === lookupUid;
898
910
  });
@@ -2,7 +2,7 @@
2
2
  * 把 `/order/sales/{id}` 响应(OrderData)解析为 ISalesDetail。
3
3
  *
4
4
  * - 纯函数:不依赖任何运行时模块/插件,便于单测与 view-model 适配
5
- * - products 保留 tempOrder / 后端详情原字段,仅做浅拷贝,避免丢失 product_sku 等协议字段
5
+ * - products 保留 tempOrder / 后端详情原字段,仅规范化集合身份并浅拷贝,避免丢失 product_sku 等协议字段
6
6
  * - bookings 平铺保留服务端原顺序,同时输出 byProductUid 反查表与 rootBooking
7
7
  * - header 收敛"非数组顶层字段",便于 ticketBooking view-model 直接消费
8
8
  *
@@ -82,8 +82,13 @@ export interface ISalesBooking {
82
82
  metadata?: Record<string, any> | null;
83
83
  [key: string]: any;
84
84
  }
85
+ export interface ISalesPaymentMetadata extends Record<string, any> {
86
+ /** 刷卡机设备快照;OS 不解析内部字段 */
87
+ card_reader_snapshot?: Record<string, unknown>;
88
+ }
85
89
  export interface ISalesPayment {
86
90
  order_payment_id?: number | null;
91
+ payment_number?: string;
87
92
  custom_payment_id?: number;
88
93
  code?: string;
89
94
  name?: string;
@@ -95,7 +100,7 @@ export interface ISalesPayment {
95
100
  status?: string;
96
101
  payment_time?: string | null;
97
102
  service_charge?: Record<string, any> | null;
98
- metadata?: Record<string, any> | null;
103
+ metadata?: ISalesPaymentMetadata | null;
99
104
  [key: string]: any;
100
105
  }
101
106
  export interface ISalesSurcharge {
@@ -130,7 +135,7 @@ export interface ISalesDetail {
130
135
  customer: ISalesDetailCustomer | null;
131
136
  /** 服务端 summary(仅输出) */
132
137
  summary: Record<string, any>;
133
- /** 原始响应快照,方便 UI 兜底使用 */
138
+ /** 规范化后的响应快照,方便 UI 兜底使用 */
134
139
  raw: Record<string, any>;
135
140
  }
136
141
  /**
@@ -138,7 +143,7 @@ export interface ISalesDetail {
138
143
  *
139
144
  * 注意:
140
145
  * - 入参允许是 `{ data: OrderData }` 或直接 `OrderData`,自动识别。
141
- * - products 保留原字段;字段补齐由 OrderModule hydrate 负责。
146
+ * - products/bookings/payments 在此补齐集合身份;其余 runtime 字段由 OrderModule hydrate 负责。
142
147
  * - 不做远程请求;不修改入参;返回新对象。
143
148
  */
144
149
  export declare function parseSalesResponse(input: Record<string, any> | null | undefined): ISalesDetail;
@@ -11,7 +11,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
11
11
  * 把 `/order/sales/{id}` 响应(OrderData)解析为 ISalesDetail。
12
12
  *
13
13
  * - 纯函数:不依赖任何运行时模块/插件,便于单测与 view-model 适配
14
- * - products 保留 tempOrder / 后端详情原字段,仅做浅拷贝,避免丢失 product_sku 等协议字段
14
+ * - products 保留 tempOrder / 后端详情原字段,仅规范化集合身份并浅拷贝,避免丢失 product_sku 等协议字段
15
15
  * - bookings 平铺保留服务端原顺序,同时输出 byProductUid 反查表与 rootBooking
16
16
  * - header 收敛"非数组顶层字段",便于 ticketBooking view-model 直接消费
17
17
  *
@@ -23,6 +23,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
23
23
  * - 不在此处发明等价关系;UI 侧(ticketBooking)若需要别的字段,由 view-model 适配层做转换
24
24
  */
25
25
 
26
+ import { normalizeOrderCollections } from "../../../modules/Order/utils/orderCollectionIdentity";
26
27
  /** OrderData 中除大数组外的"顶层 header 字段"白名单,按需扩展。 */
27
28
  var HEADER_KEYS = ['order_id', 'order_number', 'shop_order_number', 'shop_full_order_number', 'type', 'business_code', 'platform', 'sales_channel', 'order_sales_channel', 'vouchers', 'status', 'payment_status', 'shipping_status', 'customer_id', 'customer_name', 'country_calling_code', 'phone', 'email', 'is_price_include_tax', 'tax_title', 'tax_country_code', 'currency_code', 'currency_symbol', 'currency_format', 'is_deposit', 'deposit_amount', 'shop_discount', 'surcharge_fee', 'note', 'schedule_date', 'created_at', 'updated_at', 'metadata', 'total_amount', 'shop_id', 'create_date', 'holder', 'relation_forms', 'contacts', 'contacts_info'];
28
29
  function pickHeader(raw) {
@@ -108,19 +109,16 @@ function indexBookingsByProductUid(bookings) {
108
109
  *
109
110
  * 注意:
110
111
  * - 入参允许是 `{ data: OrderData }` 或直接 `OrderData`,自动识别。
111
- * - products 保留原字段;字段补齐由 OrderModule hydrate 负责。
112
+ * - products/bookings/payments 在此补齐集合身份;其余 runtime 字段由 OrderModule hydrate 负责。
112
113
  * - 不做远程请求;不修改入参;返回新对象。
113
114
  */
114
115
  export function parseSalesResponse(input) {
115
- var raw = input && _typeof(input) === 'object' && input.data && input.order_id == null ? input.data : input || {};
116
+ var sourceRaw = input && _typeof(input) === 'object' && input.data && input.order_id == null ? input.data : input || {};
117
+ var raw = normalizeOrderCollections(sourceRaw).order;
116
118
  var productsRaw = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.products) ? raw.products : [];
117
- var products = productsRaw.map(function (p, index) {
119
+ var products = productsRaw.map(function (p) {
118
120
  var row = _objectSpread({}, p || {});
119
121
  var metadata = row.metadata && _typeof(row.metadata) === 'object' ? _objectSpread({}, row.metadata) : {};
120
- if (!metadata.unique_identification_number) {
121
- var _row$product_id, _row$product_variant_;
122
- metadata.unique_identification_number = "sales-product-".concat((_row$product_id = row.product_id) !== null && _row$product_id !== void 0 ? _row$product_id : 'unknown', "-").concat((_row$product_variant_ = row.product_variant_id) !== null && _row$product_variant_ !== void 0 ? _row$product_variant_ : 0, "-").concat(index);
123
- }
124
122
  delete metadata.price_schema_version;
125
123
  delete row.identity_key;
126
124
  return _objectSpread(_objectSpread({}, row), {}, {
@@ -30,6 +30,17 @@ function toPriceString(value) {
30
30
  if (!Number.isFinite(parsedValue)) return fallback;
31
31
  return parsedValue.toFixed(2);
32
32
  }
33
+ function isBlankValue(value) {
34
+ return value === undefined || value === null || typeof value === 'string' && value.trim() === '';
35
+ }
36
+ function firstNonBlank() {
37
+ for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
38
+ values[_key] = arguments[_key];
39
+ }
40
+ return values.find(function (value) {
41
+ return !isBlankValue(value);
42
+ });
43
+ }
33
44
  function normalizeOptionItems(optionItems) {
34
45
  if (!Array.isArray(optionItems)) return [];
35
46
  return optionItems.map(function (optionItem) {
@@ -166,7 +177,8 @@ export function transformBaseProductToOrderProduct(params) {
166
177
  source_product_price: sourceProductPrice,
167
178
  main_product_selling_price: mainProductSellingPrice,
168
179
  main_product_original_price: mainProductOriginalPrice,
169
- price_schema_version: 2
180
+ price_schema_version: 2,
181
+ holder_config: sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.holder_config
170
182
  }, hasPriceOverride ? {
171
183
  price_override: String(payload.price_override),
172
184
  is_manual_discount: 1
@@ -198,6 +210,7 @@ export function transformBaseProductToOrderProduct(params) {
198
210
  metadata: metadata,
199
211
  note: payload.note != null ? String(payload.note) : '',
200
212
  product_title: productTitle,
213
+ product_cover: firstNonBlank(matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.cover, sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover),
201
214
  _origin: _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
202
215
  callbackData: payload
203
216
  })
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -1,8 +1,8 @@
1
1
  var _excluded = ["id"],
2
2
  _excluded2 = ["product_id"],
3
3
  _excluded3 = ["product_id"];
4
- 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; } } }; }
5
4
  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); }
5
+ 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; } } }; }
6
6
  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; }
7
7
  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; }
8
8
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
@@ -397,49 +397,52 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
397
397
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
398
398
  while (1) switch (_context5.prev = _context5.next) {
399
399
  case 0:
400
+ // 业务码切换或配置失败时不能复用上一次初始化的短号。
401
+ this.setPaymentNumberDevicePrefix(null);
400
402
  openDataConfig = null;
401
- _context5.prev = 1;
402
- _context5.next = 4;
403
+ _context5.prev = 2;
404
+ _context5.next = 5;
403
405
  return this.loadOpenDataConfig();
404
- case 4:
406
+ case 5:
405
407
  openDataConfig = _context5.sent;
406
- _context5.next = 11;
408
+ _context5.next = 12;
407
409
  break;
408
- case 7:
409
- _context5.prev = 7;
410
- _context5.t0 = _context5["catch"](1);
410
+ case 8:
411
+ _context5.prev = 8;
412
+ _context5.t0 = _context5["catch"](2);
411
413
  console.warn('[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置', _context5.t0);
412
414
  return _context5.abrupt("return");
413
- case 11:
415
+ case 12:
414
416
  // if (!openDataConfig) return;
415
417
  idGenerator = this.getIdGeneratorPlugin();
416
418
  if (idGenerator !== null && idGenerator !== void 0 && idGenerator.configure) {
417
- _context5.next = 15;
419
+ _context5.next = 16;
418
420
  break;
419
421
  }
420
422
  console.warn('[BookingTicket] idGenerator 插件不可用,跳过配置');
421
423
  return _context5.abrupt("return");
422
- case 15:
424
+ case 16:
423
425
  receiptSequenceLength = this.normalizePositiveInteger((_openDataConfig = openDataConfig) === null || _openDataConfig === void 0 ? void 0 : _openDataConfig['sale.short_number_digits'], 5);
424
426
  receiptSequenceStart = this.normalizePositiveInteger((_openDataConfig2 = openDataConfig) === null || _openDataConfig2 === void 0 ? void 0 : _openDataConfig2['sale.short_number_start_number'], 1);
425
427
  prefix = this.normalizeIdPrefix((_openDataConfig3 = openDataConfig) === null || _openDataConfig3 === void 0 ? void 0 : _openDataConfig3['sale.short_number_prefix'], '');
426
428
  shopOrderPrefix = this.normalizeIdPrefix((_openDataConfig4 = openDataConfig) === null || _openDataConfig4 === void 0 ? void 0 : _openDataConfig4['sale.sale_number_prefix'], '');
427
429
  resetReceiptSequenceDaily = typeof ((_openDataConfig5 = openDataConfig) === null || _openDataConfig5 === void 0 ? void 0 : _openDataConfig5['sale.short_number_daily_reset']) === 'boolean' ? (_openDataConfig6 = openDataConfig) === null || _openDataConfig6 === void 0 ? void 0 : _openDataConfig6['sale.short_number_daily_reset'] : false;
428
430
  operatingDayBoundary = this.getAppData('operating_day_boundary');
429
- _context5.next = 23;
431
+ _context5.next = 24;
430
432
  return this.getShortNumberOrDeviceId();
431
- case 23:
433
+ case 24:
432
434
  deviceId = _context5.sent;
435
+ this.setPaymentNumberDevicePrefix(deviceId);
433
436
  businessCode = this.getBookingTicketBusinessCode();
434
437
  if (businessCode) {
435
- _context5.next = 28;
438
+ _context5.next = 30;
436
439
  break;
437
440
  }
438
441
  console.warn('[BookingTicket] businessCode 缺失,跳过 idGenerator 配置');
439
442
  return _context5.abrupt("return");
440
- case 28:
441
- _context5.prev = 28;
442
- _context5.next = 31;
443
+ case 30:
444
+ _context5.prev = 30;
445
+ _context5.next = 33;
443
446
  return idGenerator.configure({
444
447
  biz: businessCode,
445
448
  config: {
@@ -454,18 +457,18 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
454
457
  shopOrderPrefix: shopOrderPrefix
455
458
  }
456
459
  });
457
- case 31:
458
- _context5.next = 36;
459
- break;
460
460
  case 33:
461
- _context5.prev = 33;
462
- _context5.t1 = _context5["catch"](28);
461
+ _context5.next = 38;
462
+ break;
463
+ case 35:
464
+ _context5.prev = 35;
465
+ _context5.t1 = _context5["catch"](30);
463
466
  console.warn('[BookingTicket] idGenerator 配置失败', _context5.t1);
464
- case 36:
467
+ case 38:
465
468
  case "end":
466
469
  return _context5.stop();
467
470
  }
468
- }, _callee5, this, [[1, 7], [28, 33]]);
471
+ }, _callee5, this, [[2, 8], [30, 35]]);
469
472
  }));
470
473
  function configureIdGeneratorFromOpenData() {
471
474
  return _configureIdGeneratorFromOpenData.apply(this, arguments);
@@ -549,7 +552,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
549
552
  key: "scanPromotionCode",
550
553
  value: function () {
551
554
  var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(code, customerId) {
552
- var raw;
555
+ var raw, scannedList, extractedCustomerId, hasOrderCustomer, tempOrder;
553
556
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
554
557
  while (1) switch (_context7.prev = _context7.next) {
555
558
  case 0:
@@ -563,26 +566,42 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
563
566
  return this.store.order.scanCode(code, customerId);
564
567
  case 4:
565
568
  raw = _context7.sent;
566
- if (!raw.isAvailable) {
569
+ scannedList = raw.scannedDiscountList || [];
570
+ extractedCustomerId = this.getDiscountCustomerId(scannedList);
571
+ hasOrderCustomer = Boolean(this.store.order.getOrderCustomer()); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
572
+ if (!(!hasOrderCustomer && extractedCustomerId)) {
567
573
  _context7.next = 11;
568
574
  break;
569
575
  }
570
- _context7.next = 8;
571
- return this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList || []);
572
- case 8:
573
- _context7.next = 10;
576
+ _context7.next = 11;
577
+ return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
578
+ case 11:
579
+ if (!raw.isAvailable) {
580
+ _context7.next = 18;
581
+ break;
582
+ }
583
+ _context7.next = 14;
574
584
  return this.store.order.recalculateSummary({
575
585
  createIfMissing: true
576
586
  });
577
- case 10:
587
+ case 14:
578
588
  this.store.order.persistTempOrder();
579
- case 11:
589
+ tempOrder = this.store.order.ensureTempOrder();
590
+ _context7.next = 18;
591
+ return this.effectsEmit('onDiscountApplied', {
592
+ productList: tempOrder.products || [],
593
+ discountList: this.store.order.getDiscountList(),
594
+ selectedDiscountList: tempOrder.discount_list || [],
595
+ tempOrder: tempOrder
596
+ });
597
+ case 18:
580
598
  return _context7.abrupt("return", {
581
599
  isAvailable: raw.isAvailable,
582
600
  type: raw.type,
583
- unavailableReason: raw.unavailableReason
601
+ unavailableReason: raw.unavailableReason,
602
+ scannedDiscountList: raw.scannedDiscountList
584
603
  });
585
- case 12:
604
+ case 19:
586
605
  case "end":
587
606
  return _context7.stop();
588
607
  }
@@ -641,12 +660,22 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
641
660
  }, {
642
661
  key: "getDiscountCustomerId",
643
662
  value: function getDiscountCustomerId(discounts) {
644
- var discount = discounts.find(function (item) {
645
- return item.customer_id != null;
646
- });
647
- var customerId = Number(discount === null || discount === void 0 ? void 0 : discount.customer_id);
648
- if (!Number.isFinite(customerId) || customerId <= 0) return null;
649
- return customerId;
663
+ var _iterator = _createForOfIteratorHelper(discounts),
664
+ _step;
665
+ try {
666
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
667
+ var item = _step.value;
668
+ var topLevelId = Number(item.customer_id);
669
+ if (Number.isFinite(topLevelId) && topLevelId > 0) {
670
+ return topLevelId;
671
+ }
672
+ }
673
+ } catch (err) {
674
+ _iterator.e(err);
675
+ } finally {
676
+ _iterator.f();
677
+ }
678
+ return null;
650
679
  }
651
680
  }, {
652
681
  key: "resolveCustomerByDiscountCustomerId",
@@ -1501,7 +1530,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1501
1530
  void this.store.order.recalculateSummary({
1502
1531
  createIfMissing: true
1503
1532
  }).then(function () {
1504
- return _this3.store.order.persistTempOrder();
1533
+ var _discountModule$getDi;
1534
+ var tempOrder = _this3.store.order.ensureTempOrder();
1535
+ _this3.store.order.persistTempOrder();
1536
+ return _this3.effectsEmit('onDiscountApplied', {
1537
+ productList: tempOrder.products || [],
1538
+ discountList: (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [],
1539
+ selectedDiscountList: tempOrder.discount_list || [],
1540
+ tempOrder: tempOrder
1541
+ });
1505
1542
  }).catch(function (error) {
1506
1543
  console.error('Failed to recalculate summary after clearing customer:', error);
1507
1544
  });
@@ -1959,7 +1996,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1959
1996
  }, {
1960
1997
  key: "getBookingConfig",
1961
1998
  value: function getBookingConfig() {
1962
- return this.store.bookingContext.getBookingConfig();
1999
+ var _this$store$bookingCo;
2000
+ return (_this$store$bookingCo = this.store.bookingContext) === null || _this$store$bookingCo === void 0 ? void 0 : _this$store$bookingCo.getBookingConfig();
1963
2001
  }
1964
2002
 
1965
2003
  /** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
@@ -2468,7 +2506,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2468
2506
  var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(input) {
2469
2507
  var _this7 = this,
2470
2508
  _input$bookingPatch;
2471
- var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator, _step, line;
2509
+ var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator2, _step2, line;
2472
2510
  return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2473
2511
  while (1) switch (_context30.prev = _context30.next) {
2474
2512
  case 0:
@@ -2508,15 +2546,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2508
2546
  }));
2509
2547
  case 11:
2510
2548
  result = [];
2511
- _iterator = _createForOfIteratorHelper(orderLines);
2549
+ _iterator2 = _createForOfIteratorHelper(orderLines);
2512
2550
  _context30.prev = 13;
2513
- _iterator.s();
2551
+ _iterator2.s();
2514
2552
  case 15:
2515
- if ((_step = _iterator.n()).done) {
2553
+ if ((_step2 = _iterator2.n()).done) {
2516
2554
  _context30.next = 29;
2517
2555
  break;
2518
2556
  }
2519
- line = _step.value;
2557
+ line = _step2.value;
2520
2558
  _context30.t0 = result.splice;
2521
2559
  _context30.t1 = result;
2522
2560
  _context30.t2 = [0, result.length];
@@ -2537,10 +2575,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2537
2575
  case 31:
2538
2576
  _context30.prev = 31;
2539
2577
  _context30.t7 = _context30["catch"](13);
2540
- _iterator.e(_context30.t7);
2578
+ _iterator2.e(_context30.t7);
2541
2579
  case 34:
2542
2580
  _context30.prev = 34;
2543
- _iterator.f();
2581
+ _iterator2.f();
2544
2582
  return _context30.finish(34);
2545
2583
  case 37:
2546
2584
  return _context30.abrupt("return", result);
@@ -2567,16 +2605,18 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2567
2605
  while (1) switch (_context31.prev = _context31.next) {
2568
2606
  case 0:
2569
2607
  _ref19 = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : {}, _ref19$cover = _ref19.cover, cover = _ref19$cover === void 0 ? false : _ref19$cover;
2570
- _get(_getPrototypeOf(BookingTicketImpl.prototype), "setOtherParams", this).call(this, params, {
2608
+ _context31.next = 3;
2609
+ return _get(_getPrototypeOf(BookingTicketImpl.prototype), "setOtherParams", this).call(this, params, {
2571
2610
  cover: cover
2572
2611
  });
2573
- if (!(params !== null && params !== void 0 && params.businessCode)) {
2574
- _context31.next = 5;
2612
+ case 3:
2613
+ if (!((params === null || params === void 0 ? void 0 : params.businessCode) !== undefined || (params === null || params === void 0 ? void 0 : params.business_code) !== undefined)) {
2614
+ _context31.next = 6;
2575
2615
  break;
2576
2616
  }
2577
- _context31.next = 5;
2617
+ _context31.next = 6;
2578
2618
  return this.configureIdGeneratorFromOpenData();
2579
- case 5:
2619
+ case 6:
2580
2620
  case "end":
2581
2621
  return _context31.stop();
2582
2622
  }
@@ -83,6 +83,8 @@ export interface ILoadProductsParams {
83
83
  extension_type?: string[];
84
84
  /** 商品发布状态 */
85
85
  status?: string;
86
+ /** 智能定价条件上下文,仅影响策略命中,不参与商品集合筛选 */
87
+ strategy_context?: Record<string, any>;
86
88
  }
87
89
  /**
88
90
  * 加载商品详情的参数
@@ -83,6 +83,7 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
83
83
  private getBookingAppointmentStatus;
84
84
  private isBookingIncludedInStats;
85
85
  private getBookingOrderPaymentStatus;
86
+ private isUnpaidBooking;
86
87
  private countBookingOrders;
87
88
  private countCompletedBookings;
88
89
  private groupBookingsByResource;
@@ -29,6 +29,7 @@ import dayjs from 'dayjs';
29
29
  import { BaseModule } from "../../modules/BaseModule";
30
30
  import { SalesHooks } from "./types";
31
31
  export * from "./types";
32
+ var UNPAID_PAYMENT_STATUSES = new Set(['unpaid', 'partially_paid', 'payment_processing']);
32
33
 
33
34
  /**
34
35
  * Sales 解决方案基础骨架
@@ -415,6 +416,11 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
415
416
  var _booking$order$paymen, _booking$order;
416
417
  return String((_booking$order$paymen = (_booking$order = booking.order) === null || _booking$order === void 0 ? void 0 : _booking$order.payment_status) !== null && _booking$order$paymen !== void 0 ? _booking$order$paymen : '');
417
418
  }
419
+ }, {
420
+ key: "isUnpaidBooking",
421
+ value: function isUnpaidBooking(booking) {
422
+ return UNPAID_PAYMENT_STATUSES.has(this.getBookingOrderPaymentStatus(booking));
423
+ }
418
424
  }, {
419
425
  key: "countBookingOrders",
420
426
  value: function countBookingOrders(bookings) {
@@ -895,9 +901,11 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
895
901
  });
896
902
  completedBookingList = matchedBookingList.filter(function (booking) {
897
903
  return _this7.getBookingAppointmentStatus(booking) === 'completed';
898
- });
904
+ }); // const unpaidBookingList = matchedBookingList.filter(
905
+ // (booking) => this.getBookingOrderPaymentStatus(booking) === 'unpaid' || this.getBookingOrderPaymentStatus(booking) === 'payment_processing',
906
+ // );
899
907
  unpaidBookingList = matchedBookingList.filter(function (booking) {
900
- return _this7.getBookingOrderPaymentStatus(booking) === 'unpaid' || _this7.getBookingOrderPaymentStatus(booking) === 'payment_processing';
908
+ return _this7.isUnpaidBooking(booking);
901
909
  });
902
910
  bookings = this.pickBookingsForCurrentPoint(current, this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList));
903
911
  completedBookings = completedBookingList.map(function (booking) {