@pisell/pisellos 2.2.314 → 2.2.316

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 (268) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +3 -1
  3. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  4. package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
  5. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  6. package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
  8. package/dist/model/strategy/adapter/itemRule/type.js +10 -0
  9. package/dist/model/strategy/adapter/promotion/evaluator.js +89 -104
  10. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
  11. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +28 -4
  12. package/dist/modules/BookingContext/utils/productExtend.d.ts +7 -0
  13. package/dist/modules/BookingContext/utils/productExtend.js +62 -18
  14. package/dist/modules/BookingContext/utils/resources.js +1 -1
  15. package/dist/modules/BusinessAvailability/index.d.ts +30 -0
  16. package/dist/modules/BusinessAvailability/index.js +204 -0
  17. package/dist/modules/Cart/index.js +4 -3
  18. package/dist/modules/Cart/types.d.ts +2 -0
  19. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
  20. package/dist/modules/Cart/utils/cartProduct.js +59 -32
  21. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  22. package/dist/modules/FulfillmentTiming/index.js +407 -0
  23. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  24. package/dist/modules/FulfillmentTiming/types.js +1 -0
  25. package/dist/modules/Holder/utils.d.ts +2 -0
  26. package/dist/modules/Holder/utils.js +32 -2
  27. package/dist/modules/OpenData/contactInfo.d.ts +20 -0
  28. package/dist/modules/OpenData/contactInfo.js +70 -0
  29. package/dist/modules/OpenData/index.d.ts +1 -0
  30. package/dist/modules/OpenData/index.js +1 -0
  31. package/dist/modules/OpenData/types.d.ts +23 -0
  32. package/dist/modules/Order/holderRelations.d.ts +14 -0
  33. package/dist/modules/Order/holderRelations.js +154 -0
  34. package/dist/modules/Order/index.d.ts +16 -4
  35. package/dist/modules/Order/index.js +926 -511
  36. package/dist/modules/Order/localEftposState.d.ts +13 -0
  37. package/dist/modules/Order/localEftposState.js +39 -0
  38. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  39. package/dist/modules/Order/pickupTiming.js +53 -0
  40. package/dist/modules/Order/types.d.ts +49 -3
  41. package/dist/modules/Order/types.js +2 -0
  42. package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
  43. package/dist/modules/Order/utils/discountProductLineIdentity.js +142 -7
  44. package/dist/modules/Order/utils/orderCollectionIdentity.js +24 -10
  45. package/dist/modules/Order/utils.d.ts +2 -1
  46. package/dist/modules/Order/utils.js +61 -17
  47. package/dist/modules/Payment/index.js +9 -10
  48. package/dist/modules/Product/types.d.ts +11 -0
  49. package/dist/modules/ProductList/index.js +1 -1
  50. package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
  51. package/dist/modules/ResourcePlanner/planner.js +332 -23
  52. package/dist/modules/ResourcePlanner/types.d.ts +29 -0
  53. package/dist/modules/Rules/index.js +62 -61
  54. package/dist/modules/Schedule/index.d.ts +8 -0
  55. package/dist/modules/Schedule/index.js +141 -39
  56. package/dist/modules/index.d.ts +1 -0
  57. package/dist/modules/index.js +1 -0
  58. package/dist/plugins/request.d.ts +7 -0
  59. package/dist/server/index.d.ts +1 -0
  60. package/dist/server/index.js +1557 -1322
  61. package/dist/server/modules/form/index.d.ts +19 -0
  62. package/dist/server/modules/form/index.js +205 -0
  63. package/dist/server/modules/form/types.d.ts +13 -0
  64. package/dist/server/modules/form/types.js +3 -0
  65. package/dist/server/modules/index.d.ts +3 -0
  66. package/dist/server/modules/index.js +4 -0
  67. package/dist/server/modules/order/index.d.ts +19 -0
  68. package/dist/server/modules/order/index.js +1071 -774
  69. package/dist/server/modules/order/types.d.ts +4 -0
  70. package/dist/server/modules/products/index.d.ts +28 -7
  71. package/dist/server/modules/products/index.js +1297 -770
  72. package/dist/server/modules/products/replication.d.ts +8 -0
  73. package/dist/server/modules/products/replication.js +69 -0
  74. package/dist/server/modules/products/types.d.ts +12 -1
  75. package/dist/server/modules/products/types.js +4 -0
  76. package/dist/server/test.json +1 -1
  77. package/dist/server/utils/small-ticket.d.ts +1 -85
  78. package/dist/server/utils/small-ticket.js +2 -2542
  79. package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
  80. package/dist/shared/payment/loadPaymentMethods.js +66 -0
  81. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  82. package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
  83. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  84. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
  85. package/dist/shared/receipt/small-ticket.d.ts +96 -0
  86. package/dist/shared/receipt/small-ticket.js +2763 -0
  87. package/dist/shared/receipt/templateVisibility.d.ts +26 -0
  88. package/dist/shared/receipt/templateVisibility.js +68 -0
  89. package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  90. package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
  91. package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  92. package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
  93. package/dist/solution/BaseSales/index.d.ts +43 -16
  94. package/dist/solution/BaseSales/index.js +2028 -1247
  95. package/dist/solution/BaseSales/pickupTiming.d.ts +47 -0
  96. package/dist/solution/BaseSales/pickupTiming.js +616 -0
  97. package/dist/solution/BaseSales/types.d.ts +12 -0
  98. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
  99. package/dist/solution/BaseSales/utils/parseSalesResponse.js +10 -3
  100. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -4
  101. package/dist/solution/BookingByStep/index.d.ts +4 -2
  102. package/dist/solution/BookingByStep/index.js +8 -3
  103. package/dist/solution/BookingTicket/index.d.ts +23 -3
  104. package/dist/solution/BookingTicket/index.js +867 -507
  105. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  106. package/dist/solution/BookingTicket/utils/addProductDecision.js +1 -1
  107. package/dist/solution/BookingTicket/utils/cartView.js +3 -1
  108. package/dist/solution/OrderInvoicePreview/index.d.ts +66 -0
  109. package/dist/solution/OrderInvoicePreview/index.js +340 -0
  110. package/dist/solution/RegisterAndLogin/config.js +54 -11
  111. package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
  112. package/dist/solution/RegisterAndLogin/index.js +1 -1
  113. package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
  114. package/dist/solution/RegisterAndLogin/utils.js +36 -16
  115. package/dist/solution/ScanOrder/index.js +65 -31
  116. package/dist/solution/ScanOrder/types.d.ts +3 -0
  117. package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  118. package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
  119. package/dist/solution/UnifiedBookingSales/index.d.ts +36 -4
  120. package/dist/solution/UnifiedBookingSales/index.js +1715 -906
  121. package/dist/solution/UnifiedBookingSales/types.d.ts +16 -2
  122. package/dist/solution/VenueBooking/index.d.ts +15 -2
  123. package/dist/solution/VenueBooking/index.js +1062 -785
  124. package/dist/solution/VenueBooking/types.d.ts +2 -1
  125. package/dist/solution/VenueBooking/types.js +1 -0
  126. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  127. package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
  128. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  129. package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
  130. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  131. package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
  132. package/dist/solution/index.d.ts +1 -0
  133. package/dist/solution/index.js +2 -1
  134. package/lib/index.d.ts +2 -0
  135. package/lib/index.js +21 -1
  136. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  137. package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
  138. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  139. package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
  140. package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
  141. package/lib/model/strategy/adapter/itemRule/type.js +10 -0
  142. package/lib/model/strategy/adapter/promotion/evaluator.js +9 -14
  143. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  144. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
  145. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +17 -1
  146. package/lib/modules/BookingContext/utils/productExtend.d.ts +7 -0
  147. package/lib/modules/BookingContext/utils/productExtend.js +45 -2
  148. package/lib/modules/BookingContext/utils/resources.js +1 -1
  149. package/lib/modules/BusinessAvailability/index.d.ts +30 -0
  150. package/lib/modules/BusinessAvailability/index.js +146 -0
  151. package/lib/modules/Cart/index.js +4 -2
  152. package/lib/modules/Cart/types.d.ts +2 -0
  153. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
  154. package/lib/modules/Cart/utils/cartProduct.js +39 -20
  155. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  156. package/lib/modules/FulfillmentTiming/index.js +359 -0
  157. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  158. package/lib/modules/FulfillmentTiming/types.js +5 -0
  159. package/lib/modules/Holder/utils.d.ts +2 -0
  160. package/lib/modules/Holder/utils.js +27 -1
  161. package/lib/modules/OpenData/contactInfo.d.ts +20 -0
  162. package/lib/modules/OpenData/contactInfo.js +56 -0
  163. package/lib/modules/OpenData/index.d.ts +1 -0
  164. package/lib/modules/OpenData/index.js +12 -0
  165. package/lib/modules/OpenData/types.d.ts +23 -0
  166. package/lib/modules/Order/holderRelations.d.ts +14 -0
  167. package/lib/modules/Order/holderRelations.js +98 -0
  168. package/lib/modules/Order/index.d.ts +16 -4
  169. package/lib/modules/Order/index.js +284 -50
  170. package/lib/modules/Order/localEftposState.d.ts +13 -0
  171. package/lib/modules/Order/localEftposState.js +44 -0
  172. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  173. package/lib/modules/Order/pickupTiming.js +61 -0
  174. package/lib/modules/Order/types.d.ts +49 -3
  175. package/lib/modules/Order/types.js +1 -0
  176. package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
  177. package/lib/modules/Order/utils/discountProductLineIdentity.js +51 -2
  178. package/lib/modules/Order/utils/orderCollectionIdentity.js +5 -0
  179. package/lib/modules/Order/utils.d.ts +2 -1
  180. package/lib/modules/Order/utils.js +49 -11
  181. package/lib/modules/Payment/index.js +3 -4
  182. package/lib/modules/Product/types.d.ts +11 -0
  183. package/lib/modules/ProductList/index.js +1 -1
  184. package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
  185. package/lib/modules/ResourcePlanner/planner.js +252 -8
  186. package/lib/modules/ResourcePlanner/types.d.ts +29 -0
  187. package/lib/modules/Rules/index.js +2 -1
  188. package/lib/modules/Schedule/index.d.ts +8 -0
  189. package/lib/modules/Schedule/index.js +68 -12
  190. package/lib/modules/index.d.ts +1 -0
  191. package/lib/modules/index.js +11 -0
  192. package/lib/plugins/request.d.ts +7 -0
  193. package/lib/server/index.d.ts +1 -0
  194. package/lib/server/index.js +166 -39
  195. package/lib/server/modules/form/index.d.ts +19 -0
  196. package/lib/server/modules/form/index.js +73 -0
  197. package/lib/server/modules/form/types.d.ts +13 -0
  198. package/lib/server/modules/form/types.js +9 -0
  199. package/lib/server/modules/index.d.ts +3 -0
  200. package/lib/server/modules/index.js +15 -1
  201. package/lib/server/modules/order/index.d.ts +19 -0
  202. package/lib/server/modules/order/index.js +160 -7
  203. package/lib/server/modules/order/types.d.ts +4 -0
  204. package/lib/server/modules/products/index.d.ts +28 -7
  205. package/lib/server/modules/products/index.js +226 -63
  206. package/lib/server/modules/products/replication.d.ts +8 -0
  207. package/lib/server/modules/products/replication.js +30 -0
  208. package/lib/server/modules/products/types.d.ts +12 -1
  209. package/lib/server/modules/products/types.js +3 -0
  210. package/lib/server/test.json +1 -1
  211. package/lib/server/utils/small-ticket.d.ts +1 -85
  212. package/lib/server/utils/small-ticket.js +9 -2305
  213. package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
  214. package/lib/shared/payment/loadPaymentMethods.js +40 -0
  215. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  216. package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
  217. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  218. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
  219. package/lib/shared/receipt/small-ticket.d.ts +96 -0
  220. package/lib/shared/receipt/small-ticket.js +2555 -0
  221. package/lib/shared/receipt/templateVisibility.d.ts +26 -0
  222. package/lib/shared/receipt/templateVisibility.js +67 -0
  223. package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  224. package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
  225. package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  226. package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
  227. package/lib/solution/BaseSales/index.d.ts +43 -16
  228. package/lib/solution/BaseSales/index.js +401 -33
  229. package/lib/solution/BaseSales/pickupTiming.d.ts +47 -0
  230. package/lib/solution/BaseSales/pickupTiming.js +290 -0
  231. package/lib/solution/BaseSales/types.d.ts +12 -0
  232. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
  233. package/lib/solution/BaseSales/utils/parseSalesResponse.js +7 -0
  234. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -8
  235. package/lib/solution/BookingByStep/index.d.ts +4 -2
  236. package/lib/solution/BookingByStep/index.js +7 -3
  237. package/lib/solution/BookingTicket/index.d.ts +23 -3
  238. package/lib/solution/BookingTicket/index.js +197 -9
  239. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  240. package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -1
  241. package/lib/solution/BookingTicket/utils/cartView.js +3 -1
  242. package/lib/solution/OrderInvoicePreview/index.d.ts +66 -0
  243. package/lib/solution/OrderInvoicePreview/index.js +246 -0
  244. package/lib/solution/RegisterAndLogin/config.js +57 -11
  245. package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
  246. package/lib/solution/RegisterAndLogin/index.js +9 -1
  247. package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
  248. package/lib/solution/RegisterAndLogin/utils.js +24 -17
  249. package/lib/solution/ScanOrder/index.js +59 -20
  250. package/lib/solution/ScanOrder/types.d.ts +3 -0
  251. package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  252. package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
  253. package/lib/solution/UnifiedBookingSales/index.d.ts +36 -4
  254. package/lib/solution/UnifiedBookingSales/index.js +562 -75
  255. package/lib/solution/UnifiedBookingSales/types.d.ts +16 -2
  256. package/lib/solution/VenueBooking/index.d.ts +15 -2
  257. package/lib/solution/VenueBooking/index.js +243 -96
  258. package/lib/solution/VenueBooking/types.d.ts +2 -1
  259. package/lib/solution/VenueBooking/types.js +1 -0
  260. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  261. package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
  262. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  263. package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
  264. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  265. package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
  266. package/lib/solution/index.d.ts +1 -0
  267. package/lib/solution/index.js +11 -0
  268. package/package.json +1 -1
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.FormModule = void 0;
7
+ var _BaseModule = require("../../../modules/BaseModule");
8
+ var _types = require("./types");
9
+ const FORM_LIST_URL = '/shop/form/simple/list';
10
+
11
+ /**
12
+ * 表单定义缓存。数据源负责 HTTP 与 Ably 订阅;本模块仅向 OS 消费方公开只读标题映射。
13
+ */
14
+ class FormModule extends _BaseModule.BaseModule {
15
+ defaultName = 'form';
16
+ defaultVersion = '1.0.0';
17
+ store;
18
+ dataSource;
19
+ refreshTimer;
20
+ async initialize(core, options) {
21
+ this.core = core;
22
+ const initialStore = options?.store;
23
+ this.store = {
24
+ list: Array.isArray(initialStore?.list) ? initialStore.list : [],
25
+ map: initialStore?.map instanceof Map ? initialStore.map : new Map()
26
+ };
27
+ const FormDataSource = this.core.serverOptions?.All_DATA_SOURCES?.FormDataSource;
28
+ this.dataSource = FormDataSource ? new FormDataSource() : undefined;
29
+ if (this.dataSource) {
30
+ await this.dataSource.run({
31
+ pubsub: {
32
+ callback: () => this.scheduleRefresh()
33
+ }
34
+ });
35
+ }
36
+ }
37
+ async preload() {
38
+ await this.refresh();
39
+ }
40
+ getTitleMap() {
41
+ return this.store.list.reduce((result, item) => {
42
+ if (item.id !== undefined && item.id !== null && item.title) result[String(item.id)] = item.title;
43
+ return result;
44
+ }, {});
45
+ }
46
+ scheduleRefresh() {
47
+ if (this.refreshTimer) clearTimeout(this.refreshTimer);
48
+ this.refreshTimer = setTimeout(() => void this.refresh(), 300);
49
+ }
50
+ async refresh() {
51
+ try {
52
+ const response = this.dataSource ? await this.dataSource.run({
53
+ http: {
54
+ url: FORM_LIST_URL
55
+ }
56
+ }) : await this.core.getPlugin('request')?.get(FORM_LIST_URL);
57
+ const data = response?.data;
58
+ const list = Array.isArray(data) ? data : data?.list || data?.data || [];
59
+ if (!Array.isArray(list)) return;
60
+ this.store.list = list;
61
+ this.store.map = new Map(this.store.list.map(item => [String(item.id), item]));
62
+ await this.core.effects.emit(_types.FormHooks.onChanged, this.getTitleMap());
63
+ } catch {
64
+ // 接口尚未发布或临时失败时保留现有缓存,展示层会回退订单历史标题。
65
+ }
66
+ }
67
+ async destroy() {
68
+ if (this.refreshTimer) clearTimeout(this.refreshTimer);
69
+ this.dataSource?.destroy?.();
70
+ }
71
+ }
72
+ exports.FormModule = FormModule;
73
+ var _default = exports.default = FormModule;
@@ -0,0 +1,13 @@
1
+ export interface FormDefinition {
2
+ id: string | number;
3
+ code?: string;
4
+ title?: Record<string, string> | string;
5
+ [key: string]: unknown;
6
+ }
7
+ export interface FormState {
8
+ list: FormDefinition[];
9
+ map: Map<string, FormDefinition>;
10
+ }
11
+ export declare const FormHooks: {
12
+ readonly onChanged: "form:onChanged";
13
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FormHooks = void 0;
7
+ const FormHooks = exports.FormHooks = {
8
+ onChanged: 'form:onChanged'
9
+ };
@@ -24,4 +24,7 @@ export { FloorPlanHooks } from './floor-plan/types';
24
24
  export { ResourceModule, resourceModule } from './resource';
25
25
  export type { ResourceState, ResourceData, ResourceId, ResourceBooking, ResourcePageQuery, ResourcePageResult, QueryOptions, ScheduleEventResource, } from './resource';
26
26
  export { ResourceHooks } from './resource';
27
+ export { FormModule } from './form';
28
+ export type { FormDefinition, FormState } from './form/types';
29
+ export { FormHooks } from './form/types';
27
30
  export type { RouteHandler, HttpMethod, RouteDefinition, Router, ModuleRegistryConfig, } from '../types';
@@ -15,6 +15,18 @@ Object.defineProperty(exports, "FloorPlanModule", {
15
15
  return _floorPlan.FloorPlanModule;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "FormHooks", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _types6.FormHooks;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "FormModule", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _form.FormModule;
28
+ }
29
+ });
18
30
  Object.defineProperty(exports, "MenuHooks", {
19
31
  enumerable: true,
20
32
  get: function () {
@@ -105,4 +117,6 @@ var _types4 = require("./order/types");
105
117
  var _payment = require("./payment");
106
118
  var _floorPlan = require("./floor-plan");
107
119
  var _types5 = require("./floor-plan/types");
108
- var _resource = require("./resource");
120
+ var _resource = require("./resource");
121
+ var _form = require("./form");
122
+ var _types6 = require("./form/types");
@@ -105,6 +105,8 @@ export declare class OrderModule extends BaseModule implements Module {
105
105
  getOrderByOrderId(orderId: OrderId): OrderData | undefined;
106
106
  private buildLocalPaymentOrderLogContext;
107
107
  getLocalOrderFromMemoryByLookup(lookup: OrderId): OrderData | null;
108
+ /** Read-only payment gate lookup; never hydrate the whole order list on a miss. */
109
+ getLocalOrderForPaymentReadiness(lookup: OrderId): Promise<OrderData | null>;
108
110
  getLocalOrderByLookup(lookup: OrderId, options?: {
109
111
  operationId?: string;
110
112
  }): Promise<OrderData | null>;
@@ -123,11 +125,24 @@ export declare class OrderModule extends BaseModule implements Module {
123
125
  paymentNumber: OrderId;
124
126
  operationId?: string;
125
127
  updates: Record<string, any>;
128
+ finalizeUnsuccessful?: boolean;
126
129
  }): Promise<{
127
130
  order: OrderData;
128
131
  payment: Record<string, any>;
129
132
  previousPayment: Record<string, any>;
130
133
  } | null>;
134
+ finalizeLocalEftposPayment(params: {
135
+ saleId: OrderId;
136
+ paymentNumber: OrderId;
137
+ result: 'failed' | 'not_started';
138
+ failedTransactionNumbers: string[];
139
+ }): Promise<{
140
+ order: OrderData;
141
+ payment: Record<string, any>;
142
+ previousPayment: Record<string, any>;
143
+ } | null>;
144
+ /** Only a successful full detail GET may release the persisted payment gate. */
145
+ completeLocalPaymentRefresh(fresh: OrderData): Promise<OrderData>;
131
146
  loadOrdersByServer(options?: {
132
147
  trigger?: string;
133
148
  }): Promise<OrderData[]>;
@@ -311,6 +326,10 @@ export declare class OrderModule extends BaseModule implements Module {
311
326
  private getIdentifiedPendingPayments;
312
327
  private shouldProtectLocalOrderFromRemoteSnapshot;
313
328
  private getUnmatchedIdentifiedPendingPayments;
329
+ /** 关系数组是完整快照,不能拼接或按商品子项生成 UID;扩展字段整体保留。 */
330
+ private applyHolderRelationsSnapshot;
331
+ /** 全量拉取缺少关系字段时,仍保留同一订单已有的关系快照。 */
332
+ private preserveOmittedHolderRelations;
314
333
  private mergeOrderRecords;
315
334
  private summarizeDuplicateOrders;
316
335
  private logDuplicateOrders;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.OrderModule = void 0;
7
7
  var _lodashEs = require("lodash-es");
8
+ var _localEftposState = require("../../../modules/Order/localEftposState");
8
9
  var _dayjs = _interopRequireDefault(require("dayjs"));
9
10
  var _BaseModule = require("../../../modules/BaseModule");
10
11
  var _orderCollectionIdentity = require("../../../modules/Order/utils/orderCollectionIdentity");
@@ -259,9 +260,9 @@ class OrderModule extends _BaseModule.BaseModule {
259
260
  mergeAuthoritativeOrderCollection(field, existing, incoming, uidRemaps = [], options = {}) {
260
261
  const kind = ORDER_COLLECTION_KIND_BY_FIELD[field];
261
262
  const existingItems = Array.isArray(existing) ? existing : [];
262
- if (field === 'payments' && options.preserveIdentifiedPendingPayments) {
263
+ if (field === 'payments' && (options.preserveIdentifiedPendingPayments || existingItems.some(_localEftposState.isLocalFinalizedPayment))) {
263
264
  return (0, _paymentUtils.mergeOrderPaymentListsByIdentity)(existingItems, incoming, {
264
- preserveUnmatchedExistingWhen: _paymentUtils.isIdentifiedPendingOrderPayment
265
+ preserveUnmatchedExistingWhen: payment => options.preserveIdentifiedPendingPayments === true && (0, _paymentUtils.isIdentifiedPendingOrderPayment)(payment) || (0, _localEftposState.isLocalFinalizedPayment)(payment)
265
266
  });
266
267
  }
267
268
  return incoming.map(incomingItem => {
@@ -288,6 +289,7 @@ class OrderModule extends _BaseModule.BaseModule {
288
289
  const existingRecord = existing;
289
290
  const incomingRecord = incoming;
290
291
  const uidRemaps = [];
292
+ this.applyHolderRelationsSnapshot(reconciled, existing, incoming);
291
293
  for (const field of ORDER_AUTHORITATIVE_COLLECTION_FIELDS) {
292
294
  if (!Array.isArray(incomingRecord[field])) continue;
293
295
  reconciled[field] = this.mergeAuthoritativeOrderCollection(field, existingRecord[field], incomingRecord[field], uidRemaps);
@@ -364,7 +366,7 @@ class OrderModule extends _BaseModule.BaseModule {
364
366
  continue;
365
367
  }
366
368
 
367
- // 远端商品成员确实发生增删时必须落库,避免内存已更新但 SQLite 仍被回声窗口跳过。
369
+ // 远端商品成员或 Holder 关系确实变化时必须落库,避免被回声窗口跳过。
368
370
  if (forceWriteStorageKeys.has(storageKey)) {
369
371
  toWrite.push(order);
370
372
  continue;
@@ -637,6 +639,42 @@ class OrderModule extends _BaseModule.BaseModule {
637
639
  const memoryOrder = this.store.list.find(order => this.isOrderLookupMatch(order, key));
638
640
  return memoryOrder || null;
639
641
  }
642
+
643
+ /** Read-only payment gate lookup; never hydrate the whole order list on a miss. */
644
+ async getLocalOrderForPaymentReadiness(lookup) {
645
+ if (lookup === undefined || lookup === null || lookup === '') return null;
646
+ const memoryOrder = this.getLocalOrderFromMemoryByLookup(lookup);
647
+ if (memoryOrder) return memoryOrder;
648
+ if (typeof this.dbManager?.find !== 'function') {
649
+ return this.getLocalOrderByLookup(lookup);
650
+ }
651
+ const key = this.getIdKey(lookup);
652
+ const fields = ['order_id', 'external_sale_number', 'order_number', 'shop_order_number', 'shop_full_order_number'];
653
+ const candidates = [];
654
+ for (const column of fields) {
655
+ // Match getAll's storage-key ordering even when aliases collide across rows.
656
+ // Let query errors reach the payment gate rather than treating them as a miss.
657
+ const rows = await this.dbManager.find(INDEXDB_STORE_NAME, {
658
+ filters: [{
659
+ column,
660
+ op: '=',
661
+ value: key
662
+ }],
663
+ orderBy: [{
664
+ column: '__order_storage_key',
665
+ dir: 'asc'
666
+ }],
667
+ limit: 1
668
+ });
669
+ if (rows?.[0] && this.isOrderLookupMatch(rows[0], key)) candidates.push(rows[0]);
670
+ }
671
+ candidates.sort((left, right) => {
672
+ const leftKey = String(left.__order_storage_key ?? this.getOrderStorageKey(left));
673
+ const rightKey = String(right.__order_storage_key ?? this.getOrderStorageKey(right));
674
+ return leftKey < rightKey ? -1 : leftKey > rightKey ? 1 : 0;
675
+ });
676
+ return candidates.length ? this.normalizeOrderForMemoryList(candidates[0], 'paymentReadiness.sqlite') : null;
677
+ }
640
678
  async getLocalOrderByLookup(lookup, options = {}) {
641
679
  const key = this.getIdKey(lookup);
642
680
  const logContext = {
@@ -753,6 +791,13 @@ class OrderModule extends _BaseModule.BaseModule {
753
791
  return null;
754
792
  }
755
793
  const previousPayment = (0, _lodashEs.cloneDeep)(found.payment);
794
+ if (params.finalizeUnsuccessful && (found.payment.status === 'paid' || found.payment.metadata?.transactions?.some(transaction => transaction.status === 'success') || (0, _localEftposState.isLocalFinalizedPayment)(found.payment))) {
795
+ return {
796
+ order: found.order,
797
+ payment: found.payment,
798
+ previousPayment
799
+ };
800
+ }
756
801
  const nextPayment = (0, _paymentUtils.mergeOrderPaymentRecord)(found.payment, {
757
802
  ...params.updates,
758
803
  updated_at: params.updates.updated_at || (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss')
@@ -762,6 +807,13 @@ class OrderModule extends _BaseModule.BaseModule {
762
807
  payments: (found.order.payments || []).map((payment, index) => index === found.paymentIndex ? nextPayment : payment),
763
808
  updated_at: (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss')
764
809
  };
810
+ if (params.finalizeUnsuccessful && this.hasRealOrderId(found.order) && Number(found.order.need_sync || 0) === 0 && !(nextOrder.payments || []).some(_paymentUtils.isPendingOrderPayment)) {
811
+ nextOrder.is_draft_order = 0;
812
+ nextOrder.metadata = {
813
+ ...nextOrder.metadata,
814
+ [_localEftposState.LOCAL_EFTPOS_REFRESH_REQUIRED]: true
815
+ };
816
+ }
765
817
  const paymentContext = {
766
818
  ...logContext,
767
819
  matched_by: found.matchedBy,
@@ -813,6 +865,60 @@ class OrderModule extends _BaseModule.BaseModule {
813
865
  previousPayment
814
866
  };
815
867
  }
868
+ async finalizeLocalEftposPayment(params) {
869
+ const found = await this.getLocalPayment(params);
870
+ if (!found) throw new Error('未找到本地支付记录');
871
+ const transactions = found.payment.metadata?.transactions || [];
872
+ if (transactions.some(transaction => transaction.status !== 'fail' && transaction.status !== 'success' && !params.failedTransactionNumbers.includes(String(transaction.number)))) {
873
+ throw new Error('仍有结果未知的交易,保留待确认支付');
874
+ }
875
+ if (params.result === 'not_started' && transactions.length > 0 && !(0, _localEftposState.isLocalFinalizedPayment)(found.payment) && found.payment.status !== 'paid') {
876
+ throw new Error('支付已有交易记录,不能按未发起交易结束');
877
+ }
878
+ return this.updateLocalPayment({
879
+ ...params,
880
+ finalizeUnsuccessful: true,
881
+ updates: {
882
+ status: 'voided',
883
+ metadata: {
884
+ [_localEftposState.LOCAL_EFTPOS_FINALIZED]: true,
885
+ transactions: params.failedTransactionNumbers.map(number => ({
886
+ number,
887
+ status: 'fail'
888
+ }))
889
+ }
890
+ }
891
+ });
892
+ }
893
+
894
+ /** Only a successful full detail GET may release the persisted payment gate. */
895
+ async completeLocalPaymentRefresh(fresh) {
896
+ const existing = await this.getLocalOrderByLookup(fresh.order_id);
897
+ if (!existing || !(0, _localEftposState.requiresLocalPaymentRefresh)(existing)) {
898
+ await this.upsertOrdersFromRemote([fresh]);
899
+ return (await this.getLocalOrderByLookup(fresh.order_id)) || fresh;
900
+ }
901
+ if (this.isPendingSyncOrder(existing) || this.isDraftOrder(existing) || (existing.payments || []).some(_paymentUtils.isPendingOrderPayment)) {
902
+ throw new Error('订单仍有未结束支付或待同步改动,暂不能刷新');
903
+ }
904
+ if (!Array.isArray(fresh.products) || !fresh.summary) {
905
+ throw new Error('远端订单详情不完整,请重新刷新');
906
+ }
907
+ const nextOrder = this.mergeOrderRecords(existing, this.normalizeRemoteSyncedOrder(fresh));
908
+ nextOrder.metadata = {
909
+ ...nextOrder.metadata
910
+ };
911
+ delete nextOrder.metadata[_localEftposState.LOCAL_EFTPOS_REFRESH_REQUIRED];
912
+ // Do not publish/clear the gate in memory until SQLite has accepted the full snapshot.
913
+ await this.updateOrderInSQLite(nextOrder, 'completeLocalPaymentRefresh', {
914
+ throwOnError: true
915
+ });
916
+ const index = this.findOrderIndexByIdentity(this.store.list, existing);
917
+ this.store.list = index < 0 ? [...this.store.list, nextOrder] : this.store.list.map((order, i) => i === index ? nextOrder : order);
918
+ this.syncOrdersMap();
919
+ await this.emitOrdersChanged([nextOrder], 'completeLocalPaymentRefresh');
920
+ return nextOrder;
921
+ }
816
922
  async loadOrdersByServer(options = {}) {
817
923
  let orderList = [];
818
924
  let hasFetchedRemoteSnapshot = false;
@@ -1234,6 +1340,7 @@ class OrderModule extends _BaseModule.BaseModule {
1234
1340
  if (matchIndex >= 0) {
1235
1341
  const existingOrder = updatedList[matchIndex];
1236
1342
  const reconciledDraftOrder = this.preserveExistingBusinessCodeForDraft(existingOrder, draftOrder);
1343
+ this.applyHolderRelationsSnapshot(reconciledDraftOrder, existingOrder, draftOrder);
1237
1344
  const mergedOrder = this.mergeOrderRecords(existingOrder, reconciledDraftOrder);
1238
1345
  const nextOrder = {
1239
1346
  ...mergedOrder,
@@ -1512,7 +1619,10 @@ class OrderModule extends _BaseModule.BaseModule {
1512
1619
  const hasSingleId = routeInfo.hasSingleId;
1513
1620
  const normalizedBody = this.normalizeOrderSyncPayload(msg.body || msg.data);
1514
1621
  if (routeInfo.route === 'bodyUpsert' && normalizedBody) {
1515
- upsertOrders.set(this.getIdKey(normalizedBody.order_id), normalizedBody);
1622
+ const orderKey = this.getIdKey(normalizedBody.order_id);
1623
+ const previousBody = upsertOrders.get(orderKey);
1624
+ if (previousBody) this.applyHolderRelationsSnapshot(normalizedBody, previousBody, normalizedBody);
1625
+ upsertOrders.set(orderKey, normalizedBody);
1516
1626
  return;
1517
1627
  }
1518
1628
  if (hasBatchIds) refreshIds.push(...routeInfo.batchIds);else if (routeInfo.route === 'httpRefresh.singleId' && singleId !== null) refreshIds.push(singleId);else if (routeInfo.route === 'httpRefresh.relationIds') refreshIds.push(...routeInfo.batchIds);
@@ -1705,6 +1815,9 @@ class OrderModule extends _BaseModule.BaseModule {
1705
1815
  const mergedStorageKey = this.getOrderStorageKey(mergedOrder);
1706
1816
  if (mergedStorageKey) forceWriteStorageKeys.add(mergedStorageKey);
1707
1817
  }
1818
+ if (nextStorageKey && !(0, _lodashEs.isEqual)(existingOrder.holder_relations, mergedOrder.holder_relations)) {
1819
+ forceWriteStorageKeys.add(nextStorageKey);
1820
+ }
1708
1821
  // 合并后身份字段可能新增(如挂单拿到 order_id),同步登记到索引,
1709
1822
  // 供同批后续 fresh 命中同一槽位,避免重复插入
1710
1823
  this.registerOrderIdentityKeys(identityKeyToIndex, mergedOrder, adjustedMatchIndex);
@@ -1997,7 +2110,7 @@ class OrderModule extends _BaseModule.BaseModule {
1997
2110
  return payments.filter(payment => (0, _paymentUtils.isIdentifiedPendingOrderPayment)(payment));
1998
2111
  }
1999
2112
  shouldProtectLocalOrderFromRemoteSnapshot(order) {
2000
- return this.isPendingSyncOrder(order) || this.isDraftOrder(order) || this.getIdentifiedPendingPayments(order).length > 0;
2113
+ return this.isPendingSyncOrder(order) || this.isDraftOrder(order) || this.getIdentifiedPendingPayments(order).length > 0 || (0, _localEftposState.requiresLocalPaymentRefresh)(order) || (order.payments || []).some(_localEftposState.isLocalFinalizedPayment);
2001
2114
  }
2002
2115
  getUnmatchedIdentifiedPendingPayments(existing, incoming) {
2003
2116
  const existingPayments = Array.isArray(existing) ? existing : [];
@@ -2005,6 +2118,38 @@ class OrderModule extends _BaseModule.BaseModule {
2005
2118
  const incomingIdentityKeys = new Set(incomingPayments.flatMap(payment => (0, _paymentUtils.getOrderPaymentIdentityKeys)(payment)));
2006
2119
  return existingPayments.filter(payment => (0, _paymentUtils.isIdentifiedPendingOrderPayment)(payment) && !(0, _paymentUtils.getOrderPaymentIdentityKeys)(payment).some(key => incomingIdentityKeys.has(key)));
2007
2120
  }
2121
+
2122
+ /** 关系数组是完整快照,不能拼接或按商品子项生成 UID;扩展字段整体保留。 */
2123
+ applyHolderRelationsSnapshot(target, existing, incoming) {
2124
+ if (Array.isArray(incoming.holder_relations)) {
2125
+ target.holder_relations = (0, _lodashEs.cloneDeep)(incoming.holder_relations);
2126
+ } else if (Array.isArray(existing.holder_relations)) {
2127
+ target.holder_relations = (0, _lodashEs.cloneDeep)(existing.holder_relations);
2128
+ } else {
2129
+ delete target.holder_relations;
2130
+ }
2131
+ }
2132
+
2133
+ /** 全量拉取缺少关系字段时,仍保留同一订单已有的关系快照。 */
2134
+ preserveOmittedHolderRelations(incomingOrders, existingOrders) {
2135
+ const existingByIdentity = new Map();
2136
+ for (const order of existingOrders) {
2137
+ if (!Array.isArray(order.holder_relations)) continue;
2138
+ for (const key of this.getOrderIdentityMatchKeys(order)) {
2139
+ existingByIdentity.set(key, order);
2140
+ }
2141
+ }
2142
+ return incomingOrders.map(order => {
2143
+ if (Array.isArray(order.holder_relations)) return order;
2144
+ const existingOrder = this.getOrderIdentityMatchKeys(order).map(key => existingByIdentity.get(key)).find(Boolean);
2145
+ if (!existingOrder) return order;
2146
+ const nextOrder = {
2147
+ ...order
2148
+ };
2149
+ this.applyHolderRelationsSnapshot(nextOrder, existingOrder, order);
2150
+ return nextOrder;
2151
+ });
2152
+ }
2008
2153
  mergeOrderRecords(existing, incoming) {
2009
2154
  const preferred = this.pickPreferredOrder(existing, incoming);
2010
2155
  const secondary = preferred === existing ? incoming : existing;
@@ -2019,6 +2164,12 @@ class OrderModule extends _BaseModule.BaseModule {
2019
2164
  const secondaryRecord = secondary;
2020
2165
  const existingRecord = existing;
2021
2166
  const incomingRecord = incoming;
2167
+ if ((0, _localEftposState.requiresLocalPaymentRefresh)(existing)) {
2168
+ mergedRecord.metadata = {
2169
+ ...mergedRecord.metadata,
2170
+ [_localEftposState.LOCAL_EFTPOS_REFRESH_REQUIRED]: true
2171
+ };
2172
+ }
2022
2173
  const childUidRemaps = [];
2023
2174
  for (const field of fieldsToPreserve) {
2024
2175
  if (!this.isBlankIdentityValue(preferredRecord[field])) {
@@ -2041,6 +2192,7 @@ class OrderModule extends _BaseModule.BaseModule {
2041
2192
  if (Object.prototype.hasOwnProperty.call(incomingRecord, 'order_meta_list')) {
2042
2193
  mergedRecord.order_meta_list = (0, _lodashEs.cloneDeep)(incomingRecord.order_meta_list);
2043
2194
  }
2195
+ this.applyHolderRelationsSnapshot(merged, existing, incoming);
2044
2196
 
2045
2197
  // 子项数组遵循完整快照语义:incoming 自有且为数组(包括 [])时权威替换;
2046
2198
  // 字段缺席或不是数组时视为稀疏 patch,继续保留 existing。
@@ -2482,7 +2634,7 @@ class OrderModule extends _BaseModule.BaseModule {
2482
2634
  async replaceOrdersSnapshotInSQLite(orderList, source, protectedOrdersBeforeRemoteFetch = []) {
2483
2635
  if (!this.dbManager) {
2484
2636
  return {
2485
- orders: this.compactOrderListByIdentity(orderList.map(order => this.normalizeRemoteSyncedOrder(order)), `${source}.snapshotNoDb`).list,
2637
+ orders: this.compactOrderListByIdentity(this.preserveOmittedHolderRelations(orderList, this.store.list).map(order => this.normalizeRemoteSyncedOrder(order)), `${source}.snapshotNoDb`).list,
2486
2638
  persisted: false
2487
2639
  };
2488
2640
  }
@@ -2492,6 +2644,7 @@ class OrderModule extends _BaseModule.BaseModule {
2492
2644
  try {
2493
2645
  await this.runInOrderSQLiteSaveQueue(async () => {
2494
2646
  const existingOrders = typeof this.dbManager.getAll === 'function' ? await this.dbManager.getAll(INDEXDB_STORE_NAME) : [];
2647
+ const remoteSnapshotWithHolderRelations = this.preserveOmittedHolderRelations(remoteSnapshot, [...protectedOrdersBeforeRemoteFetch, ...(existingOrders || [])]);
2495
2648
  const protectedLocalOrders = protectedOrdersBeforeRemoteFetch.map(order => this.normalizeOrderCollectionsForIngress(order, `${source}.protectedBeforeRemoteFetch`)).filter(order => this.shouldProtectLocalOrderFromRemoteSnapshot(order));
2496
2649
  for (const rawCurrentOrder of existingOrders || []) {
2497
2650
  const currentOrder = this.normalizeOrderCollectionsForIngress(rawCurrentOrder, `${source}.currentSQLite`);
@@ -2507,7 +2660,7 @@ class OrderModule extends _BaseModule.BaseModule {
2507
2660
  }
2508
2661
  if (currentNeedsProtection) protectedLocalOrders.push(currentOrder);
2509
2662
  }
2510
- const orderListSnapshot = this.mergeRemoteSnapshotWithPendingOrders(remoteSnapshot, protectedLocalOrders);
2663
+ const orderListSnapshot = this.mergeRemoteSnapshotWithPendingOrders(remoteSnapshotWithHolderRelations, protectedLocalOrders);
2511
2664
  mergedSnapshot = this.compactOrderListByIdentity(orderListSnapshot, `${source}.sqliteSnapshot`).list;
2512
2665
  this.logInfo('replaceOrdersSnapshotInSQLite-开始', {
2513
2666
  source,
@@ -1,4 +1,5 @@
1
1
  import type { ScheduleEventResource } from '../resource/types';
2
+ import type { OrderHolderRelation } from '../../../modules/Order/types';
2
3
  /**
3
4
  * Order 模块主键类型(对齐标准 Sales 协议的 order_id)
4
5
  */
@@ -448,6 +449,8 @@ export interface OrderData {
448
449
  contacts_info?: unknown[];
449
450
  /** 订单级主体参数 */
450
451
  holder?: Record<string, unknown> | null;
452
+ /** 非预约商品 Holder 关系完整快照;缺席表示本次回包未提供 */
453
+ holder_relations?: OrderHolderRelation[];
451
454
  /** 订单前端扩展快照 */
452
455
  order_meta_list?: {
453
456
  point_cards_snapshot?: Array<{
@@ -463,6 +466,7 @@ export interface OrderData {
463
466
  id: number | string;
464
467
  tag: 'virtual_currency';
465
468
  product_id?: number | string;
469
+ code?: string;
466
470
  product_name: string;
467
471
  par_value: string;
468
472
  used_par_value: string;
@@ -3,6 +3,7 @@ import { BaseModule } from '../../../modules/BaseModule';
3
3
  import { ProductData } from '../../../modules/Product/types';
4
4
  import type { RouteDefinition } from '../../types';
5
5
  import { ProductIdScope, type ProductSnapshot, ProductFormatter, ProductFormatterContext } from './types';
6
+ import type { CommittedProducts, ReplicatedProducts } from './types';
6
7
  /**
7
8
  * Products 模块 - 用于获取和管理完整的商品详细数据
8
9
  * 相比 ProductList 模块,Products 会获取所有详细信息并缓存
@@ -40,6 +41,26 @@ export declare class ProductsModule extends BaseModule implements Module {
40
41
  private productIndexDBSaveQueue;
41
42
  /** 最近一次智能定价评估提取的 schedule 变价时间点(HH:mm),供 Server 订阅定时刷新使用 */
42
43
  private lastScheduleTimePoints;
44
+ private committedProductState?;
45
+ private productReplicationSourceGeneration;
46
+ private productPersistenceFailed;
47
+ private runtimeSyncMode;
48
+ private runtimeSyncGeneration;
49
+ private requestReplicaRefresh?;
50
+ private replicaApplyQueue;
51
+ private productSyncQueue;
52
+ private replicaPriceDirtyIds;
53
+ /** Installed after initial preload; initial cache/network loading stays unchanged. */
54
+ setRuntimeSyncMode(mode: 'normal' | 'memoryReplica', requestRefresh?: (trigger: string) => Promise<void>): Promise<void>;
55
+ isMemoryReplica(): boolean;
56
+ /** Read persisted data once on the main screen to establish a committed baseline. */
57
+ enableProductReplicationSource(): Promise<void>;
58
+ /** Release the extra catalog without changing the normal product store or persistence. */
59
+ disableProductReplicationSource(): void;
60
+ getCommittedProductSnapshot(): CommittedProducts | null;
61
+ private recordProductCommit;
62
+ applyReplicatedProducts(change: ReplicatedProducts): Promise<void>;
63
+ private refreshFromReplica;
43
64
  constructor(name?: string, version?: string);
44
65
  initialize(core: PisellCore, options: any): Promise<void>;
45
66
  /**
@@ -230,7 +251,10 @@ export declare class ProductsModule extends BaseModule implements Module {
230
251
  * 根据 ID 列表删除商品(用于 pubsub 同步删除场景)
231
252
  * 同时更新 store.list、store.map、IndexDB 和价格缓存
232
253
  */
233
- removeProductsByIds(ids: number[]): Promise<void>;
254
+ removeProductsByIds(ids: number[], options?: {
255
+ skipIndexDB?: boolean;
256
+ skipEmit?: boolean;
257
+ }): Promise<void>;
234
258
  /**
235
259
  * 重新从服务器加载全量商品列表并更新本地 store
236
260
  * 用于 pubsub 同步 create / update / batch_update 场景
@@ -261,13 +285,8 @@ export declare class ProductsModule extends BaseModule implements Module {
261
285
  * await this.replaceProductsSnapshotInIndexDB(list, 'loadProductsByServer')
262
286
  */
263
287
  private replaceProductsSnapshotInIndexDB;
264
- /**
265
- * 增量 upsert 商品到 IndexDB,不清空表;用于 pubsub 批次合并后的变更商品。
266
- *
267
- * @example
268
- * await this.patchProductsInIndexDB(changedProducts, 'pubsub.processProductSyncMessages', mergeActions)
269
- */
270
288
  private patchProductsInIndexDB;
289
+ private persistProductDelta;
271
290
  /**
272
291
  * 同步更新商品 Map 缓存
273
292
  * 将 list 中的商品同步到 map,以 id 为 key
@@ -309,6 +328,7 @@ export declare class ProductsModule extends BaseModule implements Module {
309
328
  * Server 层监听该事件后对变更商品增量执行 prepareProductsWithPrice 并更新缓存
310
329
  */
311
330
  private processProductSyncMessages;
331
+ private processProductSyncBatch;
312
332
  /**
313
333
  * 通过 SSE 按 ids 增量拉取商品数据
314
334
  * 请求 GET /shop/core/stream?type=product&ids={ids}
@@ -342,6 +362,7 @@ export declare class ProductsModule extends BaseModule implements Module {
342
362
  * 销毁同步资源(取消 pubsub 订阅、清除定时器)
343
363
  */
344
364
  destroyProductSync(): void;
365
+ destroy(): void;
345
366
  /**
346
367
  * 获取模块的路由定义
347
368
  * Products 模块暂不提供路由,由 Server 层统一处理