@pisell/pisellos 0.0.569 → 0.10.2

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 (328) hide show
  1. package/dist/core/index.js +10 -6
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -3
  4. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
  6. package/dist/model/strategy/adapter/walletPass/example.js +26 -3
  7. package/dist/model/strategy/adapter/walletPass/index.js +5 -5
  8. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
  9. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  10. package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
  11. package/dist/model/strategy/strategy-example.js +19 -5
  12. package/dist/modules/BaseModule.d.ts +1 -1
  13. package/dist/modules/BaseModule.js +8 -10
  14. package/dist/modules/Cart/index.js +3 -0
  15. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  16. package/dist/modules/Cart/utils/cartResource.js +0 -2
  17. package/dist/modules/Cart/utils/changePrice.js +9 -16
  18. package/dist/modules/Date/index.js +5 -1
  19. package/dist/modules/Discount/index.d.ts +0 -1
  20. package/dist/modules/Discount/index.js +7 -22
  21. package/dist/modules/Discount/types.d.ts +0 -1
  22. package/dist/modules/OpenData/index.js +2 -0
  23. package/dist/modules/Order/index.js +70 -40
  24. package/dist/modules/Payment/index.js +162 -97
  25. package/dist/modules/Payment/types.d.ts +4 -8
  26. package/dist/modules/Payment/walletpass.d.ts +0 -2
  27. package/dist/modules/Payment/walletpass.js +5 -4
  28. package/dist/modules/ProductList/index.d.ts +1 -1
  29. package/dist/modules/ProductList/index.js +3 -12
  30. package/dist/modules/ProductList/types.d.ts +0 -1
  31. package/dist/modules/Rules/index.js +126 -427
  32. package/dist/modules/SalesSummary/utils.js +1 -2
  33. package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
  34. package/dist/modules/Schedule/index.js +1 -0
  35. package/dist/modules/Schedule/utils.js +1 -0
  36. package/dist/modules/Step/index.js +1 -0
  37. package/dist/modules/Summary/utils.js +22 -43
  38. package/dist/plugins/request.js +4 -1
  39. package/dist/plugins/window.js +6 -2
  40. package/dist/server/index.js +129 -97
  41. package/dist/server/modules/menu/index.js +41 -32
  42. package/dist/server/modules/order/index.js +4 -2
  43. package/dist/server/modules/products/index.js +42 -24
  44. package/dist/server/modules/quotation/index.js +38 -29
  45. package/dist/server/modules/resource/index.js +4 -3
  46. package/dist/server/modules/schedule/index.js +35 -27
  47. package/dist/server/utils/product.js +1 -0
  48. package/dist/solution/BaseSales/index.js +41 -38
  49. package/dist/solution/BookingByStep/index.d.ts +1 -1
  50. package/dist/solution/BookingByStep/index.js +60 -11
  51. package/dist/solution/BookingByStep/utils/capacity.js +11 -1
  52. package/dist/solution/BookingByStep/utils/resources.js +3 -1
  53. package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
  54. package/dist/solution/BookingTicket/index.d.ts +1 -1
  55. package/dist/solution/BookingTicket/index.js +2 -0
  56. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
  57. package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
  58. package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
  59. package/dist/solution/BuyTickets/index.js +12 -9
  60. package/dist/solution/Checkout/index.js +252 -177
  61. package/dist/solution/Checkout/utils/index.js +16 -4
  62. package/dist/solution/RegisterAndLogin/index.js +76 -30
  63. package/dist/solution/ScanOrder/index.js +60 -50
  64. package/dist/solution/ShopDiscount/index.js +14 -15
  65. package/dist/solution/ShopDiscount/types.d.ts +4 -5
  66. package/dist/solution/ShopDiscount/utils.d.ts +0 -9
  67. package/dist/solution/ShopDiscount/utils.js +0 -9
  68. package/dist/solution/VenueBooking/index.d.ts +3 -31
  69. package/dist/solution/VenueBooking/index.js +496 -651
  70. package/dist/solution/VenueBooking/types.d.ts +1 -3
  71. package/dist/solution/VenueBooking/types.js +0 -1
  72. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  73. package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
  74. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  75. package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
  76. package/dist/types/index.d.ts +1 -1
  77. package/dist/utils/task.js +18 -15
  78. package/dist/utils/watch.js +1 -0
  79. package/lib/apis/picoding.js +0 -2
  80. package/lib/core/index.js +132 -130
  81. package/lib/effects/index.js +57 -46
  82. package/lib/index.d.ts +0 -1
  83. package/lib/index.js +50 -92
  84. package/lib/model/index.js +21 -14
  85. package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
  86. package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
  87. package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
  88. package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
  89. package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
  90. package/lib/model/strategy/adapter/index.js +64 -100
  91. package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
  92. package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
  93. package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
  94. package/lib/model/strategy/adapter/itemRule/index.js +57 -83
  95. package/lib/model/strategy/adapter/itemRule/type.js +36 -97
  96. package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
  97. package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
  98. package/lib/model/strategy/adapter/promotion/examples.js +159 -139
  99. package/lib/model/strategy/adapter/promotion/index.js +49 -1
  100. package/lib/model/strategy/adapter/promotion/type.js +35 -199
  101. package/lib/model/strategy/adapter/type.js +16 -4
  102. package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
  103. package/lib/model/strategy/adapter/walletPass/example.js +190 -217
  104. package/lib/model/strategy/adapter/walletPass/index.js +51 -75
  105. package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
  106. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
  107. package/lib/model/strategy/adapter/walletPass/type.js +16 -4
  108. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  109. package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
  110. package/lib/model/strategy/engine.js +168 -270
  111. package/lib/model/strategy/index.js +34 -49
  112. package/lib/model/strategy/strategy-example.js +239 -243
  113. package/lib/model/strategy/type.js +40 -100
  114. package/lib/modules/Account/index.js +53 -39
  115. package/lib/modules/Account/types.js +33 -20
  116. package/lib/modules/AccountList/index.js +154 -116
  117. package/lib/modules/AccountList/types.js +31 -30
  118. package/lib/modules/AccountList/utils.js +30 -18
  119. package/lib/modules/BaseModule.d.ts +1 -1
  120. package/lib/modules/BaseModule.js +46 -25
  121. package/lib/modules/BookingContext/index.js +136 -158
  122. package/lib/modules/BookingContext/types.js +32 -46
  123. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
  124. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
  125. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
  126. package/lib/modules/BookingContext/utils/flexible.js +55 -38
  127. package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
  128. package/lib/modules/BookingContext/utils/index.js +41 -124
  129. package/lib/modules/BookingContext/utils/noResource.js +70 -58
  130. package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
  131. package/lib/modules/BookingContext/utils/productExtend.js +155 -202
  132. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  133. package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
  134. package/lib/modules/BookingContext/utils/resources.js +167 -209
  135. package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
  136. package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
  137. package/lib/modules/Cart/index.js +124 -170
  138. package/lib/modules/Cart/types.js +51 -46
  139. package/lib/modules/Cart/utils/cartAccount.js +39 -40
  140. package/lib/modules/Cart/utils/cartDate.js +61 -56
  141. package/lib/modules/Cart/utils/cartDiscount.js +33 -28
  142. package/lib/modules/Cart/utils/cartNote.js +32 -27
  143. package/lib/modules/Cart/utils/cartProduct.js +251 -321
  144. package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
  145. package/lib/modules/Cart/utils/cartResource.js +78 -72
  146. package/lib/modules/Cart/utils/changePrice.js +50 -28
  147. package/lib/modules/Cart/utils/index.js +48 -106
  148. package/lib/modules/Customer/constants.js +34 -13
  149. package/lib/modules/Customer/index.js +169 -232
  150. package/lib/modules/Customer/types.js +35 -38
  151. package/lib/modules/Date/index.js +115 -116
  152. package/lib/modules/Date/types.js +28 -16
  153. package/lib/modules/Date/utils.js +123 -174
  154. package/lib/modules/Discount/index.d.ts +0 -1
  155. package/lib/modules/Discount/index.js +128 -130
  156. package/lib/modules/Discount/types.d.ts +0 -1
  157. package/lib/modules/Discount/types.js +31 -9
  158. package/lib/modules/Guests/index.js +56 -30
  159. package/lib/modules/Guests/types.js +33 -23
  160. package/lib/modules/Holder/index.js +189 -209
  161. package/lib/modules/Holder/types.js +16 -4
  162. package/lib/modules/Holder/utils.js +49 -20
  163. package/lib/modules/OpenData/index.js +76 -69
  164. package/lib/modules/OpenData/types.js +16 -4
  165. package/lib/modules/OpenData/utils.js +78 -44
  166. package/lib/modules/Order/index.js +1909 -1572
  167. package/lib/modules/Order/types.js +35 -78
  168. package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
  169. package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
  170. package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
  171. package/lib/modules/Order/utils.js +634 -799
  172. package/lib/modules/Payment/cash.js +33 -20
  173. package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
  174. package/lib/modules/Payment/eftpos.js +30 -16
  175. package/lib/modules/Payment/index.js +378 -518
  176. package/lib/modules/Payment/mx51.js +0 -1
  177. package/lib/modules/Payment/types.d.ts +4 -8
  178. package/lib/modules/Payment/types.js +107 -216
  179. package/lib/modules/Payment/utils.js +48 -51
  180. package/lib/modules/Payment/walletpass.d.ts +0 -2
  181. package/lib/modules/Payment/walletpass.js +211 -226
  182. package/lib/modules/Product/index.js +46 -51
  183. package/lib/modules/Product/types.js +16 -4
  184. package/lib/modules/Product/utils.js +33 -32
  185. package/lib/modules/ProductList/index.d.ts +1 -1
  186. package/lib/modules/ProductList/index.js +117 -117
  187. package/lib/modules/ProductList/types.d.ts +0 -1
  188. package/lib/modules/ProductList/types.js +31 -9
  189. package/lib/modules/Quotation/index.js +100 -66
  190. package/lib/modules/Quotation/types.js +16 -4
  191. package/lib/modules/Resource/index.js +59 -27
  192. package/lib/modules/Resource/types.js +32 -22
  193. package/lib/modules/Resource/utils.js +38 -30
  194. package/lib/modules/ResourcePlanner/index.js +61 -60
  195. package/lib/modules/ResourcePlanner/planner.js +384 -346
  196. package/lib/modules/ResourcePlanner/types.js +16 -4
  197. package/lib/modules/Rules/index.js +903 -1475
  198. package/lib/modules/Rules/types.js +40 -17
  199. package/lib/modules/SalesSummary/index.js +90 -85
  200. package/lib/modules/SalesSummary/types.js +16 -4
  201. package/lib/modules/SalesSummary/utils.js +427 -351
  202. package/lib/modules/ScanOrderLogger/index.js +79 -59
  203. package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
  204. package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
  205. package/lib/modules/ScanOrderLogger/types.js +16 -4
  206. package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
  207. package/lib/modules/Schedule/index.js +114 -100
  208. package/lib/modules/Schedule/type.js +16 -4
  209. package/lib/modules/Schedule/types.js +16 -4
  210. package/lib/modules/Schedule/utils.js +291 -433
  211. package/lib/modules/Step/index.js +52 -40
  212. package/lib/modules/Step/tyeps.js +16 -4
  213. package/lib/modules/Summary/index.js +71 -66
  214. package/lib/modules/Summary/types.js +16 -4
  215. package/lib/modules/Summary/utils.js +418 -791
  216. package/lib/modules/SurchargeList/index.js +60 -46
  217. package/lib/modules/SurchargeList/types.js +16 -4
  218. package/lib/modules/index.js +63 -245
  219. package/lib/plugins/app.js +16 -4
  220. package/lib/plugins/index.js +25 -36
  221. package/lib/plugins/request.js +126 -137
  222. package/lib/plugins/shopStore.js +16 -4
  223. package/lib/plugins/user.js +16 -4
  224. package/lib/plugins/window.js +179 -171
  225. package/lib/server/index.js +2337 -2675
  226. package/lib/server/modules/floor-plan/index.js +123 -102
  227. package/lib/server/modules/floor-plan/types.js +30 -15
  228. package/lib/server/modules/index.js +68 -106
  229. package/lib/server/modules/menu/index.js +122 -146
  230. package/lib/server/modules/menu/types.js +31 -18
  231. package/lib/server/modules/order/index.js +642 -567
  232. package/lib/server/modules/order/types.js +32 -117
  233. package/lib/server/modules/order/utils/filterBookings.js +194 -219
  234. package/lib/server/modules/order/utils/filterOrders.js +92 -118
  235. package/lib/server/modules/payment/index.js +83 -59
  236. package/lib/server/modules/payment/types.js +16 -4
  237. package/lib/server/modules/products/index.js +459 -575
  238. package/lib/server/modules/products/types.js +34 -44
  239. package/lib/server/modules/quotation/index.js +172 -137
  240. package/lib/server/modules/quotation/types.js +31 -21
  241. package/lib/server/modules/resource/index.js +184 -213
  242. package/lib/server/modules/resource/types.js +33 -42
  243. package/lib/server/modules/schedule/index.js +123 -135
  244. package/lib/server/modules/schedule/types.js +21 -14
  245. package/lib/server/modules/schedule/utils.js +163 -334
  246. package/lib/server/types.js +16 -4
  247. package/lib/server/utils/index.js +23 -25
  248. package/lib/server/utils/product.js +139 -196
  249. package/lib/server/utils/schedule.js +41 -34
  250. package/lib/server/utils/small-ticket.js +456 -478
  251. package/lib/server/utils/time.js +49 -40
  252. package/lib/solution/BaseSales/index.js +1016 -850
  253. package/lib/solution/BaseSales/types.js +37 -41
  254. package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
  255. package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
  256. package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
  257. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
  258. package/lib/solution/BaseSales/utils.js +140 -155
  259. package/lib/solution/BookingByStep/index.d.ts +1 -1
  260. package/lib/solution/BookingByStep/index.js +1340 -1530
  261. package/lib/solution/BookingByStep/types.js +99 -40
  262. package/lib/solution/BookingByStep/utils/capacity.js +160 -192
  263. package/lib/solution/BookingByStep/utils/products.js +52 -42
  264. package/lib/solution/BookingByStep/utils/resources.js +330 -527
  265. package/lib/solution/BookingByStep/utils/stock.js +44 -65
  266. package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
  267. package/lib/solution/BookingTicket/index.d.ts +1 -1
  268. package/lib/solution/BookingTicket/index.js +459 -543
  269. package/lib/solution/BookingTicket/types.js +77 -99
  270. package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
  271. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
  272. package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
  273. package/lib/solution/BookingTicket/utils/cartView.js +94 -110
  274. package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
  275. package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
  276. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
  277. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
  278. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
  279. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
  280. package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
  281. package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
  282. package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
  283. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
  284. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
  285. package/lib/solution/BuyTickets/index.js +70 -67
  286. package/lib/solution/BuyTickets/types.js +38 -22
  287. package/lib/solution/Checkout/index.js +1158 -1451
  288. package/lib/solution/Checkout/types.js +61 -91
  289. package/lib/solution/Checkout/utils/index.js +156 -228
  290. package/lib/solution/PlaceOrder/index.js +0 -55
  291. package/lib/solution/RegisterAndLogin/config.js +460 -493
  292. package/lib/solution/RegisterAndLogin/index.js +630 -633
  293. package/lib/solution/RegisterAndLogin/types.js +76 -189
  294. package/lib/solution/RegisterAndLogin/utils.js +125 -183
  295. package/lib/solution/Sales/index.js +320 -317
  296. package/lib/solution/Sales/types.js +33 -27
  297. package/lib/solution/ScanOrder/index.js +862 -831
  298. package/lib/solution/ScanOrder/types.js +34 -33
  299. package/lib/solution/ScanOrder/utils.js +371 -406
  300. package/lib/solution/ShopDiscount/index.js +233 -235
  301. package/lib/solution/ShopDiscount/types.d.ts +4 -5
  302. package/lib/solution/ShopDiscount/types.js +37 -15
  303. package/lib/solution/ShopDiscount/utils.d.ts +0 -9
  304. package/lib/solution/ShopDiscount/utils.js +172 -309
  305. package/lib/solution/UnifiedBookingSales/index.js +405 -379
  306. package/lib/solution/UnifiedBookingSales/types.js +31 -12
  307. package/lib/solution/VenueBooking/index.d.ts +3 -31
  308. package/lib/solution/VenueBooking/index.js +916 -967
  309. package/lib/solution/VenueBooking/types.d.ts +1 -3
  310. package/lib/solution/VenueBooking/types.js +39 -20
  311. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  312. package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
  313. package/lib/solution/VenueBooking/utils/resource.js +54 -31
  314. package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
  315. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  316. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
  317. package/lib/solution/VenueBooking/utils.js +67 -130
  318. package/lib/solution/index.js +41 -124
  319. package/lib/store/createStore.js +29 -32
  320. package/lib/types/index.d.ts +1 -1
  321. package/lib/types/index.js +16 -4
  322. package/lib/utils/task.js +36 -36
  323. package/lib/utils/watch.js +47 -81
  324. package/package.json +2 -4
  325. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  326. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  327. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  328. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
@@ -1,92 +1,113 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- ScanOrderImpl: true
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
8
10
  };
9
- exports.ScanOrderImpl = void 0;
10
- var _BaseSales = require("../BaseSales");
11
- var _types = require("./types");
12
- Object.keys(_types).forEach(function (key) {
13
- if (key === "default" || key === "__esModule") return;
14
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
15
- if (key in exports && exports[key] === _types[key]) return;
16
- Object.defineProperty(exports, key, {
17
- enumerable: true,
18
- get: function () {
19
- return _types[key];
20
- }
21
- });
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/solution/ScanOrder/index.ts
31
+ var ScanOrder_exports = {};
32
+ __export(ScanOrder_exports, {
33
+ ScanOrderImpl: () => ScanOrderImpl
22
34
  });
23
- var _Order = require("../../modules/Order");
24
- var _types2 = require("../../modules/Account/types");
25
- var _types3 = require("../RegisterAndLogin/types");
26
- var _decimal = _interopRequireDefault(require("decimal.js"));
27
- var _utils = require("./utils");
28
- var _types4 = require("../BookingByStep/types");
29
- var _ProductList = require("../../modules/ProductList");
30
- var _getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule");
31
- var _utils2 = require("../../modules/Order/utils");
32
- var _dayjs = _interopRequireDefault(require("dayjs"));
33
- var _itemRule = require("../../model/strategy/adapter/itemRule");
34
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
- class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
36
- defaultName = 'scanOrder';
37
- defaultVersion = '1.0.0';
38
- isSolution = true;
39
- initializeOptions = {};
40
- store = {
41
- entryContext: null,
42
- status: 'idle',
43
- config: null,
44
- resource: null,
45
- flow: {},
46
- error: null,
47
- products: undefined,
48
- itemRuleQuantityLimits: [],
49
- cartValidation: {
50
- passed: null,
51
- failures: []
52
- },
53
- entryPaxNumber: 1
54
- };
55
- otherParams = {};
56
- cacheId;
57
- window;
58
- request;
59
- itemRuleEvaluator = new _itemRule.ItemRuleEvaluator();
60
- itemRuleConfigs = [];
61
- itemRuleConfigsPromise = null;
62
- itemRulePrefillApplied = false;
63
- itemRuleRuntimeConfig = {};
64
- /** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
65
- enabledReservationRuleProducts = [];
66
- loginEffectDisposers = [];
67
- customerLoginRefreshInFlight = null;
68
- customerLoginRefreshIdInFlight = null;
69
- static PISELL1_LOGIN_SUCCESS = 'pisell1.login.success';
35
+ module.exports = __toCommonJS(ScanOrder_exports);
36
+ var import_BaseSales = require("../BaseSales");
37
+ var import_types = require("./types");
38
+ var import_Order = require("../../modules/Order");
39
+ var import_types2 = require("../../modules/Account/types");
40
+ var import_types3 = require("../RegisterAndLogin/types");
41
+ var import_decimal = __toESM(require("decimal.js"));
42
+ var import_utils = require("./utils");
43
+ var import_types4 = require("../BookingByStep/types");
44
+ var import_ProductList = require("../../modules/ProductList");
45
+ var import_getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule");
46
+ var import_utils2 = require("../../modules/Order/utils");
47
+ var import_dayjs = __toESM(require("dayjs"));
48
+ var import_itemRule = require("../../model/strategy/adapter/itemRule");
49
+ __reExport(ScanOrder_exports, require("./types"), module.exports);
50
+ var _ScanOrderImpl = class extends import_BaseSales.BaseSalesImpl {
51
+ constructor(name, version) {
52
+ super(name, version);
53
+ this.defaultName = "scanOrder";
54
+ this.defaultVersion = "1.0.0";
55
+ this.isSolution = true;
56
+ this.initializeOptions = {};
57
+ this.store = {
58
+ entryContext: null,
59
+ status: "idle",
60
+ config: null,
61
+ resource: null,
62
+ flow: {},
63
+ error: null,
64
+ products: void 0,
65
+ itemRuleQuantityLimits: [],
66
+ cartValidation: {
67
+ passed: null,
68
+ failures: []
69
+ },
70
+ entryPaxNumber: 1
71
+ };
72
+ this.otherParams = {};
73
+ this.itemRuleEvaluator = new import_itemRule.ItemRuleEvaluator();
74
+ this.itemRuleConfigs = [];
75
+ this.itemRuleConfigsPromise = null;
76
+ this.itemRulePrefillApplied = false;
77
+ this.itemRuleRuntimeConfig = {};
78
+ /** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
79
+ this.enabledReservationRuleProducts = [];
80
+ this.loginEffectDisposers = [];
81
+ this.customerLoginRefreshInFlight = null;
82
+ this.customerLoginRefreshIdInFlight = null;
83
+ }
70
84
  getScanOrderLoggerContext() {
71
85
  return {
72
86
  cacheId: this.cacheId,
73
87
  solutionName: this.name,
74
- moduleName: 'scanOrder'
88
+ moduleName: "scanOrder"
75
89
  };
76
90
  }
77
91
  safeStringify(value) {
78
92
  try {
79
93
  return JSON.stringify(value);
80
94
  } catch {
81
- return undefined;
95
+ return void 0;
82
96
  }
83
97
  }
84
98
  pickErrorMessage(error) {
85
- const candidates = [error.message, error.data?.message, error.response?.data?.message, error.error?.message];
99
+ var _a, _b, _c, _d;
100
+ const candidates = [
101
+ error.message,
102
+ (_a = error.data) == null ? void 0 : _a.message,
103
+ (_c = (_b = error.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message,
104
+ (_d = error.error) == null ? void 0 : _d.message
105
+ ];
86
106
  for (const candidate of candidates) {
87
- if (typeof candidate === 'string' && candidate.trim()) return candidate;
107
+ if (typeof candidate === "string" && candidate.trim())
108
+ return candidate;
88
109
  }
89
- return undefined;
110
+ return void 0;
90
111
  }
91
112
  serializeError(error) {
92
113
  if (error instanceof Error) {
@@ -96,23 +117,15 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
96
117
  stack: error.stack
97
118
  };
98
119
  }
99
- if (error && typeof error === 'object') {
120
+ if (error && typeof error === "object") {
100
121
  const raw = error;
101
122
  const message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
102
123
  return {
103
- ...(typeof raw.name === 'string' ? {
104
- name: raw.name
105
- } : {}),
124
+ ...typeof raw.name === "string" ? { name: raw.name } : {},
106
125
  message,
107
- ...('code' in raw ? {
108
- code: raw.code
109
- } : {}),
110
- ...('status' in raw ? {
111
- status: raw.status
112
- } : {}),
113
- ...(this.safeStringify(raw) ? {
114
- raw: this.safeStringify(raw)
115
- } : {})
126
+ ..."code" in raw ? { code: raw.code } : {},
127
+ ..."status" in raw ? { status: raw.status } : {},
128
+ ...this.safeStringify(raw) ? { raw: this.safeStringify(raw) } : {}
116
129
  };
117
130
  }
118
131
  return {
@@ -122,19 +135,18 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
122
135
  async addScanOrderLog(params) {
123
136
  const payload = {
124
137
  cacheId: this.cacheId,
125
- ...(params.payload || {})
138
+ ...params.payload || {}
126
139
  };
127
140
  const extra = {
128
- ...(params.extra || {})
141
+ ...params.extra || {}
129
142
  };
130
143
  const logger = this.store.scanOrderLogger;
131
144
  if (!logger) {
132
- if ((params.level || 'info') === 'error') {
133
- console.error('[ScanOrder][log-fallback]', params.title, {
134
- payload,
135
- extra
136
- });
137
- } else {}
145
+ if ((params.level || "info") === "error") {
146
+ console.error("[ScanOrder][log-fallback]", params.title, { payload, extra });
147
+ } else {
148
+ console.log("[ScanOrder][log-fallback]", params.title, { payload, extra });
149
+ }
138
150
  return;
139
151
  }
140
152
  await logger.addLog({
@@ -145,7 +157,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
145
157
  }
146
158
  logMethodStart(method, payload = {}) {
147
159
  void this.addScanOrderLog({
148
- level: 'info',
160
+ level: "info",
149
161
  title: `[ScanOrder] ${method} start`,
150
162
  payload: {
151
163
  method,
@@ -155,7 +167,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
155
167
  }
156
168
  logMethodSuccess(method, payload = {}) {
157
169
  void this.addScanOrderLog({
158
- level: 'info',
170
+ level: "info",
159
171
  title: `[ScanOrder] ${method} success`,
160
172
  payload: {
161
173
  method,
@@ -165,7 +177,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
165
177
  }
166
178
  logMethodError(method, error, payload = {}) {
167
179
  void this.addScanOrderLog({
168
- level: 'error',
180
+ level: "error",
169
181
  title: `[ScanOrder] ${method} failed`,
170
182
  payload: {
171
183
  method,
@@ -175,8 +187,9 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
175
187
  });
176
188
  }
177
189
  assertProductListLoaded(method, result, payload = {}) {
178
- if (Array.isArray(result)) return result;
179
- const error = result instanceof Error ? result : new Error('商品列表接口返回异常');
190
+ if (Array.isArray(result))
191
+ return result;
192
+ const error = result instanceof Error ? result : new Error("商品列表接口返回异常");
180
193
  this.logMethodError(method, error, payload);
181
194
  error.__scanOrderLogged = true;
182
195
  throw error;
@@ -185,21 +198,36 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
185
198
  await this.addScanOrderLog({
186
199
  ...params,
187
200
  payload: {
188
- source: 'ui-bridge',
189
- ...(params.payload || {})
201
+ source: "ui-bridge",
202
+ ...params.payload || {}
190
203
  }
191
204
  });
192
205
  }
193
206
  normalizeCustomerId(value) {
194
207
  const customerId = Number(value);
195
- if (!Number.isFinite(customerId) || customerId <= 0) return null;
208
+ if (!Number.isFinite(customerId) || customerId <= 0)
209
+ return null;
196
210
  return customerId;
197
211
  }
198
212
  resolveCustomerIdFromLoginPayload(payload) {
199
- const candidates = [payload?.customerId, payload?.customer_id, payload?.id, payload?.user?.customerId, payload?.user?.customer_id, payload?.user?.id, payload?.user?._origin?.customer_id, payload?.account?.customerId, payload?.account?.customer_id, payload?.account?.id, payload?._origin?.customer_id];
213
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
214
+ const candidates = [
215
+ payload == null ? void 0 : payload.customerId,
216
+ payload == null ? void 0 : payload.customer_id,
217
+ payload == null ? void 0 : payload.id,
218
+ (_a = payload == null ? void 0 : payload.user) == null ? void 0 : _a.customerId,
219
+ (_b = payload == null ? void 0 : payload.user) == null ? void 0 : _b.customer_id,
220
+ (_c = payload == null ? void 0 : payload.user) == null ? void 0 : _c.id,
221
+ (_e = (_d = payload == null ? void 0 : payload.user) == null ? void 0 : _d._origin) == null ? void 0 : _e.customer_id,
222
+ (_f = payload == null ? void 0 : payload.account) == null ? void 0 : _f.customerId,
223
+ (_g = payload == null ? void 0 : payload.account) == null ? void 0 : _g.customer_id,
224
+ (_h = payload == null ? void 0 : payload.account) == null ? void 0 : _h.id,
225
+ (_i = payload == null ? void 0 : payload._origin) == null ? void 0 : _i.customer_id
226
+ ];
200
227
  for (const candidate of candidates) {
201
228
  const customerId = this.normalizeCustomerId(candidate);
202
- if (customerId) return customerId;
229
+ if (customerId)
230
+ return customerId;
203
231
  }
204
232
  return null;
205
233
  }
@@ -210,30 +238,38 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
210
238
  this.loginEffectDisposers = [];
211
239
  }
212
240
  registerLoginEffect(event, callback) {
213
- const effects = this.core?.effects;
214
- if (!effects?.on) return;
241
+ var _a;
242
+ const effects = (_a = this.core) == null ? void 0 : _a.effects;
243
+ if (!(effects == null ? void 0 : effects.on))
244
+ return;
215
245
  effects.on(event, callback);
216
246
  this.loginEffectDisposers.push(() => {
217
- if (typeof effects.off === 'function') {
247
+ if (typeof effects.off === "function") {
218
248
  effects.off(event, callback);
219
249
  }
220
250
  });
221
251
  }
222
252
  registerCustomerLoginListeners() {
223
253
  this.clearLoginEffectListeners();
224
- const createHandleLogin = () => async payload => {
254
+ const createHandleLogin = () => async (payload) => {
225
255
  const customerId = this.resolveCustomerIdFromLoginPayload(payload);
226
- if (!customerId) return;
227
- await this.refreshOrderMarketingAfterLogin({
228
- customerId
229
- });
256
+ if (!customerId)
257
+ return;
258
+ await this.refreshOrderMarketingAfterLogin({ customerId });
230
259
  };
231
- this.registerLoginEffect(ScanOrderImpl.PISELL1_LOGIN_SUCCESS, createHandleLogin());
232
- this.registerLoginEffect(_types2.AccountHooks.OnLogin, createHandleLogin());
233
- this.registerLoginEffect(_types3.RegisterAndLoginHooks.onLoginSuccess, createHandleLogin());
260
+ this.registerLoginEffect(
261
+ _ScanOrderImpl.PISELL1_LOGIN_SUCCESS,
262
+ createHandleLogin()
263
+ );
264
+ this.registerLoginEffect(import_types2.AccountHooks.OnLogin, createHandleLogin());
265
+ this.registerLoginEffect(
266
+ import_types3.RegisterAndLoginHooks.onLoginSuccess,
267
+ createHandleLogin()
268
+ );
234
269
  }
235
270
  async refreshOrderMarketingAfterLogin(params) {
236
- if (!this.store.order) throw new Error('order 模块未初始化');
271
+ if (!this.store.order)
272
+ throw new Error("order 模块未初始化");
237
273
  if (this.customerLoginRefreshInFlight) {
238
274
  if (this.customerLoginRefreshIdInFlight === params.customerId) {
239
275
  await this.customerLoginRefreshInFlight;
@@ -246,9 +282,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
246
282
  await this.store.order.loadDiscountConfig({
247
283
  customerId: params.customerId
248
284
  });
249
- await this.store.order.recalculateSummary({
250
- createIfMissing: true
251
- });
285
+ await this.store.order.recalculateSummary({ createIfMissing: true });
252
286
  this.store.order.persistTempOrder();
253
287
  await this.refreshItemRuleQuantityLimits();
254
288
  await this.refreshCartValidationPassed();
@@ -265,35 +299,29 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
265
299
  }
266
300
  }
267
301
  }
268
- constructor(name, version) {
269
- super(name, version);
270
- }
271
302
  getRegisteredModuleNames() {
272
- return ['scanOrderLogger', 'products', 'order', 'salesSummary', 'schedule'];
303
+ return ["scanOrderLogger", "products", "order", "salesSummary", "schedule"];
273
304
  }
274
305
  createSubModule(moduleName) {
275
- if (moduleName === 'scanOrderLogger') {
276
- return (0, _types4.createModule)('scanOrderLogger', this.name);
306
+ if (moduleName === "scanOrderLogger") {
307
+ return (0, import_types4.createModule)("scanOrderLogger", this.name);
277
308
  }
278
309
  return super.createSubModule(moduleName);
279
310
  }
280
-
281
311
  /** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
282
312
  getCacheId() {
283
313
  return this.cacheId;
284
314
  }
285
315
  async initialize(core, options = {}) {
286
- this.logMethodStart('initialize');
287
- this.store = {
288
- ...this.store,
289
- ...options.store
290
- };
291
- this.store.entryContext = options.otherParams?.entryContext || this.store.entryContext;
292
- this.store.status = 'initializing';
316
+ var _a, _b, _c, _d, _e, _f, _g, _h;
317
+ this.logMethodStart("initialize");
318
+ this.store = { ...this.store, ...options.store };
319
+ this.store.entryContext = ((_a = options.otherParams) == null ? void 0 : _a.entryContext) || this.store.entryContext;
320
+ this.store.status = "initializing";
293
321
  this.store.error = null;
294
322
  this.otherParams = options.otherParams || {};
295
- this.cacheId = this.otherParams?.cacheId;
296
- this.itemRuleRuntimeConfig = this.otherParams?.scanOrderItemRule || this.otherParams?.itemRule || {};
323
+ this.cacheId = (_b = this.otherParams) == null ? void 0 : _b.cacheId;
324
+ this.itemRuleRuntimeConfig = ((_c = this.otherParams) == null ? void 0 : _c.scanOrderItemRule) || ((_d = this.otherParams) == null ? void 0 : _d.itemRule) || {};
297
325
  this.itemRuleConfigs = [];
298
326
  this.itemRuleConfigsPromise = null;
299
327
  this.itemRulePrefillApplied = false;
@@ -304,354 +332,359 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
304
332
  };
305
333
  await super.initialize(core, options);
306
334
  if (this.store.scanOrderLogger) {
307
- this.store.scanOrderLogger.setProvider(this.otherParams?.scanOrderLoggerProvider || 'feishu');
308
- this.store.scanOrderLogger.setProviderConfig(this.otherParams?.scanOrderLoggerConfig || {
309
- feishu: {
310
- webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed',
311
- errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f'
335
+ this.store.scanOrderLogger.setProvider(
336
+ ((_e = this.otherParams) == null ? void 0 : _e.scanOrderLoggerProvider) || "feishu"
337
+ );
338
+ this.store.scanOrderLogger.setProviderConfig(
339
+ ((_f = this.otherParams) == null ? void 0 : _f.scanOrderLoggerConfig) || {
340
+ feishu: {
341
+ webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed",
342
+ errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f"
343
+ }
312
344
  }
313
- });
345
+ );
314
346
  this.store.scanOrderLogger.setContext(this.getScanOrderLoggerContext());
315
347
  }
316
348
  this.registerCustomerLoginListeners();
349
+ console.log("[ScanOrder] 初始化开始");
317
350
  try {
318
- await this.store.order?.recalculateSummary({
319
- createIfMissing: false
320
- });
321
- this.store.order?.persistTempOrder();
351
+ await ((_g = this.store.order) == null ? void 0 : _g.recalculateSummary({ createIfMissing: false }));
352
+ (_h = this.store.order) == null ? void 0 : _h.persistTempOrder();
322
353
  await this.loadRuntimeConfigs();
323
354
  if (this.store.schedule) {
324
355
  try {
325
356
  await this.store.schedule.loadAllSchedule();
326
357
  } catch (scheduleError) {
327
- console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', scheduleError);
358
+ console.warn("[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过", scheduleError);
328
359
  }
329
360
  }
330
361
  await this.refreshItemRuleQuantityLimits();
331
- this.store.status = 'ready';
332
- await this.core.effects.emit(_types.ScanOrderHooks.onInited, {
362
+ this.store.status = "ready";
363
+ console.log("[ScanOrder] 初始化完成");
364
+ await this.core.effects.emit(import_types.ScanOrderHooks.onInited, {
333
365
  status: this.store.status
334
366
  });
335
- this.logMethodSuccess('initialize', {
367
+ this.logMethodSuccess("initialize", {
336
368
  status: this.store.status
337
369
  });
338
370
  } catch (error) {
339
- this.store.status = 'error';
340
- this.store.error = error instanceof Error ? error.message : '初始化失败';
341
- console.error('[ScanOrder] 初始化失败', error);
342
- this.logMethodError('initialize', error, {
371
+ this.store.status = "error";
372
+ this.store.error = error instanceof Error ? error.message : "初始化失败";
373
+ console.error("[ScanOrder] 初始化失败", error);
374
+ this.logMethodError("initialize", error, {
343
375
  status: this.store.status
344
376
  });
345
377
  throw error;
346
378
  }
347
379
  }
348
380
  async destroy() {
349
- this.logMethodStart('destroy');
381
+ this.logMethodStart("destroy");
350
382
  this.clearLoginEffectListeners();
351
- await this.core.effects.emit(_types.ScanOrderHooks.onDestroy, {});
383
+ await this.core.effects.emit(import_types.ScanOrderHooks.onDestroy, {});
352
384
  super.destroy();
353
- this.logMethodSuccess('destroy');
385
+ console.log("[ScanOrder] 已销毁");
386
+ this.logMethodSuccess("destroy");
354
387
  }
355
388
  async retryInit() {
356
- this.logMethodStart('retryInit');
357
- // TODO: 细化重试策略(指数退避、最大重试次数)后替换当前实现
358
-
359
- await this.core.effects.emit(_types.ScanOrderHooks.onRetryInit, {});
389
+ this.logMethodStart("retryInit");
390
+ console.log("[ScanOrder] retryInit 调用");
391
+ await this.core.effects.emit(import_types.ScanOrderHooks.onRetryInit, {});
360
392
  try {
361
393
  await this.initialize(this.core, this.initializeOptions);
362
- this.logMethodSuccess('retryInit');
394
+ this.logMethodSuccess("retryInit");
363
395
  } catch (error) {
364
- this.logMethodError('retryInit', error);
396
+ this.logMethodError("retryInit", error);
365
397
  throw error;
366
398
  }
367
399
  }
368
400
  async refresh() {
369
- this.logMethodStart('refresh');
370
- // TODO: 接入真实刷新逻辑(资源重拉取、流程重建)后替换当前实现
371
-
401
+ this.logMethodStart("refresh");
402
+ console.log("[ScanOrder] refresh 调用");
372
403
  try {
373
- this.store.status = 'initializing';
404
+ this.store.status = "initializing";
374
405
  await this.loadRuntimeConfigs();
375
406
  await this.refreshItemRuleQuantityLimits();
376
- this.store.status = 'ready';
377
- await this.core.effects.emit(_types.ScanOrderHooks.onRefresh, {
407
+ this.store.status = "ready";
408
+ await this.core.effects.emit(import_types.ScanOrderHooks.onRefresh, {
378
409
  status: this.store.status
379
410
  });
380
- this.logMethodSuccess('refresh', {
411
+ this.logMethodSuccess("refresh", {
381
412
  status: this.store.status
382
413
  });
383
414
  } catch (error) {
384
- this.logMethodError('refresh', error);
415
+ this.logMethodError("refresh", error);
385
416
  throw error;
386
417
  }
387
418
  }
388
419
  getStatus() {
389
- this.logMethodStart('getStatus');
420
+ this.logMethodStart("getStatus");
390
421
  const result = this.store.status;
391
- this.logMethodSuccess('getStatus', {
422
+ this.logMethodSuccess("getStatus", {
392
423
  status: result
393
424
  });
394
425
  return result;
395
426
  }
396
427
  getEntryContext() {
397
- this.logMethodStart('getEntryContext');
428
+ this.logMethodStart("getEntryContext");
398
429
  const result = this.store.entryContext;
399
- this.logMethodSuccess('getEntryContext', {
430
+ this.logMethodSuccess("getEntryContext", {
400
431
  hasEntryContext: Boolean(result)
401
432
  });
402
433
  return result;
403
434
  }
404
435
  getConfig() {
405
- this.logMethodStart('getConfig');
436
+ this.logMethodStart("getConfig");
406
437
  const result = this.store.config || {};
407
- this.logMethodSuccess('getConfig', {
438
+ this.logMethodSuccess("getConfig", {
408
439
  configKeys: Object.keys(result || {})
409
440
  });
410
441
  return result;
411
442
  }
412
443
  getItemRuleQuantityLimits() {
413
- this.logMethodStart('getItemRuleQuantityLimits');
444
+ this.logMethodStart("getItemRuleQuantityLimits");
414
445
  const result = this.store.itemRuleQuantityLimits || [];
415
- this.logMethodSuccess('getItemRuleQuantityLimits', {
446
+ this.logMethodSuccess("getItemRuleQuantityLimits", {
416
447
  limitCount: result.length
417
448
  });
418
449
  return result;
419
450
  }
420
451
  getCartValidationPassed() {
421
- this.logMethodStart('getCartValidationPassed');
422
- const result = this.store.cartValidation?.passed ?? null;
423
- this.logMethodSuccess('getCartValidationPassed', {
452
+ var _a;
453
+ this.logMethodStart("getCartValidationPassed");
454
+ const result = ((_a = this.store.cartValidation) == null ? void 0 : _a.passed) ?? null;
455
+ this.logMethodSuccess("getCartValidationPassed", {
424
456
  cartValidationPassed: result
425
457
  });
426
458
  return result;
427
459
  }
428
460
  getCartValidation() {
429
- this.logMethodStart('getCartValidation');
461
+ this.logMethodStart("getCartValidation");
430
462
  const result = this.store.cartValidation || {
431
463
  passed: null,
432
464
  failures: []
433
465
  };
434
- this.logMethodSuccess('getCartValidation', {
466
+ this.logMethodSuccess("getCartValidation", {
435
467
  cartValidationPassed: result.passed,
436
468
  failureCount: Array.isArray(result.failures) ? result.failures.length : 0
437
469
  });
438
470
  return result;
439
471
  }
440
472
  getTempOrder() {
441
- this.logMethodStart('getTempOrder');
442
- const result = this.store.order?.getTempOrder() || null;
443
- this.logMethodSuccess('getTempOrder', {
473
+ var _a, _b, _c;
474
+ this.logMethodStart("getTempOrder");
475
+ const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
476
+ this.logMethodSuccess("getTempOrder", {
444
477
  hasTempOrder: Boolean(result),
445
- productCount: result?.products?.length || 0,
446
- noteLength: result?.note?.length || 0
478
+ productCount: ((_b = result == null ? void 0 : result.products) == null ? void 0 : _b.length) || 0,
479
+ noteLength: ((_c = result == null ? void 0 : result.note) == null ? void 0 : _c.length) || 0
447
480
  });
448
481
  return result;
449
482
  }
450
483
  updateTempOrderNote(note, sync = false) {
451
- this.logMethodStart('updateTempOrderNote', {
452
- noteLength: String(note || '').length
484
+ this.logMethodStart("updateTempOrderNote", {
485
+ noteLength: String(note || "").length
453
486
  });
454
487
  try {
455
- if (!this.store.order) throw new Error('order 模块未初始化');
488
+ if (!this.store.order)
489
+ throw new Error("order 模块未初始化");
456
490
  const result = this.store.order.updateTempOrderNote(note, sync);
457
- if (result && typeof result.then === 'function') {
458
- return result.then(nextNote => {
459
- this.logMethodSuccess('updateTempOrderNote', {
460
- noteLength: nextNote.length
491
+ if (result && typeof result.then === "function") {
492
+ return result.then((nextNote2) => {
493
+ this.logMethodSuccess("updateTempOrderNote", {
494
+ noteLength: nextNote2.length
461
495
  });
462
- return nextNote;
496
+ return nextNote2;
463
497
  });
464
498
  }
465
499
  const nextNote = result;
466
- this.logMethodSuccess('updateTempOrderNote', {
500
+ this.logMethodSuccess("updateTempOrderNote", {
467
501
  noteLength: nextNote.length
468
502
  });
469
503
  return nextNote;
470
504
  } catch (error) {
471
- this.logMethodError('updateTempOrderNote', error);
505
+ this.logMethodError("updateTempOrderNote", error);
472
506
  throw error;
473
507
  }
474
508
  }
475
-
476
509
  // 存储 UI 层选择的取餐方式到 tempOrder.metadata.shop_service_data
477
510
  // service_type 在扫码点餐场景固定为 dine_in
478
511
  setPickupReferenceMode(mode) {
479
- this.logMethodStart('setPickupReferenceMode', {
480
- mode
481
- });
512
+ var _a;
513
+ this.logMethodStart("setPickupReferenceMode", { mode });
482
514
  try {
483
- if (!this.store.order) throw new Error('order 模块未初始化');
515
+ if (!this.store.order)
516
+ throw new Error("order 模块未初始化");
484
517
  const tempOrder = this.store.order.ensureTempOrder();
485
518
  tempOrder.metadata = {
486
- ...(tempOrder.metadata || {}),
519
+ ...tempOrder.metadata || {},
487
520
  shop_service_data: {
488
- ...((tempOrder.metadata || {}).shop_service_data || {}),
489
- service_type: this.otherParams?.businessCode === 'dine_in' ? 'dine_in' : '',
521
+ ...(tempOrder.metadata || {}).shop_service_data || {},
522
+ service_type: ((_a = this.otherParams) == null ? void 0 : _a.businessCode) === "dine_in" ? "dine_in" : "",
490
523
  pickup_reference_mode: mode
491
524
  }
492
525
  };
493
526
  this.store.order.persistTempOrder();
494
- this.logMethodSuccess('setPickupReferenceMode', {
527
+ this.logMethodSuccess("setPickupReferenceMode", {
495
528
  mode
496
529
  });
497
530
  return tempOrder.metadata.shop_service_data;
498
531
  } catch (error) {
499
- this.logMethodError('setPickupReferenceMode', error, {
500
- mode
501
- });
532
+ this.logMethodError("setPickupReferenceMode", error, { mode });
502
533
  throw error;
503
534
  }
504
535
  }
505
-
506
536
  // 存储用户自定义取餐标识到 tempOrder.buzzer
507
537
  setPickupRef(buzzer) {
508
- this.logMethodStart('setPickupRef', {
509
- buzzerLength: String(buzzer || '').length
538
+ this.logMethodStart("setPickupRef", {
539
+ buzzerLength: String(buzzer || "").length
510
540
  });
511
541
  try {
512
- if (!this.store.order) throw new Error('order 模块未初始化');
542
+ if (!this.store.order)
543
+ throw new Error("order 模块未初始化");
513
544
  const result = this.store.order.updateTempOrderBuzzer(buzzer);
514
- this.logMethodSuccess('setPickupRef', {
545
+ this.logMethodSuccess("setPickupRef", {
515
546
  buzzerLength: result.length
516
547
  });
517
548
  return result;
518
549
  } catch (error) {
519
- this.logMethodError('setPickupRef', error);
550
+ this.logMethodError("setPickupRef", error);
520
551
  throw error;
521
552
  }
522
553
  }
523
554
  ensureScanOrderTempOrder() {
524
- if (!this.store.order) throw new Error('order 模块未初始化');
555
+ if (!this.store.order)
556
+ throw new Error("order 模块未初始化");
525
557
  return this.store.order.ensureTempOrder();
526
558
  }
527
-
528
559
  // 主动创建临时订单;若已存在则直接返回已有订单
529
560
  async addNewOrder() {
530
- this.logMethodStart('addNewOrder');
561
+ this.logMethodStart("addNewOrder");
531
562
  try {
532
- if (!this.store.order) throw new Error('order 模块未初始化');
563
+ if (!this.store.order)
564
+ throw new Error("order 模块未初始化");
533
565
  const tempOrder = await this.store.order.addNewOrder();
534
- this.logMethodSuccess('addNewOrder', {
566
+ this.logMethodSuccess("addNewOrder", {
535
567
  productCount: tempOrder.products.length
536
568
  });
537
569
  return tempOrder;
538
570
  } catch (error) {
539
- this.logMethodError('addNewOrder', error);
571
+ this.logMethodError("addNewOrder", error);
540
572
  throw error;
541
573
  }
542
574
  }
543
-
544
575
  // 重置 tempOrder 与与上一单强相关的运行态(resource/entryPaxNumber/enabledReservationRuleProducts),
545
576
  // 适用于从支付页通过 react-router 跳回继续下单时清理残留数据
546
577
  async restoreOrder() {
547
- this.logMethodStart('restoreOrder');
578
+ this.logMethodStart("restoreOrder");
548
579
  try {
549
580
  if (!this.store.order) {
550
- throw new Error('scanOrder 解决方案需要 order 模块支持');
581
+ throw new Error("scanOrder 解决方案需要 order 模块支持");
551
582
  }
552
583
  this.store.resource = null;
553
584
  this.store.entryPaxNumber = 1;
554
585
  this.enabledReservationRuleProducts = [];
555
586
  const tempOrder = this.store.order.restoreOrder();
556
- this.logMethodSuccess('restoreOrder');
587
+ this.logMethodSuccess("restoreOrder");
557
588
  return tempOrder;
558
589
  } catch (error) {
559
- this.logMethodError('restoreOrder', error);
590
+ this.logMethodError("restoreOrder", error);
560
591
  throw error;
561
592
  }
562
593
  }
563
594
  getOrderProducts() {
564
- this.logMethodStart('getOrderProducts');
565
- if (!this.store.order) throw new Error('order 模块未初始化');
595
+ this.logMethodStart("getOrderProducts");
596
+ if (!this.store.order)
597
+ throw new Error("order 模块未初始化");
566
598
  const products = this.store.order.getOrderProducts();
567
- this.logMethodSuccess('getOrderProducts', {
599
+ this.logMethodSuccess("getOrderProducts", {
568
600
  productCount: products.length
569
601
  });
570
602
  return products;
571
603
  }
572
604
  async getSummary() {
573
- this.logMethodStart('getSummary');
605
+ this.logMethodStart("getSummary");
574
606
  try {
575
- if (!this.store.order) throw new Error('order 模块未初始化');
607
+ if (!this.store.order)
608
+ throw new Error("order 模块未初始化");
576
609
  const summary = await this.store.order.getOrderSummary();
577
- this.logMethodSuccess('getSummary', {
610
+ this.logMethodSuccess("getSummary", {
578
611
  totalAmount: summary.total_amount
579
612
  });
580
613
  return summary;
581
614
  } catch (error) {
582
- this.logMethodError('getSummary', error);
615
+ this.logMethodError("getSummary", error);
583
616
  throw error;
584
617
  }
585
618
  }
586
619
  getDiscountList() {
587
- if (!this.store.order) return [];
620
+ if (!this.store.order)
621
+ return [];
588
622
  return this.store.order.getDiscountList();
589
623
  }
590
624
  async scanCode(code, customerId) {
591
- this.logMethodStart('scanCode', {
592
- code
593
- });
625
+ this.logMethodStart("scanCode", { code });
594
626
  try {
595
- if (!this.store.order) throw new Error('order 模块未初始化');
627
+ if (!this.store.order)
628
+ throw new Error("order 模块未初始化");
596
629
  const raw = await this.store.order.scanCode(code, customerId);
597
630
  if (raw.isAvailable) {
598
- await this.store.order.recalculateSummary({
599
- createIfMissing: true
600
- });
631
+ await this.store.order.recalculateSummary({ createIfMissing: true });
601
632
  this.store.order.persistTempOrder();
602
633
  }
603
- this.logMethodSuccess('scanCode', {
604
- isAvailable: raw.isAvailable
605
- });
634
+ this.logMethodSuccess("scanCode", { isAvailable: raw.isAvailable });
606
635
  return {
607
636
  isAvailable: raw.isAvailable,
608
637
  type: raw.type,
609
638
  unavailableReason: raw.unavailableReason
610
639
  };
611
640
  } catch (error) {
612
- this.logMethodError('scanCode', error);
641
+ this.logMethodError("scanCode", error);
613
642
  throw error;
614
643
  }
615
644
  }
616
645
  async setDiscountSelected(params) {
617
- this.logMethodStart('setDiscountSelected', params);
646
+ var _a, _b, _c, _d, _e;
647
+ this.logMethodStart("setDiscountSelected", params);
618
648
  try {
619
- if (!this.store.order) throw new Error('order 模块未初始化');
649
+ if (!this.store.order)
650
+ throw new Error("order 模块未初始化");
620
651
  const list = this.store.order.getDiscountList();
621
- const updated = list.map(d => d.id === params.discountId ? {
622
- ...d,
623
- isSelected: params.isSelected,
624
- isManualSelect: !params.isSelected
625
- } : d);
652
+ const updated = list.map(
653
+ (d) => d.id === params.discountId ? {
654
+ ...d,
655
+ isSelected: params.isSelected,
656
+ isManualSelect: !params.isSelected
657
+ } : d
658
+ );
626
659
  const tempOrder = this.store.order.ensureTempOrder();
627
660
  const orderStore = this.store.order.store || {};
628
661
  const discountModule = orderStore.discount;
629
662
  const rulesModule = orderStore.rules;
630
- const holders = tempOrder.holder?.form_record_id ? [{
631
- form_record_id: tempOrder.holder.form_record_id
632
- }] : [];
663
+ const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
633
664
  let nextDiscountList = updated;
634
- await discountModule?.setDiscountList(updated);
665
+ await (discountModule == null ? void 0 : discountModule.setDiscountList(updated));
635
666
  if (rulesModule) {
636
- const result = rulesModule.calcDiscount({
637
- productList: tempOrder.products,
638
- discountList: updated,
639
- holders,
640
- isFormSubject: !!tempOrder.holder?.type && tempOrder.holder.type === 'form'
641
- }, {
642
- discountId: params.discountId,
643
- isSelected: params.isSelected
644
- }) || {
645
- productList: tempOrder.products,
646
- discountList: updated
647
- };
648
- if (result?.productList) {
667
+ const result = rulesModule.calcDiscount(
668
+ {
669
+ productList: tempOrder.products,
670
+ discountList: updated,
671
+ holders,
672
+ isFormSubject: !!((_b = tempOrder.holder) == null ? void 0 : _b.type) && tempOrder.holder.type === "form"
673
+ },
674
+ {
675
+ discountId: params.discountId,
676
+ isSelected: params.isSelected
677
+ }
678
+ ) || { productList: tempOrder.products, discountList: updated };
679
+ if (result == null ? void 0 : result.productList) {
649
680
  tempOrder.products = result.productList;
650
681
  }
651
- if (result?.discountList) {
682
+ if (result == null ? void 0 : result.discountList) {
652
683
  nextDiscountList = result.discountList;
653
684
  if (!params.isSelected) {
654
- const beforeSelectedIds = new Set(updated.filter(d => d.isSelected).map(d => d.id));
685
+ const beforeSelectedIds = new Set(
686
+ updated.filter((d) => d.isSelected).map((d) => d.id)
687
+ );
655
688
  for (const d of nextDiscountList) {
656
689
  if (d.isSelected && !beforeSelectedIds.has(d.id)) {
657
690
  d.isSelected = false;
@@ -660,92 +693,88 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
660
693
  }
661
694
  }
662
695
  }
663
- const selectedResourceIds = new Set(nextDiscountList.filter(d => d.isSelected).map(d => d.id));
696
+ const selectedResourceIds = new Set(
697
+ nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
698
+ );
664
699
  for (const product of tempOrder.products) {
665
- if (product._origin?.isManualDiscount) continue;
666
- product.discount_list = (product.discount_list || []).filter(pd => {
667
- const rid = pd.discount?.resource_id ?? pd.id;
700
+ if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
701
+ continue;
702
+ product.discount_list = (product.discount_list || []).filter((pd) => {
703
+ var _a2;
704
+ const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
668
705
  return rid != null && selectedResourceIds.has(rid);
669
706
  });
670
-
671
- // 券作用于 source(不含 option、不含 bundle);算出新 source 折后价后补回 options
672
- // 写入含 option 的 main_product_selling_price,再合成 composite 回写 selling_price。
673
- const totalPerUnitDiscount = (product.discount_list || []).reduce((sum, pd) => sum + (pd.amount || 0), 0);
674
- const optionSum = (0, _utils2.sumOptionUnitPrice)((0, _utils2.getProductSkuOptions)(product));
675
- const sourcePrice = product.metadata?.source_product_price ?? (product.metadata?.main_product_original_price != null ? new _decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? '0');
676
- const newSourceSellingPrice = new _decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
677
- const newMainSellingPrice = new _decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
707
+ const totalPerUnitDiscount = (product.discount_list || []).reduce(
708
+ (sum, pd) => sum + (pd.amount || 0),
709
+ 0
710
+ );
711
+ const optionSum = (0, import_utils2.sumOptionUnitPrice)((0, import_utils2.getProductSkuOptions)(product));
712
+ const sourcePrice = ((_d = product.metadata) == null ? void 0 : _d.source_product_price) ?? (((_e = product.metadata) == null ? void 0 : _e.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
713
+ const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
714
+ const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
678
715
  if (product.metadata) {
679
716
  product.metadata.main_product_selling_price = newMainSellingPrice;
680
717
  product.metadata.price_schema_version = 2;
681
718
  }
682
- product.selling_price = (0, _utils2.composeLinePrice)({
719
+ product.selling_price = (0, import_utils2.composeLinePrice)({
683
720
  mainPrice: newMainSellingPrice,
684
721
  bundle: product.product_bundle
685
722
  });
686
723
  }
687
- _Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
688
- await discountModule?.setDiscountList(nextDiscountList);
689
- tempOrder.discount_list = (nextDiscountList || []).filter(d => d.isSelected);
690
- await this.store.order.recalculateSummary({
691
- createIfMissing: true
692
- });
724
+ import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
725
+ await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
726
+ tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
727
+ await this.store.order.recalculateSummary({ createIfMissing: true });
693
728
  this.store.order.persistTempOrder();
694
- this.logMethodSuccess('setDiscountSelected', params);
729
+ this.logMethodSuccess("setDiscountSelected", params);
695
730
  } catch (error) {
696
- this.logMethodError('setDiscountSelected', error);
731
+ this.logMethodError("setDiscountSelected", error);
697
732
  throw error;
698
733
  }
699
734
  }
700
735
  async onCustomerLogin(params) {
701
- this.logMethodStart('onCustomerLogin', {
702
- customerId: params.customerId
703
- });
736
+ this.logMethodStart("onCustomerLogin", { customerId: params.customerId });
704
737
  try {
705
738
  await this.refreshOrderMarketingAfterLogin({
706
739
  customerId: params.customerId
707
740
  });
708
- this.logMethodSuccess('onCustomerLogin', {
709
- customerId: params.customerId
710
- });
741
+ this.logMethodSuccess("onCustomerLogin", { customerId: params.customerId });
711
742
  } catch (error) {
712
- this.logMethodError('onCustomerLogin', error);
743
+ this.logMethodError("onCustomerLogin", error);
713
744
  throw error;
714
745
  }
715
746
  }
716
747
  findReservationRuleResource(formId) {
717
- if (formId == null) return undefined;
748
+ var _a;
749
+ if (formId == null)
750
+ return void 0;
718
751
  const numericFormId = Number(formId);
719
- if (!Number.isFinite(numericFormId) || numericFormId <= 0) return undefined;
752
+ if (!Number.isFinite(numericFormId) || numericFormId <= 0)
753
+ return void 0;
720
754
  for (const product of this.enabledReservationRuleProducts) {
721
- const resources = product?.product_resource?.resources;
722
- if (!Array.isArray(resources)) continue;
723
- const matched = resources.find(resource => Number(resource?.id) === numericFormId);
724
- if (matched) return matched;
755
+ const resources = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources;
756
+ if (!Array.isArray(resources))
757
+ continue;
758
+ const matched = resources.find((resource) => Number(resource == null ? void 0 : resource.id) === numericFormId);
759
+ if (matched)
760
+ return matched;
725
761
  }
726
- return undefined;
762
+ return void 0;
727
763
  }
728
764
  buildScanOrderResourceMetadata(params) {
729
- const {
730
- resourceState,
731
- resourceName
732
- } = params;
765
+ const { resourceState, resourceName } = params;
733
766
  const ruleResource = this.findReservationRuleResource(resourceState.tableFormId);
734
- const combined = ruleResource?.combined_resource;
767
+ const combined = ruleResource == null ? void 0 : ruleResource.combined_resource;
735
768
  const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
736
769
  return {
737
- form_name: ruleResource?.title ?? '',
770
+ form_name: (ruleResource == null ? void 0 : ruleResource.title) ?? "",
738
771
  resource_name: resourceName,
739
772
  combined_resource: isCombined ? combined : null
740
773
  };
741
774
  }
742
775
  async prepareRetailAvailability(params) {
743
- const {
744
- tempOrder,
745
- hasOrderId,
746
- resourceId,
747
- reason
748
- } = params;
776
+ var _a, _b;
777
+ const { tempOrder, hasOrderId, resourceId, reason } = params;
749
778
  this.enabledReservationRuleProducts = [];
750
779
  tempOrder.bookings = [];
751
780
  tempOrder.order_id = null;
@@ -753,12 +782,10 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
753
782
  delete tempOrder.table_form_id;
754
783
  delete tempOrder.resource_id;
755
784
  delete tempOrder.table_number;
756
- tempOrder.metadata = {
757
- ...(tempOrder.metadata || {})
758
- };
785
+ tempOrder.metadata = { ...tempOrder.metadata || {} };
759
786
  delete tempOrder.metadata.table_occupancy_duration;
760
787
  const resourceState = {
761
- mode: 'idle',
788
+ mode: "idle",
762
789
  deskmate_valid: false,
763
790
  allowSnack: false,
764
791
  deskmateValid: false,
@@ -767,18 +794,18 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
767
794
  raw: null
768
795
  };
769
796
  this.store.resource = resourceState;
770
- this.store.order?.persistTempOrder();
797
+ (_a = this.store.order) == null ? void 0 : _a.persistTempOrder();
771
798
  await this.addNewOrder();
772
799
  await this.setItemRuleRuntimeConfig({
773
- serviceType: this.otherParams?.businessCode,
800
+ serviceType: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
774
801
  submissionIndex: hasOrderId ? 1 : 0,
775
802
  historicalItems: []
776
803
  });
777
804
  const availabilityInfo = {
778
- mode: 'idle',
805
+ mode: "idle",
779
806
  deskmate_valid: false
780
807
  };
781
- this.logMethodSuccess('checkResourceAvailable', {
808
+ this.logMethodSuccess("checkResourceAvailable", {
782
809
  resourceId,
783
810
  mode: availabilityInfo.mode,
784
811
  retailMode: true,
@@ -788,7 +815,6 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
788
815
  });
789
816
  return availabilityInfo;
790
817
  }
791
-
792
818
  // ScanOrder 提交 payload enhancer:
793
819
  // - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
794
820
  // - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
@@ -797,45 +823,45 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
797
823
  buildSubmitPayloadEnhancer() {
798
824
  const ruleProduct = this.enabledReservationRuleProducts[0];
799
825
  const resourceState = this.store.resource;
800
- const resourceSelectType = resourceState?.resourceSelectType;
801
-
802
- // ScanOrder 的 booking 容量只由预约规则决定:single 占用整张桌台,multiple 占用 1 个容量位。
826
+ const resourceSelectType = resourceState == null ? void 0 : resourceState.resourceSelectType;
803
827
  const resolveBookingCapacityValue = () => {
804
- if (resourceSelectType === 'single') {
805
- const raw = resourceState?.table_form_record?.capacity;
828
+ var _a;
829
+ if (resourceSelectType === "single") {
830
+ const raw = (_a = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _a.capacity;
806
831
  const num = Number(raw);
807
- if (Number.isFinite(num) && num > 0) return Math.max(1, Math.floor(num));
832
+ if (Number.isFinite(num) && num > 0)
833
+ return Math.max(1, Math.floor(num));
808
834
  return 1;
809
835
  }
810
836
  return 1;
811
837
  };
812
- return (payload, {
813
- bookingUuid,
814
- tempOrder
815
- }) => {
816
- const resourceId = String(resourceState?.relationId ?? '').trim();
817
- const hasReservationBookingContext = Boolean(ruleProduct && resourceState && resourceId && resourceState.relationId && resourceState.tableFormId);
838
+ return (payload, { bookingUuid, tempOrder }) => {
839
+ var _a, _b;
840
+ const resourceId = String((resourceState == null ? void 0 : resourceState.relationId) ?? "").trim();
841
+ const hasReservationBookingContext = Boolean(
842
+ ruleProduct && resourceState && resourceId && resourceState.relationId && resourceState.tableFormId
843
+ );
818
844
  if (!hasReservationBookingContext) {
819
845
  return {
820
846
  ...payload,
821
847
  bookings: [],
822
- products: [...(payload.products || [])]
848
+ products: [...payload.products || []]
823
849
  };
824
850
  }
825
- const rawCollectPax = tempOrder.metadata?.collect_pax;
826
- const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
851
+ const rawCollectPax = (_a = tempOrder.metadata) == null ? void 0 : _a.collect_pax;
852
+ const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== void 0 && rawCollectPax !== "";
827
853
  const bookingCapacityValue = resolveBookingCapacityValue();
828
- const pickOriginal = value => {
829
- if (value && typeof value === 'object' && !Array.isArray(value)) {
854
+ const pickOriginal = (value) => {
855
+ if (value && typeof value === "object" && !Array.isArray(value)) {
830
856
  const original = value.original;
831
- return typeof original === 'string' && original.length > 0 ? original : undefined;
857
+ return typeof original === "string" && original.length > 0 ? original : void 0;
832
858
  }
833
- return undefined;
859
+ return void 0;
834
860
  };
835
- const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal(resourceState?.table_form_record?.name) ?? '';
861
+ const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal((_b = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _b.name) ?? "";
836
862
  const resourceEntry = resourceState && resourceId ? {
837
- relation_type: 'form',
838
- like_status: 'common',
863
+ relation_type: "form",
864
+ like_status: "common",
839
865
  id: Number(resourceId),
840
866
  main_field: mainField,
841
867
  form_id: resourceState.tableFormId,
@@ -845,48 +871,43 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
845
871
  resourceState,
846
872
  resourceName: mainField
847
873
  })
848
- } : undefined;
849
- const ruleProductUid = ruleProduct ? (0, _utils2.createUuidV4)() : undefined;
850
- const bookingCapacityDimensionId = (0, _utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
874
+ } : void 0;
875
+ const ruleProductUid = ruleProduct ? (0, import_utils2.createUuidV4)() : void 0;
876
+ const bookingCapacityDimensionId = (0, import_utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
851
877
  const nextBookings = (payload.bookings || []).map((booking, idx) => {
852
- const metadata = {
853
- ...(booking.metadata || {})
854
- };
878
+ const metadata = { ...booking.metadata || {} };
855
879
  if (hasExplicitCollectPax) {
856
- metadata.collect_pax = (0, _utils2.normalizeSubmitCollectPaxValue)(rawCollectPax);
880
+ metadata.collect_pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(rawCollectPax);
857
881
  } else {
858
882
  delete metadata.collect_pax;
859
883
  }
860
884
  return {
861
885
  ...booking,
862
886
  number: bookingCapacityValue,
863
- appointment_status: 'started',
887
+ appointment_status: "started",
864
888
  metadata: {
865
889
  ...metadata,
866
- ...(resourceSelectType ? {
867
- resource_select_type: resourceSelectType
868
- } : {}),
869
- ...(resourceSelectType ? {
870
- capacity: [{
871
- id: bookingCapacityDimensionId,
872
- value: bookingCapacityValue,
873
- name: ''
874
- }]
875
- } : {})
890
+ ...resourceSelectType ? { resource_select_type: resourceSelectType } : {},
891
+ ...resourceSelectType ? {
892
+ capacity: [
893
+ {
894
+ id: bookingCapacityDimensionId,
895
+ value: bookingCapacityValue,
896
+ name: ""
897
+ }
898
+ ]
899
+ } : {}
876
900
  },
877
- ...(idx === 0 && resourceEntry ? {
878
- resources: [resourceEntry]
879
- } : {}),
880
- ...(idx === 0 && ruleProductUid ? {
881
- product_uid: ruleProductUid
882
- } : {})
901
+ ...idx === 0 && resourceEntry ? { resources: [resourceEntry] } : {},
902
+ ...idx === 0 && ruleProductUid ? { product_uid: ruleProductUid } : {}
883
903
  };
884
904
  });
885
- const nextProducts = [...(payload.products || [])];
886
- // 加餐(已有 order_id)走 scanOrderMore,原单已含 booking 规则行,勿再追加虚拟规则商品
905
+ const nextProducts = [...payload.products || []];
887
906
  if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
888
- const sellingPrice = String(ruleProduct.price ?? '0.00');
889
- const originalPrice = String(ruleProduct.original_price ?? ruleProduct.price ?? '0.00');
907
+ const sellingPrice = String(ruleProduct.price ?? "0.00");
908
+ const originalPrice = String(
909
+ ruleProduct.original_price ?? ruleProduct.price ?? "0.00"
910
+ );
890
911
  nextProducts.push({
891
912
  product_id: ruleProduct.id,
892
913
  product_variant_id: 0,
@@ -895,9 +916,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
895
916
  original_price: originalPrice,
896
917
  payment_price: sellingPrice,
897
918
  is_charge_tax: ruleProduct.is_gst ?? 0,
898
- product_sku: {
899
- option: []
900
- },
919
+ product_sku: { option: [] },
901
920
  discount_list: [],
902
921
  product_bundle: [],
903
922
  booking_uid: bookingUuid,
@@ -908,50 +927,50 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
908
927
  }
909
928
  });
910
929
  }
911
- return {
912
- ...payload,
913
- bookings: nextBookings,
914
- products: nextProducts
915
- };
930
+ return { ...payload, bookings: nextBookings, products: nextProducts };
916
931
  };
917
932
  }
918
933
  isScanOrderMoreMode(tempOrder) {
919
- const mode = this.store.resource?.mode;
920
- return Boolean(tempOrder.order_id && (mode === 'additional_order' || mode === 'additional_order_with_code' || this.store.entryContext?.mode === 'append'));
934
+ var _a, _b;
935
+ const mode = (_a = this.store.resource) == null ? void 0 : _a.mode;
936
+ return Boolean(
937
+ tempOrder.order_id && (mode === "additional_order" || mode === "additional_order_with_code" || ((_b = this.store.entryContext) == null ? void 0 : _b.mode) === "append")
938
+ );
921
939
  }
922
940
  async submitScanOrderMore(params) {
941
+ var _a, _b, _c, _d, _e;
923
942
  if (!this.request) {
924
- throw new Error('scanOrder解决方案需要 request 插件支持');
943
+ throw new Error("scanOrder解决方案需要 request 插件支持");
925
944
  }
926
945
  if (!this.store.order) {
927
- throw new Error('scanOrder解决方案需要 order 模块支持');
946
+ throw new Error("scanOrder解决方案需要 order 模块支持");
928
947
  }
929
- const {
930
- tempOrder,
931
- enhancePayload
932
- } = params;
948
+ const { tempOrder, enhancePayload } = params;
933
949
  const latestSummary = await this.store.order.recalculateSummary({
934
950
  createIfMissing: true
935
951
  });
936
- const payload = (0, _utils2.buildSubmitPayload)({
937
- tempOrder: tempOrder,
952
+ const payload = (0, import_utils2.buildSubmitPayload)({
953
+ tempOrder,
938
954
  cacheId: this.cacheId,
939
- platform: this.otherParams?.platform,
940
- businessCode: this.otherParams?.businessCode || this.otherParams?.business_code,
941
- channel: this.otherParams?.channel,
942
- type: this.otherParams?.type,
955
+ platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
956
+ businessCode: ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code),
957
+ channel: (_d = this.otherParams) == null ? void 0 : _d.channel,
958
+ type: (_e = this.otherParams) == null ? void 0 : _e.type,
943
959
  summary: latestSummary,
944
960
  enhance: enhancePayload
945
961
  });
946
- const products = (0, _utils.filterProductsForScanOrderMore)(payload.products);
962
+ const products = (0, import_utils.filterProductsForScanOrderMore)(payload.products);
947
963
  const orderId = tempOrder.order_id;
948
- const result = await this.request.put(`/order/order/product/${orderId}`, {
949
- products,
950
- request_unique_idempotency_token: payload.request_unique_idempotency_token
951
- }, {
952
- customToast: () => {}
953
- });
954
- if (result?.code === 200 && !result?.data) {
964
+ const result = await this.request.put(
965
+ `/order/order/product/${orderId}`,
966
+ {
967
+ products,
968
+ request_unique_idempotency_token: payload.request_unique_idempotency_token
969
+ },
970
+ { customToast: () => {
971
+ } }
972
+ );
973
+ if ((result == null ? void 0 : result.code) === 200 && !(result == null ? void 0 : result.data)) {
955
974
  return {
956
975
  ...result,
957
976
  data: {
@@ -962,22 +981,20 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
962
981
  return result;
963
982
  }
964
983
  async submitScanOrder() {
965
- this.logMethodStart('submitScanOrder');
984
+ var _a, _b, _c;
985
+ this.logMethodStart("submitScanOrder");
966
986
  try {
967
987
  await this.validateBeforeSubmitByItemRule();
968
988
  if (!this.store.order) {
969
- throw new Error('scanOrder解决方案需要 order 模块支持');
989
+ throw new Error("scanOrder解决方案需要 order 模块支持");
970
990
  }
971
- const pax = (0, _utils2.normalizeSubmitCollectPaxValue)(this.store.entryPaxNumber);
991
+ const pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(this.store.entryPaxNumber);
972
992
  this.store.entryPaxNumber = pax;
973
993
  const tempOrderForSubmit = this.store.order.ensureTempOrder();
974
- tempOrderForSubmit.metadata = {
975
- ...tempOrderForSubmit.metadata,
976
- collect_pax: pax
977
- };
978
- tempOrderForSubmit.delivery_type = 'shop_service';
979
- const resourceTableName = this.store.resource?.table_form_record?.name;
980
- if (resourceTableName && typeof resourceTableName === 'object') {
994
+ tempOrderForSubmit.metadata = { ...tempOrderForSubmit.metadata, collect_pax: pax };
995
+ tempOrderForSubmit.delivery_type = "shop_service";
996
+ const resourceTableName = (_b = (_a = this.store.resource) == null ? void 0 : _a.table_form_record) == null ? void 0 : _b.name;
997
+ if (resourceTableName && typeof resourceTableName === "object") {
981
998
  tempOrderForSubmit.table_number = resourceTableName;
982
999
  } else {
983
1000
  delete tempOrderForSubmit.table_number;
@@ -991,60 +1008,61 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
991
1008
  enhancePayload
992
1009
  });
993
1010
  const tempOrder = this.store.order.getTempOrder();
994
- this.logMethodSuccess('submitScanOrder', {
995
- productCount: tempOrder?.products?.length || 0
1011
+ this.logMethodSuccess("submitScanOrder", {
1012
+ productCount: ((_c = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _c.length) || 0
996
1013
  });
997
1014
  return result;
998
1015
  } catch (error) {
999
- this.logMethodError('submitScanOrder', error);
1016
+ this.logMethodError("submitScanOrder", error);
1000
1017
  throw error;
1001
1018
  }
1002
1019
  }
1003
1020
  async addProductToOrder(product) {
1004
- this.logMethodStart('addProductToOrder', {
1021
+ this.logMethodStart("addProductToOrder", {
1005
1022
  product_id: product.product_id,
1006
1023
  product_variant_id: product.product_variant_id
1007
1024
  });
1008
1025
  try {
1009
- if (!this.store.order) throw new Error('order 模块未初始化');
1026
+ if (!this.store.order)
1027
+ throw new Error("order 模块未初始化");
1010
1028
  const products = await this.store.order.addProductToOrder(product);
1011
1029
  await this.refreshItemRuleQuantityLimits();
1012
1030
  await this.refreshCartValidationPassed();
1013
- this.logMethodSuccess('addProductToOrder', {
1031
+ this.logMethodSuccess("addProductToOrder", {
1014
1032
  productCount: products.length
1015
1033
  });
1016
1034
  return products;
1017
1035
  } catch (error) {
1018
- this.logMethodError('addProductToOrder', error);
1036
+ this.logMethodError("addProductToOrder", error);
1019
1037
  throw error;
1020
1038
  }
1021
1039
  }
1022
1040
  async updateOrderProduct(params) {
1023
- this.logMethodStart('updateOrderProduct', {
1041
+ this.logMethodStart("updateOrderProduct", {
1024
1042
  product_id: params.product_id,
1025
1043
  product_variant_id: params.product_variant_id
1026
1044
  });
1027
1045
  try {
1028
- if (!this.store.order) throw new Error('order 模块未初始化');
1046
+ if (!this.store.order)
1047
+ throw new Error("order 模块未初始化");
1029
1048
  const products = await this.store.order.updateOrderProduct(params);
1030
1049
  await this.refreshItemRuleQuantityLimits();
1031
1050
  await this.refreshCartValidationPassed();
1032
- this.logMethodSuccess('updateOrderProduct', {
1051
+ this.logMethodSuccess("updateOrderProduct", {
1033
1052
  productCount: products.length
1034
1053
  });
1035
1054
  return products;
1036
1055
  } catch (error) {
1037
- this.logMethodError('updateOrderProduct', error);
1056
+ this.logMethodError("updateOrderProduct", error);
1038
1057
  throw error;
1039
1058
  }
1040
1059
  }
1041
-
1042
1060
  /**
1043
1061
  * 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
1044
1062
  * 多行同 SKU 时必须传入与删除/更新一致的 identity(如 `identity_key`)。
1045
1063
  */
1046
1064
  async setOrderProductLineNote(identity, note) {
1047
- this.logMethodStart('setOrderProductLineNote', {
1065
+ this.logMethodStart("setOrderProductLineNote", {
1048
1066
  product_id: identity.product_id,
1049
1067
  product_variant_id: identity.product_variant_id
1050
1068
  });
@@ -1052,47 +1070,46 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1052
1070
  const params = {
1053
1071
  product_id: identity.product_id,
1054
1072
  product_variant_id: identity.product_variant_id,
1055
- updates: {
1056
- note: String(note || '')
1057
- }
1073
+ updates: { note: String(note || "") }
1058
1074
  };
1059
- if (identity.identity_key !== undefined) params.identity_key = identity.identity_key;
1060
- if (identity.product_sku !== undefined) {
1075
+ if (identity.identity_key !== void 0)
1076
+ params.identity_key = identity.identity_key;
1077
+ if (identity.product_sku !== void 0) {
1061
1078
  params.product_sku = identity.product_sku;
1062
1079
  }
1063
- if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
1080
+ if (identity.product_bundle !== void 0)
1081
+ params.product_bundle = identity.product_bundle;
1064
1082
  const products = await this.updateOrderProduct(params);
1065
- this.logMethodSuccess('setOrderProductLineNote', {
1066
- productCount: products.length
1067
- });
1083
+ this.logMethodSuccess("setOrderProductLineNote", { productCount: products.length });
1068
1084
  return products;
1069
1085
  } catch (error) {
1070
- this.logMethodError('setOrderProductLineNote', error);
1086
+ this.logMethodError("setOrderProductLineNote", error);
1071
1087
  throw error;
1072
1088
  }
1073
1089
  }
1074
1090
  async removeProductFromOrder(identity) {
1075
- this.logMethodStart('removeProductFromOrder', {
1091
+ this.logMethodStart("removeProductFromOrder", {
1076
1092
  product_id: identity.product_id,
1077
1093
  product_variant_id: identity.product_variant_id
1078
1094
  });
1079
1095
  try {
1080
- if (!this.store.order) throw new Error('order 模块未初始化');
1096
+ if (!this.store.order)
1097
+ throw new Error("order 模块未初始化");
1081
1098
  const products = await this.store.order.removeProductFromOrder(identity);
1082
1099
  await this.refreshItemRuleQuantityLimits();
1083
1100
  await this.refreshCartValidationPassed();
1084
- this.logMethodSuccess('removeProductFromOrder', {
1101
+ this.logMethodSuccess("removeProductFromOrder", {
1085
1102
  productCount: products.length
1086
1103
  });
1087
1104
  return products;
1088
1105
  } catch (error) {
1089
- this.logMethodError('removeProductFromOrder', error);
1106
+ this.logMethodError("removeProductFromOrder", error);
1090
1107
  throw error;
1091
1108
  }
1092
1109
  }
1093
1110
  async loadRuntimeConfigs() {
1094
1111
  const itemRuleConfigs = await this.ensureItemRuleConfigsLoaded();
1095
- this.logMethodSuccess('loadRuntimeConfigs', {
1112
+ this.logMethodSuccess("loadRuntimeConfigs", {
1096
1113
  itemRuleCount: itemRuleConfigs.length
1097
1114
  });
1098
1115
  return {
@@ -1100,24 +1117,28 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1100
1117
  };
1101
1118
  }
1102
1119
  async syncItemRuleConfigsFromDineInConfig(dineInConfig) {
1103
- const enableItemRules = (0, _utils.toBoolean)(dineInConfig?.['sale.enable_item_rules']);
1104
- const strategyModelIds = (0, _utils.normalizeEnabledItemRuleIds)(dineInConfig?.['sale.enabled_item_rules']);
1120
+ const enableItemRules = (0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["sale.enable_item_rules"]);
1121
+ const strategyModelIds = (0, import_utils.normalizeEnabledItemRuleIds)(
1122
+ dineInConfig == null ? void 0 : dineInConfig["sale.enabled_item_rules"]
1123
+ );
1105
1124
  if (!enableItemRules || !strategyModelIds.length) {
1106
1125
  this.itemRuleConfigs = [];
1107
1126
  this.itemRuleConfigsPromise = Promise.resolve([]);
1108
1127
  this.itemRuleEvaluator.setStrategyConfigs([]);
1109
- this.logMethodSuccess('syncItemRuleConfigsFromDineInConfig', {
1128
+ this.logMethodSuccess("syncItemRuleConfigsFromDineInConfig", {
1110
1129
  enabled: enableItemRules,
1111
1130
  strategyModelIds: [],
1112
1131
  itemRuleCount: 0
1113
1132
  });
1114
1133
  return [];
1115
1134
  }
1116
- const itemRuleConfigs = await this.fetchItemRuleConfigsByModelIds(strategyModelIds);
1135
+ const itemRuleConfigs = await this.fetchItemRuleConfigsByModelIds(
1136
+ strategyModelIds
1137
+ );
1117
1138
  this.itemRuleConfigs = itemRuleConfigs;
1118
1139
  this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
1119
1140
  this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
1120
- this.logMethodSuccess('syncItemRuleConfigsFromDineInConfig', {
1141
+ this.logMethodSuccess("syncItemRuleConfigsFromDineInConfig", {
1121
1142
  enabled: enableItemRules,
1122
1143
  strategyModelIds,
1123
1144
  itemRuleCount: itemRuleConfigs.length
@@ -1125,70 +1146,76 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1125
1146
  return itemRuleConfigs;
1126
1147
  }
1127
1148
  async fetchItemRuleConfigsByModelIds(strategyModelIds) {
1128
- this.logMethodStart('fetchItemRuleConfigsByModelIds', {
1149
+ this.logMethodStart("fetchItemRuleConfigsByModelIds", {
1129
1150
  strategyModelIds
1130
1151
  });
1131
- if (!strategyModelIds.length) return [];
1152
+ if (!strategyModelIds.length)
1153
+ return [];
1132
1154
  try {
1133
- const result = await this.request.get('/promotion', {
1155
+ const result = await this.request.get("/promotion", {
1134
1156
  skip: 1,
1135
1157
  num: 99,
1136
- status: 'active',
1158
+ status: "active",
1137
1159
  ids: strategyModelIds
1138
1160
  });
1139
1161
  let configs = [];
1140
1162
  if (result.code === 200) {
1141
- configs = result.data.list.map(item => {
1163
+ configs = result.data.list.map((item) => {
1142
1164
  return item.metadata;
1143
1165
  });
1144
1166
  }
1145
- this.logMethodSuccess('fetchItemRuleConfigsByModelIds', {
1167
+ this.logMethodSuccess("fetchItemRuleConfigsByModelIds", {
1146
1168
  strategyModelIds,
1147
1169
  strategyCount: configs.length
1148
1170
  });
1149
1171
  return configs;
1150
1172
  } catch (error) {
1151
- this.logMethodError('fetchItemRuleConfigsByModelIds', error, {
1173
+ this.logMethodError("fetchItemRuleConfigsByModelIds", error, {
1152
1174
  strategyModelIds
1153
1175
  });
1154
- // A:策略加载失败时不阻塞下单
1155
1176
  return [];
1156
1177
  }
1157
1178
  }
1158
1179
  async buildPrefillProductSourceMap() {
1159
- const sourceMap = new Map();
1180
+ const sourceMap = /* @__PURE__ */ new Map();
1160
1181
  try {
1161
1182
  const productList = await this.getProductList();
1162
- if (!Array.isArray(productList)) return sourceMap;
1163
- const visited = new Set();
1164
- const collectFromValue = value => {
1165
- if (!value || typeof value !== 'object') return;
1166
- if (visited.has(value)) return;
1183
+ if (!Array.isArray(productList))
1184
+ return sourceMap;
1185
+ const visited = /* @__PURE__ */ new Set();
1186
+ const collectFromValue = (value) => {
1187
+ if (!value || typeof value !== "object")
1188
+ return;
1189
+ if (visited.has(value))
1190
+ return;
1167
1191
  visited.add(value);
1168
1192
  if (Array.isArray(value)) {
1169
- for (const item of value) collectFromValue(item);
1193
+ for (const item of value)
1194
+ collectFromValue(item);
1170
1195
  return;
1171
1196
  }
1172
1197
  const node = value;
1173
1198
  const rawProductId = node.product_id ?? node.id;
1174
1199
  const productId = Number(rawProductId);
1175
1200
  if (Number.isFinite(productId) && productId > 0) {
1176
- const productVariantId = Number(node.product_variant_id ?? node.variant_id ?? 0);
1201
+ const productVariantId = Number(
1202
+ node.product_variant_id ?? node.variant_id ?? 0
1203
+ );
1177
1204
  const normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
1178
- const key = (0, _utils.buildProductKey)(productId, normalizedVariantId);
1205
+ const key = (0, import_utils.buildProductKey)(productId, normalizedVariantId);
1179
1206
  if (!sourceMap.has(key)) {
1180
1207
  sourceMap.set(key, node);
1181
1208
  }
1182
1209
  }
1183
1210
  for (const childValue of Object.values(node)) {
1184
- if (childValue && typeof childValue === 'object') {
1211
+ if (childValue && typeof childValue === "object") {
1185
1212
  collectFromValue(childValue);
1186
1213
  }
1187
1214
  }
1188
1215
  };
1189
1216
  collectFromValue(productList);
1190
1217
  } catch (error) {
1191
- this.logMethodError('buildPrefillProductSourceMap', error);
1218
+ this.logMethodError("buildPrefillProductSourceMap", error);
1192
1219
  }
1193
1220
  return sourceMap;
1194
1221
  }
@@ -1196,11 +1223,13 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1196
1223
  return this.itemRuleRuntimeConfig || {};
1197
1224
  }
1198
1225
  async ensureItemRuleConfigsLoaded() {
1199
- if (this.itemRuleConfigs.length > 0) return this.itemRuleConfigs;
1200
- if (this.itemRuleConfigsPromise) return this.itemRuleConfigsPromise;
1226
+ if (this.itemRuleConfigs.length > 0)
1227
+ return this.itemRuleConfigs;
1228
+ if (this.itemRuleConfigsPromise)
1229
+ return this.itemRuleConfigsPromise;
1201
1230
  this.itemRuleConfigsPromise = (async () => {
1202
1231
  const runtimeConfig = this.getItemRuleRuntimeConfig();
1203
- const staticConfigs = (0, _utils.normalizeItemRuleStrategies)(runtimeConfig.strategyConfigs);
1232
+ const staticConfigs = (0, import_utils.normalizeItemRuleStrategies)(runtimeConfig.strategyConfigs);
1204
1233
  if (staticConfigs.length > 0) {
1205
1234
  this.itemRuleConfigs = staticConfigs;
1206
1235
  this.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
@@ -1220,29 +1249,33 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1220
1249
  this.store.itemRuleQuantityLimits = [];
1221
1250
  return [];
1222
1251
  }
1223
- const businessData = (0, _utils.buildItemRuleBusinessData)({
1252
+ const businessData = (0, import_utils.buildItemRuleBusinessData)({
1224
1253
  tempOrder: this.ensureScanOrderTempOrder(),
1225
1254
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1226
1255
  itemRuleConfigs: this.itemRuleConfigs
1227
1256
  });
1228
1257
  const limits = this.itemRuleEvaluator.getQuantityLimits(businessData);
1229
1258
  this.store.itemRuleQuantityLimits = limits;
1230
- this.logMethodSuccess('refreshItemRuleQuantityLimits', {
1259
+ this.logMethodSuccess("refreshItemRuleQuantityLimits", {
1231
1260
  limitCount: limits.length
1232
1261
  });
1233
1262
  return limits;
1234
1263
  } catch (error) {
1235
1264
  this.store.itemRuleQuantityLimits = [];
1236
- this.logMethodError('refreshItemRuleQuantityLimits', error);
1265
+ this.logMethodError("refreshItemRuleQuantityLimits", error);
1237
1266
  return [];
1238
1267
  }
1239
1268
  }
1240
1269
  async applyPrefillByItemRule() {
1241
- if (this.itemRulePrefillApplied) return;
1242
- if (!this.store.order) return;
1270
+ var _a, _b, _c;
1271
+ if (this.itemRulePrefillApplied)
1272
+ return;
1273
+ if (!this.store.order)
1274
+ return;
1243
1275
  const strategyConfigs = await this.ensureItemRuleConfigsLoaded();
1244
- if (!strategyConfigs.length) return;
1245
- const businessData = (0, _utils.buildItemRuleBusinessData)({
1276
+ if (!strategyConfigs.length)
1277
+ return;
1278
+ const businessData = (0, import_utils.buildItemRuleBusinessData)({
1246
1279
  tempOrder: this.ensureScanOrderTempOrder(),
1247
1280
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1248
1281
  itemRuleConfigs: this.itemRuleConfigs
@@ -1258,81 +1291,88 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1258
1291
  for (const prefillItem of prefillItems) {
1259
1292
  const productId = Number(prefillItem.product_id);
1260
1293
  const productVariantId = Number(prefillItem.product_variant_id ?? 0);
1261
- const targetQuantity = (0, _utils.toNonNegativeInt)(prefillItem.quantity);
1262
- if (!Number.isFinite(productId) || targetQuantity <= 0) continue;
1263
- if (Number.isNaN(productVariantId)) continue;
1264
- const sourceItem = productSourceMap.get((0, _utils.buildProductKey)(productId, productVariantId)) || productSourceMap.get((0, _utils.buildProductKey)(productId, 0)) || null;
1265
- const productIndex = (0, _utils.getProductIdentityIndex)(tempOrder.products, {
1294
+ const targetQuantity = (0, import_utils.toNonNegativeInt)(prefillItem.quantity);
1295
+ if (!Number.isFinite(productId) || targetQuantity <= 0)
1296
+ continue;
1297
+ if (Number.isNaN(productVariantId))
1298
+ continue;
1299
+ const sourceItem = productSourceMap.get(
1300
+ (0, import_utils.buildProductKey)(productId, productVariantId)
1301
+ ) || productSourceMap.get((0, import_utils.buildProductKey)(productId, 0)) || null;
1302
+ const productIndex = (0, import_utils.getProductIdentityIndex)(tempOrder.products, {
1266
1303
  product_id: productId,
1267
1304
  product_variant_id: productVariantId
1268
1305
  });
1269
1306
  if (productIndex === -1) {
1270
- const sellingPrice = (0, _utils.toPriceString)(sourceItem?.price ?? sourceItem?.selling_price, '0.00');
1271
- tempOrder.products.push((0, _utils.normalizeOrderProduct)({
1272
- ...sourceItem,
1273
- product_id: productId,
1274
- product_variant_id: productVariantId,
1275
- num: targetQuantity,
1276
- selling_price: sellingPrice,
1277
- original_price: sellingPrice,
1278
- metadata: {
1279
- item_rule_prefill: true,
1280
- item_rule_id: prefillItem.ruleId
1281
- },
1282
- _origin: {
1283
- ...(sourceItem || {}),
1284
- item_rule_prefill: true,
1285
- item_rule_id: prefillItem.ruleId
1286
- }
1287
- }));
1307
+ const sellingPrice = (0, import_utils.toPriceString)(
1308
+ (sourceItem == null ? void 0 : sourceItem.price) ?? (sourceItem == null ? void 0 : sourceItem.selling_price),
1309
+ "0.00"
1310
+ );
1311
+ tempOrder.products.push(
1312
+ (0, import_utils.normalizeOrderProduct)({
1313
+ ...sourceItem,
1314
+ product_id: productId,
1315
+ product_variant_id: productVariantId,
1316
+ num: targetQuantity,
1317
+ selling_price: sellingPrice,
1318
+ original_price: sellingPrice,
1319
+ metadata: {
1320
+ item_rule_prefill: true,
1321
+ item_rule_id: prefillItem.ruleId
1322
+ },
1323
+ _origin: {
1324
+ ...sourceItem || {},
1325
+ item_rule_prefill: true,
1326
+ item_rule_id: prefillItem.ruleId
1327
+ }
1328
+ })
1329
+ );
1288
1330
  hasChanges = true;
1289
1331
  continue;
1290
1332
  }
1291
1333
  const targetProduct = tempOrder.products[productIndex];
1292
- const existedQuantity = (0, _utils.toNonNegativeInt)(targetProduct.num);
1334
+ const existedQuantity = (0, import_utils.toNonNegativeInt)(targetProduct.num);
1293
1335
  const delta = targetQuantity - existedQuantity;
1294
1336
  const nextProduct = {
1295
1337
  ...targetProduct,
1296
- ...(delta > 0 ? {
1297
- num: (0, _utils.getSafeProductNum)(existedQuantity + delta)
1298
- } : {}),
1338
+ ...delta > 0 ? { num: (0, import_utils.getSafeProductNum)(existedQuantity + delta) } : {},
1299
1339
  metadata: {
1300
- ...(targetProduct.metadata || {}),
1340
+ ...targetProduct.metadata || {},
1301
1341
  item_rule_prefill: true,
1302
1342
  item_rule_id: prefillItem.ruleId
1303
1343
  },
1304
1344
  _origin: sourceItem ? {
1305
- ...(targetProduct._origin || {}),
1345
+ ...targetProduct._origin || {},
1306
1346
  ...sourceItem
1307
1347
  } : targetProduct._origin
1308
1348
  };
1309
1349
  const hasQuantityChanged = delta > 0;
1310
- const hasOriginChanged = Boolean(sourceItem && (!targetProduct._origin || targetProduct._origin?.name !== sourceItem?.name || targetProduct._origin?.title !== sourceItem?.title || targetProduct._origin?.price !== sourceItem?.price));
1350
+ const hasOriginChanged = Boolean(
1351
+ sourceItem && (!targetProduct._origin || ((_a = targetProduct._origin) == null ? void 0 : _a.name) !== (sourceItem == null ? void 0 : sourceItem.name) || ((_b = targetProduct._origin) == null ? void 0 : _b.title) !== (sourceItem == null ? void 0 : sourceItem.title) || ((_c = targetProduct._origin) == null ? void 0 : _c.price) !== (sourceItem == null ? void 0 : sourceItem.price))
1352
+ );
1311
1353
  if (hasQuantityChanged || hasOriginChanged) {
1312
1354
  tempOrder.products[productIndex] = nextProduct;
1313
1355
  hasChanges = true;
1314
1356
  }
1315
1357
  }
1316
1358
  if (hasChanges) {
1317
- // Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
1318
1359
  this.store.order.applyDiscount();
1319
- await this.store.order.recalculateSummary({
1320
- createIfMissing: true
1321
- });
1360
+ await this.store.order.recalculateSummary({ createIfMissing: true });
1322
1361
  this.store.order.persistTempOrder();
1323
1362
  }
1324
1363
  await this.refreshItemRuleQuantityLimits();
1325
1364
  this.itemRulePrefillApplied = true;
1326
- this.logMethodSuccess('applyPrefillByItemRule', {
1365
+ this.logMethodSuccess("applyPrefillByItemRule", {
1327
1366
  prefillCount: prefillItems.length,
1328
1367
  hasChanges
1329
1368
  });
1330
1369
  }
1331
1370
  async applyItemRulePrefill() {
1332
- if (this.store.order?.getLastOrderInfo?.()) {
1371
+ var _a, _b;
1372
+ if ((_b = (_a = this.store.order) == null ? void 0 : _a.getLastOrderInfo) == null ? void 0 : _b.call(_a)) {
1333
1373
  return;
1334
1374
  }
1335
- this.logMethodStart('applyItemRulePrefill');
1375
+ this.logMethodStart("applyItemRulePrefill");
1336
1376
  await this.applyPrefillByItemRule();
1337
1377
  await this.refreshItemRuleQuantityLimits();
1338
1378
  await this.refreshCartValidationPassed();
@@ -1345,7 +1385,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1345
1385
  failures: []
1346
1386
  };
1347
1387
  }
1348
- const businessData = (0, _utils.buildItemRuleBusinessData)({
1388
+ const businessData = (0, import_utils.buildItemRuleBusinessData)({
1349
1389
  tempOrder: this.ensureScanOrderTempOrder(),
1350
1390
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1351
1391
  itemRuleConfigs: this.itemRuleConfigs
@@ -1354,9 +1394,10 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1354
1394
  }
1355
1395
  async validateBeforeSubmitByItemRule() {
1356
1396
  const validationResult = await this.evaluateCartValidationByItemRule();
1357
- if (validationResult.passed) return;
1397
+ if (validationResult.passed)
1398
+ return;
1358
1399
  const firstFailure = validationResult.failures[0];
1359
- const errorMessage = firstFailure?.validationMessage || '当前购物车未满足商品规则,请调整后再提交';
1400
+ const errorMessage = (firstFailure == null ? void 0 : firstFailure.validationMessage) || "当前购物车未满足商品规则,请调整后再提交";
1360
1401
  const error = new Error(String(errorMessage));
1361
1402
  error.failures = validationResult.failures;
1362
1403
  throw error;
@@ -1385,7 +1426,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1385
1426
  this.store.cartValidation = nextState;
1386
1427
  const changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
1387
1428
  if (changed) {
1388
- await this.core.effects.emit(_types.ScanOrderHooks.onCartValidationChanged, {
1429
+ await this.core.effects.emit(import_types.ScanOrderHooks.onCartValidationChanged, {
1389
1430
  cartValidation: nextState,
1390
1431
  cartValidationPassed: nextState.passed
1391
1432
  });
@@ -1393,20 +1434,21 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1393
1434
  return nextState.passed;
1394
1435
  }
1395
1436
  async setItemRuleRuntimeConfig(config = {}) {
1396
- this.logMethodStart('setItemRuleRuntimeConfig');
1437
+ var _a, _b;
1438
+ this.logMethodStart("setItemRuleRuntimeConfig");
1397
1439
  this.itemRuleRuntimeConfig = {
1398
1440
  ...this.itemRuleRuntimeConfig,
1399
1441
  ...config,
1400
1442
  pax: {
1401
- ...(this.itemRuleRuntimeConfig?.pax || {}),
1402
- ...(config?.pax || {})
1443
+ ...((_a = this.itemRuleRuntimeConfig) == null ? void 0 : _a.pax) || {},
1444
+ ...(config == null ? void 0 : config.pax) || {}
1403
1445
  },
1404
1446
  custom: {
1405
- ...(this.itemRuleRuntimeConfig?.custom || {}),
1406
- ...(config?.custom || {})
1447
+ ...((_b = this.itemRuleRuntimeConfig) == null ? void 0 : _b.custom) || {},
1448
+ ...(config == null ? void 0 : config.custom) || {}
1407
1449
  }
1408
1450
  };
1409
- if ('strategyConfigs' in config) {
1451
+ if ("strategyConfigs" in config) {
1410
1452
  this.itemRuleConfigs = [];
1411
1453
  this.itemRuleConfigsPromise = null;
1412
1454
  this.itemRuleEvaluator.setStrategyConfigs([]);
@@ -1414,47 +1456,42 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1414
1456
  this.itemRulePrefillApplied = false;
1415
1457
  await this.refreshItemRuleQuantityLimits();
1416
1458
  await this.refreshCartValidationPassed();
1417
- this.logMethodSuccess('setItemRuleRuntimeConfig', {
1459
+ this.logMethodSuccess("setItemRuleRuntimeConfig", {
1418
1460
  strategyCount: Array.isArray(this.itemRuleRuntimeConfig.strategyConfigs) ? this.itemRuleRuntimeConfig.strategyConfigs.length : 0
1419
1461
  });
1420
1462
  }
1421
1463
  normalizeResourceState(detail, resourceSelectType, hasOrderId) {
1422
- const currentOrderId = (0, _utils.toPositiveString)(detail?.order_id);
1423
- const lastOrderId = (0, _utils.toPositiveString)(detail?.last_order_id);
1424
- const relationId = (0, _utils.toPositiveString)(detail?.form_record_id);
1425
- const tableFormId = (0, _utils.toPositiveString)(detail?.form_id);
1426
- const formRecord = detail?.form_record ?? null;
1427
- // 是否允许加餐
1428
- const allowSnack = this.otherParams?.dineInConfig?.['sale.allow_add_items'] || false;
1429
- // 开启同桌验证 - 本期没有这个配置,默认关掉
1464
+ var _a, _b, _c, _d;
1465
+ const currentOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.order_id);
1466
+ const lastOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.last_order_id);
1467
+ const relationId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.form_record_id);
1468
+ const tableFormId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.form_id);
1469
+ const formRecord = (detail == null ? void 0 : detail.form_record) ?? null;
1470
+ const allowSnack = ((_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["sale.allow_add_items"]) || false;
1430
1471
  const deskmateValid = false;
1431
- const isExclusive = resourceSelectType === 'single';
1432
- const isFull = (0, _utils.computeResourceIsFull)({
1472
+ const isExclusive = resourceSelectType === "single";
1473
+ const isFull = (0, import_utils.computeResourceIsFull)({
1433
1474
  resourceSelectType,
1434
1475
  lastOrderId,
1435
- capacityList: detail?.resource_capacity?.[0]?.capacity_list ?? [],
1436
- capacity: formRecord?.capacity
1476
+ capacityList: ((_d = (_c = detail == null ? void 0 : detail.resource_capacity) == null ? void 0 : _c[0]) == null ? void 0 : _d.capacity_list) ?? [],
1477
+ capacity: formRecord == null ? void 0 : formRecord.capacity
1437
1478
  });
1438
1479
  let availabilityInfo = {
1439
- mode: 'idle',
1480
+ mode: "idle",
1440
1481
  deskmate_valid: deskmateValid
1441
1482
  };
1442
-
1443
- // 有currentOrderId代表是我点的单
1444
- // 如果 url 上没有 hasOrderId,则跳转到订单详情,通过返回 resource_busy 实现
1445
1483
  if (currentOrderId) {
1446
1484
  if (!hasOrderId) {
1447
1485
  availabilityInfo = {
1448
- mode: 'resource_busy',
1486
+ mode: "resource_busy",
1449
1487
  order_id: currentOrderId,
1450
1488
  relation_id: relationId,
1451
1489
  table_form_id: tableFormId,
1452
1490
  deskmate_valid: deskmateValid
1453
1491
  };
1454
1492
  } else {
1455
- // 如果有 hasOrderId,需要检测是否允许加餐,如果允许则返回additional_order,否则也是 resource_busy
1456
1493
  availabilityInfo = {
1457
- mode: allowSnack ? 'additional_order' : 'resource_busy',
1494
+ mode: allowSnack ? "additional_order" : "resource_busy",
1458
1495
  order_id: currentOrderId,
1459
1496
  relation_id: relationId,
1460
1497
  table_form_id: tableFormId,
@@ -1462,13 +1499,11 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1462
1499
  };
1463
1500
  }
1464
1501
  } else if (lastOrderId) {
1465
- // 如果有其他人点的单
1466
- // multiple 预约且容量仍有剩余时,其他人的单不影响当前用户下单,保持 idle 走正常下单流程
1467
- const canFallthroughToIdle = resourceSelectType === 'multiple' && !isFull;
1502
+ const canFallthroughToIdle = resourceSelectType === "multiple" && !isFull;
1468
1503
  if (!canFallthroughToIdle) {
1469
1504
  availabilityInfo = {
1470
- mode: 'resource_busy',
1471
- order_id: '0',
1505
+ mode: "resource_busy",
1506
+ order_id: "0",
1472
1507
  relation_id: relationId,
1473
1508
  table_form_id: tableFormId,
1474
1509
  deskmate_valid: deskmateValid
@@ -1490,62 +1525,67 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1490
1525
  table_form_record: formRecord
1491
1526
  };
1492
1527
  }
1493
-
1494
1528
  // 从首个预约规则商品的 product_resource.resources 中,按 form_id 匹配返回 type
1495
1529
  resolveResourceSelectType(formId) {
1530
+ var _a;
1496
1531
  const firstProduct = this.enabledReservationRuleProducts[0];
1497
- const resources = firstProduct?.product_resource?.resources || [];
1532
+ const resources = ((_a = firstProduct == null ? void 0 : firstProduct.product_resource) == null ? void 0 : _a.resources) || [];
1498
1533
  const numericFormId = Number(formId);
1499
- if (!Number.isFinite(numericFormId) || numericFormId <= 0) return undefined;
1500
- const matched = resources.find(r => Number(r?.id) === numericFormId);
1501
- return matched?.type;
1534
+ if (!Number.isFinite(numericFormId) || numericFormId <= 0)
1535
+ return void 0;
1536
+ const matched = resources.find((r) => Number(r == null ? void 0 : r.id) === numericFormId);
1537
+ return matched == null ? void 0 : matched.type;
1502
1538
  }
1503
1539
  async fetchResourceOccupyDetailsByResourceId(resourceId) {
1540
+ var _a, _b, _c;
1504
1541
  const formRecordId = Number(resourceId);
1505
1542
  if (!Number.isFinite(formRecordId) || formRecordId <= 0) {
1506
1543
  throw new Error(`[ScanOrder] 非法桌台 resourceId: ${resourceId}`);
1507
1544
  }
1508
- const shopId = this.otherParams?.getStateData?.('shop_id');
1545
+ const shopId = (_b = (_a = this.otherParams) == null ? void 0 : _a.getStateData) == null ? void 0 : _b.call(_a, "shop_id");
1509
1546
  if (!shopId) {
1510
- throw new Error('[ScanOrder] 无法获取 shop_id');
1511
- }
1512
- const response = await this.request.get('/order/resource/occupy-detail', {
1513
- shop_id: shopId,
1514
- 'form_record_ids[]': formRecordId,
1515
- with_resource_capacity_info: 1,
1516
- with_resource_order_info: 1,
1517
- with_resource_form_info: 1
1518
- });
1519
- if (!response?.status) {
1520
- throw new Error(response?.message || '获取资源占用详情失败');
1547
+ throw new Error("[ScanOrder] 无法获取 shop_id");
1548
+ }
1549
+ const response = await this.request.get(
1550
+ "/order/resource/occupy-detail",
1551
+ {
1552
+ shop_id: shopId,
1553
+ "form_record_ids[]": formRecordId,
1554
+ with_resource_capacity_info: 1,
1555
+ with_resource_order_info: 1,
1556
+ with_resource_form_info: 1
1557
+ }
1558
+ );
1559
+ if (!(response == null ? void 0 : response.status)) {
1560
+ throw new Error((response == null ? void 0 : response.message) || "获取资源占用详情失败");
1521
1561
  }
1522
- return response?.data?.occupy_details ?? [];
1562
+ return ((_c = response == null ? void 0 : response.data) == null ? void 0 : _c.occupy_details) ?? [];
1523
1563
  }
1524
1564
  resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
1525
- const currentOrderId = (0, _utils.toPositiveString)(detail?.order_id);
1565
+ const currentOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.order_id);
1526
1566
  if (currentOrderId) {
1527
1567
  return {
1528
1568
  matched: true,
1529
1569
  order_id: currentOrderId
1530
1570
  };
1531
1571
  }
1532
- const orderListIds = (Array.isArray(detail?.order_list) ? detail?.order_list || [] : []).map(order => (0, _utils.toPositiveString)(order?.id)).filter(Boolean);
1533
- if (resourceSelectType !== 'single') {
1572
+ const orderListIds = (Array.isArray(detail == null ? void 0 : detail.order_list) ? (detail == null ? void 0 : detail.order_list) || [] : []).map((order) => (0, import_utils.toPositiveString)(order == null ? void 0 : order.id)).filter(Boolean);
1573
+ if (resourceSelectType !== "single") {
1534
1574
  return {
1535
1575
  matched: false,
1536
- reason: 'no_order'
1576
+ reason: "no_order"
1537
1577
  };
1538
1578
  }
1539
1579
  if (!orderListIds.length) {
1540
1580
  return {
1541
1581
  matched: false,
1542
- reason: 'no_order'
1582
+ reason: "no_order"
1543
1583
  };
1544
1584
  }
1545
1585
  if (!allowAddItems) {
1546
1586
  return {
1547
1587
  matched: false,
1548
- reason: 'add_items_disabled'
1588
+ reason: "add_items_disabled"
1549
1589
  };
1550
1590
  }
1551
1591
  if (orderListIds.length === 1) {
@@ -1557,103 +1597,94 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1557
1597
  if (orderListIds.length > 1) {
1558
1598
  return {
1559
1599
  matched: false,
1560
- reason: 'multiple_orders'
1600
+ reason: "multiple_orders"
1561
1601
  };
1562
1602
  }
1563
1603
  return {
1564
1604
  matched: false,
1565
- reason: 'no_order'
1605
+ reason: "no_order"
1566
1606
  };
1567
1607
  }
1568
-
1569
1608
  // 检测当前链接是否可用
1570
1609
  // 通过 resource_id + 店铺配置
1571
1610
  // hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
1572
1611
  async checkResourceAvailable(resourceId, hasOrderId = false) {
1573
- const normalizedResourceId = String(resourceId ?? '').trim();
1574
- this.logMethodStart('checkResourceAvailable', {
1612
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1613
+ const normalizedResourceId = String(resourceId ?? "").trim();
1614
+ this.logMethodStart("checkResourceAvailable", {
1575
1615
  resourceId: normalizedResourceId
1576
1616
  });
1577
1617
  try {
1578
- const businessCode = String(this.otherParams?.businessCode ?? '').trim();
1579
- const channel = String(this.otherParams?.channel ?? '').trim();
1580
- const openDataTarget = businessCode && channel ? `${businessCode}+${channel}` : 'dine_in+scan_to_order';
1581
- const openData = await this.otherParams?.getOpenData?.({
1582
- scope: 'board',
1618
+ const businessCode = String(((_a = this.otherParams) == null ? void 0 : _a.businessCode) ?? "").trim();
1619
+ const channel = String(((_b = this.otherParams) == null ? void 0 : _b.channel) ?? "").trim();
1620
+ const openDataTarget = businessCode && channel ? `${businessCode}+${channel}` : "dine_in+scan_to_order";
1621
+ const openData = await ((_d = (_c = this.otherParams) == null ? void 0 : _c.getOpenData) == null ? void 0 : _d.call(_c, {
1622
+ scope: "board",
1583
1623
  target: openDataTarget,
1584
- section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
1585
- });
1586
- if (openData?.status === false) {
1587
- throw new Error(openData?.message || '获取店铺配置失败');
1624
+ section_code: ["basic", "fulfillment", "reservation", "sale", "menu", "availability", "workflow"]
1625
+ }));
1626
+ if ((openData == null ? void 0 : openData.status) === false) {
1627
+ throw new Error((openData == null ? void 0 : openData.message) || "获取店铺配置失败");
1588
1628
  }
1589
- const dineInConfig = openData?.data || {};
1629
+ const dineInConfig = (openData == null ? void 0 : openData.data) || {};
1590
1630
  this.otherParams.dineInConfig = dineInConfig;
1591
1631
  await this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
1592
- const closedBehaviorValue = dineInConfig?.['availability.closed_behavior'];
1593
- const closedMessage = dineInConfig?.['availability.closed_message'] || dineInConfig?.['availability.message'] || dineInConfig?.['basic.closed_message'];
1594
- const basicUnavailableMessage = dineInConfig?.['basic.unavailable_message'] || closedMessage;
1595
- const pauseMessage = dineInConfig?.['availability.pause_message'] || closedMessage;
1632
+ const closedBehaviorValue = dineInConfig == null ? void 0 : dineInConfig["availability.closed_behavior"];
1633
+ const closedMessage = (dineInConfig == null ? void 0 : dineInConfig["availability.closed_message"]) || (dineInConfig == null ? void 0 : dineInConfig["availability.message"]) || (dineInConfig == null ? void 0 : dineInConfig["basic.closed_message"]);
1634
+ const basicUnavailableMessage = (dineInConfig == null ? void 0 : dineInConfig["basic.unavailable_message"]) || closedMessage;
1635
+ const pauseMessage = (dineInConfig == null ? void 0 : dineInConfig["availability.pause_message"]) || closedMessage;
1596
1636
  const makeShopClosed = (errorTips, closed_behavior) => ({
1597
- mode: 'shop_closed',
1598
- order_id: undefined,
1599
- relation_id: undefined,
1600
- table_form_id: undefined,
1637
+ mode: "shop_closed",
1638
+ order_id: void 0,
1639
+ relation_id: void 0,
1640
+ table_form_id: void 0,
1601
1641
  deskmate_valid: false,
1602
1642
  errorTips,
1603
1643
  closed_behavior
1604
1644
  });
1605
-
1606
- // 1. 基础开关 basic.enable 关闭
1607
- if (dineInConfig?.['basic.enable'] === false) {
1645
+ if ((dineInConfig == null ? void 0 : dineInConfig["basic.enable"]) === false) {
1608
1646
  return makeShopClosed(basicUnavailableMessage);
1609
1647
  }
1610
-
1611
- // 2. 暂停营业(保留原有逻辑:仅 hide_all 才阻止进入)
1612
- if ((0, _utils.toBoolean)(dineInConfig?.['availability.paused'])) {
1613
- if (dineInConfig?.['availability.pause_behavior'] === 'hide_all') {
1648
+ if ((0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["availability.paused"])) {
1649
+ if ((dineInConfig == null ? void 0 : dineInConfig["availability.pause_behavior"]) === "hide_all") {
1614
1650
  return makeShopClosed(pauseMessage);
1615
1651
  }
1616
1652
  }
1617
-
1618
- // 3. 营业时间 operating_hours 闸门
1619
- const operatingHourIds = Array.isArray(dineInConfig?.['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(id => Number(id)).filter(id => Number.isFinite(id) && id > 0) : [];
1653
+ const operatingHourIds = Array.isArray(dineInConfig == null ? void 0 : dineInConfig["availability.operating_hours"]) ? dineInConfig["availability.operating_hours"].map((id) => Number(id)).filter((id) => Number.isFinite(id) && id > 0) : [];
1620
1654
  let outsideOperatingHours = false;
1621
1655
  if (operatingHourIds.length && this.store.schedule) {
1622
1656
  const scheduleList = this.store.schedule.getScheduleListByIds(operatingHourIds);
1623
1657
  if (scheduleList.length) {
1624
- const now = (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss');
1625
- outsideOperatingHours = !(0, _getDateIsInSchedule.getDateIsInSchedule)(now, scheduleList);
1658
+ const now = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
1659
+ outsideOperatingHours = !(0, import_getDateIsInSchedule.getDateIsInSchedule)(now, scheduleList);
1626
1660
  }
1627
1661
  }
1628
- if (outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled') {
1662
+ if (outsideOperatingHours && closedBehaviorValue !== "show_menu_disabled") {
1629
1663
  return makeShopClosed(closedMessage, closedBehaviorValue);
1630
1664
  }
1631
-
1632
- // Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
1633
- // (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
1634
1665
  const tempOrder = this.ensureScanOrderTempOrder();
1635
- const reservationLinkIds = (0, _utils.collectLinkProductIdsFromReservationRules)(dineInConfig['fulfillment.enabled_resource_rules']);
1666
+ const reservationLinkIds = (0, import_utils.collectLinkProductIdsFromReservationRules)(
1667
+ dineInConfig["fulfillment.enabled_resource_rules"]
1668
+ );
1636
1669
  if (!normalizedResourceId || reservationLinkIds.length === 0) {
1637
1670
  return await this.prepareRetailAvailability({
1638
1671
  tempOrder,
1639
1672
  hasOrderId,
1640
1673
  resourceId: normalizedResourceId,
1641
- reason: !normalizedResourceId ? 'missing_resource_id' : 'missing_enabled_resource_rules'
1674
+ reason: !normalizedResourceId ? "missing_resource_id" : "missing_enabled_resource_rules"
1642
1675
  });
1643
1676
  }
1644
1677
  let pendingRequestEntryPax;
1645
1678
  let pendingRequestPaxMin;
1646
1679
  let pendingRequestPaxMax;
1647
- tempOrder.metadata = {
1648
- ...(tempOrder.metadata || {})
1649
- };
1680
+ tempOrder.metadata = { ...tempOrder.metadata || {} };
1650
1681
  delete tempOrder.metadata.table_occupancy_duration;
1651
- const reservationProductList = new _ProductList.ProductList(`${this.name}_reservationEnabledRules`, this.defaultVersion);
1682
+ const reservationProductList = new import_ProductList.ProductList(
1683
+ `${this.name}_reservationEnabledRules`,
1684
+ this.defaultVersion
1685
+ );
1652
1686
  await reservationProductList.initialize(this.core, {
1653
- store: {
1654
- list: [],
1655
- selectProducts: []
1656
- },
1687
+ store: { list: [], selectProducts: [] },
1657
1688
  otherParams: {
1658
1689
  ...this.otherParams,
1659
1690
  fatherModule: this.name,
@@ -1661,8 +1692,8 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1661
1692
  cacheId: this.cacheId
1662
1693
  }
1663
1694
  });
1664
- const scheduleDate = (0, _dayjs.default)().format('YYYY-MM-DD');
1665
- const scheduleDatetime = (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss');
1695
+ const scheduleDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
1696
+ const scheduleDatetime = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
1666
1697
  const loaded = await reservationProductList.loadProducts({
1667
1698
  product_ids: reservationLinkIds,
1668
1699
  schedule_date: scheduleDate,
@@ -1670,23 +1701,28 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1670
1701
  cacheId: this.cacheId
1671
1702
  });
1672
1703
  if (Array.isArray(loaded)) {
1673
- const matchedRuleProduct = (0, _utils.findReservationRuleProductByResourceId)(loaded, normalizedResourceId);
1704
+ const matchedRuleProduct = (0, import_utils.findReservationRuleProductByResourceId)(
1705
+ loaded,
1706
+ normalizedResourceId
1707
+ );
1674
1708
  const ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
1675
1709
  this.enabledReservationRuleProducts = ruleProductsForResource;
1676
- const occupancyMinutes = (0, _utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
1677
- if (occupancyMinutes !== undefined) {
1710
+ const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
1711
+ if (occupancyMinutes !== void 0) {
1678
1712
  tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1679
1713
  }
1680
- if ((0, _utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
1714
+ if ((0, import_utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
1681
1715
  pendingRequestEntryPax = 1;
1682
- const paxBounds = (0, _utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
1683
- if (paxBounds?.min !== undefined) pendingRequestPaxMin = paxBounds.min;
1684
- if (paxBounds?.max !== undefined) pendingRequestPaxMax = paxBounds.max;
1716
+ const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
1717
+ if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1718
+ pendingRequestPaxMin = paxBounds.min;
1719
+ if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
1720
+ pendingRequestPaxMax = paxBounds.max;
1685
1721
  }
1686
1722
  } else {
1687
1723
  this.enabledReservationRuleProducts = [];
1688
- const error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
1689
- this.logMethodError('loadReservationRuleProducts', error, {
1724
+ const error = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
1725
+ this.logMethodError("loadReservationRuleProducts", error, {
1690
1726
  resourceId: normalizedResourceId,
1691
1727
  reservationLinkIds,
1692
1728
  scheduleDate,
@@ -1695,20 +1731,22 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1695
1731
  });
1696
1732
  if (Array.isArray(loaded)) {
1697
1733
  this.enabledReservationRuleProducts = loaded;
1698
- const occupancyMinutes = (0, _utils.pickFirstDurationMinutesFromProducts)(loaded);
1699
- if (occupancyMinutes !== undefined) {
1734
+ const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(loaded);
1735
+ if (occupancyMinutes !== void 0) {
1700
1736
  tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1701
1737
  }
1702
- if ((0, _utils.hasCustomCapacityProduct)(loaded)) {
1738
+ if ((0, import_utils.hasCustomCapacityProduct)(loaded)) {
1703
1739
  pendingRequestEntryPax = 1;
1704
- const paxBounds = (0, _utils.pickFirstCustomCapacityPaxBounds)(loaded);
1705
- if (paxBounds?.min !== undefined) pendingRequestPaxMin = paxBounds.min;
1706
- if (paxBounds?.max !== undefined) pendingRequestPaxMax = paxBounds.max;
1740
+ const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(loaded);
1741
+ if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1742
+ pendingRequestPaxMin = paxBounds.min;
1743
+ if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
1744
+ pendingRequestPaxMax = paxBounds.max;
1707
1745
  }
1708
1746
  } else {
1709
1747
  this.enabledReservationRuleProducts = [];
1710
- const error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
1711
- this.logMethodError('loadReservationRuleProducts', error, {
1748
+ const error2 = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
1749
+ this.logMethodError("loadReservationRuleProducts", error2, {
1712
1750
  resourceId,
1713
1751
  reservationLinkIds,
1714
1752
  scheduleDate,
@@ -1717,61 +1755,62 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1717
1755
  });
1718
1756
  }
1719
1757
  }
1720
-
1721
- // Step2: 请求新的资源占用详情接口。occupy_details 第一维是资源,不是订单。
1722
1758
  const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
1723
1759
  const occupyDetail = occupyDetails[0] ?? null;
1724
-
1725
- // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
1726
- // 计算当前桌台的 resourceSelectType(single/multiple/capacity)
1727
- const resourceSelectType = this.resolveResourceSelectType((0, _utils.toPositiveString)(occupyDetail?.form_id));
1728
- const allowAddItems = (0, _utils.toBoolean)(dineInConfig?.['sale.allow_add_items']);
1729
- const additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
1730
- if (additionalOrderResult.reason === 'multiple_orders') {
1760
+ const resourceSelectType = this.resolveResourceSelectType(
1761
+ (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id)
1762
+ );
1763
+ const allowAddItems = (0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["sale.allow_add_items"]);
1764
+ const additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(
1765
+ occupyDetail,
1766
+ resourceSelectType,
1767
+ allowAddItems
1768
+ );
1769
+ if (additionalOrderResult.reason === "multiple_orders") {
1731
1770
  const multipleOrdersState = {
1732
1771
  ...this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId),
1733
- mode: 'multiple_orders'
1772
+ mode: "multiple_orders"
1734
1773
  };
1735
1774
  this.store.resource = multipleOrdersState;
1736
- const availabilityInfo = {
1737
- mode: 'multiple_orders',
1775
+ const availabilityInfo2 = {
1776
+ mode: "multiple_orders",
1738
1777
  deskmate_valid: multipleOrdersState.deskmate_valid,
1739
1778
  relation_id: multipleOrdersState.relationId,
1740
1779
  table_form_id: multipleOrdersState.tableFormId,
1741
1780
  table_form_record: multipleOrdersState.table_form_record
1742
1781
  };
1743
- this.logMethodSuccess('checkResourceAvailable', {
1782
+ this.logMethodSuccess("checkResourceAvailable", {
1744
1783
  resourceId: normalizedResourceId,
1745
- mode: availabilityInfo.mode,
1746
- orderListCount: occupyDetail?.order_list?.length || 0,
1784
+ mode: availabilityInfo2.mode,
1785
+ orderListCount: ((_e = occupyDetail == null ? void 0 : occupyDetail.order_list) == null ? void 0 : _e.length) || 0,
1747
1786
  resourceSelectType
1748
1787
  });
1749
- return availabilityInfo;
1788
+ return availabilityInfo2;
1750
1789
  }
1751
-
1752
- // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
1753
- const resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
1790
+ const resourceState = this.normalizeResourceState(
1791
+ occupyDetail,
1792
+ resourceSelectType,
1793
+ hasOrderId
1794
+ );
1754
1795
  const additionalOrderId = additionalOrderResult.order_id;
1755
1796
  if (additionalOrderId) {
1756
- resourceState.mode = 'additional_order';
1797
+ resourceState.mode = "additional_order";
1757
1798
  resourceState.order_id = additionalOrderId;
1758
- } else if (additionalOrderResult.reason === 'add_items_disabled') {
1759
- resourceState.mode = 'resource_busy';
1760
- resourceState.order_id = '0';
1761
- } else if (resourceSelectType === 'multiple' && resourceState.isFull) {
1762
- resourceState.mode = 'resource_busy';
1763
- resourceState.order_id = '0';
1799
+ } else if (additionalOrderResult.reason === "add_items_disabled") {
1800
+ resourceState.mode = "resource_busy";
1801
+ resourceState.order_id = "0";
1802
+ } else if (resourceSelectType === "multiple" && resourceState.isFull) {
1803
+ resourceState.mode = "resource_busy";
1804
+ resourceState.order_id = "0";
1764
1805
  }
1765
1806
  this.store.resource = resourceState;
1766
-
1767
- // Step5: 把预约规则商品阶段暂存的 requestEntryPax 等注入 store.resource
1768
- if (pendingRequestEntryPax !== undefined) {
1807
+ if (pendingRequestEntryPax !== void 0) {
1769
1808
  this.store.resource.requestEntryPax = pendingRequestEntryPax;
1770
1809
  }
1771
- if (pendingRequestPaxMin !== undefined) {
1810
+ if (pendingRequestPaxMin !== void 0) {
1772
1811
  this.store.resource.requestPaxMin = pendingRequestPaxMin;
1773
1812
  }
1774
- if (pendingRequestPaxMax !== undefined) {
1813
+ if (pendingRequestPaxMax !== void 0) {
1775
1814
  this.store.resource.requestPaxMax = pendingRequestPaxMax;
1776
1815
  }
1777
1816
  const availabilityInfo = {
@@ -1781,64 +1820,49 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1781
1820
  table_form_id: resourceState.tableFormId,
1782
1821
  deskmate_valid: resourceState.deskmate_valid,
1783
1822
  table_form_record: resourceState.table_form_record,
1784
- policy: occupyDetail?.form_record?.policy,
1785
- partyroom_booking: occupyDetail?.form_record?.partyroom_booking,
1786
- ...(this.store.resource.requestEntryPax !== undefined ? {
1787
- requestEntryPax: this.store.resource.requestEntryPax
1788
- } : {}),
1789
- ...(this.store.resource.requestPaxMin !== undefined ? {
1790
- requestPaxMin: this.store.resource.requestPaxMin
1791
- } : {}),
1792
- ...(this.store.resource.requestPaxMax !== undefined ? {
1793
- requestPaxMax: this.store.resource.requestPaxMax
1794
- } : {})
1823
+ policy: (_f = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _f.policy,
1824
+ partyroom_booking: (_g = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _g.partyroom_booking,
1825
+ ...this.store.resource.requestEntryPax !== void 0 ? { requestEntryPax: this.store.resource.requestEntryPax } : {},
1826
+ ...this.store.resource.requestPaxMin !== void 0 ? { requestPaxMin: this.store.resource.requestPaxMin } : {},
1827
+ ...this.store.resource.requestPaxMax !== void 0 ? { requestPaxMax: this.store.resource.requestPaxMax } : {}
1795
1828
  };
1796
- this.store.order?.persistTempOrder();
1797
-
1798
- // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
1799
- if (availabilityInfo.mode === 'idle') {
1829
+ (_h = this.store.order) == null ? void 0 : _h.persistTempOrder();
1830
+ if (availabilityInfo.mode === "idle") {
1800
1831
  await this.addNewOrder();
1801
1832
  }
1802
- const isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code';
1803
- // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
1833
+ const isAdditionalOrderMode = availabilityInfo.mode === "additional_order" || availabilityInfo.mode === "additional_order_with_code";
1804
1834
  if (isAdditionalOrderMode) {
1805
1835
  tempOrder.order_id = additionalOrderId;
1806
1836
  }
1807
- const lastOrderInfo = this.store.order?.getLastOrderInfo?.();
1808
- const historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo?.products) ? lastOrderInfo.products.reduce((acc, p) => {
1809
- if (typeof p?.product_id !== 'number') return acc;
1837
+ const lastOrderInfo = (_j = (_i = this.store.order) == null ? void 0 : _i.getLastOrderInfo) == null ? void 0 : _j.call(_i);
1838
+ const historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo == null ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce((acc, p) => {
1839
+ if (typeof (p == null ? void 0 : p.product_id) !== "number")
1840
+ return acc;
1810
1841
  acc.push({
1811
1842
  product_id: p.product_id,
1812
1843
  quantity: Number(p.product_quantity) || 0,
1813
- ...(typeof p.product_variant_id === 'number' ? {
1814
- product_variant_id: p.product_variant_id
1815
- } : {})
1844
+ ...typeof p.product_variant_id === "number" ? { product_variant_id: p.product_variant_id } : {}
1816
1845
  });
1817
1846
  return acc;
1818
1847
  }, []) : [];
1819
-
1820
- // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
1821
1848
  await this.setItemRuleRuntimeConfig({
1822
- serviceType: this.otherParams?.businessCode,
1849
+ serviceType: (_k = this.otherParams) == null ? void 0 : _k.businessCode,
1823
1850
  submissionIndex: isAdditionalOrderMode ? 1 : 0,
1824
1851
  historicalItems
1825
1852
  });
1826
-
1827
- // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
1828
- // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
1829
- if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
1830
- availabilityInfo.mode = 'submit_disabled';
1853
+ if (outsideOperatingHours && closedBehaviorValue === "show_menu_disabled") {
1854
+ availabilityInfo.mode = "submit_disabled";
1831
1855
  availabilityInfo.errorTips = closedMessage;
1832
1856
  availabilityInfo.closed_behavior = closedBehaviorValue;
1833
1857
  }
1834
- this.logMethodSuccess('checkResourceAvailable', {
1858
+ this.logMethodSuccess("checkResourceAvailable", {
1835
1859
  resourceId: normalizedResourceId,
1836
1860
  mode: availabilityInfo.mode,
1837
1861
  orderId: availabilityInfo.order_id,
1838
1862
  relationId: availabilityInfo.relation_id,
1839
1863
  tableFormId: availabilityInfo.table_form_id,
1840
- persistedRelationId: this.store.resource?.relationId,
1841
- persistedResourceId: this.store.resource?.relationId,
1864
+ persistedRelationId: (_l = this.store.resource) == null ? void 0 : _l.relationId,
1865
+ persistedResourceId: (_m = this.store.resource) == null ? void 0 : _m.relationId,
1842
1866
  deskmateValid: availabilityInfo.deskmate_valid,
1843
1867
  resourceSelectType: resourceState.resourceSelectType,
1844
1868
  isExclusive: resourceState.isExclusive,
@@ -1846,71 +1870,76 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1846
1870
  });
1847
1871
  return availabilityInfo;
1848
1872
  } catch (error) {
1849
- this.logMethodError('checkResourceAvailable', error.message, {
1873
+ this.logMethodError("checkResourceAvailable", error.message, {
1850
1874
  resourceId: normalizedResourceId
1851
1875
  });
1852
1876
  throw error;
1853
1877
  }
1854
1878
  }
1855
-
1856
1879
  // 恢复之前订单的数据,读取 entrypax
1857
1880
  async restorePreviousOrderData() {
1881
+ var _a, _b, _c, _d;
1858
1882
  const orderModule = this.store.order;
1859
- if (!orderModule) return;
1883
+ if (!orderModule)
1884
+ return;
1860
1885
  const tempOrder = orderModule.ensureTempOrder();
1861
1886
  if (tempOrder.order_id) {
1862
1887
  const res = await orderModule.getOrderInfo(tempOrder.order_id);
1863
- // 找到下单的时候输入的 entryPaxNumber
1864
- const entryPaxNumber = res?.data?.bookings?.find(p => p.metadata?.collect_pax)?.metadata?.collect_pax;
1888
+ const entryPaxNumber = (_d = (_c = (_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.bookings) == null ? void 0 : _b.find((p) => {
1889
+ var _a2;
1890
+ return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
1891
+ })) == null ? void 0 : _c.metadata) == null ? void 0 : _d.collect_pax;
1865
1892
  if (entryPaxNumber) {
1866
1893
  await this.setEntryPaxNumber(entryPaxNumber);
1867
1894
  }
1868
1895
  }
1869
1896
  }
1870
-
1871
1897
  // 如果是加单的情况,提供返回当前订单相关信息的能力
1872
1898
  async getAdditionalOrderInfo() {
1873
- this.logMethodStart('getAdditionalOrderInfo');
1899
+ this.logMethodStart("getAdditionalOrderInfo");
1874
1900
  const result = {
1875
- orderId: '123567890',
1876
- orderStatus: 'pending',
1877
- orderTime: '2026-03-31 10:00:00',
1901
+ orderId: "123567890",
1902
+ orderStatus: "pending",
1903
+ orderTime: "2026-03-31 10:00:00",
1878
1904
  orderAmount: 100,
1879
1905
  orderItems: []
1880
1906
  };
1881
- this.logMethodSuccess('getAdditionalOrderInfo', {
1907
+ this.logMethodSuccess("getAdditionalOrderInfo", {
1882
1908
  orderId: result.orderId,
1883
1909
  orderStatus: result.orderStatus
1884
1910
  });
1885
1911
  return result;
1886
1912
  }
1887
-
1888
1913
  // 获取商品列表
1889
1914
  async getProductList() {
1890
- this.logMethodStart('getProductList');
1891
- // 可以直接通过配置里的 menu 读取
1892
- const associatedMenus = this.otherParams?.dineInConfig?.['menu.associated_menus'];
1893
- const menu_list_ids = associatedMenus.map(n => Number(n.value)) || [];
1915
+ var _a, _b;
1916
+ this.logMethodStart("getProductList");
1917
+ const associatedMenus = (_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["menu.associated_menus"];
1918
+ const menu_list_ids = associatedMenus.map((n) => Number(n.value)) || [];
1894
1919
  try {
1895
- if (!this.store.products) throw new Error('products 模块未初始化');
1920
+ if (!this.store.products)
1921
+ throw new Error("products 模块未初始化");
1896
1922
  const res = await this.store.products.loadProducts({
1897
1923
  menu_list_ids,
1898
1924
  cacheId: this.cacheId,
1899
- schedule_date: (0, _dayjs.default)().format('YYYY-MM-DD'),
1900
- schedule_datetime: (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss')
1925
+ schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
1926
+ schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
1901
1927
  });
1902
- const productList = this.assertProductListLoaded('getProductList', res, {
1928
+ const productList = this.assertProductListLoaded("getProductList", res, {
1903
1929
  menu_list_ids,
1904
1930
  cacheId: this.cacheId
1905
1931
  });
1906
- const formattedRes = (0, _utils.attachItemRuleLimitsToTopLevelProducts)(productList, this.store.itemRuleQuantityLimits || []);
1907
- this.logMethodSuccess('getProductList', {
1932
+ const formattedRes = (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
1933
+ productList,
1934
+ this.store.itemRuleQuantityLimits || []
1935
+ );
1936
+ this.logMethodSuccess("getProductList", {
1908
1937
  menuCount: menu_list_ids.length
1909
1938
  });
1910
1939
  return formattedRes;
1911
1940
  } catch (error) {
1912
- if (!error?.__scanOrderLogged) {
1913
- this.logMethodError('getProductList', error, {
1941
+ if (!(error == null ? void 0 : error.__scanOrderLogged)) {
1942
+ this.logMethodError("getProductList", error, {
1914
1943
  menu_list_ids,
1915
1944
  cacheId: this.cacheId
1916
1945
  });
@@ -1921,107 +1950,87 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1921
1950
  getOtherParams() {
1922
1951
  return this.otherParams;
1923
1952
  }
1924
- async setOtherParams(params, {
1925
- cover = false
1926
- } = {}) {
1953
+ async setOtherParams(params, { cover = false } = {}) {
1927
1954
  if (cover) {
1928
1955
  this.otherParams = params;
1929
1956
  } else {
1930
- this.otherParams = {
1931
- ...this.otherParams,
1932
- ...params
1933
- };
1957
+ this.otherParams = { ...this.otherParams, ...params };
1934
1958
  }
1935
1959
  }
1936
-
1937
- // ─── UI 状态缓存(按 cacheId 分桶,localStorage) ───
1938
- //
1939
- // 用于物料层持久化 UI 层面的轻量状态(如当前步骤、gate 标记、登录回跳意图等)。
1940
- // 桶键:pisell.scanOrder.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
1941
- // 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
1942
- //
1943
- // 之所以用 localStorage 而不是 sessionStorage:
1944
- // 1. 与 Order 模块 openCache 下的 tempOrder 同栈,购物车在 / UIState 在,行为对齐;
1945
- // 2. pisell1.login 整页 OAuth 跳转在 H5 壳 / iOS Safari 场景下可能丢 sessionStorage,
1946
- // 导致登录回跳后 gate 标记失效、pax 弹窗重开、落点错误;localStorage 稳定不受影响。
1947
- // 3. 失效由上层显式控制:提交成功 clearStepCache / entryContext 不一致 clearUIState /
1948
- // pendingStep 登录回调 deleteUIState,足够约束生命周期。
1949
-
1950
- static UI_STATE_KEY_PREFIX = 'pisell.scanOrder.uiState:';
1951
1960
  getUIStateBucketKey() {
1952
- if (!this.cacheId) return null;
1953
- return `${ScanOrderImpl.UI_STATE_KEY_PREFIX}${this.cacheId}`;
1961
+ if (!this.cacheId)
1962
+ return null;
1963
+ return `${_ScanOrderImpl.UI_STATE_KEY_PREFIX}${this.cacheId}`;
1954
1964
  }
1955
1965
  readUIStateBucket() {
1966
+ var _a;
1956
1967
  const key = this.getUIStateBucketKey();
1957
- if (!key || !this.window?.localStorage) return {};
1968
+ if (!key || !((_a = this.window) == null ? void 0 : _a.localStorage))
1969
+ return {};
1958
1970
  try {
1959
- const raw = this.window.localStorage.getItem(key) || '{}';
1971
+ const raw = this.window.localStorage.getItem(key) || "{}";
1960
1972
  const parsed = JSON.parse(raw);
1961
- return parsed && typeof parsed === 'object' ? parsed : {};
1973
+ return parsed && typeof parsed === "object" ? parsed : {};
1962
1974
  } catch {
1963
1975
  return {};
1964
1976
  }
1965
1977
  }
1966
1978
  writeUIStateBucket(bucket) {
1979
+ var _a;
1967
1980
  const key = this.getUIStateBucketKey();
1968
- if (!key || !this.window?.localStorage) return;
1981
+ if (!key || !((_a = this.window) == null ? void 0 : _a.localStorage))
1982
+ return;
1969
1983
  try {
1970
1984
  this.window.localStorage.setItem(key, JSON.stringify(bucket));
1971
1985
  } catch (error) {
1972
- console.warn('[ScanOrder] writeUIStateBucket failed', error);
1986
+ console.warn("[ScanOrder] writeUIStateBucket failed", error);
1973
1987
  }
1974
1988
  }
1975
1989
  setUIState(key, value) {
1976
- if (!this.getUIStateBucketKey()) return;
1990
+ if (!this.getUIStateBucketKey())
1991
+ return;
1977
1992
  const bucket = this.readUIStateBucket();
1978
1993
  bucket[key] = value;
1979
1994
  this.writeUIStateBucket(bucket);
1980
1995
  }
1981
1996
  getUIState(key) {
1982
- if (!this.getUIStateBucketKey()) return undefined;
1997
+ if (!this.getUIStateBucketKey())
1998
+ return void 0;
1983
1999
  const bucket = this.readUIStateBucket();
1984
2000
  return bucket[key];
1985
2001
  }
1986
2002
  deleteUIState(key) {
1987
- if (!this.getUIStateBucketKey()) return;
2003
+ if (!this.getUIStateBucketKey())
2004
+ return;
1988
2005
  const bucket = this.readUIStateBucket();
1989
2006
  if (key in bucket) {
1990
2007
  delete bucket[key];
1991
2008
  this.writeUIStateBucket(bucket);
1992
2009
  }
1993
2010
  }
1994
-
1995
2011
  // 整桶清空(用于扫新桌、提交成功、restoreOrder 等场景)
1996
2012
  clearUIState() {
2013
+ var _a;
1997
2014
  const key = this.getUIStateBucketKey();
1998
- if (!key || !this.window?.localStorage) return;
2015
+ if (!key || !((_a = this.window) == null ? void 0 : _a.localStorage))
2016
+ return;
1999
2017
  try {
2000
2018
  this.window.localStorage.removeItem(key);
2001
2019
  } catch (error) {
2002
- console.warn('[ScanOrder] clearUIState failed', error);
2020
+ console.warn("[ScanOrder] clearUIState failed", error);
2003
2021
  }
2004
2022
  }
2005
2023
  async setEntryPaxNumber(number) {
2006
- const pax = (0, _utils2.normalizeSubmitCollectPaxValue)(number);
2024
+ const pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(number);
2007
2025
  this.store.entryPaxNumber = pax;
2008
2026
  if (this.store.order) {
2009
2027
  const t = this.store.order.ensureTempOrder();
2010
- t.metadata = {
2011
- ...t.metadata,
2012
- collect_pax: pax
2013
- };
2028
+ t.metadata = { ...t.metadata, collect_pax: pax };
2014
2029
  this.store.order.persistTempOrder();
2015
2030
  }
2016
-
2017
- // pax 变化后同步到 itemRuleRuntimeConfig,并刷新限购 / 校验
2018
2031
  this.itemRuleRuntimeConfig = {
2019
2032
  ...this.itemRuleRuntimeConfig,
2020
- pax: {
2021
- total: pax,
2022
- adult: 0,
2023
- child: 0
2024
- }
2033
+ pax: { total: pax, adult: 0, child: 0 }
2025
2034
  };
2026
2035
  this.itemRulePrefillApplied = false;
2027
2036
  await this.refreshItemRuleQuantityLimits();
@@ -2031,27 +2040,37 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
2031
2040
  return this.store.entryPaxNumber;
2032
2041
  }
2033
2042
  async syncAdditionalOrderFromResource(resourceId) {
2034
- if (!this.store.order) throw new Error('order 模块未初始化');
2043
+ var _a, _b, _c, _d, _e, _f;
2044
+ if (!this.store.order)
2045
+ throw new Error("order 模块未初始化");
2035
2046
  const tempOrder = this.store.order.ensureTempOrder();
2036
- const normalizedResourceId = String(resourceId ?? tempOrder.resource_id ?? this.store.resource?.relationId ?? this.store.resource?.relation_id ?? '').trim();
2037
- this.logMethodStart('syncAdditionalOrderFromResource', {
2047
+ const normalizedResourceId = String(
2048
+ resourceId ?? tempOrder.resource_id ?? ((_a = this.store.resource) == null ? void 0 : _a.relationId) ?? ((_b = this.store.resource) == null ? void 0 : _b.relation_id) ?? ""
2049
+ ).trim();
2050
+ this.logMethodStart("syncAdditionalOrderFromResource", {
2038
2051
  resourceId: normalizedResourceId
2039
2052
  });
2040
2053
  if (!normalizedResourceId) {
2041
- const result = {
2054
+ const result2 = {
2042
2055
  matched: false,
2043
- reason: 'missing_resource_id'
2056
+ reason: "missing_resource_id"
2044
2057
  };
2045
- this.logMethodSuccess('syncAdditionalOrderFromResource', result);
2046
- return result;
2058
+ this.logMethodSuccess("syncAdditionalOrderFromResource", result2);
2059
+ return result2;
2047
2060
  }
2048
2061
  const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
2049
2062
  const occupyDetail = occupyDetails[0] ?? null;
2050
- const resourceSelectType = this.store.resource?.resourceSelectType || this.resolveResourceSelectType((0, _utils.toPositiveString)(occupyDetail?.form_id));
2051
- const allowAddItems = (0, _utils.toBoolean)(this.otherParams?.dineInConfig?.['sale.allow_add_items']);
2052
- const result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
2063
+ const resourceSelectType = ((_c = this.store.resource) == null ? void 0 : _c.resourceSelectType) || this.resolveResourceSelectType((0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id));
2064
+ const allowAddItems = (0, import_utils.toBoolean)(
2065
+ (_e = (_d = this.otherParams) == null ? void 0 : _d.dineInConfig) == null ? void 0 : _e["sale.allow_add_items"]
2066
+ );
2067
+ const result = this.resolveAdditionalOrderFromOccupyDetail(
2068
+ occupyDetail,
2069
+ resourceSelectType,
2070
+ allowAddItems
2071
+ );
2053
2072
  if (!result.matched || !result.order_id) {
2054
- this.logMethodSuccess('syncAdditionalOrderFromResource', {
2073
+ this.logMethodSuccess("syncAdditionalOrderFromResource", {
2055
2074
  ...result,
2056
2075
  resourceId: normalizedResourceId,
2057
2076
  resourceSelectType,
@@ -2061,10 +2080,10 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
2061
2080
  }
2062
2081
  tempOrder.order_id = result.order_id;
2063
2082
  tempOrder.resource_id = normalizedResourceId;
2064
- tempOrder.relation_id = (0, _utils.toPositiveString)(occupyDetail?.form_record_id) || normalizedResourceId || tempOrder.relation_id;
2065
- tempOrder.table_form_id = (0, _utils.toPositiveString)(occupyDetail?.form_id) || tempOrder.table_form_id;
2066
- this.store.order?.persistTempOrder();
2067
- this.logMethodSuccess('syncAdditionalOrderFromResource', {
2083
+ tempOrder.relation_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
2084
+ tempOrder.table_form_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
2085
+ (_f = this.store.order) == null ? void 0 : _f.persistTempOrder();
2086
+ this.logMethodSuccess("syncAdditionalOrderFromResource", {
2068
2087
  ...result,
2069
2088
  resourceId: normalizedResourceId,
2070
2089
  resourceSelectType,
@@ -2072,68 +2091,80 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
2072
2091
  });
2073
2092
  return result;
2074
2093
  }
2075
-
2076
2094
  // 读取预约规则商品的资源选择类型:single=单个预约,multiple=多个预约,capacity=容量型预约
2077
2095
  // 依赖 checkResourceAvailable 已根据预约规则商品与 occupy-detail 的 form_id 计算并缓存 store.resource
2078
2096
  getReservationResourceSelectType() {
2079
- this.logMethodStart('getReservationResourceSelectType');
2080
- const resourceSelectType = this.store.resource?.resourceSelectType;
2097
+ var _a;
2098
+ this.logMethodStart("getReservationResourceSelectType");
2099
+ const resourceSelectType = (_a = this.store.resource) == null ? void 0 : _a.resourceSelectType;
2081
2100
  const result = {
2082
- ...(resourceSelectType ? {
2083
- resourceSelectType
2084
- } : {}),
2085
- isSingleReservation: resourceSelectType === 'single',
2086
- isMultipleReservation: resourceSelectType === 'multiple',
2087
- isCapacityReservation: resourceSelectType === 'capacity'
2101
+ ...resourceSelectType ? { resourceSelectType } : {},
2102
+ isSingleReservation: resourceSelectType === "single",
2103
+ isMultipleReservation: resourceSelectType === "multiple",
2104
+ isCapacityReservation: resourceSelectType === "capacity"
2088
2105
  };
2089
- this.logMethodSuccess('getReservationResourceSelectType', result);
2106
+ this.logMethodSuccess("getReservationResourceSelectType", result);
2090
2107
  return result;
2091
2108
  }
2092
-
2093
2109
  // 判定后台是否开启允许加餐
2094
2110
  // 依赖 checkResourceAvailable 已缓存的 dineInConfig
2095
2111
  checkAllowAddItems() {
2096
- this.logMethodStart('checkAllowAddItems');
2097
- const dineInConfig = this.otherParams?.dineInConfig || {};
2112
+ var _a;
2113
+ this.logMethodStart("checkAllowAddItems");
2114
+ const dineInConfig = ((_a = this.otherParams) == null ? void 0 : _a.dineInConfig) || {};
2098
2115
  const result = {
2099
- enabled: (0, _utils.toBoolean)(dineInConfig['sale.allow_add_items'])
2116
+ enabled: (0, import_utils.toBoolean)(dineInConfig["sale.allow_add_items"])
2100
2117
  };
2101
- this.logMethodSuccess('checkAllowAddItems', result);
2118
+ this.logMethodSuccess("checkAllowAddItems", result);
2102
2119
  return result;
2103
2120
  }
2104
-
2105
2121
  // 读取取餐/送餐开关
2106
2122
  // 依赖 checkResourceAvailable 已缓存的 dineInConfig
2107
2123
  getFulfillmentModes() {
2108
- this.logMethodStart('getFulfillmentModes');
2109
- const dineInConfig = this.otherParams?.dineInConfig || {};
2124
+ var _a;
2125
+ this.logMethodStart("getFulfillmentModes");
2126
+ const dineInConfig = ((_a = this.otherParams) == null ? void 0 : _a.dineInConfig) || {};
2110
2127
  const result = {
2111
- enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
2112
- enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
2128
+ enablePickup: Boolean(dineInConfig["fulfillment.enable_pickup"]),
2129
+ enableTableService: Boolean(dineInConfig["fulfillment.enable_table_service"])
2113
2130
  };
2114
- this.logMethodSuccess('getFulfillmentModes', result);
2131
+ this.logMethodSuccess("getFulfillmentModes", result);
2115
2132
  return result;
2116
2133
  }
2117
-
2118
2134
  // 判定后台是否开启客户自定义取餐标识
2119
2135
  // 依赖 checkResourceAvailable 已缓存的 dineInConfig
2120
2136
  checkManualPickupRef() {
2121
- this.logMethodStart('checkManualPickupRef');
2122
- const dineInConfig = this.otherParams?.dineInConfig || {};
2123
- const refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
2124
- const manualInputType = dineInConfig['fulfillment.manual_input_type'];
2125
- const enabled = refMode === 'manual_input';
2126
- const result = enabled ? {
2127
- enabled: true,
2128
- manualInputType
2129
- } : {
2130
- enabled: false
2131
- };
2132
- this.logMethodSuccess('checkManualPickupRef', {
2137
+ var _a;
2138
+ this.logMethodStart("checkManualPickupRef");
2139
+ const dineInConfig = ((_a = this.otherParams) == null ? void 0 : _a.dineInConfig) || {};
2140
+ const refMode = dineInConfig["fulfillment.fulfillment_ref_mode"];
2141
+ const manualInputType = dineInConfig["fulfillment.manual_input_type"];
2142
+ const enabled = refMode === "manual_input";
2143
+ const result = enabled ? { enabled: true, manualInputType } : { enabled: false };
2144
+ this.logMethodSuccess("checkManualPickupRef", {
2133
2145
  enabled,
2134
- manualInputType: enabled ? manualInputType : undefined
2146
+ manualInputType: enabled ? manualInputType : void 0
2135
2147
  });
2136
2148
  return result;
2137
2149
  }
2138
- }
2139
- exports.ScanOrderImpl = ScanOrderImpl;
2150
+ };
2151
+ var ScanOrderImpl = _ScanOrderImpl;
2152
+ ScanOrderImpl.PISELL1_LOGIN_SUCCESS = "pisell1.login.success";
2153
+ // ─── UI 状态缓存(按 cacheId 分桶,localStorage) ───
2154
+ //
2155
+ // 用于物料层持久化 UI 层面的轻量状态(如当前步骤、gate 标记、登录回跳意图等)。
2156
+ // 桶键:pisell.scanOrder.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
2157
+ // 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
2158
+ //
2159
+ // 之所以用 localStorage 而不是 sessionStorage:
2160
+ // 1. 与 Order 模块 openCache 下的 tempOrder 同栈,购物车在 / UIState 在,行为对齐;
2161
+ // 2. pisell1.login 整页 OAuth 跳转在 H5 壳 / iOS Safari 场景下可能丢 sessionStorage,
2162
+ // 导致登录回跳后 gate 标记失效、pax 弹窗重开、落点错误;localStorage 稳定不受影响。
2163
+ // 3. 失效由上层显式控制:提交成功 clearStepCache / entryContext 不一致 clearUIState /
2164
+ // pendingStep 登录回调 deleteUIState,足够约束生命周期。
2165
+ ScanOrderImpl.UI_STATE_KEY_PREFIX = "pisell.scanOrder.uiState:";
2166
+ // Annotate the CommonJS export names for ESM import in node:
2167
+ 0 && (module.exports = {
2168
+ ScanOrderImpl,
2169
+ ...require("./types")
2170
+ });