@pisell/pisellos 2.3.140 → 2.3.142

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 (39) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/Cart/index.js +4 -3
  3. package/dist/modules/Cart/types.d.ts +2 -0
  4. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
  5. package/dist/modules/Cart/utils/cartProduct.js +59 -32
  6. package/dist/modules/Order/index.d.ts +1 -1
  7. package/dist/modules/Order/types.d.ts +1 -0
  8. package/dist/modules/Order/utils.js +8 -0
  9. package/dist/modules/Product/types.d.ts +11 -0
  10. package/dist/server/index.js +118 -69
  11. package/dist/server/modules/order/types.d.ts +1 -0
  12. package/dist/shared/receipt/small-ticket.d.ts +2 -0
  13. package/dist/shared/receipt/small-ticket.js +188 -73
  14. package/dist/shared/receipt/templateVisibility.d.ts +23 -0
  15. package/dist/shared/receipt/templateVisibility.js +64 -0
  16. package/dist/solution/BookingByStep/index.d.ts +4 -2
  17. package/dist/solution/BookingByStep/index.js +8 -3
  18. package/dist/solution/OrderInvoicePreview/index.js +2 -1
  19. package/dist/solution/UnifiedBookingSales/index.js +6 -2
  20. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  21. package/lib/modules/Cart/index.js +4 -2
  22. package/lib/modules/Cart/types.d.ts +2 -0
  23. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
  24. package/lib/modules/Cart/utils/cartProduct.js +39 -20
  25. package/lib/modules/Order/index.d.ts +1 -1
  26. package/lib/modules/Order/types.d.ts +1 -0
  27. package/lib/modules/Order/utils.js +8 -0
  28. package/lib/modules/Product/types.d.ts +11 -0
  29. package/lib/server/index.js +68 -28
  30. package/lib/server/modules/order/types.d.ts +1 -0
  31. package/lib/shared/receipt/small-ticket.d.ts +2 -0
  32. package/lib/shared/receipt/small-ticket.js +113 -22
  33. package/lib/shared/receipt/templateVisibility.d.ts +23 -0
  34. package/lib/shared/receipt/templateVisibility.js +63 -0
  35. package/lib/solution/BookingByStep/index.d.ts +4 -2
  36. package/lib/solution/BookingByStep/index.js +7 -3
  37. package/lib/solution/OrderInvoicePreview/index.js +2 -1
  38. package/lib/solution/UnifiedBookingSales/index.js +2 -1
  39. package/package.json +1 -1
@@ -41,6 +41,7 @@ import { OrderHooks } from "./modules/order/types";
41
41
  import { filterOrders } from "./modules/order/utils/filterOrders";
42
42
  import { filterBookingsFromOrders, sortBookings } from "./modules/order/utils/filterBookings";
43
43
  import { buildSmallTicketData, hasSmallTicketData } from "./utils/small-ticket";
44
+ import { requiresInvoiceDataFiltering } from "../shared/receipt/templateVisibility";
44
45
  import { BaseSalesImpl } from "../solution/BaseSales";
45
46
  import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity } from "../modules/Order/payment-utils";
46
47
  import { finalizeSalesNotesForCheckout } from "../modules/Order/salesNotes";
@@ -1386,7 +1387,10 @@ var Server = /*#__PURE__*/function () {
1386
1387
  small_ticket_data_flag: 1,
1387
1388
  payment_info: paymentInfo
1388
1389
  }), {
1389
- locales: _this.normalizeRequestedReceiptLocales(input.locales)
1390
+ locales: _this.normalizeRequestedReceiptLocales(input.locales),
1391
+ invoiceTemplateSettings: input.template_settings === undefined ? undefined : _this.normalizePrintInvoiceTemplateSettings(input.template_settings),
1392
+ applyTemplateVisibility: true,
1393
+ includeReceiptKeys: input.template_settings !== undefined
1390
1394
  });
1391
1395
  case 22:
1392
1396
  rebuiltOrder = _context20.sent;
@@ -1409,7 +1413,15 @@ var Server = /*#__PURE__*/function () {
1409
1413
  status: true,
1410
1414
  message: '',
1411
1415
  data: {
1412
- small_ticket_data: smallTicketData
1416
+ small_ticket_data: smallTicketData,
1417
+ template_visibility_applied: true,
1418
+ // These products and currency settings are the exact source used for
1419
+ // this receipt, not the potentially newer active tempOrder.
1420
+ source: _objectSpread(_objectSpread({}, rebuiltOrder), {}, {
1421
+ payment_info: _objectSpread(_objectSpread({}, rebuiltOrder.payment_info || {}), {}, {
1422
+ small_ticket_data: undefined
1423
+ })
1424
+ })
1413
1425
  }
1414
1426
  });
1415
1427
  case 29:
@@ -6146,7 +6158,8 @@ var Server = /*#__PURE__*/function () {
6146
6158
  _context60.next = 4;
6147
6159
  return this.withLocalSmallTicketData(params.order, {
6148
6160
  requireFullyPaid: params.requireFullyPaid,
6149
- invoiceTemplateSettings: params.invoiceTemplateSettings
6161
+ invoiceTemplateSettings: params.invoiceTemplateSettings,
6162
+ applyTemplateVisibility: true
6150
6163
  });
6151
6164
  case 4:
6152
6165
  printableOrder = _context60.sent;
@@ -6177,7 +6190,7 @@ var Server = /*#__PURE__*/function () {
6177
6190
  case 10:
6178
6191
  return _context60.abrupt("return", {
6179
6192
  printed: true,
6180
- order: printableOrder
6193
+ order: requiresInvoiceDataFiltering(params.invoiceTemplateSettings) ? params.order : printableOrder
6181
6194
  });
6182
6195
  case 11:
6183
6196
  case "end":
@@ -6429,15 +6442,16 @@ var Server = /*#__PURE__*/function () {
6429
6442
  case 18:
6430
6443
  pendingResult = _context62.sent;
6431
6444
  if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
6432
- _context62.next = 26;
6445
+ _context62.next = 33;
6433
6446
  break;
6434
6447
  }
6435
6448
  pendingOrder = pendingResult.data;
6436
- if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
6437
- _context62.next = 24;
6449
+ if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
6450
+ _context62.next = 31;
6438
6451
  break;
6439
6452
  }
6440
- _context62.next = 24;
6453
+ _context62.prev = 22;
6454
+ _context62.next = 25;
6441
6455
  return this.dispatchLocalReceiptPrint({
6442
6456
  checkoutData: checkoutData,
6443
6457
  order: pendingOrder,
@@ -6446,8 +6460,20 @@ var Server = /*#__PURE__*/function () {
6446
6460
  invoiceLayoutConfig: invoiceLayoutConfig,
6447
6461
  invoiceTemplateSettings: invoiceTemplateSettings
6448
6462
  });
6449
- case 24:
6450
- _context62.next = 26;
6463
+ case 25:
6464
+ _context62.next = 31;
6465
+ break;
6466
+ case 27:
6467
+ _context62.prev = 27;
6468
+ _context62.t0 = _context62["catch"](22);
6469
+ // The sale is already persisted. A failed receipt must not cancel its
6470
+ // sync task or send an unfiltered fallback to the printer.
6471
+ pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context62.t0);
6472
+ this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u4ECD\u7EE7\u7EED\u540C\u6B65"), {
6473
+ error: pendingResult.receipt_print_error
6474
+ });
6475
+ case 31:
6476
+ _context62.next = 33;
6451
6477
  return this.dispatchCheckoutSyncTask({
6452
6478
  backendPath: backendPath,
6453
6479
  data: checkoutData,
@@ -6455,9 +6481,9 @@ var Server = /*#__PURE__*/function () {
6455
6481
  invoiceLayoutConfig: invoiceLayoutConfig,
6456
6482
  invoiceTemplateSettings: invoiceTemplateSettings
6457
6483
  });
6458
- case 26:
6484
+ case 33:
6459
6485
  if (pendingResult.data.order_id) {
6460
- _context62.next = 28;
6486
+ _context62.next = 35;
6461
6487
  break;
6462
6488
  }
6463
6489
  return _context62.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
@@ -6465,13 +6491,13 @@ var Server = /*#__PURE__*/function () {
6465
6491
  order_id: pendingResult.data.external_sale_number
6466
6492
  })
6467
6493
  }));
6468
- case 28:
6494
+ case 35:
6469
6495
  return _context62.abrupt("return", pendingResult);
6470
- case 29:
6496
+ case 36:
6471
6497
  case "end":
6472
6498
  return _context62.stop();
6473
6499
  }
6474
- }, _callee62, this);
6500
+ }, _callee62, this, [[22, 27]]);
6475
6501
  }));
6476
6502
  function handleOrderCheckoutSubmit(_x69) {
6477
6503
  return _handleOrderCheckoutSubmit.apply(this, arguments);
@@ -6525,11 +6551,12 @@ var Server = /*#__PURE__*/function () {
6525
6551
  case 11:
6526
6552
  response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
6527
6553
  syncedOrder = syncResult.syncedOrder;
6528
- if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData) && this.isSalesOrderFullyPaid(syncedOrder))) {
6529
- _context63.next = 16;
6554
+ if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.isSalesOrderFullyPaid(syncedOrder))) {
6555
+ _context63.next = 23;
6530
6556
  break;
6531
6557
  }
6532
- _context63.next = 16;
6558
+ _context63.prev = 14;
6559
+ _context63.next = 17;
6533
6560
  return this.dispatchLocalReceiptPrint({
6534
6561
  checkoutData: syncResult.checkoutData,
6535
6562
  order: syncedOrder,
@@ -6537,16 +6564,27 @@ var Server = /*#__PURE__*/function () {
6537
6564
  requireFullyPaid: true,
6538
6565
  invoiceLayoutConfig: invoiceLayoutConfig,
6539
6566
  invoiceTemplateSettings: invoiceTemplateSettings
6540
- // print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
6541
6567
  });
6542
- case 16:
6543
- return _context63.abrupt("return", response);
6568
+ case 17:
6569
+ _context63.next = 23;
6570
+ break;
6544
6571
  case 19:
6545
6572
  _context63.prev = 19;
6546
- _context63.t0 = _context63["catch"](4);
6547
- backendError = this.extractBackendErrorResponse(_context63.t0);
6573
+ _context63.t0 = _context63["catch"](14);
6574
+ // Checkout already succeeded remotely; report the receipt failure
6575
+ // separately instead of implying that payment/order creation failed.
6576
+ response.receipt_print_error = this.getUnknownErrorMessage(_context63.t0);
6577
+ this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u5DF2\u540C\u6B65"), {
6578
+ error: response.receipt_print_error
6579
+ });
6580
+ case 23:
6581
+ return _context63.abrupt("return", response);
6582
+ case 26:
6583
+ _context63.prev = 26;
6584
+ _context63.t1 = _context63["catch"](4);
6585
+ backendError = this.extractBackendErrorResponse(_context63.t1);
6548
6586
  if (!backendError) {
6549
- _context63.next = 25;
6587
+ _context63.next = 32;
6550
6588
  break;
6551
6589
  }
6552
6590
  _normalized = this.normalizeCheckoutResponse(backendError);
@@ -6555,12 +6593,12 @@ var Server = /*#__PURE__*/function () {
6555
6593
  message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
6556
6594
  data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
6557
6595
  }));
6558
- case 25:
6559
- message = this.getUnknownErrorMessage(_context63.t0);
6596
+ case 32:
6597
+ message = this.getUnknownErrorMessage(_context63.t1);
6560
6598
  this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
6561
6599
  backendPath: backendPath,
6562
6600
  error: message,
6563
- error_detail: this.normalizeUnknownError(_context63.t0)
6601
+ error_detail: this.normalizeUnknownError(_context63.t1)
6564
6602
  });
6565
6603
  return _context63.abrupt("return", {
6566
6604
  code: 500,
@@ -6568,11 +6606,11 @@ var Server = /*#__PURE__*/function () {
6568
6606
  message: message,
6569
6607
  data: null
6570
6608
  });
6571
- case 28:
6609
+ case 35:
6572
6610
  case "end":
6573
6611
  return _context63.stop();
6574
6612
  }
6575
- }, _callee63, this, [[4, 19]]);
6613
+ }, _callee63, this, [[4, 26], [14, 19]]);
6576
6614
  }));
6577
6615
  function handleSyncCheckoutSubmit(_x70) {
6578
6616
  return _handleSyncCheckoutSubmit.apply(this, arguments);
@@ -6840,11 +6878,13 @@ var Server = /*#__PURE__*/function () {
6840
6878
  }
6841
6879
  }, {
6842
6880
  key: "shouldBuildSmallTicketData",
6843
- value: function shouldBuildSmallTicketData(order) {
6844
- var _ref68, _order$small_ticket_d;
6881
+ value: function shouldBuildSmallTicketData(order, invoiceTemplateSettings) {
6882
+ var _order$small_ticket_d;
6845
6883
  if (!order || _typeof(order) !== 'object') return false;
6846
- // if (hasSmallTicketData(order.payment_info?.small_ticket_data)) return false;
6847
- return Number((_ref68 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref68 !== void 0 ? _ref68 : 0) === 1;
6884
+ var flag = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag;
6885
+ // A synced order can omit the generation flag; required display filtering
6886
+ // still rebuilds its output. An explicit 0 retains the no-auto-print intent.
6887
+ return Number(flag !== null && flag !== void 0 ? flag : 0) === 1 || flag == null && requiresInvoiceDataFiltering(invoiceTemplateSettings);
6848
6888
  }
6849
6889
  }, {
6850
6890
  key: "shouldPrintSyncedOrder",
@@ -6862,7 +6902,7 @@ var Server = /*#__PURE__*/function () {
6862
6902
  }, {
6863
6903
  key: "isSalesOrderFullyPaid",
6864
6904
  value: function isSalesOrderFullyPaid(order) {
6865
- var _order$summary$amount, _order$summary, _ref69, _ref70, _order$summary$expect, _order$summary2, _order$summary3;
6905
+ var _order$summary$amount, _order$summary, _ref68, _ref69, _order$summary$expect, _order$summary2, _order$summary3;
6866
6906
  if (!order || _typeof(order) !== 'object') return false;
6867
6907
  var paymentStatus = String(order.payment_status || '').toLowerCase();
6868
6908
  if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
@@ -6874,7 +6914,7 @@ var Server = /*#__PURE__*/function () {
6874
6914
  return this.toAmountNumber(amountGap) <= 0;
6875
6915
  }
6876
6916
  var paidAmount = this.sumPaidOrderPayments(order.payments);
6877
- var targetAmount = this.toAmountNumber((_ref69 = (_ref70 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref70 !== void 0 ? _ref70 : order.expect_amount) !== null && _ref69 !== void 0 ? _ref69 : order.total_amount);
6917
+ var targetAmount = this.toAmountNumber((_ref68 = (_ref69 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref69 !== void 0 ? _ref69 : order.expect_amount) !== null && _ref68 !== void 0 ? _ref68 : order.total_amount);
6878
6918
  if (targetAmount <= 0) return paidAmount > 0;
6879
6919
  return paidAmount >= targetAmount;
6880
6920
  }
@@ -6918,8 +6958,8 @@ var Server = /*#__PURE__*/function () {
6918
6958
  }
6919
6959
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
6920
6960
  product.product_bundle.forEach(function (bundle) {
6921
- var _ref71, _bundle$bundle_produc;
6922
- var bundleProductId = (_ref71 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref71 !== void 0 ? _ref71 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6961
+ var _ref70, _bundle$bundle_produc;
6962
+ var bundleProductId = (_ref70 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref70 !== void 0 ? _ref70 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6923
6963
  if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
6924
6964
  productIdSet.add(bundleProductId);
6925
6965
  }
@@ -6935,7 +6975,7 @@ var Server = /*#__PURE__*/function () {
6935
6975
  case 6:
6936
6976
  _context68.next = 8;
6937
6977
  return Promise.all(productIds.map( /*#__PURE__*/function () {
6938
- var _ref72 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(id) {
6978
+ var _ref71 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(id) {
6939
6979
  var _this18$products, _this18$products$getP, product;
6940
6980
  return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6941
6981
  while (1) switch (_context67.prev = _context67.next) {
@@ -6961,7 +7001,7 @@ var Server = /*#__PURE__*/function () {
6961
7001
  }, _callee67, null, [[0, 7]]);
6962
7002
  }));
6963
7003
  return function (_x76) {
6964
- return _ref72.apply(this, arguments);
7004
+ return _ref71.apply(this, arguments);
6965
7005
  };
6966
7006
  }()));
6967
7007
  case 8:
@@ -7000,8 +7040,8 @@ var Server = /*#__PURE__*/function () {
7000
7040
  addProductId((_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id);
7001
7041
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
7002
7042
  product.product_bundle.forEach(function (bundle) {
7003
- var _ref73, _bundle$bundle_produc2;
7004
- addProductId((_ref73 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref73 !== void 0 ? _ref73 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
7043
+ var _ref72, _bundle$bundle_produc2;
7044
+ addProductId((_ref72 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref72 !== void 0 ? _ref72 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
7005
7045
  });
7006
7046
  }
7007
7047
  });
@@ -7077,9 +7117,9 @@ var Server = /*#__PURE__*/function () {
7077
7117
  if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
7078
7118
  var hasChanged = false;
7079
7119
  var productBundle = product.product_bundle.map(function (bundle) {
7080
- var _ref74, _bundle$bundle_produc3;
7120
+ var _ref73, _bundle$bundle_produc3;
7081
7121
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
7082
- var rawProductId = (_ref74 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref74 !== void 0 ? _ref74 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7122
+ var rawProductId = (_ref73 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref73 !== void 0 ? _ref73 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
7083
7123
  if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
7084
7124
  var productId = Number(rawProductId);
7085
7125
  if (!Number.isFinite(productId)) return bundle;
@@ -7203,7 +7243,7 @@ var Server = /*#__PURE__*/function () {
7203
7243
  }, {
7204
7244
  key: "resolveProductTitleValue",
7205
7245
  value: function resolveProductTitleValue(value, key, currentLocale) {
7206
- var _ref75, _ref76, _value$key;
7246
+ var _ref74, _ref75, _value$key;
7207
7247
  if (value === undefined || value === null || value === '') return null;
7208
7248
  if (_typeof(value) !== 'object') {
7209
7249
  var title = String(value);
@@ -7213,7 +7253,7 @@ var Server = /*#__PURE__*/function () {
7213
7253
  }
7214
7254
  var normalizedKey = key.replace('-', '_');
7215
7255
  var dashedKey = key.replace('_', '-');
7216
- var rawValue = (_ref75 = (_ref76 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref76 !== void 0 ? _ref76 : value[dashedKey]) !== null && _ref75 !== void 0 ? _ref75 : key === 'auto' ? value.default : undefined;
7256
+ var rawValue = (_ref74 = (_ref75 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref75 !== void 0 ? _ref75 : value[dashedKey]) !== null && _ref74 !== void 0 ? _ref74 : key === 'auto' ? value.default : undefined;
7217
7257
  if (rawValue === undefined || rawValue === null || rawValue === '') return null;
7218
7258
  if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
7219
7259
  return String(rawValue);
@@ -7357,23 +7397,24 @@ var Server = /*#__PURE__*/function () {
7357
7397
  key: "withLocalSmallTicketData",
7358
7398
  value: function () {
7359
7399
  var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(order, options) {
7360
- var _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref77, _ref78, _order_id, enrichedOrder, productMap, smallTicketData;
7400
+ var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref76, _ref77, _order_id, enrichedOrder, productMap, smallTicketData;
7361
7401
  return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7362
7402
  while (1) switch (_context72.prev = _context72.next) {
7363
7403
  case 0:
7364
- if (this.shouldBuildSmallTicketData(order)) {
7365
- _context72.next = 2;
7404
+ mustApplyVisibility = (options === null || options === void 0 ? void 0 : options.applyTemplateVisibility) === true && requiresInvoiceDataFiltering(options.invoiceTemplateSettings);
7405
+ if (!(!this.shouldBuildSmallTicketData(order) && !mustApplyVisibility)) {
7406
+ _context72.next = 3;
7366
7407
  break;
7367
7408
  }
7368
7409
  return _context72.abrupt("return", order);
7369
- case 2:
7410
+ case 3:
7370
7411
  if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
7371
- _context72.next = 4;
7412
+ _context72.next = 5;
7372
7413
  break;
7373
7414
  }
7374
7415
  return _context72.abrupt("return", order);
7375
- case 4:
7376
- _context72.prev = 4;
7416
+ case 5:
7417
+ _context72.prev = 5;
7377
7418
  normalizedCollections = normalizeOrderCollections(order, {
7378
7419
  ensureUid: false
7379
7420
  });
@@ -7387,51 +7428,59 @@ var Server = /*#__PURE__*/function () {
7387
7428
  return count > 0;
7388
7429
  })) {
7389
7430
  this.logWarning('withLocalSmallTicketData: 折叠重复订单子项', {
7390
- order_identifier: (_ref77 = (_ref78 = (_order_id = normalizedOrder.order_id) !== null && _order_id !== void 0 ? _order_id : normalizedOrder.external_sale_number) !== null && _ref78 !== void 0 ? _ref78 : normalizedOrder.shop_order_number) !== null && _ref77 !== void 0 ? _ref77 : null,
7431
+ order_identifier: (_ref76 = (_ref77 = (_order_id = normalizedOrder.order_id) !== null && _order_id !== void 0 ? _order_id : normalizedOrder.external_sale_number) !== null && _ref77 !== void 0 ? _ref77 : normalizedOrder.shop_order_number) !== null && _ref76 !== void 0 ? _ref76 : null,
7391
7432
  collapsed_duplicate_counts: collapsedDuplicateCounts
7392
7433
  });
7393
7434
  }
7394
- _context72.next = 11;
7435
+ _context72.next = 12;
7395
7436
  return this.enrichPaymentNamesByCode(normalizedOrder);
7396
- case 11:
7437
+ case 12:
7397
7438
  enrichedOrder = _context72.sent;
7398
7439
  if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
7399
- _context72.next = 16;
7440
+ _context72.next = 17;
7400
7441
  break;
7401
7442
  }
7402
7443
  _context72.t0 = _options$productMap;
7403
- _context72.next = 19;
7444
+ _context72.next = 20;
7404
7445
  break;
7405
- case 16:
7406
- _context72.next = 18;
7446
+ case 17:
7447
+ _context72.next = 19;
7407
7448
  return this.buildSmallTicketProductMap(enrichedOrder);
7408
- case 18:
7409
- _context72.t0 = _context72.sent;
7410
7449
  case 19:
7450
+ _context72.t0 = _context72.sent;
7451
+ case 20:
7411
7452
  productMap = _context72.t0;
7412
7453
  smallTicketData = buildSmallTicketData({
7413
7454
  order: enrichedOrder,
7414
7455
  shopInfo: this.getSmallTicketShopInfo(),
7415
7456
  locales: [].concat(_toConsumableArray(resolveInvoiceReceiptLocales(options === null || options === void 0 ? void 0 : options.invoiceTemplateSettings)), _toConsumableArray((options === null || options === void 0 ? void 0 : options.locales) || [])),
7416
- productMap: productMap
7457
+ productMap: productMap,
7458
+ includeReceiptKeys: options === null || options === void 0 ? void 0 : options.includeReceiptKeys,
7459
+ templateSettings: options !== null && options !== void 0 && options.applyTemplateVisibility ? options.invoiceTemplateSettings : undefined
7417
7460
  });
7418
7461
  return _context72.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
7419
7462
  payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
7420
7463
  small_ticket_data: smallTicketData
7421
7464
  })
7422
7465
  }));
7423
- case 24:
7424
- _context72.prev = 24;
7425
- _context72.t1 = _context72["catch"](4);
7466
+ case 25:
7467
+ _context72.prev = 25;
7468
+ _context72.t1 = _context72["catch"](5);
7426
7469
  this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
7427
7470
  error: _context72.t1 instanceof Error ? _context72.t1.message : String(_context72.t1)
7428
7471
  });
7472
+ if (!mustApplyVisibility) {
7473
+ _context72.next = 30;
7474
+ break;
7475
+ }
7476
+ throw _context72.t1;
7477
+ case 30:
7429
7478
  return _context72.abrupt("return", order);
7430
- case 28:
7479
+ case 31:
7431
7480
  case "end":
7432
7481
  return _context72.stop();
7433
7482
  }
7434
- }, _callee72, this, [[4, 24]]);
7483
+ }, _callee72, this, [[5, 25]]);
7435
7484
  }));
7436
7485
  function withLocalSmallTicketData(_x80, _x81) {
7437
7486
  return _withLocalSmallTicketData.apply(this, arguments);
@@ -7450,7 +7499,7 @@ var Server = /*#__PURE__*/function () {
7450
7499
  value: function () {
7451
7500
  var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(lookup, data, title) {
7452
7501
  var _this$order5, _this$order6, _this$app17;
7453
- var backendPath, response, _response$code3, responseStatusCode, code, message, fresh, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref79, _backendError$code2, backendStatusCode, _code, _message2, _message3;
7502
+ var backendPath, response, _response$code3, responseStatusCode, code, message, fresh, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref78, _backendError$code2, backendStatusCode, _code, _message2, _message3;
7454
7503
  return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7455
7504
  while (1) switch (_context73.prev = _context73.next) {
7456
7505
  case 0:
@@ -7571,7 +7620,7 @@ var Server = /*#__PURE__*/function () {
7571
7620
  break;
7572
7621
  }
7573
7622
  backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
7574
- _code = this.normalizeRemoteSalesOrderErrorCode((_ref79 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref79 !== void 0 ? _ref79 : _responseStatusCode);
7623
+ _code = this.normalizeRemoteSalesOrderErrorCode((_ref78 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref78 !== void 0 ? _ref78 : _responseStatusCode);
7575
7624
  _message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context73.t0);
7576
7625
  this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
7577
7626
  lookup: lookup,
@@ -463,6 +463,7 @@ export interface OrderData {
463
463
  id: number | string;
464
464
  tag: 'virtual_currency';
465
465
  product_id?: number | string;
466
+ code?: string;
466
467
  product_name: string;
467
468
  par_value: string;
468
469
  used_par_value: string;
@@ -22,6 +22,8 @@ export interface BuildSmallTicketDataParams {
22
22
  shopInfo?: SmallTicketShopInfo | null;
23
23
  locales?: string[];
24
24
  productMap?: Record<string | number, Record<string, any>>;
25
+ /** Resolved template settings or layout; omitted settings preserve native compatibility. */
26
+ templateSettings?: unknown;
25
27
  /** Customer preview only: stable source identities for bilingual rows. */
26
28
  includeReceiptKeys?: boolean;
27
29
  }