@pisell/pisellos 0.10.15 → 0.10.17

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 (331) hide show
  1. package/dist/core/index.js +6 -9
  2. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  3. package/dist/model/strategy/adapter/walletPass/example.js +3 -26
  4. package/dist/model/strategy/strategy-example.js +5 -19
  5. package/dist/modules/Cart/index.js +0 -3
  6. package/dist/modules/Cart/utils/cartProduct.js +0 -1
  7. package/dist/modules/Date/index.js +1 -5
  8. package/dist/modules/Discount/index.js +2 -4
  9. package/dist/modules/OpenData/index.d.ts +5 -2
  10. package/dist/modules/OpenData/index.js +27 -14
  11. package/dist/modules/OpenData/types.d.ts +42 -0
  12. package/dist/modules/OpenData/types.js +7 -1
  13. package/dist/modules/OpenData/utils.d.ts +15 -1
  14. package/dist/modules/OpenData/utils.js +85 -0
  15. package/dist/modules/Order/index.d.ts +4 -2
  16. package/dist/modules/Order/index.js +131 -123
  17. package/dist/modules/Order/types.d.ts +8 -1
  18. package/dist/modules/Order/types.js +1 -0
  19. package/dist/modules/Order/utils.js +7 -1
  20. package/dist/modules/Payment/index.js +97 -162
  21. package/dist/modules/Product/types.d.ts +2 -0
  22. package/dist/modules/ProductList/index.js +96 -74
  23. package/dist/modules/Rules/index.js +12 -12
  24. package/dist/modules/SalesSummary/index.js +6 -4
  25. package/dist/modules/Schedule/index.js +0 -1
  26. package/dist/modules/Schedule/utils.js +0 -1
  27. package/dist/modules/Step/index.js +0 -1
  28. package/dist/plugins/request.js +1 -4
  29. package/dist/plugins/window.js +2 -6
  30. package/dist/server/index.d.ts +11 -0
  31. package/dist/server/index.js +977 -641
  32. package/dist/server/modules/menu/index.js +32 -41
  33. package/dist/server/modules/order/index.d.ts +8 -0
  34. package/dist/server/modules/order/index.js +253 -219
  35. package/dist/server/modules/products/index.js +24 -42
  36. package/dist/server/modules/quotation/index.js +29 -38
  37. package/dist/server/modules/resource/index.js +3 -4
  38. package/dist/server/modules/schedule/index.js +27 -35
  39. package/dist/server/utils/product.js +0 -1
  40. package/dist/server/utils/small-ticket.d.ts +9 -1
  41. package/dist/server/utils/small-ticket.js +117 -43
  42. package/dist/solution/BaseSales/index.d.ts +7 -0
  43. package/dist/solution/BaseSales/index.js +350 -215
  44. package/dist/solution/BaseSales/types.d.ts +2 -0
  45. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
  46. package/dist/solution/BaseSales/utils/cartPromotion.js +15 -6
  47. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
  48. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +7 -1
  49. package/dist/solution/BaseSales/utils.js +6 -3
  50. package/dist/solution/BookingByStep/index.d.ts +2 -2
  51. package/dist/solution/BookingByStep/index.js +7 -59
  52. package/dist/solution/BookingByStep/utils/capacity.js +1 -11
  53. package/dist/solution/BookingByStep/utils/resources.js +1 -3
  54. package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
  55. package/dist/solution/BookingTicket/index.d.ts +14 -19
  56. package/dist/solution/BookingTicket/index.js +553 -433
  57. package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -1
  58. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
  59. package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
  60. package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
  61. package/dist/solution/BuyTickets/index.js +9 -12
  62. package/dist/solution/Checkout/index.js +177 -252
  63. package/dist/solution/Checkout/utils/index.js +4 -16
  64. package/dist/solution/RegisterAndLogin/index.js +30 -76
  65. package/dist/solution/Sales/index.d.ts +20 -4
  66. package/dist/solution/Sales/index.js +348 -75
  67. package/dist/solution/Sales/types.d.ts +10 -0
  68. package/dist/solution/ScanOrder/index.js +50 -60
  69. package/dist/solution/ScanOrder/types.d.ts +2 -0
  70. package/dist/solution/ScanOrder/utils.js +6 -3
  71. package/dist/solution/ShopDiscount/index.js +2 -7
  72. package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
  73. package/dist/solution/UnifiedBookingSales/index.js +495 -422
  74. package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
  75. package/dist/solution/VenueBooking/index.js +45 -55
  76. package/dist/utils/task.js +15 -18
  77. package/dist/utils/watch.js +0 -1
  78. package/lib/apis/picoding.js +2 -0
  79. package/lib/core/index.js +131 -131
  80. package/lib/effects/index.js +46 -57
  81. package/lib/index.js +82 -49
  82. package/lib/model/index.js +14 -21
  83. package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
  84. package/lib/model/strategy/adapter/dataVariant/evaluator.js +209 -315
  85. package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
  86. package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
  87. package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
  88. package/lib/model/strategy/adapter/index.js +100 -64
  89. package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
  90. package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
  91. package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
  92. package/lib/model/strategy/adapter/itemRule/index.js +83 -57
  93. package/lib/model/strategy/adapter/itemRule/type.js +97 -36
  94. package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
  95. package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
  96. package/lib/model/strategy/adapter/promotion/examples.js +222 -234
  97. package/lib/model/strategy/adapter/promotion/index.js +1 -51
  98. package/lib/model/strategy/adapter/promotion/type.js +243 -36
  99. package/lib/model/strategy/adapter/type.js +4 -16
  100. package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
  101. package/lib/model/strategy/adapter/walletPass/example.js +217 -190
  102. package/lib/model/strategy/adapter/walletPass/index.js +75 -51
  103. package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
  104. package/lib/model/strategy/adapter/walletPass/type.js +4 -16
  105. package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
  106. package/lib/model/strategy/engine.js +270 -168
  107. package/lib/model/strategy/index.js +49 -34
  108. package/lib/model/strategy/strategy-example.js +243 -239
  109. package/lib/model/strategy/type.js +100 -40
  110. package/lib/modules/Account/index.js +39 -53
  111. package/lib/modules/Account/types.js +20 -33
  112. package/lib/modules/AccountList/index.js +116 -154
  113. package/lib/modules/AccountList/types.js +30 -31
  114. package/lib/modules/AccountList/utils.js +18 -30
  115. package/lib/modules/BaseModule.js +23 -42
  116. package/lib/modules/BookingContext/index.js +158 -136
  117. package/lib/modules/BookingContext/types.js +46 -32
  118. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
  119. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
  120. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
  121. package/lib/modules/BookingContext/utils/flexible.js +38 -55
  122. package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
  123. package/lib/modules/BookingContext/utils/index.js +124 -41
  124. package/lib/modules/BookingContext/utils/noResource.js +58 -70
  125. package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
  126. package/lib/modules/BookingContext/utils/productExtend.js +202 -155
  127. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  128. package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
  129. package/lib/modules/BookingContext/utils/resources.js +209 -167
  130. package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
  131. package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
  132. package/lib/modules/Cart/index.js +170 -124
  133. package/lib/modules/Cart/types.js +46 -51
  134. package/lib/modules/Cart/utils/cartAccount.js +40 -39
  135. package/lib/modules/Cart/utils/cartDate.js +56 -61
  136. package/lib/modules/Cart/utils/cartDiscount.js +28 -33
  137. package/lib/modules/Cart/utils/cartNote.js +27 -32
  138. package/lib/modules/Cart/utils/cartProduct.js +321 -251
  139. package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
  140. package/lib/modules/Cart/utils/cartResource.js +70 -78
  141. package/lib/modules/Cart/utils/changePrice.js +22 -50
  142. package/lib/modules/Cart/utils/index.js +106 -48
  143. package/lib/modules/Customer/constants.js +13 -34
  144. package/lib/modules/Customer/index.js +235 -172
  145. package/lib/modules/Customer/types.js +38 -35
  146. package/lib/modules/Date/index.js +116 -115
  147. package/lib/modules/Date/types.js +16 -28
  148. package/lib/modules/Date/utils.js +174 -123
  149. package/lib/modules/Discount/index.js +133 -143
  150. package/lib/modules/Discount/types.js +9 -31
  151. package/lib/modules/Guests/index.js +30 -56
  152. package/lib/modules/Guests/types.js +23 -33
  153. package/lib/modules/Holder/index.js +209 -189
  154. package/lib/modules/Holder/types.js +4 -16
  155. package/lib/modules/Holder/utils.js +20 -49
  156. package/lib/modules/OpenData/index.d.ts +5 -2
  157. package/lib/modules/OpenData/index.js +119 -78
  158. package/lib/modules/OpenData/types.d.ts +42 -0
  159. package/lib/modules/OpenData/types.js +12 -16
  160. package/lib/modules/OpenData/utils.d.ts +15 -1
  161. package/lib/modules/OpenData/utils.js +129 -78
  162. package/lib/modules/Order/index.d.ts +4 -2
  163. package/lib/modules/Order/index.js +1843 -2251
  164. package/lib/modules/Order/payment-utils.js +77 -120
  165. package/lib/modules/Order/types.d.ts +8 -1
  166. package/lib/modules/Order/types.js +88 -35
  167. package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
  168. package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
  169. package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
  170. package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
  171. package/lib/modules/Order/utils/virtualSettlement.js +120 -171
  172. package/lib/modules/Order/utils.js +834 -668
  173. package/lib/modules/Payment/cash.js +20 -33
  174. package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
  175. package/lib/modules/Payment/eftpos.js +16 -30
  176. package/lib/modules/Payment/index.js +532 -399
  177. package/lib/modules/Payment/mx51.js +1 -0
  178. package/lib/modules/Payment/types.js +230 -108
  179. package/lib/modules/Payment/utils.js +52 -51
  180. package/lib/modules/Payment/walletpass.js +485 -660
  181. package/lib/modules/Product/index.js +51 -46
  182. package/lib/modules/Product/types.d.ts +2 -0
  183. package/lib/modules/Product/types.js +4 -16
  184. package/lib/modules/Product/utils.js +32 -33
  185. package/lib/modules/ProductList/index.js +141 -161
  186. package/lib/modules/ProductList/types.js +9 -31
  187. package/lib/modules/Quotation/index.js +66 -100
  188. package/lib/modules/Quotation/types.js +4 -16
  189. package/lib/modules/Resource/index.js +27 -59
  190. package/lib/modules/Resource/types.js +22 -32
  191. package/lib/modules/Resource/utils.js +30 -38
  192. package/lib/modules/ResourcePlanner/index.js +25 -23
  193. package/lib/modules/ResourcePlanner/localClock.js +54 -119
  194. package/lib/modules/ResourcePlanner/planner.js +591 -772
  195. package/lib/modules/ResourcePlanner/types.js +10 -29
  196. package/lib/modules/Rules/index.js +1224 -963
  197. package/lib/modules/Rules/types.js +17 -40
  198. package/lib/modules/SalesSummary/index.js +80 -89
  199. package/lib/modules/SalesSummary/types.js +4 -16
  200. package/lib/modules/SalesSummary/utils.js +359 -442
  201. package/lib/modules/ScanOrderLogger/index.js +59 -79
  202. package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
  203. package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
  204. package/lib/modules/ScanOrderLogger/types.js +4 -16
  205. package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
  206. package/lib/modules/Schedule/index.js +100 -114
  207. package/lib/modules/Schedule/type.js +4 -16
  208. package/lib/modules/Schedule/types.js +4 -16
  209. package/lib/modules/Schedule/utils.js +433 -291
  210. package/lib/modules/Step/index.js +40 -52
  211. package/lib/modules/Step/tyeps.js +4 -16
  212. package/lib/modules/Summary/index.js +66 -71
  213. package/lib/modules/Summary/types.js +4 -16
  214. package/lib/modules/Summary/utils.js +773 -418
  215. package/lib/modules/SurchargeList/index.js +46 -60
  216. package/lib/modules/SurchargeList/types.js +4 -16
  217. package/lib/modules/index.js +245 -63
  218. package/lib/plugins/app.js +4 -16
  219. package/lib/plugins/index.js +36 -25
  220. package/lib/plugins/request.js +137 -126
  221. package/lib/plugins/shopStore.js +4 -16
  222. package/lib/plugins/user.js +4 -16
  223. package/lib/plugins/window.js +171 -179
  224. package/lib/server/index.d.ts +11 -0
  225. package/lib/server/index.js +3432 -2757
  226. package/lib/server/modules/floor-plan/index.js +102 -123
  227. package/lib/server/modules/floor-plan/types.js +15 -30
  228. package/lib/server/modules/index.js +106 -68
  229. package/lib/server/modules/menu/index.js +146 -122
  230. package/lib/server/modules/menu/types.js +18 -31
  231. package/lib/server/modules/order/index.d.ts +8 -0
  232. package/lib/server/modules/order/index.js +781 -956
  233. package/lib/server/modules/order/types.js +122 -33
  234. package/lib/server/modules/order/utils/filterBookings.js +219 -194
  235. package/lib/server/modules/order/utils/filterOrders.js +118 -92
  236. package/lib/server/modules/payment/index.js +59 -83
  237. package/lib/server/modules/payment/types.js +4 -16
  238. package/lib/server/modules/products/index.js +575 -459
  239. package/lib/server/modules/products/types.js +44 -34
  240. package/lib/server/modules/quotation/index.js +137 -172
  241. package/lib/server/modules/quotation/types.js +21 -31
  242. package/lib/server/modules/resource/index.js +213 -184
  243. package/lib/server/modules/resource/types.js +42 -33
  244. package/lib/server/modules/schedule/index.js +135 -123
  245. package/lib/server/modules/schedule/types.js +14 -21
  246. package/lib/server/modules/schedule/utils.js +334 -163
  247. package/lib/server/types.js +4 -16
  248. package/lib/server/utils/index.js +25 -23
  249. package/lib/server/utils/product.js +196 -139
  250. package/lib/server/utils/schedule.js +34 -41
  251. package/lib/server/utils/small-ticket.d.ts +9 -1
  252. package/lib/server/utils/small-ticket.js +565 -470
  253. package/lib/server/utils/time.js +40 -49
  254. package/lib/solution/BaseSales/index.d.ts +7 -0
  255. package/lib/solution/BaseSales/index.js +1385 -1503
  256. package/lib/solution/BaseSales/types.d.ts +2 -0
  257. package/lib/solution/BaseSales/types.js +42 -38
  258. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
  259. package/lib/solution/BaseSales/utils/cartPromotion.js +652 -498
  260. package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
  261. package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
  262. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
  263. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +138 -180
  264. package/lib/solution/BaseSales/utils.js +161 -143
  265. package/lib/solution/BookingByStep/index.d.ts +2 -2
  266. package/lib/solution/BookingByStep/index.js +1527 -1340
  267. package/lib/solution/BookingByStep/types.js +40 -99
  268. package/lib/solution/BookingByStep/utils/capacity.js +192 -160
  269. package/lib/solution/BookingByStep/utils/products.js +42 -52
  270. package/lib/solution/BookingByStep/utils/resources.js +527 -330
  271. package/lib/solution/BookingByStep/utils/stock.js +65 -44
  272. package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
  273. package/lib/solution/BookingTicket/index.d.ts +14 -19
  274. package/lib/solution/BookingTicket/index.js +663 -526
  275. package/lib/solution/BookingTicket/types.js +99 -77
  276. package/lib/solution/BookingTicket/utils/addProductDecision.js +229 -190
  277. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
  278. package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
  279. package/lib/solution/BookingTicket/utils/cartView.js +114 -99
  280. package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
  281. package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
  282. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
  283. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
  284. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
  285. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
  286. package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
  287. package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
  288. package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
  289. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
  290. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
  291. package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
  292. package/lib/solution/BuyTickets/index.js +67 -70
  293. package/lib/solution/BuyTickets/types.js +22 -38
  294. package/lib/solution/Checkout/index.js +1451 -1158
  295. package/lib/solution/Checkout/types.js +91 -61
  296. package/lib/solution/Checkout/utils/index.js +228 -156
  297. package/lib/solution/PlaceOrder/index.js +55 -0
  298. package/lib/solution/RegisterAndLogin/config.js +493 -460
  299. package/lib/solution/RegisterAndLogin/index.js +633 -630
  300. package/lib/solution/RegisterAndLogin/types.js +189 -76
  301. package/lib/solution/RegisterAndLogin/utils.js +183 -125
  302. package/lib/solution/Sales/index.d.ts +20 -4
  303. package/lib/solution/Sales/index.js +502 -330
  304. package/lib/solution/Sales/types.d.ts +10 -0
  305. package/lib/solution/Sales/types.js +27 -33
  306. package/lib/solution/ScanOrder/index.js +822 -852
  307. package/lib/solution/ScanOrder/types.d.ts +2 -0
  308. package/lib/solution/ScanOrder/types.js +33 -34
  309. package/lib/solution/ScanOrder/utils.js +412 -374
  310. package/lib/solution/ShopDiscount/index.js +226 -232
  311. package/lib/solution/ShopDiscount/types.js +15 -37
  312. package/lib/solution/ShopDiscount/utils.js +300 -172
  313. package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
  314. package/lib/solution/UnifiedBookingSales/index.js +1087 -1222
  315. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
  316. package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
  317. package/lib/solution/UnifiedBookingSales/types.js +10 -32
  318. package/lib/solution/VenueBooking/index.js +811 -879
  319. package/lib/solution/VenueBooking/types.js +19 -39
  320. package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
  321. package/lib/solution/VenueBooking/utils/resource.js +31 -54
  322. package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
  323. package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
  324. package/lib/solution/VenueBooking/utils.js +130 -67
  325. package/lib/solution/index.js +124 -41
  326. package/lib/store/createStore.js +32 -29
  327. package/lib/types/index.js +4 -16
  328. package/lib/utils/payment-number.js +26 -46
  329. package/lib/utils/task.js +36 -36
  330. package/lib/utils/watch.js +81 -47
  331. package/package.json +2 -1
@@ -43,6 +43,10 @@ import { filterBookingsFromOrders, sortBookings } from "./modules/order/utils/fi
43
43
  import { buildSmallTicketData, hasSmallTicketData } from "./utils/small-ticket";
44
44
  import { BaseSalesImpl } from "../solution/BaseSales";
45
45
  import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity } from "../modules/Order/payment-utils";
46
+ import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "../modules/OpenData";
47
+ var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
48
+ var OS_INVOICE_LAYOUT_CONFIG_FIELD = '_os_invoice_layout_config';
49
+ var OS_INVOICE_TEMPLATE_SETTINGS_FIELD = '_os_invoice_template_settings';
46
50
 
47
51
  // 重新导出类型供外部使用
48
52
 
@@ -68,7 +72,7 @@ var AUTO_PRINT_STORAGE_KEY = 'auto_print';
68
72
  var Server = /*#__PURE__*/function () {
69
73
  function Server(core) {
70
74
  var _this = this,
71
- _this$app4;
75
+ _this$app3;
72
76
  _classCallCheck(this, Server);
73
77
  _defineProperty(this, "core", void 0);
74
78
  _defineProperty(this, "app", void 0);
@@ -289,7 +293,6 @@ var Server = /*#__PURE__*/function () {
289
293
  while (1) switch (_context3.prev = _context3.next) {
290
294
  case 0:
291
295
  url = _ref5.url, method = _ref5.method, data = _ref5.data, config = _ref5.config;
292
- console.log('[Server] handleProductQuery:', url, method, data, config);
293
296
  menu_list_ids = data.menu_list_ids, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type, strategy_context = data.strategy_context;
294
297
  _this$resolveProductQ = _this.resolveProductQueryScheduleContext({
295
298
  schedule_date: data.schedule_date,
@@ -325,7 +328,7 @@ var Server = /*#__PURE__*/function () {
325
328
  totalSubscribers: _this.productQuerySubscribers.size
326
329
  });
327
330
  }
328
- _context3.next = 9;
331
+ _context3.next = 8;
329
332
  return _this.computeProductQueryResult({
330
333
  menu_list_ids: menu_list_ids,
331
334
  ids: ids,
@@ -335,7 +338,7 @@ var Server = /*#__PURE__*/function () {
335
338
  extension_type: extension_type,
336
339
  strategy_context: strategy_context
337
340
  });
338
- case 9:
341
+ case 8:
339
342
  result = _context3.sent;
340
343
  if (subscriberId && typeof callback === 'function') {
341
344
  _this.syncProductQueryScheduleTimers({
@@ -345,7 +348,7 @@ var Server = /*#__PURE__*/function () {
345
348
  });
346
349
  }
347
350
  return _context3.abrupt("return", result);
348
- case 12:
351
+ case 11:
349
352
  case "end":
350
353
  return _context3.stop();
351
354
  }
@@ -369,9 +372,8 @@ var Server = /*#__PURE__*/function () {
369
372
  pathname = _this.parseRequestPath(url || '', path);
370
373
  idMatch = pathname.match(/^\/shop\/product\/query\/(\d+)$/);
371
374
  productId = idMatch ? Number(idMatch[1]) : NaN;
372
- console.log('[Server] handleProductQueryById:', pathname, method, data);
373
375
  if (Number.isFinite(productId)) {
374
- _context4.next = 8;
376
+ _context4.next = 7;
375
377
  break;
376
378
  }
377
379
  _this.logWarning('handleProductQueryById: 无效的商品 id', {
@@ -385,11 +387,11 @@ var Server = /*#__PURE__*/function () {
385
387
  item: null
386
388
  }
387
389
  });
388
- case 8:
390
+ case 7:
389
391
  scheduleDateFromData = data && _typeof(data) === 'object' && typeof data.schedule_date === 'string' ? data.schedule_date.trim() : '';
390
392
  schedule_date = scheduleDateFromData || (_this.extractQueryParam(url || '', 'schedule_date') || '').trim() || dayjs().format('YYYY-MM-DD');
391
393
  if (schedule_date) {
392
- _context4.next = 13;
394
+ _context4.next = 12;
393
395
  break;
394
396
  }
395
397
  _this.logWarning('handleProductQueryById: 缺少 schedule_date', {
@@ -401,7 +403,7 @@ var Server = /*#__PURE__*/function () {
401
403
  status: false,
402
404
  data: null
403
405
  });
404
- case 13:
406
+ case 12:
405
407
  scheduleDtFromData = data && _typeof(data) === 'object' && typeof data.schedule_datetime === 'string' ? data.schedule_datetime.trim() : '';
406
408
  scheduleDtFromUrl = (_this.extractQueryParam(url || '', 'schedule_datetime') || '').trim();
407
409
  scheduleDatetime = scheduleDtFromData || scheduleDtFromUrl || "".concat(schedule_date, "T00:00:00");
@@ -415,7 +417,7 @@ var Server = /*#__PURE__*/function () {
415
417
  schedule_datetime: scheduleDatetime,
416
418
  product_id: productId
417
419
  }));
418
- case 18:
420
+ case 17:
419
421
  case "end":
420
422
  return _context4.stop();
421
423
  }
@@ -463,7 +465,6 @@ var Server = /*#__PURE__*/function () {
463
465
  while (1) switch (_context6.prev = _context6.next) {
464
466
  case 0:
465
467
  url = _ref13.url, method = _ref13.method, data = _ref13.data, config = _ref13.config;
466
- console.log('[Server] handleOrderList:', url, method, data, config);
467
468
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
468
469
  _ref15 = config || {}, callback = _ref15.callback, subscriberId = _ref15.subscriberId;
469
470
  useLocal = _this.shouldUseLocalOrderQuery(queryPayload);
@@ -472,7 +473,7 @@ var Server = /*#__PURE__*/function () {
472
473
  useLocal: useLocal
473
474
  });
474
475
  if (!useLocal) {
475
- _context6.next = 9;
476
+ _context6.next = 8;
476
477
  break;
477
478
  }
478
479
  if (subscriberId && typeof callback === 'function') {
@@ -486,7 +487,7 @@ var Server = /*#__PURE__*/function () {
486
487
  });
487
488
  }
488
489
  return _context6.abrupt("return", _this.computeOrderQueryResult(queryPayload));
489
- case 9:
490
+ case 8:
490
491
  if (subscriberId) {
491
492
  _this.orderQuerySubscribers.delete(subscriberId);
492
493
  _this.logInfo('handleOrderList: 已清理订阅者(走远端)', {
@@ -495,7 +496,7 @@ var Server = /*#__PURE__*/function () {
495
496
  });
496
497
  }
497
498
  return _context6.abrupt("return", _this.fetchOrderListFromAPI(queryPayload));
498
- case 11:
499
+ case 10:
499
500
  case "end":
500
501
  return _context6.stop();
501
502
  }
@@ -638,7 +639,6 @@ var Server = /*#__PURE__*/function () {
638
639
  while (1) switch (_context11.prev = _context11.next) {
639
640
  case 0:
640
641
  url = _ref26.url, method = _ref26.method, data = _ref26.data, config = _ref26.config;
641
- console.log('[Server] handleBookingList:', url, method, data, config);
642
642
  queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
643
643
  _ref28 = config || {}, callback = _ref28.callback, subscriberId = _ref28.subscriberId;
644
644
  useLocal = _this.shouldUseLocalBookingQuery(queryPayload);
@@ -647,7 +647,7 @@ var Server = /*#__PURE__*/function () {
647
647
  useLocal: useLocal
648
648
  });
649
649
  if (!useLocal) {
650
- _context11.next = 12;
650
+ _context11.next = 11;
651
651
  break;
652
652
  }
653
653
  if (subscriberId) {
@@ -664,7 +664,7 @@ var Server = /*#__PURE__*/function () {
664
664
  });
665
665
  }
666
666
  return _context11.abrupt("return", _this.computeBookingQueryResult(queryPayload));
667
- case 12:
667
+ case 11:
668
668
  if (subscriberId) {
669
669
  _this.bookingQuerySubscribers.delete(subscriberId);
670
670
  }
@@ -690,7 +690,7 @@ var Server = /*#__PURE__*/function () {
690
690
  });
691
691
  }
692
692
  return _context11.abrupt("return", _this.fetchBookingListFromAPI(queryPayload));
693
- case 16:
693
+ case 15:
694
694
  case "end":
695
695
  return _context11.stop();
696
696
  }
@@ -712,7 +712,6 @@ var Server = /*#__PURE__*/function () {
712
712
  while (1) switch (_context12.prev = _context12.next) {
713
713
  case 0:
714
714
  url = _ref29.url, method = _ref29.method, data = _ref29.data, config = _ref29.config;
715
- console.log('[Server] handleResourceList:', url, method, data, config);
716
715
  list = (_this$resource = _this.resource) === null || _this$resource === void 0 ? void 0 : _this$resource.getResources({
717
716
  skip: (data === null || data === void 0 ? void 0 : data.skip) || 1,
718
717
  num: (data === null || data === void 0 ? void 0 : data.num) || 10
@@ -729,7 +728,7 @@ var Server = /*#__PURE__*/function () {
729
728
  message: '',
730
729
  status: true
731
730
  });
732
- case 5:
731
+ case 4:
733
732
  case "end":
734
733
  return _context12.stop();
735
734
  }
@@ -1141,15 +1140,30 @@ var Server = /*#__PURE__*/function () {
1141
1140
  }());
1142
1141
  _defineProperty(this, "handleLocalPrintOrder", /*#__PURE__*/function () {
1143
1142
  var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref44) {
1144
- var data, _this$getLocalPrintOr, _need_sync, inputOrder, shouldLookup, lookup, sourceOrder, _this$order, _ref46, _localOrder$order_id, _ref47, _external_sale_number, localOrder, checkoutData, printableOrder, printResult, message;
1143
+ var data, _extractedRequestTemp, _nestedOrderTemplateS, _extractedRequest$inv, _extractedRequestTemp2, _this$getLocalPrintOr, _need_sync, extractedRequest, extractedRequestTemplateSettings, requestOrder, nestedOrder, nestedOrderTemplateSettings, inputOrder, invoiceLayoutConfig, invoiceTemplateSettings, shouldLookup, lookup, sourceOrder, _this$order, localOrder, remoteResult, checkoutData, printableOrder, printResult, message;
1145
1144
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1146
1145
  while (1) switch (_context19.prev = _context19.next) {
1147
1146
  case 0:
1148
1147
  data = _ref44.data;
1149
1148
  _context19.prev = 1;
1150
- inputOrder = data !== null && data !== void 0 && data.order && _typeof(data.order) === 'object' ? data.order : data;
1149
+ extractedRequest = _this.extractInvoiceLayoutConfig(data, {
1150
+ includePublicInvoice: true
1151
+ });
1152
+ extractedRequestTemplateSettings = _this.extractInvoiceTemplateSettings(extractedRequest.data, {
1153
+ includePublicTemplateSettings: true
1154
+ });
1155
+ requestOrder = (_extractedRequestTemp = extractedRequestTemplateSettings.data) === null || _extractedRequestTemp === void 0 ? void 0 : _extractedRequestTemp.order;
1156
+ nestedOrder = requestOrder && _typeof(requestOrder) === 'object' ? _this.extractInvoiceLayoutConfig(requestOrder, {
1157
+ includePublicInvoice: true
1158
+ }) : null;
1159
+ nestedOrderTemplateSettings = nestedOrder ? _this.extractInvoiceTemplateSettings(nestedOrder.data, {
1160
+ includePublicTemplateSettings: true
1161
+ }) : null;
1162
+ inputOrder = (_nestedOrderTemplateS = nestedOrderTemplateSettings === null || nestedOrderTemplateSettings === void 0 ? void 0 : nestedOrderTemplateSettings.data) !== null && _nestedOrderTemplateS !== void 0 ? _nestedOrderTemplateS : extractedRequestTemplateSettings.data;
1163
+ invoiceLayoutConfig = (_extractedRequest$inv = extractedRequest.invoiceLayoutConfig) !== null && _extractedRequest$inv !== void 0 ? _extractedRequest$inv : nestedOrder === null || nestedOrder === void 0 ? void 0 : nestedOrder.invoiceLayoutConfig;
1164
+ invoiceTemplateSettings = _this.normalizePrintInvoiceTemplateSettings((_extractedRequestTemp2 = extractedRequestTemplateSettings.invoiceTemplateSettings) !== null && _extractedRequestTemp2 !== void 0 ? _extractedRequestTemp2 : nestedOrderTemplateSettings === null || nestedOrderTemplateSettings === void 0 ? void 0 : nestedOrderTemplateSettings.invoiceTemplateSettings);
1151
1165
  if (!(!inputOrder || _typeof(inputOrder) !== 'object')) {
1152
- _context19.next = 5;
1166
+ _context19.next = 12;
1153
1167
  break;
1154
1168
  }
1155
1169
  return _context19.abrupt("return", {
@@ -1161,21 +1175,21 @@ var Server = /*#__PURE__*/function () {
1161
1175
  order: null
1162
1176
  }
1163
1177
  });
1164
- case 5:
1165
- shouldLookup = _this.shouldLookupLocalPrintOrder(inputOrder) || _this.shouldLookupLocalPrintOrder(data);
1178
+ case 12:
1179
+ shouldLookup = _this.shouldLookupLocalPrintOrder(inputOrder) || _this.shouldLookupLocalPrintOrder(extractedRequest.data);
1166
1180
  _this.logInfo('handleLocalPrintOrder: 是否需要查找本地订单', {
1167
1181
  shouldLookup: shouldLookup,
1168
1182
  inputOrder: inputOrder,
1169
1183
  data: data
1170
1184
  });
1171
- lookup = shouldLookup ? (_this$getLocalPrintOr = _this.getLocalPrintOrderLookup(inputOrder)) !== null && _this$getLocalPrintOr !== void 0 ? _this$getLocalPrintOr : _this.getLocalPrintOrderLookup(data) : undefined;
1185
+ lookup = shouldLookup ? (_this$getLocalPrintOr = _this.getLocalPrintOrderLookup(inputOrder)) !== null && _this$getLocalPrintOr !== void 0 ? _this$getLocalPrintOr : _this.getLocalPrintOrderLookup(extractedRequest.data) : undefined;
1172
1186
  sourceOrder = inputOrder;
1173
1187
  if (!shouldLookup) {
1174
- _context19.next = 20;
1188
+ _context19.next = 32;
1175
1189
  break;
1176
1190
  }
1177
1191
  if (!(lookup === undefined)) {
1178
- _context19.next = 12;
1192
+ _context19.next = 19;
1179
1193
  break;
1180
1194
  }
1181
1195
  return _context19.abrupt("return", {
@@ -1187,9 +1201,9 @@ var Server = /*#__PURE__*/function () {
1187
1201
  order: null
1188
1202
  }
1189
1203
  });
1190
- case 12:
1204
+ case 19:
1191
1205
  if ((_this$order = _this.order) !== null && _this$order !== void 0 && _this$order.getLocalOrderByLookup) {
1192
- _context19.next = 14;
1206
+ _context19.next = 21;
1193
1207
  break;
1194
1208
  }
1195
1209
  return _context19.abrupt("return", {
@@ -1201,35 +1215,44 @@ var Server = /*#__PURE__*/function () {
1201
1215
  order: null
1202
1216
  }
1203
1217
  });
1204
- case 14:
1205
- _context19.next = 16;
1218
+ case 21:
1219
+ _context19.next = 23;
1206
1220
  return _this.order.getLocalOrderByLookup(lookup);
1207
- case 16:
1221
+ case 23:
1208
1222
  localOrder = _context19.sent;
1209
1223
  if (localOrder) {
1210
- _context19.next = 19;
1224
+ _context19.next = 31;
1225
+ break;
1226
+ }
1227
+ _context19.next = 27;
1228
+ return _this.fetchAndPersistSalesOrderByLookup(lookup, {
1229
+ with: ['all']
1230
+ }, 'handleLocalPrintOrder');
1231
+ case 27:
1232
+ remoteResult = _context19.sent;
1233
+ if (remoteResult.order) {
1234
+ _context19.next = 30;
1211
1235
  break;
1212
1236
  }
1213
1237
  return _context19.abrupt("return", {
1214
- code: 404,
1238
+ code: remoteResult.code,
1215
1239
  status: false,
1216
- message: '订单不存在',
1240
+ message: remoteResult.message,
1217
1241
  data: {
1218
1242
  printed: false,
1219
1243
  order: null
1220
1244
  }
1221
1245
  });
1222
- case 19:
1223
- sourceOrder = _objectSpread(_objectSpread(_objectSpread({}, localOrder), inputOrder), {}, {
1224
- order_id: (_ref46 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : inputOrder.order_id) !== null && _ref46 !== void 0 ? _ref46 : inputOrder.orderId,
1225
- external_sale_number: (_ref47 = (_external_sale_number = localOrder.external_sale_number) !== null && _external_sale_number !== void 0 ? _external_sale_number : inputOrder.external_sale_number) !== null && _ref47 !== void 0 ? _ref47 : inputOrder.externalSaleNumber
1226
- });
1227
- case 20:
1228
- _context19.next = 22;
1246
+ case 30:
1247
+ localOrder = remoteResult.order;
1248
+ case 31:
1249
+ sourceOrder = _this.mergeLocalPrintOrderInput(localOrder, inputOrder);
1250
+ case 32:
1251
+ _context19.next = 34;
1229
1252
  return _this.ensureCheckoutOrderNumbers(_objectSpread(_objectSpread({}, sourceOrder), {}, {
1230
1253
  small_ticket_data_flag: 1
1231
1254
  }), 'handleLocalPrintOrder');
1232
- case 22:
1255
+ case 34:
1233
1256
  checkoutData = _context19.sent;
1234
1257
  printableOrder = _objectSpread(_objectSpread({}, checkoutData), {}, {
1235
1258
  need_sync: (_need_sync = checkoutData.need_sync) !== null && _need_sync !== void 0 ? _need_sync : 1
@@ -1238,15 +1261,17 @@ var Server = /*#__PURE__*/function () {
1238
1261
  checkoutData: checkoutData,
1239
1262
  printableOrder: printableOrder
1240
1263
  });
1241
- _context19.next = 27;
1264
+ _context19.next = 39;
1242
1265
  return _this.dispatchLocalReceiptPrint({
1243
1266
  checkoutData: checkoutData,
1244
1267
  order: printableOrder,
1245
1268
  response: null,
1246
1269
  requireFullyPaid: false,
1247
- isManualPrint: true
1270
+ isManualPrint: true,
1271
+ invoiceLayoutConfig: invoiceLayoutConfig,
1272
+ invoiceTemplateSettings: invoiceTemplateSettings
1248
1273
  });
1249
- case 27:
1274
+ case 39:
1250
1275
  printResult = _context19.sent;
1251
1276
  return _context19.abrupt("return", {
1252
1277
  code: 200,
@@ -1257,8 +1282,8 @@ var Server = /*#__PURE__*/function () {
1257
1282
  order: printResult.order
1258
1283
  }
1259
1284
  });
1260
- case 31:
1261
- _context19.prev = 31;
1285
+ case 43:
1286
+ _context19.prev = 43;
1262
1287
  _context19.t0 = _context19["catch"](1);
1263
1288
  message = _context19.t0 instanceof Error ? _context19.t0.message : String(_context19.t0);
1264
1289
  _this.logError('handleLocalPrintOrder: 本地打印小票失败', {
@@ -1273,24 +1298,24 @@ var Server = /*#__PURE__*/function () {
1273
1298
  order: null
1274
1299
  }
1275
1300
  });
1276
- case 36:
1301
+ case 48:
1277
1302
  case "end":
1278
1303
  return _context19.stop();
1279
1304
  }
1280
- }, _callee19, null, [[1, 31]]);
1305
+ }, _callee19, null, [[1, 43]]);
1281
1306
  }));
1282
1307
  return function (_x19) {
1283
1308
  return _ref45.apply(this, arguments);
1284
1309
  };
1285
1310
  }());
1286
1311
  _defineProperty(this, "handleMachinecodeBatchMeta", /*#__PURE__*/function () {
1287
- var _ref49 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref48) {
1312
+ var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref46) {
1288
1313
  var _this$resolveMachinec, _this$app2;
1289
1314
  var data, title, backendPath, ids, status, message, _response$code, _response$status, _response$message, _response$data2, response, backendError, _backendError$code, _backendError$status, _backendError$message, _backendError$data, _message;
1290
1315
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1291
1316
  while (1) switch (_context20.prev = _context20.next) {
1292
1317
  case 0:
1293
- data = _ref48.data;
1318
+ data = _ref46.data;
1294
1319
  title = 'handleMachinecodeBatchMeta';
1295
1320
  backendPath = '/shop/machinecode/batch';
1296
1321
  ids = Array.isArray(data === null || data === void 0 ? void 0 : data.ids) ? data.ids : [];
@@ -1409,17 +1434,16 @@ var Server = /*#__PURE__*/function () {
1409
1434
  }, _callee20, null, [[10, 15], [23, 30]]);
1410
1435
  }));
1411
1436
  return function (_x20) {
1412
- return _ref49.apply(this, arguments);
1437
+ return _ref47.apply(this, arguments);
1413
1438
  };
1414
1439
  }());
1415
1440
  _defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
1416
- var _ref51 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(_ref50) {
1417
- var _this$app3;
1418
- var url, data, path, requestPath, lookup, localOrder, enrichedOrder, backendPath, _response$data3, response, fresh, savedOrder, _enrichedOrder, errorMessage;
1441
+ var _ref49 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(_ref48) {
1442
+ var url, data, path, requestPath, lookup, localOrder, _enrichedOrder, remoteResult, enrichedOrder;
1419
1443
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1420
1444
  while (1) switch (_context21.prev = _context21.next) {
1421
1445
  case 0:
1422
- url = _ref50.url, data = _ref50.data, path = _ref50.path;
1446
+ url = _ref48.url, data = _ref48.data, path = _ref48.path;
1423
1447
  requestPath = _this.parseRequestPath(url, path);
1424
1448
  lookup = _this.extractOrderSalesDetailLookup(requestPath);
1425
1449
  _this.logInfo('handleOrderSalesDetail: 开始处理', {
@@ -1469,7 +1493,7 @@ var Server = /*#__PURE__*/function () {
1469
1493
  _context21.next = 17;
1470
1494
  return _this.withSalesDetailProductSnapshots(localOrder);
1471
1495
  case 17:
1472
- enrichedOrder = _context21.sent;
1496
+ _enrichedOrder = _context21.sent;
1473
1497
  _this.logInfo('handleOrderSalesDetail: 命中本地订单', {
1474
1498
  lookup: lookup
1475
1499
  });
@@ -1477,117 +1501,54 @@ var Server = /*#__PURE__*/function () {
1477
1501
  code: 200,
1478
1502
  status: true,
1479
1503
  message: '',
1480
- data: enrichedOrder
1504
+ data: _enrichedOrder
1481
1505
  });
1482
1506
  case 20:
1483
- if ((_this$app3 = _this.app) !== null && _this$app3 !== void 0 && _this$app3.request) {
1484
- _context21.next = 23;
1507
+ _context21.next = 22;
1508
+ return _this.fetchAndPersistSalesOrderByLookup(lookup, data, 'handleOrderSalesDetail');
1509
+ case 22:
1510
+ remoteResult = _context21.sent;
1511
+ if (remoteResult.order) {
1512
+ _context21.next = 25;
1485
1513
  break;
1486
1514
  }
1487
- _this.logError('handleOrderSalesDetail: app.request 不可用');
1488
1515
  return _context21.abrupt("return", {
1489
- code: 500,
1516
+ code: remoteResult.code,
1490
1517
  status: false,
1491
- message: 'app.request 不可用',
1518
+ message: remoteResult.message,
1492
1519
  data: null
1493
1520
  });
1494
- case 23:
1495
- backendPath = _this.buildOrderSalesDetailBackendPath(lookup, data);
1496
- _context21.prev = 24;
1521
+ case 25:
1497
1522
  _context21.next = 27;
1498
- return _this.app.request.get(backendPath, {
1499
- lookup_mode: 'multi'
1500
- }, {
1501
- isShopApi: true,
1502
- customToast: function customToast() {}
1503
- });
1523
+ return _this.withSalesDetailProductSnapshots(remoteResult.order);
1504
1524
  case 27:
1505
- response = _context21.sent;
1506
- fresh = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
1507
- if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
1508
- _context21.next = 32;
1509
- break;
1510
- }
1511
- _this.logInfo('handleOrderSalesDetail: 后端返回订单为空', {
1512
- lookup: lookup,
1513
- backendPath: backendPath
1514
- });
1515
- return _context21.abrupt("return", {
1516
- code: 500,
1517
- status: false,
1518
- message: '后端返回订单为空',
1519
- data: null
1520
- });
1521
- case 32:
1522
- _context21.next = 34;
1523
- return _this.order.upsertOrdersFromRemote([fresh]);
1524
- case 34:
1525
- _context21.next = 36;
1526
- return _this.order.getLocalOrderByLookup(lookup);
1527
- case 36:
1528
- savedOrder = _context21.sent;
1529
- if (savedOrder) {
1530
- _context21.next = 40;
1531
- break;
1532
- }
1533
- _this.logError('handleOrderSalesDetail: 订单写入后回读失败', {
1534
- lookup: lookup
1535
- });
1536
- return _context21.abrupt("return", {
1537
- code: 500,
1538
- status: false,
1539
- message: '订单写入后回读失败',
1540
- data: null
1541
- });
1542
- case 40:
1543
- _this.logInfo('handleOrderSalesDetail: 远端订单已同步到本地', {
1544
- lookup: lookup
1545
- });
1546
- _context21.next = 43;
1547
- return _this.withSalesDetailProductSnapshots(savedOrder);
1548
- case 43:
1549
- _enrichedOrder = _context21.sent;
1525
+ enrichedOrder = _context21.sent;
1550
1526
  return _context21.abrupt("return", {
1551
1527
  code: 200,
1552
1528
  status: true,
1553
1529
  message: '',
1554
- data: _enrichedOrder
1555
- });
1556
- case 47:
1557
- _context21.prev = 47;
1558
- _context21.t0 = _context21["catch"](24);
1559
- errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
1560
- _this.logInfo('handleOrderSalesDetail: 请求失败', {
1561
- lookup: lookup,
1562
- backendPath: backendPath,
1563
- error: errorMessage
1564
- });
1565
- return _context21.abrupt("return", {
1566
- code: 500,
1567
- status: false,
1568
- message: errorMessage,
1569
- data: null
1530
+ data: enrichedOrder
1570
1531
  });
1571
- case 52:
1532
+ case 29:
1572
1533
  case "end":
1573
1534
  return _context21.stop();
1574
1535
  }
1575
- }, _callee21, null, [[24, 47]]);
1536
+ }, _callee21);
1576
1537
  }));
1577
1538
  return function (_x21) {
1578
- return _ref51.apply(this, arguments);
1539
+ return _ref49.apply(this, arguments);
1579
1540
  };
1580
1541
  }());
1581
1542
  /**
1582
1543
  * GET /shop/schedule/floor-plan* 前缀路由:读本地 store;支持 subscriberId + callback 订阅更新
1583
1544
  */
1584
1545
  _defineProperty(this, "handleFloorPlanGet", /*#__PURE__*/function () {
1585
- var _ref53 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(_ref52) {
1586
- var url, data, config, routePath, base, path, _subscriberId, _ref54, callback, subscriberId, ctx;
1546
+ var _ref51 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(_ref50) {
1547
+ var url, data, config, routePath, base, path, _subscriberId, _ref52, callback, subscriberId, ctx;
1587
1548
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1588
1549
  while (1) switch (_context22.prev = _context22.next) {
1589
1550
  case 0:
1590
- url = _ref52.url, data = _ref52.data, config = _ref52.config, routePath = _ref52.path;
1551
+ url = _ref50.url, data = _ref50.data, config = _ref50.config, routePath = _ref50.path;
1591
1552
  base = '/shop/schedule/floor-plan';
1592
1553
  path = _this.parseRequestPath(url, routePath);
1593
1554
  if (!(path === "".concat(base, "/unsubscribe") || path === "".concat(base, "/code/unsubscribe"))) {
@@ -1608,7 +1569,7 @@ var Server = /*#__PURE__*/function () {
1608
1569
  status: true
1609
1570
  });
1610
1571
  case 7:
1611
- _ref54 = config || {}, callback = _ref54.callback, subscriberId = _ref54.subscriberId;
1572
+ _ref52 = config || {}, callback = _ref52.callback, subscriberId = _ref52.subscriberId;
1612
1573
  ctx = _this.resolveFloorPlanQueryContext(path, base);
1613
1574
  if (ctx) {
1614
1575
  _context22.next = 11;
@@ -1640,20 +1601,20 @@ var Server = /*#__PURE__*/function () {
1640
1601
  }, _callee22);
1641
1602
  }));
1642
1603
  return function (_x22) {
1643
- return _ref53.apply(this, arguments);
1604
+ return _ref51.apply(this, arguments);
1644
1605
  };
1645
1606
  }());
1646
1607
  /**
1647
1608
  * 取消预约列表查询订阅(HTTP 路由入口)
1648
1609
  */
1649
1610
  _defineProperty(this, "handleUnsubscribeBookingQuery", /*#__PURE__*/function () {
1650
- var _ref56 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(_ref55) {
1651
- var data, _ref57, subscriberId;
1611
+ var _ref54 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(_ref53) {
1612
+ var data, _ref55, subscriberId;
1652
1613
  return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1653
1614
  while (1) switch (_context23.prev = _context23.next) {
1654
1615
  case 0:
1655
- data = _ref55.data;
1656
- _ref57 = data || {}, subscriberId = _ref57.subscriberId;
1616
+ data = _ref53.data;
1617
+ _ref55 = data || {}, subscriberId = _ref55.subscriberId;
1657
1618
  if (subscriberId) {
1658
1619
  _this.bookingQuerySubscribers.delete(subscriberId);
1659
1620
  _this.bookingRemoteQuerySubscribers.delete(subscriberId);
@@ -1675,7 +1636,7 @@ var Server = /*#__PURE__*/function () {
1675
1636
  }, _callee23);
1676
1637
  }));
1677
1638
  return function (_x23) {
1678
- return _ref56.apply(this, arguments);
1639
+ return _ref54.apply(this, arguments);
1679
1640
  };
1680
1641
  }());
1681
1642
  /**
@@ -1683,14 +1644,13 @@ var Server = /*#__PURE__*/function () {
1683
1644
  * 通过餐牌ID列表获取所有相关日程的时间段点
1684
1645
  */
1685
1646
  _defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
1686
- var _ref59 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref58) {
1647
+ var _ref57 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref56) {
1687
1648
  var _menu_list_ids$length;
1688
1649
  var url, method, data, config, menu_list_ids, _menu_list_ids$length2, _this$getMenuSchedule, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
1689
1650
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1690
1651
  while (1) switch (_context24.prev = _context24.next) {
1691
1652
  case 0:
1692
- url = _ref58.url, method = _ref58.method, data = _ref58.data, config = _ref58.config;
1693
- console.log('[Server] handleGetScheduleTimePoints:', url, method, data, config);
1653
+ url = _ref56.url, method = _ref56.method, data = _ref56.data, config = _ref56.config;
1694
1654
  menu_list_ids = data.menu_list_ids;
1695
1655
  _this.logInfo('handleGetScheduleTimePoints 开始处理', {
1696
1656
  menuListIdsCount: (_menu_list_ids$length = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length !== void 0 ? _menu_list_ids$length : 0,
@@ -1699,7 +1659,7 @@ var Server = /*#__PURE__*/function () {
1699
1659
 
1700
1660
  // 检查必要的模块是否已注册
1701
1661
  if (_this.menu) {
1702
- _context24.next = 8;
1662
+ _context24.next = 7;
1703
1663
  break;
1704
1664
  }
1705
1665
  console.error('[Server] Menu 模块未注册');
@@ -1710,9 +1670,9 @@ var Server = /*#__PURE__*/function () {
1710
1670
  data: [],
1711
1671
  status: false
1712
1672
  });
1713
- case 8:
1673
+ case 7:
1714
1674
  if (_this.schedule) {
1715
- _context24.next = 12;
1675
+ _context24.next = 11;
1716
1676
  break;
1717
1677
  }
1718
1678
  console.error('[Server] Schedule 模块未注册');
@@ -1723,9 +1683,9 @@ var Server = /*#__PURE__*/function () {
1723
1683
  data: [],
1724
1684
  status: false
1725
1685
  });
1726
- case 12:
1686
+ case 11:
1727
1687
  if (!(!menu_list_ids || !Array.isArray(menu_list_ids) || menu_list_ids.length === 0)) {
1728
- _context24.next = 16;
1688
+ _context24.next = 15;
1729
1689
  break;
1730
1690
  }
1731
1691
  console.error('[Server] menu_list_ids 参数无效');
@@ -1739,22 +1699,20 @@ var Server = /*#__PURE__*/function () {
1739
1699
  data: [],
1740
1700
  status: false
1741
1701
  });
1742
- case 16:
1743
- _context24.prev = 16;
1702
+ case 15:
1703
+ _context24.prev = 15;
1744
1704
  _this$getMenuSchedule = _this.getMenuScheduleTimePoints(menu_list_ids), menuList = _this$getMenuSchedule.menuList, scheduleIds = _this$getMenuSchedule.scheduleIds, scheduleList = _this$getMenuSchedule.scheduleList, timePoints = _this$getMenuSchedule.timePoints;
1745
- console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
1746
1705
  _this.logInfo('handleGetScheduleTimePoints: 获取到餐牌列表', {
1747
1706
  requestedCount: menu_list_ids.length,
1748
1707
  foundCount: menuList.length,
1749
1708
  menu_list_ids: menu_list_ids,
1750
1709
  menuList: menuList
1751
1710
  });
1752
- console.log("[Server] \u63D0\u53D6\u5230 ".concat(scheduleIds.length, " \u4E2A\u65E5\u7A0BID:"), scheduleIds);
1753
1711
  _this.logInfo('handleGetScheduleTimePoints: 提取到日程 IDs', {
1754
1712
  scheduleCount: scheduleIds.length
1755
1713
  });
1756
1714
  if (!(scheduleIds.length === 0)) {
1757
- _context24.next = 25;
1715
+ _context24.next = 22;
1758
1716
  break;
1759
1717
  }
1760
1718
  _this.logInfo('handleGetScheduleTimePoints: 没有找到相关日程', {
@@ -1766,13 +1724,11 @@ var Server = /*#__PURE__*/function () {
1766
1724
  data: [],
1767
1725
  status: true
1768
1726
  });
1769
- case 25:
1770
- console.log("[Server] \u627E\u5230 ".concat(scheduleList.length, " \u4E2A\u65E5\u7A0B"));
1727
+ case 22:
1771
1728
  _this.logInfo('handleGetScheduleTimePoints: 获取到日程详情', {
1772
1729
  requestedCount: scheduleIds.length,
1773
1730
  foundCount: scheduleList.length
1774
1731
  });
1775
- console.log("[Server] \u63D0\u53D6\u5230 ".concat(timePoints.length, " \u4E2A\u65F6\u95F4\u70B9:"), timePoints);
1776
1732
  _this.logInfo('handleGetScheduleTimePoints 处理完成', {
1777
1733
  menuListIdsCount: menu_list_ids.length,
1778
1734
  menuCount: menuList.length,
@@ -1785,9 +1741,9 @@ var Server = /*#__PURE__*/function () {
1785
1741
  data: timePoints,
1786
1742
  status: true
1787
1743
  });
1788
- case 32:
1789
- _context24.prev = 32;
1790
- _context24.t0 = _context24["catch"](16);
1744
+ case 27:
1745
+ _context24.prev = 27;
1746
+ _context24.t0 = _context24["catch"](15);
1791
1747
  errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : '未知错误';
1792
1748
  console.error('[Server] 获取日程时间点失败:', _context24.t0);
1793
1749
  _this.logError('handleGetScheduleTimePoints: 获取日程时间点失败', {
@@ -1800,21 +1756,20 @@ var Server = /*#__PURE__*/function () {
1800
1756
  data: [],
1801
1757
  status: false
1802
1758
  });
1803
- case 38:
1759
+ case 33:
1804
1760
  case "end":
1805
1761
  return _context24.stop();
1806
1762
  }
1807
- }, _callee24, null, [[16, 32]]);
1763
+ }, _callee24, null, [[15, 27]]);
1808
1764
  }));
1809
1765
  return function (_x24) {
1810
- return _ref59.apply(this, arguments);
1766
+ return _ref57.apply(this, arguments);
1811
1767
  };
1812
1768
  }());
1813
1769
  this.core = core;
1814
1770
  var appPlugin = core.getPlugin('app');
1815
1771
  this.app = (appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp()) || null;
1816
- this.logger = ((_this$app4 = this.app) === null || _this$app4 === void 0 ? void 0 : _this$app4.logger) || null;
1817
- console.log('[Server] Server 初始化', this.core);
1772
+ this.logger = ((_this$app3 = this.app) === null || _this$app3 === void 0 ? void 0 : _this$app3.logger) || null;
1818
1773
  this.logInfo('Server 初始化', {
1819
1774
  hasApp: !!this.app,
1820
1775
  hasLogger: !!this.logger
@@ -1875,7 +1830,6 @@ var Server = /*#__PURE__*/function () {
1875
1830
  });
1876
1831
  }
1877
1832
  _this2.router[method][path] = handler;
1878
- console.log("[Server] \uD83D\uDCDD \u6CE8\u518C\u8DEF\u7531: ".concat(method.toUpperCase(), " ").concat(path));
1879
1833
  _this2.logInfo("\u6CE8\u518C\u8DEF\u7531", {
1880
1834
  method: method.toUpperCase(),
1881
1835
  path: path
@@ -1942,7 +1896,6 @@ var Server = /*#__PURE__*/function () {
1942
1896
  _context25.next = 3;
1943
1897
  return this.core.registerModule(module, options);
1944
1898
  case 3:
1945
- console.log("[Server] \u2705 ".concat(moduleName, " \u6A21\u5757\u5DF2\u6CE8\u518C"));
1946
1899
  this.logInfo("\u6A21\u5757\u6CE8\u518C\u6210\u529F: ".concat(moduleName), {
1947
1900
  moduleName: moduleName
1948
1901
  });
@@ -1958,7 +1911,7 @@ var Server = /*#__PURE__*/function () {
1958
1911
  });
1959
1912
  }
1960
1913
  }
1961
- case 6:
1914
+ case 5:
1962
1915
  case "end":
1963
1916
  return _context25.stop();
1964
1917
  }
@@ -2048,8 +2001,6 @@ var Server = /*#__PURE__*/function () {
2048
2001
  return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2049
2002
  while (1) switch (_context27.prev = _context27.next) {
2050
2003
  case 0:
2051
- console.log('[Server] 开始注册模块...');
2052
-
2053
2004
  // 如果没有指定模块,则注册所有模块
2054
2005
  configs = moduleConfigs || Object.keys(this.moduleRegistry);
2055
2006
  this.logInfo('开始批量注册模块', {
@@ -2058,26 +2009,26 @@ var Server = /*#__PURE__*/function () {
2058
2009
  });
2059
2010
  registeredModules = [];
2060
2011
  _iterator2 = _createForOfIteratorHelper(configs);
2061
- _context27.prev = 5;
2012
+ _context27.prev = 4;
2062
2013
  _iterator2.s();
2063
- case 7:
2014
+ case 6:
2064
2015
  if ((_step2 = _iterator2.n()).done) {
2065
- _context27.next = 25;
2016
+ _context27.next = 24;
2066
2017
  break;
2067
2018
  }
2068
2019
  config = _step2.value;
2069
2020
  configName = typeof config === 'string' ? config : config.name;
2070
- _context27.prev = 10;
2071
- _context27.next = 13;
2021
+ _context27.prev = 9;
2022
+ _context27.next = 12;
2072
2023
  return this.registerModuleByName(config);
2073
- case 13:
2024
+ case 12:
2074
2025
  result = _context27.sent;
2075
2026
  registeredModules.push(result);
2076
- _context27.next = 23;
2027
+ _context27.next = 22;
2077
2028
  break;
2078
- case 17:
2079
- _context27.prev = 17;
2080
- _context27.t0 = _context27["catch"](10);
2029
+ case 16:
2030
+ _context27.prev = 16;
2031
+ _context27.t0 = _context27["catch"](9);
2081
2032
  errorMessage = _context27.t0 instanceof Error ? _context27.t0.message : String(_context27.t0);
2082
2033
  this.logError("\u6A21\u5757\u6CE8\u518C\u5931\u8D25: ".concat(configName), {
2083
2034
  moduleName: configName,
@@ -2085,22 +2036,21 @@ var Server = /*#__PURE__*/function () {
2085
2036
  });
2086
2037
  console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:", _context27.t0);
2087
2038
  throw _context27.t0;
2088
- case 23:
2089
- _context27.next = 7;
2039
+ case 22:
2040
+ _context27.next = 6;
2090
2041
  break;
2091
- case 25:
2092
- _context27.next = 30;
2042
+ case 24:
2043
+ _context27.next = 29;
2093
2044
  break;
2094
- case 27:
2095
- _context27.prev = 27;
2096
- _context27.t1 = _context27["catch"](5);
2045
+ case 26:
2046
+ _context27.prev = 26;
2047
+ _context27.t1 = _context27["catch"](4);
2097
2048
  _iterator2.e(_context27.t1);
2098
- case 30:
2099
- _context27.prev = 30;
2049
+ case 29:
2050
+ _context27.prev = 29;
2100
2051
  _iterator2.f();
2101
- return _context27.finish(30);
2102
- case 33:
2103
- console.log('[Server] ✅ 所有模块注册完成');
2052
+ return _context27.finish(29);
2053
+ case 32:
2104
2054
  this.logInfo('所有模块注册完成', {
2105
2055
  registeredCount: registeredModules.length,
2106
2056
  moduleNames: registeredModules.map(function (m) {
@@ -2109,11 +2059,11 @@ var Server = /*#__PURE__*/function () {
2109
2059
  })
2110
2060
  });
2111
2061
  return _context27.abrupt("return", registeredModules);
2112
- case 36:
2062
+ case 34:
2113
2063
  case "end":
2114
2064
  return _context27.stop();
2115
2065
  }
2116
- }, _callee27, this, [[5, 27, 30, 33], [10, 17]]);
2066
+ }, _callee27, this, [[4, 26, 29, 32], [9, 16]]);
2117
2067
  }));
2118
2068
  function registerModules(_x29) {
2119
2069
  return _registerModules.apply(this, arguments);
@@ -2133,7 +2083,6 @@ var Server = /*#__PURE__*/function () {
2133
2083
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2134
2084
  while (1) switch (_context28.prev = _context28.next) {
2135
2085
  case 0:
2136
- console.log('[Server] 开始预加载模块数据...');
2137
2086
  modulesToPreload = registeredModules.filter(function (m) {
2138
2087
  return m.shouldPreload;
2139
2088
  });
@@ -2144,41 +2093,39 @@ var Server = /*#__PURE__*/function () {
2144
2093
  });
2145
2094
  preloadResults = [];
2146
2095
  _iterator3 = _createForOfIteratorHelper(registeredModules);
2147
- _context28.prev = 5;
2096
+ _context28.prev = 4;
2148
2097
  _iterator3.s();
2149
- case 7:
2098
+ case 6:
2150
2099
  if ((_step3 = _iterator3.n()).done) {
2151
- _context28.next = 40;
2100
+ _context28.next = 36;
2152
2101
  break;
2153
2102
  }
2154
2103
  _step3$value = _step3.value, module = _step3$value.module, config = _step3$value.config, shouldPreload = _step3$value.shouldPreload;
2155
2104
  if (shouldPreload) {
2156
- _context28.next = 13;
2105
+ _context28.next = 11;
2157
2106
  break;
2158
2107
  }
2159
- console.log("[Server] \u23ED\uFE0F \u8DF3\u8FC7 ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D"));
2160
2108
  this.logInfo("\u8DF3\u8FC7\u6A21\u5757\u9884\u52A0\u8F7D: ".concat(config.name), {
2161
2109
  moduleName: config.name,
2162
2110
  reason: 'shouldPreload=false'
2163
2111
  });
2164
- return _context28.abrupt("continue", 38);
2165
- case 13:
2112
+ return _context28.abrupt("continue", 34);
2113
+ case 11:
2166
2114
  if (!(typeof module.preload === 'function')) {
2167
- _context28.next = 36;
2115
+ _context28.next = 33;
2168
2116
  break;
2169
2117
  }
2170
2118
  startTime = Date.now();
2171
- _context28.prev = 15;
2119
+ _context28.prev = 13;
2172
2120
  this.logInfo("\u5F00\u59CB\u9884\u52A0\u8F7D\u6A21\u5757: ".concat(config.name), {
2173
2121
  moduleName: config.name
2174
2122
  });
2175
2123
  options === null || options === void 0 || (_options$onModuleLoad = options.onModuleLoad) === null || _options$onModuleLoad === void 0 || _options$onModuleLoad.call(options, config.name);
2176
- _context28.next = 20;
2124
+ _context28.next = 18;
2177
2125
  return module.preload();
2178
- case 20:
2126
+ case 18:
2179
2127
  options === null || options === void 0 || (_options$onModuleLoad2 = options.onModuleLoadComplete) === null || _options$onModuleLoad2 === void 0 || _options$onModuleLoad2.call(options, config.name);
2180
2128
  duration = Date.now() - startTime;
2181
- console.log("[Server] \u2705 ".concat(config.name, " \u6A21\u5757\u6570\u636E\u5DF2\u9884\u52A0\u8F7D"));
2182
2129
  this.logInfo("\u6A21\u5757\u9884\u52A0\u8F7D\u6210\u529F: ".concat(config.name), {
2183
2130
  moduleName: config.name,
2184
2131
  duration: "".concat(duration, "ms")
@@ -2187,11 +2134,11 @@ var Server = /*#__PURE__*/function () {
2187
2134
  name: config.name,
2188
2135
  success: true
2189
2136
  });
2190
- _context28.next = 34;
2137
+ _context28.next = 31;
2191
2138
  break;
2192
- case 27:
2193
- _context28.prev = 27;
2194
- _context28.t0 = _context28["catch"](15);
2139
+ case 24:
2140
+ _context28.prev = 24;
2141
+ _context28.t0 = _context28["catch"](13);
2195
2142
  _duration = Date.now() - startTime;
2196
2143
  errorMessage = _context28.t0 instanceof Error ? _context28.t0.message : String(_context28.t0);
2197
2144
  console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"), _context28.t0);
@@ -2205,45 +2152,43 @@ var Server = /*#__PURE__*/function () {
2205
2152
  success: false,
2206
2153
  error: errorMessage
2207
2154
  });
2208
- case 34:
2209
- _context28.next = 38;
2155
+ case 31:
2156
+ _context28.next = 34;
2210
2157
  break;
2211
- case 36:
2212
- console.log("[Server] \u26A0\uFE0F ".concat(config.name, " \u6A21\u5757\u672A\u5B9E\u73B0 preload() \u65B9\u6CD5"));
2158
+ case 33:
2213
2159
  this.logWarning("\u6A21\u5757\u672A\u5B9E\u73B0 preload \u65B9\u6CD5: ".concat(config.name), {
2214
2160
  moduleName: config.name
2215
2161
  });
2216
- case 38:
2217
- _context28.next = 7;
2162
+ case 34:
2163
+ _context28.next = 6;
2218
2164
  break;
2219
- case 40:
2220
- _context28.next = 45;
2165
+ case 36:
2166
+ _context28.next = 41;
2221
2167
  break;
2222
- case 42:
2223
- _context28.prev = 42;
2224
- _context28.t1 = _context28["catch"](5);
2168
+ case 38:
2169
+ _context28.prev = 38;
2170
+ _context28.t1 = _context28["catch"](4);
2225
2171
  _iterator3.e(_context28.t1);
2226
- case 45:
2227
- _context28.prev = 45;
2172
+ case 41:
2173
+ _context28.prev = 41;
2228
2174
  _iterator3.f();
2229
- return _context28.finish(45);
2230
- case 48:
2175
+ return _context28.finish(41);
2176
+ case 44:
2231
2177
  successCount = preloadResults.filter(function (r) {
2232
2178
  return r.success;
2233
2179
  }).length;
2234
2180
  failCount = preloadResults.filter(function (r) {
2235
2181
  return !r.success;
2236
2182
  }).length;
2237
- console.log('[Server] ✅ 所有模块数据预加载完成');
2238
2183
  this.logInfo('所有模块预加载完成', {
2239
2184
  successCount: successCount,
2240
2185
  failCount: failCount
2241
2186
  });
2242
- case 52:
2187
+ case 47:
2243
2188
  case "end":
2244
2189
  return _context28.stop();
2245
2190
  }
2246
- }, _callee28, this, [[5, 42, 45, 48], [15, 27]]);
2191
+ }, _callee28, this, [[4, 38, 41, 44], [13, 24]]);
2247
2192
  }));
2248
2193
  function preloadModulesData(_x30, _x31) {
2249
2194
  return _preloadModulesData.apply(this, arguments);
@@ -2380,42 +2325,53 @@ var Server = /*#__PURE__*/function () {
2380
2325
  key: "handleSyncSalesTask",
2381
2326
  value: function () {
2382
2327
  var _handleSyncSalesTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(ctx) {
2383
- var _ctx$task, _this$app5;
2384
- var payload, backendPath, data, title, _ctx$task2, _syncResult$syncedOrd, syncResult, backendError, message, errorMessage;
2328
+ var _ctx$task, _payload$invoice, _payload$template_set, _this$app4;
2329
+ var payload, backendPath, extractedInvoice, extractedTemplateSettings, data, rawInvoiceLayoutConfig, invoiceLayoutConfig, invoiceTemplateSettings, title, _ctx$task2, _syncResult$syncedOrd, syncResult, backendError, message, errorMessage;
2385
2330
  return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2386
2331
  while (1) switch (_context30.prev = _context30.next) {
2387
2332
  case 0:
2388
2333
  payload = ((_ctx$task = ctx.task) === null || _ctx$task === void 0 ? void 0 : _ctx$task.payload) || {};
2389
2334
  backendPath = payload.backendPath;
2390
- data = payload.data;
2335
+ extractedInvoice = this.extractInvoiceLayoutConfig(payload.data, {
2336
+ includePublicInvoice: true
2337
+ });
2338
+ extractedTemplateSettings = this.extractInvoiceTemplateSettings(extractedInvoice.data, {
2339
+ includePublicTemplateSettings: true
2340
+ });
2341
+ data = extractedTemplateSettings.data;
2342
+ rawInvoiceLayoutConfig = (_payload$invoice = payload.invoice) !== null && _payload$invoice !== void 0 ? _payload$invoice : extractedInvoice.invoiceLayoutConfig;
2343
+ invoiceLayoutConfig = rawInvoiceLayoutConfig === undefined || rawInvoiceLayoutConfig === null ? undefined : this.normalizePrintInvoiceLayoutConfig(rawInvoiceLayoutConfig);
2344
+ invoiceTemplateSettings = this.normalizePrintInvoiceTemplateSettings((_payload$template_set = payload.template_settings) !== null && _payload$template_set !== void 0 ? _payload$template_set : extractedTemplateSettings.invoiceTemplateSettings);
2391
2345
  title = payload.title || 'sync_sales';
2392
2346
  if (!(!backendPath || !data)) {
2393
- _context30.next = 6;
2347
+ _context30.next = 11;
2394
2348
  break;
2395
2349
  }
2396
2350
  return _context30.abrupt("return", this.taskFail('INVALID_PAYLOAD', '缺少 backendPath 或 data'));
2397
- case 6:
2398
- if ((_this$app5 = this.app) !== null && _this$app5 !== void 0 && _this$app5.request) {
2399
- _context30.next = 9;
2351
+ case 11:
2352
+ if ((_this$app4 = this.app) !== null && _this$app4 !== void 0 && _this$app4.request) {
2353
+ _context30.next = 14;
2400
2354
  break;
2401
2355
  }
2402
2356
  this.logError("".concat(title, ": sync_sales app.request \u4E0D\u53EF\u7528"));
2403
2357
  return _context30.abrupt("return", this.taskTimeout('app.request 不可用'));
2404
- case 9:
2405
- _context30.prev = 9;
2406
- _context30.next = 12;
2358
+ case 14:
2359
+ _context30.prev = 14;
2360
+ _context30.next = 17;
2407
2361
  return this.runCheckoutSync({
2408
2362
  backendPath: backendPath,
2409
2363
  data: data,
2410
2364
  title: title,
2411
2365
  externalSaleNumber: payload.external_sale_number,
2412
2366
  deviceId: (_ctx$task2 = ctx.task) === null || _ctx$task2 === void 0 ? void 0 : _ctx$task2.device_id,
2413
- persistCheckoutDataWithResponse: false
2367
+ persistCheckoutDataWithResponse: false,
2368
+ invoiceLayoutConfig: invoiceLayoutConfig,
2369
+ invoiceTemplateSettings: invoiceTemplateSettings
2414
2370
  });
2415
- case 12:
2371
+ case 17:
2416
2372
  syncResult = _context30.sent;
2417
2373
  if (!syncResult.rejected) {
2418
- _context30.next = 16;
2374
+ _context30.next = 21;
2419
2375
  break;
2420
2376
  }
2421
2377
  this.logError("".concat(title, ": sync_sales \u540E\u7AEF\u660E\u786E\u5931\u8D25"), {
@@ -2423,17 +2379,17 @@ var Server = /*#__PURE__*/function () {
2423
2379
  response: syncResult.errorResponse
2424
2380
  });
2425
2381
  return _context30.abrupt("return", this.taskFail('BACKEND_REJECTED', syncResult.message || '后端明确拒绝 checkout', syncResult.errorResponse));
2426
- case 16:
2382
+ case 21:
2427
2383
  return _context30.abrupt("return", this.taskOk({
2428
2384
  order: (_syncResult$syncedOrd = syncResult.syncedOrder) !== null && _syncResult$syncedOrd !== void 0 ? _syncResult$syncedOrd : null,
2429
2385
  response: syncResult.normalizedResponse
2430
2386
  }));
2431
- case 19:
2432
- _context30.prev = 19;
2433
- _context30.t0 = _context30["catch"](9);
2387
+ case 24:
2388
+ _context30.prev = 24;
2389
+ _context30.t0 = _context30["catch"](14);
2434
2390
  backendError = this.extractBackendErrorResponse(_context30.t0);
2435
2391
  if (!backendError) {
2436
- _context30.next = 26;
2392
+ _context30.next = 31;
2437
2393
  break;
2438
2394
  }
2439
2395
  message = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || '后端明确拒绝 checkout';
@@ -2442,7 +2398,7 @@ var Server = /*#__PURE__*/function () {
2442
2398
  backendError: backendError
2443
2399
  });
2444
2400
  return _context30.abrupt("return", this.taskFail('BACKEND_REJECTED', message, backendError));
2445
- case 26:
2401
+ case 31:
2446
2402
  errorMessage = this.getUnknownErrorMessage(_context30.t0);
2447
2403
  this.logError("".concat(title, ": sync_sales \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
2448
2404
  backendPath: backendPath,
@@ -2450,11 +2406,11 @@ var Server = /*#__PURE__*/function () {
2450
2406
  error_detail: this.normalizeUnknownError(_context30.t0)
2451
2407
  });
2452
2408
  return _context30.abrupt("return", this.taskTimeout(errorMessage));
2453
- case 29:
2409
+ case 34:
2454
2410
  case "end":
2455
2411
  return _context30.stop();
2456
2412
  }
2457
- }, _callee30, this, [[9, 19]]);
2413
+ }, _callee30, this, [[14, 24]]);
2458
2414
  }));
2459
2415
  function handleSyncSalesTask(_x33) {
2460
2416
  return _handleSyncSalesTask.apply(this, arguments);
@@ -2465,8 +2421,8 @@ var Server = /*#__PURE__*/function () {
2465
2421
  key: "runCheckoutSync",
2466
2422
  value: function () {
2467
2423
  var _runCheckoutSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2468
- var _this$app6;
2469
- var backendPath, title, normalizedData, checkoutData, remoteCheckoutData, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
2424
+ var _this$app5;
2425
+ var backendPath, title, normalizedData, numberedData, checkoutData, remoteCheckoutData, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
2470
2426
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2471
2427
  while (1) switch (_context31.prev = _context31.next) {
2472
2428
  case 0:
@@ -2478,23 +2434,24 @@ var Server = /*#__PURE__*/function () {
2478
2434
  _context31.next = 6;
2479
2435
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
2480
2436
  case 6:
2481
- checkoutData = _context31.sent;
2437
+ numberedData = _context31.sent;
2438
+ checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
2482
2439
  remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
2483
- if ((_this$app6 = this.app) !== null && _this$app6 !== void 0 && (_this$app6 = _this$app6.request) !== null && _this$app6 !== void 0 && _this$app6.post) {
2484
- _context31.next = 10;
2440
+ if ((_this$app5 = this.app) !== null && _this$app5 !== void 0 && (_this$app5 = _this$app5.request) !== null && _this$app5 !== void 0 && _this$app5.post) {
2441
+ _context31.next = 11;
2485
2442
  break;
2486
2443
  }
2487
2444
  throw new Error('app.request 不可用');
2488
- case 10:
2489
- _context31.next = 12;
2445
+ case 11:
2446
+ _context31.next = 13;
2490
2447
  return this.app.request.post(backendPath, remoteCheckoutData, {
2491
2448
  isShopApi: true,
2492
2449
  customToast: function customToast() {}
2493
2450
  });
2494
- case 12:
2451
+ case 13:
2495
2452
  response = _context31.sent;
2496
2453
  if (!this.isCheckoutResponseRejected(response)) {
2497
- _context31.next = 15;
2454
+ _context31.next = 16;
2498
2455
  break;
2499
2456
  }
2500
2457
  return _context31.abrupt("return", {
@@ -2505,13 +2462,13 @@ var Server = /*#__PURE__*/function () {
2505
2462
  normalizedResponse: this.normalizeCheckoutResponse(response),
2506
2463
  checkoutData: checkoutData
2507
2464
  });
2508
- case 15:
2465
+ case 16:
2509
2466
  fresh = this.extractOrderDataFromCheckoutResponse(response);
2510
2467
  externalSaleNumber = this.getCheckoutExternalSaleNumber(checkoutData, {
2511
2468
  external_sale_number: params.externalSaleNumber,
2512
2469
  data: checkoutData
2513
2470
  });
2514
- _context31.next = 19;
2471
+ _context31.next = 20;
2515
2472
  return this.persistSyncedCheckoutOrder({
2516
2473
  backendPath: backendPath,
2517
2474
  checkoutData: checkoutData,
@@ -2520,7 +2477,7 @@ var Server = /*#__PURE__*/function () {
2520
2477
  title: title,
2521
2478
  persistCheckoutDataWithResponse: params.persistCheckoutDataWithResponse === true
2522
2479
  });
2523
- case 19:
2480
+ case 20:
2524
2481
  syncedOrder = _context31.sent;
2525
2482
  printableSyncedOrder = syncedOrder ? this.buildSyncedOrderForPrint({
2526
2483
  syncedOrder: syncedOrder,
@@ -2530,17 +2487,19 @@ var Server = /*#__PURE__*/function () {
2530
2487
  checkoutData: checkoutData,
2531
2488
  syncedOrder: printableSyncedOrder
2532
2489
  }))) {
2533
- _context31.next = 24;
2490
+ _context31.next = 25;
2534
2491
  break;
2535
2492
  }
2536
- _context31.next = 24;
2493
+ _context31.next = 25;
2537
2494
  return this.dispatchPrintOtherReceiptTask({
2538
2495
  checkoutData: checkoutData,
2539
2496
  syncedOrder: printableSyncedOrder,
2540
2497
  response: response,
2541
- deviceId: params.deviceId
2498
+ deviceId: params.deviceId,
2499
+ invoiceLayoutConfig: params.invoiceLayoutConfig,
2500
+ invoiceTemplateSettings: params.invoiceTemplateSettings
2542
2501
  });
2543
- case 24:
2502
+ case 25:
2544
2503
  return _context31.abrupt("return", {
2545
2504
  rejected: false,
2546
2505
  response: response,
@@ -2549,7 +2508,7 @@ var Server = /*#__PURE__*/function () {
2549
2508
  syncedOrder: syncedOrder,
2550
2509
  fresh: fresh
2551
2510
  });
2552
- case 25:
2511
+ case 26:
2553
2512
  case "end":
2554
2513
  return _context31.stop();
2555
2514
  }
@@ -2575,6 +2534,8 @@ var Server = /*#__PURE__*/function () {
2575
2534
  var next = cloneDeep(this.omitCheckoutSyncMode(data));
2576
2535
  if (!next || _typeof(next) !== 'object') return next;
2577
2536
  var record = next;
2537
+ delete record[OS_FULFILLMENT_REF_MODE_FIELD];
2538
+ delete record[OS_INVOICE_LAYOUT_CONFIG_FIELD];
2578
2539
  if (!Array.isArray(record.payments)) return next;
2579
2540
  var originalPayments = record.payments;
2580
2541
  var filteredPayments = originalPayments.filter(function (payment) {
@@ -2634,7 +2595,7 @@ var Server = /*#__PURE__*/function () {
2634
2595
  key: "persistSyncedCheckoutOrder",
2635
2596
  value: function () {
2636
2597
  var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
2637
- var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder, _external_sale_number2, _external_sale_number3, _syncedOrder$order_id, _syncedOrder, patch, result;
2598
+ var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder, _external_sale_number, _external_sale_number2, _syncedOrder$order_id, _syncedOrder, patch, result;
2638
2599
  return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2639
2600
  while (1) switch (_context32.prev = _context32.next) {
2640
2601
  case 0:
@@ -2645,11 +2606,11 @@ var Server = /*#__PURE__*/function () {
2645
2606
  break;
2646
2607
  }
2647
2608
  syncedOrder = persistCheckoutDataWithResponse ? _objectSpread(_objectSpread(_objectSpread({}, checkoutData), this.mergeCheckoutSyncPayments(checkoutData, fresh, title)), {}, {
2648
- external_sale_number: (_external_sale_number2 = fresh.external_sale_number) !== null && _external_sale_number2 !== void 0 ? _external_sale_number2 : externalSaleNumber,
2609
+ external_sale_number: (_external_sale_number = fresh.external_sale_number) !== null && _external_sale_number !== void 0 ? _external_sale_number : externalSaleNumber,
2649
2610
  need_sync: 0,
2650
2611
  is_draft_order: 0
2651
2612
  }) : _objectSpread(_objectSpread({}, this.mergeCheckoutSyncPayments(checkoutData, fresh, title)), {}, {
2652
- external_sale_number: (_external_sale_number3 = fresh.external_sale_number) !== null && _external_sale_number3 !== void 0 ? _external_sale_number3 : externalSaleNumber,
2613
+ external_sale_number: (_external_sale_number2 = fresh.external_sale_number) !== null && _external_sale_number2 !== void 0 ? _external_sale_number2 : externalSaleNumber,
2653
2614
  need_sync: 0,
2654
2615
  is_draft_order: 0
2655
2616
  });
@@ -3022,7 +2983,6 @@ var Server = /*#__PURE__*/function () {
3022
2983
  return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3023
2984
  while (1) switch (_context37.prev = _context37.next) {
3024
2985
  case 0:
3025
- console.log('[Server] 开始清空所有模块的IndexedDB缓存...');
3026
2986
  this.logInfo('开始清空所有模块的 IndexedDB 缓存');
3027
2987
  clearTasks = [];
3028
2988
  moduleNames = []; // 收集所有模块的清空任务
@@ -3055,29 +3015,28 @@ var Server = /*#__PURE__*/function () {
3055
3015
  moduleNames.push('FloorPlan');
3056
3016
  }
3057
3017
  if (!(clearTasks.length === 0)) {
3058
- _context37.next = 15;
3018
+ _context37.next = 14;
3059
3019
  break;
3060
3020
  }
3061
3021
  console.warn('[Server] 没有找到已注册的模块,无需清空');
3062
3022
  this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
3063
3023
  return _context37.abrupt("return");
3064
- case 15:
3024
+ case 14:
3065
3025
  this.logInfo('准备清空模块缓存', {
3066
3026
  moduleNames: moduleNames
3067
3027
  });
3068
- _context37.prev = 16;
3069
- _context37.next = 19;
3028
+ _context37.prev = 15;
3029
+ _context37.next = 18;
3070
3030
  return Promise.all(clearTasks);
3071
- case 19:
3072
- console.log("[Server] \u2705 \u5DF2\u6210\u529F\u6E05\u7A7A\u6240\u6709\u6A21\u5757\u7684IndexedDB\u7F13\u5B58: ".concat(moduleNames.join(', ')));
3031
+ case 18:
3073
3032
  this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
3074
3033
  moduleNames: moduleNames
3075
3034
  });
3076
- _context37.next = 29;
3035
+ _context37.next = 27;
3077
3036
  break;
3078
- case 23:
3079
- _context37.prev = 23;
3080
- _context37.t0 = _context37["catch"](16);
3037
+ case 21:
3038
+ _context37.prev = 21;
3039
+ _context37.t0 = _context37["catch"](15);
3081
3040
  errorMessage = _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0);
3082
3041
  console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context37.t0);
3083
3042
  this.logError('清空 IndexedDB 缓存时发生错误', {
@@ -3085,11 +3044,11 @@ var Server = /*#__PURE__*/function () {
3085
3044
  error: errorMessage
3086
3045
  });
3087
3046
  throw _context37.t0;
3088
- case 29:
3047
+ case 27:
3089
3048
  case "end":
3090
3049
  return _context37.stop();
3091
3050
  }
3092
- }, _callee37, this, [[16, 23]]);
3051
+ }, _callee37, this, [[15, 21]]);
3093
3052
  }));
3094
3053
  function clearAllIndexDB() {
3095
3054
  return _clearAllIndexDB.apply(this, arguments);
@@ -3256,7 +3215,6 @@ var Server = /*#__PURE__*/function () {
3256
3215
  }, {
3257
3216
  key: "registerServerRoutes",
3258
3217
  value: function registerServerRoutes() {
3259
- console.log('[Server] 注册 Server 层业务路由...');
3260
3218
  this.registerRoutes([{
3261
3219
  method: 'post',
3262
3220
  path: '/shop/product/query',
@@ -3429,12 +3387,12 @@ var Server = /*#__PURE__*/function () {
3429
3387
  key: "fetchQuotationAvailableFromAPI",
3430
3388
  value: function () {
3431
3389
  var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data) {
3432
- var _this$app7;
3390
+ var _this$app6;
3433
3391
  var requester;
3434
3392
  return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3435
3393
  while (1) switch (_context41.prev = _context41.next) {
3436
3394
  case 0:
3437
- requester = ((_this$app7 = this.app) === null || _this$app7 === void 0 ? void 0 : _this$app7.request) || this.core.getPlugin('request');
3395
+ requester = ((_this$app6 = this.app) === null || _this$app6 === void 0 ? void 0 : _this$app6.request) || this.core.getPlugin('request');
3438
3396
  if (requester !== null && requester !== void 0 && requester.get) {
3439
3397
  _context41.next = 4;
3440
3398
  break;
@@ -3731,11 +3689,11 @@ var Server = /*#__PURE__*/function () {
3731
3689
  */
3732
3690
  }, {
3733
3691
  key: "syncProductQueryScheduleTimers",
3734
- value: function syncProductQueryScheduleTimers(_ref61) {
3692
+ value: function syncProductQueryScheduleTimers(_ref59) {
3735
3693
  var _this$products$getLas3, _this$products2, _this$products2$getLa;
3736
- var subscriberId = _ref61.subscriberId,
3737
- menu_list_ids = _ref61.menu_list_ids,
3738
- strategy_context = _ref61.strategy_context;
3694
+ var subscriberId = _ref59.subscriberId,
3695
+ menu_list_ids = _ref59.menu_list_ids,
3696
+ strategy_context = _ref59.strategy_context;
3739
3697
  this.clearSubscriberScheduleTimers(subscriberId);
3740
3698
  if (!this.shouldScheduleProductQueryReload(strategy_context)) {
3741
3699
  return;
@@ -3834,7 +3792,7 @@ var Server = /*#__PURE__*/function () {
3834
3792
  */
3835
3793
  function () {
3836
3794
  var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(kind, backendPath, data, config) {
3837
- var queryPayload, result, _ref62, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3795
+ var queryPayload, result, _ref60, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
3838
3796
  return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3839
3797
  while (1) switch (_context45.prev = _context45.next) {
3840
3798
  case 0:
@@ -3843,7 +3801,7 @@ var Server = /*#__PURE__*/function () {
3843
3801
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
3844
3802
  case 3:
3845
3803
  result = _context45.sent;
3846
- _ref62 = config || {}, callback = _ref62.callback, subscriberId = _ref62.subscriberId, resetVisibleOrderIds = _ref62.resetVisibleOrderIds;
3804
+ _ref60 = config || {}, callback = _ref60.callback, subscriberId = _ref60.subscriberId, resetVisibleOrderIds = _ref60.resetVisibleOrderIds;
3847
3805
  if (subscriberId && typeof callback === 'function') {
3848
3806
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
3849
3807
  existing = this.salesSearchSubscribers.get(subscriberId);
@@ -3897,12 +3855,12 @@ var Server = /*#__PURE__*/function () {
3897
3855
  key: "fetchSalesSearchFromAPI",
3898
3856
  value: (function () {
3899
3857
  var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(backendPath, data) {
3900
- var _this$app8;
3901
- var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
3858
+ var _this$app7;
3859
+ var _response$data3, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
3902
3860
  return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3903
3861
  while (1) switch (_context46.prev = _context46.next) {
3904
3862
  case 0:
3905
- if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
3863
+ if ((_this$app7 = this.app) !== null && _this$app7 !== void 0 && _this$app7.request) {
3906
3864
  _context46.next = 3;
3907
3865
  break;
3908
3866
  }
@@ -3928,7 +3886,7 @@ var Server = /*#__PURE__*/function () {
3928
3886
  });
3929
3887
  case 6:
3930
3888
  response = _context46.sent;
3931
- _payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
3889
+ _payload = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
3932
3890
  return _context46.abrupt("return", {
3933
3891
  code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
3934
3892
  status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
@@ -4482,12 +4440,12 @@ var Server = /*#__PURE__*/function () {
4482
4440
  key: "fetchOrderListFromAPI",
4483
4441
  value: (function () {
4484
4442
  var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(data) {
4485
- var _this$app9;
4486
- var _response$data5, response, _payload2, list, count, errorMessage;
4443
+ var _this$app8;
4444
+ var _response$data4, response, _payload2, list, count, errorMessage;
4487
4445
  return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4488
4446
  while (1) switch (_context47.prev = _context47.next) {
4489
4447
  case 0:
4490
- if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
4448
+ if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
4491
4449
  _context47.next = 3;
4492
4450
  break;
4493
4451
  }
@@ -4509,7 +4467,7 @@ var Server = /*#__PURE__*/function () {
4509
4467
  });
4510
4468
  case 6:
4511
4469
  response = _context47.sent;
4512
- _payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
4470
+ _payload2 = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
4513
4471
  list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
4514
4472
  count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
4515
4473
  return _context47.abrupt("return", {
@@ -4684,11 +4642,11 @@ var Server = /*#__PURE__*/function () {
4684
4642
  }, {
4685
4643
  key: "buildLocalPaymentOrderLogContext",
4686
4644
  value: function buildLocalPaymentOrderLogContext(order) {
4687
- var _order$order_id2, _external_sale_number4, _order_number, _shop_order_number, _shop_full_order_numb, _status, _payment_status, _platform, _business_code, _order_sales_channel, _sales_channel, _type;
4645
+ var _order$order_id2, _external_sale_number3, _order_number, _shop_order_number, _shop_full_order_numb, _status, _payment_status, _platform, _business_code, _order_sales_channel, _sales_channel, _type;
4688
4646
  if (!order) return {};
4689
4647
  return {
4690
4648
  order_id: (_order$order_id2 = order.order_id) !== null && _order$order_id2 !== void 0 ? _order$order_id2 : null,
4691
- external_sale_number: (_external_sale_number4 = order.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : null,
4649
+ external_sale_number: (_external_sale_number3 = order.external_sale_number) !== null && _external_sale_number3 !== void 0 ? _external_sale_number3 : null,
4692
4650
  order_number: (_order_number = order.order_number) !== null && _order_number !== void 0 ? _order_number : null,
4693
4651
  shop_order_number: (_shop_order_number = order.shop_order_number) !== null && _shop_order_number !== void 0 ? _shop_order_number : null,
4694
4652
  shop_full_order_number: (_shop_full_order_numb = order.shop_full_order_number) !== null && _shop_full_order_numb !== void 0 ? _shop_full_order_numb : null,
@@ -5222,24 +5180,24 @@ var Server = /*#__PURE__*/function () {
5222
5180
  }, {
5223
5181
  key: "getDeviceTaskPlugin",
5224
5182
  value: function getDeviceTaskPlugin() {
5225
- var _this$app10, _this$app10$getPlugin;
5226
- return ((_this$app10 = this.app) === null || _this$app10 === void 0 || (_this$app10$getPlugin = _this$app10.getPlugin) === null || _this$app10$getPlugin === void 0 ? void 0 : _this$app10$getPlugin.call(_this$app10, 'deviceTask')) || null;
5183
+ var _this$app9, _this$app9$getPlugin;
5184
+ return ((_this$app9 = this.app) === null || _this$app9 === void 0 || (_this$app9$getPlugin = _this$app9.getPlugin) === null || _this$app9$getPlugin === void 0 ? void 0 : _this$app9$getPlugin.call(_this$app9, 'deviceTask')) || null;
5227
5185
  }
5228
5186
  }, {
5229
5187
  key: "getIdGeneratorPlugin",
5230
5188
  value: function getIdGeneratorPlugin() {
5231
- var _this$app11, _this$app11$getPlugin;
5232
- return ((_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11$getPlugin = _this$app11.getPlugin) === null || _this$app11$getPlugin === void 0 ? void 0 : _this$app11$getPlugin.call(_this$app11, 'idGenerator')) || null;
5189
+ var _this$app10, _this$app10$getPlugin;
5190
+ return ((_this$app10 = this.app) === null || _this$app10 === void 0 || (_this$app10$getPlugin = _this$app10.getPlugin) === null || _this$app10$getPlugin === void 0 ? void 0 : _this$app10$getPlugin.call(_this$app10, 'idGenerator')) || null;
5233
5191
  }
5234
5192
  }, {
5235
5193
  key: "getAppData",
5236
5194
  value: function getAppData(key) {
5237
- var _this$core$getPlugin, _this$core$getPlugin$, _this$app12, _this$app12$getData, _this$app13, _this$app13$getStore, _this$app13$getStore$, _this$app13$getStore$2, _this$app14, _this$app14$getStore, _this$app14$getStore$, _this$app14$getStore$2, _this$app15, _this$app15$getStore, _this$app15$getStore$, _this$app15$getStore$2;
5195
+ var _this$core$getPlugin, _this$core$getPlugin$, _this$app11, _this$app11$getData, _this$app12, _this$app12$getStore, _this$app12$getStore$, _this$app12$getStore$2, _this$app13, _this$app13$getStore, _this$app13$getStore$, _this$app13$getStore$2, _this$app14, _this$app14$getStore, _this$app14$getStore$, _this$app14$getStore$2;
5238
5196
  var getData = (_this$core$getPlugin = this.core.getPlugin('app')) === null || _this$core$getPlugin === void 0 || (_this$core$getPlugin$ = _this$core$getPlugin.getData) === null || _this$core$getPlugin$ === void 0 ? void 0 : _this$core$getPlugin$.call(_this$core$getPlugin);
5239
5197
  if (typeof getData === 'function') return getData(key);
5240
- var directValue = (_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12$getData = _this$app12.getData) === null || _this$app12$getData === void 0 ? void 0 : _this$app12$getData.call(_this$app12, key);
5198
+ var directValue = (_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11$getData = _this$app11.getData) === null || _this$app11$getData === void 0 ? void 0 : _this$app11$getData.call(_this$app11, key);
5241
5199
  if (directValue !== undefined) return directValue;
5242
- var coreData = ((_this$app13 = this.app) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.models) === null || _this$app13 === void 0 || (_this$app13$getStore = _this$app13.getStore) === null || _this$app13$getStore === void 0 || (_this$app13$getStore$ = (_this$app13$getStore$2 = _this$app13$getStore.call(_this$app13)).getDataByModel) === null || _this$app13$getStore$ === void 0 ? void 0 : _this$app13$getStore$.call(_this$app13$getStore$2, 'core', 'core')) || ((_this$app14 = this.app) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.data) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.store) === null || _this$app14 === void 0 || (_this$app14$getStore = _this$app14.getStore) === null || _this$app14$getStore === void 0 || (_this$app14$getStore$ = (_this$app14$getStore$2 = _this$app14$getStore.call(_this$app14)).getDataByModel) === null || _this$app14$getStore$ === void 0 ? void 0 : _this$app14$getStore$.call(_this$app14$getStore$2, 'core', 'core')) || ((_this$app15 = this.app) === null || _this$app15 === void 0 || (_this$app15 = _this$app15.data) === null || _this$app15 === void 0 || (_this$app15 = _this$app15.store) === null || _this$app15 === void 0 || (_this$app15$getStore = _this$app15.getStore) === null || _this$app15$getStore === void 0 || (_this$app15$getStore$ = (_this$app15$getStore$2 = _this$app15$getStore.call(_this$app15)).getDataByModel) === null || _this$app15$getStore$ === void 0 || (_this$app15$getStore$ = _this$app15$getStore$.call(_this$app15$getStore$2, 'core')) === null || _this$app15$getStore$ === void 0 ? void 0 : _this$app15$getStore$.core);
5200
+ var coreData = ((_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.models) === null || _this$app12 === void 0 || (_this$app12$getStore = _this$app12.getStore) === null || _this$app12$getStore === void 0 || (_this$app12$getStore$ = (_this$app12$getStore$2 = _this$app12$getStore.call(_this$app12)).getDataByModel) === null || _this$app12$getStore$ === void 0 ? void 0 : _this$app12$getStore$.call(_this$app12$getStore$2, 'core', 'core')) || ((_this$app13 = this.app) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.data) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.store) === null || _this$app13 === void 0 || (_this$app13$getStore = _this$app13.getStore) === null || _this$app13$getStore === void 0 || (_this$app13$getStore$ = (_this$app13$getStore$2 = _this$app13$getStore.call(_this$app13)).getDataByModel) === null || _this$app13$getStore$ === void 0 ? void 0 : _this$app13$getStore$.call(_this$app13$getStore$2, 'core', 'core')) || ((_this$app14 = this.app) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.data) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.store) === null || _this$app14 === void 0 || (_this$app14$getStore = _this$app14.getStore) === null || _this$app14$getStore === void 0 || (_this$app14$getStore$ = (_this$app14$getStore$2 = _this$app14$getStore.call(_this$app14)).getDataByModel) === null || _this$app14$getStore$ === void 0 || (_this$app14$getStore$ = _this$app14$getStore$.call(_this$app14$getStore$2, 'core')) === null || _this$app14$getStore$ === void 0 ? void 0 : _this$app14$getStore$.core);
5243
5201
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
5244
5202
  }
5245
5203
  }, {
@@ -5340,35 +5298,202 @@ var Server = /*#__PURE__*/function () {
5340
5298
  return typeof orderId === 'string' && orderId.startsWith('LOCAL_');
5341
5299
  }
5342
5300
  }, {
5343
- key: "normalizeCheckoutSubmitData",
5344
- value: function () {
5345
- var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data, title) {
5346
- var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
5347
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5348
- while (1) switch (_context54.prev = _context54.next) {
5349
- case 0:
5350
- if (!(!data || _typeof(data) !== 'object')) {
5351
- _context54.next = 2;
5352
- break;
5353
- }
5354
- return _context54.abrupt("return", data);
5355
- case 2:
5356
- next = _objectSpread({}, data);
5357
- externalSaleNumber = next.external_sale_number;
5358
- shouldClearLocalOrderId = this.isLocalCheckoutOrderId(next.order_id);
5359
- if (shouldClearLocalOrderId) next.order_id = null;
5360
- // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
5361
- delete next.vouchers;
5362
- hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
5363
- if (!hasCheckoutOrderNumbers) {
5364
- _context54.next = 11;
5365
- break;
5366
- }
5367
- this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
5368
- original_order_id: data.order_id,
5369
- order_id: next.order_id,
5370
- external_sale_number: externalSaleNumber,
5371
- shop_order_number: next.shop_order_number,
5301
+ key: "normalizePrintInvoiceLayoutConfig",
5302
+ value: function normalizePrintInvoiceLayoutConfig(value) {
5303
+ if (value === undefined || value === null) {
5304
+ return getDefaultInvoiceLayoutConfig();
5305
+ }
5306
+ var parsed = value;
5307
+ if (typeof parsed === 'string') {
5308
+ try {
5309
+ parsed = JSON.parse(parsed);
5310
+ } catch (_unused2) {
5311
+ return getDefaultInvoiceLayoutConfig();
5312
+ }
5313
+ }
5314
+ if (!parsed || _typeof(parsed) !== 'object' || Array.isArray(parsed)) {
5315
+ return getDefaultInvoiceLayoutConfig();
5316
+ }
5317
+ var record = parsed;
5318
+ if (!Array.isArray(record.module)) {
5319
+ return getDefaultInvoiceLayoutConfig();
5320
+ }
5321
+ return _objectSpread(_objectSpread({}, typeof record.locale === 'string' ? {
5322
+ locale: record.locale
5323
+ } : {}), {}, {
5324
+ module: record.module.map(function (moduleConfig) {
5325
+ return moduleConfig && _typeof(moduleConfig) === 'object' && !Array.isArray(moduleConfig) ? _objectSpread({}, moduleConfig) : moduleConfig;
5326
+ })
5327
+ });
5328
+ }
5329
+ }, {
5330
+ key: "extractInvoiceLayoutConfig",
5331
+ value: function extractInvoiceLayoutConfig(data, options) {
5332
+ var _record$invoice;
5333
+ if (!data || _typeof(data) !== 'object' || Array.isArray(data)) {
5334
+ return {
5335
+ data: data
5336
+ };
5337
+ }
5338
+ var record = data;
5339
+ var rawInvoiceLayoutConfig = options !== null && options !== void 0 && options.includePublicInvoice ? (_record$invoice = record.invoice) !== null && _record$invoice !== void 0 ? _record$invoice : record[OS_INVOICE_LAYOUT_CONFIG_FIELD] : record[OS_INVOICE_LAYOUT_CONFIG_FIELD];
5340
+ var next = _objectSpread({}, record);
5341
+ delete next[OS_INVOICE_LAYOUT_CONFIG_FIELD];
5342
+ if (options !== null && options !== void 0 && options.includePublicInvoice) delete next.invoice;
5343
+ return _objectSpread({
5344
+ data: next
5345
+ }, rawInvoiceLayoutConfig !== undefined && rawInvoiceLayoutConfig !== null ? {
5346
+ invoiceLayoutConfig: this.normalizePrintInvoiceLayoutConfig(rawInvoiceLayoutConfig)
5347
+ } : {});
5348
+ }
5349
+ }, {
5350
+ key: "normalizePrintInvoiceTemplateSettings",
5351
+ value: function normalizePrintInvoiceTemplateSettings(value) {
5352
+ if (value === undefined || value === null) {
5353
+ return getDefaultInvoiceTemplateSettings();
5354
+ }
5355
+ return normalizeRawInvoiceTemplateSettings(value);
5356
+ }
5357
+ }, {
5358
+ key: "extractInvoiceTemplateSettings",
5359
+ value: function extractInvoiceTemplateSettings(data, options) {
5360
+ var _record$template_sett;
5361
+ if (!data || _typeof(data) !== 'object' || Array.isArray(data)) {
5362
+ return {
5363
+ data: data
5364
+ };
5365
+ }
5366
+ var record = data;
5367
+ var rawInvoiceTemplateSettings = options !== null && options !== void 0 && options.includePublicTemplateSettings ? (_record$template_sett = record.template_settings) !== null && _record$template_sett !== void 0 ? _record$template_sett : record[OS_INVOICE_TEMPLATE_SETTINGS_FIELD] : record[OS_INVOICE_TEMPLATE_SETTINGS_FIELD];
5368
+ var next = _objectSpread({}, record);
5369
+ delete next[OS_INVOICE_TEMPLATE_SETTINGS_FIELD];
5370
+ if (options !== null && options !== void 0 && options.includePublicTemplateSettings) delete next.template_settings;
5371
+ return _objectSpread({
5372
+ data: next
5373
+ }, rawInvoiceTemplateSettings !== undefined && rawInvoiceTemplateSettings !== null ? {
5374
+ invoiceTemplateSettings: this.normalizePrintInvoiceTemplateSettings(rawInvoiceTemplateSettings)
5375
+ } : {});
5376
+ }
5377
+ }, {
5378
+ key: "applyCheckoutFulfillmentBuzzer",
5379
+ value: function applyCheckoutFulfillmentBuzzer(data, title) {
5380
+ if (!data || _typeof(data) !== 'object') return data;
5381
+ var next = _objectSpread({}, data);
5382
+ var refMode = String(next[OS_FULFILLMENT_REF_MODE_FIELD] || '').trim();
5383
+ delete next[OS_FULFILLMENT_REF_MODE_FIELD];
5384
+ if (!refMode) return next;
5385
+ if (refMode === 'manual_input') {
5386
+ this.logInfo("".concat(title, ": fulfillment ref mode \u4FDD\u7559\u624B\u52A8 buzzer"), {
5387
+ fulfillment_ref_mode: refMode,
5388
+ has_buzzer: !this.isBlankCheckoutValue(next.buzzer)
5389
+ });
5390
+ return next;
5391
+ }
5392
+ if (refMode === 'resource_identifier') {
5393
+ next.buzzer = this.buildCheckoutResourceIdentifierBuzzer(next.bookings);
5394
+ } else if (refMode === 'sale_number') {
5395
+ next.buzzer = this.isBlankCheckoutValue(next.shop_order_number) ? '' : String(next.shop_order_number);
5396
+ } else if (refMode === 'short_number') {
5397
+ next.buzzer = this.isBlankCheckoutValue(next.shop_full_order_number) ? '' : String(next.shop_full_order_number);
5398
+ } else {
5399
+ this.logWarning("".concat(title, ": \u672A\u8BC6\u522B\u7684 fulfillment ref mode\uFF0C\u8DF3\u8FC7 buzzer \u81EA\u52A8\u586B\u5145"), {
5400
+ fulfillment_ref_mode: refMode
5401
+ });
5402
+ return next;
5403
+ }
5404
+ this.logInfo("".concat(title, ": fulfillment ref mode \u5DF2\u586B\u5145 buzzer"), {
5405
+ fulfillment_ref_mode: refMode,
5406
+ buzzer: next.buzzer
5407
+ });
5408
+ return next;
5409
+ }
5410
+ }, {
5411
+ key: "buildCheckoutResourceIdentifierBuzzer",
5412
+ value: function buildCheckoutResourceIdentifierBuzzer(bookings) {
5413
+ var _this13 = this;
5414
+ if (!Array.isArray(bookings)) return '';
5415
+ var values = [];
5416
+ var seen = new Set();
5417
+ var visitResource = function visitResource(resource, fallbackName) {
5418
+ var identifier = _this13.getCheckoutResourceIdentifier(resource, fallbackName);
5419
+ if (identifier && !seen.has(identifier)) {
5420
+ seen.add(identifier);
5421
+ values.push(identifier);
5422
+ }
5423
+ if (Array.isArray(resource === null || resource === void 0 ? void 0 : resource.children)) {
5424
+ resource.children.forEach(function (child) {
5425
+ return visitResource(child);
5426
+ });
5427
+ }
5428
+ };
5429
+ bookings.forEach(function (booking) {
5430
+ if (Array.isArray(booking === null || booking === void 0 ? void 0 : booking.resources)) {
5431
+ booking.resources.forEach(function (resource, index) {
5432
+ visitResource(resource, index === 0 ? booking === null || booking === void 0 ? void 0 : booking.relation_form_name : undefined);
5433
+ });
5434
+ }
5435
+ });
5436
+ return values.join(',');
5437
+ }
5438
+ }, {
5439
+ key: "getCheckoutResourceIdentifier",
5440
+ value: function getCheckoutResourceIdentifier(resource, fallbackName) {
5441
+ var _resource$metadata, _resource$metadata2;
5442
+ if (!resource || _typeof(resource) !== 'object') return '';
5443
+ var candidates = [resource.main_field, resource.name, resource.title, (_resource$metadata = resource.metadata) === null || _resource$metadata === void 0 ? void 0 : _resource$metadata.resource_name, (_resource$metadata2 = resource.metadata) === null || _resource$metadata2 === void 0 ? void 0 : _resource$metadata2.name, fallbackName, resource.relation_id, resource.id];
5444
+ for (var _i2 = 0, _candidates = candidates; _i2 < _candidates.length; _i2++) {
5445
+ var candidate = _candidates[_i2];
5446
+ var value = this.stringifyCheckoutResourceIdentifier(candidate);
5447
+ if (value) return value;
5448
+ }
5449
+ return '';
5450
+ }
5451
+ }, {
5452
+ key: "stringifyCheckoutResourceIdentifier",
5453
+ value: function stringifyCheckoutResourceIdentifier(value) {
5454
+ if (value === undefined || value === null) return '';
5455
+ if (typeof value === 'string' || typeof value === 'number') {
5456
+ return String(value).trim();
5457
+ }
5458
+ if (_typeof(value) !== 'object' || Array.isArray(value)) return '';
5459
+ var localeCandidates = [value.original, value.auto, value.en, value['zh-CN'], value.zh_CN, value['zh-HK'], value.zh_HK];
5460
+ for (var _i3 = 0, _localeCandidates = localeCandidates; _i3 < _localeCandidates.length; _i3++) {
5461
+ var candidate = _localeCandidates[_i3];
5462
+ var normalized = this.stringifyCheckoutResourceIdentifier(candidate);
5463
+ if (normalized) return normalized;
5464
+ }
5465
+ return '';
5466
+ }
5467
+ }, {
5468
+ key: "normalizeCheckoutSubmitData",
5469
+ value: function () {
5470
+ var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data, title) {
5471
+ var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
5472
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5473
+ while (1) switch (_context54.prev = _context54.next) {
5474
+ case 0:
5475
+ if (!(!data || _typeof(data) !== 'object')) {
5476
+ _context54.next = 2;
5477
+ break;
5478
+ }
5479
+ return _context54.abrupt("return", data);
5480
+ case 2:
5481
+ next = _objectSpread({}, data);
5482
+ externalSaleNumber = next.external_sale_number;
5483
+ shouldClearLocalOrderId = this.isLocalCheckoutOrderId(next.order_id);
5484
+ if (shouldClearLocalOrderId) next.order_id = null;
5485
+ // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
5486
+ delete next.vouchers;
5487
+ hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
5488
+ if (!hasCheckoutOrderNumbers) {
5489
+ _context54.next = 11;
5490
+ break;
5491
+ }
5492
+ this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
5493
+ original_order_id: data.order_id,
5494
+ order_id: next.order_id,
5495
+ external_sale_number: externalSaleNumber,
5496
+ shop_order_number: next.shop_order_number,
5372
5497
  shop_full_order_number: next.shop_full_order_number
5373
5498
  });
5374
5499
  return _context54.abrupt("return", next);
@@ -5560,6 +5685,8 @@ var Server = /*#__PURE__*/function () {
5560
5685
  payload: {
5561
5686
  backendPath: params.backendPath,
5562
5687
  data: params.data,
5688
+ invoice: this.normalizePrintInvoiceLayoutConfig(params.invoiceLayoutConfig),
5689
+ template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
5563
5690
  external_sale_number: (_params$data = params.data) === null || _params$data === void 0 ? void 0 : _params$data.external_sale_number,
5564
5691
  title: params.title
5565
5692
  },
@@ -5627,14 +5754,20 @@ var Server = /*#__PURE__*/function () {
5627
5754
  data: params.receiptOnly ? {
5628
5755
  order_id: printIdentity,
5629
5756
  small_ticket_data: (_params$syncedOrder = params.syncedOrder) === null || _params$syncedOrder === void 0 || (_params$syncedOrder = _params$syncedOrder.payment_info) === null || _params$syncedOrder === void 0 ? void 0 : _params$syncedOrder.small_ticket_data,
5757
+ invoice: this.normalizePrintInvoiceLayoutConfig(params.invoiceLayoutConfig),
5758
+ template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
5630
5759
  skip_wristband: true,
5631
5760
  skip_voucher: true
5632
- } : {
5761
+ } : _objectSpread(_objectSpread({
5633
5762
  order_id: printIdentity,
5634
5763
  machine_code_print_info: (_params$syncedOrder2 = params.syncedOrder) === null || _params$syncedOrder2 === void 0 || (_params$syncedOrder2 = _params$syncedOrder2.payment_info) === null || _params$syncedOrder2 === void 0 ? void 0 : _params$syncedOrder2.machine_code_print_info,
5635
- machine_code_print_info_v2: (_params$syncedOrder3 = params.syncedOrder) === null || _params$syncedOrder3 === void 0 ? void 0 : _params$syncedOrder3.machine_code_print_info_v2,
5764
+ machine_code_print_info_v2: (_params$syncedOrder3 = params.syncedOrder) === null || _params$syncedOrder3 === void 0 ? void 0 : _params$syncedOrder3.machine_code_print_info_v2
5765
+ }, params.invoiceLayoutConfig ? {
5766
+ invoice: this.normalizePrintInvoiceLayoutConfig(params.invoiceLayoutConfig)
5767
+ } : {}), {}, {
5768
+ template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
5636
5769
  skip_receipt: true
5637
- }
5770
+ })
5638
5771
  },
5639
5772
  idempotency_key: this.buildPrintOtherReceiptIdempotencyKey(params.syncedOrder, {
5640
5773
  receiptOnly: params.receiptOnly
@@ -5720,7 +5853,9 @@ var Server = /*#__PURE__*/function () {
5720
5853
  syncedOrder: printableOrder,
5721
5854
  response: params.response,
5722
5855
  receiptOnly: true,
5723
- isManualPrint: params.isManualPrint
5856
+ isManualPrint: params.isManualPrint,
5857
+ invoiceLayoutConfig: params.invoiceLayoutConfig,
5858
+ invoiceTemplateSettings: params.invoiceTemplateSettings
5724
5859
  });
5725
5860
  case 10:
5726
5861
  return _context58.abrupt("return", {
@@ -5757,6 +5892,20 @@ var Server = /*#__PURE__*/function () {
5757
5892
  }
5758
5893
  return undefined;
5759
5894
  }
5895
+ }, {
5896
+ key: "mergeLocalPrintOrderInput",
5897
+ value: function mergeLocalPrintOrderInput(localOrder, inputOrder) {
5898
+ var _ref64, _localOrder$order_id, _ref65, _external_sale_number4;
5899
+ var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (_ref62) {
5900
+ var _ref63 = _slicedToArray(_ref62, 2),
5901
+ value = _ref63[1];
5902
+ return value !== undefined;
5903
+ }));
5904
+ return _objectSpread(_objectSpread(_objectSpread({}, localOrder), definedInput), {}, {
5905
+ order_id: (_ref64 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : definedInput.order_id) !== null && _ref64 !== void 0 ? _ref64 : definedInput.orderId,
5906
+ external_sale_number: (_ref65 = (_external_sale_number4 = localOrder.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : definedInput.external_sale_number) !== null && _ref65 !== void 0 ? _ref65 : definedInput.externalSaleNumber
5907
+ });
5908
+ }
5760
5909
  }, {
5761
5910
  key: "resolveMachinecodeBatchMetadataLookup",
5762
5911
  value: function resolveMachinecodeBatchMetadataLookup(data) {
@@ -5901,11 +6050,20 @@ var Server = /*#__PURE__*/function () {
5901
6050
  key: "handleOrderCheckoutSubmit",
5902
6051
  value: function () {
5903
6052
  var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
5904
- var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
6053
+ var backendPath, title, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
5905
6054
  return _regeneratorRuntime().wrap(function _callee60$(_context60) {
5906
6055
  while (1) switch (_context60.prev = _context60.next) {
5907
6056
  case 0:
5908
- backendPath = params.backendPath, data = params.data, title = params.title;
6057
+ backendPath = params.backendPath, title = params.title;
6058
+ extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
6059
+ includePublicInvoice: true
6060
+ });
6061
+ extractedTemplateSettings = this.extractInvoiceTemplateSettings(extractedInvoice.data, {
6062
+ includePublicTemplateSettings: true
6063
+ });
6064
+ data = extractedTemplateSettings.data;
6065
+ invoiceLayoutConfig = extractedInvoice.invoiceLayoutConfig;
6066
+ invoiceTemplateSettings = this.normalizePrintInvoiceTemplateSettings(extractedTemplateSettings.invoiceTemplateSettings);
5909
6067
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
5910
6068
  backendPath: backendPath,
5911
6069
  order_id: data === null || data === void 0 ? void 0 : data.order_id,
@@ -5913,58 +6071,65 @@ var Server = /*#__PURE__*/function () {
5913
6071
  order_number: data === null || data === void 0 ? void 0 : data.order_number
5914
6072
  });
5915
6073
  if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
5916
- _context60.next = 4;
6074
+ _context60.next = 9;
5917
6075
  break;
5918
6076
  }
5919
6077
  return _context60.abrupt("return", this.handleSyncCheckoutSubmit({
5920
6078
  backendPath: backendPath,
5921
6079
  data: data,
5922
- title: title
6080
+ title: title,
6081
+ invoiceLayoutConfig: invoiceLayoutConfig,
6082
+ invoiceTemplateSettings: invoiceTemplateSettings
5923
6083
  }));
5924
- case 4:
5925
- _context60.next = 6;
6084
+ case 9:
6085
+ _context60.next = 11;
5926
6086
  return this.normalizeCheckoutSubmitData(data, title);
5927
- case 6:
6087
+ case 11:
5928
6088
  normalizedData = _context60.sent;
5929
- _context60.next = 9;
6089
+ _context60.next = 14;
5930
6090
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
5931
- case 9:
5932
- checkoutData = _context60.sent;
5933
- _context60.next = 12;
6091
+ case 14:
6092
+ numberedData = _context60.sent;
6093
+ checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
6094
+ _context60.next = 18;
5934
6095
  return this.handlePendingSyncCheckoutOrder({
5935
6096
  backendPath: backendPath,
5936
6097
  data: checkoutData,
5937
6098
  title: title,
5938
6099
  reason: 'checkout 已转入设备任务同步'
5939
6100
  });
5940
- case 12:
6101
+ case 18:
5941
6102
  pendingResult = _context60.sent;
5942
6103
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
5943
- _context60.next = 20;
6104
+ _context60.next = 26;
5944
6105
  break;
5945
6106
  }
5946
6107
  pendingOrder = pendingResult.data;
5947
6108
  if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
5948
- _context60.next = 18;
6109
+ _context60.next = 24;
5949
6110
  break;
5950
6111
  }
5951
- _context60.next = 18;
6112
+ _context60.next = 24;
5952
6113
  return this.dispatchLocalReceiptPrint({
5953
6114
  checkoutData: checkoutData,
5954
6115
  order: pendingOrder,
5955
6116
  response: pendingResult,
5956
- requireFullyPaid: true
6117
+ requireFullyPaid: true,
6118
+ invoiceLayoutConfig: invoiceLayoutConfig,
6119
+ invoiceTemplateSettings: invoiceTemplateSettings
5957
6120
  });
5958
- case 18:
5959
- _context60.next = 20;
6121
+ case 24:
6122
+ _context60.next = 26;
5960
6123
  return this.dispatchCheckoutSyncTask({
5961
6124
  backendPath: backendPath,
5962
6125
  data: checkoutData,
5963
- title: title
6126
+ title: title,
6127
+ invoiceLayoutConfig: invoiceLayoutConfig,
6128
+ invoiceTemplateSettings: invoiceTemplateSettings
5964
6129
  });
5965
- case 20:
6130
+ case 26:
5966
6131
  if (pendingResult.data.order_id) {
5967
- _context60.next = 22;
6132
+ _context60.next = 28;
5968
6133
  break;
5969
6134
  }
5970
6135
  return _context60.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
@@ -5972,9 +6137,9 @@ var Server = /*#__PURE__*/function () {
5972
6137
  order_id: pendingResult.data.external_sale_number
5973
6138
  })
5974
6139
  }));
5975
- case 22:
6140
+ case 28:
5976
6141
  return _context60.abrupt("return", pendingResult);
5977
- case 23:
6142
+ case 29:
5978
6143
  case "end":
5979
6144
  return _context60.stop();
5980
6145
  }
@@ -5989,13 +6154,13 @@ var Server = /*#__PURE__*/function () {
5989
6154
  key: "handleSyncCheckoutSubmit",
5990
6155
  value: function () {
5991
6156
  var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
5992
- var _this$app16;
5993
- var backendPath, data, title, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
6157
+ var _this$app15;
6158
+ var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
5994
6159
  return _regeneratorRuntime().wrap(function _callee61$(_context61) {
5995
6160
  while (1) switch (_context61.prev = _context61.next) {
5996
6161
  case 0:
5997
- backendPath = params.backendPath, data = params.data, title = params.title;
5998
- if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
6162
+ backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings;
6163
+ if ((_this$app15 = this.app) !== null && _this$app15 !== void 0 && (_this$app15 = _this$app15.request) !== null && _this$app15 !== void 0 && _this$app15.post) {
5999
6164
  _context61.next = 4;
6000
6165
  break;
6001
6166
  }
@@ -6013,7 +6178,9 @@ var Server = /*#__PURE__*/function () {
6013
6178
  backendPath: backendPath,
6014
6179
  data: data,
6015
6180
  title: title,
6016
- persistCheckoutDataWithResponse: true
6181
+ persistCheckoutDataWithResponse: true,
6182
+ invoiceLayoutConfig: invoiceLayoutConfig,
6183
+ invoiceTemplateSettings: invoiceTemplateSettings
6017
6184
  });
6018
6185
  case 7:
6019
6186
  syncResult = _context61.sent;
@@ -6039,7 +6206,9 @@ var Server = /*#__PURE__*/function () {
6039
6206
  checkoutData: syncResult.checkoutData,
6040
6207
  order: syncedOrder,
6041
6208
  response: syncResult.normalizedResponse,
6042
- requireFullyPaid: true
6209
+ requireFullyPaid: true,
6210
+ invoiceLayoutConfig: invoiceLayoutConfig,
6211
+ invoiceTemplateSettings: invoiceTemplateSettings
6043
6212
  // print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
6044
6213
  });
6045
6214
  case 16:
@@ -6086,19 +6255,25 @@ var Server = /*#__PURE__*/function () {
6086
6255
  key: "handleOrderDraftSubmit",
6087
6256
  value: function () {
6088
6257
  var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6089
- var data, title, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
6258
+ var title, extractedInvoice, _this$extractInvoiceT, data, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
6090
6259
  return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6091
6260
  while (1) switch (_context62.prev = _context62.next) {
6092
6261
  case 0:
6093
- data = params.data, title = params.title;
6262
+ title = params.title;
6263
+ extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
6264
+ includePublicInvoice: true
6265
+ });
6266
+ _this$extractInvoiceT = this.extractInvoiceTemplateSettings(extractedInvoice.data, {
6267
+ includePublicTemplateSettings: true
6268
+ }), data = _this$extractInvoiceT.data;
6094
6269
  this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
6095
6270
  order_id: data === null || data === void 0 ? void 0 : data.order_id,
6096
6271
  external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
6097
6272
  order_number: data === null || data === void 0 ? void 0 : data.order_number
6098
6273
  });
6099
- _context62.next = 4;
6274
+ _context62.next = 6;
6100
6275
  return this.normalizeCheckoutSubmitData(data, title);
6101
- case 4:
6276
+ case 6:
6102
6277
  normalizedData = _context62.sent;
6103
6278
  createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
6104
6279
  draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
@@ -6109,7 +6284,7 @@ var Server = /*#__PURE__*/function () {
6109
6284
  is_draft_order: 1
6110
6285
  });
6111
6286
  if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
6112
- _context62.next = 10;
6287
+ _context62.next = 12;
6113
6288
  break;
6114
6289
  }
6115
6290
  this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
@@ -6119,11 +6294,11 @@ var Server = /*#__PURE__*/function () {
6119
6294
  message: 'Order 模块不支持本地草稿写入',
6120
6295
  data: null
6121
6296
  });
6122
- case 10:
6123
- _context62.prev = 10;
6124
- _context62.next = 13;
6297
+ case 12:
6298
+ _context62.prev = 12;
6299
+ _context62.next = 15;
6125
6300
  return this.order.upsertLocalDraftOrders([draftOrder]);
6126
- case 13:
6301
+ case 15:
6127
6302
  this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
6128
6303
  order_id: draftOrder.order_id,
6129
6304
  external_sale_number: draftOrder.external_sale_number
@@ -6139,9 +6314,9 @@ var Server = /*#__PURE__*/function () {
6139
6314
  payment_status: draftOrder === null || draftOrder === void 0 ? void 0 : draftOrder.payment_status
6140
6315
  })
6141
6316
  });
6142
- case 17:
6143
- _context62.prev = 17;
6144
- _context62.t0 = _context62["catch"](10);
6317
+ case 19:
6318
+ _context62.prev = 19;
6319
+ _context62.t0 = _context62["catch"](12);
6145
6320
  errorMessage = _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0);
6146
6321
  this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
6147
6322
  error: errorMessage
@@ -6152,11 +6327,11 @@ var Server = /*#__PURE__*/function () {
6152
6327
  message: errorMessage,
6153
6328
  data: null
6154
6329
  });
6155
- case 22:
6330
+ case 24:
6156
6331
  case "end":
6157
6332
  return _context62.stop();
6158
6333
  }
6159
- }, _callee62, this, [[10, 17]]);
6334
+ }, _callee62, this, [[12, 19]]);
6160
6335
  }));
6161
6336
  function handleOrderDraftSubmit(_x69) {
6162
6337
  return _handleOrderDraftSubmit.apply(this, arguments);
@@ -6167,7 +6342,7 @@ var Server = /*#__PURE__*/function () {
6167
6342
  key: "handlePendingSyncCheckoutOrder",
6168
6343
  value: function () {
6169
6344
  var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6170
- var _this13 = this;
6345
+ var _this14 = this;
6171
6346
  var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6172
6347
  return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6173
6348
  while (1) switch (_context63.prev = _context63.next) {
@@ -6220,7 +6395,7 @@ var Server = /*#__PURE__*/function () {
6220
6395
  });
6221
6396
  changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
6222
6397
  var _payment$metadata;
6223
- return sum + _this13.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6398
+ return sum + _this14.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
6224
6399
  }, 0);
6225
6400
  return _context63.abrupt("return", {
6226
6401
  code: 200,
@@ -6313,17 +6488,17 @@ var Server = /*#__PURE__*/function () {
6313
6488
  }, {
6314
6489
  key: "shouldAutoPrintCheckoutReceipt",
6315
6490
  value: function shouldAutoPrintCheckoutReceipt() {
6316
- var _this$core$context2, _this$core$context2$g, _this$app17, _this$app17$getStorag;
6491
+ var _this$core$context2, _this$core$context2$g, _this$app16, _this$app16$getStorag;
6317
6492
  if (((_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 || (_this$core$context2$g = _this$core$context2.getPlatform) === null || _this$core$context2$g === void 0 ? void 0 : _this$core$context2$g.call(_this$core$context2)) !== 'android') return true;
6318
- return ((_this$app17 = this.app) === null || _this$app17 === void 0 || (_this$app17 = _this$app17.storage) === null || _this$app17 === void 0 || (_this$app17$getStorag = _this$app17.getStorage) === null || _this$app17$getStorag === void 0 ? void 0 : _this$app17$getStorag.call(_this$app17, AUTO_PRINT_STORAGE_KEY)) !== 'false';
6493
+ return ((_this$app16 = this.app) === null || _this$app16 === void 0 || (_this$app16 = _this$app16.storage) === null || _this$app16 === void 0 || (_this$app16$getStorag = _this$app16.getStorage) === null || _this$app16$getStorag === void 0 ? void 0 : _this$app16$getStorag.call(_this$app16, AUTO_PRINT_STORAGE_KEY)) !== 'false';
6319
6494
  }
6320
6495
  }, {
6321
6496
  key: "shouldBuildSmallTicketData",
6322
6497
  value: function shouldBuildSmallTicketData(order) {
6323
- var _ref64, _order$small_ticket_d;
6498
+ var _ref66, _order$small_ticket_d;
6324
6499
  if (!order || _typeof(order) !== 'object') return false;
6325
6500
  // if (hasSmallTicketData(order.payment_info?.small_ticket_data)) return false;
6326
- return Number((_ref64 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref64 !== void 0 ? _ref64 : 0) === 1;
6501
+ return Number((_ref66 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref66 !== void 0 ? _ref66 : 0) === 1;
6327
6502
  }
6328
6503
  }, {
6329
6504
  key: "shouldPrintSyncedOrder",
@@ -6341,7 +6516,7 @@ var Server = /*#__PURE__*/function () {
6341
6516
  }, {
6342
6517
  key: "isSalesOrderFullyPaid",
6343
6518
  value: function isSalesOrderFullyPaid(order) {
6344
- var _order$summary$amount, _order$summary, _ref65, _ref66, _order$summary$expect, _order$summary2, _order$summary3;
6519
+ var _order$summary$amount, _order$summary, _ref67, _ref68, _order$summary$expect, _order$summary2, _order$summary3;
6345
6520
  if (!order || _typeof(order) !== 'object') return false;
6346
6521
  var paymentStatus = String(order.payment_status || '').toLowerCase();
6347
6522
  if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
@@ -6353,20 +6528,20 @@ var Server = /*#__PURE__*/function () {
6353
6528
  return this.toAmountNumber(amountGap) <= 0;
6354
6529
  }
6355
6530
  var paidAmount = this.sumPaidOrderPayments(order.payments);
6356
- var targetAmount = this.toAmountNumber((_ref65 = (_ref66 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref66 !== void 0 ? _ref66 : order.expect_amount) !== null && _ref65 !== void 0 ? _ref65 : order.total_amount);
6531
+ var targetAmount = this.toAmountNumber((_ref67 = (_ref68 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref68 !== void 0 ? _ref68 : order.expect_amount) !== null && _ref67 !== void 0 ? _ref67 : order.total_amount);
6357
6532
  if (targetAmount <= 0) return paidAmount > 0;
6358
6533
  return paidAmount >= targetAmount;
6359
6534
  }
6360
6535
  }, {
6361
6536
  key: "sumPaidOrderPayments",
6362
6537
  value: function sumPaidOrderPayments(payments) {
6363
- var _this14 = this;
6538
+ var _this15 = this;
6364
6539
  if (!Array.isArray(payments)) return 0;
6365
6540
  return payments.reduce(function (sum, payment) {
6366
6541
  var _payment$amount;
6367
6542
  var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
6368
6543
  if (status !== 'paid') return sum;
6369
- return sum + _this14.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
6544
+ return sum + _this15.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
6370
6545
  }, 0);
6371
6546
  }
6372
6547
  }, {
@@ -6382,7 +6557,7 @@ var Server = /*#__PURE__*/function () {
6382
6557
  value: function () {
6383
6558
  var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
6384
6559
  var _this$products3,
6385
- _this15 = this;
6560
+ _this16 = this;
6386
6561
  var products, productIdSet, productIds, entries;
6387
6562
  return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6388
6563
  while (1) switch (_context66.prev = _context66.next) {
@@ -6397,8 +6572,8 @@ var Server = /*#__PURE__*/function () {
6397
6572
  }
6398
6573
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
6399
6574
  product.product_bundle.forEach(function (bundle) {
6400
- var _ref67, _bundle$bundle_produc;
6401
- var bundleProductId = (_ref67 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref67 !== void 0 ? _ref67 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6575
+ var _ref69, _bundle$bundle_produc;
6576
+ var bundleProductId = (_ref69 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref69 !== void 0 ? _ref69 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6402
6577
  if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
6403
6578
  productIdSet.add(bundleProductId);
6404
6579
  }
@@ -6414,21 +6589,21 @@ var Server = /*#__PURE__*/function () {
6414
6589
  case 6:
6415
6590
  _context66.next = 8;
6416
6591
  return Promise.all(productIds.map( /*#__PURE__*/function () {
6417
- var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
6418
- var _this15$products, _this15$products$getP, product;
6592
+ var _ref70 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
6593
+ var _this16$products, _this16$products$getP, product;
6419
6594
  return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6420
6595
  while (1) switch (_context65.prev = _context65.next) {
6421
6596
  case 0:
6422
6597
  _context65.prev = 0;
6423
6598
  _context65.next = 3;
6424
- return (_this15$products = _this15.products) === null || _this15$products === void 0 || (_this15$products$getP = _this15$products.getProductById) === null || _this15$products$getP === void 0 ? void 0 : _this15$products$getP.call(_this15$products, Number(id));
6599
+ return (_this16$products = _this16.products) === null || _this16$products === void 0 || (_this16$products$getP = _this16$products.getProductById) === null || _this16$products$getP === void 0 ? void 0 : _this16$products$getP.call(_this16$products, Number(id));
6425
6600
  case 3:
6426
6601
  product = _context65.sent;
6427
6602
  return _context65.abrupt("return", product ? [String(id), product] : null);
6428
6603
  case 7:
6429
6604
  _context65.prev = 7;
6430
6605
  _context65.t0 = _context65["catch"](0);
6431
- _this15.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6606
+ _this16.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
6432
6607
  product_id: id,
6433
6608
  error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
6434
6609
  });
@@ -6440,7 +6615,7 @@ var Server = /*#__PURE__*/function () {
6440
6615
  }, _callee65, null, [[0, 7]]);
6441
6616
  }));
6442
6617
  return function (_x73) {
6443
- return _ref68.apply(this, arguments);
6618
+ return _ref70.apply(this, arguments);
6444
6619
  };
6445
6620
  }()));
6446
6621
  case 8:
@@ -6479,8 +6654,8 @@ var Server = /*#__PURE__*/function () {
6479
6654
  addProductId((_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id);
6480
6655
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
6481
6656
  product.product_bundle.forEach(function (bundle) {
6482
- var _ref69, _bundle$bundle_produc2;
6483
- addProductId((_ref69 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref69 !== void 0 ? _ref69 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
6657
+ var _ref71, _bundle$bundle_produc2;
6658
+ addProductId((_ref71 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref71 !== void 0 ? _ref71 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
6484
6659
  });
6485
6660
  }
6486
6661
  });
@@ -6556,9 +6731,9 @@ var Server = /*#__PURE__*/function () {
6556
6731
  if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
6557
6732
  var hasChanged = false;
6558
6733
  var productBundle = product.product_bundle.map(function (bundle) {
6559
- var _ref70, _bundle$bundle_produc3;
6734
+ var _ref72, _bundle$bundle_produc3;
6560
6735
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
6561
- var rawProductId = (_ref70 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref70 !== void 0 ? _ref70 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6736
+ var rawProductId = (_ref72 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref72 !== void 0 ? _ref72 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6562
6737
  if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
6563
6738
  var productId = Number(rawProductId);
6564
6739
  if (!Number.isFinite(productId)) return bundle;
@@ -6579,7 +6754,7 @@ var Server = /*#__PURE__*/function () {
6579
6754
  key: "withSalesDetailProductSnapshots",
6580
6755
  value: function () {
6581
6756
  var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
6582
- var _this16 = this;
6757
+ var _this17 = this;
6583
6758
  var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
6584
6759
  return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6585
6760
  while (1) switch (_context68.prev = _context68.next) {
@@ -6603,8 +6778,8 @@ var Server = /*#__PURE__*/function () {
6603
6778
  case 8:
6604
6779
  hasChanged = false;
6605
6780
  enrichedProducts = products.map(function (product) {
6606
- var productWithBundleSnapshots = _this16.withBundleCatalogSnapshots(product, snapshotMap);
6607
- var nextProduct = _this16.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6781
+ var productWithBundleSnapshots = _this17.withBundleCatalogSnapshots(product, snapshotMap);
6782
+ var nextProduct = _this17.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
6608
6783
  if (nextProduct !== product) hasChanged = true;
6609
6784
  return nextProduct;
6610
6785
  });
@@ -6632,13 +6807,13 @@ var Server = /*#__PURE__*/function () {
6632
6807
  }, {
6633
6808
  key: "withPendingSyncProductTitles",
6634
6809
  value: function withPendingSyncProductTitles(order, productMap) {
6635
- var _this17 = this;
6810
+ var _this18 = this;
6636
6811
  var products = Array.isArray(order.products) ? order.products : null;
6637
6812
  if (!(products !== null && products !== void 0 && products.length)) return order;
6638
6813
  return _objectSpread(_objectSpread({}, order), {}, {
6639
6814
  products: products.map(function (product) {
6640
6815
  return _objectSpread(_objectSpread({}, product), {}, {
6641
- product_title: _this17.buildProductTitleSnapshot(product, productMap)
6816
+ product_title: _this18.buildProductTitleSnapshot(product, productMap)
6642
6817
  });
6643
6818
  })
6644
6819
  });
@@ -6649,7 +6824,7 @@ var Server = /*#__PURE__*/function () {
6649
6824
  var _product$product_id4,
6650
6825
  _product$product,
6651
6826
  _fallbackProduct$prod,
6652
- _this18 = this;
6827
+ _this19 = this;
6653
6828
  var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
6654
6829
  var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
6655
6830
  var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
@@ -6657,7 +6832,7 @@ var Server = /*#__PURE__*/function () {
6657
6832
  var currentLocale = this.getProductTitleSnapshotCurrentLocale();
6658
6833
  var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
6659
6834
  return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
6660
- snapshot[key] = _this18.resolveProductTitleValue(ownTitle, key, currentLocale) || _this18.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6835
+ snapshot[key] = _this19.resolveProductTitleValue(ownTitle, key, currentLocale) || _this19.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
6661
6836
  return snapshot;
6662
6837
  }, {});
6663
6838
  }
@@ -6682,7 +6857,7 @@ var Server = /*#__PURE__*/function () {
6682
6857
  }, {
6683
6858
  key: "resolveProductTitleValue",
6684
6859
  value: function resolveProductTitleValue(value, key, currentLocale) {
6685
- var _ref71, _ref72, _value$key;
6860
+ var _ref73, _ref74, _value$key;
6686
6861
  if (value === undefined || value === null || value === '') return null;
6687
6862
  if (_typeof(value) !== 'object') {
6688
6863
  var title = String(value);
@@ -6692,7 +6867,7 @@ var Server = /*#__PURE__*/function () {
6692
6867
  }
6693
6868
  var normalizedKey = key.replace('-', '_');
6694
6869
  var dashedKey = key.replace('_', '-');
6695
- var rawValue = (_ref71 = (_ref72 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref72 !== void 0 ? _ref72 : value[dashedKey]) !== null && _ref71 !== void 0 ? _ref71 : key === 'auto' ? value.default : undefined;
6870
+ var rawValue = (_ref73 = (_ref74 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref74 !== void 0 ? _ref74 : value[dashedKey]) !== null && _ref73 !== void 0 ? _ref73 : key === 'auto' ? value.default : undefined;
6696
6871
  if (rawValue === undefined || rawValue === null || rawValue === '') return null;
6697
6872
  if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
6698
6873
  return String(rawValue);
@@ -6719,8 +6894,8 @@ var Server = /*#__PURE__*/function () {
6719
6894
  if (value === undefined || value === null || value === '') return null;
6720
6895
  if (_typeof(value) !== 'object') return String(value);
6721
6896
  var preferredKeys = ['auto', 'en', 'original', 'zh-CN', 'zh_CN', 'zh-HK', 'zh_HK', 'kitchen', 'ja', 'pt', 'default'];
6722
- for (var _i2 = 0, _preferredKeys = preferredKeys; _i2 < _preferredKeys.length; _i2++) {
6723
- var _key6 = _preferredKeys[_i2];
6897
+ for (var _i4 = 0, _preferredKeys = preferredKeys; _i4 < _preferredKeys.length; _i4++) {
6898
+ var _key6 = _preferredKeys[_i4];
6724
6899
  var rawValue = value[_key6];
6725
6900
  if (rawValue !== undefined && rawValue !== null && rawValue !== '') return String(rawValue);
6726
6901
  }
@@ -6756,14 +6931,14 @@ var Server = /*#__PURE__*/function () {
6756
6931
  key: "enrichPaymentNamesByCode",
6757
6932
  value: function () {
6758
6933
  var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
6759
- var _this19 = this;
6934
+ var _this20 = this;
6760
6935
  var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
6761
6936
  return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6762
6937
  while (1) switch (_context69.prev = _context69.next) {
6763
6938
  case 0:
6764
6939
  payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
6765
6940
  hasMissingName = payments.some(function (payment) {
6766
- return _this19.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this19.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6941
+ return _this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
6767
6942
  });
6768
6943
  if (hasMissingName) {
6769
6944
  _context69.next = 4;
@@ -6796,9 +6971,9 @@ var Server = /*#__PURE__*/function () {
6796
6971
  }
6797
6972
  hasResolvedName = false;
6798
6973
  enrichedPayments = payments.map(function (payment) {
6799
- if (!_this19.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6800
- if (!_this19.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6801
- var name = nameByCode.get(_this19.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6974
+ if (!_this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
6975
+ if (!_this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
6976
+ var name = nameByCode.get(_this20.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
6802
6977
  if (!name) return payment;
6803
6978
  hasResolvedName = true;
6804
6979
  return _objectSpread(_objectSpread({}, payment), {}, {
@@ -6899,6 +7074,175 @@ var Server = /*#__PURE__*/function () {
6899
7074
  }
6900
7075
  return withLocalSmallTicketData;
6901
7076
  }()
7077
+ }, {
7078
+ key: "normalizeRemoteSalesOrderErrorCode",
7079
+ value: function normalizeRemoteSalesOrderErrorCode(value) {
7080
+ if (value === undefined || value === null || value === '') return 500;
7081
+ var code = typeof value === 'number' ? value : Number(value);
7082
+ return Number.isFinite(code) ? code : 500;
7083
+ }
7084
+ }, {
7085
+ key: "fetchAndPersistSalesOrderByLookup",
7086
+ value: function () {
7087
+ var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(lookup, data, title) {
7088
+ var _this$order4, _this$order5, _this$app17;
7089
+ var backendPath, response, _response$code3, responseStatusCode, code, message, fresh, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref75, _backendError$code2, backendStatusCode, _code, _message2, _message3;
7090
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7091
+ while (1) switch (_context71.prev = _context71.next) {
7092
+ case 0:
7093
+ if (!(!((_this$order4 = this.order) !== null && _this$order4 !== void 0 && _this$order4.getLocalOrderByLookup) || !((_this$order5 = this.order) !== null && _this$order5 !== void 0 && _this$order5.upsertOrdersFromRemote))) {
7094
+ _context71.next = 3;
7095
+ break;
7096
+ }
7097
+ this.logError("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C"));
7098
+ return _context71.abrupt("return", {
7099
+ code: 500,
7100
+ message: 'Order 模块未注册',
7101
+ order: null
7102
+ });
7103
+ case 3:
7104
+ if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && (_this$app17 = _this$app17.request) !== null && _this$app17 !== void 0 && _this$app17.get) {
7105
+ _context71.next = 6;
7106
+ break;
7107
+ }
7108
+ this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"));
7109
+ return _context71.abrupt("return", {
7110
+ code: 500,
7111
+ message: 'app.request 不可用',
7112
+ order: null
7113
+ });
7114
+ case 6:
7115
+ backendPath = this.buildOrderSalesDetailBackendPath(String(lookup), data);
7116
+ _context71.prev = 7;
7117
+ _context71.next = 10;
7118
+ return this.app.request.get(backendPath, {
7119
+ lookup_mode: 'multi'
7120
+ }, {
7121
+ isShopApi: true,
7122
+ customToast: function customToast() {}
7123
+ });
7124
+ case 10:
7125
+ response = _context71.sent;
7126
+ if (!this.isCheckoutResponseRejected(response)) {
7127
+ _context71.next = 17;
7128
+ break;
7129
+ }
7130
+ responseStatusCode = typeof (response === null || response === void 0 ? void 0 : response.status) === 'number' ? response.status : undefined;
7131
+ code = this.normalizeRemoteSalesOrderErrorCode((_response$code3 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code3 !== void 0 ? _response$code3 : responseStatusCode);
7132
+ message = (response === null || response === void 0 ? void 0 : response.message) || '后端拒绝订单查询';
7133
+ this.logInfo("".concat(title, ": \u540E\u7AEF\u62D2\u7EDD\u8BA2\u5355\u67E5\u8BE2"), {
7134
+ lookup: lookup,
7135
+ backendPath: backendPath,
7136
+ code: code,
7137
+ message: message
7138
+ });
7139
+ return _context71.abrupt("return", {
7140
+ code: code,
7141
+ message: message,
7142
+ order: null
7143
+ });
7144
+ case 17:
7145
+ fresh = this.extractOrderDataFromCheckoutResponse(response);
7146
+ if (!(!fresh || fresh.order_id === undefined || fresh.order_id === null || String(fresh.order_id).trim() === '')) {
7147
+ _context71.next = 21;
7148
+ break;
7149
+ }
7150
+ this.logInfo("".concat(title, ": \u540E\u7AEF\u8FD4\u56DE\u8BA2\u5355\u4E3A\u7A7A"), {
7151
+ lookup: lookup,
7152
+ backendPath: backendPath
7153
+ });
7154
+ return _context71.abrupt("return", {
7155
+ code: 500,
7156
+ message: '后端返回订单为空',
7157
+ order: null
7158
+ });
7159
+ case 21:
7160
+ _context71.next = 23;
7161
+ return this.order.upsertOrdersFromRemote([fresh]);
7162
+ case 23:
7163
+ _context71.next = 25;
7164
+ return this.order.getLocalOrderByLookup(lookup);
7165
+ case 25:
7166
+ savedOrder = _context71.sent;
7167
+ if (!(!savedOrder && fresh.order_id !== undefined && fresh.order_id !== null && String(fresh.order_id) !== String(lookup))) {
7168
+ _context71.next = 30;
7169
+ break;
7170
+ }
7171
+ _context71.next = 29;
7172
+ return this.order.getLocalOrderByLookup(fresh.order_id);
7173
+ case 29:
7174
+ savedOrder = _context71.sent;
7175
+ case 30:
7176
+ if (savedOrder) {
7177
+ _context71.next = 33;
7178
+ break;
7179
+ }
7180
+ this.logError("".concat(title, ": \u8BA2\u5355\u5199\u5165\u540E\u56DE\u8BFB\u5931\u8D25"), {
7181
+ lookup: lookup,
7182
+ remote_order_id: fresh.order_id
7183
+ });
7184
+ return _context71.abrupt("return", {
7185
+ code: 500,
7186
+ message: '订单写入后回读失败',
7187
+ order: null
7188
+ });
7189
+ case 33:
7190
+ this.logInfo("".concat(title, ": \u8FDC\u7AEF\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
7191
+ lookup: lookup,
7192
+ remote_order_id: fresh.order_id
7193
+ });
7194
+ return _context71.abrupt("return", {
7195
+ code: 200,
7196
+ message: '',
7197
+ order: savedOrder
7198
+ });
7199
+ case 37:
7200
+ _context71.prev = 37;
7201
+ _context71.t0 = _context71["catch"](7);
7202
+ backendError = this.extractBackendErrorResponse(_context71.t0);
7203
+ errorRecord = _context71.t0;
7204
+ _responseStatusCode = typeof (errorRecord === null || errorRecord === void 0 || (_errorRecord$response = errorRecord.response) === null || _errorRecord$response === void 0 ? void 0 : _errorRecord$response.status) === 'number' ? errorRecord.response.status : undefined;
7205
+ if (!(backendError || _responseStatusCode !== undefined)) {
7206
+ _context71.next = 48;
7207
+ break;
7208
+ }
7209
+ backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
7210
+ _code = this.normalizeRemoteSalesOrderErrorCode((_ref75 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref75 !== void 0 ? _ref75 : _responseStatusCode);
7211
+ _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context71.t0);
7212
+ this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
7213
+ lookup: lookup,
7214
+ backendPath: backendPath,
7215
+ code: _code,
7216
+ message: _message2
7217
+ });
7218
+ return _context71.abrupt("return", {
7219
+ code: _code,
7220
+ message: _message2,
7221
+ order: null
7222
+ });
7223
+ case 48:
7224
+ _message3 = this.getUnknownErrorMessage(_context71.t0);
7225
+ this.logInfo("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
7226
+ lookup: lookup,
7227
+ backendPath: backendPath,
7228
+ error: _message3
7229
+ });
7230
+ return _context71.abrupt("return", {
7231
+ code: 500,
7232
+ message: _message3,
7233
+ order: null
7234
+ });
7235
+ case 51:
7236
+ case "end":
7237
+ return _context71.stop();
7238
+ }
7239
+ }, _callee71, this, [[7, 37]]);
7240
+ }));
7241
+ function fetchAndPersistSalesOrderByLookup(_x79, _x80, _x81) {
7242
+ return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
7243
+ }
7244
+ return fetchAndPersistSalesOrderByLookup;
7245
+ }()
6902
7246
  }, {
6903
7247
  key: "parseOrderIdsParam",
6904
7248
  value:
@@ -6936,8 +7280,8 @@ var Server = /*#__PURE__*/function () {
6936
7280
  pushRaw(this.extractQueryParam(url, 'order_ids'));
6937
7281
  var seen = new Set();
6938
7282
  var result = [];
6939
- for (var _i3 = 0, _collected = collected; _i3 < _collected.length; _i3++) {
6940
- var id = _collected[_i3];
7283
+ for (var _i5 = 0, _collected = collected; _i5 < _collected.length; _i5++) {
7284
+ var id = _collected[_i5];
6941
7285
  if (seen.has(id)) continue;
6942
7286
  seen.add(id);
6943
7287
  result.push(id);
@@ -6956,22 +7300,22 @@ var Server = /*#__PURE__*/function () {
6956
7300
  }, {
6957
7301
  key: "handleUpdateLocalOrdersBatch",
6958
7302
  value: (function () {
6959
- var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(orderIds) {
7303
+ var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(orderIds) {
6960
7304
  var _this$app18;
6961
- var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
6962
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
6963
- while (1) switch (_context71.prev = _context71.next) {
7305
+ var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message4, overwritten, inserted;
7306
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7307
+ while (1) switch (_context72.prev = _context72.next) {
6964
7308
  case 0:
6965
7309
  this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
6966
7310
  count: orderIds.length,
6967
7311
  orderIds: orderIds
6968
7312
  });
6969
7313
  if (this.order) {
6970
- _context71.next = 4;
7314
+ _context72.next = 4;
6971
7315
  break;
6972
7316
  }
6973
7317
  this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
6974
- return _context71.abrupt("return", {
7318
+ return _context72.abrupt("return", {
6975
7319
  code: 500,
6976
7320
  status: false,
6977
7321
  message: 'Order 模块未注册',
@@ -6979,11 +7323,11 @@ var Server = /*#__PURE__*/function () {
6979
7323
  });
6980
7324
  case 4:
6981
7325
  if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && _this$app18.request) {
6982
- _context71.next = 7;
7326
+ _context72.next = 7;
6983
7327
  break;
6984
7328
  }
6985
7329
  this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
6986
- return _context71.abrupt("return", {
7330
+ return _context72.abrupt("return", {
6987
7331
  code: 500,
6988
7332
  status: false,
6989
7333
  message: 'app.request 不可用',
@@ -7006,21 +7350,21 @@ var Server = /*#__PURE__*/function () {
7006
7350
  _iterator13.f();
7007
7351
  }
7008
7352
  fetched = [];
7009
- _context71.prev = 11;
7010
- _context71.next = 14;
7353
+ _context72.prev = 11;
7354
+ _context72.next = 14;
7011
7355
  return this.order.fetchOrdersByHttp(orderIds);
7012
7356
  case 14:
7013
- fetched = _context71.sent;
7014
- _context71.next = 22;
7357
+ fetched = _context72.sent;
7358
+ _context72.next = 22;
7015
7359
  break;
7016
7360
  case 17:
7017
- _context71.prev = 17;
7018
- _context71.t0 = _context71["catch"](11);
7019
- message = _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0);
7361
+ _context72.prev = 17;
7362
+ _context72.t0 = _context72["catch"](11);
7363
+ message = _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0);
7020
7364
  this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
7021
7365
  message: message
7022
7366
  });
7023
- return _context71.abrupt("return", {
7367
+ return _context72.abrupt("return", {
7024
7368
  code: 500,
7025
7369
  status: false,
7026
7370
  message: message,
@@ -7030,36 +7374,36 @@ var Server = /*#__PURE__*/function () {
7030
7374
  // 按返回结果中的 order_id 建索引,未命中即视为单笔失败
7031
7375
  fetchedMap = new Map();
7032
7376
  _iterator14 = _createForOfIteratorHelper(fetched);
7033
- _context71.prev = 24;
7377
+ _context72.prev = 24;
7034
7378
  _iterator14.s();
7035
7379
  case 26:
7036
7380
  if ((_step14 = _iterator14.n()).done) {
7037
- _context71.next = 34;
7381
+ _context72.next = 34;
7038
7382
  break;
7039
7383
  }
7040
7384
  order = _step14.value;
7041
7385
  oid = order === null || order === void 0 ? void 0 : order.order_id;
7042
7386
  if (!(oid === undefined || oid === null)) {
7043
- _context71.next = 31;
7387
+ _context72.next = 31;
7044
7388
  break;
7045
7389
  }
7046
- return _context71.abrupt("continue", 32);
7390
+ return _context72.abrupt("continue", 32);
7047
7391
  case 31:
7048
7392
  fetchedMap.set(String(oid), order);
7049
7393
  case 32:
7050
- _context71.next = 26;
7394
+ _context72.next = 26;
7051
7395
  break;
7052
7396
  case 34:
7053
- _context71.next = 39;
7397
+ _context72.next = 39;
7054
7398
  break;
7055
7399
  case 36:
7056
- _context71.prev = 36;
7057
- _context71.t1 = _context71["catch"](24);
7058
- _iterator14.e(_context71.t1);
7400
+ _context72.prev = 36;
7401
+ _context72.t1 = _context72["catch"](24);
7402
+ _iterator14.e(_context72.t1);
7059
7403
  case 39:
7060
- _context71.prev = 39;
7404
+ _context72.prev = 39;
7061
7405
  _iterator14.f();
7062
- return _context71.finish(39);
7406
+ return _context72.finish(39);
7063
7407
  case 42:
7064
7408
  freshOrders = [];
7065
7409
  succeedIds = [];
@@ -7085,26 +7429,26 @@ var Server = /*#__PURE__*/function () {
7085
7429
  _iterator15.f();
7086
7430
  }
7087
7431
  if (!(freshOrders.length > 0)) {
7088
- _context71.next = 58;
7432
+ _context72.next = 58;
7089
7433
  break;
7090
7434
  }
7091
- _context71.prev = 48;
7092
- _context71.next = 51;
7435
+ _context72.prev = 48;
7436
+ _context72.next = 51;
7093
7437
  return this.order.upsertOrdersFromRemote(freshOrders);
7094
7438
  case 51:
7095
- _context71.next = 58;
7439
+ _context72.next = 58;
7096
7440
  break;
7097
7441
  case 53:
7098
- _context71.prev = 53;
7099
- _context71.t2 = _context71["catch"](48);
7100
- _message2 = _context71.t2 instanceof Error ? _context71.t2.message : String(_context71.t2);
7442
+ _context72.prev = 53;
7443
+ _context72.t2 = _context72["catch"](48);
7444
+ _message4 = _context72.t2 instanceof Error ? _context72.t2.message : String(_context72.t2);
7101
7445
  this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
7102
- message: _message2
7446
+ message: _message4
7103
7447
  });
7104
- return _context71.abrupt("return", {
7448
+ return _context72.abrupt("return", {
7105
7449
  code: 500,
7106
7450
  status: false,
7107
- message: _message2,
7451
+ message: _message4,
7108
7452
  data: null
7109
7453
  });
7110
7454
  case 58:
@@ -7120,7 +7464,7 @@ var Server = /*#__PURE__*/function () {
7120
7464
  insertedCount: inserted.length,
7121
7465
  failedCount: failed.length
7122
7466
  });
7123
- return _context71.abrupt("return", {
7467
+ return _context72.abrupt("return", {
7124
7468
  code: 200,
7125
7469
  status: true,
7126
7470
  message: '',
@@ -7132,11 +7476,11 @@ var Server = /*#__PURE__*/function () {
7132
7476
  });
7133
7477
  case 62:
7134
7478
  case "end":
7135
- return _context71.stop();
7479
+ return _context72.stop();
7136
7480
  }
7137
- }, _callee71, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7481
+ }, _callee72, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7138
7482
  }));
7139
- function handleUpdateLocalOrdersBatch(_x79) {
7483
+ function handleUpdateLocalOrdersBatch(_x82) {
7140
7484
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
7141
7485
  }
7142
7486
  return handleUpdateLocalOrdersBatch;
@@ -7153,7 +7497,7 @@ var Server = /*#__PURE__*/function () {
7153
7497
  var target = url.startsWith('http') ? new URL(url) : new URL(url, 'http://placeholder.local');
7154
7498
  var value = target.searchParams.get(key);
7155
7499
  return value !== null && value !== void 0 ? value : null;
7156
- } catch (_unused2) {
7500
+ } catch (_unused3) {
7157
7501
  var queryIndex = url.indexOf('?');
7158
7502
  if (queryIndex < 0) return null;
7159
7503
  var query = url.slice(queryIndex + 1);
@@ -7172,7 +7516,7 @@ var Server = /*#__PURE__*/function () {
7172
7516
  if (decodeURIComponent(rawKey) === key) {
7173
7517
  return decodeURIComponent(rawValue);
7174
7518
  }
7175
- } catch (_unused3) {
7519
+ } catch (_unused4) {
7176
7520
  if (rawKey === key) return rawValue;
7177
7521
  }
7178
7522
  }
@@ -7213,10 +7557,10 @@ var Server = /*#__PURE__*/function () {
7213
7557
  }, {
7214
7558
  key: "extractOrderDataFromCheckoutResponse",
7215
7559
  value: function extractOrderDataFromCheckoutResponse(response) {
7216
- var _response$data6, _response$data7;
7217
- var candidates = [response === null || response === void 0 || (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.order, response === null || response === void 0 || (_response$data7 = response.data) === null || _response$data7 === void 0 ? void 0 : _response$data7.sales, response === null || response === void 0 ? void 0 : response.data, response === null || response === void 0 ? void 0 : response.order, response === null || response === void 0 ? void 0 : response.sales, response];
7218
- for (var _i4 = 0, _candidates = candidates; _i4 < _candidates.length; _i4++) {
7219
- var candidate = _candidates[_i4];
7560
+ var _response$data5, _response$data6;
7561
+ var candidates = [response === null || response === void 0 || (_response$data5 = response.data) === null || _response$data5 === void 0 ? void 0 : _response$data5.order, response === null || response === void 0 || (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.sales, response === null || response === void 0 ? void 0 : response.data, response === null || response === void 0 ? void 0 : response.order, response === null || response === void 0 ? void 0 : response.sales, response];
7562
+ for (var _i6 = 0, _candidates2 = candidates; _i6 < _candidates2.length; _i6++) {
7563
+ var candidate = _candidates2[_i6];
7220
7564
  if (!candidate || _typeof(candidate) !== 'object') continue;
7221
7565
  if (candidate.order_id !== undefined && candidate.order_id !== null) {
7222
7566
  return candidate;
@@ -7336,7 +7680,7 @@ var Server = /*#__PURE__*/function () {
7336
7680
  if (typeof normalized === 'string') return normalized;
7337
7681
  try {
7338
7682
  return JSON.stringify(normalized);
7339
- } catch (_unused4) {
7683
+ } catch (_unused5) {
7340
7684
  return String(error);
7341
7685
  }
7342
7686
  }
@@ -7371,7 +7715,7 @@ var Server = /*#__PURE__*/function () {
7371
7715
  seen.add(current);
7372
7716
  return current;
7373
7717
  }));
7374
- } catch (_unused5) {
7718
+ } catch (_unused6) {
7375
7719
  return String(value);
7376
7720
  }
7377
7721
  }
@@ -7380,10 +7724,10 @@ var Server = /*#__PURE__*/function () {
7380
7724
  value: function extractBackendErrorResponse(error) {
7381
7725
  var _error$response3,
7382
7726
  _error$response4,
7383
- _this20 = this;
7727
+ _this21 = this;
7384
7728
  var candidates = [error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.body, error === null || error === void 0 ? void 0 : error.body];
7385
7729
  return candidates.find(function (candidate) {
7386
- return _this20.isExplicitBackendErrorResponse(candidate);
7730
+ return _this21.isExplicitBackendErrorResponse(candidate);
7387
7731
  }) || null;
7388
7732
  }
7389
7733
  }, {
@@ -7404,7 +7748,7 @@ var Server = /*#__PURE__*/function () {
7404
7748
  try {
7405
7749
  var pathname = url.startsWith('http') ? new URL(url).pathname : noQuery;
7406
7750
  return pathname.replace(/\/$/, '') || pathname;
7407
- } catch (_unused6) {
7751
+ } catch (_unused7) {
7408
7752
  return noQuery.replace(/\/$/, '');
7409
7753
  }
7410
7754
  }
@@ -7502,16 +7846,16 @@ var Server = /*#__PURE__*/function () {
7502
7846
  }, {
7503
7847
  key: "recomputeAndNotifyFloorPlanQuery",
7504
7848
  value: (function () {
7505
- var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72() {
7849
+ var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73() {
7506
7850
  var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
7507
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7508
- while (1) switch (_context72.prev = _context72.next) {
7851
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7852
+ while (1) switch (_context73.prev = _context73.next) {
7509
7853
  case 0:
7510
7854
  if (!(this.floorPlanQuerySubscribers.size === 0)) {
7511
- _context72.next = 2;
7855
+ _context73.next = 2;
7512
7856
  break;
7513
7857
  }
7514
- return _context72.abrupt("return");
7858
+ return _context73.abrupt("return");
7515
7859
  case 2:
7516
7860
  this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
7517
7861
  subscriberCount: this.floorPlanQuerySubscribers.size
@@ -7541,9 +7885,9 @@ var Server = /*#__PURE__*/function () {
7541
7885
  }
7542
7886
  case 5:
7543
7887
  case "end":
7544
- return _context72.stop();
7888
+ return _context73.stop();
7545
7889
  }
7546
- }, _callee72, this);
7890
+ }, _callee73, this);
7547
7891
  }));
7548
7892
  function recomputeAndNotifyFloorPlanQuery() {
7549
7893
  return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
@@ -7573,21 +7917,20 @@ var Server = /*#__PURE__*/function () {
7573
7917
  * filter 逻辑暂为 mock,仅记录参数
7574
7918
  */
7575
7919
  function () {
7576
- var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(data) {
7920
+ var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data) {
7577
7921
  var rawList, result;
7578
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7579
- while (1) switch (_context73.prev = _context73.next) {
7922
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7923
+ while (1) switch (_context74.prev = _context74.next) {
7580
7924
  case 0:
7581
7925
  this.logInfo('computeOrderQueryResult: 开始过滤', {
7582
7926
  data: data
7583
7927
  });
7584
- console.log('[Server] computeOrderQueryResult', data);
7585
7928
  if (this.order) {
7586
- _context73.next = 5;
7929
+ _context74.next = 4;
7587
7930
  break;
7588
7931
  }
7589
7932
  this.logError('computeOrderQueryResult: Order 模块未注册');
7590
- return _context73.abrupt("return", {
7933
+ return _context74.abrupt("return", {
7591
7934
  code: 500,
7592
7935
  message: 'Order 模块未注册',
7593
7936
  data: {
@@ -7596,7 +7939,7 @@ var Server = /*#__PURE__*/function () {
7596
7939
  },
7597
7940
  status: false
7598
7941
  });
7599
- case 5:
7942
+ case 4:
7600
7943
  rawList = this.order.getOrders();
7601
7944
  this.logInfo('computeOrderQueryResult: 本地订单数量', {
7602
7945
  rawCount: rawList.length
@@ -7617,19 +7960,19 @@ var Server = /*#__PURE__*/function () {
7617
7960
  skip: result.skip,
7618
7961
  rejected: result.rejected
7619
7962
  });
7620
- return _context73.abrupt("return", {
7963
+ return _context74.abrupt("return", {
7621
7964
  code: 200,
7622
7965
  data: result,
7623
7966
  message: '',
7624
7967
  status: true
7625
7968
  });
7626
- case 11:
7969
+ case 10:
7627
7970
  case "end":
7628
- return _context73.stop();
7971
+ return _context74.stop();
7629
7972
  }
7630
- }, _callee73, this);
7973
+ }, _callee74, this);
7631
7974
  }));
7632
- function computeOrderQueryResult(_x80) {
7975
+ function computeOrderQueryResult(_x83) {
7633
7976
  return _computeOrderQueryResult.apply(this, arguments);
7634
7977
  }
7635
7978
  return computeOrderQueryResult;
@@ -7642,17 +7985,17 @@ var Server = /*#__PURE__*/function () {
7642
7985
  }, {
7643
7986
  key: "computeBookingQueryResult",
7644
7987
  value: (function () {
7645
- var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data) {
7988
+ var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(data) {
7646
7989
  var rawOrders, result;
7647
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7648
- while (1) switch (_context74.prev = _context74.next) {
7990
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7991
+ while (1) switch (_context75.prev = _context75.next) {
7649
7992
  case 0:
7650
7993
  if (this.order) {
7651
- _context74.next = 3;
7994
+ _context75.next = 3;
7652
7995
  break;
7653
7996
  }
7654
7997
  this.logError('computeBookingQueryResult: Order 模块未注册');
7655
- return _context74.abrupt("return", {
7998
+ return _context75.abrupt("return", {
7656
7999
  code: 500,
7657
8000
  message: 'Order 模块未注册',
7658
8001
  data: {
@@ -7671,7 +8014,7 @@ var Server = /*#__PURE__*/function () {
7671
8014
  size: result.size,
7672
8015
  skip: result.skip
7673
8016
  });
7674
- return _context74.abrupt("return", {
8017
+ return _context75.abrupt("return", {
7675
8018
  code: 200,
7676
8019
  data: result,
7677
8020
  message: '',
@@ -7679,11 +8022,11 @@ var Server = /*#__PURE__*/function () {
7679
8022
  });
7680
8023
  case 8:
7681
8024
  case "end":
7682
- return _context74.stop();
8025
+ return _context75.stop();
7683
8026
  }
7684
- }, _callee74, this);
8027
+ }, _callee75, this);
7685
8028
  }));
7686
- function computeBookingQueryResult(_x81) {
8029
+ function computeBookingQueryResult(_x84) {
7687
8030
  return _computeBookingQueryResult.apply(this, arguments);
7688
8031
  }
7689
8032
  return computeBookingQueryResult;
@@ -7742,12 +8085,12 @@ var Server = /*#__PURE__*/function () {
7742
8085
  }, {
7743
8086
  key: "computeProductQueryResult",
7744
8087
  value: (function () {
7745
- var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(context, options) {
8088
+ var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(context, options) {
7746
8089
  var _menu_list_ids$length3,
7747
- _this21 = this;
8090
+ _this22 = this;
7748
8091
  var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
7749
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7750
- while (1) switch (_context75.prev = _context75.next) {
8092
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8093
+ while (1) switch (_context76.prev = _context76.next) {
7751
8094
  case 0:
7752
8095
  tTotal = performance.now();
7753
8096
  menu_list_ids = context.menu_list_ids, ids = context.ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, extension_type = context.extension_type, product_id = context.product_id, strategy_context = context.strategy_context;
@@ -7774,28 +8117,28 @@ var Server = /*#__PURE__*/function () {
7774
8117
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7775
8118
  });
7776
8119
  if (this.products) {
7777
- _context75.next = 8;
8120
+ _context76.next = 8;
7778
8121
  break;
7779
8122
  }
7780
8123
  this.logError('computeProductQueryResult: Products 模块未注册');
7781
- return _context75.abrupt("return", {
8124
+ return _context76.abrupt("return", {
7782
8125
  message: 'Products 模块未注册',
7783
8126
  data: this.buildProductQueryResultPayload([], 0)
7784
8127
  });
7785
8128
  case 8:
7786
8129
  if (!(queryIds.length > 0)) {
7787
- _context75.next = 20;
8130
+ _context76.next = 20;
7788
8131
  break;
7789
8132
  }
7790
8133
  uniqueIds = Array.from(new Set(queryIds));
7791
8134
  _tPrice = performance.now();
7792
- _context75.next = 13;
8135
+ _context76.next = 13;
7793
8136
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7794
8137
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7795
8138
  productIds: uniqueIds
7796
8139
  });
7797
8140
  case 13:
7798
- productsWithPrice = _context75.sent;
8141
+ productsWithPrice = _context76.sent;
7799
8142
  perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
7800
8143
  count: productsWithPrice.length,
7801
8144
  ids: uniqueIds
@@ -7815,7 +8158,7 @@ var Server = /*#__PURE__*/function () {
7815
8158
  ids: uniqueIds,
7816
8159
  count: extensionFilteredProducts.length
7817
8160
  });
7818
- return _context75.abrupt("return", {
8161
+ return _context76.abrupt("return", {
7819
8162
  code: 200,
7820
8163
  data: this.buildProductQueryResultPayload(extensionFilteredProducts),
7821
8164
  message: '',
@@ -7823,17 +8166,17 @@ var Server = /*#__PURE__*/function () {
7823
8166
  });
7824
8167
  case 20:
7825
8168
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
7826
- _context75.next = 32;
8169
+ _context76.next = 32;
7827
8170
  break;
7828
8171
  }
7829
8172
  pid = Number(product_id);
7830
8173
  _tPrice2 = performance.now();
7831
- _context75.next = 25;
8174
+ _context76.next = 25;
7832
8175
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7833
8176
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7834
8177
  });
7835
8178
  case 25:
7836
- allProductsWithPrice = _context75.sent;
8179
+ allProductsWithPrice = _context76.sent;
7837
8180
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
7838
8181
  count: allProductsWithPrice.length,
7839
8182
  productId: pid
@@ -7853,7 +8196,7 @@ var Server = /*#__PURE__*/function () {
7853
8196
  productId: pid,
7854
8197
  found: !!item
7855
8198
  });
7856
- return _context75.abrupt("return", {
8199
+ return _context76.abrupt("return", {
7857
8200
  code: 200,
7858
8201
  data: item,
7859
8202
  message: item ? '' : '商品不存在或未发布',
@@ -7861,16 +8204,16 @@ var Server = /*#__PURE__*/function () {
7861
8204
  });
7862
8205
  case 32:
7863
8206
  if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
7864
- _context75.next = 52;
8207
+ _context76.next = 52;
7865
8208
  break;
7866
8209
  }
7867
8210
  _tPrice3 = performance.now();
7868
- _context75.next = 36;
8211
+ _context76.next = 36;
7869
8212
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7870
8213
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
7871
8214
  });
7872
8215
  case 36:
7873
- _filteredProducts2 = _context75.sent;
8216
+ _filteredProducts2 = _context76.sent;
7874
8217
  perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
7875
8218
  count: _filteredProducts2.length,
7876
8219
  extension_type: extension_type
@@ -7909,7 +8252,7 @@ var Server = /*#__PURE__*/function () {
7909
8252
  filteredCount: _filteredProducts2.length,
7910
8253
  extension_type: extension_type
7911
8254
  });
7912
- return _context75.abrupt("return", {
8255
+ return _context76.abrupt("return", {
7913
8256
  code: 200,
7914
8257
  data: this.buildProductQueryResultPayload(_filteredProducts2),
7915
8258
  message: '',
@@ -7917,50 +8260,50 @@ var Server = /*#__PURE__*/function () {
7917
8260
  });
7918
8261
  case 52:
7919
8262
  if (this.menu) {
7920
- _context75.next = 55;
8263
+ _context76.next = 55;
7921
8264
  break;
7922
8265
  }
7923
8266
  this.logError('computeProductQueryResult: Menu 模块未注册');
7924
- return _context75.abrupt("return", {
8267
+ return _context76.abrupt("return", {
7925
8268
  message: 'Menu 模块未注册',
7926
8269
  data: this.buildProductQueryResultPayload([], 0)
7927
8270
  });
7928
8271
  case 55:
7929
8272
  if (this.schedule) {
7930
- _context75.next = 58;
8273
+ _context76.next = 58;
7931
8274
  break;
7932
8275
  }
7933
8276
  this.logError('computeProductQueryResult: Schedule 模块未注册');
7934
- return _context75.abrupt("return", {
8277
+ return _context76.abrupt("return", {
7935
8278
  message: 'Schedule 模块未注册',
7936
8279
  data: this.buildProductQueryResultPayload([], 0)
7937
8280
  });
7938
8281
  case 58:
7939
8282
  activeMenuList = [];
7940
8283
  if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
7941
- _context75.next = 71;
8284
+ _context76.next = 71;
7942
8285
  break;
7943
8286
  }
7944
8287
  tMenu = performance.now();
7945
8288
  getActiveMenus = function getActiveMenus() {
7946
- return _this21.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
7947
- var _this21$schedule;
7948
- return ((_this21$schedule = _this21.schedule) === null || _this21$schedule === void 0 ? void 0 : _this21$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
8289
+ return _this22.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
8290
+ var _this22$schedule;
8291
+ return ((_this22$schedule = _this22.schedule) === null || _this22$schedule === void 0 ? void 0 : _this22$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
7949
8292
  });
7950
8293
  };
7951
8294
  activeMenuList = getActiveMenus();
7952
- _context75.t0 = !activeMenuList.length;
7953
- if (!_context75.t0) {
7954
- _context75.next = 68;
8295
+ _context76.t0 = !activeMenuList.length;
8296
+ if (!_context76.t0) {
8297
+ _context76.next = 68;
7955
8298
  break;
7956
8299
  }
7957
- _context75.next = 67;
8300
+ _context76.next = 67;
7958
8301
  return this.refreshMenuScheduleCacheAfterEmptyResult();
7959
8302
  case 67:
7960
- _context75.t0 = _context75.sent;
8303
+ _context76.t0 = _context76.sent;
7961
8304
  case 68:
7962
- if (!_context75.t0) {
7963
- _context75.next = 70;
8305
+ if (!_context76.t0) {
8306
+ _context76.next = 70;
7964
8307
  break;
7965
8308
  }
7966
8309
  activeMenuList = getActiveMenus();
@@ -7980,22 +8323,22 @@ var Server = /*#__PURE__*/function () {
7980
8323
  });
7981
8324
  tPrice = performance.now();
7982
8325
  if (!(scopedProductIds.length > 0)) {
7983
- _context75.next = 82;
8326
+ _context76.next = 82;
7984
8327
  break;
7985
8328
  }
7986
- _context75.next = 79;
8329
+ _context76.next = 79;
7987
8330
  return this.products.getProductsWithPrice(schedule_date, formatterContext, {
7988
8331
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
7989
8332
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
7990
8333
  });
7991
8334
  case 79:
7992
- _context75.t1 = _context75.sent;
7993
- _context75.next = 83;
8335
+ _context76.t1 = _context76.sent;
8336
+ _context76.next = 83;
7994
8337
  break;
7995
8338
  case 82:
7996
- _context75.t1 = [];
8339
+ _context76.t1 = [];
7997
8340
  case 83:
7998
- filteredProducts = _context75.t1;
8341
+ filteredProducts = _context76.t1;
7999
8342
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
8000
8343
  count: filteredProducts.length,
8001
8344
  scopedProductCount: scopedProductIds.length
@@ -8036,7 +8379,7 @@ var Server = /*#__PURE__*/function () {
8036
8379
  filteredCount: filteredProducts.length,
8037
8380
  activeMenuCount: activeMenuList.length
8038
8381
  });
8039
- return _context75.abrupt("return", {
8382
+ return _context76.abrupt("return", {
8040
8383
  code: 200,
8041
8384
  data: this.buildProductQueryResultPayload(filteredProducts),
8042
8385
  message: '',
@@ -8044,11 +8387,11 @@ var Server = /*#__PURE__*/function () {
8044
8387
  });
8045
8388
  case 99:
8046
8389
  case "end":
8047
- return _context75.stop();
8390
+ return _context76.stop();
8048
8391
  }
8049
- }, _callee75, this);
8392
+ }, _callee76, this);
8050
8393
  }));
8051
- function computeProductQueryResult(_x82, _x83) {
8394
+ function computeProductQueryResult(_x85, _x86) {
8052
8395
  return _computeProductQueryResult.apply(this, arguments);
8053
8396
  }
8054
8397
  return computeProductQueryResult;
@@ -8084,72 +8427,72 @@ var Server = /*#__PURE__*/function () {
8084
8427
  }, {
8085
8428
  key: "recomputeAndNotifyProductQuery",
8086
8429
  value: (function () {
8087
- var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(options) {
8430
+ var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(options) {
8088
8431
  var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
8089
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
8090
- while (1) switch (_context76.prev = _context76.next) {
8432
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
8433
+ while (1) switch (_context77.prev = _context77.next) {
8091
8434
  case 0:
8092
8435
  if (!(this.productQuerySubscribers.size === 0)) {
8093
- _context76.next = 2;
8436
+ _context77.next = 2;
8094
8437
  break;
8095
8438
  }
8096
- return _context76.abrupt("return");
8439
+ return _context77.abrupt("return");
8097
8440
  case 2:
8098
8441
  this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
8099
8442
  subscriberCount: this.productQuerySubscribers.size,
8100
8443
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8101
8444
  });
8102
8445
  _iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
8103
- _context76.prev = 4;
8446
+ _context77.prev = 4;
8104
8447
  _iterator18.s();
8105
8448
  case 6:
8106
8449
  if ((_step18 = _iterator18.n()).done) {
8107
- _context76.next = 22;
8450
+ _context77.next = 22;
8108
8451
  break;
8109
8452
  }
8110
8453
  _step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
8111
- _context76.prev = 8;
8112
- _context76.next = 11;
8454
+ _context77.prev = 8;
8455
+ _context77.next = 11;
8113
8456
  return this.computeProductQueryResult(subscriber.context, {
8114
8457
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
8115
8458
  });
8116
8459
  case 11:
8117
- result = _context76.sent;
8460
+ result = _context77.sent;
8118
8461
  subscriber.callback(result);
8119
8462
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
8120
8463
  subscriberId: subscriberId
8121
8464
  });
8122
- _context76.next = 20;
8465
+ _context77.next = 20;
8123
8466
  break;
8124
8467
  case 16:
8125
- _context76.prev = 16;
8126
- _context76.t0 = _context76["catch"](8);
8127
- errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
8468
+ _context77.prev = 16;
8469
+ _context77.t0 = _context77["catch"](8);
8470
+ errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8128
8471
  this.logError('recomputeAndNotifyProductQuery: 推送失败', {
8129
8472
  subscriberId: subscriberId,
8130
8473
  error: errorMessage
8131
8474
  });
8132
8475
  case 20:
8133
- _context76.next = 6;
8476
+ _context77.next = 6;
8134
8477
  break;
8135
8478
  case 22:
8136
- _context76.next = 27;
8479
+ _context77.next = 27;
8137
8480
  break;
8138
8481
  case 24:
8139
- _context76.prev = 24;
8140
- _context76.t1 = _context76["catch"](4);
8141
- _iterator18.e(_context76.t1);
8482
+ _context77.prev = 24;
8483
+ _context77.t1 = _context77["catch"](4);
8484
+ _iterator18.e(_context77.t1);
8142
8485
  case 27:
8143
- _context76.prev = 27;
8486
+ _context77.prev = 27;
8144
8487
  _iterator18.f();
8145
- return _context76.finish(27);
8488
+ return _context77.finish(27);
8146
8489
  case 30:
8147
8490
  case "end":
8148
- return _context76.stop();
8491
+ return _context77.stop();
8149
8492
  }
8150
- }, _callee76, this, [[4, 24, 27, 30], [8, 16]]);
8493
+ }, _callee77, this, [[4, 24, 27, 30], [8, 16]]);
8151
8494
  }));
8152
- function recomputeAndNotifyProductQuery(_x84) {
8495
+ function recomputeAndNotifyProductQuery(_x87) {
8153
8496
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
8154
8497
  }
8155
8498
  return recomputeAndNotifyProductQuery;
@@ -8161,16 +8504,16 @@ var Server = /*#__PURE__*/function () {
8161
8504
  }, {
8162
8505
  key: "recomputeAndNotifyOrderQuery",
8163
8506
  value: (function () {
8164
- var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77() {
8507
+ var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
8165
8508
  var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
8166
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
8167
- while (1) switch (_context77.prev = _context77.next) {
8509
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8510
+ while (1) switch (_context78.prev = _context78.next) {
8168
8511
  case 0:
8169
8512
  if (!(this.orderQuerySubscribers.size === 0)) {
8170
- _context77.next = 2;
8513
+ _context78.next = 2;
8171
8514
  break;
8172
8515
  }
8173
- return _context77.abrupt("return");
8516
+ return _context78.abrupt("return");
8174
8517
  case 2:
8175
8518
  notifyStartAt = Date.now();
8176
8519
  this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
@@ -8178,20 +8521,20 @@ var Server = /*#__PURE__*/function () {
8178
8521
  notifyStartAt: new Date(notifyStartAt).toISOString()
8179
8522
  });
8180
8523
  _iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
8181
- _context77.prev = 5;
8524
+ _context78.prev = 5;
8182
8525
  _iterator19.s();
8183
8526
  case 7:
8184
8527
  if ((_step19 = _iterator19.n()).done) {
8185
- _context77.next = 27;
8528
+ _context78.next = 27;
8186
8529
  break;
8187
8530
  }
8188
8531
  _step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
8189
- _context77.prev = 9;
8532
+ _context78.prev = 9;
8190
8533
  computeStartAt = Date.now();
8191
- _context77.next = 13;
8534
+ _context78.next = 13;
8192
8535
  return this.computeOrderQueryResult(subscriber.context);
8193
8536
  case 13:
8194
- result = _context77.sent;
8537
+ result = _context78.sent;
8195
8538
  computeEndAt = Date.now();
8196
8539
  callbackStartAt = Date.now();
8197
8540
  subscriber.callback(result);
@@ -8202,30 +8545,30 @@ var Server = /*#__PURE__*/function () {
8202
8545
  callbackDurationMs: callbackEndAt - callbackStartAt,
8203
8546
  totalDurationMs: callbackEndAt - computeStartAt
8204
8547
  });
8205
- _context77.next = 25;
8548
+ _context78.next = 25;
8206
8549
  break;
8207
8550
  case 21:
8208
- _context77.prev = 21;
8209
- _context77.t0 = _context77["catch"](9);
8210
- errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
8551
+ _context78.prev = 21;
8552
+ _context78.t0 = _context78["catch"](9);
8553
+ errorMessage = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
8211
8554
  this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
8212
8555
  subscriberId: subscriberId,
8213
8556
  error: errorMessage
8214
8557
  });
8215
8558
  case 25:
8216
- _context77.next = 7;
8559
+ _context78.next = 7;
8217
8560
  break;
8218
8561
  case 27:
8219
- _context77.next = 32;
8562
+ _context78.next = 32;
8220
8563
  break;
8221
8564
  case 29:
8222
- _context77.prev = 29;
8223
- _context77.t1 = _context77["catch"](5);
8224
- _iterator19.e(_context77.t1);
8565
+ _context78.prev = 29;
8566
+ _context78.t1 = _context78["catch"](5);
8567
+ _iterator19.e(_context78.t1);
8225
8568
  case 32:
8226
- _context77.prev = 32;
8569
+ _context78.prev = 32;
8227
8570
  _iterator19.f();
8228
- return _context77.finish(32);
8571
+ return _context78.finish(32);
8229
8572
  case 35:
8230
8573
  notifyEndAt = Date.now();
8231
8574
  this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
@@ -8234,9 +8577,9 @@ var Server = /*#__PURE__*/function () {
8234
8577
  });
8235
8578
  case 37:
8236
8579
  case "end":
8237
- return _context77.stop();
8580
+ return _context78.stop();
8238
8581
  }
8239
- }, _callee77, this, [[5, 29, 32, 35], [9, 21]]);
8582
+ }, _callee78, this, [[5, 29, 32, 35], [9, 21]]);
8240
8583
  }));
8241
8584
  function recomputeAndNotifyOrderQuery() {
8242
8585
  return _recomputeAndNotifyOrderQuery.apply(this, arguments);
@@ -8254,7 +8597,7 @@ var Server = /*#__PURE__*/function () {
8254
8597
  }, {
8255
8598
  key: "notifySalesSearchSubscribers",
8256
8599
  value: function notifySalesSearchSubscribers(payload) {
8257
- var _this22 = this;
8600
+ var _this23 = this;
8258
8601
  if (this.salesSearchSubscribers.size === 0) return;
8259
8602
  var changedOrders = this.extractChangedOrdersFromPayload(payload);
8260
8603
  if (changedOrders.length === 0) {
@@ -8272,21 +8615,21 @@ var Server = /*#__PURE__*/function () {
8272
8615
  subscriber = _step20$value[1];
8273
8616
  try {
8274
8617
  var changedVisibleOrders = changedOrders.filter(function (order) {
8275
- var orderId = _this22.getSalesSearchOrderId(order);
8618
+ var orderId = _this23.getSalesSearchOrderId(order);
8276
8619
  return !!orderId && subscriber.visibleOrderIds.has(orderId);
8277
8620
  });
8278
8621
  if (changedVisibleOrders.length === 0) {
8279
8622
  return 1; // continue
8280
8623
  }
8281
- subscriber.callback(_this22.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8282
- _this22.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8624
+ subscriber.callback(_this23.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
8625
+ _this23.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
8283
8626
  subscriberId: subscriberId,
8284
8627
  kind: subscriber.kind,
8285
8628
  count: changedVisibleOrders.length
8286
8629
  });
8287
8630
  } catch (error) {
8288
8631
  var errorMessage = error instanceof Error ? error.message : String(error);
8289
- _this22.logError('notifySalesSearchSubscribers: 推送失败', {
8632
+ _this23.logError('notifySalesSearchSubscribers: 推送失败', {
8290
8633
  subscriberId: subscriberId,
8291
8634
  error: errorMessage
8292
8635
  });
@@ -8377,67 +8720,67 @@ var Server = /*#__PURE__*/function () {
8377
8720
  }, {
8378
8721
  key: "recomputeAndNotifyBookingQuery",
8379
8722
  value: (function () {
8380
- var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
8723
+ var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79() {
8381
8724
  var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
8382
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
8383
- while (1) switch (_context78.prev = _context78.next) {
8725
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
8726
+ while (1) switch (_context79.prev = _context79.next) {
8384
8727
  case 0:
8385
8728
  if (!(this.bookingQuerySubscribers.size === 0)) {
8386
- _context78.next = 2;
8729
+ _context79.next = 2;
8387
8730
  break;
8388
8731
  }
8389
- return _context78.abrupt("return");
8732
+ return _context79.abrupt("return");
8390
8733
  case 2:
8391
8734
  this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
8392
8735
  subscriberCount: this.bookingQuerySubscribers.size
8393
8736
  });
8394
8737
  _iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
8395
- _context78.prev = 4;
8738
+ _context79.prev = 4;
8396
8739
  _iterator21.s();
8397
8740
  case 6:
8398
8741
  if ((_step21 = _iterator21.n()).done) {
8399
- _context78.next = 22;
8742
+ _context79.next = 22;
8400
8743
  break;
8401
8744
  }
8402
8745
  _step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
8403
- _context78.prev = 8;
8404
- _context78.next = 11;
8746
+ _context79.prev = 8;
8747
+ _context79.next = 11;
8405
8748
  return this.computeBookingQueryResult(subscriber.context);
8406
8749
  case 11:
8407
- result = _context78.sent;
8750
+ result = _context79.sent;
8408
8751
  subscriber.callback(result);
8409
8752
  this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
8410
8753
  subscriberId: subscriberId
8411
8754
  });
8412
- _context78.next = 20;
8755
+ _context79.next = 20;
8413
8756
  break;
8414
8757
  case 16:
8415
- _context78.prev = 16;
8416
- _context78.t0 = _context78["catch"](8);
8417
- errorMessage = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
8758
+ _context79.prev = 16;
8759
+ _context79.t0 = _context79["catch"](8);
8760
+ errorMessage = _context79.t0 instanceof Error ? _context79.t0.message : String(_context79.t0);
8418
8761
  this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
8419
8762
  subscriberId: subscriberId,
8420
8763
  error: errorMessage
8421
8764
  });
8422
8765
  case 20:
8423
- _context78.next = 6;
8766
+ _context79.next = 6;
8424
8767
  break;
8425
8768
  case 22:
8426
- _context78.next = 27;
8769
+ _context79.next = 27;
8427
8770
  break;
8428
8771
  case 24:
8429
- _context78.prev = 24;
8430
- _context78.t1 = _context78["catch"](4);
8431
- _iterator21.e(_context78.t1);
8772
+ _context79.prev = 24;
8773
+ _context79.t1 = _context79["catch"](4);
8774
+ _iterator21.e(_context79.t1);
8432
8775
  case 27:
8433
- _context78.prev = 27;
8776
+ _context79.prev = 27;
8434
8777
  _iterator21.f();
8435
- return _context78.finish(27);
8778
+ return _context79.finish(27);
8436
8779
  case 30:
8437
8780
  case "end":
8438
- return _context78.stop();
8781
+ return _context79.stop();
8439
8782
  }
8440
- }, _callee78, this, [[4, 24, 27, 30], [8, 16]]);
8783
+ }, _callee79, this, [[4, 24, 27, 30], [8, 16]]);
8441
8784
  }));
8442
8785
  function recomputeAndNotifyBookingQuery() {
8443
8786
  return _recomputeAndNotifyBookingQuery.apply(this, arguments);
@@ -8453,7 +8796,6 @@ var Server = /*#__PURE__*/function () {
8453
8796
  key: "getProductScopeByMenuConfig",
8454
8797
  value: function getProductScopeByMenuConfig(activeMenuList) {
8455
8798
  if (!activeMenuList || activeMenuList.length === 0) {
8456
- console.log('[Server] 没有生效的餐牌,返回空数组');
8457
8799
  this.logInfo('getProductScopeByMenuConfig: 没有生效的餐牌,返回空数组', {
8458
8800
  activeMenuCount: 0
8459
8801
  });
@@ -8484,7 +8826,6 @@ var Server = /*#__PURE__*/function () {
8484
8826
 
8485
8827
  // 如果有任何一个餐牌是 product_all,则返回所有商品
8486
8828
  if (config.type === 'product_all') {
8487
- console.log('[Server] 餐牌允许所有商品:', menu.name);
8488
8829
  this.logInfo('getProductScopeByMenuConfig: 餐牌允许所有商品', {
8489
8830
  menuId: menu.form_record_id,
8490
8831
  menuName: menu.name,
@@ -8502,7 +8843,6 @@ var Server = /*#__PURE__*/function () {
8502
8843
  productIds.forEach(function (id) {
8503
8844
  return id && allowedProductIds.add(id);
8504
8845
  });
8505
- console.log('[Server] 餐牌允许指定商品 (product_ids):', menu.name, productIds);
8506
8846
  this.logInfo('getProductScopeByMenuConfig: 餐牌允许指定商品', {
8507
8847
  menuId: menu.form_record_id,
8508
8848
  menuName: menu.name,
@@ -8519,7 +8859,6 @@ var Server = /*#__PURE__*/function () {
8519
8859
  collectionIds.forEach(function (id) {
8520
8860
  return id && allowedCollectionIds.add(id);
8521
8861
  });
8522
- console.log('[Server] 餐牌允许商品集合 (product_collection):', menu.name, collectionIds);
8523
8862
  this.logInfo('getProductScopeByMenuConfig: 餐牌允许商品集合', {
8524
8863
  menuId: menu.form_record_id,
8525
8864
  menuName: menu.name,
@@ -8544,7 +8883,6 @@ var Server = /*#__PURE__*/function () {
8544
8883
 
8545
8884
  // 如果没有收集到任何商品 ID 和集合 ID,返回空数组
8546
8885
  if (allowedProductIds.size === 0 && allowedCollectionIds.size === 0) {
8547
- console.log('[Server] 没有允许的商品和集合');
8548
8886
  this.logWarning('getProductScopeByMenuConfig: 没有允许的商品和集合', {
8549
8887
  activeMenuCount: activeMenuList.length
8550
8888
  });
@@ -8555,8 +8893,6 @@ var Server = /*#__PURE__*/function () {
8555
8893
  }
8556
8894
  var allowedProductIdsArray = Array.from(allowedProductIds);
8557
8895
  var allowedCollectionIdsArray = Array.from(allowedCollectionIds);
8558
- console.log('[Server] 允许的商品 IDs:', allowedProductIdsArray);
8559
- console.log('[Server] 允许的集合 IDs:', allowedCollectionIdsArray);
8560
8896
  this.logInfo('getProductScopeByMenuConfig: 收集到的允许规则', {
8561
8897
  allowedProductCount: allowedProductIds.size,
8562
8898
  allowedCollectionCount: allowedCollectionIds.size
@@ -8583,7 +8919,7 @@ var Server = /*#__PURE__*/function () {
8583
8919
  metadata: metadata || {}
8584
8920
  });
8585
8921
  }
8586
- } catch (_unused7) {
8922
+ } catch (_unused8) {
8587
8923
  // 日志记录失败不影响主流程
8588
8924
  }
8589
8925
  }
@@ -8604,7 +8940,7 @@ var Server = /*#__PURE__*/function () {
8604
8940
  metadata: metadata || {}
8605
8941
  });
8606
8942
  }
8607
- } catch (_unused8) {
8943
+ } catch (_unused9) {
8608
8944
  // 日志记录失败不影响主流程
8609
8945
  }
8610
8946
  }
@@ -8625,7 +8961,7 @@ var Server = /*#__PURE__*/function () {
8625
8961
  metadata: metadata || {}
8626
8962
  });
8627
8963
  }
8628
- } catch (_unused9) {
8964
+ } catch (_unused10) {
8629
8965
  // 日志记录失败不影响主流程
8630
8966
  }
8631
8967
  }