@pisell/pisellos 2.3.184 → 2.3.185

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/dist/apis/picoding.d.ts.map +1 -0
  2. package/dist/core/index.d.ts.map +1 -0
  3. package/dist/effects/index.d.ts.map +1 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +1 -0
  7. package/dist/inventory/index.d.ts +92 -0
  8. package/dist/inventory/index.d.ts.map +1 -0
  9. package/dist/inventory/index.js +509 -0
  10. package/dist/model/index.d.ts.map +1 -0
  11. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts.map +1 -0
  12. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts.map +1 -0
  13. package/dist/model/strategy/adapter/dataVariant/examples.d.ts.map +1 -0
  14. package/dist/model/strategy/adapter/dataVariant/index.d.ts.map +1 -0
  15. package/dist/model/strategy/adapter/dataVariant/type.d.ts.map +1 -0
  16. package/dist/model/strategy/adapter/index.d.ts.map +1 -0
  17. package/dist/model/strategy/adapter/itemRule/adapter.d.ts.map +1 -0
  18. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts.map +1 -0
  19. package/dist/model/strategy/adapter/itemRule/examples.d.ts.map +1 -0
  20. package/dist/model/strategy/adapter/itemRule/index.d.ts.map +1 -0
  21. package/dist/model/strategy/adapter/itemRule/type.d.ts.map +1 -0
  22. package/dist/model/strategy/adapter/promotion/adapter.d.ts.map +1 -0
  23. package/dist/model/strategy/adapter/promotion/evaluator.d.ts.map +1 -0
  24. package/dist/model/strategy/adapter/promotion/examples.d.ts.map +1 -0
  25. package/dist/model/strategy/adapter/promotion/index.d.ts.map +1 -0
  26. package/dist/model/strategy/adapter/promotion/type.d.ts.map +1 -0
  27. package/dist/model/strategy/adapter/type.d.ts.map +1 -0
  28. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts.map +1 -0
  29. package/dist/model/strategy/adapter/walletPass/example.d.ts.map +1 -0
  30. package/dist/model/strategy/adapter/walletPass/index.d.ts.map +1 -0
  31. package/dist/model/strategy/adapter/walletPass/locales.d.ts.map +1 -0
  32. package/dist/model/strategy/adapter/walletPass/type.d.ts.map +1 -0
  33. package/dist/model/strategy/adapter/walletPass/utils.d.ts.map +1 -0
  34. package/dist/model/strategy/engine.d.ts.map +1 -0
  35. package/dist/model/strategy/index.d.ts.map +1 -0
  36. package/dist/model/strategy/strategy-example.d.ts.map +1 -0
  37. package/dist/model/strategy/type.d.ts.map +1 -0
  38. package/dist/modules/Account/index.d.ts.map +1 -0
  39. package/dist/modules/Account/types.d.ts.map +1 -0
  40. package/dist/modules/AccountList/index.d.ts.map +1 -0
  41. package/dist/modules/AccountList/types.d.ts.map +1 -0
  42. package/dist/modules/AccountList/utils.d.ts.map +1 -0
  43. package/dist/modules/BaseModule.d.ts.map +1 -0
  44. package/dist/modules/BookingContext/index.d.ts.map +1 -0
  45. package/dist/modules/BookingContext/types.d.ts.map +1 -0
  46. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts.map +1 -0
  47. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts.map +1 -0
  48. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts.map +1 -0
  49. package/dist/modules/BookingContext/utils/flexible.d.ts.map +1 -0
  50. package/dist/modules/BookingContext/utils/formatResourceList.d.ts.map +1 -0
  51. package/dist/modules/BookingContext/utils/index.d.ts.map +1 -0
  52. package/dist/modules/BookingContext/utils/noResource.d.ts.map +1 -0
  53. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts.map +1 -0
  54. package/dist/modules/BookingContext/utils/productExtend.d.ts.map +1 -0
  55. package/dist/modules/BookingContext/utils/resourceErrors.d.ts.map +1 -0
  56. package/dist/modules/BookingContext/utils/resourceSelection.d.ts.map +1 -0
  57. package/dist/modules/BookingContext/utils/resources.d.ts.map +1 -0
  58. package/dist/modules/BookingContext/utils/serviceTimes.d.ts.map +1 -0
  59. package/dist/modules/BookingContext/utils/timeSlices.d.ts.map +1 -0
  60. package/dist/modules/BusinessAvailability/index.d.ts.map +1 -0
  61. package/dist/modules/Cart/index.d.ts.map +1 -0
  62. package/dist/modules/Cart/types.d.ts.map +1 -0
  63. package/dist/modules/Cart/utils/cartAccount.d.ts.map +1 -0
  64. package/dist/modules/Cart/utils/cartDate.d.ts.map +1 -0
  65. package/dist/modules/Cart/utils/cartDiscount.d.ts.map +1 -0
  66. package/dist/modules/Cart/utils/cartNote.d.ts.map +1 -0
  67. package/dist/modules/Cart/utils/cartProduct.d.ts.map +1 -0
  68. package/dist/modules/Cart/utils/cartRelationForms.d.ts.map +1 -0
  69. package/dist/modules/Cart/utils/cartResource.d.ts.map +1 -0
  70. package/dist/modules/Cart/utils/changePrice.d.ts.map +1 -0
  71. package/dist/modules/Cart/utils/index.d.ts.map +1 -0
  72. package/dist/modules/Customer/constants.d.ts.map +1 -0
  73. package/dist/modules/Customer/index.d.ts.map +1 -0
  74. package/dist/modules/Customer/types.d.ts.map +1 -0
  75. package/dist/modules/Date/index.d.ts.map +1 -0
  76. package/dist/modules/Date/types.d.ts.map +1 -0
  77. package/dist/modules/Date/utils.d.ts.map +1 -0
  78. package/dist/modules/Discount/availability.d.ts.map +1 -0
  79. package/dist/modules/Discount/entitlementPass.d.ts.map +1 -0
  80. package/dist/modules/Discount/index.d.ts.map +1 -0
  81. package/dist/modules/Discount/index.js +1 -0
  82. package/dist/modules/Discount/types.d.ts.map +1 -0
  83. package/dist/modules/FulfillmentTiming/index.d.ts.map +1 -0
  84. package/dist/modules/FulfillmentTiming/types.d.ts.map +1 -0
  85. package/dist/modules/Guests/index.d.ts.map +1 -0
  86. package/dist/modules/Guests/types.d.ts.map +1 -0
  87. package/dist/modules/Holder/index.d.ts.map +1 -0
  88. package/dist/modules/Holder/types.d.ts.map +1 -0
  89. package/dist/modules/Holder/utils.d.ts.map +1 -0
  90. package/dist/modules/OpenData/contactInfo.d.ts.map +1 -0
  91. package/dist/modules/OpenData/index.d.ts.map +1 -0
  92. package/dist/modules/OpenData/salesSettings.d.ts.map +1 -0
  93. package/dist/modules/OpenData/types.d.ts.map +1 -0
  94. package/dist/modules/OpenData/utils.d.ts.map +1 -0
  95. package/dist/modules/Order/holderRelations.d.ts.map +1 -0
  96. package/dist/modules/Order/index.d.ts +25 -3
  97. package/dist/modules/Order/index.d.ts.map +1 -0
  98. package/dist/modules/Order/index.js +1770 -1311
  99. package/dist/modules/Order/localEftposState.d.ts.map +1 -0
  100. package/dist/modules/Order/payment-utils.d.ts.map +1 -0
  101. package/dist/modules/Order/pickupTiming.d.ts.map +1 -0
  102. package/dist/modules/Order/salesNotes.d.ts.map +1 -0
  103. package/dist/modules/Order/types.d.ts +7 -0
  104. package/dist/modules/Order/types.d.ts.map +1 -0
  105. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts.map +1 -0
  106. package/dist/modules/Order/utils/discountProductLineIdentity.d.ts.map +1 -0
  107. package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
  108. package/dist/modules/Order/utils/manualProductDiscount.d.ts.map +1 -0
  109. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts.map +1 -0
  110. package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  111. package/dist/modules/Order/utils/productVoucherGroups.d.ts.map +1 -0
  112. package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
  113. package/dist/modules/Order/utils/virtualSettlement.d.ts.map +1 -0
  114. package/dist/modules/Order/utils/weighedProduct.d.ts.map +1 -0
  115. package/dist/modules/Order/utils.d.ts.map +1 -0
  116. package/dist/modules/Payment/cash.d.ts.map +1 -0
  117. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts.map +1 -0
  118. package/dist/modules/Payment/eftpos.d.ts.map +1 -0
  119. package/dist/modules/Payment/index.d.ts.map +1 -0
  120. package/dist/modules/Payment/mx51.d.ts.map +1 -0
  121. package/dist/modules/Payment/types.d.ts.map +1 -0
  122. package/dist/modules/Payment/utils.d.ts.map +1 -0
  123. package/dist/modules/Payment/walletpass.d.ts.map +1 -0
  124. package/dist/modules/Product/index.d.ts +1 -1
  125. package/dist/modules/Product/index.d.ts.map +1 -0
  126. package/dist/modules/Product/types.d.ts.map +1 -0
  127. package/dist/modules/Product/utils.d.ts.map +1 -0
  128. package/dist/modules/ProductList/clientDataVariants.d.ts.map +1 -0
  129. package/dist/modules/ProductList/index.d.ts.map +1 -0
  130. package/dist/modules/ProductList/index.js +33 -12
  131. package/dist/modules/ProductList/types.d.ts.map +1 -0
  132. package/dist/modules/Quotation/index.d.ts.map +1 -0
  133. package/dist/modules/Quotation/types.d.ts.map +1 -0
  134. package/dist/modules/Resource/index.d.ts.map +1 -0
  135. package/dist/modules/Resource/types.d.ts.map +1 -0
  136. package/dist/modules/Resource/utils.d.ts.map +1 -0
  137. package/dist/modules/ResourcePlanner/index.d.ts.map +1 -0
  138. package/dist/modules/ResourcePlanner/localClock.d.ts.map +1 -0
  139. package/dist/modules/ResourcePlanner/planner.d.ts.map +1 -0
  140. package/dist/modules/ResourcePlanner/types.d.ts.map +1 -0
  141. package/dist/modules/Rules/index.d.ts +2 -0
  142. package/dist/modules/Rules/index.d.ts.map +1 -0
  143. package/dist/modules/Rules/index.js +29 -21
  144. package/dist/modules/Rules/promotionSelection.d.ts.map +1 -0
  145. package/dist/modules/Rules/types.d.ts.map +1 -0
  146. package/dist/modules/SalesSummary/index.d.ts.map +1 -0
  147. package/dist/modules/SalesSummary/types.d.ts.map +1 -0
  148. package/dist/modules/SalesSummary/utils.d.ts.map +1 -0
  149. package/dist/modules/ScanOrderLogger/index.d.ts.map +1 -0
  150. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts.map +1 -0
  151. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts.map +1 -0
  152. package/dist/modules/ScanOrderLogger/types.d.ts.map +1 -0
  153. package/dist/modules/Schedule/getDateIsInSchedule.d.ts.map +1 -0
  154. package/dist/modules/Schedule/index.d.ts.map +1 -0
  155. package/dist/modules/Schedule/type.d.ts.map +1 -0
  156. package/dist/modules/Schedule/types.d.ts.map +1 -0
  157. package/dist/modules/Schedule/utils.d.ts.map +1 -0
  158. package/dist/modules/Step/index.d.ts.map +1 -0
  159. package/dist/modules/Step/tyeps.d.ts.map +1 -0
  160. package/dist/modules/Summary/index.d.ts.map +1 -0
  161. package/dist/modules/Summary/types.d.ts.map +1 -0
  162. package/dist/modules/Summary/utils.d.ts.map +1 -0
  163. package/dist/modules/SurchargeList/index.d.ts.map +1 -0
  164. package/dist/modules/SurchargeList/types.d.ts.map +1 -0
  165. package/dist/modules/index.d.ts.map +1 -0
  166. package/dist/plugins/app.d.ts.map +1 -0
  167. package/dist/plugins/index.d.ts.map +1 -0
  168. package/dist/plugins/request.d.ts.map +1 -0
  169. package/dist/plugins/shopStore.d.ts.map +1 -0
  170. package/dist/plugins/user.d.ts.map +1 -0
  171. package/dist/plugins/window.d.ts.map +1 -0
  172. package/dist/server/index.d.ts.map +1 -0
  173. package/dist/server/modules/floor-plan/index.d.ts.map +1 -0
  174. package/dist/server/modules/floor-plan/types.d.ts.map +1 -0
  175. package/dist/server/modules/form/index.d.ts.map +1 -0
  176. package/dist/server/modules/form/types.d.ts.map +1 -0
  177. package/dist/server/modules/index.d.ts.map +1 -0
  178. package/dist/server/modules/menu/index.d.ts.map +1 -0
  179. package/dist/server/modules/menu/types.d.ts.map +1 -0
  180. package/dist/server/modules/order/index.d.ts.map +1 -0
  181. package/dist/server/modules/order/types.d.ts.map +1 -0
  182. package/dist/server/modules/order/utils/filterBookings.d.ts.map +1 -0
  183. package/dist/server/modules/order/utils/filterOrders.d.ts.map +1 -0
  184. package/dist/server/modules/payment/index.d.ts.map +1 -0
  185. package/dist/server/modules/payment/types.d.ts.map +1 -0
  186. package/dist/server/modules/products/index.d.ts.map +1 -0
  187. package/dist/server/modules/products/replication.d.ts.map +1 -0
  188. package/dist/server/modules/products/types.d.ts.map +1 -0
  189. package/dist/server/modules/quotation/index.d.ts.map +1 -0
  190. package/dist/server/modules/quotation/types.d.ts.map +1 -0
  191. package/dist/server/modules/resource/index.d.ts.map +1 -0
  192. package/dist/server/modules/resource/types.d.ts.map +1 -0
  193. package/dist/server/modules/schedule/index.d.ts.map +1 -0
  194. package/dist/server/modules/schedule/types.d.ts.map +1 -0
  195. package/dist/server/modules/schedule/utils.d.ts.map +1 -0
  196. package/dist/server/types.d.ts.map +1 -0
  197. package/dist/server/utils/index.d.ts.map +1 -0
  198. package/dist/server/utils/product.d.ts.map +1 -0
  199. package/dist/server/utils/schedule.d.ts.map +1 -0
  200. package/dist/server/utils/small-ticket.d.ts.map +1 -0
  201. package/dist/server/utils/time.d.ts.map +1 -0
  202. package/dist/shared/payment/loadPaymentMethods.d.ts.map +1 -0
  203. package/dist/shared/receipt/customerInvoiceLanguages.d.ts.map +1 -0
  204. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts.map +1 -0
  205. package/dist/shared/receipt/small-ticket.d.ts.map +1 -0
  206. package/dist/shared/receipt/templateVisibility.d.ts.map +1 -0
  207. package/dist/shared/sales/loadSalesOrderSnapshot.d.ts.map +1 -0
  208. package/dist/solution/BaseSales/fulfillmentItemRules.d.ts.map +1 -0
  209. package/dist/solution/BaseSales/index.d.ts +17 -1
  210. package/dist/solution/BaseSales/index.d.ts.map +1 -0
  211. package/dist/solution/BaseSales/index.js +1611 -1372
  212. package/dist/solution/BaseSales/pickupTiming.d.ts.map +1 -0
  213. package/dist/solution/BaseSales/types.d.ts.map +1 -0
  214. package/dist/solution/BaseSales/utils/cartPromotion.d.ts.map +1 -0
  215. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts.map +1 -0
  216. package/dist/solution/BaseSales/utils/quotationPrice.d.ts.map +1 -0
  217. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts.map +1 -0
  218. package/dist/solution/BaseSales/utils.d.ts.map +1 -0
  219. package/dist/solution/BookingByStep/index.d.ts +1 -1
  220. package/dist/solution/BookingByStep/index.d.ts.map +1 -0
  221. package/dist/solution/BookingByStep/types.d.ts.map +1 -0
  222. package/dist/solution/BookingByStep/utils/capacity.d.ts.map +1 -0
  223. package/dist/solution/BookingByStep/utils/products.d.ts.map +1 -0
  224. package/dist/solution/BookingByStep/utils/resources.d.ts.map +1 -0
  225. package/dist/solution/BookingByStep/utils/stock.d.ts.map +1 -0
  226. package/dist/solution/BookingByStep/utils/timeslots.d.ts.map +1 -0
  227. package/dist/solution/BookingTicket/index.d.ts +13 -1
  228. package/dist/solution/BookingTicket/index.d.ts.map +1 -0
  229. package/dist/solution/BookingTicket/index.js +197 -108
  230. package/dist/solution/BookingTicket/types.d.ts +14 -2
  231. package/dist/solution/BookingTicket/types.d.ts.map +1 -0
  232. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  233. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts.map +1 -0
  234. package/dist/solution/BookingTicket/utils/addProductDecision.js +4 -3
  235. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts.map +1 -0
  236. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts.map +1 -0
  237. package/dist/solution/BookingTicket/utils/cartView.d.ts.map +1 -0
  238. package/dist/solution/BookingTicket/utils/exampleData.d.ts.map +1 -0
  239. package/dist/solution/BookingTicket/utils/orderCustomer.d.ts.map +1 -0
  240. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts.map +1 -0
  241. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts.map +1 -0
  242. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
  243. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts.map +1 -0
  244. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +88 -0
  245. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts.map +1 -0
  246. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  247. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts.map +1 -0
  248. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts.map +1 -0
  249. package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  250. package/dist/solution/BookingTicket/utils/scan/index.d.ts.map +1 -0
  251. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts.map +1 -0
  252. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts.map +1 -0
  253. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts.map +1 -0
  254. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts.map +1 -0
  255. package/dist/solution/BuyTickets/index.d.ts.map +1 -0
  256. package/dist/solution/BuyTickets/types.d.ts.map +1 -0
  257. package/dist/solution/Checkout/index.d.ts.map +1 -0
  258. package/dist/solution/Checkout/types.d.ts.map +1 -0
  259. package/dist/solution/Checkout/utils/index.d.ts.map +1 -0
  260. package/dist/solution/OrderInvoicePreview/index.d.ts.map +1 -0
  261. package/dist/solution/PlaceOrder/index.d.ts.map +1 -0
  262. package/dist/solution/RegisterAndLogin/config.d.ts.map +1 -0
  263. package/dist/solution/RegisterAndLogin/index.d.ts.map +1 -0
  264. package/dist/solution/RegisterAndLogin/types.d.ts.map +1 -0
  265. package/dist/solution/RegisterAndLogin/utils.d.ts.map +1 -0
  266. package/dist/solution/Sales/index.d.ts.map +1 -0
  267. package/dist/solution/Sales/types.d.ts.map +1 -0
  268. package/dist/solution/ScanOrder/index.d.ts.map +1 -0
  269. package/dist/solution/ScanOrder/menuAvailability.d.ts.map +1 -0
  270. package/dist/solution/ScanOrder/types.d.ts.map +1 -0
  271. package/dist/solution/ScanOrder/utils.d.ts.map +1 -0
  272. package/dist/solution/ShopDiscount/index.d.ts.map +1 -0
  273. package/dist/solution/ShopDiscount/types.d.ts.map +1 -0
  274. package/dist/solution/ShopDiscount/utils.d.ts.map +1 -0
  275. package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts.map +1 -0
  276. package/dist/solution/UnifiedBookingSales/index.d.ts +1 -1
  277. package/dist/solution/UnifiedBookingSales/index.d.ts.map +1 -0
  278. package/dist/solution/UnifiedBookingSales/index.js +79 -59
  279. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts.map +1 -0
  280. package/dist/solution/UnifiedBookingSales/salesSettings.d.ts.map +1 -0
  281. package/dist/solution/UnifiedBookingSales/types.d.ts.map +1 -0
  282. package/dist/solution/VenueBooking/index.d.ts.map +1 -0
  283. package/dist/solution/VenueBooking/types.d.ts.map +1 -0
  284. package/dist/solution/VenueBooking/utils/dateSummary.d.ts.map +1 -0
  285. package/dist/solution/VenueBooking/utils/resource.d.ts.map +1 -0
  286. package/dist/solution/VenueBooking/utils/slotMerge.d.ts.map +1 -0
  287. package/dist/solution/VenueBooking/utils/smartPricing.d.ts.map +1 -0
  288. package/dist/solution/VenueBooking/utils/timeSlot.d.ts.map +1 -0
  289. package/dist/solution/VenueBooking/utils.d.ts.map +1 -0
  290. package/dist/solution/index.d.ts.map +1 -0
  291. package/dist/store/createStore.d.ts.map +1 -0
  292. package/dist/types/index.d.ts.map +1 -0
  293. package/dist/utils/os-private-payload.d.ts.map +1 -0
  294. package/dist/utils/payment-number.d.ts.map +1 -0
  295. package/dist/utils/platform.d.ts +2 -0
  296. package/dist/utils/platform.d.ts.map +1 -0
  297. package/dist/utils/platform.js +6 -0
  298. package/dist/utils/task.d.ts.map +1 -0
  299. package/dist/utils/watch.d.ts.map +1 -0
  300. package/lib/index.d.ts +1 -0
  301. package/lib/index.js +12 -0
  302. package/lib/inventory/index.d.ts +92 -0
  303. package/lib/inventory/index.js +287 -0
  304. package/lib/modules/Discount/index.js +1 -0
  305. package/lib/modules/Order/index.d.ts +25 -3
  306. package/lib/modules/Order/index.js +192 -38
  307. package/lib/modules/Order/types.d.ts +7 -0
  308. package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
  309. package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  310. package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
  311. package/lib/modules/Product/index.d.ts +1 -1
  312. package/lib/modules/ProductList/index.js +15 -0
  313. package/lib/modules/Rules/index.d.ts +2 -0
  314. package/lib/modules/Rules/index.js +6 -0
  315. package/lib/solution/BaseSales/index.d.ts +17 -1
  316. package/lib/solution/BaseSales/index.js +119 -14
  317. package/lib/solution/BookingByStep/index.d.ts +1 -1
  318. package/lib/solution/BookingTicket/index.d.ts +13 -1
  319. package/lib/solution/BookingTicket/index.js +37 -2
  320. package/lib/solution/BookingTicket/types.d.ts +14 -2
  321. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  322. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -3
  323. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
  324. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +54 -0
  325. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  326. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  327. package/lib/solution/UnifiedBookingSales/index.d.ts +1 -1
  328. package/lib/solution/UnifiedBookingSales/index.js +14 -3
  329. package/lib/utils/platform.d.ts +2 -0
  330. package/lib/utils/platform.js +7 -0
  331. package/package.json +1 -1
@@ -21,6 +21,7 @@ var _weighedProduct = require("./utils/weighedProduct");
21
21
  var _pickupTiming = require("./pickupTiming");
22
22
  var _dayjs = _interopRequireDefault(require("dayjs"));
23
23
  var _availability = require("../Discount/availability");
24
+ var _productVoucherGroups = require("./utils/productVoucherGroups");
24
25
  var _osPrivatePayload = require("../../utils/os-private-payload");
25
26
  var _salesNotes = require("./salesNotes");
26
27
  var _paymentUtils = require("./payment-utils");
@@ -147,6 +148,66 @@ class OrderModule extends _BaseModule.BaseModule {
147
148
  rulesHooksOverride;
148
149
  moduleHooksOverride;
149
150
  orderHooks;
151
+ cartCommandQueue = Promise.resolve();
152
+ queueCartCommand(run) {
153
+ if (!this.orderHooks?.onBeforeCartCommit && !this.store.tempOrder?._extend?.productVoucherGroups?.length) return run();
154
+ const pending = this.cartCommandQueue.then(run, run);
155
+ this.cartCommandQueue = pending.catch(() => undefined);
156
+ return pending;
157
+ }
158
+
159
+ /** Use the exact Order normalizers/merge rules on a private draft, not a second projection. */
160
+ beginCartMutation() {
161
+ const current = this.ensureTempOrder();
162
+ const guard = this.orderHooks?.onBeforeCartCommit;
163
+ if (!guard && !current._extend?.productVoucherGroups?.length) return {
164
+ draft: current,
165
+ commit: undefined
166
+ };
167
+ const before = (0, _lodashEs.cloneDeep)(current);
168
+ const draft = (0, _lodashEs.cloneDeep)(current);
169
+ return {
170
+ draft,
171
+ commit: async options => {
172
+ if (options?.isCurrentOrder && !options.isCurrentOrder()) return current;
173
+ (0, _productVoucherGroups.validateProductVoucherGroups)(draft, this.getDiscountList(), before);
174
+ await guard?.({
175
+ currentItems: (0, _lodashEs.cloneDeep)(before.products),
176
+ proposedItems: (0, _lodashEs.cloneDeep)(draft.products)
177
+ });
178
+ if (options?.isCurrentOrder && !options.isCurrentOrder()) return current;
179
+ if (this.store.tempOrder !== current || guard !== this.orderHooks?.onBeforeCartCommit || !(0, _lodashEs.isEqual)(current, before)) {
180
+ throw Object.assign(new Error('The cart changed. Please try again.'), {
181
+ code: 'SALES_GUARD_REJECTED'
182
+ });
183
+ }
184
+ // Recheck synchronous order/availability guards after async inventory validation.
185
+ options?.beforeCommit?.();
186
+ Object.assign(current, draft);
187
+ return current;
188
+ }
189
+ };
190
+ }
191
+
192
+ /** Serializes checkout preparation with local cart commands; hydration remains outside this guard. */
193
+ async prepareCheckout(prepare) {
194
+ const run = async () => {
195
+ const order = this.ensureTempOrder();
196
+ (0, _productVoucherGroups.validateProductVoucherGroups)(order, this.getDiscountList(), undefined, true);
197
+ const items = (0, _lodashEs.cloneDeep)(order.products);
198
+ const result = await prepare(items);
199
+ if (this.store.tempOrder !== order || !(0, _lodashEs.isEqual)(order.products, items)) {
200
+ throw Object.assign(new Error('The cart changed. Please try again.'), {
201
+ code: 'SALES_GUARD_REJECTED'
202
+ });
203
+ }
204
+ (0, _productVoucherGroups.validateProductVoucherGroups)(order, this.getDiscountList(), undefined, true);
205
+ return result;
206
+ };
207
+ const pending = this.cartCommandQueue.then(run, run);
208
+ this.cartCommandQueue = pending.catch(() => undefined);
209
+ return pending;
210
+ }
150
211
  otherParams;
151
212
  // ─── 促销/赠品 ────────────────────────────────────
152
213
  /** 评估器引用;由 SalesSdkProvider 注入,未注入时 applyPromotion 静默跳过 */
@@ -434,8 +495,11 @@ class OrderModule extends _BaseModule.BaseModule {
434
495
  * @example
435
496
  * orderModule.updateOtherParams({ cacheId: 'cache-2', channel: 'pos' });
436
497
  */
437
- updateOtherParams(params) {
498
+ updateOtherParams(params, options) {
438
499
  const otherParams = params || {};
500
+ if (options && Object.prototype.hasOwnProperty.call(options, 'hooks')) {
501
+ this.moduleHooksOverride = options.hooks;
502
+ }
439
503
  this.syncSessionStorageOptions(otherParams);
440
504
  this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
441
505
  this.rulesHooksOverride = otherParams.rules?.hooks;
@@ -542,6 +606,26 @@ class OrderModule extends _BaseModule.BaseModule {
542
606
  hooks: this.rulesHooksOverride || this.createDefaultRulesHooks()
543
607
  });
544
608
  this.store.rules = rules;
609
+ rules.setDiscountScope((product, discount) => (0, _productVoucherGroups.allowsProductVoucher)(this.store.tempOrder, product, discount));
610
+ }
611
+ setProductVoucherGroups(groups) {
612
+ const order = this.ensureTempOrder();
613
+ const ids = new Set();
614
+ const keys = new Set();
615
+ const known = new Map(this.getDiscountList().map(discount => [String(discount.id), discount]));
616
+ for (const group of groups) {
617
+ if (!group.key || keys.has(group.key)) throw (0, _productVoucherGroups.voucherGroupError)();
618
+ keys.add(group.key);
619
+ for (const id of group.discountIds) {
620
+ const discount = known.get(String(id));
621
+ if (!discount || (discount.tag || discount.type) !== 'good_pass' || ids.has(String(id))) throw (0, _productVoucherGroups.voucherGroupError)();
622
+ ids.add(String(id));
623
+ }
624
+ }
625
+ this.ensureExtend(order).productVoucherGroups = (0, _lodashEs.cloneDeep)(groups);
626
+ }
627
+ validateProductVoucherSelection() {
628
+ (0, _productVoucherGroups.validateProductVoucherGroups)(this.ensureTempOrder(), this.getDiscountList(), undefined, true);
545
629
  }
546
630
  createDefaultRulesHooks() {
547
631
  return (0, _utils.createDefaultOrderRulesHooks)(() => this.store.tempOrder?.bookings || [], () => this.store.tempOrder?.holder_relations);
@@ -704,7 +788,7 @@ class OrderModule extends _BaseModule.BaseModule {
704
788
  apply: false
705
789
  });
706
790
  }
707
- async scanCode(code, customerId) {
791
+ async scanCode(code, customerId, options) {
708
792
  const beforeCommit = this.createCartIntentCommitGuard('scan_promotion');
709
793
  if (this.isActiveVirtualSettlementOrder(this.store.tempOrder)) {
710
794
  return {
@@ -716,16 +800,22 @@ class OrderModule extends _BaseModule.BaseModule {
716
800
  unavailableReason: _types2.UnavailableReason.ProductNotApplicable
717
801
  };
718
802
  }
803
+ const scanOrderKey = this.getDiscountConfigOrderIdentityKey(this.store.tempOrder);
719
804
  const resultDiscountWithReason = (await this.store.discount?.batchSearch(code, {
720
805
  customerId
721
806
  })) || {
722
807
  discountList: [],
723
808
  unavailableReasonKey: null
724
809
  };
810
+ if (scanOrderKey !== this.getDiscountConfigOrderIdentityKey(this.store.tempOrder)) {
811
+ throw Object.assign(new Error('The scan session ended.'), {
812
+ code: 'SALES_GUARD_REJECTED'
813
+ });
814
+ }
725
815
  const {
726
- discountList: resultDiscountList,
727
816
  unavailableReasonKey
728
817
  } = resultDiscountWithReason;
818
+ const resultDiscountList = resultDiscountWithReason.discountList.filter(discount => !options?.productVouchersOnly || (discount.tag || discount.type) === 'good_pass');
729
819
  const rulesModule = this.store.rules;
730
820
  if (!rulesModule) {
731
821
  return {
@@ -752,7 +842,7 @@ class OrderModule extends _BaseModule.BaseModule {
752
842
  isScan: true
753
843
  }));
754
844
  const currentSelected = this.getDiscountList().filter(n => n.isSelected);
755
- if (currentSelected.length && currentSelected.some(n => withScanList.some(m => m.id === n.id))) {
845
+ if (currentSelected.length && (options?.productVouchersOnly ? withScanList.every(scanned => currentSelected.some(selected => selected.id === scanned.id)) : currentSelected.some(n => withScanList.some(m => m.id === n.id)))) {
756
846
  beforeCommit();
757
847
  await this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
758
848
  return {
@@ -2273,8 +2363,12 @@ class OrderModule extends _BaseModule.BaseModule {
2273
2363
  ...existed,
2274
2364
  ...(origin !== undefined ? {
2275
2365
  origin
2366
+ } : {}),
2367
+ ...(rawProduct._productVoucherGroupKey ? {
2368
+ productVoucherGroupKey: rawProduct._productVoucherGroupKey
2276
2369
  } : {})
2277
2370
  };
2371
+ delete normalizedProduct._productVoucherGroupKey;
2278
2372
  delete normalizedProduct._origin;
2279
2373
  delete normalizedProduct.unique_identification_number;
2280
2374
  }
@@ -3600,6 +3694,7 @@ class OrderModule extends _BaseModule.BaseModule {
3600
3694
  const isIncomingCustomItem = productToAdd.metadata?.origin?.isCustomItem === true || productToAdd._origin?.isCustomItem === true;
3601
3695
  const shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || hasIncomingHolder || isIncomingCustomItem || isWeighingProduct;
3602
3696
  const matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(item => {
3697
+ if ((0, _productVoucherGroups.productVoucherGroupKey)(tempOrder, item) !== productToAdd._productVoucherGroupKey) return false;
3603
3698
  if (this.hasGoodPassDiscount(item)) return false;
3604
3699
  if ((0, _holderRelations.getProductHolderRelations)(tempOrder, item).length > 0 || (0, _utils.hasAssignedHolderId)(item.metadata?.holder_id)) return false;
3605
3700
  const isRuntimeEntitlementPass = this.isRuntimeEntitlementAppend(item, tempOrder);
@@ -3783,16 +3878,37 @@ class OrderModule extends _BaseModule.BaseModule {
3783
3878
  * // → tempOrder.products 新增 3 行,每行 num=1,bookings 3 条
3784
3879
  */
3785
3880
  async addProductToOrder(product, booking, options) {
3881
+ return this.queueCartCommand(() => this.addProductToOrderDraft(product, booking, options));
3882
+ }
3883
+ async addProductToOrderDraft(product, booking, options) {
3786
3884
  const availabilityCommitGuard = options?.availabilityCommitGuard;
3787
3885
  availabilityCommitGuard?.();
3788
3886
  const liveTempOrder = this.ensureTempOrder();
3789
3887
  const beforeCommit = this.createCartIntentCommitGuard('add_product', liveTempOrder);
3790
- // 自动预约在草稿上准备完整批次,避免拆票期间暴露半成品,或在失败时
3791
- // 用整单快照回滚而抹掉其他入口的并发修改。人工路径保持原有写入行为。
3792
- const tempOrder = availabilityCommitGuard ? (0, _lodashEs.cloneDeep)(liveTempOrder) : liveTempOrder;
3888
+ const mutation = this.beginCartMutation();
3889
+ // 库存/商品券校验与自动预约共用草稿,全部门禁通过后才发布完整批次。
3890
+ const tempOrder = availabilityCommitGuard && !mutation.commit ? (0, _lodashEs.cloneDeep)(liveTempOrder) : mutation.draft;
3891
+ const beforeAppend = mutation.commit ? undefined : beforeCommit;
3793
3892
  const guardedMutationFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'currency_code', 'currency_symbol', 'currency_format'];
3794
3893
  const readGuardedMutationFields = order => Object.fromEntries(guardedMutationFields.map(key => [key, order[key]]));
3795
3894
  const guardedMutationBaseline = availabilityCommitGuard ? (0, _lodashEs.cloneDeep)(readGuardedMutationFields(liveTempOrder)) : null;
3895
+ const beforePublish = () => {
3896
+ availabilityCommitGuard?.();
3897
+ beforeCommit();
3898
+ // 调用方的结构 revision 可能不包括备注、价格或结算元数据。
3899
+ if (availabilityCommitGuard && !(0, _lodashEs.isEqual)(readGuardedMutationFields(liveTempOrder), guardedMutationBaseline)) {
3900
+ throw Object.assign(new Error('预约加购期间订单已变化,请重新选择'), {
3901
+ code: 'AVAILABILITY_SELECTION_STALE'
3902
+ });
3903
+ }
3904
+ };
3905
+ if (options?.productVoucherGroupKey) {
3906
+ if (!tempOrder._extend?.productVoucherGroups?.some(group => group.key === options.productVoucherGroupKey)) throw (0, _productVoucherGroups.voucherGroupError)();
3907
+ product = {
3908
+ ...product,
3909
+ _productVoucherGroupKey: options.productVoucherGroupKey
3910
+ };
3911
+ }
3796
3912
  const salesNoteDrafts = (options?.salesNotes || []).map(draft => ({
3797
3913
  note_type: String(draft.note_type || '').trim(),
3798
3914
  text: {
@@ -3866,7 +3982,7 @@ class OrderModule extends _BaseModule.BaseModule {
3866
3982
  const committedProduct = await this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
3867
3983
  insertAtIndex,
3868
3984
  disableMerge: options?.disableMerge,
3869
- beforeCommit
3985
+ beforeCommit: beforeAppend
3870
3986
  });
3871
3987
  availabilityCommitGuard?.();
3872
3988
  attachSalesNoteDrafts(committedProduct);
@@ -3876,7 +3992,7 @@ class OrderModule extends _BaseModule.BaseModule {
3876
3992
  const committedProduct = await this.appendProductLineToTempOrder(tempOrder, product, (0, _lodashEs.cloneDeep)(booking), {
3877
3993
  insertAtIndex,
3878
3994
  disableMerge: options?.disableMerge,
3879
- beforeCommit
3995
+ beforeCommit: beforeAppend
3880
3996
  });
3881
3997
  availabilityCommitGuard?.();
3882
3998
  attachSalesNoteDrafts(committedProduct);
@@ -3885,21 +4001,17 @@ class OrderModule extends _BaseModule.BaseModule {
3885
4001
  const committedProduct = await this.appendProductLineToTempOrder(tempOrder, product, undefined, {
3886
4002
  insertAtIndex,
3887
4003
  disableMerge: options?.disableMerge,
3888
- beforeCommit
4004
+ beforeCommit: beforeAppend
3889
4005
  });
3890
4006
  availabilityCommitGuard?.();
3891
4007
  attachSalesNoteDrafts(committedProduct);
3892
4008
  }
3893
- if (availabilityCommitGuard) {
3894
- availabilityCommitGuard();
3895
- beforeCommit();
3896
- // 调用方的结构 revision 可能不包括备注、价格或结算元数据。
3897
- // 本次会覆盖的字段也要保持原值,不能让草稿覆盖并发编辑。
3898
- if (!(0, _lodashEs.isEqual)(readGuardedMutationFields(liveTempOrder), guardedMutationBaseline)) {
3899
- throw Object.assign(new Error('预约加购期间订单已变化,请重新选择'), {
3900
- code: 'AVAILABILITY_SELECTION_STALE'
3901
- });
3902
- }
4009
+ if (mutation.commit) {
4010
+ await mutation.commit({
4011
+ beforeCommit: beforePublish
4012
+ });
4013
+ } else if (availabilityCommitGuard) {
4014
+ beforePublish();
3903
4015
  // 从最后一次门禁到真正新增之间不再 await。只发布本次新增会改写的
3904
4016
  // 字段;其余订单字段继续使用 live 对象,外部持有的订单引用也不变。
3905
4017
  Object.assign(liveTempOrder, readGuardedMutationFields(tempOrder));
@@ -3947,9 +4059,14 @@ class OrderModule extends _BaseModule.BaseModule {
3947
4059
  * ]);
3948
4060
  */
3949
4061
  async addProductsToOrder(items, options) {
3950
- const tempOrder = this.ensureTempOrder();
4062
+ return this.queueCartCommand(() => this.addProductsToOrderDraft(items, options));
4063
+ }
4064
+ async addProductsToOrderDraft(items, options) {
4065
+ const mutation = this.beginCartMutation();
4066
+ let tempOrder = mutation.draft;
3951
4067
  if (!Array.isArray(items) || items.length === 0) return tempOrder.products;
3952
- const beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
4068
+ const beforeCommit = this.createCartIntentCommitGuard('add_product');
4069
+ const beforeAppend = mutation.commit ? undefined : beforeCommit;
3953
4070
  for (const item of items || []) {
3954
4071
  const {
3955
4072
  product,
@@ -3963,7 +4080,7 @@ class OrderModule extends _BaseModule.BaseModule {
3963
4080
  for (let i = 0; i < splitCount; i += 1) {
3964
4081
  const splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
3965
4082
  const appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
3966
- beforeCommit
4083
+ beforeCommit: beforeAppend
3967
4084
  });
3968
4085
  if (appendResult) await appendResult;
3969
4086
  }
@@ -3971,10 +4088,13 @@ class OrderModule extends _BaseModule.BaseModule {
3971
4088
  }
3972
4089
  }
3973
4090
  const appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
3974
- beforeCommit
4091
+ beforeCommit: beforeAppend
3975
4092
  });
3976
4093
  if (appendResult) await appendResult;
3977
4094
  }
4095
+ if (mutation.commit) tempOrder = await mutation.commit({
4096
+ beforeCommit
4097
+ });
3978
4098
  await this.finalizeProductOrderMutation(tempOrder, options);
3979
4099
  this.logInfo('addProductsToOrder success', {
3980
4100
  itemsCount: items.length
@@ -4318,12 +4438,18 @@ class OrderModule extends _BaseModule.BaseModule {
4318
4438
  return tempOrder.products[productIndex].metadata?.unique_identification_number;
4319
4439
  }
4320
4440
  async updateOrderProduct(params) {
4321
- const tempOrder = this.ensureTempOrder();
4322
- if (this.isRestrictedCartProductUpdate(tempOrder, params)) {
4323
- this.createCartIntentCommitGuard('update_product', tempOrder)();
4324
- }
4441
+ return this.queueCartCommand(() => this.updateOrderProductDraft(params));
4442
+ }
4443
+ async updateOrderProductDraft(params) {
4444
+ const mutation = this.beginCartMutation();
4445
+ let tempOrder = mutation.draft;
4446
+ const beforeCommit = this.isRestrictedCartProductUpdate(tempOrder, params) ? this.createCartIntentCommitGuard('update_product') : undefined;
4447
+ if (!mutation.commit) beforeCommit?.();
4325
4448
  const reapplyWeighedDiscountProductUids = [];
4326
4449
  const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
4450
+ if (mutation.commit) tempOrder = await mutation.commit({
4451
+ beforeCommit
4452
+ });
4327
4453
  const promotionPayload = await this.evaluatePromotion();
4328
4454
  this.applyDiscount({
4329
4455
  reapplyWeighedDiscountProductUids,
@@ -4341,13 +4467,16 @@ class OrderModule extends _BaseModule.BaseModule {
4341
4467
  return tempOrder.products;
4342
4468
  }
4343
4469
  async updateOrderProducts(paramsList) {
4344
- const tempOrder = this.ensureTempOrder();
4470
+ return this.queueCartCommand(() => this.updateOrderProductsDraft(paramsList));
4471
+ }
4472
+ async updateOrderProductsDraft(paramsList) {
4473
+ const mutation = this.beginCartMutation();
4474
+ let tempOrder = mutation.draft;
4345
4475
  if (!paramsList.length) {
4346
4476
  return tempOrder.products;
4347
4477
  }
4348
- if (paramsList.some(params => this.isRestrictedCartProductUpdate(tempOrder, params))) {
4349
- this.createCartIntentCommitGuard('update_product', tempOrder)();
4350
- }
4478
+ const beforeCommit = paramsList.some(params => this.isRestrictedCartProductUpdate(tempOrder, params)) ? this.createCartIntentCommitGuard('update_product') : undefined;
4479
+ if (!mutation.commit) beforeCommit?.();
4351
4480
  const reapplyWeighedDiscountProductUids = [];
4352
4481
  const reapplyBookingDiscountProductUids = paramsList.reduce((acc, params) => {
4353
4482
  const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
@@ -4357,6 +4486,9 @@ class OrderModule extends _BaseModule.BaseModule {
4357
4486
  }
4358
4487
  return acc;
4359
4488
  }, []);
4489
+ if (mutation.commit) tempOrder = await mutation.commit({
4490
+ beforeCommit
4491
+ });
4360
4492
  await this.finalizeAfterProductsMutation(tempOrder, {
4361
4493
  reapplyWeighedDiscountProductUids,
4362
4494
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
@@ -4367,6 +4499,9 @@ class OrderModule extends _BaseModule.BaseModule {
4367
4499
  return tempOrder.products;
4368
4500
  }
4369
4501
  async updateOrderProductQuantity(params, options) {
4502
+ return this.queueCartCommand(() => this.updateOrderProductQuantityDraft(params, options));
4503
+ }
4504
+ async updateOrderProductQuantityDraft(params, options) {
4370
4505
  const isCurrentOrder = options?.isCurrentOrder;
4371
4506
  if (isCurrentOrder && !isCurrentOrder()) return this.store.tempOrder?.products || [];
4372
4507
  const {
@@ -4378,7 +4513,8 @@ class OrderModule extends _BaseModule.BaseModule {
4378
4513
  product_sku,
4379
4514
  product_bundle
4380
4515
  } = params;
4381
- const tempOrder = this.ensureTempOrder();
4516
+ const mutation = this.beginCartMutation();
4517
+ let tempOrder = mutation.draft;
4382
4518
  this.repairDuplicateProductLineIdentities(tempOrder);
4383
4519
  const identityLookup = {
4384
4520
  product_id,
@@ -4434,11 +4570,16 @@ class OrderModule extends _BaseModule.BaseModule {
4434
4570
  throw new _virtualSettlement.VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
4435
4571
  }
4436
4572
  }
4437
- if (normalizedProduct.num > targetProduct.num) {
4438
- this.createCartIntentCommitGuard('increase_quantity', tempOrder)();
4439
- }
4573
+ const beforeCommit = normalizedProduct.num > targetProduct.num ? this.createCartIntentCommitGuard('increase_quantity') : undefined;
4574
+ if (!mutation.commit) beforeCommit?.();
4440
4575
  if (isCurrentOrder && !isCurrentOrder()) return tempOrder.products;
4441
4576
  tempOrder.products[productIndex] = normalizedProduct;
4577
+ if (mutation.commit) {
4578
+ tempOrder = await mutation.commit({
4579
+ beforeCommit,
4580
+ isCurrentOrder
4581
+ });
4582
+ }
4442
4583
  if (isCurrentOrder) {
4443
4584
  await this.finalizeProductOrderMutation(tempOrder, {
4444
4585
  skipEditDiscountConfigRefresh: true,
@@ -4522,9 +4663,13 @@ class OrderModule extends _BaseModule.BaseModule {
4522
4663
  * await order.removeProductsFromOrder([identityA, identityB]);
4523
4664
  */
4524
4665
  async removeProductsFromOrder(identities, options) {
4666
+ return this.queueCartCommand(() => this.removeProductsFromOrderDraft(identities, options));
4667
+ }
4668
+ async removeProductsFromOrderDraft(identities, options) {
4525
4669
  const isCurrentOrder = options?.isCurrentOrder;
4526
4670
  if (isCurrentOrder && !isCurrentOrder()) return this.store.tempOrder?.products || [];
4527
- const tempOrder = this.ensureTempOrder();
4671
+ const mutation = this.beginCartMutation();
4672
+ let tempOrder = mutation.draft;
4528
4673
  if (!identities.length) {
4529
4674
  return tempOrder.products;
4530
4675
  }
@@ -4596,6 +4741,9 @@ class OrderModule extends _BaseModule.BaseModule {
4596
4741
  // 整单折扣随购物车清空,避免重新加购时沿用上一批商品的优惠。
4597
4742
  tempOrder.shop_discount = '0.00';
4598
4743
  }
4744
+ if (mutation.commit) tempOrder = await mutation.commit({
4745
+ isCurrentOrder
4746
+ });
4599
4747
  if (isCurrentOrder) {
4600
4748
  await this.finalizeProductOrderMutation(tempOrder, {
4601
4749
  skipEditDiscountConfigRefresh: true,
@@ -4618,7 +4766,11 @@ class OrderModule extends _BaseModule.BaseModule {
4618
4766
  * 普通整单 note 保持不变;以商品行为主体的 Sales Notes 同步删除。
4619
4767
  */
4620
4768
  async clearOrderCartLines() {
4621
- const tempOrder = this.ensureTempOrder();
4769
+ return this.queueCartCommand(() => this.clearOrderCartLinesDraft());
4770
+ }
4771
+ async clearOrderCartLinesDraft() {
4772
+ const mutation = this.beginCartMutation();
4773
+ let tempOrder = mutation.draft;
4622
4774
  this.ensureSalesNotesLoadedForMutation(tempOrder);
4623
4775
  (0, _holderRelations.removeProductHolderRelations)(tempOrder, tempOrder.products);
4624
4776
  tempOrder.products = [];
@@ -4633,6 +4785,7 @@ class OrderModule extends _BaseModule.BaseModule {
4633
4785
  productsByUid: {}
4634
4786
  };
4635
4787
  }
4788
+ if (mutation.commit) tempOrder = await mutation.commit();
4636
4789
  const promotionPayload = await this.evaluatePromotion();
4637
4790
  this.applyDiscount();
4638
4791
  this.sanitizeTempOrderProducts(tempOrder);
@@ -4771,6 +4924,7 @@ class OrderModule extends _BaseModule.BaseModule {
4771
4924
  async runSubmitTempOrder(params) {
4772
4925
  const tempOrder = this.ensureTempOrder();
4773
4926
  if ((0, _localEftposState.requiresLocalPaymentRefresh)(tempOrder)) throw new Error(_localEftposState.PAYMENT_REFRESH_MESSAGE);
4927
+ (0, _productVoucherGroups.validateProductVoucherGroups)(tempOrder, this.getDiscountList(), undefined, true);
4774
4928
  this.prepareVirtualSettlementTempOrder(tempOrder);
4775
4929
  const isOnlineStorePlatform = this.isOnlineStorePlatform();
4776
4930
  const shouldConfirmPendingVoucherPayments = params?.confirmPendingVoucherPayments !== false;
@@ -457,6 +457,8 @@ export type AddProductBookingInput = Record<string, any>;
457
457
  * 避免步进器修改数量改变该组展示位置。
458
458
  */
459
459
  export interface AddProductToOrderOptions {
460
+ /** Associates a selection with an existing runtime voucher group. */
461
+ productVoucherGroupKey?: string;
460
462
  insertAfterProductUid?: string;
461
463
  /** 新增商品行插入 products 首位,优先于 insertAfterProductUid。 */
462
464
  insertAtStart?: boolean;
@@ -557,6 +559,11 @@ export interface OrderHooksConfig {
557
559
  beforeCartIntentCommit?: (context: OrderCartIntentCommitContext) => void;
558
560
  /** Captures tenant/business runtime identity for asynchronous cart intents. */
559
561
  getCartIntentScope?: () => unknown;
562
+ /** Awaited before a local cart draft is published. Reject to leave the live order unchanged. */
563
+ onBeforeCartCommit?: (context: {
564
+ currentItems: readonly OrderProduct[];
565
+ proposedItems: readonly OrderProduct[];
566
+ }) => void | Promise<void>;
560
567
  onBeforeMergeProductToOrder?: (context: OrderProductMergeDecisionContext) => OrderProductMergeDecisionResult | Promise<OrderProductMergeDecisionResult>;
561
568
  }
562
569
  /**
@@ -241,7 +241,7 @@ function consolidateDiscountFreeProductLines(tempOrder) {
241
241
  bundle_selling_price: String(bundle?.bundle_selling_price ?? '')
242
242
  }))
243
243
  });
244
- const mergeKey = [discountSplitOriginUid, product.product_id, product.product_variant_id ?? 0, fingerprint, priceSignature].join('#');
244
+ const mergeKey = [discountSplitOriginUid, productUid ? tempOrder._extend?.productsByUid?.[productUid]?.productVoucherGroupKey ?? '' : '', product.product_id, product.product_variant_id ?? 0, fingerprint, priceSignature].join('#');
245
245
  const matchedIndex = productIndexByKey.get(mergeKey);
246
246
 
247
247
  // 当前拆分来源 + 商品结构组合第一次出现时,保留该行作为回并目标。
@@ -0,0 +1,15 @@
1
+ import type { Discount } from '../../Discount/types';
2
+ import type { OrderTempOrder } from '../types';
3
+ /** Runtime-only allocation constraints. Never copied into order/product metadata. */
4
+ export interface ProductVoucherGroup {
5
+ key: string;
6
+ discountIds: Array<number | string>;
7
+ }
8
+ export declare function productVoucherGroupKey(order: OrderTempOrder, product: any): string | undefined;
9
+ export declare function isUsableProductVoucher(discount: Discount): boolean;
10
+ export declare function voucherGroupError(): Error & {
11
+ code: string;
12
+ };
13
+ export declare function allowsProductVoucher(order: OrderTempOrder | null | undefined, product: any, discount: Discount): boolean;
14
+ /** Reductions stay possible when a voucher expires; checkout always requires full coverage. */
15
+ export declare function validateProductVoucherGroups(order: OrderTempOrder, discounts: Discount[], previous?: OrderTempOrder, requireCoverage?: boolean): void;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowsProductVoucher = allowsProductVoucher;
7
+ exports.isUsableProductVoucher = isUsableProductVoucher;
8
+ exports.productVoucherGroupKey = productVoucherGroupKey;
9
+ exports.validateProductVoucherGroups = validateProductVoucherGroups;
10
+ exports.voucherGroupError = voucherGroupError;
11
+ var _availability = require("../../Discount/availability");
12
+ var _dayjs = _interopRequireDefault(require("dayjs"));
13
+ var _utils = require("../../../solution/ShopDiscount/utils");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ /** Runtime-only allocation constraints. Never copied into order/product metadata. */
16
+
17
+ function productVoucherGroupKey(order, product) {
18
+ const uid = product?.metadata?.unique_identification_number ?? product?.unique_identification_number;
19
+ return order._extend?.productsByUid?.[String(uid)]?.productVoucherGroupKey;
20
+ }
21
+ function isUsableProductVoucher(discount) {
22
+ return (discount.tag || discount.type) === 'good_pass' && !discount.isEditMode && !discount.isDisabled && !(0, _availability.getDiscountUsageBlockReason)(discount) && !(0, _utils.getDiscountTimeUnavailableReason)(discount, (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss'));
23
+ }
24
+ function voucherGroupError() {
25
+ return Object.assign(new Error('The selected items no longer match the available vouchers. Please adjust your selection.'), {
26
+ code: 'PRODUCT_VOUCHER_GROUP_INVALID'
27
+ });
28
+ }
29
+ function allowsProductVoucher(order, product, discount) {
30
+ const groups = order?._extend?.productVoucherGroups;
31
+ if (!order || !groups?.length) return true;
32
+ const key = productVoucherGroupKey(order, product);
33
+ if (!key) return !groups.some(group => group.discountIds.some(id => String(id) === String(discount.id)));
34
+ return (discount.tag || discount.type) === 'good_pass' && Boolean(groups.find(group => group.key === key)?.discountIds.some(id => String(id) === String(discount.id)));
35
+ }
36
+
37
+ /** Reductions stay possible when a voucher expires; checkout always requires full coverage. */
38
+ function validateProductVoucherGroups(order, discounts, previous, requireCoverage = false) {
39
+ const groups = order._extend?.productVoucherGroups;
40
+ if (!groups?.length) return;
41
+ const usedIds = new Set();
42
+ const byId = new Map(discounts.filter(isUsableProductVoucher).map(discount => [String(discount.id), discount]));
43
+ const quantity = item => Number(item.num ?? item.product_quantity ?? 0);
44
+ for (const group of groups) {
45
+ const items = order.products.filter(item => productVoucherGroupKey(order, item) === group.key);
46
+ const selected = items.reduce((sum, item) => sum + quantity(item), 0);
47
+ const before = previous?.products.filter(item => productVoucherGroupKey(previous, item) === group.key).reduce((sum, item) => sum + quantity(item), 0) ?? 0;
48
+ if (!requireCoverage && previous && selected <= before) continue;
49
+ const ids = new Set(group.discountIds.map(String).filter(id => byId.has(id)));
50
+ if (!Number.isInteger(selected) || selected < 0 || selected > ids.size) throw voucherGroupError();
51
+ if (!requireCoverage) continue;
52
+ for (const item of items) {
53
+ const applied = (item.discount_list || []).filter(entry => (entry.type || entry.tag) === 'good_pass');
54
+ // Rules splits a good_pass allocation into one physical line per instance.
55
+ const id = String(applied[0]?.discount?.resource_id ?? '');
56
+ const voucher = byId.get(id);
57
+ if (quantity(item) !== 1 || applied.length !== 1 || !ids.has(id) || !voucher?.isAvailable || voucher.config?.isAvailable === false || usedIds.has(id)) throw voucherGroupError();
58
+ usedIds.add(id);
59
+ }
60
+ }
61
+ if (order.products.some(item => !groups.some(group => group.key === productVoucherGroupKey(order, item)))) {
62
+ throw voucherGroupError();
63
+ }
64
+ }
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "duration" | "normal" | "session";
53
53
  }
@@ -66,7 +66,13 @@ class ProductList extends _BaseModule.BaseModule {
66
66
  * productList.updateOtherParams({ channel: 'pos' });
67
67
  */
68
68
  updateOtherParams(params) {
69
+ const previousScope = this.otherParams.catalogScopeKey;
69
70
  this.otherParams = params || {};
71
+ if (previousScope !== this.otherParams.catalogScopeKey && (previousScope || this.otherParams.catalogScopeKey)) {
72
+ this.store.list = [];
73
+ this.rawProductPriceSources.clear();
74
+ this.core.effects.emit(`${this.name}:changed`, this.store.list);
75
+ }
70
76
  }
71
77
  async storeChange(path, value) {
72
78
  // No longer needed - products are stored as plain objects instead of Product instances
@@ -101,6 +107,12 @@ class ProductList extends _BaseModule.BaseModule {
101
107
  status = 'published',
102
108
  strategy_context
103
109
  } = {}, options) {
110
+ const scope = this.otherParams.catalogScopeKey;
111
+ const assertScope = () => {
112
+ if (scope !== this.otherParams.catalogScopeKey) throw Object.assign(new Error('Product catalog context changed'), {
113
+ name: 'AbortError'
114
+ });
115
+ };
104
116
  // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
105
117
  // if (!schedule_ids?.length) {
106
118
  // const schedule_ids_data = this.store.schedule
@@ -180,6 +192,7 @@ class ProductList extends _BaseModule.BaseModule {
180
192
  const handledByOsServer = (0, _clientDataVariants.isProductQueryHandledByOsServer)(this.core, this.request);
181
193
  const originalCallback = options?.callback;
182
194
  const subscriptionCallback = typeof originalCallback === 'function' ? async result => {
195
+ if (scope !== this.otherParams.catalogScopeKey) return;
183
196
  const callbackList = result?.data?.list;
184
197
  if (!Array.isArray(callbackList)) {
185
198
  originalCallback(result);
@@ -197,6 +210,7 @@ class ProductList extends _BaseModule.BaseModule {
197
210
  queryPayload,
198
211
  handledByOsServer
199
212
  });
213
+ assertScope();
200
214
  await this.addProduct(products);
201
215
  originalCallback(handledByOsServer ? result : {
202
216
  ...result,
@@ -212,6 +226,7 @@ class ProductList extends _BaseModule.BaseModule {
212
226
  subscriberId: options?.subscriberId,
213
227
  customToast: () => {}
214
228
  });
229
+ assertScope();
215
230
  if (!handledByOsServer && Array.isArray(productsData.data.list)) {
216
231
  this.replaceRawProductQueryResult(productsData.data.list, product_ids);
217
232
  }
@@ -9,6 +9,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
9
9
  private store;
10
10
  window: WindowPlugin;
11
11
  private hooks;
12
+ private discountScope?;
13
+ setDiscountScope(scope: (product: any, discount: Discount) => boolean): void;
12
14
  constructor(name?: string, version?: string);
13
15
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
14
16
  setRulesList(rulesList: Rules[]): Promise<void>;
@@ -22,6 +22,10 @@ class RulesModule extends _BaseModule.BaseModule {
22
22
  store;
23
23
  window; // WindowPlugin 实例
24
24
  hooks;
25
+ discountScope;
26
+ setDiscountScope(scope) {
27
+ this.discountScope = scope;
28
+ }
25
29
  constructor(name, version) {
26
30
  super(name, version);
27
31
  this.hooks = {};
@@ -745,6 +749,7 @@ class RulesModule extends _BaseModule.BaseModule {
745
749
 
746
750
  // 辅助函数:检查商品是否对某个折扣卡可用
747
751
  const checkItemApplicableForDiscount = (flatItem, discount) => {
752
+ if (this.discountScope && !this.discountScope(flatItem.originProduct, discount)) return false;
748
753
  if (discount.config?.isAvailable === false) return false;
749
754
  if (isCardBlockedByPromotion(flatItem, discount)) return false;
750
755
  let product;
@@ -1156,6 +1161,7 @@ class RulesModule extends _BaseModule.BaseModule {
1156
1161
 
1157
1162
  // 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
1158
1163
  const applicableDiscounts = sortedDiscountList.filter(discount => {
1164
+ if (this.discountScope && !this.discountScope(originProduct, discount)) return false;
1159
1165
  if (this.isItemRewardProductDiscount(product)) return false;
1160
1166
  if (isCardBlockedByPromotion(flatItem, discount)) return false;
1161
1167
  // 🔥 检查策略可用性(针对全额抵扣卡和折扣卡)