@pisell/pisellos 2.2.244 → 2.2.246

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 (316) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
  2. package/dist/model/strategy/adapter/walletPass/utils.js +7 -4
  3. package/dist/modules/BookingContext/index.d.ts +48 -0
  4. package/dist/modules/BookingContext/index.js +566 -0
  5. package/dist/modules/BookingContext/types.d.ts +102 -0
  6. package/dist/modules/BookingContext/types.js +51 -0
  7. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  8. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +284 -0
  9. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  10. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +148 -0
  11. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  12. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +218 -0
  13. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  14. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  15. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  16. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  17. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  18. package/dist/modules/BookingContext/utils/index.js +11 -0
  19. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  20. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  21. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  22. package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
  23. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  24. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  25. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  26. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  27. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  28. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  29. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  30. package/dist/modules/BookingContext/utils/resources.js +486 -0
  31. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  32. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  33. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  34. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  35. package/dist/modules/Cart/utils/cartProduct.js +24 -3
  36. package/dist/modules/Cart/utils/changePrice.js +11 -11
  37. package/dist/modules/Customer/index.d.ts +20 -0
  38. package/dist/modules/Customer/index.js +172 -83
  39. package/dist/modules/Customer/types.d.ts +2 -0
  40. package/dist/modules/Discount/index.d.ts +1 -1
  41. package/dist/modules/Discount/index.js +13 -6
  42. package/dist/modules/Discount/types.d.ts +1 -0
  43. package/dist/modules/OpenData/index.d.ts +8 -0
  44. package/dist/modules/OpenData/index.js +37 -17
  45. package/dist/modules/Order/index.d.ts +277 -18
  46. package/dist/modules/Order/index.js +3581 -779
  47. package/dist/modules/Order/types.d.ts +286 -31
  48. package/dist/modules/Order/types.js +38 -0
  49. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  50. package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
  51. package/dist/modules/Order/utils.d.ts +147 -5
  52. package/dist/modules/Order/utils.js +750 -104
  53. package/dist/modules/Payment/index.d.ts +10 -13
  54. package/dist/modules/Payment/index.js +467 -837
  55. package/dist/modules/Payment/types.d.ts +2 -0
  56. package/dist/modules/Payment/utils.js +2 -1
  57. package/dist/modules/Payment/walletpass.js +41 -25
  58. package/dist/modules/ProductList/index.d.ts +16 -12
  59. package/dist/modules/ProductList/index.js +133 -59
  60. package/dist/modules/ProductList/types.d.ts +14 -0
  61. package/dist/modules/Quotation/index.d.ts +0 -1
  62. package/dist/modules/Quotation/index.js +25 -22
  63. package/dist/modules/Rules/index.d.ts +4 -0
  64. package/dist/modules/Rules/index.js +97 -70
  65. package/dist/modules/Rules/types.d.ts +1 -0
  66. package/dist/modules/SalesSummary/index.d.ts +8 -25
  67. package/dist/modules/SalesSummary/index.js +86 -35
  68. package/dist/modules/SalesSummary/types.d.ts +4 -1
  69. package/dist/modules/SalesSummary/utils.d.ts +2 -25
  70. package/dist/modules/SalesSummary/utils.js +794 -162
  71. package/dist/modules/Schedule/index.d.ts +7 -0
  72. package/dist/modules/Schedule/index.js +24 -2
  73. package/dist/modules/Summary/index.js +4 -3
  74. package/dist/modules/SurchargeList/index.d.ts +16 -0
  75. package/dist/modules/SurchargeList/index.js +162 -0
  76. package/dist/modules/SurchargeList/types.d.ts +11 -0
  77. package/dist/modules/SurchargeList/types.js +1 -0
  78. package/dist/modules/index.d.ts +2 -0
  79. package/dist/modules/index.js +3 -1
  80. package/dist/plugins/request.d.ts +1 -0
  81. package/dist/server/index.d.ts +204 -1
  82. package/dist/server/index.js +3654 -922
  83. package/dist/server/modules/index.d.ts +2 -0
  84. package/dist/server/modules/index.js +2 -0
  85. package/dist/server/modules/order/index.d.ts +120 -3
  86. package/dist/server/modules/order/index.js +1762 -448
  87. package/dist/server/modules/order/types.d.ts +32 -3
  88. package/dist/server/modules/order/types.js +8 -0
  89. package/dist/server/modules/order/utils/filterBookings.js +26 -3
  90. package/dist/server/modules/order/utils/filterOrders.js +23 -8
  91. package/dist/server/modules/payment/index.d.ts +28 -0
  92. package/dist/server/modules/payment/index.js +305 -0
  93. package/dist/server/modules/payment/types.d.ts +9 -0
  94. package/dist/server/modules/payment/types.js +1 -0
  95. package/dist/server/modules/products/index.d.ts +34 -7
  96. package/dist/server/modules/products/index.js +631 -317
  97. package/dist/server/modules/resource/index.d.ts +2 -0
  98. package/dist/server/modules/resource/index.js +29 -3
  99. package/dist/server/modules/schedule/index.d.ts +4 -4
  100. package/dist/server/modules/schedule/index.js +111 -88
  101. package/dist/server/test.json +713 -0
  102. package/dist/server/utils/small-ticket.d.ts +71 -0
  103. package/dist/server/utils/small-ticket.js +840 -0
  104. package/dist/solution/BaseSales/index.d.ts +133 -10
  105. package/dist/solution/BaseSales/index.js +1950 -447
  106. package/dist/solution/BaseSales/types.d.ts +82 -6
  107. package/dist/solution/BaseSales/types.js +5 -4
  108. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  109. package/dist/solution/BaseSales/utils/cartPromotion.js +1438 -0
  110. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  111. package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
  112. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  113. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +105 -24
  114. package/dist/solution/BaseSales/utils.d.ts +1 -1
  115. package/dist/solution/BaseSales/utils.js +62 -21
  116. package/dist/solution/BookingByStep/index.d.ts +1 -1
  117. package/dist/solution/BookingTicket/index.d.ts +271 -11
  118. package/dist/solution/BookingTicket/index.js +1777 -242
  119. package/dist/solution/BookingTicket/types.d.ts +118 -1
  120. package/dist/solution/BookingTicket/types.js +41 -2
  121. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  122. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  123. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  124. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
  125. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  126. package/dist/solution/BookingTicket/utils/bookingStatus.js +70 -0
  127. package/dist/solution/BookingTicket/utils/cartView.d.ts +9 -1
  128. package/dist/solution/BookingTicket/utils/cartView.js +94 -7
  129. package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  130. package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
  131. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  132. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
  133. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  134. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
  135. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  136. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
  137. package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  138. package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
  139. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  140. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
  141. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  142. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
  143. package/dist/solution/Checkout/index.d.ts +1 -0
  144. package/dist/solution/Checkout/index.js +10 -9
  145. package/dist/solution/RegisterAndLogin/config.js +2 -10
  146. package/dist/solution/ScanOrder/index.d.ts +9 -3
  147. package/dist/solution/ScanOrder/index.js +241 -134
  148. package/dist/solution/ScanOrder/types.d.ts +9 -5
  149. package/dist/solution/ScanOrder/types.js +2 -3
  150. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  151. package/dist/solution/ScanOrder/utils.js +84 -22
  152. package/dist/solution/VenueBooking/index.d.ts +5 -2
  153. package/dist/solution/VenueBooking/index.js +110 -59
  154. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  155. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  156. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  157. package/dist/types/index.d.ts +10 -0
  158. package/lib/model/strategy/adapter/promotion/evaluator.js +2 -1
  159. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  160. package/lib/model/strategy/adapter/walletPass/utils.js +3 -2
  161. package/lib/modules/BookingContext/index.d.ts +48 -0
  162. package/lib/modules/BookingContext/index.js +368 -0
  163. package/lib/modules/BookingContext/types.d.ts +102 -0
  164. package/lib/modules/BookingContext/types.js +34 -0
  165. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  166. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +276 -0
  167. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  168. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +154 -0
  169. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  170. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +201 -0
  171. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  172. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  173. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  174. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  175. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  176. package/lib/modules/BookingContext/utils/index.js +43 -0
  177. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  178. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  179. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  180. package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
  181. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  182. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  183. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  184. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  185. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  186. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  187. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  188. package/lib/modules/BookingContext/utils/resources.js +377 -0
  189. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  190. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  191. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  192. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  193. package/lib/modules/Cart/utils/cartProduct.js +20 -3
  194. package/lib/modules/Cart/utils/changePrice.js +12 -20
  195. package/lib/modules/Customer/index.d.ts +20 -0
  196. package/lib/modules/Customer/index.js +64 -11
  197. package/lib/modules/Customer/types.d.ts +2 -0
  198. package/lib/modules/Discount/index.d.ts +1 -1
  199. package/lib/modules/Discount/index.js +9 -1
  200. package/lib/modules/Discount/types.d.ts +1 -0
  201. package/lib/modules/OpenData/index.d.ts +8 -0
  202. package/lib/modules/OpenData/index.js +19 -5
  203. package/lib/modules/Order/index.d.ts +277 -18
  204. package/lib/modules/Order/index.js +2317 -337
  205. package/lib/modules/Order/types.d.ts +286 -31
  206. package/lib/modules/Order/types.js +1 -0
  207. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  208. package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
  209. package/lib/modules/Order/utils.d.ts +147 -5
  210. package/lib/modules/Order/utils.js +615 -46
  211. package/lib/modules/Payment/index.d.ts +10 -13
  212. package/lib/modules/Payment/index.js +18 -150
  213. package/lib/modules/Payment/types.d.ts +2 -0
  214. package/lib/modules/Payment/utils.js +2 -1
  215. package/lib/modules/Payment/walletpass.js +16 -3
  216. package/lib/modules/ProductList/index.d.ts +16 -12
  217. package/lib/modules/ProductList/index.js +41 -4
  218. package/lib/modules/ProductList/types.d.ts +14 -0
  219. package/lib/modules/Quotation/index.d.ts +0 -1
  220. package/lib/modules/Quotation/index.js +19 -16
  221. package/lib/modules/Rules/index.d.ts +4 -0
  222. package/lib/modules/Rules/index.js +137 -120
  223. package/lib/modules/Rules/types.d.ts +1 -0
  224. package/lib/modules/SalesSummary/index.d.ts +8 -25
  225. package/lib/modules/SalesSummary/index.js +30 -4
  226. package/lib/modules/SalesSummary/types.d.ts +4 -1
  227. package/lib/modules/SalesSummary/utils.d.ts +2 -25
  228. package/lib/modules/SalesSummary/utils.js +645 -91
  229. package/lib/modules/Schedule/index.d.ts +7 -0
  230. package/lib/modules/Schedule/index.js +17 -1
  231. package/lib/modules/Summary/index.js +5 -4
  232. package/lib/modules/SurchargeList/index.d.ts +16 -0
  233. package/lib/modules/SurchargeList/index.js +89 -0
  234. package/lib/modules/SurchargeList/types.d.ts +11 -0
  235. package/lib/modules/SurchargeList/types.js +17 -0
  236. package/lib/modules/index.d.ts +2 -0
  237. package/lib/modules/index.js +5 -1
  238. package/lib/plugins/request.d.ts +1 -0
  239. package/lib/server/index.d.ts +204 -1
  240. package/lib/server/index.js +1891 -59
  241. package/lib/server/modules/index.d.ts +2 -0
  242. package/lib/server/modules/index.js +3 -0
  243. package/lib/server/modules/order/index.d.ts +120 -3
  244. package/lib/server/modules/order/index.js +887 -94
  245. package/lib/server/modules/order/types.d.ts +32 -3
  246. package/lib/server/modules/order/utils/filterBookings.js +24 -5
  247. package/lib/server/modules/order/utils/filterOrders.js +15 -6
  248. package/lib/server/modules/payment/index.d.ts +28 -0
  249. package/lib/server/modules/payment/index.js +192 -0
  250. package/lib/server/modules/payment/types.d.ts +9 -0
  251. package/lib/server/modules/payment/types.js +17 -0
  252. package/lib/server/modules/products/index.d.ts +34 -7
  253. package/lib/server/modules/products/index.js +189 -54
  254. package/lib/server/modules/resource/index.d.ts +2 -0
  255. package/lib/server/modules/resource/index.js +27 -3
  256. package/lib/server/modules/schedule/index.d.ts +4 -4
  257. package/lib/server/modules/schedule/index.js +47 -40
  258. package/lib/server/test.json +713 -0
  259. package/lib/server/utils/small-ticket.d.ts +71 -0
  260. package/lib/server/utils/small-ticket.js +800 -0
  261. package/lib/solution/BaseSales/index.d.ts +133 -10
  262. package/lib/solution/BaseSales/index.js +1111 -63
  263. package/lib/solution/BaseSales/types.d.ts +82 -6
  264. package/lib/solution/BaseSales/types.js +3 -1
  265. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  266. package/lib/solution/BaseSales/utils/cartPromotion.js +992 -0
  267. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  268. package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
  269. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  270. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +106 -18
  271. package/lib/solution/BaseSales/utils.d.ts +1 -1
  272. package/lib/solution/BaseSales/utils.js +54 -10
  273. package/lib/solution/BookingByStep/index.d.ts +1 -1
  274. package/lib/solution/BookingTicket/index.d.ts +271 -11
  275. package/lib/solution/BookingTicket/index.js +922 -29
  276. package/lib/solution/BookingTicket/types.d.ts +118 -1
  277. package/lib/solution/BookingTicket/types.js +11 -0
  278. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  279. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  280. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  281. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
  282. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  283. package/lib/solution/BookingTicket/utils/bookingStatus.js +44 -2
  284. package/lib/solution/BookingTicket/utils/cartView.d.ts +9 -1
  285. package/lib/solution/BookingTicket/utils/cartView.js +61 -6
  286. package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  287. package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
  288. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  289. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
  290. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  291. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
  292. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  293. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
  294. package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  295. package/lib/solution/BookingTicket/utils/scan/index.js +17 -3
  296. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  297. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
  298. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  299. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
  300. package/lib/solution/Checkout/index.d.ts +1 -0
  301. package/lib/solution/Checkout/index.js +1 -2
  302. package/lib/solution/RegisterAndLogin/config.js +2 -10
  303. package/lib/solution/ScanOrder/index.d.ts +9 -3
  304. package/lib/solution/ScanOrder/index.js +153 -70
  305. package/lib/solution/ScanOrder/types.d.ts +9 -5
  306. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  307. package/lib/solution/ScanOrder/utils.js +83 -17
  308. package/lib/solution/VenueBooking/index.d.ts +5 -2
  309. package/lib/solution/VenueBooking/index.js +54 -17
  310. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  311. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  312. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  313. package/lib/types/index.d.ts +10 -0
  314. package/package.json +1 -1
  315. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  316. package/lib/solution/Checkout/appointmentDemo.json +0 -1
@@ -28,6 +28,7 @@ var import_types = require("./types");
28
28
  var import_product = require("../../utils/product");
29
29
  var INDEXDB_STORE_NAME = "products";
30
30
  var PRODUCT_SYNC_DEBOUNCE_MS = 1e4;
31
+ var PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS = 3e4;
31
32
  var ProductsModule = class extends import_BaseModule.BaseModule {
32
33
  constructor(name, version) {
33
34
  super(name, version);
@@ -44,7 +45,14 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
44
45
  this.formatters = [];
45
46
  // 是否已注册内置价格格式化器
46
47
  this.isPriceFormatterRegistered = false;
48
+ this.quotationBridgeLoadedKey = "";
47
49
  this.pendingSyncMessages = [];
50
+ /** 最近一次 SSE 全量拉取完成时间 */
51
+ this.lastServerFullFetchAtMs = 0;
52
+ /** 最近一次 preload 完成时间(含 IndexDB 命中) */
53
+ this.lastPreloadCompletedAtMs = 0;
54
+ /** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
55
+ this.productIndexDBSaveQueue = Promise.resolve();
48
56
  }
49
57
  async initialize(core, options) {
50
58
  var _a;
@@ -177,7 +185,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
177
185
  * Server 层负责传入完整 schedule 模块,Products 只负责把报价单计算结果转成价格响应形状。
178
186
  */
179
187
  async setupQuotationPriceBridge(params) {
180
- var _a, _b, _c;
188
+ var _a;
181
189
  if (!this.core) {
182
190
  this.logWarning("setupQuotationPriceBridge: core 尚未初始化");
183
191
  return;
@@ -190,15 +198,25 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
190
198
  this.quotationPriceBridge = quotation;
191
199
  }
192
200
  if (params.scheduleModule) {
193
- const scheduleList = ((_c = (_b = params.scheduleModule).getScheduleList) == null ? void 0 : _c.call(_b)) || [];
194
- const scheduleMap = new Map(
195
- scheduleList.map((schedule) => [schedule.id, schedule])
196
- );
201
+ const scheduleCache = /* @__PURE__ */ new Map();
202
+ let hasLoadedScheduleList = false;
197
203
  this.quotationPriceBridge.setScheduleResolver((id) => {
198
- var _a2, _b2;
199
- if (scheduleMap.has(id))
200
- return scheduleMap.get(id);
201
- const schedules = ((_b2 = (_a2 = params.scheduleModule).getScheduleByIds) == null ? void 0 : _b2.call(_a2, [id])) || [];
204
+ var _a2, _b, _c, _d, _e, _f;
205
+ const scheduleId = String(id);
206
+ if (scheduleCache.has(scheduleId))
207
+ return scheduleCache.get(scheduleId);
208
+ if (!hasLoadedScheduleList) {
209
+ const scheduleList = ((_b = (_a2 = params.scheduleModule).getScheduleList) == null ? void 0 : _b.call(_a2)) || [];
210
+ for (const schedule of scheduleList) {
211
+ scheduleCache.set(String(schedule.id), schedule);
212
+ }
213
+ hasLoadedScheduleList = true;
214
+ }
215
+ if (scheduleCache.has(scheduleId))
216
+ return scheduleCache.get(scheduleId);
217
+ const schedules = ((_d = (_c = params.scheduleModule).getScheduleListByIds) == null ? void 0 : _d.call(_c, [id])) || ((_f = (_e = params.scheduleModule).getScheduleByIds) == null ? void 0 : _f.call(_e, [id])) || [];
218
+ if (schedules[0])
219
+ scheduleCache.set(scheduleId, schedules[0]);
202
220
  return schedules[0];
203
221
  });
204
222
  }
@@ -210,8 +228,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
210
228
  async refreshQuotationPriceBridge(params) {
211
229
  if (!this.quotationPriceBridge)
212
230
  return;
213
- const customerId = params && "customer_id" in params ? params.customer_id : this.quotationBridgeCustomerId;
214
- const refreshKey = this.getQuotationBridgeScopeKey(customerId);
231
+ const refreshKey = this.getQuotationBridgeScopeKey();
215
232
  if (this.quotationBridgeRefreshPromise && this.quotationBridgeRefreshKey === refreshKey) {
216
233
  await this.quotationBridgeRefreshPromise;
217
234
  return;
@@ -221,10 +238,9 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
221
238
  }
222
239
  this.quotationBridgeRefreshKey = refreshKey;
223
240
  this.quotationBridgeRefreshPromise = this.quotationPriceBridge.loadQuotations({
224
- channel: this.quotationBridgeChannel,
225
- customer_id: customerId
241
+ channel: this.quotationBridgeChannel
226
242
  }).then(() => {
227
- this.quotationBridgeCustomerId = customerId;
243
+ this.quotationBridgeLoadedKey = refreshKey;
228
244
  }).finally(() => {
229
245
  this.quotationBridgeRefreshPromise = void 0;
230
246
  this.quotationBridgeRefreshKey = void 0;
@@ -243,12 +259,12 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
243
259
  if (this.quotationBridgeRefreshPromise) {
244
260
  await this.quotationBridgeRefreshPromise;
245
261
  }
246
- if (this.getQuotationBridgeScopeKey(customerId) !== this.getQuotationBridgeScopeKey(this.quotationBridgeCustomerId)) {
262
+ if (this.getQuotationBridgeScopeKey() !== this.quotationBridgeLoadedKey) {
247
263
  await this.refreshQuotationPriceBridge({ customer_id: customerId });
248
264
  }
249
265
  }
250
- getQuotationBridgeScopeKey(customerId) {
251
- return `${this.quotationBridgeChannel || ""}:${customerId ?? ""}`;
266
+ getQuotationBridgeScopeKey() {
267
+ return this.quotationBridgeChannel || "";
252
268
  }
253
269
  buildPriceDataFromQuotation(product, datetime, customerId) {
254
270
  var _a;
@@ -258,10 +274,11 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
258
274
  customer_id: customerId
259
275
  });
260
276
  const productPrice = quotedPrice ?? product.price;
277
+ const productBasePrice = quotedPrice ?? product.base_price ?? product.price ?? 0;
261
278
  return {
262
279
  id: product.id,
263
280
  price: String(productPrice ?? 0),
264
- base_price: String(product.base_price ?? product.price ?? 0),
281
+ base_price: String(productBasePrice),
265
282
  variant: this.buildVariantPriceData(product, datetime, customerId),
266
283
  bundle_group: this.buildBundleGroupPriceData(product, datetime, customerId)
267
284
  };
@@ -278,7 +295,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
278
295
  customer_id: customerId
279
296
  });
280
297
  const price = quotedPrice ?? variant.price ?? product.price ?? 0;
281
- const basePrice = variant.base_price ?? variant.price ?? product.base_price ?? product.price ?? 0;
298
+ const basePrice = quotedPrice ?? variant.base_price ?? variant.price ?? product.base_price ?? product.price ?? 0;
282
299
  return {
283
300
  id: Number(variant.id),
284
301
  product_id: Number(variant.product_id ?? product.id),
@@ -303,7 +320,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
303
320
  customer_id: customerId
304
321
  });
305
322
  const price = quotedPrice ?? item.price ?? 0;
306
- const basePrice = item.base_price ?? item.price ?? 0;
323
+ const basePrice = quotedPrice ?? item.base_price ?? item.price ?? 0;
307
324
  return {
308
325
  id: Number(item.id),
309
326
  product_id: Number(item.product_id ?? product.id),
@@ -704,7 +721,8 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
704
721
  productCount: list.length,
705
722
  duration: `${Math.round(performance.now() - t0)}ms`
706
723
  });
707
- await this.saveProductsToIndexDB(list);
724
+ await this.replaceProductsSnapshotInIndexDB(list, "loadProductsByServer");
725
+ this.lastServerFullFetchAtMs = Date.now();
708
726
  await this.core.effects.emit(import_types.ProductsHooks.onProductsLoaded, list);
709
727
  (0, import_product.perfMark)("loadProductsByServer", performance.now() - t0, { count: list.length });
710
728
  return list;
@@ -803,7 +821,8 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
803
821
  async loadProductsByServerHttp(params) {
804
822
  const productList = await this.fetchProductsByHttp(params);
805
823
  if (productList.length > 0) {
806
- await this.saveProductsToIndexDB(productList);
824
+ await this.replaceProductsSnapshotInIndexDB(productList, "loadProductsByServerHttp");
825
+ this.lastServerFullFetchAtMs = Date.now();
807
826
  await this.core.effects.emit(import_types.ProductsHooks.onProductsLoaded, productList);
808
827
  }
809
828
  return productList;
@@ -942,33 +961,86 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
942
961
  }
943
962
  }
944
963
  /**
945
- * 保存商品数据到 IndexDB(平铺存储)
946
- * @private
964
+ * 串行执行商品 IndexDB 写入,避免快照替换与增量 patch 并发交错。
965
+ *
966
+ * @example
967
+ * await this.runInProductIndexDBSaveQueue(async () => {
968
+ * await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products)
969
+ * })
947
970
  */
948
- async saveProductsToIndexDB(products) {
971
+ async runInProductIndexDBSaveQueue(task) {
972
+ const queuedTask = this.productIndexDBSaveQueue.then(task, task);
973
+ this.productIndexDBSaveQueue = queuedTask.then(() => void 0, () => void 0);
974
+ return queuedTask;
975
+ }
976
+ /**
977
+ * 全量快照写入 IndexDB:clear + bulkUpdate,仅用于 SSE/HTTP 全量拉取。
978
+ *
979
+ * @example
980
+ * await this.replaceProductsSnapshotInIndexDB(list, 'loadProductsByServer')
981
+ */
982
+ async replaceProductsSnapshotInIndexDB(products, source) {
949
983
  if (!this.dbManager) {
950
- this.logWarning("saveProductsToIndexDB: dbManager 不可用");
984
+ this.logWarning("replaceProductsSnapshotInIndexDB: dbManager 不可用");
951
985
  return;
952
986
  }
953
- this.logInfo("开始保存商品数据到 IndexDB", { productCount: products.length });
954
987
  try {
955
- const t0 = performance.now();
956
- await this.dbManager.clear(INDEXDB_STORE_NAME);
957
- await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
958
- (0, import_product.perfMark)("saveProductsToIndexDB", performance.now() - t0, { count: products.length });
959
- console.log(
960
- `[Products] 已将 ${products.length} 个商品平铺保存到 IndexDB`
961
- );
962
- this.logInfo("商品数据已保存到 IndexDB", { productCount: products.length });
988
+ await this.runInProductIndexDBSaveQueue(async () => {
989
+ this.logInfo("replaceProductsSnapshotInIndexDB 开始", { source, productCount: products.length });
990
+ const t0 = performance.now();
991
+ await this.dbManager.clear(INDEXDB_STORE_NAME);
992
+ if (products.length > 0) {
993
+ await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
994
+ }
995
+ (0, import_product.perfMark)("replaceProductsSnapshotInIndexDB", performance.now() - t0, { count: products.length });
996
+ this.logInfo("replaceProductsSnapshotInIndexDB 完成", { source, productCount: products.length });
997
+ });
963
998
  } catch (error) {
964
999
  const errorMessage = error instanceof Error ? error.message : String(error);
965
- console.error("[Products] 保存数据到 IndexDB 失败:", error);
966
- this.logError("保存数据到 IndexDB 失败", {
1000
+ this.logError("全量保存商品到 IndexDB 失败", {
1001
+ source,
967
1002
  productCount: products.length,
968
1003
  error: errorMessage
969
1004
  });
970
1005
  }
971
1006
  }
1007
+ /**
1008
+ * 增量 upsert 商品到 IndexDB,不清空表;用于 pubsub 批次合并后的变更商品。
1009
+ *
1010
+ * @example
1011
+ * await this.patchProductsInIndexDB(changedProducts, 'pubsub.processProductSyncMessages', mergeActions)
1012
+ */
1013
+ async patchProductsInIndexDB(products, source, mergeActions = {}) {
1014
+ if (!this.dbManager || products.length === 0) {
1015
+ return;
1016
+ }
1017
+ const validProducts = products.filter((p) => (p == null ? void 0 : p.id) !== void 0 && (p == null ? void 0 : p.id) !== null);
1018
+ if (validProducts.length === 0) {
1019
+ return;
1020
+ }
1021
+ try {
1022
+ await this.runInProductIndexDBSaveQueue(async () => {
1023
+ this.logInfo("patchProductsInIndexDB 开始", { source, count: validProducts.length });
1024
+ const t0 = performance.now();
1025
+ if (typeof this.dbManager.bulkUpdate === "function") {
1026
+ await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, validProducts);
1027
+ } else if (typeof this.dbManager.update === "function") {
1028
+ for (const product of validProducts) {
1029
+ await this.dbManager.update(INDEXDB_STORE_NAME, product);
1030
+ }
1031
+ }
1032
+ (0, import_product.perfMark)("patchProductsInIndexDB", performance.now() - t0, { count: validProducts.length });
1033
+ this.logInfo("patchProductsInIndexDB 完成", { source, count: validProducts.length });
1034
+ });
1035
+ } catch (error) {
1036
+ const errorMessage = error instanceof Error ? error.message : String(error);
1037
+ this.logError("增量保存商品到 IndexDB 失败", {
1038
+ source,
1039
+ error: errorMessage,
1040
+ productCount: validProducts.length
1041
+ });
1042
+ }
1043
+ }
972
1044
  /**
973
1045
  * 同步更新商品 Map 缓存
974
1046
  * 将 list 中的商品同步到 map,以 id 为 key
@@ -1013,6 +1085,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
1013
1085
  duration: `${Math.round(performance.now() - tTotal)}ms`,
1014
1086
  source: "IndexDB"
1015
1087
  });
1088
+ this.lastPreloadCompletedAtMs = Date.now();
1016
1089
  return;
1017
1090
  }
1018
1091
  console.log("[Products] IndexDB 中没有缓存数据,从服务器加载...");
@@ -1040,6 +1113,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
1040
1113
  duration: `${Math.round(performance.now() - tTotal)}ms`,
1041
1114
  source: "Server"
1042
1115
  });
1116
+ this.lastPreloadCompletedAtMs = Date.now();
1043
1117
  } else {
1044
1118
  (0, import_product.perfMark)("preload(empty)", performance.now() - tTotal, { source: "empty" });
1045
1119
  this.logWarning("预加载完成但未获取到数据", {
@@ -1096,10 +1170,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
1096
1170
  this.productDataSource.run({
1097
1171
  pubsub: {
1098
1172
  callback: (res) => {
1099
- console.log("sse_products_callback", res);
1100
- this.logInfo("sse_products_callback: 收到同步消息", {
1101
- data: res == null ? void 0 : res.data
1102
- });
1103
1173
  if (!(res == null ? void 0 : res.data))
1104
1174
  return;
1105
1175
  const data = res.data;
@@ -1195,19 +1265,50 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
1195
1265
  if (uniqueDeleteIds.length > 0) {
1196
1266
  await this.removeProductsByIds(uniqueDeleteIds);
1197
1267
  }
1268
+ const patchProductMap = /* @__PURE__ */ new Map();
1269
+ const patchMergeActions = {};
1270
+ let storeMutated = uniqueDeleteIds.length > 0;
1198
1271
  if (bodyUpdates.size > 0) {
1199
- await this.applyBodyUpdatesToStore(bodyUpdates);
1272
+ const bodyResult = await this.applyBodyUpdatesToStore(bodyUpdates, {
1273
+ skipIndexDB: true,
1274
+ skipEmit: true
1275
+ });
1276
+ for (const product of bodyResult.changedProducts) {
1277
+ patchProductMap.set(product.id, product);
1278
+ patchMergeActions[product.id] = bodyResult.mergeActions[product.id];
1279
+ }
1280
+ storeMutated = true;
1200
1281
  }
1282
+ let freshProducts = [];
1201
1283
  if (uniqueSSEIds.length > 0) {
1202
- const freshProducts = await this.fetchProductsBySSE(uniqueSSEIds);
1284
+ freshProducts = await this.fetchProductsBySSE(uniqueSSEIds);
1203
1285
  if (freshProducts.length > 0) {
1204
- await this.mergeProductsToStore(freshProducts);
1286
+ const mergeResult = await this.mergeProductsToStore(freshProducts, {
1287
+ skipIndexDB: true,
1288
+ skipEmit: true
1289
+ });
1290
+ for (const product of mergeResult.changedProducts) {
1291
+ patchProductMap.set(product.id, product);
1292
+ patchMergeActions[product.id] = mergeResult.mergeActions[product.id];
1293
+ }
1294
+ storeMutated = true;
1205
1295
  }
1206
1296
  this.logInfo("processProductSyncMessages: SSE 增量更新完成123", {
1207
1297
  requestedCount: uniqueSSEIds.length,
1208
1298
  receivedCount: freshProducts.length
1209
1299
  });
1210
1300
  }
1301
+ const patchProducts = [...patchProductMap.values()];
1302
+ if (patchProducts.length > 0) {
1303
+ await this.patchProductsInIndexDB(
1304
+ patchProducts,
1305
+ "pubsub.processProductSyncMessages",
1306
+ patchMergeActions
1307
+ );
1308
+ }
1309
+ if (storeMutated) {
1310
+ this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
1311
+ }
1211
1312
  const allChangedIds = [.../* @__PURE__ */ new Set([
1212
1313
  ...Array.from(bodyUpdates.keys()),
1213
1314
  ...uniqueSSEIds,
@@ -1271,19 +1372,26 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
1271
1372
  /**
1272
1373
  * 将 body 完整数据直接覆盖到本地 store(不调用报价单接口)
1273
1374
  * 已存在的 → 直接替换;不存在的 → 追加
1274
- * 同时更新 Map 缓存、IndexDB,触发 onProductsChanged
1275
- * 价格缓存由 processProductSyncMessages 末尾统一清除
1375
+ *
1376
+ * @example
1377
+ * await this.applyBodyUpdatesToStore(bodyUpdates, { skipIndexDB: true })
1276
1378
  */
1277
- async applyBodyUpdatesToStore(bodyUpdates) {
1379
+ async applyBodyUpdatesToStore(bodyUpdates, options) {
1380
+ const changedProductIds = [...bodyUpdates.keys()];
1278
1381
  this.logInfo("applyBodyUpdatesToStore: 开始", { count: bodyUpdates.size });
1279
1382
  let updatedCount = 0;
1280
1383
  let newCount = 0;
1281
1384
  const appliedIds = /* @__PURE__ */ new Set();
1385
+ const mergeActions = {};
1386
+ const changedProducts = [];
1282
1387
  this.store.list = this.store.list.map((p) => {
1283
1388
  if (bodyUpdates.has(p.id)) {
1284
1389
  updatedCount++;
1285
1390
  appliedIds.add(p.id);
1286
- return bodyUpdates.get(p.id);
1391
+ mergeActions[p.id] = "update";
1392
+ const next = bodyUpdates.get(p.id);
1393
+ changedProducts.push(next);
1394
+ return next;
1287
1395
  }
1288
1396
  return p;
1289
1397
  });
@@ -1291,31 +1399,44 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
1291
1399
  if (!appliedIds.has(id)) {
1292
1400
  this.store.list.push(body);
1293
1401
  newCount++;
1402
+ mergeActions[id] = "insert";
1403
+ changedProducts.push(body);
1294
1404
  }
1295
1405
  }
1296
1406
  this.syncProductsMap();
1297
- await this.saveProductsToIndexDB(this.store.list);
1298
- this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
1407
+ if (!(options == null ? void 0 : options.skipIndexDB)) {
1408
+ await this.patchProductsInIndexDB(changedProducts, "pubsub.bodyUpdate", mergeActions);
1409
+ }
1410
+ if (!(options == null ? void 0 : options.skipEmit)) {
1411
+ this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
1412
+ }
1299
1413
  this.logInfo("applyBodyUpdatesToStore: 完成", {
1300
1414
  updatedCount,
1301
1415
  newCount,
1302
1416
  totalCount: this.store.list.length
1303
1417
  });
1418
+ return { changedProducts, mergeActions, updatedCount, newCount };
1304
1419
  }
1305
1420
  /**
1306
1421
  * 将增量拉取的商品合并到 store
1307
1422
  * 已存在的 → 替换;新的 → 追加
1308
- * 同时更新 store.map、IndexDB,触发 onProductsChanged
1423
+ *
1424
+ * @example
1425
+ * await this.mergeProductsToStore(freshProducts, { skipIndexDB: true })
1309
1426
  */
1310
- async mergeProductsToStore(freshProducts) {
1427
+ async mergeProductsToStore(freshProducts, options) {
1311
1428
  const freshMap = /* @__PURE__ */ new Map();
1312
1429
  for (const p of freshProducts) {
1313
1430
  freshMap.set(p.id, p);
1314
1431
  }
1432
+ const mergeActions = {};
1433
+ const changedProducts = [];
1315
1434
  const updatedList = this.store.list.map((p) => {
1316
1435
  if (freshMap.has(p.id)) {
1317
1436
  const fresh = freshMap.get(p.id);
1318
1437
  freshMap.delete(p.id);
1438
+ mergeActions[p.id] = "update";
1439
+ changedProducts.push(fresh);
1319
1440
  return fresh;
1320
1441
  }
1321
1442
  return p;
@@ -1323,17 +1444,25 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
1323
1444
  const newCount = freshMap.size;
1324
1445
  for (const p of freshMap.values()) {
1325
1446
  updatedList.push(p);
1447
+ mergeActions[p.id] = "insert";
1448
+ changedProducts.push(p);
1326
1449
  }
1327
1450
  const updatedCount = freshProducts.length - newCount;
1451
+ const changedProductIds = freshProducts.map((p) => p.id);
1328
1452
  this.store.list = updatedList;
1329
1453
  this.syncProductsMap();
1330
- await this.saveProductsToIndexDB(this.store.list);
1454
+ if (!(options == null ? void 0 : options.skipIndexDB)) {
1455
+ await this.patchProductsInIndexDB(changedProducts, "pubsub.mergeProductsToStore", mergeActions);
1456
+ }
1457
+ if (!(options == null ? void 0 : options.skipEmit)) {
1458
+ this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
1459
+ }
1331
1460
  this.logInfo("mergeProductsToStore: 合并完成", {
1332
1461
  updatedCount,
1333
1462
  newCount,
1334
1463
  totalCount: this.store.list.length
1335
1464
  });
1336
- this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
1465
+ return { changedProducts, mergeActions, updatedCount, newCount };
1337
1466
  }
1338
1467
  /**
1339
1468
  * 静默全量刷新:后台重新拉取全量 SSE 数据并更新本地
@@ -1342,6 +1471,12 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
1342
1471
  */
1343
1472
  async silentRefresh() {
1344
1473
  const t0 = performance.now();
1474
+ const now = Date.now();
1475
+ const elapsedSincePreload = now - this.lastPreloadCompletedAtMs;
1476
+ const elapsedSinceFullFetch = now - this.lastServerFullFetchAtMs;
1477
+ if (this.lastPreloadCompletedAtMs > 0 && elapsedSincePreload < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS || this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetch < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS) {
1478
+ return this.store.list;
1479
+ }
1345
1480
  this.logInfo("silentRefresh 开始");
1346
1481
  try {
1347
1482
  const products = await this.loadProductsByServer();
@@ -61,6 +61,8 @@ export declare class ResourceModule extends BaseModule implements Module {
61
61
  */
62
62
  clear(): Promise<void>;
63
63
  private attachBookingsToResource;
64
+ private normalizeIntegerIdValue;
65
+ private normalizeResourceIdFields;
64
66
  private normalizeResource;
65
67
  private safeEmit;
66
68
  private syncResourcesMap;
@@ -268,11 +268,35 @@ var ResourceModule = class extends import_BaseModule.BaseModule {
268
268
  bookings: this.getBookingsByResourceId(resource.id)
269
269
  };
270
270
  }
271
+ normalizeIntegerIdValue(value) {
272
+ if (typeof value !== "string")
273
+ return value;
274
+ const matched = value.match(/^(-?\d+)\.0+$/);
275
+ if (!matched)
276
+ return value;
277
+ return matched[1];
278
+ }
279
+ normalizeResourceIdFields(resource) {
280
+ resource.id = this.normalizeIntegerIdValue(resource.id);
281
+ if (resource.form_record_id !== void 0) {
282
+ resource.form_record_id = this.normalizeIntegerIdValue(resource.form_record_id);
283
+ }
284
+ if (resource.form_id !== void 0) {
285
+ resource.form_id = this.normalizeIntegerIdValue(resource.form_id);
286
+ }
287
+ if (resource.resource_form_id !== void 0) {
288
+ resource.resource_form_id = this.normalizeIntegerIdValue(resource.resource_form_id);
289
+ }
290
+ if (resource.resource_id !== void 0) {
291
+ resource.resource_id = this.normalizeIntegerIdValue(resource.resource_id);
292
+ }
293
+ return resource;
294
+ }
271
295
  normalizeResource(resource) {
272
- const normalized = {
296
+ const normalized = this.normalizeResourceIdFields({
273
297
  ...resource,
274
- id: (resource == null ? void 0 : resource.id) ?? (resource == null ? void 0 : resource.form_record_id) ?? ""
275
- };
298
+ id: this.normalizeIntegerIdValue((resource == null ? void 0 : resource.id) ?? (resource == null ? void 0 : resource.form_record_id) ?? "")
299
+ });
276
300
  if (normalized.form_record_id === void 0 && normalized.id !== "") {
277
301
  normalized.form_record_id = normalized.id;
278
302
  }
@@ -64,15 +64,15 @@ export declare class ScheduleModuleEx extends BaseModule implements Module, Sche
64
64
  */
65
65
  getDateIsInSchedule(date: string, scheduleList: (ScheduleItem | number)[]): boolean;
66
66
  /**
67
- * 从 IndexDB 加载日程数据
67
+ * 从 SQLite 加载日程数据
68
68
  * @private
69
69
  */
70
- private loadScheduleFromIndexDB;
70
+ private loadScheduleFromSQLite;
71
71
  /**
72
- * 保存日程数据到 IndexDB
72
+ * 保存日程数据到 SQLite
73
73
  * @private
74
74
  */
75
- private saveScheduleToIndexDB;
75
+ private saveScheduleToSQLite;
76
76
  /**
77
77
  * 预加载模块数据(统一接口)
78
78
  * 在模块注册后自动调用