@pisell/pisellos 2.3.73 → 2.3.75

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 (296) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +111 -71
  3. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  4. package/dist/model/strategy/adapter/walletPass/example.js +3 -26
  5. package/dist/model/strategy/strategy-example.js +5 -19
  6. package/dist/modules/Cart/index.js +0 -3
  7. package/dist/modules/Cart/utils/cartProduct.js +0 -1
  8. package/dist/modules/Date/index.js +1 -5
  9. package/dist/modules/Discount/index.js +2 -4
  10. package/dist/modules/OpenData/index.js +0 -2
  11. package/dist/modules/Order/index.d.ts +1 -1
  12. package/dist/modules/Order/index.js +36 -64
  13. package/dist/modules/Payment/index.js +97 -162
  14. package/dist/modules/Quotation/index.d.ts +6 -0
  15. package/dist/modules/Quotation/index.js +75 -19
  16. package/dist/modules/Rules/index.js +1 -4
  17. package/dist/modules/Schedule/index.js +0 -1
  18. package/dist/modules/Schedule/utils.js +0 -1
  19. package/dist/modules/Step/index.js +0 -1
  20. package/dist/plugins/request.d.ts +1 -0
  21. package/dist/plugins/request.js +1 -4
  22. package/dist/plugins/window.js +2 -6
  23. package/dist/server/index.d.ts +8 -2
  24. package/dist/server/index.js +303 -269
  25. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  26. package/dist/server/modules/floor-plan/index.js +240 -98
  27. package/dist/server/modules/menu/index.js +75 -59
  28. package/dist/server/modules/order/index.d.ts +17 -7
  29. package/dist/server/modules/order/index.js +421 -211
  30. package/dist/server/modules/products/index.d.ts +8 -2
  31. package/dist/server/modules/products/index.js +191 -117
  32. package/dist/server/modules/quotation/index.js +29 -38
  33. package/dist/server/modules/resource/index.js +24 -17
  34. package/dist/server/modules/schedule/index.js +27 -35
  35. package/dist/server/utils/product.js +0 -1
  36. package/dist/solution/BaseSales/index.js +38 -41
  37. package/dist/solution/BookingByStep/index.d.ts +1 -1
  38. package/dist/solution/BookingByStep/index.js +7 -59
  39. package/dist/solution/BookingByStep/utils/capacity.js +1 -11
  40. package/dist/solution/BookingByStep/utils/resources.js +1 -3
  41. package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
  42. package/dist/solution/BookingTicket/index.js +0 -2
  43. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
  44. package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
  45. package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
  46. package/dist/solution/BuyTickets/index.js +9 -12
  47. package/dist/solution/Checkout/index.js +177 -252
  48. package/dist/solution/Checkout/utils/index.js +4 -16
  49. package/dist/solution/RegisterAndLogin/index.js +30 -76
  50. package/dist/solution/ScanOrder/index.js +50 -60
  51. package/dist/solution/ShopDiscount/index.js +2 -7
  52. package/dist/solution/VenueBooking/index.js +45 -55
  53. package/dist/utils/task.js +15 -18
  54. package/dist/utils/watch.js +0 -1
  55. package/lib/apis/picoding.js +2 -0
  56. package/lib/core/index.d.ts +7 -0
  57. package/lib/core/index.js +149 -131
  58. package/lib/effects/index.js +46 -57
  59. package/lib/index.js +82 -49
  60. package/lib/model/index.js +14 -21
  61. package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
  62. package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
  63. package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
  64. package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
  65. package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
  66. package/lib/model/strategy/adapter/index.js +100 -64
  67. package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
  68. package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
  69. package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
  70. package/lib/model/strategy/adapter/itemRule/index.js +83 -57
  71. package/lib/model/strategy/adapter/itemRule/type.js +97 -36
  72. package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
  73. package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
  74. package/lib/model/strategy/adapter/promotion/examples.js +222 -234
  75. package/lib/model/strategy/adapter/promotion/index.js +1 -0
  76. package/lib/model/strategy/adapter/promotion/type.js +243 -36
  77. package/lib/model/strategy/adapter/type.js +4 -16
  78. package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
  79. package/lib/model/strategy/adapter/walletPass/example.js +217 -190
  80. package/lib/model/strategy/adapter/walletPass/index.js +75 -51
  81. package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
  82. package/lib/model/strategy/adapter/walletPass/type.js +4 -16
  83. package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
  84. package/lib/model/strategy/engine.js +270 -168
  85. package/lib/model/strategy/index.js +49 -34
  86. package/lib/model/strategy/strategy-example.js +243 -239
  87. package/lib/model/strategy/type.js +100 -40
  88. package/lib/modules/Account/index.js +39 -53
  89. package/lib/modules/Account/types.js +20 -33
  90. package/lib/modules/AccountList/index.js +116 -154
  91. package/lib/modules/AccountList/types.js +30 -31
  92. package/lib/modules/AccountList/utils.js +18 -30
  93. package/lib/modules/BaseModule.js +23 -42
  94. package/lib/modules/BookingContext/index.js +158 -136
  95. package/lib/modules/BookingContext/types.js +46 -32
  96. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
  97. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
  98. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
  99. package/lib/modules/BookingContext/utils/flexible.js +38 -55
  100. package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
  101. package/lib/modules/BookingContext/utils/index.js +124 -41
  102. package/lib/modules/BookingContext/utils/noResource.js +58 -70
  103. package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
  104. package/lib/modules/BookingContext/utils/productExtend.js +202 -155
  105. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  106. package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
  107. package/lib/modules/BookingContext/utils/resources.js +209 -167
  108. package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
  109. package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
  110. package/lib/modules/Cart/index.js +170 -124
  111. package/lib/modules/Cart/types.js +46 -51
  112. package/lib/modules/Cart/utils/cartAccount.js +40 -39
  113. package/lib/modules/Cart/utils/cartDate.js +56 -61
  114. package/lib/modules/Cart/utils/cartDiscount.js +28 -33
  115. package/lib/modules/Cart/utils/cartNote.js +27 -32
  116. package/lib/modules/Cart/utils/cartProduct.js +321 -251
  117. package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
  118. package/lib/modules/Cart/utils/cartResource.js +70 -78
  119. package/lib/modules/Cart/utils/changePrice.js +22 -50
  120. package/lib/modules/Cart/utils/index.js +106 -48
  121. package/lib/modules/Customer/constants.js +13 -34
  122. package/lib/modules/Customer/index.js +235 -172
  123. package/lib/modules/Customer/types.js +38 -35
  124. package/lib/modules/Date/index.js +116 -115
  125. package/lib/modules/Date/types.js +16 -28
  126. package/lib/modules/Date/utils.js +174 -123
  127. package/lib/modules/Discount/index.js +122 -127
  128. package/lib/modules/Discount/types.js +9 -31
  129. package/lib/modules/Guests/index.js +30 -56
  130. package/lib/modules/Guests/types.js +23 -33
  131. package/lib/modules/Holder/index.js +209 -189
  132. package/lib/modules/Holder/types.js +4 -16
  133. package/lib/modules/Holder/utils.js +20 -49
  134. package/lib/modules/OpenData/index.js +70 -76
  135. package/lib/modules/OpenData/types.js +4 -16
  136. package/lib/modules/OpenData/utils.js +44 -78
  137. package/lib/modules/Order/index.d.ts +1 -1
  138. package/lib/modules/Order/index.js +1713 -2118
  139. package/lib/modules/Order/payment-utils.js +77 -120
  140. package/lib/modules/Order/types.js +88 -35
  141. package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
  142. package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
  143. package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
  144. package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
  145. package/lib/modules/Order/utils.js +814 -647
  146. package/lib/modules/Payment/cash.js +20 -33
  147. package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
  148. package/lib/modules/Payment/eftpos.js +16 -30
  149. package/lib/modules/Payment/index.js +532 -399
  150. package/lib/modules/Payment/mx51.js +1 -0
  151. package/lib/modules/Payment/types.js +230 -108
  152. package/lib/modules/Payment/utils.js +52 -51
  153. package/lib/modules/Payment/walletpass.js +485 -660
  154. package/lib/modules/Product/index.js +51 -46
  155. package/lib/modules/Product/types.js +4 -16
  156. package/lib/modules/Product/utils.js +32 -33
  157. package/lib/modules/ProductList/index.js +113 -123
  158. package/lib/modules/ProductList/types.js +9 -31
  159. package/lib/modules/Quotation/index.d.ts +6 -0
  160. package/lib/modules/Quotation/index.js +110 -103
  161. package/lib/modules/Quotation/types.js +4 -16
  162. package/lib/modules/Resource/index.js +27 -59
  163. package/lib/modules/Resource/types.js +22 -32
  164. package/lib/modules/Resource/utils.js +30 -38
  165. package/lib/modules/ResourcePlanner/index.js +25 -23
  166. package/lib/modules/ResourcePlanner/localClock.js +54 -119
  167. package/lib/modules/ResourcePlanner/planner.js +589 -770
  168. package/lib/modules/ResourcePlanner/types.js +10 -29
  169. package/lib/modules/Rules/index.js +1218 -959
  170. package/lib/modules/Rules/types.js +17 -40
  171. package/lib/modules/SalesSummary/index.js +85 -90
  172. package/lib/modules/SalesSummary/types.js +4 -16
  173. package/lib/modules/SalesSummary/utils.js +355 -430
  174. package/lib/modules/ScanOrderLogger/index.js +59 -79
  175. package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
  176. package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
  177. package/lib/modules/ScanOrderLogger/types.js +4 -16
  178. package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
  179. package/lib/modules/Schedule/index.js +100 -114
  180. package/lib/modules/Schedule/type.js +4 -16
  181. package/lib/modules/Schedule/types.js +4 -16
  182. package/lib/modules/Schedule/utils.js +433 -291
  183. package/lib/modules/Step/index.js +40 -52
  184. package/lib/modules/Step/tyeps.js +4 -16
  185. package/lib/modules/Summary/index.js +66 -71
  186. package/lib/modules/Summary/types.js +4 -16
  187. package/lib/modules/Summary/utils.js +773 -418
  188. package/lib/modules/SurchargeList/index.js +46 -60
  189. package/lib/modules/SurchargeList/types.js +4 -16
  190. package/lib/modules/index.js +245 -63
  191. package/lib/plugins/app.js +4 -16
  192. package/lib/plugins/index.js +36 -25
  193. package/lib/plugins/request.d.ts +1 -0
  194. package/lib/plugins/request.js +137 -126
  195. package/lib/plugins/shopStore.js +4 -16
  196. package/lib/plugins/user.js +4 -16
  197. package/lib/plugins/window.js +171 -179
  198. package/lib/server/index.d.ts +8 -2
  199. package/lib/server/index.js +3083 -2663
  200. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  201. package/lib/server/modules/floor-plan/index.js +159 -127
  202. package/lib/server/modules/floor-plan/types.js +15 -30
  203. package/lib/server/modules/index.js +106 -68
  204. package/lib/server/modules/menu/index.js +170 -124
  205. package/lib/server/modules/menu/types.js +18 -31
  206. package/lib/server/modules/order/index.d.ts +17 -7
  207. package/lib/server/modules/order/index.js +916 -977
  208. package/lib/server/modules/order/types.js +122 -33
  209. package/lib/server/modules/order/utils/filterBookings.js +219 -194
  210. package/lib/server/modules/order/utils/filterOrders.js +118 -92
  211. package/lib/server/modules/payment/index.js +59 -83
  212. package/lib/server/modules/payment/types.js +4 -16
  213. package/lib/server/modules/products/index.d.ts +8 -2
  214. package/lib/server/modules/products/index.js +656 -471
  215. package/lib/server/modules/products/types.js +44 -34
  216. package/lib/server/modules/quotation/index.js +137 -172
  217. package/lib/server/modules/quotation/types.js +21 -31
  218. package/lib/server/modules/resource/index.js +225 -186
  219. package/lib/server/modules/resource/types.js +42 -33
  220. package/lib/server/modules/schedule/index.js +135 -123
  221. package/lib/server/modules/schedule/types.js +14 -21
  222. package/lib/server/modules/schedule/utils.js +334 -163
  223. package/lib/server/types.js +4 -16
  224. package/lib/server/utils/index.js +25 -23
  225. package/lib/server/utils/product.js +196 -139
  226. package/lib/server/utils/schedule.js +34 -41
  227. package/lib/server/utils/small-ticket.js +479 -456
  228. package/lib/server/utils/time.js +40 -49
  229. package/lib/solution/BaseSales/index.js +1186 -1410
  230. package/lib/solution/BaseSales/types.js +42 -38
  231. package/lib/solution/BaseSales/utils/cartPromotion.js +642 -498
  232. package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
  233. package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
  234. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
  235. package/lib/solution/BaseSales/utils.js +158 -143
  236. package/lib/solution/BookingByStep/index.d.ts +1 -1
  237. package/lib/solution/BookingByStep/index.js +1527 -1340
  238. package/lib/solution/BookingByStep/types.js +40 -99
  239. package/lib/solution/BookingByStep/utils/capacity.js +192 -160
  240. package/lib/solution/BookingByStep/utils/products.js +42 -52
  241. package/lib/solution/BookingByStep/utils/resources.js +527 -330
  242. package/lib/solution/BookingByStep/utils/stock.js +65 -44
  243. package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
  244. package/lib/solution/BookingTicket/index.js +607 -522
  245. package/lib/solution/BookingTicket/types.js +99 -77
  246. package/lib/solution/BookingTicket/utils/addProductDecision.js +226 -189
  247. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
  248. package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
  249. package/lib/solution/BookingTicket/utils/cartView.js +114 -99
  250. package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
  251. package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
  252. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
  253. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
  254. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
  255. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
  256. package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
  257. package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
  258. package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
  259. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
  260. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
  261. package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
  262. package/lib/solution/BuyTickets/index.js +67 -70
  263. package/lib/solution/BuyTickets/types.js +22 -38
  264. package/lib/solution/Checkout/index.js +1451 -1158
  265. package/lib/solution/Checkout/types.js +91 -61
  266. package/lib/solution/Checkout/utils/index.js +228 -156
  267. package/lib/solution/PlaceOrder/index.js +55 -0
  268. package/lib/solution/RegisterAndLogin/config.js +493 -460
  269. package/lib/solution/RegisterAndLogin/index.js +633 -630
  270. package/lib/solution/RegisterAndLogin/types.js +189 -76
  271. package/lib/solution/RegisterAndLogin/utils.js +183 -125
  272. package/lib/solution/Sales/index.js +328 -324
  273. package/lib/solution/Sales/types.js +27 -33
  274. package/lib/solution/ScanOrder/index.js +832 -864
  275. package/lib/solution/ScanOrder/types.js +33 -34
  276. package/lib/solution/ScanOrder/utils.js +409 -374
  277. package/lib/solution/ShopDiscount/index.js +226 -232
  278. package/lib/solution/ShopDiscount/types.js +15 -37
  279. package/lib/solution/ShopDiscount/utils.js +300 -172
  280. package/lib/solution/UnifiedBookingSales/index.js +1035 -1201
  281. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
  282. package/lib/solution/UnifiedBookingSales/types.js +10 -32
  283. package/lib/solution/VenueBooking/index.js +811 -879
  284. package/lib/solution/VenueBooking/types.js +19 -39
  285. package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
  286. package/lib/solution/VenueBooking/utils/resource.js +31 -54
  287. package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
  288. package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
  289. package/lib/solution/VenueBooking/utils.js +130 -67
  290. package/lib/solution/index.js +124 -41
  291. package/lib/store/createStore.js +32 -29
  292. package/lib/types/index.js +4 -16
  293. package/lib/utils/payment-number.js +26 -46
  294. package/lib/utils/task.js +36 -36
  295. package/lib/utils/watch.js +81 -47
  296. package/package.json +2 -1
@@ -12,8 +12,15 @@ declare class PisellOSCore implements PisellCore {
12
12
  context: BusinessContext;
13
13
  server: any;
14
14
  serverOptions?: ServerOptions;
15
+ private serverModulePromise?;
15
16
  constructor(options?: PisellOSOptions);
16
17
  private initialize;
18
+ /**
19
+ * 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
20
+ * 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
21
+ */
22
+ preloadServerModule(): Promise<void>;
23
+ private loadServerModule;
17
24
  /**
18
25
  * 初始化 Server(公开方法,需要外部显式调用并等待)
19
26
  * Server 配置从构造函数传入的 options.server 中获取
@@ -24,8 +24,6 @@ import { EffectsManager } from "../effects";
24
24
  * pisell OS 核心实现
25
25
  */
26
26
  var PisellOSCore = /*#__PURE__*/function () {
27
- // 保存 Server 配置
28
-
29
27
  function PisellOSCore(options) {
30
28
  _classCallCheck(this, PisellOSCore);
31
29
  _defineProperty(this, "plugins", new Map());
@@ -37,6 +35,8 @@ var PisellOSCore = /*#__PURE__*/function () {
37
35
  _defineProperty(this, "server", void 0);
38
36
  // Server 实例
39
37
  _defineProperty(this, "serverOptions", void 0);
38
+ // 保存 Server 配置
39
+ _defineProperty(this, "serverModulePromise", void 0);
40
40
  this.debug = (options === null || options === void 0 ? void 0 : options.debug) || false;
41
41
  this.context = (options === null || options === void 0 ? void 0 : options.context) || {};
42
42
 
@@ -63,6 +63,49 @@ var PisellOSCore = /*#__PURE__*/function () {
63
63
  this.log('[PisellOS] 核心初始化完成');
64
64
  }
65
65
 
66
+ /**
67
+ * 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
68
+ * 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
69
+ */
70
+ }, {
71
+ key: "preloadServerModule",
72
+ value: (function () {
73
+ var _preloadServerModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
74
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
75
+ while (1) switch (_context.prev = _context.next) {
76
+ case 0:
77
+ if (!(this.server || !this.serverOptions)) {
78
+ _context.next = 2;
79
+ break;
80
+ }
81
+ return _context.abrupt("return");
82
+ case 2:
83
+ _context.next = 4;
84
+ return this.loadServerModule();
85
+ case 4:
86
+ case "end":
87
+ return _context.stop();
88
+ }
89
+ }, _callee, this);
90
+ }));
91
+ function preloadServerModule() {
92
+ return _preloadServerModule.apply(this, arguments);
93
+ }
94
+ return preloadServerModule;
95
+ }())
96
+ }, {
97
+ key: "loadServerModule",
98
+ value: function loadServerModule() {
99
+ var _this2 = this;
100
+ if (!this.serverModulePromise) {
101
+ this.serverModulePromise = import("../server").catch(function (error) {
102
+ _this2.serverModulePromise = undefined;
103
+ throw error;
104
+ });
105
+ }
106
+ return this.serverModulePromise;
107
+ }
108
+
66
109
  /**
67
110
  * 初始化 Server(公开方法,需要外部显式调用并等待)
68
111
  * Server 配置从构造函数传入的 options.server 中获取
@@ -70,57 +113,56 @@ var PisellOSCore = /*#__PURE__*/function () {
70
113
  }, {
71
114
  key: "initializeServer",
72
115
  value: (function () {
73
- var _initializeServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
116
+ var _initializeServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
74
117
  var ServerModule, Server;
75
- return _regeneratorRuntime().wrap(function _callee$(_context) {
76
- while (1) switch (_context.prev = _context.next) {
118
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
119
+ while (1) switch (_context2.prev = _context2.next) {
77
120
  case 0:
78
121
  if (!this.server) {
79
- _context.next = 3;
122
+ _context2.next = 3;
80
123
  break;
81
124
  }
82
125
  this.log('Server 已经初始化,跳过重复初始化', 'warn');
83
- return _context.abrupt("return");
126
+ return _context2.abrupt("return");
84
127
  case 3:
85
128
  if (this.serverOptions) {
86
- _context.next = 6;
129
+ _context2.next = 6;
87
130
  break;
88
131
  }
89
132
  this.log('未提供 Server 配置,无法初始化', 'warn');
90
- return _context.abrupt("return");
133
+ return _context2.abrupt("return");
91
134
  case 6:
92
- _context.prev = 6;
93
- _context.next = 9;
94
- return import("../server");
135
+ _context2.prev = 6;
136
+ _context2.next = 9;
137
+ return this.loadServerModule();
95
138
  case 9:
96
- ServerModule = _context.sent;
139
+ ServerModule = _context2.sent;
97
140
  Server = ServerModule.default; // 创建 Server 实例
98
141
  this.server = new Server(this);
99
142
  this.log('Server 实例已创建');
100
143
 
101
144
  // 初始化模块并预加载数据
102
145
  if (!this.serverOptions.modules) {
103
- _context.next = 16;
146
+ _context2.next = 16;
104
147
  break;
105
148
  }
106
- _context.next = 16;
149
+ _context2.next = 16;
107
150
  return this.server.initialize(this.serverOptions.modules, this.serverOptions.autoInitData !== false, options);
108
151
  case 16:
109
- console.log('[PisellOS] ✅ Server 初始化完成,所有数据已预加载');
110
152
  this.log('[PisellOS] Server 初始化完成');
111
- _context.next = 25;
153
+ _context2.next = 24;
112
154
  break;
113
- case 20:
114
- _context.prev = 20;
115
- _context.t0 = _context["catch"](6);
116
- console.error('[PisellOS] ❌ Server 初始化失败:', _context.t0);
117
- this.log("Server \u521D\u59CB\u5316\u5931\u8D25: ".concat(_context.t0), 'error');
118
- throw _context.t0;
119
- case 25:
155
+ case 19:
156
+ _context2.prev = 19;
157
+ _context2.t0 = _context2["catch"](6);
158
+ console.error('[PisellOS] ❌ Server 初始化失败:', _context2.t0);
159
+ this.log("Server \u521D\u59CB\u5316\u5931\u8D25: ".concat(_context2.t0), 'error');
160
+ throw _context2.t0;
161
+ case 24:
120
162
  case "end":
121
- return _context.stop();
163
+ return _context2.stop();
122
164
  }
123
- }, _callee, this, [[6, 20]]);
165
+ }, _callee2, this, [[6, 19]]);
124
166
  }));
125
167
  function initializeServer(_x) {
126
168
  return _initializeServer.apply(this, arguments);
@@ -138,11 +180,10 @@ var PisellOSCore = /*#__PURE__*/function () {
138
180
  var prefix = '[PisellOS]';
139
181
  switch (level) {
140
182
  case 'info':
141
- console.log("".concat(prefix, " ").concat(message));
142
183
  break;
143
184
  case 'warn':
144
185
  // 使用 console.log 避免显示堆栈跟踪,提升性能
145
- console.log("%c".concat(prefix, "%c ").concat(message), 'color: #f59e0b; font-weight: bold;', 'color: #f59e0b;');
186
+
146
187
  break;
147
188
  case 'error':
148
189
  console.error("".concat(prefix, " ").concat(message));
@@ -153,7 +194,7 @@ var PisellOSCore = /*#__PURE__*/function () {
153
194
  }, {
154
195
  key: "registerPlugin",
155
196
  value: function registerPlugin(plugin, options) {
156
- var _this2 = this;
197
+ var _this3 = this;
157
198
  if (this.plugins.has(plugin.name)) {
158
199
  this.log("\u63D2\u4EF6 ".concat(plugin.name, " \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6"), 'warn');
159
200
  }
@@ -181,7 +222,7 @@ var PisellOSCore = /*#__PURE__*/function () {
181
222
  var result = plugin.initialize();
182
223
  if (result instanceof Promise) {
183
224
  result.catch(function (err) {
184
- _this2.log("\u63D2\u4EF6 ".concat(plugin.name, " \u521D\u59CB\u5316\u5931\u8D25: ").concat(err.message), 'error');
225
+ _this3.log("\u63D2\u4EF6 ".concat(plugin.name, " \u521D\u59CB\u5316\u5931\u8D25: ").concat(err.message), 'error');
185
226
  throw err;
186
227
  });
187
228
  }
@@ -207,7 +248,7 @@ var PisellOSCore = /*#__PURE__*/function () {
207
248
  }, {
208
249
  key: "registerModule",
209
250
  value: function registerModule(module, options) {
210
- var _this3 = this;
251
+ var _this4 = this;
211
252
  if (this.modules.has(module.name)) {
212
253
  this.log("\u6A21\u5757 ".concat(module.name, " \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6"), 'warn');
213
254
  }
@@ -249,8 +290,7 @@ var PisellOSCore = /*#__PURE__*/function () {
249
290
  }
250
291
  // 预先给模块初始化值系统
251
292
  var _createStore = createStore((options === null || options === void 0 ? void 0 : options.initialState) || {}, module.name, function (path, value) {
252
- console.log('core 检测到模块值更新', module.name, path, value);
253
- _this3.effects.emit("".concat(module.name, ":changed"), {
293
+ _this4.effects.emit("".concat(module.name, ":changed"), {
254
294
  path: path,
255
295
  value: value
256
296
  });
@@ -265,7 +305,7 @@ var PisellOSCore = /*#__PURE__*/function () {
265
305
  }, options));
266
306
  if (result instanceof Promise) {
267
307
  result.catch(function (err) {
268
- _this3.log("\u6A21\u5757 ".concat(module.name, " \u521D\u59CB\u5316\u5931\u8D25: ").concat(err.message), 'error');
308
+ _this4.log("\u6A21\u5757 ".concat(module.name, " \u521D\u59CB\u5316\u5931\u8D25: ").concat(err.message), 'error');
269
309
  throw err;
270
310
  });
271
311
  }
@@ -310,100 +350,100 @@ var PisellOSCore = /*#__PURE__*/function () {
310
350
  }, {
311
351
  key: "destroy",
312
352
  value: function () {
313
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
353
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
314
354
  var _iterator4, _step4, _step4$value, name, module, _iterator5, _step5, _step5$value, _name, plugin;
315
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
316
- while (1) switch (_context2.prev = _context2.next) {
355
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
356
+ while (1) switch (_context3.prev = _context3.next) {
317
357
  case 0:
318
358
  // 先销毁模块
319
359
  _iterator4 = _createForOfIteratorHelper(this.modules.entries());
320
- _context2.prev = 1;
360
+ _context3.prev = 1;
321
361
  _iterator4.s();
322
362
  case 3:
323
363
  if ((_step4 = _iterator4.n()).done) {
324
- _context2.next = 17;
364
+ _context3.next = 17;
325
365
  break;
326
366
  }
327
367
  _step4$value = _slicedToArray(_step4.value, 2), name = _step4$value[0], module = _step4$value[1];
328
368
  if (!module.destroy) {
329
- _context2.next = 15;
369
+ _context3.next = 15;
330
370
  break;
331
371
  }
332
- _context2.prev = 6;
333
- _context2.next = 9;
372
+ _context3.prev = 6;
373
+ _context3.next = 9;
334
374
  return Promise.resolve(module.destroy());
335
375
  case 9:
336
376
  this.log("\u6A21\u5757 ".concat(name, " \u5DF2\u9500\u6BC1"));
337
- _context2.next = 15;
377
+ _context3.next = 15;
338
378
  break;
339
379
  case 12:
340
- _context2.prev = 12;
341
- _context2.t0 = _context2["catch"](6);
342
- this.log("\u9500\u6BC1\u6A21\u5757 ".concat(name, " \u65F6\u51FA\u9519: ").concat(_context2.t0), 'error');
380
+ _context3.prev = 12;
381
+ _context3.t0 = _context3["catch"](6);
382
+ this.log("\u9500\u6BC1\u6A21\u5757 ".concat(name, " \u65F6\u51FA\u9519: ").concat(_context3.t0), 'error');
343
383
  case 15:
344
- _context2.next = 3;
384
+ _context3.next = 3;
345
385
  break;
346
386
  case 17:
347
- _context2.next = 22;
387
+ _context3.next = 22;
348
388
  break;
349
389
  case 19:
350
- _context2.prev = 19;
351
- _context2.t1 = _context2["catch"](1);
352
- _iterator4.e(_context2.t1);
390
+ _context3.prev = 19;
391
+ _context3.t1 = _context3["catch"](1);
392
+ _iterator4.e(_context3.t1);
353
393
  case 22:
354
- _context2.prev = 22;
394
+ _context3.prev = 22;
355
395
  _iterator4.f();
356
- return _context2.finish(22);
396
+ return _context3.finish(22);
357
397
  case 25:
358
398
  this.modules.clear();
359
399
 
360
400
  // 再销毁插件
361
401
  _iterator5 = _createForOfIteratorHelper(this.plugins.entries());
362
- _context2.prev = 27;
402
+ _context3.prev = 27;
363
403
  _iterator5.s();
364
404
  case 29:
365
405
  if ((_step5 = _iterator5.n()).done) {
366
- _context2.next = 43;
406
+ _context3.next = 43;
367
407
  break;
368
408
  }
369
409
  _step5$value = _slicedToArray(_step5.value, 2), _name = _step5$value[0], plugin = _step5$value[1];
370
410
  if (!plugin.destroy) {
371
- _context2.next = 41;
411
+ _context3.next = 41;
372
412
  break;
373
413
  }
374
- _context2.prev = 32;
375
- _context2.next = 35;
414
+ _context3.prev = 32;
415
+ _context3.next = 35;
376
416
  return Promise.resolve(plugin.destroy());
377
417
  case 35:
378
418
  this.log("\u63D2\u4EF6 ".concat(_name, " \u5DF2\u9500\u6BC1"));
379
- _context2.next = 41;
419
+ _context3.next = 41;
380
420
  break;
381
421
  case 38:
382
- _context2.prev = 38;
383
- _context2.t2 = _context2["catch"](32);
384
- this.log("\u9500\u6BC1\u63D2\u4EF6 ".concat(_name, " \u65F6\u51FA\u9519: ").concat(_context2.t2), 'error');
422
+ _context3.prev = 38;
423
+ _context3.t2 = _context3["catch"](32);
424
+ this.log("\u9500\u6BC1\u63D2\u4EF6 ".concat(_name, " \u65F6\u51FA\u9519: ").concat(_context3.t2), 'error');
385
425
  case 41:
386
- _context2.next = 29;
426
+ _context3.next = 29;
387
427
  break;
388
428
  case 43:
389
- _context2.next = 48;
429
+ _context3.next = 48;
390
430
  break;
391
431
  case 45:
392
- _context2.prev = 45;
393
- _context2.t3 = _context2["catch"](27);
394
- _iterator5.e(_context2.t3);
432
+ _context3.prev = 45;
433
+ _context3.t3 = _context3["catch"](27);
434
+ _iterator5.e(_context3.t3);
395
435
  case 48:
396
- _context2.prev = 48;
436
+ _context3.prev = 48;
397
437
  _iterator5.f();
398
- return _context2.finish(48);
438
+ return _context3.finish(48);
399
439
  case 51:
400
440
  this.plugins.clear();
401
441
  this.log('PisellOS 核心已销毁');
402
442
  case 53:
403
443
  case "end":
404
- return _context2.stop();
444
+ return _context3.stop();
405
445
  }
406
- }, _callee2, this, [[1, 19, 22, 25], [6, 12], [27, 45, 48, 51], [32, 38]]);
446
+ }, _callee3, this, [[1, 19, 22, 25], [6, 12], [27, 45, 48, 51], [32, 38]]);
407
447
  }));
408
448
  function destroy() {
409
449
  return _destroy.apply(this, arguments);
@@ -0,0 +1,9 @@
1
+ // 导出评估器
2
+ export { PromotionEvaluator } from "./evaluator";
3
+
4
+ // 导出适配器
5
+ export { PromotionAdapter } from "./adapter";
6
+ export { default } from "./adapter";
7
+
8
+ // 导出策略配置示例常量
9
+ export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -164,8 +164,6 @@ var strategyConfigs = [
164
164
  // ============================================
165
165
 
166
166
  function runExample() {
167
- console.log('========== WalletPass 评估器示例 ==========\n');
168
-
169
167
  // 创建评估器实例
170
168
  var evaluator = new WalletPassEvaluator();
171
169
 
@@ -178,38 +176,17 @@ function runExample() {
178
176
  });
179
177
 
180
178
  // 输出结果
181
- console.log('订单信息:');
182
- console.log("- \u603B\u91D1\u989D: ".concat(180, " \u5143"));
183
- console.log("- \u5546\u54C1: ".concat(products.map(function (p) {
184
- return "".concat(p.name, "(").concat(p.quantity, "\u4EF6)");
185
- }).join(', '), "\n"));
186
- console.log('评估结果:\n');
179
+
187
180
  results.forEach(function (result, index) {
188
- console.log("Voucher ".concat(index + 1, ": ").concat(result.voucher.id));
189
- console.log(" \u9762\u989D: ".concat(result.voucher.amount, " \u5143"));
190
- console.log(" \u53EF\u7528: ".concat(result.isApplicable ? '✅ 是' : '❌ 否'));
191
- if (result.isApplicable) {
192
- console.log(" \u6700\u5927\u62B5\u6263: ".concat(result.maxDeduction, " \u5143"));
193
- console.log(" \u6BCF\u5355\u53EF\u7528: ".concat(result.canUseCount, " \u5F20"));
194
- console.log(" \u62B5\u6263\u7A0E\u8D39: ".concat(result.deductTaxAndFee ? '是' : '否'));
195
- console.log(" \u9002\u7528\u5546\u54C1: ".concat(result.applicableProductIds.join(', ')));
196
- } else {
197
- console.log(" \u539F\u56E0: ".concat(result.reason));
198
- console.log(" \u539F\u56E0\u7801: ".concat(result.reasonCode));
199
- }
200
- console.log('');
181
+ if (result.isApplicable) {} else {}
201
182
  });
202
183
 
203
184
  // 筛选可用的 vouchers
204
185
  var availableVouchers = results.filter(function (r) {
205
186
  return r.isApplicable;
206
187
  });
207
- console.log("\n\u5171 ".concat(availableVouchers.length, " \u5F20\u53EF\u7528"));
208
188
  if (availableVouchers.length > 0) {
209
- console.log('可用 voucher ID:');
210
- availableVouchers.forEach(function (v) {
211
- console.log(" - ".concat(v.voucher.id, ": \u6700\u591A\u62B5\u6263 ").concat(v.maxDeduction, " \u5143"));
212
- });
189
+ availableVouchers.forEach(function (v) {});
213
190
  }
214
191
  }
215
192
 
@@ -246,8 +246,6 @@ var codeContext = {
246
246
  // ============================================
247
247
 
248
248
  function runExamples() {
249
- console.log('====== 策略模型使用示例 ======\n');
250
-
251
249
  // 创建引擎实例(开启调试和追踪)
252
250
  var engine = createStrategyEngine({
253
251
  debug: true,
@@ -255,32 +253,23 @@ function runExamples() {
255
253
  });
256
254
 
257
255
  // 示例1: 代金券
258
- console.log('示例1: 10元代金券');
256
+
259
257
  var result1 = engine.evaluate(voucherConfig, voucherContext);
260
- console.log('结果:', JSON.stringify(result1, null, 2));
261
- console.log('\n');
262
258
 
263
259
  // 示例2: 阶梯满减
264
- console.log('示例2: 阶梯满减(订单金额250)');
260
+
265
261
  var result2 = engine.evaluate(tieredDiscountConfig, tieredContext);
266
- console.log('结果:', JSON.stringify(result2, null, 2));
267
- console.log('\n');
268
262
 
269
263
  // 示例3: Code 模式
270
- console.log('示例3: Code 模式条件');
264
+
271
265
  var result3 = engine.evaluate(codeConditionConfig, codeContext);
272
- console.log('结果:', JSON.stringify(result3, null, 2));
273
- console.log('\n');
274
266
 
275
267
  // 快速评估(不需要创建引擎实例)
276
- console.log('示例4: 快速评估');
268
+
277
269
  var result4 = evaluate(voucherConfig, voucherContext);
278
- console.log('适用:', result4.applicable);
279
- console.log('匹配动作数:', result4.matchedActions.length);
280
- console.log('\n');
281
270
 
282
271
  // 注册自定义运算符
283
- console.log('示例5: 自定义运算符');
272
+
284
273
  engine.registerOperator('divisible_by', function (fieldValue, compareValue) {
285
274
  return Number(fieldValue) % Number(compareValue) === 0;
286
275
  });
@@ -317,11 +306,8 @@ function runExamples() {
317
306
  }
318
307
  };
319
308
  var result5 = engine.evaluate(customOperatorConfig, customContext);
320
- console.log('结果:', result5.applicable ? '适用' : '不适用');
321
- console.log('匹配动作:', result5.matchedActions);
322
309
 
323
310
  // 调试信息
324
- console.log('\n引擎调试信息:', engine.getDebugInfo());
325
311
  }
326
312
 
327
313
  // 运行示例(如果直接执行此文件)
@@ -95,9 +95,6 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
95
95
  }
96
96
  throw new Error('购物车模块需要 window 插件支持');
97
97
  case 11:
98
- // this.store.temp = {};
99
- console.log('[CartModule] 初始化完成');
100
- case 12:
101
98
  case "end":
102
99
  return _context.stop();
103
100
  }
@@ -63,7 +63,6 @@ export var handleVariantProduct = function handleVariantProduct(product) {
63
63
  */
64
64
  export var formatProductToCartItem = function formatProductToCartItem(params) {
65
65
  var _product$custom_depos;
66
- console.log('formatProductToCartItem>>>>>>', params);
67
66
  var cartItem = params.cartItem,
68
67
  product = params.product,
69
68
  bundle = params.bundle,
@@ -294,8 +294,6 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
294
294
  // 将 start_time 向上取整到下一个10分钟整数
295
295
  var roundedStartTime = _this3.roundUpToNext10Minutes(resourceStartTime);
296
296
  var roundedStartTimeDayjs = dayjs(roundedStartTime);
297
- console.log("[DateModule] \u4FEE\u6B63\u65F6\u95F4\u6BB5\u5F00\u59CB\u65F6\u95F4: ".concat(timeSlot.start_at, " -> ").concat(roundedStartTime, " (\u8D44\u6E90ID: ").concat(resource.id, ", \u539F\u59CBstart_time: ").concat(resource.start_time, ")"));
298
-
299
297
  // 将 start_at 修正为向上取整后的时间
300
298
  var correctedTimeSlot = _objectSpread(_objectSpread({}, timeSlot), {}, {
301
299
  start_at: roundedStartTime
@@ -303,7 +301,6 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
303
301
 
304
302
  // 检查修正后的 end_at 是否也早于修正后的 start_time
305
303
  if (endAt.isBefore(roundedStartTimeDayjs)) {
306
- console.log("[DateModule] \u65F6\u95F4\u6BB5\u65E0\u6548\uFF0C\u5C06\u88AB\u5220\u9664: ".concat(timeSlot.start_at, " - ").concat(timeSlot.end_at, " (\u8D44\u6E90ID: ").concat(resource.id, ", \u4FEE\u6B63\u540Estart_time: ").concat(roundedStartTime, ")"));
307
304
  return null; // 标记为删除
308
305
  }
309
306
  return correctedTimeSlot;
@@ -366,9 +363,8 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
366
363
  case 18:
367
364
  _context4.prev = 18;
368
365
  _context4.t0 = _context4["catch"](7);
369
- console.log('getAvailableTimeList_error', _context4.t0);
370
366
  return _context4.abrupt("return", disableAllDates(dates));
371
- case 22:
367
+ case 21:
372
368
  case "end":
373
369
  return _context4.stop();
374
370
  }
@@ -468,9 +468,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
468
468
  _context7.next = 4;
469
469
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
470
470
  case 4:
471
- console.log('[Discount] 已销毁');
472
471
  _get(_getPrototypeOf(DiscountModule.prototype), "destroy", this).call(this);
473
- case 6:
472
+ case 5:
474
473
  case "end":
475
474
  return _context7.stop();
476
475
  }
@@ -490,8 +489,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
490
489
  case 0:
491
490
  this.store.discountList = [];
492
491
  this.store.originalDiscountList = [];
493
- console.log('[Discount] clear');
494
- case 3:
492
+ case 2:
495
493
  case "end":
496
494
  return _context8.stop();
497
495
  }
@@ -74,8 +74,6 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
74
74
  }
75
75
  throw new Error('OpenDataModule 需要 window 插件支持');
76
76
  case 14:
77
- console.log('[OpenDataModule] 初始化完成');
78
- case 15:
79
77
  case "end":
80
78
  return _context.stop();
81
79
  }
@@ -512,7 +512,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
512
512
  generateIdempotencyToken(): string;
513
513
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
514
514
  createOrder(params: CommitOrderParams['query']): {
515
- type: "virtual" | "appointment_booking";
515
+ type: "appointment_booking" | "virtual";
516
516
  platform: string;
517
517
  sales_channel: string;
518
518
  order_sales_channel: string;