@pisell/pisellos 0.10.19 → 0.10.20

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.
@@ -0,0 +1,9 @@
1
+ // 导出评估器
2
+ export { PromotionEvaluator } from "./evaluator";
3
+
4
+ // 导出适配器
5
+ export { PromotionAdapter } from "./adapter";
6
+ export { default } from "./adapter";
7
+
8
+ // 导出策略配置示例常量
9
+ export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -3,7 +3,7 @@ import { BaseModule } from '../BaseModule';
3
3
  import type { ScheduleModule } from '../Schedule';
4
4
  import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
5
5
  export * from './types';
6
- export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, } from './utils';
6
+ export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales, } from './utils';
7
7
  export declare class OpenDataModule extends BaseModule implements Module {
8
8
  protected defaultName: string;
9
9
  protected defaultVersion: string;
@@ -18,7 +18,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
18
18
  import { BaseModule } from "../BaseModule";
19
19
  import { computeAvailability, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings } from "./utils";
20
20
  export * from "./types";
21
- export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "./utils";
21
+ export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "./utils";
22
22
  export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
23
23
  _inherits(OpenDataModule, _BaseModule);
24
24
  var _super = _createSuper(OpenDataModule);
@@ -1,6 +1,11 @@
1
1
  import type { OpenDataConfig, OpenDataAvailabilityResult, ComputeAvailabilityParams, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
2
2
  export declare function getDefaultInvoiceLayoutConfig(): InvoiceLayoutConfig;
3
3
  export declare function getDefaultInvoiceTemplateSettings(): InvoiceTemplateSettings;
4
+ /**
5
+ * 将非 DEFAULT Invoice 模板启用的语言转换为 small_ticket_data locale。
6
+ * cn_en 是中英组合打印模式,因此展开为 en 与 zh_CN 两份数据。
7
+ */
8
+ export declare function resolveInvoiceReceiptLocales(settings?: InvoiceTemplateSettings | null): string[];
4
9
  /**
5
10
  * 规范化已经提取出的公开 template_settings 值,供打印入口复用。
6
11
  */
@@ -3,6 +3,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
3
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
5
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
12
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
13
  import dayjs from 'dayjs';
8
14
  import { getDateIsInSchedule } from "../Schedule/getDateIsInSchedule";
@@ -38,6 +44,42 @@ export function getDefaultInvoiceTemplateSettings() {
38
44
  modules: []
39
45
  };
40
46
  }
47
+ var INVOICE_RECEIPT_LOCALE_ORDER = ['en', 'zh_CN', 'zh_HK', 'ja', 'pt'];
48
+ var INVOICE_RECEIPT_LOCALE_MAPPING = {
49
+ en: ['en'],
50
+ zh_cn: ['zh_CN'],
51
+ zh_hk: ['zh_HK'],
52
+ ja: ['ja'],
53
+ pt: ['pt'],
54
+ cn_en: ['en', 'zh_CN']
55
+ };
56
+
57
+ /**
58
+ * 将非 DEFAULT Invoice 模板启用的语言转换为 small_ticket_data locale。
59
+ * cn_en 是中英组合打印模式,因此展开为 en 与 zh_CN 两份数据。
60
+ */
61
+ export function resolveInvoiceReceiptLocales(settings) {
62
+ if (typeof (settings === null || settings === void 0 ? void 0 : settings.template) !== 'string' || settings.template.trim().length === 0 || settings.template.trim().toUpperCase() === 'DEFAULT' || !isRecord(settings.language)) {
63
+ return [];
64
+ }
65
+ var enabledLocales = new Set();
66
+ Object.entries(settings.language).forEach(function (_ref) {
67
+ var _INVOICE_RECEIPT_LOCA;
68
+ var _ref2 = _slicedToArray(_ref, 2),
69
+ rawKey = _ref2[0],
70
+ count = _ref2[1];
71
+ if (typeof count !== 'number' || !Number.isFinite(count) || count <= 0) {
72
+ return;
73
+ }
74
+ var key = rawKey.trim().toLowerCase().replace(/-/g, '_');
75
+ (_INVOICE_RECEIPT_LOCA = INVOICE_RECEIPT_LOCALE_MAPPING[key]) === null || _INVOICE_RECEIPT_LOCA === void 0 || _INVOICE_RECEIPT_LOCA.forEach(function (locale) {
76
+ enabledLocales.add(locale);
77
+ });
78
+ });
79
+ return INVOICE_RECEIPT_LOCALE_ORDER.filter(function (locale) {
80
+ return enabledLocales.has(locale);
81
+ });
82
+ }
41
83
  function normalizeInvoiceTemplate(value) {
42
84
  if (typeof value !== 'string' || value.trim().length === 0) return 'DEFAULT';
43
85
  return value.trim().toUpperCase() === 'DEFAULT' ? 'DEFAULT' : value;
@@ -532,6 +532,11 @@ declare class Server {
532
532
  private handleOrderDraftSubmit;
533
533
  private handlePendingSyncCheckoutOrder;
534
534
  private buildPendingSyncCheckoutOrder;
535
+ /**
536
+ * Checkout 与本地小票必须消费同一份规范化子项快照。
537
+ * 商品/预约只折叠持久化 ID 或协议 UID 相同的行;支付额外兼容 payment_number。
538
+ */
539
+ private normalizeCheckoutCollections;
535
540
  /**
536
541
  * Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
537
542
  */
@@ -43,7 +43,8 @@ import { filterBookingsFromOrders, sortBookings } from "./modules/order/utils/fi
43
43
  import { buildSmallTicketData, hasSmallTicketData } from "./utils/small-ticket";
44
44
  import { BaseSalesImpl } from "../solution/BaseSales";
45
45
  import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity } from "../modules/Order/payment-utils";
46
- import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "../modules/OpenData";
46
+ import { normalizeOrderCollections } from "../modules/Order/utils/orderCollectionIdentity";
47
+ import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "../modules/OpenData";
47
48
  var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
48
49
  var OS_INVOICE_LAYOUT_CONFIG_FIELD = '_os_invoice_layout_config';
49
50
  var OS_INVOICE_TEMPLATE_SETTINGS_FIELD = '_os_invoice_template_settings';
@@ -2435,7 +2436,7 @@ var Server = /*#__PURE__*/function () {
2435
2436
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
2436
2437
  case 6:
2437
2438
  numberedData = _context31.sent;
2438
- checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
2439
+ checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
2439
2440
  remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
2440
2441
  if ((_this$app5 = this.app) !== null && _this$app5 !== void 0 && (_this$app5 = _this$app5.request) !== null && _this$app5 !== void 0 && _this$app5.post) {
2441
2442
  _context31.next = 11;
@@ -5824,7 +5825,8 @@ var Server = /*#__PURE__*/function () {
5824
5825
  case 2:
5825
5826
  _context58.next = 4;
5826
5827
  return this.withLocalSmallTicketData(params.order, {
5827
- requireFullyPaid: params.requireFullyPaid
5828
+ requireFullyPaid: params.requireFullyPaid,
5829
+ invoiceTemplateSettings: params.invoiceTemplateSettings
5828
5830
  });
5829
5831
  case 4:
5830
5832
  printableOrder = _context58.sent;
@@ -6085,13 +6087,14 @@ var Server = /*#__PURE__*/function () {
6085
6087
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
6086
6088
  case 14:
6087
6089
  numberedData = _context60.sent;
6088
- checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
6090
+ checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
6089
6091
  _context60.next = 18;
6090
6092
  return this.handlePendingSyncCheckoutOrder({
6091
6093
  backendPath: backendPath,
6092
6094
  data: checkoutData,
6093
6095
  title: title,
6094
- reason: 'checkout 已转入设备任务同步'
6096
+ reason: 'checkout 已转入设备任务同步',
6097
+ invoiceTemplateSettings: invoiceTemplateSettings
6095
6098
  });
6096
6099
  case 18:
6097
6100
  pendingResult = _context60.sent;
@@ -6338,13 +6341,13 @@ var Server = /*#__PURE__*/function () {
6338
6341
  value: function () {
6339
6342
  var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6340
6343
  var _this14 = this;
6341
- var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6344
+ var backendPath, data, title, reason, invoiceTemplateSettings, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6342
6345
  return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6343
6346
  while (1) switch (_context63.prev = _context63.next) {
6344
6347
  case 0:
6345
- backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
6348
+ backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason, invoiceTemplateSettings = params.invoiceTemplateSettings;
6346
6349
  _context63.next = 3;
6347
- return this.buildPendingSyncCheckoutOrder(data);
6350
+ return this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
6348
6351
  case 3:
6349
6352
  pendingOrder = _context63.sent;
6350
6353
  if (pendingOrder) {
@@ -6435,7 +6438,7 @@ var Server = /*#__PURE__*/function () {
6435
6438
  }, {
6436
6439
  key: "buildPendingSyncCheckoutOrder",
6437
6440
  value: function () {
6438
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data) {
6441
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data, invoiceTemplateSettings) {
6439
6442
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
6440
6443
  return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6441
6444
  while (1) switch (_context64.prev = _context64.next) {
@@ -6453,10 +6456,10 @@ var Server = /*#__PURE__*/function () {
6453
6456
  }
6454
6457
  return _context64.abrupt("return", null);
6455
6458
  case 5:
6456
- pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
6459
+ pendingOrder = this.normalizeCheckoutCollections(_objectSpread(_objectSpread({}, data), {}, {
6457
6460
  need_sync: 1,
6458
6461
  is_draft_order: 0
6459
- });
6462
+ }));
6460
6463
  _context64.next = 8;
6461
6464
  return this.buildSmallTicketProductMap(pendingOrder);
6462
6465
  case 8:
@@ -6464,7 +6467,8 @@ var Server = /*#__PURE__*/function () {
6464
6467
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
6465
6468
  return _context64.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6466
6469
  requireFullyPaid: true,
6467
- productMap: productMap
6470
+ productMap: productMap,
6471
+ invoiceTemplateSettings: invoiceTemplateSettings
6468
6472
  }));
6469
6473
  case 11:
6470
6474
  case "end":
@@ -6472,11 +6476,28 @@ var Server = /*#__PURE__*/function () {
6472
6476
  }
6473
6477
  }, _callee64, this);
6474
6478
  }));
6475
- function buildPendingSyncCheckoutOrder(_x71) {
6479
+ function buildPendingSyncCheckoutOrder(_x71, _x72) {
6476
6480
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
6477
6481
  }
6478
6482
  return buildPendingSyncCheckoutOrder;
6479
6483
  }()
6484
+ /**
6485
+ * Checkout 与本地小票必须消费同一份规范化子项快照。
6486
+ * 商品/预约只折叠持久化 ID 或协议 UID 相同的行;支付额外兼容 payment_number。
6487
+ */
6488
+ }, {
6489
+ key: "normalizeCheckoutCollections",
6490
+ value: function normalizeCheckoutCollections(data) {
6491
+ if (!data || _typeof(data) !== 'object' || Array.isArray(data)) return data;
6492
+ var normalized = normalizeOrderCollections(data, {
6493
+ ensureUid: false
6494
+ }).order;
6495
+ if (Array.isArray(normalized.payments)) {
6496
+ normalized.payments = mergeOrderPaymentListsByIdentity([], normalized.payments);
6497
+ }
6498
+ return normalized;
6499
+ }
6500
+
6480
6501
  /**
6481
6502
  * Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
6482
6503
  */
@@ -6609,7 +6630,7 @@ var Server = /*#__PURE__*/function () {
6609
6630
  }
6610
6631
  }, _callee65, null, [[0, 7]]);
6611
6632
  }));
6612
- return function (_x73) {
6633
+ return function (_x74) {
6613
6634
  return _ref70.apply(this, arguments);
6614
6635
  };
6615
6636
  }()));
@@ -6629,7 +6650,7 @@ var Server = /*#__PURE__*/function () {
6629
6650
  }
6630
6651
  }, _callee66, this);
6631
6652
  }));
6632
- function buildSmallTicketProductMap(_x72) {
6653
+ function buildSmallTicketProductMap(_x73) {
6633
6654
  return _buildSmallTicketProductMap.apply(this, arguments);
6634
6655
  }
6635
6656
  return buildSmallTicketProductMap;
@@ -6692,7 +6713,7 @@ var Server = /*#__PURE__*/function () {
6692
6713
  }
6693
6714
  }, _callee67, this, [[4, 10]]);
6694
6715
  }));
6695
- function buildSalesDetailProductSnapshotMap(_x74) {
6716
+ function buildSalesDetailProductSnapshotMap(_x75) {
6696
6717
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
6697
6718
  }
6698
6719
  return buildSalesDetailProductSnapshotMap;
@@ -6794,7 +6815,7 @@ var Server = /*#__PURE__*/function () {
6794
6815
  }
6795
6816
  }, _callee68, this);
6796
6817
  }));
6797
- function withSalesDetailProductSnapshots(_x75) {
6818
+ function withSalesDetailProductSnapshots(_x76) {
6798
6819
  return _withSalesDetailProductSnapshots.apply(this, arguments);
6799
6820
  }
6800
6821
  return withSalesDetailProductSnapshots;
@@ -6997,7 +7018,7 @@ var Server = /*#__PURE__*/function () {
6997
7018
  }
6998
7019
  }, _callee69, this, [[4, 21]]);
6999
7020
  }));
7000
- function enrichPaymentNamesByCode(_x76) {
7021
+ function enrichPaymentNamesByCode(_x77) {
7001
7022
  return _enrichPaymentNamesByCode.apply(this, arguments);
7002
7023
  }
7003
7024
  return enrichPaymentNamesByCode;
@@ -7044,6 +7065,7 @@ var Server = /*#__PURE__*/function () {
7044
7065
  smallTicketData = buildSmallTicketData({
7045
7066
  order: enrichedOrder,
7046
7067
  shopInfo: this.getSmallTicketShopInfo(),
7068
+ locales: resolveInvoiceReceiptLocales(options === null || options === void 0 ? void 0 : options.invoiceTemplateSettings),
7047
7069
  productMap: productMap
7048
7070
  });
7049
7071
  return _context70.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
@@ -7064,7 +7086,7 @@ var Server = /*#__PURE__*/function () {
7064
7086
  }
7065
7087
  }, _callee70, this, [[4, 20]]);
7066
7088
  }));
7067
- function withLocalSmallTicketData(_x77, _x78) {
7089
+ function withLocalSmallTicketData(_x78, _x79) {
7068
7090
  return _withLocalSmallTicketData.apply(this, arguments);
7069
7091
  }
7070
7092
  return withLocalSmallTicketData;
@@ -7233,7 +7255,7 @@ var Server = /*#__PURE__*/function () {
7233
7255
  }
7234
7256
  }, _callee71, this, [[7, 37]]);
7235
7257
  }));
7236
- function fetchAndPersistSalesOrderByLookup(_x79, _x80, _x81) {
7258
+ function fetchAndPersistSalesOrderByLookup(_x80, _x81, _x82) {
7237
7259
  return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
7238
7260
  }
7239
7261
  return fetchAndPersistSalesOrderByLookup;
@@ -7475,7 +7497,7 @@ var Server = /*#__PURE__*/function () {
7475
7497
  }
7476
7498
  }, _callee72, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7477
7499
  }));
7478
- function handleUpdateLocalOrdersBatch(_x82) {
7500
+ function handleUpdateLocalOrdersBatch(_x83) {
7479
7501
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
7480
7502
  }
7481
7503
  return handleUpdateLocalOrdersBatch;
@@ -7967,7 +7989,7 @@ var Server = /*#__PURE__*/function () {
7967
7989
  }
7968
7990
  }, _callee74, this);
7969
7991
  }));
7970
- function computeOrderQueryResult(_x83) {
7992
+ function computeOrderQueryResult(_x84) {
7971
7993
  return _computeOrderQueryResult.apply(this, arguments);
7972
7994
  }
7973
7995
  return computeOrderQueryResult;
@@ -8021,7 +8043,7 @@ var Server = /*#__PURE__*/function () {
8021
8043
  }
8022
8044
  }, _callee75, this);
8023
8045
  }));
8024
- function computeBookingQueryResult(_x84) {
8046
+ function computeBookingQueryResult(_x85) {
8025
8047
  return _computeBookingQueryResult.apply(this, arguments);
8026
8048
  }
8027
8049
  return computeBookingQueryResult;
@@ -8386,7 +8408,7 @@ var Server = /*#__PURE__*/function () {
8386
8408
  }
8387
8409
  }, _callee76, this);
8388
8410
  }));
8389
- function computeProductQueryResult(_x85, _x86) {
8411
+ function computeProductQueryResult(_x86, _x87) {
8390
8412
  return _computeProductQueryResult.apply(this, arguments);
8391
8413
  }
8392
8414
  return computeProductQueryResult;
@@ -8487,7 +8509,7 @@ var Server = /*#__PURE__*/function () {
8487
8509
  }
8488
8510
  }, _callee77, this, [[4, 24, 27, 30], [8, 16]]);
8489
8511
  }));
8490
- function recomputeAndNotifyProductQuery(_x87) {
8512
+ function recomputeAndNotifyProductQuery(_x88) {
8491
8513
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
8492
8514
  }
8493
8515
  return recomputeAndNotifyProductQuery;
@@ -95,6 +95,58 @@ var LABELS = {
95
95
  rounding: '抹零',
96
96
  gross: '重量',
97
97
  tare: '去皮'
98
+ },
99
+ ja: {
100
+ contactName: '連絡先名',
101
+ contactMobile: '連絡先電話',
102
+ email: 'メール',
103
+ dineIn: '店内飲食',
104
+ takeAway: 'テイクアウト',
105
+ delivery: '配達',
106
+ pickUp: '受け取り',
107
+ shopService: '店内飲食',
108
+ pickUpTime: '受取時間',
109
+ asap: 'できるだけ早く',
110
+ cash: '現金',
111
+ eftpos: 'カード',
112
+ wallet: 'ウォレット',
113
+ giftCard: 'ギフトカード',
114
+ remainingAmount: '残高',
115
+ redeemPoints: '利用ポイント',
116
+ remainingPoints: '残りポイント',
117
+ table: 'テーブル',
118
+ orderDiscount: '注文割引',
119
+ manualDiscount: '手動割引',
120
+ payProcessingFee: '決済手数料',
121
+ rounding: '端数調整',
122
+ gross: '総重量',
123
+ tare: '風袋'
124
+ },
125
+ pt: {
126
+ contactName: 'Nome de contato',
127
+ contactMobile: 'Celular de contato',
128
+ email: 'e-mail',
129
+ dineIn: 'Consumo no local',
130
+ takeAway: 'Para levar',
131
+ delivery: 'Entrega',
132
+ pickUp: 'Recolha',
133
+ shopService: 'Consumo no local',
134
+ pickUpTime: 'Hora de recolha',
135
+ asap: 'Assim que possível',
136
+ cash: 'Dinheiro',
137
+ eftpos: 'Cartão',
138
+ wallet: 'Carteira',
139
+ giftCard: 'Cartão-presente',
140
+ remainingAmount: 'Saldo restante',
141
+ redeemPoints: 'Pontos utilizados',
142
+ remainingPoints: 'Pontos restantes',
143
+ table: 'Mesa',
144
+ orderDiscount: 'Desconto do pedido',
145
+ manualDiscount: 'Desconto manual',
146
+ payProcessingFee: 'Taxa de processamento',
147
+ rounding: 'Arredondamento',
148
+ gross: 'Peso bruto',
149
+ tare: 'Tara'
98
150
  }
99
151
  };
100
152
  export function buildSmallTicketData(params) {
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 4 | 6 | 5;
329
+ weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -339,7 +339,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
339
339
  * 获取当前的客户搜索条件
340
340
  * @returns 当前搜索条件
341
341
  */
342
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
342
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
343
343
  /**
344
344
  * 获取客户列表状态(包含滚动加载相关状态)
345
345
  * @returns 客户状态
@@ -1 +1,46 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _examples.ITEM_REWARD_STRATEGY;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "PromotionAdapter", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _adapter.PromotionAdapter;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "PromotionEvaluator", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _evaluator.PromotionEvaluator;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "default", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _adapter.default;
40
+ }
41
+ });
42
+ var _evaluator = require("./evaluator");
43
+ var _adapter = _interopRequireWildcard(require("./adapter"));
44
+ var _examples = require("./examples");
45
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -3,7 +3,7 @@ import { BaseModule } from '../BaseModule';
3
3
  import type { ScheduleModule } from '../Schedule';
4
4
  import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
5
5
  export * from './types';
6
- export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, } from './utils';
6
+ export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales, } from './utils';
7
7
  export declare class OpenDataModule extends BaseModule implements Module {
8
8
  protected defaultName: string;
9
9
  protected defaultVersion: string;
@@ -10,7 +10,8 @@ var _exportNames = {
10
10
  getDefaultInvoiceTemplateSettings: true,
11
11
  normalizeInvoiceLayoutConfig: true,
12
12
  normalizeInvoiceTemplateSettings: true,
13
- normalizeRawInvoiceTemplateSettings: true
13
+ normalizeRawInvoiceTemplateSettings: true,
14
+ resolveInvoiceReceiptLocales: true
14
15
  };
15
16
  exports.OpenDataModule = void 0;
16
17
  Object.defineProperty(exports, "computeAvailability", {
@@ -49,6 +50,12 @@ Object.defineProperty(exports, "normalizeRawInvoiceTemplateSettings", {
49
50
  return _utils.normalizeRawInvoiceTemplateSettings;
50
51
  }
51
52
  });
53
+ Object.defineProperty(exports, "resolveInvoiceReceiptLocales", {
54
+ enumerable: true,
55
+ get: function () {
56
+ return _utils.resolveInvoiceReceiptLocales;
57
+ }
58
+ });
52
59
  var _BaseModule = require("../BaseModule");
53
60
  var _utils = require("./utils");
54
61
  var _types = require("./types");
@@ -1,6 +1,11 @@
1
1
  import type { OpenDataConfig, OpenDataAvailabilityResult, ComputeAvailabilityParams, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
2
2
  export declare function getDefaultInvoiceLayoutConfig(): InvoiceLayoutConfig;
3
3
  export declare function getDefaultInvoiceTemplateSettings(): InvoiceTemplateSettings;
4
+ /**
5
+ * 将非 DEFAULT Invoice 模板启用的语言转换为 small_ticket_data locale。
6
+ * cn_en 是中英组合打印模式,因此展开为 en 与 zh_CN 两份数据。
7
+ */
8
+ export declare function resolveInvoiceReceiptLocales(settings?: InvoiceTemplateSettings | null): string[];
4
9
  /**
5
10
  * 规范化已经提取出的公开 template_settings 值,供打印入口复用。
6
11
  */
@@ -9,6 +9,7 @@ exports.getDefaultInvoiceTemplateSettings = getDefaultInvoiceTemplateSettings;
9
9
  exports.normalizeInvoiceLayoutConfig = normalizeInvoiceLayoutConfig;
10
10
  exports.normalizeInvoiceTemplateSettings = normalizeInvoiceTemplateSettings;
11
11
  exports.normalizeRawInvoiceTemplateSettings = normalizeRawInvoiceTemplateSettings;
12
+ exports.resolveInvoiceReceiptLocales = resolveInvoiceReceiptLocales;
12
13
  var _dayjs = _interopRequireDefault(require("dayjs"));
13
14
  var _getDateIsInSchedule = require("../Schedule/getDateIsInSchedule");
14
15
  var _types = require("./types");
@@ -42,6 +43,36 @@ function getDefaultInvoiceTemplateSettings() {
42
43
  modules: []
43
44
  };
44
45
  }
46
+ const INVOICE_RECEIPT_LOCALE_ORDER = ['en', 'zh_CN', 'zh_HK', 'ja', 'pt'];
47
+ const INVOICE_RECEIPT_LOCALE_MAPPING = {
48
+ en: ['en'],
49
+ zh_cn: ['zh_CN'],
50
+ zh_hk: ['zh_HK'],
51
+ ja: ['ja'],
52
+ pt: ['pt'],
53
+ cn_en: ['en', 'zh_CN']
54
+ };
55
+
56
+ /**
57
+ * 将非 DEFAULT Invoice 模板启用的语言转换为 small_ticket_data locale。
58
+ * cn_en 是中英组合打印模式,因此展开为 en 与 zh_CN 两份数据。
59
+ */
60
+ function resolveInvoiceReceiptLocales(settings) {
61
+ if (typeof settings?.template !== 'string' || settings.template.trim().length === 0 || settings.template.trim().toUpperCase() === 'DEFAULT' || !isRecord(settings.language)) {
62
+ return [];
63
+ }
64
+ const enabledLocales = new Set();
65
+ Object.entries(settings.language).forEach(([rawKey, count]) => {
66
+ if (typeof count !== 'number' || !Number.isFinite(count) || count <= 0) {
67
+ return;
68
+ }
69
+ const key = rawKey.trim().toLowerCase().replace(/-/g, '_');
70
+ INVOICE_RECEIPT_LOCALE_MAPPING[key]?.forEach(locale => {
71
+ enabledLocales.add(locale);
72
+ });
73
+ });
74
+ return INVOICE_RECEIPT_LOCALE_ORDER.filter(locale => enabledLocales.has(locale));
75
+ }
45
76
  function normalizeInvoiceTemplate(value) {
46
77
  if (typeof value !== 'string' || value.trim().length === 0) return 'DEFAULT';
47
78
  return value.trim().toUpperCase() === 'DEFAULT' ? 'DEFAULT' : value;
@@ -532,6 +532,11 @@ declare class Server {
532
532
  private handleOrderDraftSubmit;
533
533
  private handlePendingSyncCheckoutOrder;
534
534
  private buildPendingSyncCheckoutOrder;
535
+ /**
536
+ * Checkout 与本地小票必须消费同一份规范化子项快照。
537
+ * 商品/预约只折叠持久化 ID 或协议 UID 相同的行;支付额外兼容 payment_number。
538
+ */
539
+ private normalizeCheckoutCollections;
535
540
  /**
536
541
  * Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
537
542
  */
@@ -27,6 +27,7 @@ var _filterBookings = require("./modules/order/utils/filterBookings");
27
27
  var _smallTicket = require("./utils/small-ticket");
28
28
  var _BaseSales = require("../solution/BaseSales");
29
29
  var _paymentUtils = require("../modules/Order/payment-utils");
30
+ var _orderCollectionIdentity = require("../modules/Order/utils/orderCollectionIdentity");
30
31
  var _OpenData = require("../modules/OpenData");
31
32
  var _modules = require("./modules");
32
33
  Object.keys(_modules).forEach(function (key) {
@@ -631,7 +632,7 @@ class Server {
631
632
  } = params;
632
633
  const normalizedData = await this.normalizeCheckoutSubmitData(params.data, title);
633
634
  const numberedData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
634
- const checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
635
+ const checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
635
636
  const remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
636
637
  if (!this.app?.request?.post) {
637
638
  throw new Error('app.request 不可用');
@@ -3725,7 +3726,8 @@ class Server {
3725
3726
  };
3726
3727
  }
3727
3728
  const printableOrder = await this.withLocalSmallTicketData(params.order, {
3728
- requireFullyPaid: params.requireFullyPaid
3729
+ requireFullyPaid: params.requireFullyPaid,
3730
+ invoiceTemplateSettings: params.invoiceTemplateSettings
3729
3731
  });
3730
3732
  if (!(0, _smallTicket.hasSmallTicketData)(printableOrder.payment_info?.small_ticket_data)) {
3731
3733
  return {
@@ -4114,12 +4116,13 @@ class Server {
4114
4116
  }
4115
4117
  const normalizedData = await this.normalizeCheckoutSubmitData(data, title);
4116
4118
  const numberedData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
4117
- const checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
4119
+ const checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
4118
4120
  const pendingResult = await this.handlePendingSyncCheckoutOrder({
4119
4121
  backendPath,
4120
4122
  data: checkoutData,
4121
4123
  title,
4122
- reason: 'checkout 已转入设备任务同步'
4124
+ reason: 'checkout 已转入设备任务同步',
4125
+ invoiceTemplateSettings
4123
4126
  });
4124
4127
  if (pendingResult?.status === true) {
4125
4128
  const pendingOrder = pendingResult.data;
@@ -4298,9 +4301,10 @@ class Server {
4298
4301
  backendPath,
4299
4302
  data,
4300
4303
  title,
4301
- reason
4304
+ reason,
4305
+ invoiceTemplateSettings
4302
4306
  } = params;
4303
- const pendingOrder = await this.buildPendingSyncCheckoutOrder(data);
4307
+ const pendingOrder = await this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
4304
4308
  if (!pendingOrder) {
4305
4309
  this.logError(`${title}: checkout 失败且订单缺少本地存储标识`, {
4306
4310
  backendPath,
@@ -4366,23 +4370,39 @@ class Server {
4366
4370
  };
4367
4371
  }
4368
4372
  }
4369
- async buildPendingSyncCheckoutOrder(data) {
4373
+ async buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings) {
4370
4374
  if (!data || typeof data !== 'object') return null;
4371
4375
  const hasStorageKey = data.external_sale_number !== undefined && data.external_sale_number !== null && data.external_sale_number !== '' ? true : data.order_id !== undefined && data.order_id !== null && data.order_id !== '';
4372
4376
  if (!hasStorageKey) return null;
4373
- const pendingOrder = {
4377
+ const pendingOrder = this.normalizeCheckoutCollections({
4374
4378
  ...data,
4375
4379
  need_sync: 1,
4376
4380
  is_draft_order: 0
4377
- };
4381
+ });
4378
4382
  const productMap = await this.buildSmallTicketProductMap(pendingOrder);
4379
4383
  const orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
4380
4384
  return this.withLocalSmallTicketData(orderWithProductTitles, {
4381
4385
  requireFullyPaid: true,
4382
- productMap
4386
+ productMap,
4387
+ invoiceTemplateSettings
4383
4388
  });
4384
4389
  }
4385
4390
 
4391
+ /**
4392
+ * Checkout 与本地小票必须消费同一份规范化子项快照。
4393
+ * 商品/预约只折叠持久化 ID 或协议 UID 相同的行;支付额外兼容 payment_number。
4394
+ */
4395
+ normalizeCheckoutCollections(data) {
4396
+ if (!data || typeof data !== 'object' || Array.isArray(data)) return data;
4397
+ const normalized = (0, _orderCollectionIdentity.normalizeOrderCollections)(data, {
4398
+ ensureUid: false
4399
+ }).order;
4400
+ if (Array.isArray(normalized.payments)) {
4401
+ normalized.payments = (0, _paymentUtils.mergeOrderPaymentListsByIdentity)([], normalized.payments);
4402
+ }
4403
+ return normalized;
4404
+ }
4405
+
4386
4406
  /**
4387
4407
  * Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
4388
4408
  */
@@ -4705,6 +4725,7 @@ class Server {
4705
4725
  const smallTicketData = (0, _smallTicket.buildSmallTicketData)({
4706
4726
  order: enrichedOrder,
4707
4727
  shopInfo: this.getSmallTicketShopInfo(),
4728
+ locales: (0, _OpenData.resolveInvoiceReceiptLocales)(options?.invoiceTemplateSettings),
4708
4729
  productMap
4709
4730
  });
4710
4731
  return {
@@ -87,6 +87,58 @@ const LABELS = {
87
87
  rounding: '抹零',
88
88
  gross: '重量',
89
89
  tare: '去皮'
90
+ },
91
+ ja: {
92
+ contactName: '連絡先名',
93
+ contactMobile: '連絡先電話',
94
+ email: 'メール',
95
+ dineIn: '店内飲食',
96
+ takeAway: 'テイクアウト',
97
+ delivery: '配達',
98
+ pickUp: '受け取り',
99
+ shopService: '店内飲食',
100
+ pickUpTime: '受取時間',
101
+ asap: 'できるだけ早く',
102
+ cash: '現金',
103
+ eftpos: 'カード',
104
+ wallet: 'ウォレット',
105
+ giftCard: 'ギフトカード',
106
+ remainingAmount: '残高',
107
+ redeemPoints: '利用ポイント',
108
+ remainingPoints: '残りポイント',
109
+ table: 'テーブル',
110
+ orderDiscount: '注文割引',
111
+ manualDiscount: '手動割引',
112
+ payProcessingFee: '決済手数料',
113
+ rounding: '端数調整',
114
+ gross: '総重量',
115
+ tare: '風袋'
116
+ },
117
+ pt: {
118
+ contactName: 'Nome de contato',
119
+ contactMobile: 'Celular de contato',
120
+ email: 'e-mail',
121
+ dineIn: 'Consumo no local',
122
+ takeAway: 'Para levar',
123
+ delivery: 'Entrega',
124
+ pickUp: 'Recolha',
125
+ shopService: 'Consumo no local',
126
+ pickUpTime: 'Hora de recolha',
127
+ asap: 'Assim que possível',
128
+ cash: 'Dinheiro',
129
+ eftpos: 'Cartão',
130
+ wallet: 'Carteira',
131
+ giftCard: 'Cartão-presente',
132
+ remainingAmount: 'Saldo restante',
133
+ redeemPoints: 'Pontos utilizados',
134
+ remainingPoints: 'Pontos restantes',
135
+ table: 'Mesa',
136
+ orderDiscount: 'Desconto do pedido',
137
+ manualDiscount: 'Desconto manual',
138
+ payProcessingFee: 'Taxa de processamento',
139
+ rounding: 'Arredondamento',
140
+ gross: 'Peso bruto',
141
+ tare: 'Tara'
90
142
  }
91
143
  };
92
144
  function buildSmallTicketData(params) {
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 4 | 6 | 5;
329
+ weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -339,7 +339,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
339
339
  * 获取当前的客户搜索条件
340
340
  * @returns 当前搜索条件
341
341
  */
342
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
342
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
343
343
  /**
344
344
  * 获取客户列表状态(包含滚动加载相关状态)
345
345
  * @returns 客户状态
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.10.19",
4
+ "version": "0.10.20",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",