@pisell/pisellos 2.2.283 → 2.2.284

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 (284) hide show
  1. package/dist/core/index.js +6 -10
  2. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  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.js +0 -2
  10. package/dist/modules/Order/index.d.ts +1 -1
  11. package/dist/modules/Order/index.js +64 -86
  12. package/dist/modules/Order/types.d.ts +1 -1
  13. package/dist/modules/Payment/index.js +97 -162
  14. package/dist/modules/Rules/index.js +1 -4
  15. package/dist/modules/Schedule/index.js +0 -1
  16. package/dist/modules/Schedule/utils.js +0 -1
  17. package/dist/modules/Step/index.js +0 -1
  18. package/dist/modules/Summary/utils.d.ts +1 -1
  19. package/dist/plugins/request.js +1 -4
  20. package/dist/plugins/window.js +2 -6
  21. package/dist/server/index.js +97 -129
  22. package/dist/server/modules/menu/index.js +32 -41
  23. package/dist/server/modules/order/index.js +2 -4
  24. package/dist/server/modules/products/index.js +24 -42
  25. package/dist/server/modules/quotation/index.js +29 -38
  26. package/dist/server/modules/resource/index.js +3 -4
  27. package/dist/server/modules/schedule/index.js +27 -35
  28. package/dist/server/utils/product.js +0 -1
  29. package/dist/solution/BaseSales/index.js +100 -72
  30. package/dist/solution/BookingByStep/index.d.ts +1 -1
  31. package/dist/solution/BookingByStep/index.js +7 -59
  32. package/dist/solution/BookingByStep/utils/capacity.js +1 -11
  33. package/dist/solution/BookingByStep/utils/resources.js +1 -3
  34. package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
  35. package/dist/solution/BookingTicket/index.d.ts +1 -13
  36. package/dist/solution/BookingTicket/index.js +0 -2
  37. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
  38. package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
  39. package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
  40. package/dist/solution/BuyTickets/index.js +9 -12
  41. package/dist/solution/Checkout/index.js +177 -252
  42. package/dist/solution/Checkout/utils/index.js +4 -16
  43. package/dist/solution/RegisterAndLogin/index.js +30 -76
  44. package/dist/solution/ScanOrder/index.js +50 -60
  45. package/dist/solution/ShopDiscount/index.js +2 -7
  46. package/dist/solution/VenueBooking/index.js +45 -55
  47. package/dist/utils/task.js +15 -18
  48. package/dist/utils/watch.js +0 -1
  49. package/lib/apis/picoding.js +2 -0
  50. package/lib/core/index.js +131 -132
  51. package/lib/effects/index.js +46 -57
  52. package/lib/index.js +82 -49
  53. package/lib/model/index.js +14 -21
  54. package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
  55. package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
  56. package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
  57. package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
  58. package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
  59. package/lib/model/strategy/adapter/index.js +100 -64
  60. package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
  61. package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
  62. package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
  63. package/lib/model/strategy/adapter/itemRule/index.js +83 -57
  64. package/lib/model/strategy/adapter/itemRule/type.js +97 -36
  65. package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
  66. package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
  67. package/lib/model/strategy/adapter/promotion/examples.js +222 -234
  68. package/lib/model/strategy/adapter/promotion/index.js +1 -0
  69. package/lib/model/strategy/adapter/promotion/type.js +243 -36
  70. package/lib/model/strategy/adapter/type.js +4 -16
  71. package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
  72. package/lib/model/strategy/adapter/walletPass/example.js +217 -190
  73. package/lib/model/strategy/adapter/walletPass/index.js +75 -51
  74. package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
  75. package/lib/model/strategy/adapter/walletPass/type.js +4 -16
  76. package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
  77. package/lib/model/strategy/engine.js +270 -168
  78. package/lib/model/strategy/index.js +49 -34
  79. package/lib/model/strategy/strategy-example.js +243 -239
  80. package/lib/model/strategy/type.js +100 -40
  81. package/lib/modules/Account/index.js +39 -53
  82. package/lib/modules/Account/types.js +20 -33
  83. package/lib/modules/AccountList/index.js +116 -154
  84. package/lib/modules/AccountList/types.js +30 -31
  85. package/lib/modules/AccountList/utils.js +18 -30
  86. package/lib/modules/BaseModule.js +23 -42
  87. package/lib/modules/BookingContext/index.js +158 -136
  88. package/lib/modules/BookingContext/types.js +46 -32
  89. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
  90. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
  91. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
  92. package/lib/modules/BookingContext/utils/flexible.js +38 -55
  93. package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
  94. package/lib/modules/BookingContext/utils/index.js +124 -41
  95. package/lib/modules/BookingContext/utils/noResource.js +58 -70
  96. package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
  97. package/lib/modules/BookingContext/utils/productExtend.js +202 -155
  98. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  99. package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
  100. package/lib/modules/BookingContext/utils/resources.js +209 -167
  101. package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
  102. package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
  103. package/lib/modules/Cart/index.js +170 -124
  104. package/lib/modules/Cart/types.js +46 -51
  105. package/lib/modules/Cart/utils/cartAccount.js +40 -39
  106. package/lib/modules/Cart/utils/cartDate.js +56 -61
  107. package/lib/modules/Cart/utils/cartDiscount.js +28 -33
  108. package/lib/modules/Cart/utils/cartNote.js +27 -32
  109. package/lib/modules/Cart/utils/cartProduct.js +321 -251
  110. package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
  111. package/lib/modules/Cart/utils/cartResource.js +70 -78
  112. package/lib/modules/Cart/utils/changePrice.js +22 -50
  113. package/lib/modules/Cart/utils/index.js +106 -48
  114. package/lib/modules/Customer/constants.js +13 -34
  115. package/lib/modules/Customer/index.js +235 -172
  116. package/lib/modules/Customer/types.js +38 -35
  117. package/lib/modules/Date/index.js +116 -115
  118. package/lib/modules/Date/types.js +16 -28
  119. package/lib/modules/Date/utils.js +174 -123
  120. package/lib/modules/Discount/index.js +122 -127
  121. package/lib/modules/Discount/types.js +9 -31
  122. package/lib/modules/Guests/index.js +30 -56
  123. package/lib/modules/Guests/types.js +23 -33
  124. package/lib/modules/Holder/index.js +209 -189
  125. package/lib/modules/Holder/types.js +4 -16
  126. package/lib/modules/Holder/utils.js +20 -49
  127. package/lib/modules/OpenData/index.js +70 -76
  128. package/lib/modules/OpenData/types.js +4 -16
  129. package/lib/modules/OpenData/utils.js +44 -78
  130. package/lib/modules/Order/index.d.ts +1 -1
  131. package/lib/modules/Order/index.js +1728 -2123
  132. package/lib/modules/Order/payment-utils.js +77 -120
  133. package/lib/modules/Order/types.d.ts +1 -1
  134. package/lib/modules/Order/types.js +87 -35
  135. package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
  136. package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
  137. package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
  138. package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
  139. package/lib/modules/Order/utils.js +814 -647
  140. package/lib/modules/Payment/cash.js +20 -33
  141. package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
  142. package/lib/modules/Payment/eftpos.js +16 -30
  143. package/lib/modules/Payment/index.js +532 -399
  144. package/lib/modules/Payment/mx51.js +1 -0
  145. package/lib/modules/Payment/types.js +230 -108
  146. package/lib/modules/Payment/utils.js +52 -51
  147. package/lib/modules/Payment/walletpass.js +485 -660
  148. package/lib/modules/Product/index.js +51 -46
  149. package/lib/modules/Product/types.js +4 -16
  150. package/lib/modules/Product/utils.js +32 -33
  151. package/lib/modules/ProductList/index.js +113 -123
  152. package/lib/modules/ProductList/types.js +9 -31
  153. package/lib/modules/Quotation/index.js +66 -100
  154. package/lib/modules/Quotation/types.js +4 -16
  155. package/lib/modules/Resource/index.js +27 -59
  156. package/lib/modules/Resource/types.js +22 -32
  157. package/lib/modules/Resource/utils.js +30 -38
  158. package/lib/modules/ResourcePlanner/index.js +60 -61
  159. package/lib/modules/ResourcePlanner/planner.js +346 -384
  160. package/lib/modules/ResourcePlanner/types.js +4 -16
  161. package/lib/modules/Rules/index.js +1218 -959
  162. package/lib/modules/Rules/types.js +17 -40
  163. package/lib/modules/SalesSummary/index.js +85 -90
  164. package/lib/modules/SalesSummary/types.js +4 -16
  165. package/lib/modules/SalesSummary/utils.js +355 -430
  166. package/lib/modules/ScanOrderLogger/index.js +59 -79
  167. package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
  168. package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
  169. package/lib/modules/ScanOrderLogger/types.js +4 -16
  170. package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
  171. package/lib/modules/Schedule/index.js +100 -114
  172. package/lib/modules/Schedule/type.js +4 -16
  173. package/lib/modules/Schedule/types.js +4 -16
  174. package/lib/modules/Schedule/utils.js +433 -291
  175. package/lib/modules/Step/index.js +40 -52
  176. package/lib/modules/Step/tyeps.js +4 -16
  177. package/lib/modules/Summary/index.js +66 -71
  178. package/lib/modules/Summary/types.js +4 -16
  179. package/lib/modules/Summary/utils.d.ts +1 -1
  180. package/lib/modules/Summary/utils.js +773 -418
  181. package/lib/modules/SurchargeList/index.js +46 -60
  182. package/lib/modules/SurchargeList/types.js +4 -16
  183. package/lib/modules/index.js +245 -63
  184. package/lib/plugins/app.js +4 -16
  185. package/lib/plugins/index.js +36 -25
  186. package/lib/plugins/request.js +137 -126
  187. package/lib/plugins/shopStore.js +4 -16
  188. package/lib/plugins/user.js +4 -16
  189. package/lib/plugins/window.js +171 -179
  190. package/lib/server/index.js +3027 -2655
  191. package/lib/server/modules/floor-plan/index.js +102 -123
  192. package/lib/server/modules/floor-plan/types.js +15 -30
  193. package/lib/server/modules/index.js +106 -68
  194. package/lib/server/modules/menu/index.js +146 -122
  195. package/lib/server/modules/menu/types.js +18 -31
  196. package/lib/server/modules/order/index.js +758 -956
  197. package/lib/server/modules/order/types.js +122 -33
  198. package/lib/server/modules/order/utils/filterBookings.js +219 -194
  199. package/lib/server/modules/order/utils/filterOrders.js +118 -92
  200. package/lib/server/modules/payment/index.js +59 -83
  201. package/lib/server/modules/payment/types.js +4 -16
  202. package/lib/server/modules/products/index.js +575 -459
  203. package/lib/server/modules/products/types.js +44 -34
  204. package/lib/server/modules/quotation/index.js +137 -172
  205. package/lib/server/modules/quotation/types.js +21 -31
  206. package/lib/server/modules/resource/index.js +213 -184
  207. package/lib/server/modules/resource/types.js +42 -33
  208. package/lib/server/modules/schedule/index.js +135 -123
  209. package/lib/server/modules/schedule/types.js +14 -21
  210. package/lib/server/modules/schedule/utils.js +334 -163
  211. package/lib/server/types.js +4 -16
  212. package/lib/server/utils/index.js +25 -23
  213. package/lib/server/utils/product.js +196 -139
  214. package/lib/server/utils/schedule.js +34 -41
  215. package/lib/server/utils/small-ticket.js +479 -456
  216. package/lib/server/utils/time.js +40 -49
  217. package/lib/solution/BaseSales/index.js +1209 -1412
  218. package/lib/solution/BaseSales/types.js +42 -38
  219. package/lib/solution/BaseSales/utils/cartPromotion.js +650 -502
  220. package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
  221. package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
  222. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
  223. package/lib/solution/BaseSales/utils.js +158 -143
  224. package/lib/solution/BookingByStep/index.d.ts +1 -1
  225. package/lib/solution/BookingByStep/index.js +1527 -1340
  226. package/lib/solution/BookingByStep/types.js +40 -99
  227. package/lib/solution/BookingByStep/utils/capacity.js +192 -160
  228. package/lib/solution/BookingByStep/utils/products.js +42 -52
  229. package/lib/solution/BookingByStep/utils/resources.js +527 -330
  230. package/lib/solution/BookingByStep/utils/stock.js +65 -44
  231. package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
  232. package/lib/solution/BookingTicket/index.d.ts +1 -13
  233. package/lib/solution/BookingTicket/index.js +594 -514
  234. package/lib/solution/BookingTicket/types.js +99 -77
  235. package/lib/solution/BookingTicket/utils/addProductDecision.js +225 -187
  236. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
  237. package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
  238. package/lib/solution/BookingTicket/utils/cartView.js +114 -99
  239. package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
  240. package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
  241. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
  242. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
  243. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
  244. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
  245. package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
  246. package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
  247. package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
  248. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
  249. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
  250. package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
  251. package/lib/solution/BuyTickets/index.js +67 -70
  252. package/lib/solution/BuyTickets/types.js +22 -38
  253. package/lib/solution/Checkout/index.js +1451 -1158
  254. package/lib/solution/Checkout/types.js +91 -61
  255. package/lib/solution/Checkout/utils/index.js +228 -156
  256. package/lib/solution/PlaceOrder/index.js +55 -0
  257. package/lib/solution/RegisterAndLogin/config.js +493 -460
  258. package/lib/solution/RegisterAndLogin/index.js +633 -630
  259. package/lib/solution/RegisterAndLogin/types.js +189 -76
  260. package/lib/solution/RegisterAndLogin/utils.js +183 -125
  261. package/lib/solution/Sales/index.js +328 -324
  262. package/lib/solution/Sales/types.js +27 -33
  263. package/lib/solution/ScanOrder/index.js +832 -864
  264. package/lib/solution/ScanOrder/types.js +33 -34
  265. package/lib/solution/ScanOrder/utils.js +409 -374
  266. package/lib/solution/ShopDiscount/index.js +226 -232
  267. package/lib/solution/ShopDiscount/types.js +15 -37
  268. package/lib/solution/ShopDiscount/utils.js +300 -172
  269. package/lib/solution/UnifiedBookingSales/index.js +437 -487
  270. package/lib/solution/UnifiedBookingSales/types.js +12 -31
  271. package/lib/solution/VenueBooking/index.js +811 -879
  272. package/lib/solution/VenueBooking/types.js +19 -39
  273. package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
  274. package/lib/solution/VenueBooking/utils/resource.js +31 -54
  275. package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
  276. package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
  277. package/lib/solution/VenueBooking/utils.js +130 -67
  278. package/lib/solution/index.js +124 -41
  279. package/lib/store/createStore.js +32 -29
  280. package/lib/types/index.js +4 -16
  281. package/lib/utils/payment-number.js +26 -46
  282. package/lib/utils/task.js +36 -36
  283. package/lib/utils/watch.js +81 -47
  284. package/package.json +2 -1
@@ -157,9 +157,7 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
157
157
  app = appPlugin.getApp();
158
158
  this.dbManager = app.sqlite;
159
159
  this.logger = app.logger;
160
- if (this.dbManager) {
161
- console.log('[Schedule] SQLite 已初始化');
162
- } else {
160
+ if (this.dbManager) {} else {
163
161
  console.warn('[Schedule] SQLite 未找到');
164
162
  }
165
163
  }
@@ -323,7 +321,6 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
323
321
  } finally {
324
322
  _iterator2.f();
325
323
  }
326
- console.log("[Schedule] Map \u7F13\u5B58\u5DF2\u540C\u6B65\uFF0C\u5171 ".concat(this.store.map.size, " \u4E2A\u65E5\u7A0B"));
327
324
  }
328
325
 
329
326
  /**
@@ -344,32 +341,31 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
344
341
  this.store.map.clear();
345
342
  // 同时清空 SQLite 中的数据
346
343
  if (!this.dbManager) {
347
- _context3.next = 16;
344
+ _context3.next = 15;
348
345
  break;
349
346
  }
350
347
  _context3.prev = 4;
351
348
  _context3.next = 7;
352
349
  return this.dbManager.clear(SCHEDULE_STORE_NAME);
353
350
  case 7:
354
- console.log('[Schedule] SQLite 缓存已清空');
355
351
  this.logInfo('SQLite 缓存已清空');
356
- _context3.next = 16;
352
+ _context3.next = 15;
357
353
  break;
358
- case 11:
359
- _context3.prev = 11;
354
+ case 10:
355
+ _context3.prev = 10;
360
356
  _context3.t0 = _context3["catch"](4);
361
357
  errorMessage = _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0);
362
358
  console.error('[Schedule] 清空 SQLite 缓存失败:', _context3.t0);
363
359
  this.logError('清空 SQLite 缓存失败', {
364
360
  error: errorMessage
365
361
  });
366
- case 16:
362
+ case 15:
367
363
  this.logInfo('缓存清空完成');
368
- case 17:
364
+ case 16:
369
365
  case "end":
370
366
  return _context3.stop();
371
367
  }
372
- }, _callee3, this, [[4, 11]]);
368
+ }, _callee3, this, [[4, 10]]);
373
369
  }));
374
370
  function clear() {
375
371
  return _clear.apply(this, arguments);
@@ -509,14 +505,13 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
509
505
  return _this4.dbManager.add(SCHEDULE_STORE_NAME, schedule);
510
506
  }));
511
507
  case 20:
512
- console.log("[Schedule] \u5DF2\u5C06 ".concat(scheduleList.length, " \u6761\u65E5\u7A0B\u6570\u636E\u4FDD\u5B58\u5230 SQLite"));
513
508
  this.logInfo('日程数据已保存到 SQLite', {
514
509
  scheduleCount: scheduleList.length
515
510
  });
516
- _context5.next = 29;
511
+ _context5.next = 28;
517
512
  break;
518
- case 24:
519
- _context5.prev = 24;
513
+ case 23:
514
+ _context5.prev = 23;
520
515
  _context5.t0 = _context5["catch"](4);
521
516
  errorMessage = _context5.t0 instanceof Error ? _context5.t0.message : String(_context5.t0);
522
517
  console.error('[Schedule] 保存数据到 SQLite 失败:', _context5.t0);
@@ -524,11 +519,11 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
524
519
  scheduleCount: scheduleList.length,
525
520
  error: errorMessage
526
521
  });
527
- case 29:
522
+ case 28:
528
523
  case "end":
529
524
  return _context5.stop();
530
525
  }
531
- }, _callee5, this, [[4, 24]]);
526
+ }, _callee5, this, [[4, 23]]);
532
527
  }));
533
528
  function saveScheduleToSQLite(_x3) {
534
529
  return _saveScheduleToSQLite.apply(this, arguments);
@@ -548,19 +543,17 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
548
543
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
549
544
  while (1) switch (_context6.prev = _context6.next) {
550
545
  case 0:
551
- console.log('[Schedule] 开始预加载数据...');
552
546
  startTime = Date.now();
553
547
  this.logInfo('开始预加载数据');
554
- _context6.prev = 3;
555
- _context6.next = 6;
548
+ _context6.prev = 2;
549
+ _context6.next = 5;
556
550
  return this.loadScheduleFromSQLite();
557
- case 6:
551
+ case 5:
558
552
  cachedData = _context6.sent;
559
553
  if (!(cachedData && cachedData.length > 0)) {
560
- _context6.next = 14;
554
+ _context6.next = 12;
561
555
  break;
562
556
  }
563
- console.log("[Schedule] \u4ECE SQLite \u52A0\u8F7D\u4E86 ".concat(cachedData.length, " \u6761\u65E5\u7A0B\u6570\u636E"));
564
557
  // 将缓存数据放入 store
565
558
  this.store.scheduleList = cloneDeep(cachedData);
566
559
  // 同步更新 Map 缓存
@@ -572,23 +565,22 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
572
565
  source: 'SQLite'
573
566
  });
574
567
  return _context6.abrupt("return");
575
- case 14:
576
- console.log('[Schedule] SQLite 中没有缓存数据,从服务器加载...');
568
+ case 12:
577
569
  this.logInfo('SQLite 中没有缓存数据,准备从服务器加载');
578
- _context6.next = 23;
570
+ _context6.next = 20;
579
571
  break;
580
- case 18:
581
- _context6.prev = 18;
582
- _context6.t0 = _context6["catch"](3);
572
+ case 15:
573
+ _context6.prev = 15;
574
+ _context6.t0 = _context6["catch"](2);
583
575
  errorMessage = _context6.t0 instanceof Error ? _context6.t0.message : String(_context6.t0);
584
576
  console.warn('[Schedule] 从 SQLite 加载数据失败:', _context6.t0);
585
577
  this.logWarning('从 SQLite 加载数据失败,准备从服务器加载', {
586
578
  error: errorMessage
587
579
  });
588
- case 23:
589
- _context6.next = 25;
580
+ case 20:
581
+ _context6.next = 22;
590
582
  return this.loadAllSchedule();
591
- case 25:
583
+ case 22:
592
584
  scheduleList = _context6.sent;
593
585
  // 3. 将服务器数据放入 store
594
586
  if (scheduleList && scheduleList.length > 0) {
@@ -607,11 +599,11 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
607
599
  duration: "".concat(_duration3, "ms")
608
600
  });
609
601
  }
610
- case 27:
602
+ case 24:
611
603
  case "end":
612
604
  return _context6.stop();
613
605
  }
614
- }, _callee6, this, [[3, 18]]);
606
+ }, _callee6, this, [[2, 15]]);
615
607
  }));
616
608
  function preload() {
617
609
  return _preload.apply(this, arguments);
@@ -82,7 +82,6 @@ function buildPriceIndexMap(priceData) {
82
82
  export function applyPriceDataToProducts(products, priceData) {
83
83
  var t0 = performance.now();
84
84
  if (!priceData || priceData.length === 0) {
85
- console.log('[applyPriceDataToProducts] 没有价格数据,返回原商品');
86
85
  return products;
87
86
  }
88
87
  var t1 = performance.now();
@@ -370,6 +370,24 @@ function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
370
370
  }
371
371
  return record;
372
372
  }
373
+
374
+ /**
375
+ * merge hydrate 不会统一给所有商品补 saved 标记,因此先只标记远端已保存商品。
376
+ * 当前 tempOrder 中尚未提交的本地商品会在 merge 后继续保持 current item 语义。
377
+ */
378
+ function markLoadedSalesDetailProductsAsSaved(sourceRecord) {
379
+ if (!sourceRecord || _typeof(sourceRecord) !== 'object') return sourceRecord;
380
+ if (!Array.isArray(sourceRecord.products)) return sourceRecord;
381
+ return _objectSpread(_objectSpread({}, sourceRecord), {}, {
382
+ products: sourceRecord.products.map(function (product) {
383
+ return _objectSpread(_objectSpread({}, product || {}), {}, {
384
+ metadata: _objectSpread(_objectSpread({}, product !== null && product !== void 0 && product.metadata && _typeof(product.metadata) === 'object' ? product.metadata : {}), {}, {
385
+ is_edit_for_runtime: true
386
+ })
387
+ });
388
+ })
389
+ });
390
+ }
373
391
  export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
374
392
  _inherits(BaseSalesImpl, _BaseModule);
375
393
  var _super = _createSuper(BaseSalesImpl);
@@ -669,7 +687,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
669
687
  }, {
670
688
  key: "hydrateLatestLoadedSalesDetail",
671
689
  value: function () {
672
- var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence, hydrateSource) {
690
+ var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence, options) {
673
691
  var _this4 = this;
674
692
  var hydratedSales, skippedBeforeHydrate, hydrateTask, queuedTask;
675
693
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
@@ -679,7 +697,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
679
697
  skippedBeforeHydrate = false;
680
698
  hydrateTask = /*#__PURE__*/function () {
681
699
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
682
- var sales;
700
+ var hydrateOptions, sales;
683
701
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
684
702
  while (1) switch (_context4.prev = _context4.next) {
685
703
  case 0:
@@ -696,30 +714,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
696
714
  }
697
715
  throw new Error('order 模块未初始化');
698
716
  case 5:
699
- _context4.next = 7;
700
- return _this4.store.order.hydrateTempOrderFromRecord(record, hydrateSource === 'sessionStorage' ? {
701
- recalcOnHydrate: true,
702
- source: 'sessionStorage'
703
- } : {
717
+ hydrateOptions = {
704
718
  recalcOnHydrate: false
705
- });
706
- case 7:
719
+ };
720
+ if ((options === null || options === void 0 ? void 0 : options.hydrateSource) === 'sessionStorage') {
721
+ hydrateOptions = {
722
+ recalcOnHydrate: true,
723
+ source: 'sessionStorage'
724
+ };
725
+ } else if (options !== null && options !== void 0 && options.merge) {
726
+ hydrateOptions = {
727
+ recalcOnHydrate: true,
728
+ source: 'mergedSalesDetail'
729
+ };
730
+ }
731
+ _context4.next = 9;
732
+ return _this4.store.order.hydrateTempOrderFromRecord(record, hydrateOptions);
733
+ case 9:
707
734
  sales = _context4.sent;
708
735
  hydratedSales = sales;
709
736
 
710
737
  // hydrate 期间可能又发起了更新请求;后续任务已串行排队,将负责最终状态。
711
738
  if (!(loadSequence !== _this4.salesDetailLoadSequence)) {
712
- _context4.next = 11;
739
+ _context4.next = 13;
713
740
  break;
714
741
  }
715
742
  return _context4.abrupt("return");
716
- case 11:
743
+ case 13:
717
744
  _this4.currentSalesDetail = sales;
718
- _context4.next = 14;
745
+ _context4.next = 16;
719
746
  return _this4.core.effects.emit("".concat(_this4.name, ":onSalesOrderLoaded"), {
720
747
  sales: sales
721
748
  });
722
- case 14:
749
+ case 16:
723
750
  case "end":
724
751
  return _context4.stop();
725
752
  }
@@ -1534,7 +1561,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1534
1561
  key: "loadSalesDetail",
1535
1562
  value: (function () {
1536
1563
  var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderIdOrParams) {
1537
- var loadSequence, _ref27, _ref28, _ref29, _ref30, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, currentTempOrder, mergedRecord, record;
1564
+ var loadSequence, _ref27, _ref28, _ref29, _ref30, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, mergeSourceRecord, currentTempOrder, mergedRecord, record;
1538
1565
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1539
1566
  while (1) switch (_context14.prev = _context14.next) {
1540
1567
  case 0:
@@ -1586,39 +1613,43 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1586
1613
  loadedSalesDetail = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data; // payment_pending 只存在于本地;远端详情需过滤,但会话快照必须完整恢复。
1587
1614
  shouldFilterPendingPayments = params.hydrateSource !== 'sessionStorage';
1588
1615
  remoteRecord = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(loadedSalesDetail) : loadedSalesDetail;
1616
+ mergeSourceRecord = params.merge ? markLoadedSalesDetailProductsAsSaved(remoteRecord) : remoteRecord;
1589
1617
  currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
1590
- mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1618
+ mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, mergeSourceRecord, 'preserve-local') : mergeSourceRecord;
1591
1619
  record = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(mergedRecord) : mergedRecord;
1592
- _context14.next = 30;
1593
- return this.hydrateLatestLoadedSalesDetail(record, loadSequence, params.hydrateSource);
1594
- case 30:
1595
- return _context14.abrupt("return", _context14.sent);
1620
+ _context14.next = 31;
1621
+ return this.hydrateLatestLoadedSalesDetail(record, loadSequence, {
1622
+ hydrateSource: params.hydrateSource,
1623
+ merge: params.merge
1624
+ });
1596
1625
  case 31:
1597
- _context14.prev = 31;
1626
+ return _context14.abrupt("return", _context14.sent);
1627
+ case 32:
1628
+ _context14.prev = 32;
1598
1629
  this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
1599
1630
  if (!(this.salesDetailLoadInFlightCount === 0)) {
1600
- _context14.next = 42;
1631
+ _context14.next = 43;
1601
1632
  break;
1602
1633
  }
1603
- _context14.prev = 34;
1604
- _context14.next = 37;
1634
+ _context14.prev = 35;
1635
+ _context14.next = 38;
1605
1636
  return this.drainQueuedServerOrderChanges();
1606
- case 37:
1607
- _context14.next = 42;
1637
+ case 38:
1638
+ _context14.next = 43;
1608
1639
  break;
1609
- case 39:
1610
- _context14.prev = 39;
1611
- _context14.t1 = _context14["catch"](34);
1640
+ case 40:
1641
+ _context14.prev = 40;
1642
+ _context14.t1 = _context14["catch"](35);
1612
1643
  this.logError('drain queued server order changes failed', {
1613
1644
  error: _context14.t1 instanceof Error ? _context14.t1.message : String(_context14.t1)
1614
1645
  });
1615
- case 42:
1616
- return _context14.finish(31);
1617
1646
  case 43:
1647
+ return _context14.finish(32);
1648
+ case 44:
1618
1649
  case "end":
1619
1650
  return _context14.stop();
1620
1651
  }
1621
- }, _callee14, this, [[4,, 31, 43], [34, 39]]);
1652
+ }, _callee14, this, [[4,, 32, 44], [35, 40]]);
1622
1653
  }));
1623
1654
  function loadSalesDetail(_x13) {
1624
1655
  return _loadSalesDetail.apply(this, arguments);
@@ -2261,11 +2292,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2261
2292
  });
2262
2293
  case 40:
2263
2294
  if (!rulesModule) {
2264
- _context21.next = 77;
2295
+ _context21.next = 76;
2265
2296
  break;
2266
2297
  }
2267
2298
  orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
2268
- console.log('[BaseSales.applyDiscountConfig.calcDiscount]');
2269
2299
  result = rulesModule.calcDiscount({
2270
2300
  productList: tempOrder.products,
2271
2301
  discountList: nextDiscountList,
@@ -2282,22 +2312,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2282
2312
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2283
2313
  }
2284
2314
  _iterator2 = _createForOfIteratorHelper(tempOrder.products || []);
2285
- _context21.prev = 46;
2315
+ _context21.prev = 45;
2286
2316
  _iterator2.s();
2287
- case 48:
2317
+ case 47:
2288
2318
  if ((_step2 = _iterator2.n()).done) {
2289
- _context21.next = 63;
2319
+ _context21.next = 62;
2290
2320
  break;
2291
2321
  }
2292
2322
  product = _step2.value;
2293
2323
  productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
2294
2324
  runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
2295
2325
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
2296
- _context21.next = 54;
2326
+ _context21.next = 53;
2297
2327
  break;
2298
2328
  }
2299
- return _context21.abrupt("continue", 61);
2300
- case 54:
2329
+ return _context21.abrupt("continue", 60);
2330
+ case 53:
2301
2331
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
2302
2332
  return sum + Number(pd.amount || 0);
2303
2333
  }, 0);
@@ -2313,59 +2343,59 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2313
2343
  mainPrice: newMainSellingPrice,
2314
2344
  bundle: product.product_bundle
2315
2345
  });
2316
- case 61:
2317
- _context21.next = 48;
2346
+ case 60:
2347
+ _context21.next = 47;
2318
2348
  break;
2319
- case 63:
2320
- _context21.next = 68;
2349
+ case 62:
2350
+ _context21.next = 67;
2321
2351
  break;
2322
- case 65:
2323
- _context21.prev = 65;
2324
- _context21.t0 = _context21["catch"](46);
2352
+ case 64:
2353
+ _context21.prev = 64;
2354
+ _context21.t0 = _context21["catch"](45);
2325
2355
  _iterator2.e(_context21.t0);
2326
- case 68:
2327
- _context21.prev = 68;
2356
+ case 67:
2357
+ _context21.prev = 67;
2328
2358
  _iterator2.f();
2329
- return _context21.finish(68);
2330
- case 71:
2359
+ return _context21.finish(67);
2360
+ case 70:
2331
2361
  if (!result.discountList) {
2332
- _context21.next = 77;
2362
+ _context21.next = 76;
2333
2363
  break;
2334
2364
  }
2335
2365
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2336
2366
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2337
- _context21.next = 76;
2367
+ _context21.next = 75;
2338
2368
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2339
- case 76:
2369
+ case 75:
2340
2370
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
2341
2371
  return discount.isSelected;
2342
2372
  });
2343
- case 77:
2344
- _context21.next = 79;
2373
+ case 76:
2374
+ _context21.next = 78;
2345
2375
  return this.store.order.recalculateSummary({
2346
2376
  createIfMissing: true
2347
2377
  });
2348
- case 79:
2378
+ case 78:
2349
2379
  summary = _context21.sent;
2350
2380
  this.store.order.persistTempOrder();
2351
- _context21.next = 83;
2381
+ _context21.next = 82;
2352
2382
  return this.effectsEmit('onDiscountApplied', {
2353
2383
  productList: tempOrder.products || [],
2354
2384
  discountList: nextDiscountList,
2355
2385
  selectedDiscountList: tempOrder.discount_list || [],
2356
2386
  tempOrder: tempOrder
2357
2387
  });
2358
- case 83:
2388
+ case 82:
2359
2389
  return _context21.abrupt("return", {
2360
2390
  productList: tempOrder.products || [],
2361
2391
  discountList: nextDiscountList,
2362
2392
  availableWalletIds: this.getAvailableWalletIds()
2363
2393
  });
2364
- case 84:
2394
+ case 83:
2365
2395
  case "end":
2366
2396
  return _context21.stop();
2367
2397
  }
2368
- }, _callee21, this, [[46, 65, 68, 71]]);
2398
+ }, _callee21, this, [[45, 64, 67, 70]]);
2369
2399
  }));
2370
2400
  function loadDiscountConfig(_x16) {
2371
2401
  return _loadDiscountConfig.apply(this, arguments);
@@ -2409,11 +2439,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2409
2439
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2410
2440
  case 12:
2411
2441
  if (!rulesModule) {
2412
- _context22.next = 24;
2442
+ _context22.next = 23;
2413
2443
  break;
2414
2444
  }
2415
2445
  orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
2416
- console.log('[BaseSales.bestDiscount.calcDiscount]');
2417
2446
  result = rulesModule.calcDiscount({
2418
2447
  productList: tempOrder.products,
2419
2448
  discountList: nextDiscountList,
@@ -2427,14 +2456,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2427
2456
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2428
2457
  }
2429
2458
  if (!result.discountList) {
2430
- _context22.next = 24;
2459
+ _context22.next = 23;
2431
2460
  break;
2432
2461
  }
2433
2462
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2434
2463
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2435
- _context22.next = 22;
2464
+ _context22.next = 21;
2436
2465
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2437
- case 22:
2466
+ case 21:
2438
2467
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
2439
2468
  return discount.isSelected;
2440
2469
  });
@@ -2442,24 +2471,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2442
2471
  productList: tempOrder.products,
2443
2472
  discountList: nextDiscountList
2444
2473
  };
2445
- case 24:
2446
- _context22.next = 26;
2474
+ case 23:
2475
+ _context22.next = 25;
2447
2476
  return this.store.order.recalculateSummary({
2448
2477
  createIfMissing: true
2449
2478
  });
2450
- case 26:
2479
+ case 25:
2451
2480
  this.store.order.persistTempOrder();
2452
- _context22.next = 29;
2481
+ _context22.next = 28;
2453
2482
  return this.effectsEmit('onDiscountApplied', {
2454
2483
  productList: tempOrder.products || [],
2455
2484
  discountList: nextDiscountList,
2456
2485
  selectedDiscountList: tempOrder.discount_list || [],
2457
2486
  tempOrder: tempOrder
2458
2487
  });
2459
- case 29:
2488
+ case 28:
2460
2489
  cb === null || cb === void 0 || cb(result);
2461
2490
  return _context22.abrupt("return", result);
2462
- case 31:
2491
+ case 30:
2463
2492
  case "end":
2464
2493
  return _context22.stop();
2465
2494
  }
@@ -2628,7 +2657,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2628
2657
  case 13:
2629
2658
  if (rulesModule) {
2630
2659
  orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
2631
- console.log('[BaseSales.setDiscountSelected.calcDiscount]');
2632
2660
  result = rulesModule.calcDiscount({
2633
2661
  productList: tempOrder.products,
2634
2662
  discountList: updated,
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;