@pisell/pisellos 2.2.187 → 2.2.189

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 (43) hide show
  1. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -4
  2. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +11 -4
  3. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  4. package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
  5. package/dist/modules/Order/index.d.ts +5 -0
  6. package/dist/modules/Order/index.js +174 -70
  7. package/dist/modules/Order/types.d.ts +1 -0
  8. package/dist/modules/Order/utils.js +3 -1
  9. package/dist/modules/Rules/index.js +32 -21
  10. package/dist/solution/BaseSales/utils/cartPromotion.js +31 -11
  11. package/dist/solution/BookingByStep/index.d.ts +1 -1
  12. package/dist/solution/BookingTicket/index.d.ts +15 -0
  13. package/dist/solution/BookingTicket/index.js +135 -10
  14. package/dist/solution/BookingTicket/types.d.ts +48 -0
  15. package/dist/solution/BookingTicket/types.js +5 -1
  16. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  17. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +394 -0
  18. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  19. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
  20. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  21. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
  22. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  23. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -1
  24. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +4 -0
  25. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  26. package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
  27. package/lib/modules/Order/index.d.ts +5 -0
  28. package/lib/modules/Order/index.js +99 -14
  29. package/lib/modules/Order/types.d.ts +1 -0
  30. package/lib/modules/Order/utils.js +1 -0
  31. package/lib/modules/Rules/index.js +88 -78
  32. package/lib/solution/BaseSales/utils/cartPromotion.js +22 -1
  33. package/lib/solution/BookingByStep/index.d.ts +1 -1
  34. package/lib/solution/BookingTicket/index.d.ts +15 -0
  35. package/lib/solution/BookingTicket/index.js +75 -2
  36. package/lib/solution/BookingTicket/types.d.ts +48 -0
  37. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  38. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +166 -0
  39. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  40. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
  41. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  42. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
  43. package/package.json +1 -1
@@ -16,6 +16,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
16
16
  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); }
17
17
  import dayjs from 'dayjs';
18
18
  import { resolveManualDiscountMessage } from "../../Order/utils/manualProductDiscount";
19
+ import { buildProductOptionStringFromOrderLine } from "./orderLineDisplay";
19
20
  function safeFormat(value, fmt) {
20
21
  if (value === undefined || value === null) return undefined;
21
22
  var d = dayjs(value);
@@ -188,12 +189,13 @@ export function buildCacheItemFromOrderLine(input) {
188
189
  var capacity = resolveCapacityFromBooking(booking);
189
190
  var holderId = (_booking$metadata$hol = (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.holder_id) !== null && _booking$metadata$hol !== void 0 ? _booking$metadata$hol : booking.holder_id;
190
191
  var productTitle = resolveProductTitle(product, booking, sourceProduct);
192
+ var productOptionString = buildProductOptionStringFromOrderLine(product);
191
193
  var other = {
192
194
  product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
193
195
  option: Array.isArray(product.product_option_item) ? _toConsumableArray(product.product_option_item) : [],
194
196
  bundle: Array.isArray(product.product_bundle) ? _toConsumableArray(product.product_bundle) : []
195
197
  };
196
- var extend = {
198
+ var extend = _objectSpread({
197
199
  start_date: startDate ? dayjs(startDate) : undefined,
198
200
  end_date: endDate ? dayjs(endDate) : undefined,
199
201
  startDate: startDate ? dayjs(startDate) : undefined,
@@ -214,7 +216,9 @@ export function buildCacheItemFromOrderLine(input) {
214
216
  other: other,
215
217
  like_status: booking.like_status || 'common',
216
218
  discount_reason: resolveManualDiscountMessage(product.discount_list, (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.product_discount_reason) || undefined
217
- };
219
+ }, productOptionString ? {
220
+ product_option_string: productOptionString
221
+ } : {});
218
222
  var manualDiscount = (product.discount_list || []).find(function (d) {
219
223
  return (d === null || d === void 0 ? void 0 : d.type) === 'product';
220
224
  });
@@ -234,14 +238,17 @@ export function buildCacheItemFromOrderLine(input) {
234
238
  if (Array.isArray(booking.relation_forms)) {
235
239
  extend.relation_forms = booking.relation_forms;
236
240
  }
237
- var base = _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
241
+ var base = _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
238
242
  id: resolvedId,
239
243
  product_id: resolvedId,
240
244
  extension_type: (_ref9 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref9 !== void 0 ? _ref9 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
241
245
  title: productTitle || (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || (booking === null || booking === void 0 || (_booking$product3 = booking.product) === null || _booking$product3 === void 0 ? void 0 : _booking$product3.title),
242
246
  price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
243
247
  selling_price: product.selling_price,
244
- original_price: product.original_price,
248
+ original_price: product.original_price
249
+ }, productOptionString ? {
250
+ product_option_string: productOptionString
251
+ } : {}), {}, {
245
252
  _extend: extend,
246
253
  new: 0,
247
254
  autoClose: false,
@@ -13,6 +13,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
13
13
  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); }
14
14
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
15
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
+ import { buildProductOptionStringFromOrderLine } from "./orderLineDisplay";
16
17
  /**
17
18
  * 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
18
19
  *
@@ -86,6 +87,7 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
86
87
  var option = Array.isArray(product.product_option_item) ? _toConsumableArray(product.product_option_item) : [];
87
88
  var bundle = mapOrderBundleToOtherBundle(Array.isArray(product.product_bundle) ? product.product_bundle : []);
88
89
  var originExtend = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 || (_product$metadata2 = _product$metadata2.origin) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2._extend;
90
+ var productOptionString = buildProductOptionStringFromOrderLine(product);
89
91
  var other = {
90
92
  product_id: resolvedId,
91
93
  product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
@@ -99,7 +101,7 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
99
101
  option: other.option,
100
102
  bundle: other.bundle
101
103
  };
102
- var extend = _objectSpread(_objectSpread({
104
+ var extend = _objectSpread(_objectSpread(_objectSpread({
103
105
  quantity: (_product$num2 = product.num) !== null && _product$num2 !== void 0 ? _product$num2 : 1,
104
106
  product_name: (_title = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title !== void 0 ? _title : '',
105
107
  note: (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : '',
@@ -111,7 +113,9 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
111
113
  skuValue: JSON.parse(JSON.stringify(skuValue)),
112
114
  _skuValue: JSON.parse(JSON.stringify(skuValue)),
113
115
  isNormalProduct: true
114
- }, (originExtend === null || originExtend === void 0 ? void 0 : originExtend.priceOverride) !== undefined ? {
116
+ }, productOptionString ? {
117
+ product_option_string: productOptionString
118
+ } : {}), (originExtend === null || originExtend === void 0 ? void 0 : originExtend.priceOverride) !== undefined ? {
115
119
  priceOverride: originExtend.priceOverride
116
120
  } : {}), (originExtend === null || originExtend === void 0 ? void 0 : originExtend.bundle_edit) !== undefined ? {
117
121
  bundle_edit: originExtend.bundle_edit
@@ -120,14 +124,17 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
120
124
  extend.skuValue = JSON.parse(JSON.stringify(originExtend.skuValue || originExtend._skuValue));
121
125
  extend._skuValue = JSON.parse(JSON.stringify(extend.skuValue));
122
126
  }
123
- return _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
127
+ return _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
124
128
  id: resolvedId,
125
129
  product_id: resolvedId,
126
130
  _id: uid,
127
131
  title: sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title,
128
132
  price: (_price3 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price3 !== void 0 ? _price3 : sourcePrice,
129
133
  selling_price: product.selling_price,
130
- original_price: product.original_price,
134
+ original_price: product.original_price
135
+ }, productOptionString ? {
136
+ product_option_string: productOptionString
137
+ } : {}), {}, {
131
138
  note: product.note,
132
139
  order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
133
140
  new: 0,
@@ -0,0 +1 @@
1
+ export declare function buildProductOptionStringFromOrderLine(product: any): string;
@@ -0,0 +1,36 @@
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; } } }; }
2
+ 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); }
3
+ 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; }
4
+ 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); }
5
+ function pickDisplayText(value) {
6
+ if (value === undefined || value === null) return '';
7
+ if (typeof value === 'string') return value;
8
+ if (_typeof(value) !== 'object') return String(value);
9
+ return value.auto || value.original || value.en || value['zh-CN'] || value['zh-HK'] || '';
10
+ }
11
+ function formatNamePair(group, item) {
12
+ var groupText = pickDisplayText(group);
13
+ var itemText = pickDisplayText(item);
14
+ if (groupText && itemText) return "".concat(groupText, ":").concat(itemText);
15
+ return groupText || itemText;
16
+ }
17
+ export function buildProductOptionStringFromOrderLine(product) {
18
+ var segments = [];
19
+ var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
20
+ if (Array.isArray(sku.variant)) {
21
+ var _iterator = _createForOfIteratorHelper(sku.variant),
22
+ _step;
23
+ try {
24
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
25
+ var variant = _step.value;
26
+ var segment = formatNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
27
+ if (segment) segments.push(segment);
28
+ }
29
+ } catch (err) {
30
+ _iterator.e(err);
31
+ } finally {
32
+ _iterator.f();
33
+ }
34
+ }
35
+ return segments.join(', ');
36
+ }
@@ -143,6 +143,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
143
143
  private saveDraftInBackground;
144
144
  private hydrateTempOrderFromLocalRecord;
145
145
  private extractOrderIdFromSubmitResult;
146
+ private calculatePaymentEffectiveAmount;
146
147
  private calculatePaymentTotal;
147
148
  private normalizePaymentSource;
148
149
  private updateTempOrderPaymentStatus;
@@ -312,7 +313,11 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
312
313
  recalcOnHydrate?: boolean;
313
314
  }): Promise<OrderTempOrder>;
314
315
  private normalizeTempOrderForRuntime;
316
+ private pickHydratedDisplayText;
317
+ private formatHydratedNamePair;
318
+ private buildHydratedProductOptionString;
315
319
  private normalizeHydratedProductOptionItem;
320
+ private mergeHydratedProductOptionDisplayFields;
316
321
  private resolveHydratedProductOptions;
317
322
  private normalizeHydratedOrderProduct;
318
323
  getLastOrderInfo(): Record<string, any> | undefined;