@pisell/pisellos 2.3.94 → 2.3.96

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 (88) hide show
  1. package/dist/model/strategy/adapter/dataVariant/evaluator.js +13 -2
  2. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  3. package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
  4. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  5. package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
  6. package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
  7. package/dist/model/strategy/adapter/itemRule/type.js +19 -1
  8. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  9. package/dist/modules/Order/index.d.ts +20 -3
  10. package/dist/modules/Order/index.js +931 -508
  11. package/dist/modules/Order/salesNotes.d.ts +31 -0
  12. package/dist/modules/Order/salesNotes.js +492 -0
  13. package/dist/modules/Order/types.d.ts +91 -5
  14. package/dist/modules/Order/types.js +5 -0
  15. package/dist/modules/Order/utils.d.ts +12 -0
  16. package/dist/modules/Order/utils.js +75 -26
  17. package/dist/modules/ProductList/index.d.ts +2 -1
  18. package/dist/modules/ProductList/index.js +100 -20
  19. package/dist/modules/ProductList/types.d.ts +10 -0
  20. package/dist/modules/SalesSummary/index.js +6 -4
  21. package/dist/server/index.d.ts +6 -0
  22. package/dist/server/index.js +57 -11
  23. package/dist/server/modules/products/index.d.ts +2 -2
  24. package/dist/server/modules/products/index.js +10 -9
  25. package/dist/server/utils/product.d.ts +1 -1
  26. package/dist/server/utils/product.js +186 -22
  27. package/dist/server/utils/small-ticket.js +23 -2
  28. package/dist/solution/BaseSales/index.d.ts +9 -1
  29. package/dist/solution/BaseSales/index.js +894 -706
  30. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
  31. package/dist/solution/BookingByStep/index.d.ts +2 -2
  32. package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
  33. package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
  34. package/dist/solution/RegisterAndLogin/config.js +95 -40
  35. package/dist/solution/RegisterAndLogin/index.js +4 -1
  36. package/dist/solution/ScanOrder/index.d.ts +1 -0
  37. package/dist/solution/ScanOrder/index.js +31 -27
  38. package/dist/solution/ScanOrder/utils.d.ts +1 -0
  39. package/dist/solution/ScanOrder/utils.js +2 -0
  40. package/dist/solution/UnifiedBookingSales/index.d.ts +15 -2
  41. package/dist/solution/UnifiedBookingSales/index.js +751 -483
  42. package/dist/solution/UnifiedBookingSales/types.d.ts +14 -1
  43. package/dist/solution/VenueBooking/index.d.ts +1 -0
  44. package/dist/solution/VenueBooking/index.js +8 -4
  45. package/lib/model/strategy/adapter/dataVariant/evaluator.js +12 -2
  46. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  47. package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
  48. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  49. package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
  50. package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
  51. package/lib/model/strategy/adapter/itemRule/type.js +19 -1
  52. package/lib/modules/Order/index.d.ts +20 -3
  53. package/lib/modules/Order/index.js +358 -42
  54. package/lib/modules/Order/salesNotes.d.ts +31 -0
  55. package/lib/modules/Order/salesNotes.js +382 -0
  56. package/lib/modules/Order/types.d.ts +91 -5
  57. package/lib/modules/Order/types.js +4 -0
  58. package/lib/modules/Order/utils.d.ts +12 -0
  59. package/lib/modules/Order/utils.js +68 -16
  60. package/lib/modules/ProductList/index.d.ts +2 -1
  61. package/lib/modules/ProductList/index.js +47 -2
  62. package/lib/modules/ProductList/types.d.ts +10 -0
  63. package/lib/modules/SalesSummary/index.js +3 -1
  64. package/lib/server/index.d.ts +6 -0
  65. package/lib/server/index.js +47 -9
  66. package/lib/server/modules/products/index.d.ts +2 -2
  67. package/lib/server/modules/products/index.js +5 -4
  68. package/lib/server/utils/product.d.ts +1 -1
  69. package/lib/server/utils/product.js +163 -3
  70. package/lib/server/utils/small-ticket.js +22 -1
  71. package/lib/solution/BaseSales/index.d.ts +9 -1
  72. package/lib/solution/BaseSales/index.js +105 -1
  73. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
  74. package/lib/solution/BookingByStep/index.d.ts +2 -2
  75. package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
  76. package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
  77. package/lib/solution/RegisterAndLogin/config.js +49 -8
  78. package/lib/solution/RegisterAndLogin/index.js +4 -1
  79. package/lib/solution/ScanOrder/index.d.ts +1 -0
  80. package/lib/solution/ScanOrder/index.js +5 -1
  81. package/lib/solution/ScanOrder/utils.d.ts +1 -0
  82. package/lib/solution/ScanOrder/utils.js +1 -0
  83. package/lib/solution/UnifiedBookingSales/index.d.ts +15 -2
  84. package/lib/solution/UnifiedBookingSales/index.js +125 -1
  85. package/lib/solution/UnifiedBookingSales/types.d.ts +14 -1
  86. package/lib/solution/VenueBooking/index.d.ts +1 -0
  87. package/lib/solution/VenueBooking/index.js +5 -1
  88. package/package.json +1 -1
@@ -61,7 +61,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
61
61
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
62
62
  // LoggerManager 实例
63
63
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
64
- // 商品价格缓存:Map<日期, 应用了价格的商品列表>
64
+ // 商品格式化缓存:Map<查询上下文 key, 已应用价格与多语言的商品列表>
65
65
  _defineProperty(_assertThisInitialized(_this), "productsPriceCache", new Map());
66
66
  // 缓存配置
67
67
  _defineProperty(_assertThisInitialized(_this), "CACHE_MAX_DAYS", 7);
@@ -585,8 +585,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
585
585
 
586
586
  /**
587
587
  * 获取应用了价格的商品列表(带缓存)
588
- * 使用日期作为缓存 key,同一天的商品价格会被缓存
589
- * 缓存的是已经应用了价格的完整商品列表,避免重复转换
588
+ * 使用时间、客户、策略、商品范围和语言作为缓存 key
589
+ * 缓存的是已经应用了价格与多语言的完整商品列表,避免重复转换
590
590
  * @param schedule_date 日期
591
591
  * @param extraContext 额外的上下文数据(可选,由 Server 层传入)
592
592
  * @param options 可选参数
@@ -877,11 +877,12 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
877
877
  }, {
878
878
  key: "getProductsPriceCacheKey",
879
879
  value: function getProductsPriceCacheKey(schedule_date, extraContext, productIds) {
880
- var _extraContext$custome;
880
+ var _ref13, _extraContext$locale, _this$core3, _extraContext$custome;
881
881
  var datetime = (extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime) || schedule_date;
882
+ var locale = (_ref13 = (_extraContext$locale = extraContext === null || extraContext === void 0 ? void 0 : extraContext.locale) !== null && _extraContext$locale !== void 0 ? _extraContext$locale : (_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.locale) !== null && _ref13 !== void 0 ? _ref13 : '';
882
883
  var productScope = productIds ? ":products:".concat(productIds.join(',')) : '';
883
884
  var strategyScope = this.stringifyStable((extraContext === null || extraContext === void 0 ? void 0 : extraContext.strategy_context) || {});
884
- return "".concat(datetime, ":customer:").concat((_extraContext$custome = extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id) !== null && _extraContext$custome !== void 0 ? _extraContext$custome : '', ":strategy:").concat(strategyScope).concat(productScope);
885
+ return "".concat(datetime, ":locale:").concat(locale, ":customer:").concat((_extraContext$custome = extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id) !== null && _extraContext$custome !== void 0 ? _extraContext$custome : '') + ":strategy:".concat(strategyScope).concat(productScope);
885
886
  }
886
887
 
887
888
  /**
@@ -1119,8 +1120,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1119
1120
  }, {
1120
1121
  key: "shouldEnableLegacyPriceFormatter",
1121
1122
  value: function shouldEnableLegacyPriceFormatter() {
1122
- var _this$otherParams3, _this$core3;
1123
- return ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.enableLegacyPriceFormatter) === true || ((_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.enableLegacyPriceFormatter) === true;
1123
+ var _this$otherParams3, _this$core4;
1124
+ return ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.enableLegacyPriceFormatter) === true || ((_this$core4 = this.core) === null || _this$core4 === void 0 || (_this$core4 = _this$core4.context) === null || _this$core4 === void 0 ? void 0 : _this$core4.enableLegacyPriceFormatter) === true;
1124
1125
  }
1125
1126
 
1126
1127
  /**
@@ -1300,11 +1301,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1300
1301
  key: "fetchProductsByHttp",
1301
1302
  value: (function () {
1302
1303
  var _fetchProductsByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
1303
- var _ref13, _ref13$category_ids, category_ids, _ref13$product_ids, product_ids, _ref13$collection, collection, customer_id, cacheId, startTime, _this$otherParams4, _productsData$data, productsData, productList, duration, _duration2, errorMessage;
1304
+ var _ref14, _ref14$category_ids, category_ids, _ref14$product_ids, product_ids, _ref14$collection, collection, customer_id, cacheId, startTime, _this$otherParams4, _productsData$data, productsData, productList, duration, _duration2, errorMessage;
1304
1305
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1305
1306
  while (1) switch (_context10.prev = _context10.next) {
1306
1307
  case 0:
1307
- _ref13 = params || {}, _ref13$category_ids = _ref13.category_ids, category_ids = _ref13$category_ids === void 0 ? [] : _ref13$category_ids, _ref13$product_ids = _ref13.product_ids, product_ids = _ref13$product_ids === void 0 ? [] : _ref13$product_ids, _ref13$collection = _ref13.collection, collection = _ref13$collection === void 0 ? [] : _ref13$collection, customer_id = _ref13.customer_id, cacheId = _ref13.cacheId;
1308
+ _ref14 = params || {}, _ref14$category_ids = _ref14.category_ids, category_ids = _ref14$category_ids === void 0 ? [] : _ref14$category_ids, _ref14$product_ids = _ref14.product_ids, product_ids = _ref14$product_ids === void 0 ? [] : _ref14$product_ids, _ref14$collection = _ref14.collection, collection = _ref14$collection === void 0 ? [] : _ref14$collection, customer_id = _ref14.customer_id, cacheId = _ref14.cacheId;
1308
1309
  this.logInfo('fetchProductsByHttp: 开始请求', {
1309
1310
  categoryIdsCount: category_ids.length,
1310
1311
  productIdsCount: product_ids.length,
@@ -11,7 +11,7 @@ export declare function perfMark(label: string, durationMs: number, meta?: Recor
11
11
  export declare function applyPriceDataToProducts(products: ProductData[], priceData: LoadProductsPriceData[]): ProductData[];
12
12
  export declare const getIsSessionProduct: (product: ProductData) => boolean;
13
13
  /**
14
- * 根据 locale 将商品的 i18n 字段覆盖到对应原始字段
14
+ * 根据 locale 格式化商品、分类、规格及套餐文案,缺少对应语言时回退 original。
15
15
  */
16
16
  export declare function applyI18nToProducts(products: ProductData[], locale?: string): ProductData[];
17
17
  /**
@@ -1,4 +1,3 @@
1
- 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); }
2
1
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
3
  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."); }
@@ -6,6 +5,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
6
5
  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; }
7
6
  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; } }
8
7
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ 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); }
9
9
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
10
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
11
  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; }
@@ -195,9 +195,120 @@ var I18N_FIELD_MAP = {
195
195
  description_i18n: 'description',
196
196
  cover_i18n: 'cover'
197
197
  };
198
+ /**
199
+ * 按当前语言读取 i18n 文案;当前语言为空时回退到商家原始文案。
200
+ */
201
+ function resolveI18nValue(i18nDict, locale) {
202
+ if (!i18nDict) return undefined;
203
+ return i18nDict[locale] || i18nDict.original || undefined;
204
+ }
205
+
206
+ /**
207
+ * 递归格式化商品分类名称,同时保留未变化节点的引用。
208
+ */
209
+ function applyI18nToCategory(category, locale) {
210
+ if (!category || _typeof(category) !== 'object') return category;
211
+ var localizedName = resolveI18nValue(category.name_i18n, locale);
212
+ var localizedParent = applyI18nToCategory(category.parent_category, locale);
213
+ var nameChanged = localizedName !== undefined && localizedName !== category.name;
214
+ var parentChanged = localizedParent !== category.parent_category;
215
+ if (!nameChanged && !parentChanged) return category;
216
+ return _objectSpread(_objectSpread(_objectSpread({}, category), nameChanged ? {
217
+ name: localizedName
218
+ } : {}), parentChanged ? {
219
+ parent_category: localizedParent
220
+ } : {});
221
+ }
222
+ function applyI18nToCategories(categories, locale) {
223
+ if (!Array.isArray(categories)) return categories;
224
+ var changed = false;
225
+ var localizedCategories = categories.map(function (category) {
226
+ var localizedCategory = applyI18nToCategory(category, locale);
227
+ if (localizedCategory !== category) changed = true;
228
+ return localizedCategory;
229
+ });
230
+ return changed ? localizedCategories : categories;
231
+ }
232
+ function applyI18nToNamedItems(items, locale) {
233
+ if (!Array.isArray(items)) return items;
234
+ var changed = false;
235
+ var localizedItems = items.map(function (item) {
236
+ if (!item || _typeof(item) !== 'object') return item;
237
+ var localizedName = resolveI18nValue(item.name_i18n, locale);
238
+ if (localizedName === undefined || localizedName === item.name) return item;
239
+ changed = true;
240
+ return _objectSpread(_objectSpread({}, item), {}, {
241
+ name: localizedName
242
+ });
243
+ });
244
+ return changed ? localizedItems : items;
245
+ }
246
+
247
+ /**
248
+ * 格式化选项组、规格组及其子项名称,同时保留未变化节点的引用。
249
+ */
250
+ function applyI18nToNamedGroups(groups, itemKey, locale) {
251
+ if (!Array.isArray(groups)) return groups;
252
+ var changed = false;
253
+ var localizedGroups = groups.map(function (group) {
254
+ if (!group || _typeof(group) !== 'object') return group;
255
+ var localizedName = resolveI18nValue(group.name_i18n, locale);
256
+ var localizedItems = applyI18nToNamedItems(group[itemKey], locale);
257
+ var nameChanged = localizedName !== undefined && localizedName !== group.name;
258
+ var itemsChanged = localizedItems !== group[itemKey];
259
+ if (!nameChanged && !itemsChanged) return group;
260
+ changed = true;
261
+ return _objectSpread(_objectSpread(_objectSpread({}, group), nameChanged ? {
262
+ name: localizedName
263
+ } : {}), itemsChanged ? _defineProperty({}, itemKey, localizedItems) : {});
264
+ });
265
+ return changed ? localizedGroups : groups;
266
+ }
267
+ function applyI18nToBundleItems(items, locale) {
268
+ if (!Array.isArray(items)) return items;
269
+ var changed = false;
270
+ var localizedItems = items.map(function (item) {
271
+ if (!item || _typeof(item) !== 'object') return item;
272
+ var localizedTitle = resolveI18nValue(item.trans_title, locale);
273
+ var localizedOptionGroups = applyI18nToNamedGroups(item.option_group, 'option_item', locale);
274
+ var titleChanged = localizedTitle !== undefined && localizedTitle !== item.title;
275
+ var optionGroupsChanged = localizedOptionGroups !== item.option_group;
276
+ if (!titleChanged && !optionGroupsChanged) return item;
277
+ changed = true;
278
+ return _objectSpread(_objectSpread(_objectSpread({}, item), titleChanged ? {
279
+ title: localizedTitle
280
+ } : {}), optionGroupsChanged ? {
281
+ option_group: localizedOptionGroups
282
+ } : {});
283
+ });
284
+ return changed ? localizedItems : items;
285
+ }
198
286
 
199
287
  /**
200
- * 根据 locale 将商品的 i18n 字段覆盖到对应原始字段
288
+ * 格式化套餐组名称、套餐子商品标题及子商品选项,同时保留未变化节点的引用。
289
+ */
290
+ function applyI18nToBundleGroups(groups, locale) {
291
+ if (!Array.isArray(groups)) return groups;
292
+ var changed = false;
293
+ var localizedGroups = groups.map(function (group) {
294
+ if (!group || _typeof(group) !== 'object') return group;
295
+ var localizedName = resolveI18nValue(group.name_i18n, locale);
296
+ var localizedItems = applyI18nToBundleItems(group.bundle_item, locale);
297
+ var nameChanged = localizedName !== undefined && localizedName !== group.name;
298
+ var itemsChanged = localizedItems !== group.bundle_item;
299
+ if (!nameChanged && !itemsChanged) return group;
300
+ changed = true;
301
+ return _objectSpread(_objectSpread(_objectSpread({}, group), nameChanged ? {
302
+ name: localizedName
303
+ } : {}), itemsChanged ? {
304
+ bundle_item: localizedItems
305
+ } : {});
306
+ });
307
+ return changed ? localizedGroups : groups;
308
+ }
309
+
310
+ /**
311
+ * 根据 locale 格式化商品、分类、规格及套餐文案,缺少对应语言时回退 original。
201
312
  */
202
313
  export function applyI18nToProducts(products, locale) {
203
314
  if (!locale) return products;
@@ -210,12 +321,65 @@ export function applyI18nToProducts(products, locale) {
210
321
  originalKey = _Object$entries$_i[1];
211
322
  var i18nDict = product[i18nKey];
212
323
  if (!i18nDict) continue;
213
- var localizedValue = i18nDict[locale];
214
- if (localizedValue) {
324
+ var localizedValue = resolveI18nValue(i18nDict, locale);
325
+ if (localizedValue !== undefined && localizedValue !== product[originalKey]) {
215
326
  if (!patched) patched = _objectSpread({}, product);
216
327
  patched[originalKey] = localizedValue;
217
328
  }
218
329
  }
330
+ var _iterator = _createForOfIteratorHelper(['category', 'categories']),
331
+ _step;
332
+ try {
333
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
334
+ var categoryKey = _step.value;
335
+ var categories = product[categoryKey];
336
+ var localizedCategories = applyI18nToCategories(categories, locale);
337
+ if (localizedCategories !== categories) {
338
+ if (!patched) patched = _objectSpread({}, product);
339
+ patched[categoryKey] = localizedCategories;
340
+ }
341
+ }
342
+ } catch (err) {
343
+ _iterator.e(err);
344
+ } finally {
345
+ _iterator.f();
346
+ }
347
+ var _iterator2 = _createForOfIteratorHelper([['option_group', 'option_item'], ['variant_group', 'variant_item']]),
348
+ _step2;
349
+ try {
350
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
351
+ var _step2$value = _slicedToArray(_step2.value, 2),
352
+ groupKey = _step2$value[0],
353
+ itemKey = _step2$value[1];
354
+ var groups = product[groupKey];
355
+ var localizedGroups = applyI18nToNamedGroups(groups, itemKey, locale);
356
+ if (localizedGroups !== groups) {
357
+ if (!patched) patched = _objectSpread({}, product);
358
+ patched[groupKey] = localizedGroups;
359
+ }
360
+ }
361
+ } catch (err) {
362
+ _iterator2.e(err);
363
+ } finally {
364
+ _iterator2.f();
365
+ }
366
+ var _iterator3 = _createForOfIteratorHelper(['bundle_group', 'bundle_groups']),
367
+ _step3;
368
+ try {
369
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
370
+ var bundleGroupKey = _step3.value;
371
+ var _groups = product[bundleGroupKey];
372
+ var _localizedGroups = applyI18nToBundleGroups(_groups, locale);
373
+ if (_localizedGroups !== _groups) {
374
+ if (!patched) patched = _objectSpread({}, product);
375
+ patched[bundleGroupKey] = _localizedGroups;
376
+ }
377
+ }
378
+ } catch (err) {
379
+ _iterator3.e(err);
380
+ } finally {
381
+ _iterator3.f();
382
+ }
219
383
  return (_patched = patched) !== null && _patched !== void 0 ? _patched : product;
220
384
  });
221
385
  }
@@ -234,54 +398,54 @@ var formatDataKey = function formatDataKey(data) {
234
398
 
235
399
  // 单规格
236
400
  if (_data !== null && _data !== void 0 && (_data$option = _data.option) !== null && _data$option !== void 0 && _data$option.length) {
237
- var _iterator = _createForOfIteratorHelper(_data.option),
238
- _step;
401
+ var _iterator4 = _createForOfIteratorHelper(_data.option),
402
+ _step4;
239
403
  try {
240
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
241
- var item = _step.value;
404
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
405
+ var item = _step4.value;
242
406
  var _str = "_".concat(item.option_group_id, "_").concat(item.option_group_item_id);
243
407
  key += _str;
244
408
  rowKey += "".concat(_str, "_").concat(item.quantity || item.num);
245
409
  }
246
410
  } catch (err) {
247
- _iterator.e(err);
411
+ _iterator4.e(err);
248
412
  } finally {
249
- _iterator.f();
413
+ _iterator4.f();
250
414
  }
251
415
  }
252
416
 
253
417
  // 套餐
254
418
  if (_data !== null && _data !== void 0 && (_data$bundle = _data.bundle) !== null && _data$bundle !== void 0 && _data$bundle.length) {
255
- var _iterator2 = _createForOfIteratorHelper(_data.bundle),
256
- _step2;
419
+ var _iterator5 = _createForOfIteratorHelper(_data.bundle),
420
+ _step5;
257
421
  try {
258
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
259
- var _item = _step2.value;
422
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
423
+ var _item = _step5.value;
260
424
  var _str2 = "_".concat(_item.group_id, "_").concat(_item.bundle_product_id);
261
425
  key += _str2;
262
426
  rowKey += "".concat(_str2, "_").concat(_item.quantity || _item.num);
263
427
  // 如果有单规格
264
428
  if (_item !== null && _item !== void 0 && _item.option) {
265
- var _iterator3 = _createForOfIteratorHelper(_item.option),
266
- _step3;
429
+ var _iterator6 = _createForOfIteratorHelper(_item.option),
430
+ _step6;
267
431
  try {
268
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
269
- var opt = _step3.value;
432
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
433
+ var opt = _step6.value;
270
434
  var _str3 = "_".concat(opt.option_group_id, "_").concat(opt.option_group_item_id);
271
435
  key += _str3;
272
436
  rowKey += "".concat(_str3, "_").concat(opt.quantity || opt.num);
273
437
  }
274
438
  } catch (err) {
275
- _iterator3.e(err);
439
+ _iterator6.e(err);
276
440
  } finally {
277
- _iterator3.f();
441
+ _iterator6.f();
278
442
  }
279
443
  }
280
444
  }
281
445
  } catch (err) {
282
- _iterator2.e(err);
446
+ _iterator5.e(err);
283
447
  } finally {
284
- _iterator2.f();
448
+ _iterator5.f();
285
449
  }
286
450
  }
287
451
 
@@ -40,6 +40,7 @@ var LABELS = {
40
40
  orderDiscount: 'Order discount',
41
41
  manualDiscount: 'Manual discount',
42
42
  payProcessingFee: 'Pay processing fee',
43
+ surchargeIncluded: 'Surcharge(Included)',
43
44
  rounding: 'Rounding',
44
45
  gross: 'Gross',
45
46
  tare: 'Tare'
@@ -66,6 +67,7 @@ var LABELS = {
66
67
  orderDiscount: '整单折扣',
67
68
  manualDiscount: '手动折扣',
68
69
  payProcessingFee: '支付手续费',
70
+ surchargeIncluded: '手续费(已含)',
69
71
  rounding: '抹零',
70
72
  gross: '重量',
71
73
  tare: '去皮'
@@ -92,6 +94,7 @@ var LABELS = {
92
94
  orderDiscount: '整單折扣',
93
95
  manualDiscount: '手動折扣',
94
96
  payProcessingFee: '支付手續費',
97
+ surchargeIncluded: '手續費(已含)',
95
98
  rounding: '抹零',
96
99
  gross: '重量',
97
100
  tare: '去皮'
@@ -760,11 +763,17 @@ function buildPaymentData(params) {
760
763
  return payments.filter(function (payment) {
761
764
  return isPrintablePayment(payment);
762
765
  }).map(function (payment) {
763
- var _payment$amount;
766
+ var serviceFee = getPaymentServiceFee(payment);
764
767
  var items = [{
765
768
  item: paymentMethodName(payment, params.locale),
766
- value: formatMoney((_payment$amount = payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment.origin_amount, params.currencySymbol)
769
+ value: formatMoney(resolveReceiptPaymentAmount(payment, serviceFee), params.currencySymbol)
767
770
  }];
771
+ if (serviceFee.gt(0)) {
772
+ items.push({
773
+ item: label(params.locale, 'surchargeIncluded'),
774
+ value: formatMoney(serviceFee, params.currencySymbol)
775
+ });
776
+ }
768
777
  var fundRecord = getFundRecord(payment);
769
778
  if (fundRecord) {
770
779
  items.push.apply(items, _toConsumableArray(buildFundRecordPaymentItems({
@@ -790,6 +799,18 @@ function buildPaymentData(params) {
790
799
  return items;
791
800
  });
792
801
  }
802
+ function getPaymentServiceFee(payment) {
803
+ return new Decimal(toMoneyNumber(payment.service_fee));
804
+ }
805
+ function resolveReceiptPaymentAmount(payment, serviceFee) {
806
+ var _payment$amount;
807
+ var amount = new Decimal(toMoneyNumber((_payment$amount = payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment.origin_amount));
808
+ var hasAmount = payment.amount !== undefined && payment.amount !== null && payment.amount !== '';
809
+ var hasOriginAmount = payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '';
810
+ if (!hasAmount || !hasOriginAmount || serviceFee.lte(0)) return amount;
811
+ var originAmount = new Decimal(toMoneyNumber(payment.origin_amount));
812
+ return amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
813
+ }
793
814
  function buildFundRecordPaymentItems(params) {
794
815
  var payment = params.payment,
795
816
  fundRecord = params.fundRecord,
@@ -2,7 +2,7 @@ import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
4
4
  import { OrderModule } from '../../modules/Order';
5
- import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, ReplaceTempOrderOptions } from '../../modules/Order/types';
5
+ import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, ReplaceTempOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } from '../../modules/Order/types';
6
6
  import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
7
7
  import type { Discount } from '../../modules/Discount/types';
8
8
  import { RequestPlugin, WindowPlugin } from '../../plugins';
@@ -225,12 +225,20 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
225
225
  getOrderSyncState(): import("../../modules/Order/types").OrderSyncState;
226
226
  getOrderAmountSnapshot(): import("../../modules/Order/types").OrderAmountSnapshot | null;
227
227
  getTempOrderNote(): string;
228
+ getSalesNotes(): SalesNote[];
229
+ createSalesNotesMutationSnapshot(): SalesNotesMutationSnapshot;
230
+ restoreSalesNotesMutationSnapshot(snapshot: SalesNotesMutationSnapshot): void;
231
+ setSalesNote(input: SetSalesNoteInput): Promise<SalesNote>;
232
+ removeSalesNote(uuid: string): Promise<void>;
233
+ clearSalesNotes(): Promise<void>;
228
234
  updateTempOrderNote(note: string): string;
229
235
  updateTempOrderNote(note: string, sync: true): Promise<string>;
230
236
  updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
231
237
  updateRemoteOrderNote(orderId: number | string, note: string): void;
232
238
  updateTempOrderShopDiscount(amount: string | number): string;
233
239
  updateTempOrderDepositAmount(amount: string | number): OrderSummary;
240
+ setPickupReferenceMode(mode: PickupReferenceMode): ShopServiceData;
241
+ setServiceType(serviceType: ShopServiceType): ShopServiceData;
234
242
  updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
235
243
  /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
236
244
  setEnableTempOrderPersist(enabled: boolean): void;