@pisell/pisellos 2.2.243 → 2.2.244

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 (315) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +2 -3
  2. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  3. package/dist/model/strategy/adapter/walletPass/utils.js +4 -7
  4. package/dist/modules/Cart/utils/cartProduct.js +3 -24
  5. package/dist/modules/Cart/utils/changePrice.js +11 -11
  6. package/dist/modules/Customer/index.d.ts +0 -20
  7. package/dist/modules/Customer/index.js +83 -172
  8. package/dist/modules/Customer/types.d.ts +0 -2
  9. package/dist/modules/Discount/index.js +3 -4
  10. package/dist/modules/Discount/types.d.ts +0 -1
  11. package/dist/modules/OpenData/index.d.ts +0 -8
  12. package/dist/modules/OpenData/index.js +17 -37
  13. package/dist/modules/Order/index.d.ts +18 -268
  14. package/dist/modules/Order/index.js +757 -3306
  15. package/dist/modules/Order/types.d.ts +31 -279
  16. package/dist/modules/Order/types.js +0 -38
  17. package/dist/modules/Order/utils.d.ts +5 -147
  18. package/dist/modules/Order/utils.js +103 -746
  19. package/dist/modules/Payment/index.d.ts +13 -10
  20. package/dist/modules/Payment/index.js +837 -467
  21. package/dist/modules/Payment/types.d.ts +0 -2
  22. package/dist/modules/Payment/utils.js +1 -2
  23. package/dist/modules/Payment/walletpass.js +7 -14
  24. package/dist/modules/ProductList/index.d.ts +12 -16
  25. package/dist/modules/ProductList/index.js +59 -133
  26. package/dist/modules/ProductList/types.d.ts +0 -14
  27. package/dist/modules/Quotation/index.d.ts +1 -0
  28. package/dist/modules/Quotation/index.js +22 -25
  29. package/dist/modules/Rules/index.d.ts +0 -4
  30. package/dist/modules/Rules/index.js +69 -93
  31. package/dist/modules/Rules/types.d.ts +0 -1
  32. package/dist/modules/SalesSummary/index.d.ts +25 -8
  33. package/dist/modules/SalesSummary/index.js +35 -86
  34. package/dist/modules/SalesSummary/types.d.ts +1 -4
  35. package/dist/modules/SalesSummary/utils.d.ts +25 -2
  36. package/dist/modules/SalesSummary/utils.js +162 -794
  37. package/dist/modules/Schedule/index.d.ts +0 -7
  38. package/dist/modules/Schedule/index.js +2 -24
  39. package/dist/modules/Summary/index.js +3 -4
  40. package/dist/modules/index.d.ts +0 -2
  41. package/dist/modules/index.js +1 -3
  42. package/dist/plugins/request.d.ts +0 -1
  43. package/dist/server/index.d.ts +1 -204
  44. package/dist/server/index.js +928 -3658
  45. package/dist/server/modules/index.d.ts +0 -2
  46. package/dist/server/modules/index.js +0 -2
  47. package/dist/server/modules/order/index.d.ts +4 -120
  48. package/dist/server/modules/order/index.js +483 -1779
  49. package/dist/server/modules/order/types.d.ts +3 -32
  50. package/dist/server/modules/order/types.js +0 -8
  51. package/dist/server/modules/order/utils/filterBookings.js +3 -26
  52. package/dist/server/modules/order/utils/filterOrders.js +8 -23
  53. package/dist/server/modules/products/index.d.ts +7 -34
  54. package/dist/server/modules/products/index.js +317 -631
  55. package/dist/server/modules/resource/index.d.ts +0 -2
  56. package/dist/server/modules/resource/index.js +3 -29
  57. package/dist/server/modules/schedule/index.d.ts +4 -4
  58. package/dist/server/modules/schedule/index.js +88 -111
  59. package/dist/solution/BaseSales/index.d.ts +9 -131
  60. package/dist/solution/BaseSales/index.js +447 -1944
  61. package/dist/solution/BaseSales/types.d.ts +6 -76
  62. package/dist/solution/BaseSales/types.js +4 -5
  63. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
  64. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -105
  65. package/dist/solution/BaseSales/utils.d.ts +1 -1
  66. package/dist/solution/BaseSales/utils.js +21 -62
  67. package/dist/solution/BookingByStep/index.d.ts +1 -1
  68. package/dist/solution/BookingTicket/index.d.ts +10 -270
  69. package/dist/solution/BookingTicket/index.js +237 -1772
  70. package/dist/solution/BookingTicket/types.d.ts +1 -118
  71. package/dist/solution/BookingTicket/types.js +2 -41
  72. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
  73. package/dist/solution/BookingTicket/utils/bookingStatus.js +0 -70
  74. package/dist/solution/BookingTicket/utils/cartView.d.ts +1 -9
  75. package/dist/solution/BookingTicket/utils/cartView.js +7 -94
  76. package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -5
  77. package/dist/solution/BookingTicket/utils/scan/index.js +8 -20
  78. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  79. package/dist/solution/Checkout/index.d.ts +0 -1
  80. package/dist/solution/Checkout/index.js +9 -10
  81. package/dist/solution/RegisterAndLogin/config.js +10 -2
  82. package/dist/solution/ScanOrder/index.d.ts +3 -9
  83. package/dist/solution/ScanOrder/index.js +134 -241
  84. package/dist/solution/ScanOrder/types.d.ts +5 -9
  85. package/dist/solution/ScanOrder/types.js +3 -2
  86. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  87. package/dist/solution/ScanOrder/utils.js +22 -84
  88. package/dist/solution/VenueBooking/index.d.ts +2 -5
  89. package/dist/solution/VenueBooking/index.js +59 -110
  90. package/dist/solution/VenueBooking/sales-section-4-annotated.json +2 -0
  91. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  92. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  93. package/dist/types/index.d.ts +0 -10
  94. package/lib/model/strategy/adapter/promotion/evaluator.js +1 -2
  95. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  96. package/lib/model/strategy/adapter/walletPass/utils.js +2 -3
  97. package/lib/modules/Cart/utils/cartProduct.js +3 -20
  98. package/lib/modules/Cart/utils/changePrice.js +20 -12
  99. package/lib/modules/Customer/index.d.ts +0 -20
  100. package/lib/modules/Customer/index.js +11 -64
  101. package/lib/modules/Customer/types.d.ts +0 -2
  102. package/lib/modules/Discount/index.js +1 -5
  103. package/lib/modules/Discount/types.d.ts +0 -1
  104. package/lib/modules/OpenData/index.d.ts +0 -8
  105. package/lib/modules/OpenData/index.js +5 -19
  106. package/lib/modules/Order/index.d.ts +18 -268
  107. package/lib/modules/Order/index.js +344 -2149
  108. package/lib/modules/Order/types.d.ts +31 -279
  109. package/lib/modules/Order/types.js +0 -1
  110. package/lib/modules/Order/utils.d.ts +5 -147
  111. package/lib/modules/Order/utils.js +46 -614
  112. package/lib/modules/Payment/index.d.ts +13 -10
  113. package/lib/modules/Payment/index.js +150 -18
  114. package/lib/modules/Payment/types.d.ts +0 -2
  115. package/lib/modules/Payment/utils.js +1 -2
  116. package/lib/modules/Payment/walletpass.js +3 -7
  117. package/lib/modules/ProductList/index.d.ts +12 -16
  118. package/lib/modules/ProductList/index.js +4 -41
  119. package/lib/modules/ProductList/types.d.ts +0 -14
  120. package/lib/modules/Quotation/index.d.ts +1 -0
  121. package/lib/modules/Quotation/index.js +16 -19
  122. package/lib/modules/Rules/index.d.ts +0 -4
  123. package/lib/modules/Rules/index.js +120 -136
  124. package/lib/modules/Rules/types.d.ts +0 -1
  125. package/lib/modules/SalesSummary/index.d.ts +25 -8
  126. package/lib/modules/SalesSummary/index.js +4 -30
  127. package/lib/modules/SalesSummary/types.d.ts +1 -4
  128. package/lib/modules/SalesSummary/utils.d.ts +25 -2
  129. package/lib/modules/SalesSummary/utils.js +91 -645
  130. package/lib/modules/Schedule/index.d.ts +0 -7
  131. package/lib/modules/Schedule/index.js +1 -17
  132. package/lib/modules/Summary/index.js +4 -5
  133. package/lib/modules/index.d.ts +0 -2
  134. package/lib/modules/index.js +1 -5
  135. package/lib/plugins/request.d.ts +0 -1
  136. package/lib/server/index.d.ts +1 -204
  137. package/lib/server/index.js +57 -1888
  138. package/lib/server/modules/index.d.ts +0 -2
  139. package/lib/server/modules/index.js +0 -3
  140. package/lib/server/modules/order/index.d.ts +4 -120
  141. package/lib/server/modules/order/index.js +142 -919
  142. package/lib/server/modules/order/types.d.ts +3 -32
  143. package/lib/server/modules/order/utils/filterBookings.js +5 -24
  144. package/lib/server/modules/order/utils/filterOrders.js +6 -15
  145. package/lib/server/modules/products/index.d.ts +7 -34
  146. package/lib/server/modules/products/index.js +54 -189
  147. package/lib/server/modules/resource/index.d.ts +0 -2
  148. package/lib/server/modules/resource/index.js +3 -27
  149. package/lib/server/modules/schedule/index.d.ts +4 -4
  150. package/lib/server/modules/schedule/index.js +40 -47
  151. package/lib/solution/BaseSales/index.d.ts +9 -131
  152. package/lib/solution/BaseSales/index.js +63 -1106
  153. package/lib/solution/BaseSales/types.d.ts +6 -76
  154. package/lib/solution/BaseSales/types.js +1 -3
  155. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
  156. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +18 -106
  157. package/lib/solution/BaseSales/utils.d.ts +1 -1
  158. package/lib/solution/BaseSales/utils.js +10 -54
  159. package/lib/solution/BookingByStep/index.d.ts +1 -1
  160. package/lib/solution/BookingTicket/index.d.ts +10 -270
  161. package/lib/solution/BookingTicket/index.js +29 -922
  162. package/lib/solution/BookingTicket/types.d.ts +1 -118
  163. package/lib/solution/BookingTicket/types.js +0 -11
  164. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
  165. package/lib/solution/BookingTicket/utils/bookingStatus.js +2 -44
  166. package/lib/solution/BookingTicket/utils/cartView.d.ts +1 -9
  167. package/lib/solution/BookingTicket/utils/cartView.js +6 -61
  168. package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -5
  169. package/lib/solution/BookingTicket/utils/scan/index.js +3 -17
  170. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  171. package/lib/solution/Checkout/index.d.ts +0 -1
  172. package/lib/solution/Checkout/index.js +2 -1
  173. package/lib/solution/RegisterAndLogin/config.js +10 -2
  174. package/lib/solution/ScanOrder/index.d.ts +3 -9
  175. package/lib/solution/ScanOrder/index.js +70 -153
  176. package/lib/solution/ScanOrder/types.d.ts +5 -9
  177. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  178. package/lib/solution/ScanOrder/utils.js +17 -83
  179. package/lib/solution/VenueBooking/index.d.ts +2 -5
  180. package/lib/solution/VenueBooking/index.js +17 -54
  181. package/lib/solution/VenueBooking/sales-section-4-annotated.json +2 -0
  182. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  183. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  184. package/lib/types/index.d.ts +0 -10
  185. package/package.json +1 -1
  186. package/dist/modules/BookingContext/index.d.ts +0 -48
  187. package/dist/modules/BookingContext/index.js +0 -566
  188. package/dist/modules/BookingContext/types.d.ts +0 -102
  189. package/dist/modules/BookingContext/types.js +0 -51
  190. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  191. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -284
  192. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  193. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -145
  194. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
  195. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -218
  196. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  197. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  198. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  199. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  200. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  201. package/dist/modules/BookingContext/utils/index.js +0 -11
  202. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  203. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  204. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
  205. package/dist/modules/BookingContext/utils/orderLineDisplay.js +0 -36
  206. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  207. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  208. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  209. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  210. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  211. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  212. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  213. package/dist/modules/BookingContext/utils/resources.js +0 -486
  214. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  215. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  216. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  217. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  218. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  219. package/dist/modules/Order/utils/manualProductDiscount.js +0 -210
  220. package/dist/modules/SurchargeList/index.d.ts +0 -16
  221. package/dist/modules/SurchargeList/index.js +0 -162
  222. package/dist/modules/SurchargeList/types.d.ts +0 -11
  223. package/dist/modules/SurchargeList/types.js +0 -1
  224. package/dist/server/modules/payment/index.d.ts +0 -28
  225. package/dist/server/modules/payment/index.js +0 -305
  226. package/dist/server/modules/payment/types.d.ts +0 -9
  227. package/dist/server/modules/payment/types.js +0 -1
  228. package/dist/server/test.json +0 -713
  229. package/dist/server/utils/small-ticket.d.ts +0 -71
  230. package/dist/server/utils/small-ticket.js +0 -830
  231. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
  232. package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1438
  233. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  234. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  235. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
  236. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  237. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
  238. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +0 -95
  239. package/dist/solution/BookingTicket/utils/exampleData.d.ts +0 -123
  240. package/dist/solution/BookingTicket/utils/exampleData.js +0 -183
  241. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
  242. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -438
  243. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
  244. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -399
  245. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
  246. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -56
  247. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
  248. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +0 -150
  249. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
  250. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +0 -78
  251. package/lib/modules/BookingContext/index.d.ts +0 -48
  252. package/lib/modules/BookingContext/index.js +0 -368
  253. package/lib/modules/BookingContext/types.d.ts +0 -102
  254. package/lib/modules/BookingContext/types.js +0 -34
  255. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  256. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -276
  257. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  258. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -151
  259. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
  260. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -201
  261. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  262. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  263. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  264. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  265. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  266. package/lib/modules/BookingContext/utils/index.js +0 -43
  267. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  268. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  269. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
  270. package/lib/modules/BookingContext/utils/orderLineDisplay.js +0 -56
  271. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  272. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  273. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  274. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  275. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  276. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  277. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  278. package/lib/modules/BookingContext/utils/resources.js +0 -377
  279. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  280. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  281. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  282. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  283. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  284. package/lib/modules/Order/utils/manualProductDiscount.js +0 -206
  285. package/lib/modules/SurchargeList/index.d.ts +0 -16
  286. package/lib/modules/SurchargeList/index.js +0 -89
  287. package/lib/modules/SurchargeList/types.d.ts +0 -11
  288. package/lib/modules/SurchargeList/types.js +0 -17
  289. package/lib/server/modules/payment/index.d.ts +0 -28
  290. package/lib/server/modules/payment/index.js +0 -192
  291. package/lib/server/modules/payment/types.d.ts +0 -9
  292. package/lib/server/modules/payment/types.js +0 -17
  293. package/lib/server/test.json +0 -713
  294. package/lib/server/utils/small-ticket.d.ts +0 -71
  295. package/lib/server/utils/small-ticket.js +0 -781
  296. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
  297. package/lib/solution/BaseSales/utils/cartPromotion.js +0 -992
  298. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  299. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  300. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
  301. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
  302. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
  303. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +0 -125
  304. package/lib/solution/BookingTicket/utils/exampleData.d.ts +0 -123
  305. package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
  306. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
  307. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -254
  308. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
  309. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -168
  310. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
  311. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -51
  312. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
  313. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +0 -127
  314. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
  315. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +0 -85
@@ -1,185 +0,0 @@
1
- /**
2
- * 计算指定加时时长下的最优购买方案。
3
- *
4
- * 输入的商品结构来自旧版 booking addTimeModal 的加时商品配置映射:
5
- * - `minMinutes`:该商品第一次可选择的最小时长。
6
- * - `maxMinutes`:单次购买该商品可覆盖的最大时长。
7
- * - `unitMinutes`:超过最小时长后,每次递增的时长切片。
8
- * - `price`:每个 `unitMinutes` 切片的价格。
9
- * - `unlimited`:固定价格商品,可覆盖任意目标时长。
10
- *
11
- * 算法流程:
12
- *
13
- * ```
14
- * products
15
- * |
16
- * v
17
- * 将每个普通商品展开成有限候选档位
18
- * 商品 A: min=30, max=60, unit=10, price=10
19
- * => 30m/$30, 40m/$40, 50m/$50, 60m/$60
20
- * |
21
- * v
22
- * 单独加入 unlimited 候选
23
- * unlimited 商品 => targetMinutes / 固定商品价格
24
- * |
25
- * v
26
- * 按 covered minutes 做动态规划
27
- * dp[minutes] = 正好覆盖 `minutes` 时的最低价候选组合
28
- * |
29
- * v
30
- * 从所有 dp[minutes >= targetMinutes] 中挑选最优方案
31
- * ```
32
- *
33
- * 候选档位生成刻意对齐旧版 addTimeModal:
34
- * `totalPrice = minutes / unitMinutes * price`.
35
- * 例如 `minMinutes=30`、`unitMinutes=10`、`price=10` 时:
36
- * - 30 分钟 => 30 / 10 * 10 = 30
37
- * - 60 分钟 => 60 / 10 * 10 = 60
38
- *
39
- * 目标时长不要求精确命中某个档位,只需要覆盖即可。例如目标是 51 分钟时,
40
- * 60 分钟档位可以作为候选。动态规划也允许跨商品组合,例如商品 A 的 30m
41
- * 加上商品 B 的 30m。最终方案按以下优先级比较:
42
- * 1. 总价更低;
43
- * 2. 超出时长更少,即 `coveredMinutes - targetMinutes` 更小;
44
- * 3. 结果行数更少,让购买方案尽量简单。
45
- *
46
- * 典型匹配示例:
47
- *
48
- * 示例 1:精确命中,直接选择更便宜的商品。
49
- * ```
50
- * target = 30
51
- * 商品 A: min=30, max=30, unit=30, price=10 => 30m/$10
52
- * 商品 B: min=30, max=30, unit=30, price=8 => 30m/$8
53
- * 结果:选择商品 B,coveredMinutes=30,totalPrice=8
54
- * ```
55
- *
56
- * 示例 2:目标时长落在两个档位之间,向上选择可覆盖的档位。
57
- * ```
58
- * target = 51
59
- * 商品 A: min=30, max=120, unit=10, price=10
60
- * 候选:30m/$30, 40m/$40, 50m/$50, 60m/$60 ...
61
- * 结果:50m 不足以覆盖 51m,因此选择 60m/$60
62
- * ```
63
- *
64
- * 示例 3:不同商品都能覆盖同一目标时长,比较最终价格。
65
- * ```
66
- * target = 51
67
- * 商品 A: min=30, max=120, unit=10, price=10 => 60m/$60
68
- * 商品 B: min=30, max=120, unit=30, price=25 => 60m/$50
69
- * 结果:两个方案都覆盖 60m,但商品 B 更便宜,所以选择商品 B
70
- * ```
71
- *
72
- * 示例 4:允许跨商品组合,组合价更低时会选择组合。
73
- * ```
74
- * target = 90
75
- * 商品 A: min=30, max=30, unit=30, price=5 => 30m/$5
76
- * 商品 B: min=60, max=60, unit=60, price=8 => 60m/$8
77
- * 商品 C: min=90, max=90, unit=90, price=20 => 90m/$20
78
- * 结果:商品 A + 商品 B = 90m/$13,比商品 C 更便宜
79
- * ```
80
- *
81
- * 示例 5:允许重复购买同一个候选档位。
82
- * ```
83
- * target = 90
84
- * 商品 A: min=30, max=30, unit=30, price=5 => 30m/$5
85
- * 结果:购买 3 份商品 A,coveredMinutes=90,totalPrice=15,
86
- * lines 中会合并为一行:product_add_schedule_time=30,num=3
87
- * ```
88
- *
89
- * 示例 6:unlimited 可以覆盖任意目标时长,并参与价格比较。
90
- * ```
91
- * target = 180
92
- * 商品 A: min=30, max=120, unit=30, price=10
93
- * 商品 B: unlimited=true, price=35
94
- * 普通商品可以组合成 180m,例如 120m + 60m,总价 $60
95
- * unlimited 商品固定 $35
96
- * 结果:选择 unlimited 商品,coveredMinutes=180,totalPrice=35
97
- * ```
98
- *
99
- * 示例 7:unlimited 不一定优先,普通商品更便宜时选择普通商品。
100
- * ```
101
- * target = 60
102
- * 商品 A: min=30, max=60, unit=30, price=10 => 60m/$20
103
- * 商品 B: unlimited=true, price=50
104
- * 结果:选择商品 A 的 60m 档位
105
- * ```
106
- *
107
- * 示例 8:价格相同,优先选择超出时长更少的方案。
108
- * ```
109
- * target = 51
110
- * 商品 A: 60m/$20
111
- * 商品 B: 90m/$20
112
- * 结果:选择 60m,因为 overage=9,小于 90m 的 overage=39
113
- * ```
114
- *
115
- * 示例 9:价格和覆盖时长都相同,优先选择结果行数更少的方案。
116
- * ```
117
- * target = 60
118
- * 商品 A: 60m/$20
119
- * 商品 B: 30m/$10
120
- * 商品 C: 30m/$10
121
- * 结果:商品 A 单行方案和 B+C 两行方案价格、时长相同,选择商品 A
122
- * ```
123
- *
124
- * 示例 10:没有任何有效商品时返回 `NO_PRODUCTS`。
125
- * ```
126
- * target = 30
127
- * products = []
128
- * 结果:available=false,unavailableReason='NO_PRODUCTS'
129
- * ```
130
- *
131
- * 示例 11:有商品但没有可用候选时返回 `NO_COVERAGE`。
132
- * ```
133
- * target = 30
134
- * 商品 A: price=0,或 minMinutes 缺失/无效
135
- * 结果:available=false,unavailableReason='NO_COVERAGE'
136
- * ```
137
- *
138
- * 示例 12:目标时长小于等于 0 时无需购买。
139
- * ```
140
- * target = 0
141
- * 结果:available=true,coveredMinutes=0,totalPrice=0,lines=[]
142
- * ```
143
- *
144
- * 搜索边界:
145
- * 有限档位只需要搜索到 `targetMinutes + maxFiniteCandidateMinutes`。
146
- * 这里的 `maxFiniteCandidateMinutes` 是所有普通候选档位里的最大时长。
147
- * 例如目标是 51 分钟,最大普通档位是 120 分钟,则只搜索到 171 分钟。
148
- * 如果某个组合覆盖了 180 分钟,那么移除其中任意一个普通档位后,剩余时长
149
- * 仍然有机会覆盖 51 分钟,而且价格一定不会更高,所以 180 分钟这个组合不
150
- * 可能是最优解。
151
- */
152
- export interface AddTimeProduct {
153
- id: string | number;
154
- title?: string;
155
- price: number;
156
- minMinutes?: number;
157
- maxMinutes?: number;
158
- unitMinutes?: number;
159
- unlimited?: boolean;
160
- _originalProduct?: unknown;
161
- }
162
- export interface AddTimePlanLine {
163
- product_id: string | number;
164
- product_title?: string;
165
- product_add_schedule_time: number;
166
- num: number;
167
- price: number;
168
- _originalProduct?: unknown;
169
- }
170
- export interface AddTimePlan {
171
- available: boolean;
172
- unavailableReason?: 'NO_PRODUCTS' | 'NO_COVERAGE';
173
- targetMinutes: number;
174
- coveredMinutes: number;
175
- totalPrice: number;
176
- lines: AddTimePlanLine[];
177
- }
178
- interface AddTimeCandidate extends AddTimePlanLine {
179
- totalPrice: number;
180
- unlimited?: boolean;
181
- }
182
- export declare const ADD_TIME_UNIT_MINUTES: readonly [10, 15, 20, 30, 45, 60];
183
- export declare function buildAddTimeCandidates(products: AddTimeProduct[]): AddTimeCandidate[];
184
- export declare function resolveBestAddTimePlan(products: AddTimeProduct[], targetMinutes: number): AddTimePlan;
185
- export {};
@@ -1,254 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/solution/BookingTicket/utils/resolveBestAddTimePlan.ts
20
- var resolveBestAddTimePlan_exports = {};
21
- __export(resolveBestAddTimePlan_exports, {
22
- ADD_TIME_UNIT_MINUTES: () => ADD_TIME_UNIT_MINUTES,
23
- buildAddTimeCandidates: () => buildAddTimeCandidates,
24
- resolveBestAddTimePlan: () => resolveBestAddTimePlan
25
- });
26
- module.exports = __toCommonJS(resolveBestAddTimePlan_exports);
27
- var ADD_TIME_UNIT_MINUTES = [10, 15, 20, 30, 45, 60];
28
- var toPositiveNumber = (value) => {
29
- const n = Number(value);
30
- return Number.isFinite(n) && n > 0 ? n : null;
31
- };
32
- var normalizeTargetMinutes = (minutes) => {
33
- const n = Number(minutes);
34
- return Number.isFinite(n) ? Math.max(0, Math.ceil(n)) : 0;
35
- };
36
- var gcd = (a, b) => {
37
- let x = Math.abs(a);
38
- let y = Math.abs(b);
39
- while (y !== 0) {
40
- const next = x % y;
41
- x = y;
42
- y = next;
43
- }
44
- return x;
45
- };
46
- var getDpStepMinutes = (candidates) => {
47
- return candidates.reduce(
48
- (current, candidate) => gcd(current, candidate.product_add_schedule_time),
49
- 0
50
- ) || 1;
51
- };
52
- var comparePlans = (left, right) => {
53
- if (!left)
54
- return right;
55
- if (right.totalPrice !== left.totalPrice) {
56
- return right.totalPrice < left.totalPrice ? right : left;
57
- }
58
- const leftOverage = left.coveredMinutes - left.targetMinutes;
59
- const rightOverage = right.coveredMinutes - right.targetMinutes;
60
- if (rightOverage !== leftOverage) {
61
- return rightOverage < leftOverage ? right : left;
62
- }
63
- return right.lines.length < left.lines.length ? right : left;
64
- };
65
- var toPlanLine = (candidate) => ({
66
- product_id: candidate.product_id,
67
- product_title: candidate.product_title,
68
- product_add_schedule_time: Number.isFinite(candidate.product_add_schedule_time) ? candidate.product_add_schedule_time : 0,
69
- num: candidate.num,
70
- price: candidate.price,
71
- _originalProduct: candidate._originalProduct
72
- });
73
- var mergePlanLines = (candidates) => {
74
- const map = /* @__PURE__ */ new Map();
75
- for (const candidate of candidates) {
76
- const key = `${candidate.product_id}-${candidate.product_add_schedule_time}-${candidate.unlimited ? "u" : "n"}`;
77
- const existing = map.get(key);
78
- if (existing) {
79
- existing.num += candidate.num;
80
- continue;
81
- }
82
- map.set(key, toPlanLine(candidate));
83
- }
84
- return Array.from(map.values());
85
- };
86
- var sumPlanLineMinutes = (lines) => lines.reduce(
87
- (total, line) => total + line.product_add_schedule_time * line.num,
88
- 0
89
- );
90
- var restoreDpCandidates = (dp, finiteCandidates, index) => {
91
- const candidates = [];
92
- let currentIndex = index;
93
- while (currentIndex > 0) {
94
- const current = dp[currentIndex];
95
- if (!current || current.candidateIndex < 0)
96
- break;
97
- candidates.push(finiteCandidates[current.candidateIndex]);
98
- currentIndex = current.prevIndex;
99
- }
100
- return candidates.reverse();
101
- };
102
- function buildAddTimeCandidates(products) {
103
- const candidates = [];
104
- for (const product of products) {
105
- const price = toPositiveNumber(product.price);
106
- if (price == null)
107
- continue;
108
- if (product.unlimited) {
109
- candidates.push({
110
- product_id: product.id,
111
- product_title: product.title,
112
- _originalProduct: product._originalProduct ?? product,
113
- product_add_schedule_time: Number.POSITIVE_INFINITY,
114
- num: 1,
115
- price,
116
- totalPrice: price,
117
- unlimited: true
118
- });
119
- continue;
120
- }
121
- const minMinutes = toPositiveNumber(product.minMinutes);
122
- if (minMinutes == null)
123
- continue;
124
- const maxMinutes = toPositiveNumber(product.maxMinutes) ?? minMinutes;
125
- const unitMinutes = toPositiveNumber(product.unitMinutes) ?? minMinutes;
126
- const safeMax = Math.max(minMinutes, maxMinutes);
127
- for (let minutes = minMinutes; minutes <= safeMax; minutes += unitMinutes) {
128
- candidates.push({
129
- product_id: product.id,
130
- product_title: product.title,
131
- _originalProduct: product._originalProduct ?? product,
132
- product_add_schedule_time: minutes,
133
- num: 1,
134
- price,
135
- totalPrice: minutes / unitMinutes * price
136
- });
137
- }
138
- }
139
- return candidates;
140
- }
141
- function resolveBestAddTimePlan(products, targetMinutes) {
142
- const normalizedTarget = normalizeTargetMinutes(targetMinutes);
143
- if (normalizedTarget <= 0) {
144
- return {
145
- available: true,
146
- targetMinutes: 0,
147
- coveredMinutes: 0,
148
- totalPrice: 0,
149
- lines: []
150
- };
151
- }
152
- if (!products.length) {
153
- return {
154
- available: false,
155
- unavailableReason: "NO_PRODUCTS",
156
- targetMinutes: normalizedTarget,
157
- coveredMinutes: 0,
158
- totalPrice: 0,
159
- lines: []
160
- };
161
- }
162
- const candidates = buildAddTimeCandidates(products);
163
- const finiteCandidates = candidates.filter(
164
- (item) => Number.isFinite(item.product_add_schedule_time)
165
- );
166
- const unlimitedCandidates = candidates.filter((item) => item.unlimited);
167
- const maxFiniteMinutes = Math.max(
168
- 0,
169
- ...finiteCandidates.map((item) => item.product_add_schedule_time)
170
- );
171
- const searchLimit = normalizedTarget + maxFiniteMinutes;
172
- let best = null;
173
- for (const unlimited of unlimitedCandidates) {
174
- const lines = [
175
- toPlanLine({
176
- ...unlimited,
177
- product_add_schedule_time: normalizedTarget
178
- })
179
- ];
180
- best = comparePlans(best, {
181
- available: true,
182
- targetMinutes: normalizedTarget,
183
- coveredMinutes: sumPlanLineMinutes(lines),
184
- totalPrice: unlimited.totalPrice,
185
- lines
186
- });
187
- }
188
- if (finiteCandidates.length && searchLimit > 0) {
189
- const stepMinutes = getDpStepMinutes(finiteCandidates);
190
- const searchLimitIndex = Math.ceil(searchLimit / stepMinutes);
191
- const targetIndex = Math.ceil(normalizedTarget / stepMinutes);
192
- const finiteCandidateSteps = finiteCandidates.map(
193
- (candidate) => candidate.product_add_schedule_time / stepMinutes
194
- );
195
- const dp = [];
196
- dp[0] = {
197
- price: 0,
198
- itemCount: 0,
199
- prevIndex: -1,
200
- candidateIndex: -1
201
- };
202
- for (let index = 0; index <= searchLimitIndex; index += 1) {
203
- const current = dp[index];
204
- if (!current)
205
- continue;
206
- for (let candidateIndex = 0; candidateIndex < finiteCandidates.length; candidateIndex += 1) {
207
- const nextIndex = index + finiteCandidateSteps[candidateIndex];
208
- if (nextIndex > searchLimitIndex)
209
- continue;
210
- const candidate = finiteCandidates[candidateIndex];
211
- const nextPrice = current.price + candidate.totalPrice;
212
- const nextItemCount = current.itemCount + 1;
213
- const prev = dp[nextIndex];
214
- if (!prev || nextPrice < prev.price || nextPrice === prev.price && nextItemCount < prev.itemCount) {
215
- dp[nextIndex] = {
216
- price: nextPrice,
217
- itemCount: nextItemCount,
218
- prevIndex: index,
219
- candidateIndex
220
- };
221
- }
222
- }
223
- }
224
- for (let index = targetIndex; index <= searchLimitIndex; index += 1) {
225
- const current = dp[index];
226
- if (!current)
227
- continue;
228
- const lines = mergePlanLines(
229
- restoreDpCandidates(dp, finiteCandidates, index)
230
- );
231
- best = comparePlans(best, {
232
- available: true,
233
- targetMinutes: normalizedTarget,
234
- coveredMinutes: sumPlanLineMinutes(lines),
235
- totalPrice: current.price,
236
- lines
237
- });
238
- }
239
- }
240
- return best ?? {
241
- available: false,
242
- unavailableReason: "NO_COVERAGE",
243
- targetMinutes: normalizedTarget,
244
- coveredMinutes: 0,
245
- totalPrice: 0,
246
- lines: []
247
- };
248
- }
249
- // Annotate the CommonJS export names for ESM import in node:
250
- 0 && (module.exports = {
251
- ADD_TIME_UNIT_MINUTES,
252
- buildAddTimeCandidates,
253
- resolveBestAddTimePlan
254
- });
@@ -1,36 +0,0 @@
1
- import type { GlobalScanHandleResult, GlobalScanHostBridge, ICustomer } from '../../types';
2
- import type { AddProductDecision } from '../addProductDecision';
3
- import { GlobalScanFormattedResult } from './formatGlobalScan';
4
- /** applyGlobalScan 所需的 BookingTicket 运行时能力 */
5
- export interface GlobalScanApplyHost {
6
- setOrderCustomer(customer: ICustomer | null): void;
7
- getOrderCustomerSnapshot(): ICustomer | null;
8
- getBusinessCode(): string | undefined;
9
- buildAddProductCtx(extra?: Record<string, any>): Record<string, any>;
10
- decideAddProduct(item: any, options?: Record<string, any>): AddProductDecision;
11
- decideAfterDetail(cacheItem: any, options?: Record<string, any>): AddProductDecision;
12
- transformDetailToProductAndBooking(input: {
13
- item: any;
14
- cacheItem?: any;
15
- detailResult?: {
16
- e: any;
17
- extension_type?: any;
18
- detail?: any;
19
- };
20
- options?: Record<string, any>;
21
- }): {
22
- product: any;
23
- booking?: any;
24
- cacheItem: any;
25
- };
26
- addProductToOrder(product: any, booking?: any): Promise<any>;
27
- }
28
- /**
29
- * 应用全局扫码格式化结果:设客户 / 加车 / 开单 / 弹窗链。
30
- *
31
- * @example
32
- * ```ts
33
- * const result = await applyGlobalScan(bookingTicket, formatted, bridge);
34
- * ```
35
- */
36
- export declare function applyGlobalScan(host: GlobalScanApplyHost, formatted: GlobalScanFormattedResult, bridge?: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
@@ -1,168 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/solution/BookingTicket/utils/scan/applyGlobalScan.ts
20
- var applyGlobalScan_exports = {};
21
- __export(applyGlobalScan_exports, {
22
- applyGlobalScan: () => applyGlobalScan
23
- });
24
- module.exports = __toCommonJS(applyGlobalScan_exports);
25
- var import_addProductDecision = require("../addProductDecision");
26
- var import_cartView = require("../cartView");
27
- var import_scanProductValues = require("./scanProductValues");
28
- async function processScannedProductItem(host, item, code, bridge) {
29
- const ctx = host.buildAddProductCtx();
30
- if ((0, import_scanProductValues.isScanProductBundle)(item) || (0, import_scanProductValues.isScanProductOption)(item)) {
31
- return runRequiresDetailFlow(host, item, ctx, bridge);
32
- }
33
- if ((0, import_scanProductValues.countScanVariantMatches)(item, code) >= 2) {
34
- return runRequiresDetailFlow(host, item, ctx, bridge);
35
- }
36
- const values = (0, import_scanProductValues.genScanProductValues)(item, code);
37
- const itemWithSelection = { ...item, cartDetailValue: values };
38
- const decision = host.decideAddProduct(itemWithSelection, ctx);
39
- return runAddProductDecision(host, item, decision, ctx, bridge);
40
- }
41
- async function runRequiresDetailFlow(host, item, ctx, bridge) {
42
- if (!(bridge == null ? void 0 : bridge.openProductDetail)) {
43
- return "pending";
44
- }
45
- const payload = (0, import_addProductDecision.buildRequiresDetailPayload)(item, ctx);
46
- const detailResult = await bridge.openProductDetail(payload);
47
- if (!detailResult) {
48
- return "cancelled";
49
- }
50
- if (!bridge.confirmDetail) {
51
- return "pending";
52
- }
53
- await bridge.confirmDetail({
54
- item: payload.productData ?? payload.item ?? item,
55
- detailResult
56
- });
57
- return "added";
58
- }
59
- async function runAddProductDecision(host, catalogItem, decision, ctx, bridge) {
60
- if (decision.action === "reloadCatalog") {
61
- return "cancelled";
62
- }
63
- if (decision.action === "add") {
64
- const transformed = host.transformDetailToProductAndBooking({
65
- item: catalogItem,
66
- cacheItem: decision.cacheItem,
67
- options: ctx
68
- });
69
- await host.addProductToOrder(transformed.product, transformed.booking);
70
- return "added";
71
- }
72
- if (decision.action === "requiresDetail") {
73
- return runRequiresDetailFlow(host, catalogItem, ctx, bridge);
74
- }
75
- if (decision.action === "requiresBookingEdit") {
76
- if (!(bridge == null ? void 0 : bridge.openBookingEdit)) {
77
- return "pending";
78
- }
79
- const edited = await bridge.openBookingEdit(decision.payload);
80
- if (!edited) {
81
- return "cancelled";
82
- }
83
- if (!bridge.confirmBookingEdit) {
84
- return "pending";
85
- }
86
- await bridge.confirmBookingEdit({ cacheItem: edited });
87
- return "added";
88
- }
89
- return "pending";
90
- }
91
- async function applyGlobalScan(host, formatted, bridge) {
92
- var _a, _b, _c, _d, _e, _f, _g;
93
- const { searchType, data, scanCode } = formatted;
94
- if (searchType === "wallet") {
95
- if (!data) {
96
- (_a = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _a.call(bridge, "fail", "pisell2.text.scan-global-failed");
97
- return { status: "failed", reason: "invalid_data" };
98
- }
99
- host.setOrderCustomer(data);
100
- (_b = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _b.call(bridge, "success", "pisell2.text.add-client-success");
101
- return { status: "success", kind: "customer" };
102
- }
103
- if (searchType === "walletPass") {
104
- if (!data) {
105
- (_c = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _c.call(bridge, "fail", "pisell2.text.scan-global-failed");
106
- return { status: "failed", reason: "invalid_data" };
107
- }
108
- const snapshot = host.getOrderCustomerSnapshot();
109
- if ((0, import_cartView.isWalkInCustomer)(snapshot)) {
110
- if (!(bridge == null ? void 0 : bridge.applyPromotionCode)) {
111
- return { status: "failed", reason: "no_bridge" };
112
- }
113
- const result = await bridge.applyPromotionCode(scanCode);
114
- if (result == null ? void 0 : result.isAvailable) {
115
- return { status: "success", kind: "promotion" };
116
- }
117
- return { status: "failed", reason: "invalid_data" };
118
- }
119
- host.setOrderCustomer(data);
120
- (_d = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _d.call(bridge, "success", "pisell2.text.add-client-success");
121
- return { status: "success", kind: "customer" };
122
- }
123
- if (searchType === "product" || searchType === "local_product") {
124
- const list = data == null ? void 0 : data.list;
125
- if (!Array.isArray(list) || list.length === 0) {
126
- (_e = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _e.call(bridge, "fail", "pisell2.text.scan-global-failed");
127
- return { status: "failed", reason: "invalid_data" };
128
- }
129
- let addedCount = 0;
130
- for (const item of list) {
131
- const outcome = await processScannedProductItem(host, item, scanCode, bridge);
132
- if (outcome === "added") {
133
- addedCount += 1;
134
- }
135
- if (outcome === "cancelled") {
136
- return { status: "cancelled" };
137
- }
138
- if (outcome === "pending") {
139
- return { status: "pending", kind: "requiresDetail" };
140
- }
141
- }
142
- if (addedCount > 0) {
143
- (_f = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _f.call(bridge, "success");
144
- return { status: "success", kind: "products", meta: { count: addedCount } };
145
- }
146
- return { status: "failed", reason: "no_bridge" };
147
- }
148
- if (searchType === "order") {
149
- const orderId = (data == null ? void 0 : data.order_id) ?? (data == null ? void 0 : data.id);
150
- if (!orderId) {
151
- (_g = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _g.call(bridge, "fail", "pisell2.text.scan-global-failed");
152
- return { status: "failed", reason: "invalid_data" };
153
- }
154
- if (!(bridge == null ? void 0 : bridge.openOrder)) {
155
- return { status: "pending", kind: "openOrder" };
156
- }
157
- bridge.openOrder({
158
- order_id: Number(orderId),
159
- business_code: (data == null ? void 0 : data.business_code) ?? host.getBusinessCode()
160
- });
161
- return { status: "pending", kind: "openOrder" };
162
- }
163
- return { status: "failed", reason: "invalid_data" };
164
- }
165
- // Annotate the CommonJS export names for ESM import in node:
166
- 0 && (module.exports = {
167
- applyGlobalScan
168
- });
@@ -1,32 +0,0 @@
1
- /**
2
- * 全局扫码搜索结果格式化(对齐 ticketBooking `formatScanGlobal`)。
3
- */
4
- export type GlobalScanSearchType = 'customer' | 'wallet' | 'walletPass' | 'product' | 'local_product' | 'order';
5
- export interface GlobalScanFormattedResult {
6
- searchType: GlobalScanSearchType;
7
- data: any;
8
- scanCode: string;
9
- }
10
- interface RawScanSearchResult {
11
- searchType?: GlobalScanSearchType;
12
- response?: {
13
- status?: boolean;
14
- code?: number;
15
- message?: string;
16
- data?: any;
17
- };
18
- }
19
- /**
20
- * 将 handleGlobalScan 返回的原始结构格式化为 UI/OS 统一结构。
21
- *
22
- * @example
23
- * ```ts
24
- * const formatted = formatGlobalScanResult(
25
- * { searchType: 'wallet', response: { code: 200, data: { customer: {...} } } },
26
- * 'WL123',
27
- * );
28
- * // => { searchType: 'wallet', data: customerObj, scanCode: 'WL123' }
29
- * ```
30
- */
31
- export declare function formatGlobalScanResult(raw: RawScanSearchResult | null | undefined, scanCode: string): GlobalScanFormattedResult | null;
32
- export {};