@pisell/pisellos 2.2.178 → 2.2.180

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 (182) hide show
  1. package/dist/modules/Customer/index.d.ts +0 -6
  2. package/dist/modules/Customer/index.js +83 -129
  3. package/dist/modules/Customer/types.d.ts +0 -2
  4. package/dist/modules/Discount/index.d.ts +4 -2
  5. package/dist/modules/Discount/index.js +93 -8
  6. package/dist/modules/Discount/types.d.ts +7 -1
  7. package/dist/modules/Order/index.d.ts +17 -87
  8. package/dist/modules/Order/index.js +501 -1357
  9. package/dist/modules/Order/types.d.ts +19 -198
  10. package/dist/modules/Order/types.js +0 -31
  11. package/dist/modules/Order/utils.d.ts +1 -50
  12. package/dist/modules/Order/utils.js +32 -261
  13. package/dist/modules/Quotation/index.d.ts +1 -0
  14. package/dist/modules/Quotation/index.js +21 -23
  15. package/dist/modules/Rules/index.d.ts +0 -4
  16. package/dist/modules/Rules/index.js +10 -26
  17. package/dist/modules/SalesSummary/index.js +2 -4
  18. package/dist/modules/SalesSummary/utils.js +7 -21
  19. package/dist/modules/Schedule/index.js +2 -6
  20. package/dist/modules/index.d.ts +0 -1
  21. package/dist/modules/index.js +1 -2
  22. package/dist/server/index.js +29 -87
  23. package/dist/server/modules/order/index.d.ts +0 -23
  24. package/dist/server/modules/order/index.js +46 -123
  25. package/dist/server/modules/order/types.d.ts +2 -0
  26. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  27. package/dist/server/modules/products/index.d.ts +1 -1
  28. package/dist/server/modules/products/index.js +113 -130
  29. package/dist/server/modules/schedule/index.js +6 -13
  30. package/dist/solution/BaseSales/index.d.ts +7 -89
  31. package/dist/solution/BaseSales/index.js +375 -1494
  32. package/dist/solution/BaseSales/types.d.ts +1 -67
  33. package/dist/solution/BaseSales/types.js +1 -3
  34. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
  35. package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  36. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
  37. package/dist/solution/BaseSales/utils.js +8 -46
  38. package/dist/solution/BookingByStep/index.d.ts +1 -1
  39. package/dist/solution/BookingTicket/index.d.ts +1 -133
  40. package/dist/solution/BookingTicket/index.js +175 -780
  41. package/dist/solution/BookingTicket/types.d.ts +0 -2
  42. package/dist/solution/BookingTicket/types.js +0 -3
  43. package/dist/solution/BookingTicket/utils/cartView.js +2 -4
  44. package/dist/solution/ScanOrder/index.d.ts +3 -9
  45. package/dist/solution/ScanOrder/index.js +128 -231
  46. package/dist/solution/ScanOrder/utils.js +8 -46
  47. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  48. package/dist/solution/ShopDiscount/index.js +23 -18
  49. package/dist/solution/VenueBooking/index.d.ts +9 -5
  50. package/dist/solution/VenueBooking/index.js +55 -103
  51. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  52. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  53. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  54. package/lib/modules/Customer/index.d.ts +0 -6
  55. package/lib/modules/Customer/index.js +11 -26
  56. package/lib/modules/Customer/types.d.ts +0 -2
  57. package/lib/modules/Discount/index.d.ts +4 -2
  58. package/lib/modules/Discount/index.js +63 -8
  59. package/lib/modules/Discount/types.d.ts +7 -1
  60. package/lib/modules/Order/index.d.ts +17 -87
  61. package/lib/modules/Order/index.js +150 -677
  62. package/lib/modules/Order/types.d.ts +19 -198
  63. package/lib/modules/Order/types.js +0 -1
  64. package/lib/modules/Order/utils.d.ts +1 -50
  65. package/lib/modules/Order/utils.js +22 -229
  66. package/lib/modules/Quotation/index.d.ts +1 -0
  67. package/lib/modules/Quotation/index.js +15 -18
  68. package/lib/modules/Rules/index.d.ts +0 -4
  69. package/lib/modules/Rules/index.js +14 -22
  70. package/lib/modules/SalesSummary/index.js +2 -4
  71. package/lib/modules/SalesSummary/utils.js +7 -21
  72. package/lib/modules/Schedule/index.js +1 -3
  73. package/lib/modules/index.d.ts +0 -1
  74. package/lib/modules/index.js +1 -3
  75. package/lib/server/index.js +4 -41
  76. package/lib/server/modules/order/index.d.ts +0 -23
  77. package/lib/server/modules/order/index.js +14 -46
  78. package/lib/server/modules/order/types.d.ts +2 -0
  79. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  80. package/lib/server/modules/products/index.d.ts +1 -1
  81. package/lib/server/modules/products/index.js +20 -30
  82. package/lib/server/modules/schedule/index.js +1 -2
  83. package/lib/solution/BaseSales/index.d.ts +7 -89
  84. package/lib/solution/BaseSales/index.js +22 -736
  85. package/lib/solution/BaseSales/types.d.ts +1 -67
  86. package/lib/solution/BaseSales/types.js +1 -3
  87. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
  88. package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -0
  89. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
  90. package/lib/solution/BaseSales/utils.js +6 -46
  91. package/lib/solution/BookingByStep/index.d.ts +1 -1
  92. package/lib/solution/BookingTicket/index.d.ts +1 -133
  93. package/lib/solution/BookingTicket/index.js +8 -352
  94. package/lib/solution/BookingTicket/types.d.ts +0 -2
  95. package/lib/solution/BookingTicket/types.js +0 -6
  96. package/lib/solution/BookingTicket/utils/cartView.js +2 -4
  97. package/lib/solution/ScanOrder/index.d.ts +3 -9
  98. package/lib/solution/ScanOrder/index.js +66 -147
  99. package/lib/solution/ScanOrder/utils.js +6 -46
  100. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  101. package/lib/solution/ShopDiscount/index.js +4 -2
  102. package/lib/solution/VenueBooking/index.d.ts +9 -5
  103. package/lib/solution/VenueBooking/index.js +14 -50
  104. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  105. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  106. package/package.json +2 -2
  107. package/dist/modules/BookingContext/index.d.ts +0 -37
  108. package/dist/modules/BookingContext/index.js +0 -436
  109. package/dist/modules/BookingContext/types.d.ts +0 -102
  110. package/dist/modules/BookingContext/types.js +0 -51
  111. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  112. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  113. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  114. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  115. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  116. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  117. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  118. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  119. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  120. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  121. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  122. package/dist/modules/BookingContext/utils/index.js +0 -11
  123. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  124. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  125. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  126. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  127. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  128. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  129. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  130. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  131. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  132. package/dist/modules/BookingContext/utils/resources.js +0 -486
  133. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  134. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  135. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  136. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  137. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  138. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  139. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
  140. package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1258
  141. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  142. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  143. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  144. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  145. package/lib/modules/BookingContext/index.d.ts +0 -37
  146. package/lib/modules/BookingContext/index.js +0 -297
  147. package/lib/modules/BookingContext/types.d.ts +0 -102
  148. package/lib/modules/BookingContext/types.js +0 -34
  149. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  150. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  151. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  152. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  153. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  154. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  155. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  156. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  157. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  158. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  159. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  160. package/lib/modules/BookingContext/utils/index.js +0 -43
  161. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  162. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  163. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  164. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  165. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  166. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  167. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  168. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  169. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  170. package/lib/modules/BookingContext/utils/resources.js +0 -377
  171. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  172. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  173. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  174. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  175. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  176. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  177. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
  178. package/lib/solution/BaseSales/utils/cartPromotion.js +0 -836
  179. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  180. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  181. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  182. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
@@ -89,45 +89,13 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
89
89
  moduleName: "scanOrder"
90
90
  };
91
91
  }
92
- safeStringify(value) {
93
- try {
94
- return JSON.stringify(value);
95
- } catch {
96
- return void 0;
97
- }
98
- }
99
- pickErrorMessage(error) {
100
- var _a, _b, _c, _d;
101
- const candidates = [
102
- error.message,
103
- (_a = error.data) == null ? void 0 : _a.message,
104
- (_c = (_b = error.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message,
105
- (_d = error.error) == null ? void 0 : _d.message
106
- ];
107
- for (const candidate of candidates) {
108
- if (typeof candidate === "string" && candidate.trim())
109
- return candidate;
110
- }
111
- return void 0;
112
- }
113
92
  serializeError(error) {
114
93
  if (error instanceof Error) {
115
- return {
94
+ return JSON.stringify({
116
95
  name: error.name,
117
96
  message: error.message,
118
97
  stack: error.stack
119
- };
120
- }
121
- if (error && typeof error === "object") {
122
- const raw = error;
123
- const message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
124
- return {
125
- ...typeof raw.name === "string" ? { name: raw.name } : {},
126
- message,
127
- ..."code" in raw ? { code: raw.code } : {},
128
- ..."status" in raw ? { status: raw.status } : {},
129
- ...this.safeStringify(raw) ? { raw: this.safeStringify(raw) } : {}
130
- };
98
+ });
131
99
  }
132
100
  return {
133
101
  message: String(error)
@@ -187,14 +155,6 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
187
155
  }
188
156
  });
189
157
  }
190
- assertProductListLoaded(method, result, payload = {}) {
191
- if (Array.isArray(result))
192
- return result;
193
- const error = result instanceof Error ? result : new Error("商品列表接口返回异常");
194
- this.logMethodError(method, error, payload);
195
- error.__scanOrderLogged = true;
196
- throw error;
197
- }
198
158
  async addLog(params) {
199
159
  await this.addScanOrderLog({
200
160
  ...params,
@@ -359,13 +319,13 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
359
319
  if (targetModule) {
360
320
  this.store[step] = targetModule;
361
321
  const initialState = step === "salesSummary" ? {
322
+ // TODO(Order types): ScanOrder runtime should read OrderState.summary instead of tempOrder.summary.
362
323
  summary: ((_b2 = (_a2 = this.store.order) == null ? void 0 : _a2.getTempOrder()) == null ? void 0 : _b2.summary) || (0, import_utils.createEmptySummary)()
363
324
  } : {};
364
325
  const loggerProvider = ((_c2 = this.otherParams) == null ? void 0 : _c2.scanOrderLoggerProvider) || "feishu";
365
326
  const loggerConfig = ((_d2 = this.otherParams) == null ? void 0 : _d2.scanOrderLoggerConfig) || {
366
327
  feishu: {
367
- webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed",
368
- errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f"
328
+ webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed"
369
329
  }
370
330
  };
371
331
  this.core.registerModule(targetModule, {
@@ -787,34 +747,6 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
787
747
  throw error;
788
748
  }
789
749
  }
790
- findReservationRuleResource(formId) {
791
- var _a;
792
- if (formId == null)
793
- return void 0;
794
- const numericFormId = Number(formId);
795
- if (!Number.isFinite(numericFormId) || numericFormId <= 0)
796
- return void 0;
797
- for (const product of this.enabledReservationRuleProducts) {
798
- const resources = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources;
799
- if (!Array.isArray(resources))
800
- continue;
801
- const matched = resources.find((resource) => Number(resource == null ? void 0 : resource.id) === numericFormId);
802
- if (matched)
803
- return matched;
804
- }
805
- return void 0;
806
- }
807
- buildScanOrderResourceMetadata(params) {
808
- const { resourceState, resourceName } = params;
809
- const ruleResource = this.findReservationRuleResource(resourceState.tableFormId);
810
- const combined = ruleResource == null ? void 0 : ruleResource.combined_resource;
811
- const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
812
- return {
813
- form_name: (ruleResource == null ? void 0 : ruleResource.title) ?? "",
814
- resource_name: resourceName,
815
- combined_resource: isCombined ? combined : null
816
- };
817
- }
818
750
  // ScanOrder 提交 payload enhancer:
819
751
  // - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
820
752
  // - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
@@ -838,9 +770,6 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
838
770
  return (payload, { bookingUuid, tempOrder }) => {
839
771
  var _a, _b;
840
772
  const resourceId = tempOrder.resource_id ?? (resourceState == null ? void 0 : resourceState.relationId);
841
- const rawCollectPax = (_a = tempOrder.metadata) == null ? void 0 : _a.collect_pax;
842
- const hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== void 0 && rawCollectPax !== "";
843
- const resourceCapacityValue = hasCollectPaxForCapacity ? (0, import_utils2.normalizeSubmitCollectPaxValue)(rawCollectPax) : resolveResourceCapacity();
844
773
  const pickOriginal = (value) => {
845
774
  if (value && typeof value === "object" && !Array.isArray(value)) {
846
775
  const original = value.original;
@@ -848,7 +777,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
848
777
  }
849
778
  return void 0;
850
779
  };
851
- const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal((_b = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _b.name) ?? "";
780
+ const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal((_a = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _a.name) ?? "";
852
781
  const resourceEntry = resourceState && resourceId ? {
853
782
  relation_type: "form",
854
783
  like_status: "common",
@@ -856,35 +785,37 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
856
785
  main_field: mainField,
857
786
  form_id: resourceState.tableFormId,
858
787
  relation_id: resourceState.relationId ?? resourceId,
859
- capacity: resourceCapacityValue,
860
- metadata: this.buildScanOrderResourceMetadata({
861
- resourceState,
862
- resourceName: mainField
863
- })
788
+ capacity: resolveResourceCapacity(),
789
+ metadata: {}
864
790
  } : void 0;
865
791
  const ruleProductUid = ruleProduct ? (0, import_utils2.createUuidV4)() : void 0;
866
- const bookingCapacityValue = resourceCapacityValue;
792
+ const rawCollectPax = (_b = tempOrder.metadata) == null ? void 0 : _b.collect_pax;
793
+ const hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== void 0 && rawCollectPax !== "";
794
+ const bookingCapacityValue = hasCollectPaxForCapacity ? (0, import_utils2.normalizeSubmitCollectPaxValue)(rawCollectPax) : resolveResourceCapacity();
867
795
  const bookingCapacityDimensionId = (0, import_utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
868
- const nextBookings = (payload.bookings || []).map((booking, idx) => ({
869
- ...booking,
870
- number: bookingCapacityValue,
871
- appointment_status: "started",
872
- metadata: {
873
- ...booking.metadata || {},
874
- ...resourceSelectType ? { resource_select_type: resourceSelectType } : {},
875
- ...resourceSelectType ? {
876
- capacity: [
877
- {
878
- id: bookingCapacityDimensionId,
879
- value: bookingCapacityValue,
880
- name: ""
881
- }
882
- ]
883
- } : {}
884
- },
885
- ...idx === 0 && resourceEntry ? { resources: [resourceEntry] } : {},
886
- ...idx === 0 && ruleProductUid ? { product_uid: ruleProductUid } : {}
887
- }));
796
+ const nextBookings = (payload.bookings || []).map((booking, idx) => {
797
+ var _a2;
798
+ return {
799
+ ...booking,
800
+ appointment_status: "started",
801
+ metadata: {
802
+ ...booking.metadata || {},
803
+ holder_id: ((_a2 = booking.metadata) == null ? void 0 : _a2.holder_id) ?? null,
804
+ ...resourceSelectType ? { resource_select_type: resourceSelectType } : {},
805
+ ...resourceSelectType ? {
806
+ capacity: [
807
+ {
808
+ id: bookingCapacityDimensionId,
809
+ value: bookingCapacityValue,
810
+ name: ""
811
+ }
812
+ ]
813
+ } : {}
814
+ },
815
+ ...idx === 0 && resourceEntry ? { resources: [resourceEntry] } : {},
816
+ ...idx === 0 && ruleProductUid ? { product_uid: ruleProductUid } : {}
817
+ };
818
+ });
888
819
  const nextProducts = [...payload.products || []];
889
820
  if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
890
821
  const sellingPrice = String(ruleProduct.price ?? "0.00");
@@ -972,23 +903,23 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
972
903
  throw error;
973
904
  }
974
905
  }
975
- async updateOrderProduct(params) {
976
- this.logMethodStart("updateOrderProduct", {
906
+ async updateProductInOrder(params) {
907
+ this.logMethodStart("updateProductInOrder", {
977
908
  product_id: params.product_id,
978
909
  product_variant_id: params.product_variant_id
979
910
  });
980
911
  try {
981
912
  if (!this.store.order)
982
913
  throw new Error("order 模块未初始化");
983
- const products = await this.store.order.updateOrderProduct(params);
914
+ const products = await this.store.order.updateProductInOrder(params);
984
915
  await this.refreshItemRuleQuantityLimits();
985
916
  await this.refreshCartValidationPassed();
986
- this.logMethodSuccess("updateOrderProduct", {
917
+ this.logMethodSuccess("updateProductInOrder", {
987
918
  productCount: products.length
988
919
  });
989
920
  return products;
990
921
  } catch (error) {
991
- this.logMethodError("updateOrderProduct", error);
922
+ this.logMethodError("updateProductInOrder", error);
992
923
  throw error;
993
924
  }
994
925
  }
@@ -1007,14 +938,15 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1007
938
  product_variant_id: identity.product_variant_id,
1008
939
  updates: { note: String(note || "") }
1009
940
  };
1010
- if (identity.identity_key !== void 0)
941
+ if (identity.identity_key !== void 0) {
1011
942
  params.identity_key = identity.identity_key;
943
+ }
1012
944
  if (identity.product_option_item !== void 0) {
1013
945
  params.product_option_item = identity.product_option_item;
1014
946
  }
1015
947
  if (identity.product_bundle !== void 0)
1016
948
  params.product_bundle = identity.product_bundle;
1017
- const products = await this.updateOrderProduct(params);
949
+ const products = await this.updateProductInOrder(params);
1018
950
  this.logMethodSuccess("setOrderProductLineNote", { productCount: products.length });
1019
951
  return products;
1020
952
  } catch (error) {
@@ -1276,6 +1208,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1276
1208
  item_rule_prefill: true,
1277
1209
  item_rule_id: prefillItem.ruleId
1278
1210
  },
1211
+ // TODO(Order types): migrate ScanOrder prefill origin runtime into tempOrder._extend.
1279
1212
  _origin: sourceItem ? {
1280
1213
  ...targetProduct._origin || {},
1281
1214
  ...sourceItem
@@ -1500,17 +1433,14 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1500
1433
  // 通过 resource_id + 店铺配置
1501
1434
  // hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
1502
1435
  async checkResourceAvailable(resourceId, hasOrderId) {
1503
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1436
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
1504
1437
  this.logMethodStart("checkResourceAvailable", {
1505
1438
  resourceId
1506
1439
  });
1507
1440
  try {
1508
- const businessCode = String(((_a = this.otherParams) == null ? void 0 : _a.businessCode) ?? "").trim();
1509
- const channel = String(((_b = this.otherParams) == null ? void 0 : _b.channel) ?? "").trim();
1510
- const openDataTarget = businessCode && channel ? `${businessCode}+${channel}` : "dine_in+scan_to_order";
1511
- const openData = await ((_d = (_c = this.otherParams) == null ? void 0 : _c.getOpenData) == null ? void 0 : _d.call(_c, {
1441
+ const openData = await ((_b = (_a = this.otherParams) == null ? void 0 : _a.getOpenData) == null ? void 0 : _b.call(_a, {
1512
1442
  scope: "board",
1513
- target: openDataTarget,
1443
+ target: "dine_in+scan_to_order",
1514
1444
  section_code: ["basic", "fulfillment", "reservation", "sale", "menu", "availability", "workflow"]
1515
1445
  }));
1516
1446
  if ((openData == null ? void 0 : openData.status) === false) {
@@ -1601,13 +1531,13 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1601
1531
  }
1602
1532
  } else {
1603
1533
  this.enabledReservationRuleProducts = [];
1604
- const error = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
1605
- this.logMethodError("loadReservationRuleProducts", error, {
1606
- resourceId,
1607
- reservationLinkIds,
1608
- scheduleDate,
1609
- scheduleDatetime,
1610
- cacheId: this.cacheId
1534
+ void this.addScanOrderLog({
1535
+ level: "error",
1536
+ title: "[ScanOrder] enabled_reservation_rules product query failed",
1537
+ payload: {
1538
+ linkIds: reservationLinkIds,
1539
+ error: this.serializeError(loaded)
1540
+ }
1611
1541
  });
1612
1542
  }
1613
1543
  }
@@ -1637,16 +1567,16 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1637
1567
  table_form_id: resourceState.tableFormId,
1638
1568
  deskmate_valid: resourceState.deskmate_valid,
1639
1569
  table_form_record: resourceState.table_form_record,
1640
- policy: (_e = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _e.policy,
1641
- partyroom_booking: (_f = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _f.partyroom_booking,
1570
+ policy: (_c = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _c.policy,
1571
+ partyroom_booking: (_d = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _d.partyroom_booking,
1642
1572
  ...this.store.resource.requestEntryPax !== void 0 ? { requestEntryPax: this.store.resource.requestEntryPax } : {},
1643
1573
  ...this.store.resource.requestPaxMin !== void 0 ? { requestPaxMin: this.store.resource.requestPaxMin } : {},
1644
1574
  ...this.store.resource.requestPaxMax !== void 0 ? { requestPaxMax: this.store.resource.requestPaxMax } : {}
1645
1575
  };
1646
- tempOrder.relation_id = resourceId || ((_g = this.otherParams) == null ? void 0 : _g.relation_id);
1576
+ tempOrder.relation_id = resourceId || ((_e = this.otherParams) == null ? void 0 : _e.relation_id);
1647
1577
  tempOrder.table_form_id = resourceState.tableFormId;
1648
1578
  tempOrder.resource_id = resourceId;
1649
- (_h = this.store.order) == null ? void 0 : _h.persistTempOrder();
1579
+ (_f = this.store.order) == null ? void 0 : _f.persistTempOrder();
1650
1580
  if (availabilityInfo.mode === "idle") {
1651
1581
  await this.addNewOrder();
1652
1582
  }
@@ -1654,16 +1584,16 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1654
1584
  tempOrder.order_id = resourceState.lastOrderId;
1655
1585
  }
1656
1586
  if (tempOrder.order_id) {
1657
- const res = await ((_i = this.store.order) == null ? void 0 : _i.getOrderInfoByRemote(tempOrder.order_id));
1658
- const entryPaxNumber = (_m = (_l = (_k = (_j = res == null ? void 0 : res.data) == null ? void 0 : _j.bookings) == null ? void 0 : _k.find((p) => {
1587
+ const res = await ((_g = this.store.order) == null ? void 0 : _g.getOrderInfoByRemote(tempOrder.order_id));
1588
+ const entryPaxNumber = (_k = (_j = (_i = (_h = res == null ? void 0 : res.data) == null ? void 0 : _h.bookings) == null ? void 0 : _i.find((p) => {
1659
1589
  var _a2;
1660
1590
  return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
1661
- })) == null ? void 0 : _l.metadata) == null ? void 0 : _m.collect_pax;
1591
+ })) == null ? void 0 : _j.metadata) == null ? void 0 : _k.collect_pax;
1662
1592
  if (entryPaxNumber) {
1663
1593
  await this.setEntryPaxNumber(entryPaxNumber);
1664
1594
  }
1665
1595
  }
1666
- const lastOrderInfo = (_o = (_n = this.store.order) == null ? void 0 : _n.getLastOrderInfo) == null ? void 0 : _o.call(_n);
1596
+ const lastOrderInfo = (_m = (_l = this.store.order) == null ? void 0 : _l.getLastOrderInfo) == null ? void 0 : _m.call(_l);
1667
1597
  const historicalItems = hasOrderId && Array.isArray(lastOrderInfo == null ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce((acc, p) => {
1668
1598
  if (typeof (p == null ? void 0 : p.product_id) !== "number")
1669
1599
  return acc;
@@ -1675,7 +1605,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1675
1605
  return acc;
1676
1606
  }, []) : [];
1677
1607
  await this.setItemRuleRuntimeConfig({
1678
- serviceType: (_p = this.otherParams) == null ? void 0 : _p.businessCode,
1608
+ serviceType: (_n = this.otherParams) == null ? void 0 : _n.businessCode,
1679
1609
  submissionIndex: hasOrderId ? 1 : 0,
1680
1610
  historicalItems
1681
1611
  });
@@ -1723,24 +1653,18 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1723
1653
  }
1724
1654
  // 获取商品列表
1725
1655
  async getProductList() {
1726
- var _a, _b;
1656
+ var _a, _b, _c;
1727
1657
  this.logMethodStart("getProductList");
1728
1658
  const menu_list_ids = ((_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["menu.associated_menus"].map((n) => Number(n.value))) || [];
1729
1659
  try {
1730
- if (!this.store.products)
1731
- throw new Error("products 模块未初始化");
1732
- const res = await this.store.products.loadProducts({
1660
+ const res = await ((_c = this.store.products) == null ? void 0 : _c.loadProducts({
1733
1661
  menu_list_ids,
1734
1662
  cacheId: this.cacheId,
1735
1663
  schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
1736
1664
  schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
1737
- });
1738
- const productList = this.assertProductListLoaded("getProductList", res, {
1739
- menu_list_ids,
1740
- cacheId: this.cacheId
1741
- });
1665
+ }));
1742
1666
  const formattedRes = (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
1743
- productList,
1667
+ res,
1744
1668
  this.store.itemRuleQuantityLimits || []
1745
1669
  );
1746
1670
  this.logMethodSuccess("getProductList", {
@@ -1748,12 +1672,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1748
1672
  });
1749
1673
  return formattedRes;
1750
1674
  } catch (error) {
1751
- if (!(error == null ? void 0 : error.__scanOrderLogged)) {
1752
- this.logMethodError("getProductList", error, {
1753
- menu_list_ids,
1754
- cacheId: this.cacheId
1755
- });
1756
- }
1675
+ this.logMethodError("getProductList", error.message);
1757
1676
  throw error;
1758
1677
  }
1759
1678
  }
@@ -63,7 +63,6 @@ module.exports = __toCommonJS(utils_exports);
63
63
  var import_dayjs = __toESM(require("dayjs"));
64
64
  var import_decimal = __toESM(require("decimal.js"));
65
65
  var import_utils = require("../../modules/Order/utils");
66
- var import_manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
67
66
  function createEmptySummary() {
68
67
  return {
69
68
  product_quantity: 0,
@@ -407,40 +406,12 @@ function getProductIdentityIndex(products, identity) {
407
406
  return products.findIndex((item) => isIdentityMatch(item, identity));
408
407
  }
409
408
  function normalizeOrderProduct(product) {
410
- var _a, _b, _c, _d, _e, _f;
409
+ var _a, _b, _c;
411
410
  const metadata = { ...product.metadata || {} };
412
411
  const resolvedIdentityKey = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? String(product.metadata.unique_identification_number) : product.unique_identification_number && String(product.unique_identification_number).length > 0 ? String(product.unique_identification_number) : product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : (0, import_utils.createUuidV4)();
413
412
  metadata.unique_identification_number = resolvedIdentityKey;
414
- const priceOverride = metadata.price_override;
415
- const originOtherBundle = (_d = (_c = (_b = metadata.origin) == null ? void 0 : _b._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.bundle;
416
- let bundleInput = product.product_bundle || [];
417
- if (priceOverride !== void 0 && priceOverride !== null && priceOverride !== "" && Array.isArray(originOtherBundle) && originOtherBundle.length > 0) {
418
- const priceById = /* @__PURE__ */ new Map();
419
- originOtherBundle.forEach((item) => {
420
- if ((item == null ? void 0 : item.id) == null)
421
- return;
422
- const unit = item.price ?? item.bundle_selling_price;
423
- if (unit === void 0 || unit === null)
424
- return;
425
- priceById.set(String(item.id), String(unit));
426
- });
427
- const base = Array.isArray(bundleInput) && bundleInput.length > 0 ? bundleInput : originOtherBundle;
428
- bundleInput = base.map((item) => {
429
- const unit = priceById.get(String(item == null ? void 0 : item.id));
430
- if (unit === void 0)
431
- return item;
432
- return {
433
- ...item,
434
- price: unit,
435
- bundle_selling_price: unit
436
- };
437
- });
438
- }
439
- const normalizedBundle = bundleInput.map((item) => ({
413
+ const normalizedBundle = (product.product_bundle || []).map((item) => ({
440
414
  ...item,
441
- bundle_id: item.bundle_id ?? item.id,
442
- bundle_product_id: item.bundle_product_id ?? item._bundle_product_id,
443
- bundle_group_id: item.bundle_group_id ?? item.group_id,
444
415
  bundle_selling_price: item.bundle_selling_price ?? item.price ?? "0.00",
445
416
  price: item.price ?? item.custom_price ?? item.bundle_selling_price ?? "0.00",
446
417
  price_type: item.price_type ?? item.custom_price_type ?? "",
@@ -450,8 +421,8 @@ function normalizeOrderProduct(product) {
450
421
  const optionSum = (0, import_utils.sumOptionUnitPrice)(normalizedOptions);
451
422
  const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === "2";
452
423
  const variantId = Number(product.product_variant_id || 0);
453
- const variantList = variantId ? (_e = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _e.variant : null;
454
- const variantPrice = Array.isArray(variantList) ? (_f = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _f.price : void 0;
424
+ const variantList = variantId ? (_b = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _b.variant : null;
425
+ const variantPrice = Array.isArray(variantList) ? (_c = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _c.price : void 0;
455
426
  const resolvedSource = (() => {
456
427
  var _a2, _b2;
457
428
  if (metadata.source_product_price !== void 0) {
@@ -507,17 +478,6 @@ function normalizeOrderProduct(product) {
507
478
  bundle: normalizedBundle,
508
479
  useOriginalBundle: true
509
480
  });
510
- const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
511
- { num: product.num, metadata, lineOriginalPrice: product.original_price },
512
- composedOriginalPrice
513
- );
514
- const discountList = (0, import_manualProductDiscount.ensureManualProductDiscountList)({
515
- discountList: product.discount_list,
516
- metadata,
517
- originalPrice: finalOriginalPrice,
518
- sellingPrice: composedSellingPrice,
519
- quantity: getSafeProductNum(product.num)
520
- });
521
481
  return {
522
482
  order_detail_id: product.order_detail_id || null,
523
483
  product_id: product.product_id,
@@ -525,10 +485,10 @@ function normalizeOrderProduct(product) {
525
485
  product_variant_id: product.product_variant_id,
526
486
  product_option_item: normalizedOptions,
527
487
  selling_price: composedSellingPrice,
528
- original_price: finalOriginalPrice,
488
+ original_price: composedOriginalPrice,
529
489
  tax_fee: product.tax_fee || "0.00",
530
490
  is_charge_tax: product.is_charge_tax ?? 0,
531
- discount_list: discountList,
491
+ discount_list: product.discount_list || [],
532
492
  product_bundle: normalizedBundle,
533
493
  metadata,
534
494
  note: product.note != null ? String(product.note) : ""
@@ -46,6 +46,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
46
46
  discountList: Discount[];
47
47
  type: "server" | "clientCalc";
48
48
  unavailableReason?: UnavailableReason;
49
+ unavailableReasonKey?: string | null;
49
50
  }>;
50
51
  calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
51
52
  private getCustomer;
@@ -274,7 +274,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
274
274
  async scanCode(code, customerId) {
275
275
  var _a, _b, _c;
276
276
  try {
277
- const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId, orderId: this.store.orderId })) || [];
277
+ const resultDiscountWithReason = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId, orderId: this.store.orderId })) || { discountList: [], unavailableReasonKey: null };
278
+ const { discountList: resultDiscountList, unavailableReasonKey } = resultDiscountWithReason;
278
279
  const rulesModule = this.store.rules;
279
280
  if (!rulesModule) {
280
281
  return {
@@ -290,7 +291,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
290
291
  type: "server",
291
292
  isAvailable: false,
292
293
  productList: this.store.productList || [],
293
- discountList: this.getDiscountList()
294
+ discountList: this.getDiscountList(),
295
+ unavailableReasonKey
294
296
  };
295
297
  }
296
298
  const withScanList = resultDiscountList.map((item) => {
@@ -2,7 +2,7 @@ import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { VenueBookingAddLogParams, VenueBookingSlotConfig, VenueDateSummaryItem, VenueSlotSelection, VenueTimeSlotGrid } from './types';
4
4
  import type { ScanOrderOrderProduct, ScanOrderOrderProductIdentity } from '../ScanOrder/types';
5
- import type { UpdateOrderProductParams } from '../../modules/Order/types';
5
+ import type { UpdateProductInOrderParams } from '../../modules/Order/types';
6
6
  import type { OpenDataAvailabilityResult } from '../../modules/OpenData';
7
7
  import type { ProductData } from '../../modules/Product/types';
8
8
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
@@ -41,8 +41,6 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
41
41
  private loadOpenDataConfigInFlight;
42
42
  private static readonly OPEN_DATA_CACHE_TTL;
43
43
  private getLoggerContext;
44
- private safeStringify;
45
- private pickErrorMessage;
46
44
  private serializeError;
47
45
  private addVenueBookingLog;
48
46
  private logMethodStart;
@@ -150,7 +148,13 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
150
148
  customerId: number;
151
149
  }): Promise<void>;
152
150
  private recalculateOrderPricesFromQuotation;
153
- scanCode(code: string, customerId?: number): Promise<import("../../modules/Order/types").OrderScanCodeResult>;
151
+ scanCode(code: string, customerId?: number): Promise<{
152
+ isAvailable: boolean;
153
+ discountList: import("../../modules/Discount").Discount[];
154
+ type: "server" | "clientCalc";
155
+ unavailableReason?: import("../../modules/Rules/types").UnavailableReason | undefined;
156
+ unavailableReasonKey?: string | null | undefined;
157
+ }>;
154
158
  /** 获取当前折扣列表(包装 order.getDiscountList) */
155
159
  getDiscountList(): import("../../modules/Discount").Discount[];
156
160
  /** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
@@ -163,7 +167,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
163
167
  getSummary(): Promise<import("../../modules/Order/types").OrderSummary>;
164
168
  submitOrder<T = any>(): Promise<T>;
165
169
  addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
166
- updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
170
+ updateProductInOrder(params: UpdateProductInOrderParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
167
171
  removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
168
172
  getProductList(): Promise<ProductData[]>;
169
173
  private loadOpenDataConfig;