@pisell/pisellos 0.10.90 → 0.10.93

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 (229) hide show
  1. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  2. package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
  3. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  4. package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
  5. package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
  6. package/dist/model/strategy/adapter/itemRule/type.js +10 -0
  7. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
  8. package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
  9. package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  10. package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
  11. package/dist/modules/BookingContext/utils/index.d.ts +1 -0
  12. package/dist/modules/BookingContext/utils/index.js +1 -0
  13. package/dist/modules/BookingContext/utils/productExtend.d.ts +21 -0
  14. package/dist/modules/BookingContext/utils/productExtend.js +132 -33
  15. package/dist/modules/BookingContext/utils/resources.js +1 -1
  16. package/dist/modules/Cart/index.js +4 -3
  17. package/dist/modules/Cart/types.d.ts +2 -0
  18. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
  19. package/dist/modules/Cart/utils/cartProduct.js +59 -32
  20. package/dist/modules/Date/index.d.ts +1 -1
  21. package/dist/modules/Date/index.js +60 -14
  22. package/dist/modules/Date/types.d.ts +5 -0
  23. package/dist/modules/OpenData/salesSettings.js +1 -1
  24. package/dist/modules/OpenData/types.d.ts +9 -0
  25. package/dist/modules/OpenData/utils.d.ts +1 -1
  26. package/dist/modules/OpenData/utils.js +3 -2
  27. package/dist/modules/Order/index.d.ts +22 -7
  28. package/dist/modules/Order/index.js +1565 -1161
  29. package/dist/modules/Order/localEftposState.d.ts +13 -0
  30. package/dist/modules/Order/localEftposState.js +39 -0
  31. package/dist/modules/Order/types.d.ts +33 -11
  32. package/dist/modules/Order/types.js +2 -2
  33. package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
  34. package/dist/modules/Order/unpaidAmountGap.js +72 -0
  35. package/dist/modules/Order/utils.d.ts +4 -1
  36. package/dist/modules/Order/utils.js +75 -52
  37. package/dist/modules/Payment/walletpass.js +32 -6
  38. package/dist/modules/Product/index.d.ts +1 -1
  39. package/dist/modules/Product/types.d.ts +16 -0
  40. package/dist/modules/ProductList/index.js +1 -1
  41. package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
  42. package/dist/modules/ResourcePlanner/planner.js +383 -24
  43. package/dist/modules/ResourcePlanner/types.d.ts +42 -0
  44. package/dist/modules/Rules/index.js +86 -54
  45. package/dist/modules/Schedule/index.d.ts +7 -1
  46. package/dist/modules/Schedule/index.js +155 -39
  47. package/dist/modules/Schedule/types.d.ts +2 -0
  48. package/dist/modules/bookingReadValidation.d.ts +6 -0
  49. package/dist/modules/bookingReadValidation.js +72 -0
  50. package/dist/plugins/request.d.ts +2 -0
  51. package/dist/server/index.d.ts +9 -0
  52. package/dist/server/index.js +1928 -1462
  53. package/dist/server/modules/form/index.d.ts +19 -0
  54. package/dist/server/modules/form/index.js +205 -0
  55. package/dist/server/modules/form/types.d.ts +13 -0
  56. package/dist/server/modules/form/types.js +3 -0
  57. package/dist/server/modules/index.d.ts +3 -0
  58. package/dist/server/modules/index.js +4 -0
  59. package/dist/server/modules/order/index.d.ts +21 -0
  60. package/dist/server/modules/order/index.js +1399 -831
  61. package/dist/server/modules/order/types.d.ts +3 -0
  62. package/dist/server/modules/order/utils/filterOrders.js +20 -0
  63. package/dist/server/modules/products/index.d.ts +28 -7
  64. package/dist/server/modules/products/index.js +1295 -769
  65. package/dist/server/modules/products/replication.d.ts +8 -0
  66. package/dist/server/modules/products/replication.js +69 -0
  67. package/dist/server/modules/products/types.d.ts +12 -1
  68. package/dist/server/modules/products/types.js +4 -0
  69. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  70. package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
  71. package/dist/shared/receipt/small-ticket.d.ts +1 -0
  72. package/dist/shared/receipt/small-ticket.js +58 -26
  73. package/dist/shared/receipt/templateVisibility.d.ts +3 -0
  74. package/dist/shared/receipt/templateVisibility.js +6 -2
  75. package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  76. package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
  77. package/dist/solution/BaseSales/index.d.ts +22 -6
  78. package/dist/solution/BaseSales/index.js +1881 -1347
  79. package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
  80. package/dist/solution/BaseSales/pickupTiming.js +35 -8
  81. package/dist/solution/BaseSales/types.d.ts +4 -0
  82. package/dist/solution/BaseSales/types.js +1 -0
  83. package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  84. package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
  85. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  86. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
  87. package/dist/solution/BookingByStep/index.d.ts +20 -4
  88. package/dist/solution/BookingByStep/index.js +681 -361
  89. package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
  90. package/dist/solution/BookingByStep/utils/resources.js +117 -76
  91. package/dist/solution/BookingTicket/index.d.ts +10 -0
  92. package/dist/solution/BookingTicket/index.js +686 -598
  93. package/dist/solution/BookingTicket/types.d.ts +1 -1
  94. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  95. package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
  96. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +8 -8
  97. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  98. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
  99. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
  100. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
  101. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
  102. package/dist/solution/OrderInvoicePreview/index.js +4 -3
  103. package/dist/solution/Sales/index.js +1 -1
  104. package/dist/solution/ScanOrder/index.d.ts +2 -0
  105. package/dist/solution/ScanOrder/index.js +230 -97
  106. package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
  107. package/dist/solution/ScanOrder/menuAvailability.js +363 -0
  108. package/dist/solution/ScanOrder/types.d.ts +3 -0
  109. package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
  110. package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
  111. package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
  112. package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
  113. package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
  114. package/dist/utils/pos-receipt-auto-print.js +14 -0
  115. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  116. package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
  117. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  118. package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
  119. package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
  120. package/lib/model/strategy/adapter/itemRule/type.js +10 -0
  121. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
  122. package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
  123. package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  124. package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
  125. package/lib/modules/BookingContext/utils/index.d.ts +1 -0
  126. package/lib/modules/BookingContext/utils/index.js +11 -0
  127. package/lib/modules/BookingContext/utils/productExtend.d.ts +21 -0
  128. package/lib/modules/BookingContext/utils/productExtend.js +104 -5
  129. package/lib/modules/BookingContext/utils/resources.js +1 -1
  130. package/lib/modules/Cart/index.js +4 -2
  131. package/lib/modules/Cart/types.d.ts +2 -0
  132. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
  133. package/lib/modules/Cart/utils/cartProduct.js +39 -20
  134. package/lib/modules/Date/index.d.ts +1 -1
  135. package/lib/modules/Date/index.js +28 -5
  136. package/lib/modules/Date/types.d.ts +5 -0
  137. package/lib/modules/OpenData/salesSettings.js +1 -1
  138. package/lib/modules/OpenData/types.d.ts +9 -0
  139. package/lib/modules/OpenData/utils.d.ts +1 -1
  140. package/lib/modules/OpenData/utils.js +3 -2
  141. package/lib/modules/Order/index.d.ts +22 -7
  142. package/lib/modules/Order/index.js +457 -174
  143. package/lib/modules/Order/localEftposState.d.ts +13 -0
  144. package/lib/modules/Order/localEftposState.js +44 -0
  145. package/lib/modules/Order/types.d.ts +33 -11
  146. package/lib/modules/Order/types.js +2 -2
  147. package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
  148. package/lib/modules/Order/unpaidAmountGap.js +60 -0
  149. package/lib/modules/Order/utils.d.ts +4 -1
  150. package/lib/modules/Order/utils.js +29 -3
  151. package/lib/modules/Payment/walletpass.js +23 -1
  152. package/lib/modules/Product/index.d.ts +1 -1
  153. package/lib/modules/Product/types.d.ts +16 -0
  154. package/lib/modules/ProductList/index.js +1 -1
  155. package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
  156. package/lib/modules/ResourcePlanner/planner.js +299 -9
  157. package/lib/modules/ResourcePlanner/types.d.ts +42 -0
  158. package/lib/modules/Rules/index.js +32 -3
  159. package/lib/modules/Schedule/index.d.ts +7 -1
  160. package/lib/modules/Schedule/index.js +68 -4
  161. package/lib/modules/Schedule/types.d.ts +2 -0
  162. package/lib/modules/bookingReadValidation.d.ts +6 -0
  163. package/lib/modules/bookingReadValidation.js +56 -0
  164. package/lib/plugins/request.d.ts +2 -0
  165. package/lib/server/index.d.ts +9 -0
  166. package/lib/server/index.js +279 -30
  167. package/lib/server/modules/form/index.d.ts +19 -0
  168. package/lib/server/modules/form/index.js +73 -0
  169. package/lib/server/modules/form/types.d.ts +13 -0
  170. package/lib/server/modules/form/types.js +9 -0
  171. package/lib/server/modules/index.d.ts +3 -0
  172. package/lib/server/modules/index.js +15 -1
  173. package/lib/server/modules/order/index.d.ts +21 -0
  174. package/lib/server/modules/order/index.js +344 -35
  175. package/lib/server/modules/order/types.d.ts +3 -0
  176. package/lib/server/modules/order/utils/filterOrders.js +18 -0
  177. package/lib/server/modules/products/index.d.ts +28 -7
  178. package/lib/server/modules/products/index.js +224 -62
  179. package/lib/server/modules/products/replication.d.ts +8 -0
  180. package/lib/server/modules/products/replication.js +30 -0
  181. package/lib/server/modules/products/types.d.ts +12 -1
  182. package/lib/server/modules/products/types.js +3 -0
  183. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
  184. package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
  185. package/lib/shared/receipt/small-ticket.d.ts +1 -0
  186. package/lib/shared/receipt/small-ticket.js +53 -25
  187. package/lib/shared/receipt/templateVisibility.d.ts +3 -0
  188. package/lib/shared/receipt/templateVisibility.js +6 -2
  189. package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  190. package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
  191. package/lib/solution/BaseSales/index.d.ts +22 -6
  192. package/lib/solution/BaseSales/index.js +347 -59
  193. package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
  194. package/lib/solution/BaseSales/pickupTiming.js +24 -3
  195. package/lib/solution/BaseSales/types.d.ts +4 -0
  196. package/lib/solution/BaseSales/types.js +1 -0
  197. package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  198. package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
  199. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  200. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
  201. package/lib/solution/BookingByStep/index.d.ts +20 -4
  202. package/lib/solution/BookingByStep/index.js +229 -17
  203. package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
  204. package/lib/solution/BookingByStep/utils/resources.js +25 -15
  205. package/lib/solution/BookingTicket/index.d.ts +10 -0
  206. package/lib/solution/BookingTicket/index.js +57 -6
  207. package/lib/solution/BookingTicket/types.d.ts +1 -1
  208. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  209. package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
  210. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +8 -8
  211. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  212. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
  213. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
  214. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
  215. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
  216. package/lib/solution/OrderInvoicePreview/index.js +1 -0
  217. package/lib/solution/Sales/index.js +1 -1
  218. package/lib/solution/ScanOrder/index.d.ts +2 -0
  219. package/lib/solution/ScanOrder/index.js +131 -22
  220. package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
  221. package/lib/solution/ScanOrder/menuAvailability.js +203 -0
  222. package/lib/solution/ScanOrder/types.d.ts +3 -0
  223. package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
  224. package/lib/solution/UnifiedBookingSales/index.js +717 -144
  225. package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
  226. package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
  227. package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
  228. package/lib/utils/pos-receipt-auto-print.js +13 -0
  229. package/package.json +1 -1
@@ -7,6 +7,7 @@ var _exportNames = {};
7
7
  exports.default = void 0;
8
8
  var _dayjs = _interopRequireDefault(require("dayjs"));
9
9
  var _decimal = _interopRequireDefault(require("decimal.js"));
10
+ var _localEftposState = require("../modules/Order/localEftposState");
10
11
  var _lodashEs = require("lodash-es");
11
12
  var _products = require("./modules/products");
12
13
  var _menu = require("./modules/menu");
@@ -16,6 +17,7 @@ var _resource = require("./modules/resource");
16
17
  var _floorPlan = require("./modules/floor-plan");
17
18
  var _types = require("./modules/floor-plan/types");
18
19
  var _payment = require("./modules/payment");
20
+ var _form = require("./modules/form");
19
21
  var _schedule2 = require("./utils/schedule");
20
22
  var _time = require("./utils/time");
21
23
  var _types2 = require("./modules/products/types");
@@ -31,6 +33,7 @@ var _paymentUtils = require("../modules/Order/payment-utils");
31
33
  var _salesNotes = require("../modules/Order/salesNotes");
32
34
  var _orderCollectionIdentity = require("../modules/Order/utils/orderCollectionIdentity");
33
35
  var _osPrivatePayload = require("../utils/os-private-payload");
36
+ var _posReceiptAutoPrint = require("../utils/pos-receipt-auto-print");
34
37
  var _OpenData = require("../modules/OpenData");
35
38
  var _modules = require("./modules");
36
39
  Object.keys(_modules).forEach(function (key) {
@@ -121,6 +124,8 @@ class Server {
121
124
  salesSearchSubscribers = new Map();
122
125
  deviceTaskActionsRegistered = false;
123
126
  localPaymentUpdateQueues = new Map();
127
+ paymentIdentityRefreshes = new Map();
128
+ receiptFulfillmentConfigInFlight = new Map();
124
129
  floorPlanQuerySubscribers = new Map();
125
130
 
126
131
  // 模块注册表 - 定义所有可用的模块配置
@@ -182,6 +187,16 @@ class Server {
182
187
  payMethods: []
183
188
  }
184
189
  },
190
+ form: {
191
+ name: 'form',
192
+ moduleClass: _form.FormModule,
193
+ moduleName: 'server_form',
194
+ version: '1.0.0',
195
+ defaultStore: {
196
+ list: [],
197
+ map: new Map()
198
+ }
199
+ },
185
200
  resource: {
186
201
  name: 'resource',
187
202
  moduleClass: _resource.ResourceModule,
@@ -528,7 +543,7 @@ class Server {
528
543
 
529
544
  // 监听 ProductsModule 同步完成事件,重新计算并推送查询结果
530
545
  this.core.effects.on(_types2.ProductsHooks.onProductsSyncCompleted, payload => {
531
- this.recomputeAndNotifyProductQuery({
546
+ return this.recomputeAndNotifyProductQuery({
532
547
  changedIds: payload?.changedIds
533
548
  });
534
549
  });
@@ -646,7 +661,7 @@ class Server {
646
661
  const normalizedData = await this.normalizeCheckoutSubmitData(params.data, title);
647
662
  const numberedData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
648
663
  const checkoutData = this.normalizeCheckoutCollections((0, _osPrivatePayload.stripOsPrivatePayloadFields)(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
649
- const remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
664
+ const remoteCheckoutData = (0, _localEftposState.stripLocalEftposState)(this.buildRemoteCheckoutData(checkoutData, title));
650
665
  const deviceHeaders = await this.buildCheckoutDeviceHeaders(title);
651
666
  if (!this.app?.request?.post) {
652
667
  throw new Error('app.request 不可用');
@@ -784,7 +799,7 @@ class Server {
784
799
  }
785
800
  const freshPayments = freshRecord.payments;
786
801
  const mergedPayments = (0, _paymentUtils.mergeOrderPaymentListsByIdentity)(localPayments, freshPayments, {
787
- preserveUnmatchedExistingWhen: _paymentUtils.isIdentifiedPendingOrderPayment
802
+ preserveUnmatchedExistingWhen: payment => (0, _paymentUtils.isIdentifiedPendingOrderPayment)(payment) || (0, _localEftposState.isLocalFinalizedPayment)(payment)
788
803
  });
789
804
  const remoteIdentityKeys = new Set(freshPayments.flatMap(payment => (0, _paymentUtils.getOrderPaymentIdentityKeys)(payment)));
790
805
  const preservedPending = localPayments.filter(payment => (0, _paymentUtils.isIdentifiedPendingOrderPayment)(payment) && !(0, _paymentUtils.getOrderPaymentIdentityKeys)(payment).some(key => remoteIdentityKeys.has(key)));
@@ -861,8 +876,52 @@ class Server {
861
876
  order_id: fresh?.order_id
862
877
  });
863
878
  }
879
+ if (syncedOrder) {
880
+ // 不占用 sync_sales 的执行超时:慢速补取不能让已成功的 checkout 被再次提交。
881
+ void this.refreshMissingPaymentIds(syncedOrder, title).catch(error => {
882
+ this.logWarning(`${title}: 后台补齐付款 ID 失败`, {
883
+ order_id: syncedOrder?.order_id,
884
+ error: this.getUnknownErrorMessage(error)
885
+ });
886
+ });
887
+ }
864
888
  return syncedOrder;
865
889
  }
890
+ hasPaidPaymentWithoutId(order) {
891
+ return (order?.payments || []).some(payment => {
892
+ const paymentId = payment.order_payment_id ?? payment.id;
893
+ return payment.status === 'paid' && (paymentId === undefined || paymentId === null || String(paymentId).trim() === '');
894
+ });
895
+ }
896
+ async refreshMissingPaymentIds(order, title) {
897
+ if (!this.hasPaidPaymentWithoutId(order) || !(Number(order.order_id) > 0) || Number(order.need_sync || 0) === 1 || Number(order.is_draft_order || 0) === 1) {
898
+ return order;
899
+ }
900
+ const key = String(order.order_id);
901
+ let refresh = this.paymentIdentityRefreshes.get(key);
902
+ if (!refresh) {
903
+ // checkout 已成功,只补取付款身份;补取失败不能让 sync_sales 重试 checkout。
904
+ refresh = this.fetchAndPersistSalesOrderByLookup(key, {
905
+ forceRemote: true
906
+ }, `${title}.paymentIdentityRefresh`, order);
907
+ this.paymentIdentityRefreshes.set(key, refresh);
908
+ }
909
+ try {
910
+ const result = await refresh;
911
+ const refreshedOrder = result.order || this.order?.getLocalOrderFromMemoryByLookup?.(key) || order;
912
+ if (this.hasPaidPaymentWithoutId(refreshedOrder)) {
913
+ this.logWarning(`${title}: 付款 ID 尚未补齐,下次读取详情重试`, {
914
+ order_id: order.order_id,
915
+ code: result.code
916
+ });
917
+ }
918
+ return refreshedOrder;
919
+ } finally {
920
+ if (this.paymentIdentityRefreshes.get(key) === refresh) {
921
+ this.paymentIdentityRefreshes.delete(key);
922
+ }
923
+ }
924
+ }
866
925
 
867
926
  /**
868
927
  * 将普通层 QuotationModule 的报价单计算能力桥接到 Server Products 模块。
@@ -1340,6 +1399,19 @@ class Server {
1340
1399
  method: 'post',
1341
1400
  path: '/shop/local/updateLocalPayment',
1342
1401
  handler: this.handleUpdateLocalPayment.bind(this)
1402
+ }, {
1403
+ method: 'post',
1404
+ path: '/shop/local/finalizeLocalEftposPayment',
1405
+ handler: this.handleFinalizeLocalEftposPayment.bind(this)
1406
+ }, {
1407
+ method: 'post',
1408
+ path: '/shop/local/orderPaymentReadiness',
1409
+ handler: async ({
1410
+ data
1411
+ }) => ({
1412
+ code: 200,
1413
+ data: await this.order?.getLocalOrderForPaymentReadiness(data?.sale_id)
1414
+ })
1343
1415
  }, {
1344
1416
  method: 'post',
1345
1417
  path: '/shop/machinecode/batch',
@@ -1655,8 +1727,7 @@ class Server {
1655
1727
  data,
1656
1728
  config
1657
1729
  }) => {
1658
- // Venue previews seed one complete raw Kiosk pool. Quoting or applying the
1659
- // current schedule here would remove members needed by other preview dates.
1730
+ // Venue Kiosk requires the complete unquoted pool, including future items.
1660
1731
  if (data?.open_quotation === 0 && data?.application_code === 'kiosk') {
1661
1732
  return this.queryRawKioskProductPool(data);
1662
1733
  }
@@ -1665,6 +1736,7 @@ class Server {
1665
1736
  customer_id,
1666
1737
  ids,
1667
1738
  extension_type,
1739
+ application_code,
1668
1740
  strategy_context
1669
1741
  } = data;
1670
1742
  const {
@@ -1699,6 +1771,7 @@ class Server {
1699
1771
  schedule_datetime,
1700
1772
  customer_id,
1701
1773
  extension_type,
1774
+ application_code,
1702
1775
  strategy_context
1703
1776
  }
1704
1777
  });
@@ -1714,6 +1787,7 @@ class Server {
1714
1787
  schedule_datetime,
1715
1788
  customer_id,
1716
1789
  extension_type,
1790
+ application_code,
1717
1791
  strategy_context
1718
1792
  });
1719
1793
  if (subscriberId && typeof callback === 'function') {
@@ -1849,6 +1923,7 @@ class Server {
1849
1923
  schedule_date,
1850
1924
  schedule_datetime: scheduleDatetime,
1851
1925
  product_id: productId,
1926
+ application_code: data?.application_code ?? this.extractQueryParam(url || '', 'application_code') ?? undefined,
1852
1927
  ...(data && typeof data === 'object' ? {
1853
1928
  customer_id: data.customer_id,
1854
1929
  strategy_context: data.strategy_context
@@ -2493,7 +2568,10 @@ class Server {
2493
2568
  };
2494
2569
  }
2495
2570
  try {
2496
- const response = await this.app.request.post('/shop/order/v2/list', data, {
2571
+ const response = await this.app.request.post('/shop/order/v2/list', {
2572
+ ...data,
2573
+ with: [...new Set([...(Array.isArray(data.with) ? data.with : []), 'buzzer'])]
2574
+ }, {
2497
2575
  isShopApi: true
2498
2576
  });
2499
2577
  const payload = response?.data ?? response;
@@ -3044,7 +3122,7 @@ class Server {
3044
3122
  data: null
3045
3123
  };
3046
3124
  }
3047
- const queueKey = `${String(saleId)}:${String(paymentNumber)}`;
3125
+ const queueKey = String(saleId);
3048
3126
  return this.runLocalPaymentUpdateInQueue(queueKey, () => this.processLocalPaymentUpdate({
3049
3127
  operationId,
3050
3128
  saleId,
@@ -3056,6 +3134,42 @@ class Server {
3056
3134
  hasSurchargeInput
3057
3135
  }), requestContext);
3058
3136
  };
3137
+ handleFinalizeLocalEftposPayment = async ({
3138
+ data
3139
+ }) => {
3140
+ const {
3141
+ sale_id: saleId,
3142
+ payment_number: paymentNumber,
3143
+ result,
3144
+ failed_transaction_numbers: numbers = []
3145
+ } = data || {};
3146
+ if (!saleId || !paymentNumber || !Array.isArray(numbers) || numbers.some(number => typeof number !== 'string' || !number.trim()) || result !== 'failed' && result !== 'not_started' || result === 'failed' && numbers.length === 0 || result === 'not_started' && numbers.length !== 0) {
3147
+ return {
3148
+ code: 400,
3149
+ status: false,
3150
+ message: '缺少明确的支付结果或交易编号',
3151
+ data: null
3152
+ };
3153
+ }
3154
+ return this.runLocalPaymentUpdateInQueue(String(saleId), async () => {
3155
+ if (!this.order) throw new Error('Order 模块未注册');
3156
+ const finalized = await this.order.finalizeLocalEftposPayment({
3157
+ saleId,
3158
+ paymentNumber,
3159
+ result,
3160
+ failedTransactionNumbers: [...new Set(numbers)]
3161
+ });
3162
+ return {
3163
+ code: 200,
3164
+ status: true,
3165
+ local_only: true,
3166
+ data: finalized
3167
+ };
3168
+ }, {
3169
+ sale_id: saleId,
3170
+ payment_number: paymentNumber
3171
+ });
3172
+ };
3059
3173
  async runLocalPaymentUpdateInQueue(key, task, context) {
3060
3174
  const queuedAt = Date.now();
3061
3175
  const hasPreviousTask = this.localPaymentUpdateQueues.has(key);
@@ -3636,6 +3750,69 @@ class Server {
3636
3750
  });
3637
3751
  return values.join(',');
3638
3752
  }
3753
+
3754
+ /** Refresh derived references on receipt copies; manual references and stored orders stay intact. */
3755
+ async withCurrentReceiptResourceReference(order) {
3756
+ const resourceReference = this.buildCheckoutResourceIdentifierBuzzer(order.bookings);
3757
+ if (!resourceReference || resourceReference === String(order.buzzer ?? '')) return order;
3758
+ const businessCode = String(order.business_code || '').trim();
3759
+ const channel = String(order.order_sales_channel || '').trim();
3760
+ const shopId = this.getAppData('shop_id');
3761
+ const tenantId = this.getAppData('tenant_id');
3762
+ if (!businessCode || !channel || !shopId || !this.app?.request?.post) return order;
3763
+
3764
+ // A receipt can be printed outside a Sales instance. Read the order's own
3765
+ // business/channel settings rather than borrowing the currently open page.
3766
+ const key = JSON.stringify([String(shopId), String(tenantId ?? ''), businessCode, channel]);
3767
+ let inFlight = this.receiptFulfillmentConfigInFlight.get(key);
3768
+ if (!inFlight) {
3769
+ inFlight = (async () => {
3770
+ const response = await this.app.request.post(`/open/my-pisell/${shopId}/setting`, {
3771
+ scope: 'board',
3772
+ target: `${businessCode}+${channel}`,
3773
+ section_code: ['fulfillment']
3774
+ }, {
3775
+ pisell2: true,
3776
+ isPisell2: true,
3777
+ prefix: false,
3778
+ customToast: () => {},
3779
+ ...(tenantId ? {
3780
+ headers: {
3781
+ 'Tenant-Id': String(tenantId)
3782
+ }
3783
+ } : {})
3784
+ });
3785
+ if (response?.status === false || response?.code != null && Number(response.code) !== 200) {
3786
+ throw new Error('Receipt fulfillment settings are unavailable');
3787
+ }
3788
+ return response?.data?.['fulfillment.fulfillment_ref_mode'];
3789
+ })();
3790
+ this.receiptFulfillmentConfigInFlight.set(key, inFlight);
3791
+ }
3792
+ try {
3793
+ const mode = await inFlight;
3794
+ if (mode !== 'resource_identifier' || String(this.getAppData('shop_id')) !== String(shopId) || String(this.getAppData('tenant_id') ?? '') !== String(tenantId ?? '')) return order;
3795
+ return {
3796
+ ...order,
3797
+ buzzer: resourceReference
3798
+ };
3799
+ } catch (error) {
3800
+ // Offline/manual printing still works. Without a confirmed policy, do not
3801
+ // mistake a manually entered pickup reference for an obsolete table name.
3802
+ this.logWarning('withCurrentReceiptResourceReference: 配置不可用,保留原取单号', {
3803
+ order_id: order.order_id,
3804
+ target: `${businessCode}+${channel}`,
3805
+ error: error instanceof Error ? error.message : String(error)
3806
+ });
3807
+ return order;
3808
+ } finally {
3809
+ // Only coalesce concurrent outputs; settings changes and failures must be
3810
+ // re-read on the next receipt instead of becoming a permanent cache.
3811
+ if (this.receiptFulfillmentConfigInFlight.get(key) === inFlight) {
3812
+ this.receiptFulfillmentConfigInFlight.delete(key);
3813
+ }
3814
+ }
3815
+ }
3639
3816
  getCheckoutResourceIdentifier(resource, fallbackName) {
3640
3817
  if (!resource || typeof resource !== 'object') return '';
3641
3818
  const candidates = [resource.main_field, resource.name, resource.title, resource.metadata?.resource_name, resource.metadata?.name, fallbackName, resource.relation_id, resource.id];
@@ -3820,7 +3997,7 @@ class Server {
3820
3997
  device_id: debugDeviceId,
3821
3998
  payload: {
3822
3999
  backendPath: params.backendPath,
3823
- data: params.data,
4000
+ data: (0, _localEftposState.stripLocalEftposState)(params.data),
3824
4001
  invoice: this.normalizePrintInvoiceLayoutConfig(params.invoiceLayoutConfig),
3825
4002
  template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
3826
4003
  external_sale_number: params.data?.external_sale_number,
@@ -3904,7 +4081,8 @@ class Server {
3904
4081
  const printableOrder = await this.withLocalSmallTicketData(params.order, {
3905
4082
  requireFullyPaid: params.requireFullyPaid,
3906
4083
  invoiceTemplateSettings: params.invoiceTemplateSettings,
3907
- applyTemplateVisibility: true
4084
+ applyTemplateVisibility: true,
4085
+ refreshResourceReference: true
3908
4086
  });
3909
4087
  if (!(0, _smallTicket.hasSmallTicketData)(printableOrder.payment_info?.small_ticket_data)) {
3910
4088
  return {
@@ -4142,7 +4320,8 @@ class Server {
4142
4320
  locales: this.normalizeRequestedReceiptLocales(input.locales),
4143
4321
  invoiceTemplateSettings: input.template_settings === undefined ? undefined : this.normalizePrintInvoiceTemplateSettings(input.template_settings),
4144
4322
  applyTemplateVisibility: true,
4145
- includeReceiptKeys: input.template_settings !== undefined
4323
+ includeReceiptKeys: input.template_settings !== undefined,
4324
+ refreshResourceReference: true
4146
4325
  });
4147
4326
  const smallTicketData = rebuiltOrder.payment_info?.small_ticket_data;
4148
4327
  if (!(0, _smallTicket.hasSmallTicketData)(smallTicketData)) {
@@ -4303,7 +4482,11 @@ class Server {
4303
4482
  });
4304
4483
  return;
4305
4484
  }
4306
- const localOrder = await this.order.getLocalOrderByLookup(lookup);
4485
+ let localOrder = await this.order.getLocalOrderByLookup(lookup);
4486
+ const orderId = data?.order_id ?? data?.orderId;
4487
+ if (!localOrder && orderId !== undefined && orderId !== null && orderId !== '' && String(orderId) !== String(lookup)) {
4488
+ localOrder = await this.order.getLocalOrderByLookup(orderId);
4489
+ }
4307
4490
  if (!localOrder) {
4308
4491
  this.logWarning(`${title}: 本地订单不存在,跳过核销状态更新`, {
4309
4492
  lookup,
@@ -4375,6 +4558,16 @@ class Server {
4375
4558
  backendPath,
4376
4559
  title
4377
4560
  } = params;
4561
+ const lookup = params.data?.order_id || params.data?.external_sale_number;
4562
+ const localOrder = lookup && (await this.order?.getLocalOrderByLookup?.(lookup));
4563
+ if ((0, _localEftposState.requiresLocalPaymentRefresh)(params.data) || (0, _localEftposState.requiresLocalPaymentRefresh)(localOrder)) {
4564
+ return {
4565
+ code: 409,
4566
+ status: false,
4567
+ message: _localEftposState.PAYMENT_REFRESH_MESSAGE,
4568
+ data: null
4569
+ };
4570
+ }
4378
4571
  const extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
4379
4572
  includePublicInvoice: true
4380
4573
  });
@@ -4384,6 +4577,7 @@ class Server {
4384
4577
  const data = extractedTemplateSettings.data;
4385
4578
  const invoiceLayoutConfig = extractedInvoice.invoiceLayoutConfig;
4386
4579
  const invoiceTemplateSettings = this.normalizePrintInvoiceTemplateSettings(extractedTemplateSettings.invoiceTemplateSettings);
4580
+ const receiptAutoPrintPaymentStatuses = (0, _posReceiptAutoPrint.normalizePosReceiptAutoPrintPaymentStatuses)(data?.[_posReceiptAutoPrint.OS_POS_RECEIPT_AUTO_PRINT_PAYMENT_STATUSES_FIELD]);
4387
4581
  this.logInfo(`${title}: 开始处理`, {
4388
4582
  backendPath,
4389
4583
  order_id: data?.order_id,
@@ -4396,7 +4590,8 @@ class Server {
4396
4590
  data,
4397
4591
  title,
4398
4592
  invoiceLayoutConfig,
4399
- invoiceTemplateSettings
4593
+ invoiceTemplateSettings,
4594
+ receiptAutoPrintPaymentStatuses
4400
4595
  });
4401
4596
  }
4402
4597
  const normalizedData = await this.normalizeCheckoutSubmitData(data, title);
@@ -4411,13 +4606,13 @@ class Server {
4411
4606
  });
4412
4607
  if (pendingResult?.status === true) {
4413
4608
  const pendingOrder = pendingResult.data;
4414
- if (pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt()) {
4609
+ if (pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(pendingOrder, receiptAutoPrintPaymentStatuses) && this.shouldAutoPrintCheckoutReceipt()) {
4415
4610
  try {
4416
4611
  await this.dispatchLocalReceiptPrint({
4417
4612
  checkoutData,
4418
4613
  order: pendingOrder,
4419
4614
  response: pendingResult,
4420
- requireFullyPaid: true,
4615
+ requireFullyPaid: receiptAutoPrintPaymentStatuses === undefined,
4421
4616
  invoiceLayoutConfig,
4422
4617
  invoiceTemplateSettings
4423
4618
  });
@@ -4455,7 +4650,8 @@ class Server {
4455
4650
  data,
4456
4651
  title,
4457
4652
  invoiceLayoutConfig,
4458
- invoiceTemplateSettings
4653
+ invoiceTemplateSettings,
4654
+ receiptAutoPrintPaymentStatuses
4459
4655
  } = params;
4460
4656
  if (!this.app?.request?.post) {
4461
4657
  this.logError(`${title}: sync checkout app.request 不可用`);
@@ -4486,13 +4682,13 @@ class Server {
4486
4682
  }
4487
4683
  const response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
4488
4684
  const syncedOrder = syncResult.syncedOrder;
4489
- if (syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.isSalesOrderFullyPaid(syncedOrder)) {
4685
+ if (syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(syncedOrder, receiptAutoPrintPaymentStatuses) && (receiptAutoPrintPaymentStatuses === undefined || this.shouldAutoPrintCheckoutReceipt())) {
4490
4686
  try {
4491
4687
  await this.dispatchLocalReceiptPrint({
4492
4688
  checkoutData: syncResult.checkoutData,
4493
4689
  order: syncedOrder,
4494
4690
  response: syncResult.normalizedResponse,
4495
- requireFullyPaid: true,
4691
+ requireFullyPaid: receiptAutoPrintPaymentStatuses === undefined,
4496
4692
  invoiceLayoutConfig,
4497
4693
  invoiceTemplateSettings
4498
4694
  });
@@ -4712,6 +4908,13 @@ class Server {
4712
4908
  if (this.core.context?.getPlatform?.() !== 'android') return true;
4713
4909
  return this.app?.storage?.getStorage?.(AUTO_PRINT_STORAGE_KEY) !== 'false';
4714
4910
  }
4911
+
4912
+ /** Only receipt auto-printing uses this policy; vouchers retain their paid-order gate. */
4913
+ shouldAutoPrintReceiptForPaymentStatus(order, statuses) {
4914
+ if (statuses === undefined) return this.isSalesOrderFullyPaid(order);
4915
+ const paymentStatus = String(order?.payment_status || '').toLowerCase();
4916
+ return statuses.some(status => status === 'paid' ? this.isSalesOrderFullyPaid(order) : paymentStatus === status);
4917
+ }
4715
4918
  shouldBuildSmallTicketData(order, invoiceTemplateSettings) {
4716
4919
  if (!order || typeof order !== 'object') return false;
4717
4920
  const flag = order.small_ticket_data_flag ?? order.smallTicketDataFlag;
@@ -5040,7 +5243,8 @@ class Server {
5040
5243
  collapsed_duplicate_counts: collapsedDuplicateCounts
5041
5244
  });
5042
5245
  }
5043
- const enrichedOrder = await this.enrichPaymentNamesByCode(normalizedOrder);
5246
+ const receiptOrder = options?.refreshResourceReference ? await this.withCurrentReceiptResourceReference(normalizedOrder) : normalizedOrder;
5247
+ const enrichedOrder = await this.enrichPaymentNamesByCode(receiptOrder);
5044
5248
  const productMap = options?.productMap ?? (await this.buildSmallTicketProductMap(enrichedOrder));
5045
5249
  const smallTicketData = (0, _smallTicket.buildSmallTicketData)({
5046
5250
  order: enrichedOrder,
@@ -5070,7 +5274,7 @@ class Server {
5070
5274
  const code = typeof value === 'number' ? value : Number(value);
5071
5275
  return Number.isFinite(code) ? code : 500;
5072
5276
  }
5073
- async fetchAndPersistSalesOrderByLookup(lookup, data, title) {
5277
+ async fetchAndPersistSalesOrderByLookup(lookup, data, title, paymentIdentityOrder) {
5074
5278
  if (!this.order?.getLocalOrderByLookup || !this.order?.upsertOrdersFromRemote) {
5075
5279
  this.logError(`${title}: Order 模块未注册`);
5076
5280
  return {
@@ -5123,7 +5327,46 @@ class Server {
5123
5327
  order: null
5124
5328
  };
5125
5329
  }
5126
- await this.order.upsertOrdersFromRemote([fresh]);
5330
+ const localBeforeRefresh = this.order.getLocalOrderFromMemoryByLookup?.(lookup) || (this.shouldForceRemoteSalesDetail(data) ? await this.order.getLocalOrderByLookup(lookup) : null);
5331
+ let orderToPersist = fresh;
5332
+ if (paymentIdentityOrder) {
5333
+ if (String(fresh.order_id) !== String(paymentIdentityOrder.order_id) || fresh.external_sale_number && paymentIdentityOrder.external_sale_number && fresh.external_sale_number !== paymentIdentityOrder.external_sale_number || !Array.isArray(fresh.payments)) {
5334
+ throw new Error('远端订单身份不匹配或缺少付款明细,暂不补齐付款 ID');
5335
+ }
5336
+ // 请求期间可能又产生本地改动,不能用这次补取清除待同步状态。
5337
+ if (!localBeforeRefresh || Number(localBeforeRefresh.need_sync || 0) === 1 || Number(localBeforeRefresh.is_draft_order || 0) === 1) {
5338
+ return {
5339
+ code: 200,
5340
+ message: '',
5341
+ order: localBeforeRefresh || paymentIdentityOrder
5342
+ };
5343
+ }
5344
+ const remotePayments = fresh.payments;
5345
+ const paidPayments = (localBeforeRefresh.payments || []).filter(payment => payment.status === 'paid');
5346
+ const paymentIdsComplete = paidPayments.every(payment => {
5347
+ const localKeys = new Set((0, _paymentUtils.getOrderPaymentIdentityKeys)(payment));
5348
+ const matches = remotePayments.filter(remotePayment => (0, _paymentUtils.getOrderPaymentIdentityKeys)(remotePayment).some(key => localKeys.has(key)));
5349
+ const paymentId = matches[0]?.order_payment_id ?? matches[0]?.id;
5350
+ return matches.length === 1 && paymentId !== undefined && paymentId !== null && String(paymentId).trim() !== '';
5351
+ });
5352
+ if (!paymentIdsComplete) {
5353
+ throw new Error('远端付款 ID 尚未齐全或付款身份匹配不唯一,保留本地付款等待重试');
5354
+ }
5355
+ orderToPersist = {
5356
+ ...fresh,
5357
+ payments: (0, _paymentUtils.mergeOrderPaymentListsByIdentity)(localBeforeRefresh.payments, remotePayments, {
5358
+ preserveUnmatchedExisting: true
5359
+ })
5360
+ };
5361
+ }
5362
+ if ((0, _localEftposState.requiresLocalPaymentRefresh)(localBeforeRefresh)) {
5363
+ if (String(fresh.order_id) !== String(localBeforeRefresh.order_id)) {
5364
+ throw new Error('远端订单身份不匹配,请重新刷新');
5365
+ }
5366
+ await this.order.completeLocalPaymentRefresh(orderToPersist);
5367
+ } else {
5368
+ await this.order.upsertOrdersFromRemote([orderToPersist]);
5369
+ }
5127
5370
  let savedOrder = await this.order.getLocalOrderByLookup(lookup);
5128
5371
  if (!savedOrder && fresh.order_id !== undefined && fresh.order_id !== null && String(fresh.order_id) !== String(lookup)) {
5129
5372
  savedOrder = await this.order.getLocalOrderByLookup(fresh.order_id);
@@ -5217,7 +5460,8 @@ class Server {
5217
5460
  if (!this.shouldForceRemoteSalesDetail(data)) {
5218
5461
  const localOrder = await this.order.getLocalOrderByLookup(lookup);
5219
5462
  if (localOrder) {
5220
- const enrichedOrder = await this.withSalesDetailProductSnapshots(localOrder);
5463
+ const refreshedOrder = await this.refreshMissingPaymentIds(localOrder, 'handleOrderSalesDetail');
5464
+ const enrichedOrder = await this.withSalesDetailProductSnapshots(refreshedOrder);
5221
5465
  this.logInfo('handleOrderSalesDetail: 命中本地订单', {
5222
5466
  lookup
5223
5467
  });
@@ -5440,7 +5684,7 @@ class Server {
5440
5684
  }
5441
5685
  buildOrderSalesDetailBackendPath(lookup, data) {
5442
5686
  const rawWith = data && typeof data === 'object' ? data.with : undefined;
5443
- const withFields = Array.isArray(rawWith) && rawWith.length > 0 ? rawWith : ['products', 'scheduleEvents'];
5687
+ const withFields = Array.isArray(rawWith) && rawWith.length > 0 ? rawWith : ['all'];
5444
5688
  const searchParams = new URLSearchParams();
5445
5689
  withFields.forEach(field => {
5446
5690
  if (field === undefined || field === null || field === '') return;
@@ -5844,9 +6088,11 @@ class Server {
5844
6088
 
5845
6089
  // 使用 filterOrders 进行过滤、排序、分页
5846
6090
  const result = (0, _filterOrders.filterOrders)(rawList, data);
5847
- result.list.forEach(order => {
5848
- order.payments = order.payments?.filter(payment => !(0, _paymentUtils.isPendingOrderPayment)(payment));
5849
- });
6091
+ // filterOrders retains store object references; hide pending only in the list response.
6092
+ result.list = result.list.map(order => ({
6093
+ ...order,
6094
+ payments: order.payments?.filter(payment => !(0, _paymentUtils.isPendingOrderPayment)(payment))
6095
+ }));
5850
6096
  this.logInfo('computeOrderQueryResult: 过滤结果', {
5851
6097
  rawCount: rawList.length,
5852
6098
  filteredCount: result.count,
@@ -5946,8 +6192,11 @@ class Server {
5946
6192
  customer_id,
5947
6193
  extension_type,
5948
6194
  product_id,
6195
+ application_code,
5949
6196
  strategy_context
5950
6197
  } = context;
6198
+ // 仅 Kiosk 查询额外按商品销售渠道过滤。
6199
+ const isVisibleProduct = product => (product?.status || 'published') === 'published' && (application_code !== 'kiosk' || Array.isArray(product?.channel_application) && product.channel_application.includes('kiosk'));
5951
6200
  const queryIds = Array.isArray(ids) ? ids.map(id => Number(id)).filter(id => Number.isFinite(id)) : [];
5952
6201
  this.logInfo('computeProductQueryResult 开始', {
5953
6202
  menuListIdsCount: menu_list_ids?.length ?? 0,
@@ -5995,7 +6244,7 @@ class Server {
5995
6244
  count: productsWithPrice.length,
5996
6245
  ids: uniqueIds
5997
6246
  });
5998
- const filteredProducts = productsWithPrice.filter(p => uniqueIds.includes(Number(p?.id))).filter(p => (p?.status || 'published') === 'published');
6247
+ const filteredProducts = productsWithPrice.filter(p => uniqueIds.includes(Number(p?.id))).filter(isVisibleProduct);
5999
6248
  const extensionFilteredProducts = this.filterProductsByExtensionTypes(filteredProducts, extension_type);
6000
6249
  (0, _product.perfMark)('computeProductQueryResult', performance.now() - tTotal, {
6001
6250
  mode: 'ids',
@@ -6025,7 +6274,7 @@ class Server {
6025
6274
  count: allProductsWithPrice.length,
6026
6275
  productId: pid
6027
6276
  });
6028
- const published = this.filterProductsByExtensionTypes(allProductsWithPrice.filter(p => (p?.status || 'published') === 'published'), extension_type);
6277
+ const published = this.filterProductsByExtensionTypes(allProductsWithPrice.filter(isVisibleProduct), extension_type);
6029
6278
  const item = published.find(p => Number(p.id) === pid) ?? null;
6030
6279
  (0, _product.perfMark)('computeProductQueryResult', performance.now() - tTotal, {
6031
6280
  mode: 'single',
@@ -6054,7 +6303,7 @@ class Server {
6054
6303
  });
6055
6304
  const tStatus = performance.now();
6056
6305
  const beforeStatusCount = filteredProducts.length;
6057
- filteredProducts = filteredProducts.filter(p => (p?.status || 'published') === 'published');
6306
+ filteredProducts = filteredProducts.filter(isVisibleProduct);
6058
6307
  (0, _product.perfMark)('computeQuery.filterByStatus(extensionType)', performance.now() - tStatus, {
6059
6308
  before: beforeStatusCount,
6060
6309
  after: filteredProducts.length
@@ -6137,7 +6386,7 @@ class Server {
6137
6386
  });
6138
6387
  const tStatus = performance.now();
6139
6388
  const beforeStatusCount = filteredProducts.length;
6140
- filteredProducts = filteredProducts.filter(p => (p?.status || "published") === 'published');
6389
+ filteredProducts = filteredProducts.filter(isVisibleProduct);
6141
6390
  (0, _product.perfMark)('computeQuery.filterByStatus', performance.now() - tStatus, {
6142
6391
  before: beforeStatusCount,
6143
6392
  after: filteredProducts.length
@@ -6214,7 +6463,7 @@ class Server {
6214
6463
  const result = await this.computeProductQueryResult(subscriber.context, {
6215
6464
  changedIds: options?.changedIds
6216
6465
  });
6217
- subscriber.callback(result);
6466
+ await subscriber.callback(result);
6218
6467
  this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
6219
6468
  subscriberId
6220
6469
  });
@@ -0,0 +1,19 @@
1
+ import { BaseModule } from '../../../modules/BaseModule';
2
+ import type { Module, ModuleOptions, PisellCore } from '../../../types';
3
+ /**
4
+ * 表单定义缓存。数据源负责 HTTP 与 Ably 订阅;本模块仅向 OS 消费方公开只读标题映射。
5
+ */
6
+ export declare class FormModule extends BaseModule implements Module {
7
+ protected defaultName: string;
8
+ protected defaultVersion: string;
9
+ private store;
10
+ private dataSource;
11
+ private refreshTimer?;
12
+ initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
13
+ preload(): Promise<void>;
14
+ getTitleMap(): Record<string, Record<string, string> | string>;
15
+ private scheduleRefresh;
16
+ private refresh;
17
+ destroy(): Promise<void>;
18
+ }
19
+ export default FormModule;