@pisell/pisellos 2.2.246 → 2.2.247

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.
@@ -34,6 +34,7 @@ export interface OrderPromotionEvaluator {
34
34
  products: any[];
35
35
  channel?: string;
36
36
  }, matchVariant?: boolean): any[];
37
+ getStrategyConfigs?: () => unknown[];
37
38
  }
38
39
  /** 赠品解析回调 context(OS → SDK 的请求体) */
39
40
  export interface OrderGiftSelectContext {
@@ -283,7 +283,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
283
283
  filter_prepare_wallet_pass: 1
284
284
  }); // 并行获取用户识别码列表和订单详情
285
285
  _context3.next = 4;
286
- return Promise.all([this.getUserIdentificationCodeListAsync(identificationParams), baseParams.payment_order_id ? this.getOrderBasicDetailAsync(baseParams.payment_order_id) : Promise.resolve(null)]);
286
+ return Promise.all([this.getUserIdentificationCodeListAsync(identificationParams), baseParams.payment_order_id && typeof baseParams.payment_order_id === 'string' && !baseParams.payment_order_id.startsWith('LOCAL_') ? this.getOrderBasicDetailAsync(baseParams.payment_order_id) : Promise.resolve(null)]);
287
287
  case 4:
288
288
  _yield$Promise$all = _context3.sent;
289
289
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
@@ -35,6 +35,7 @@ export interface SmallTicketProduct {
35
35
  original_price: string;
36
36
  total_original_price: string;
37
37
  extension_list: any[];
38
+ discount_list?: any[];
38
39
  options?: Array<{
39
40
  name: string;
40
41
  num?: number;
@@ -38,6 +38,7 @@ var LABELS = {
38
38
  remainingPoints: 'Remaining points',
39
39
  table: 'Table',
40
40
  orderDiscount: 'Order discount',
41
+ manualDiscount: 'Manual discount',
41
42
  payProcessingFee: 'Pay processing fee',
42
43
  rounding: 'Rounding'
43
44
  },
@@ -61,6 +62,7 @@ var LABELS = {
61
62
  remainingPoints: '剩余积分',
62
63
  table: '桌台',
63
64
  orderDiscount: '整单折扣',
65
+ manualDiscount: '手动折扣',
64
66
  payProcessingFee: '支付手续费',
65
67
  rounding: '抹零'
66
68
  },
@@ -84,6 +86,7 @@ var LABELS = {
84
86
  remainingPoints: '剩餘積分',
85
87
  table: '桌台',
86
88
  orderDiscount: '整單折扣',
89
+ manualDiscount: '手動折扣',
87
90
  payProcessingFee: '支付手續費',
88
91
  rounding: '抹零'
89
92
  }
@@ -197,14 +200,21 @@ function buildProducts(order, locale, productMap) {
197
200
  parentProduct: parentProduct,
198
201
  locale: locale
199
202
  });
200
- return _objectSpread(_objectSpread(_objectSpread({
203
+ var discountList = normalizeProductDiscounts({
204
+ product: product,
205
+ locale: locale,
206
+ currencySymbol: currencySymbol
207
+ });
208
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({
201
209
  product_title: productTitle,
202
210
  product_quantity: quantity,
203
211
  selling_price: formatMoney(sellingPrice, currencySymbol),
204
212
  original_price: formatMoney(originalPrice, currencySymbol),
205
213
  total_original_price: formatMoney(new Decimal(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
206
214
  extension_list: Array.isArray(product.extension_list) ? product.extension_list : []
207
- }, options.length ? {
215
+ }, discountList.length ? {
216
+ discount_list: discountList
217
+ } : {}), options.length ? {
208
218
  options: options
209
219
  } : {}), resolvedVariant ? {
210
220
  variant: resolvedVariant
@@ -215,6 +225,30 @@ function buildProducts(order, locale, productMap) {
215
225
  } : {});
216
226
  });
217
227
  }
228
+ function normalizeProductDiscounts(params) {
229
+ var product = params.product,
230
+ locale = params.locale,
231
+ currencySymbol = params.currencySymbol;
232
+ return normalizeArray(product.discount_list).map(function (discount) {
233
+ var _ref8, _discount$amount;
234
+ var title = resolveDiscountTitle(discount, locale);
235
+ var amount = (_ref8 = (_discount$amount = discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : discount.value) !== null && _ref8 !== void 0 ? _ref8 : discount.discount_amount;
236
+ var formattedAmount = formatNegativeMoney(amount, currencySymbol);
237
+ return _objectSpread(_objectSpread({}, discount), {}, {
238
+ item: title,
239
+ name: title,
240
+ title: title,
241
+ value: formattedAmount
242
+ });
243
+ });
244
+ }
245
+ function resolveDiscountTitle(discount, locale) {
246
+ var _ref9, _ref10, _ref11, _ref12, _discount$discount$na, _discount$discount, _discount$discount2, _discount$discount3;
247
+ var title = getLocalizedValue((_ref9 = (_ref10 = (_ref11 = (_ref12 = (_discount$discount$na = (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.name) !== null && _discount$discount$na !== void 0 ? _discount$discount$na : (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.title) !== null && _ref12 !== void 0 ? _ref12 : (_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.message) !== null && _ref11 !== void 0 ? _ref11 : discount.name) !== null && _ref10 !== void 0 ? _ref10 : discount.title) !== null && _ref9 !== void 0 ? _ref9 : discount.message, locale);
248
+ if (title) return title;
249
+ if (discount.type === 'product') return label(locale, 'manualDiscount');
250
+ return '';
251
+ }
218
252
  function resolveProductTitle(params) {
219
253
  var _product$product_id2;
220
254
  var product = params.product,
@@ -235,9 +269,9 @@ function normalizeProductOptions(params) {
235
269
  parentProduct = params.parentProduct;
236
270
  var rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) ? product.product_sku.option : [];
237
271
  return rawOptions.map(function (option) {
238
- var _ref8, _option$original_pric, _ref9, _option$value, _option$num;
239
- var price = (_ref8 = (_option$original_pric = option.original_price) !== null && _option$original_pric !== void 0 ? _option$original_pric : option.add_price) !== null && _ref8 !== void 0 ? _ref8 : option.price;
240
- var value = (_ref9 = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.option) !== null && _ref9 !== void 0 ? _ref9 : option.item;
272
+ var _ref13, _option$original_pric, _ref14, _option$value, _option$num;
273
+ var price = (_ref13 = (_option$original_pric = option.original_price) !== null && _option$original_pric !== void 0 ? _option$original_pric : option.add_price) !== null && _ref13 !== void 0 ? _ref13 : option.price;
274
+ var value = (_ref14 = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.option) !== null && _ref14 !== void 0 ? _ref14 : option.item;
241
275
  var name = getProductTitleSource(option, locale) || resolveOptionTitleFromParentProduct({
242
276
  option: option,
243
277
  parentProduct: parentProduct,
@@ -262,7 +296,7 @@ function normalizeProductCombinations(params) {
262
296
  parentProduct = params.parentProduct;
263
297
  var bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
264
298
  return bundles.map(function (bundle) {
265
- var _ref10, _bundle$num;
299
+ var _ref15, _bundle$num;
266
300
  var combinationsOptions = normalizeProductOptions({
267
301
  product: {},
268
302
  locale: locale,
@@ -279,14 +313,14 @@ function normalizeProductCombinations(params) {
279
313
  var optionTitle = buildOptionTitleSuffix(combinationsOptions);
280
314
  return {
281
315
  product_title: "".concat(baseTitle).concat(optionTitle),
282
- product_quantity: toNumber((_ref10 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref10 !== void 0 ? _ref10 : 1, 1),
316
+ product_quantity: toNumber((_ref15 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref15 !== void 0 ? _ref15 : 1, 1),
283
317
  price: formatBundlePrice(bundle, currencySymbol),
284
318
  combinations_options: combinationsOptions
285
319
  };
286
320
  });
287
321
  }
288
322
  function resolveBundleProductTitle(params) {
289
- var _ref11, _ref12, _bundle$bundle_produc;
323
+ var _ref16, _ref17, _bundle$bundle_produc;
290
324
  var bundle = params.bundle,
291
325
  productMap = params.productMap,
292
326
  locale = params.locale,
@@ -299,7 +333,7 @@ function resolveBundleProductTitle(params) {
299
333
  });
300
334
  var parentBundleTitle = parentBundleItem ? getProductTitleSource(parentBundleItem, locale) : '';
301
335
  if (parentBundleTitle) return parentBundleTitle;
302
- var productId = (_ref11 = (_ref12 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref12 !== void 0 ? _ref12 : bundle.product_id) !== null && _ref11 !== void 0 ? _ref11 : bundle.id;
336
+ var productId = (_ref16 = (_ref17 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref17 !== void 0 ? _ref17 : bundle.product_id) !== null && _ref16 !== void 0 ? _ref16 : bundle.id;
303
337
  var fallbackProduct = resolveProductFromMap(productId, productMap);
304
338
  if (!fallbackProduct) return '';
305
339
  return getProductTitleSource(fallbackProduct, locale);
@@ -351,10 +385,10 @@ function resolveVariantTextFromSkuKey(params) {
351
385
  }
352
386
  function resolveVariantTextFromNameMap(params) {
353
387
  if (!params.nameMap || _typeof(params.nameMap) !== 'object') return '';
354
- return Object.entries(params.nameMap).map(function (_ref13) {
355
- var _ref14 = _slicedToArray(_ref13, 2),
356
- groupPositionId = _ref14[0],
357
- value = _ref14[1];
388
+ return Object.entries(params.nameMap).map(function (_ref18) {
389
+ var _ref19 = _slicedToArray(_ref18, 2),
390
+ groupPositionId = _ref19[0],
391
+ value = _ref19[1];
358
392
  var group = resolveVariantGroup(params.parentProduct, groupPositionId);
359
393
  if (!group) return '';
360
394
  var groupName = getLocalizedValue(group.name, params.locale);
@@ -388,12 +422,12 @@ function getProductTitleSource(source, locale) {
388
422
  return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
389
423
  }
390
424
  function resolveTitleValue(value, locale) {
391
- var _ref15, _ref16, _ref17, _ref18, _value$locale;
425
+ var _ref20, _ref21, _ref22, _ref23, _value$locale;
392
426
  if (value === undefined || value === null) return '';
393
427
  if (_typeof(value) !== 'object') return stringify(value);
394
428
  var dashedLocale = locale.replace('_', '-');
395
429
  var underscoredLocale = locale.replace('-', '_');
396
- return stringify((_ref15 = (_ref16 = (_ref17 = (_ref18 = (_value$locale = value[locale]) !== null && _value$locale !== void 0 ? _value$locale : value[dashedLocale]) !== null && _ref18 !== void 0 ? _ref18 : value[underscoredLocale]) !== null && _ref17 !== void 0 ? _ref17 : value.original) !== null && _ref16 !== void 0 ? _ref16 : value.auto) !== null && _ref15 !== void 0 ? _ref15 : '');
430
+ return stringify((_ref20 = (_ref21 = (_ref22 = (_ref23 = (_value$locale = value[locale]) !== null && _value$locale !== void 0 ? _value$locale : value[dashedLocale]) !== null && _ref23 !== void 0 ? _ref23 : value[underscoredLocale]) !== null && _ref22 !== void 0 ? _ref22 : value.original) !== null && _ref21 !== void 0 ? _ref21 : value.auto) !== null && _ref20 !== void 0 ? _ref20 : '');
397
431
  }
398
432
  function resolveOptionTitleFromParentProduct(params) {
399
433
  var option = params.option,
@@ -411,17 +445,17 @@ function flattenOptionItems(parentProduct) {
411
445
  return optionGroups.flatMap(function (group) {
412
446
  var items = normalizeArray(group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item);
413
447
  return items.map(function (item) {
414
- var _ref19, _item$option_group_id;
448
+ var _ref24, _item$option_group_id;
415
449
  return _objectSpread(_objectSpread({}, item), {}, {
416
- option_group_id: (_ref19 = (_item$option_group_id = item.option_group_id) !== null && _item$option_group_id !== void 0 ? _item$option_group_id : group.id) !== null && _ref19 !== void 0 ? _ref19 : group.option_group_id
450
+ option_group_id: (_ref24 = (_item$option_group_id = item.option_group_id) !== null && _item$option_group_id !== void 0 ? _item$option_group_id : group.id) !== null && _ref24 !== void 0 ? _ref24 : group.option_group_id
417
451
  });
418
452
  });
419
453
  });
420
454
  }
421
455
  function isOptionItemMatch(option, item) {
422
- var _ref20, _option$option_group_, _ref21, _item$option_group_it, _option$option_group_2, _item$option_group_id2;
423
- var optionItemId = (_ref20 = (_option$option_group_ = option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.product_option_item_id) !== null && _ref20 !== void 0 ? _ref20 : option.id;
424
- var itemId = (_ref21 = (_item$option_group_it = item.option_group_item_id) !== null && _item$option_group_it !== void 0 ? _item$option_group_it : item.product_option_item_id) !== null && _ref21 !== void 0 ? _ref21 : item.id;
456
+ var _ref25, _option$option_group_, _ref26, _item$option_group_it, _option$option_group_2, _item$option_group_id2;
457
+ var optionItemId = (_ref25 = (_option$option_group_ = option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.product_option_item_id) !== null && _ref25 !== void 0 ? _ref25 : option.id;
458
+ var itemId = (_ref26 = (_item$option_group_it = item.option_group_item_id) !== null && _item$option_group_it !== void 0 ? _item$option_group_it : item.product_option_item_id) !== null && _ref26 !== void 0 ? _ref26 : item.id;
425
459
  if (!isSameId(optionItemId, itemId)) return false;
426
460
  var optionGroupId = (_option$option_group_2 = option.option_group_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option.group_id;
427
461
  var itemGroupId = (_item$option_group_id2 = item.option_group_id) !== null && _item$option_group_id2 !== void 0 ? _item$option_group_id2 : item.group_id;
@@ -431,16 +465,16 @@ function isOptionItemMatch(option, item) {
431
465
  return true;
432
466
  }
433
467
  function resolveBundleItemFromParentProduct(params) {
434
- var _ref22, _bundle$bundle_varian, _bundle$bundle_id, _bundle$bundle_group_, _ref24, _bundle$bundle_produc2;
468
+ var _ref27, _bundle$bundle_varian, _bundle$bundle_id, _bundle$bundle_group_, _ref29, _bundle$bundle_produc2;
435
469
  var bundle = params.bundle,
436
470
  parentProduct = params.parentProduct;
437
471
  if (!parentProduct) return null;
438
472
  var bundleItems = flattenBundleItems(parentProduct);
439
- var bundleVariantId = (_ref22 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref22 !== void 0 ? _ref22 : bundle.product_variant_id;
473
+ var bundleVariantId = (_ref27 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref27 !== void 0 ? _ref27 : bundle.product_variant_id;
440
474
  if (isNonZeroId(bundleVariantId)) {
441
475
  var matchedByVariant = bundleItems.find(function (item) {
442
- var _ref23, _item$bundle_variant_;
443
- return isSameId((_ref23 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.variant_id) !== null && _ref23 !== void 0 ? _ref23 : item.product_variant_id, bundleVariantId);
476
+ var _ref28, _item$bundle_variant_;
477
+ return isSameId((_ref28 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.variant_id) !== null && _ref28 !== void 0 ? _ref28 : item.product_variant_id, bundleVariantId);
444
478
  });
445
479
  if (matchedByVariant) return matchedByVariant;
446
480
  }
@@ -453,18 +487,18 @@ function resolveBundleItemFromParentProduct(params) {
453
487
  if (matchedByBundleId) return matchedByBundleId;
454
488
  }
455
489
  var bundleGroupId = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id;
456
- var bundleProductId = (_ref24 = (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : bundle.product_id;
490
+ var bundleProductId = (_ref29 = (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id) !== null && _ref29 !== void 0 ? _ref29 : bundle.product_id;
457
491
  if (isPresentId(bundleGroupId) && isPresentId(bundleProductId)) {
458
492
  var matchedByGroupAndProduct = bundleItems.find(function (item) {
459
- var _item$group_id, _ref25, _item$bundle_product_;
460
- return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((_ref25 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref25 !== void 0 ? _ref25 : item.product_id, bundleProductId);
493
+ var _item$group_id, _ref30, _item$bundle_product_;
494
+ return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((_ref30 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref30 !== void 0 ? _ref30 : item.product_id, bundleProductId);
461
495
  });
462
496
  if (matchedByGroupAndProduct) return matchedByGroupAndProduct;
463
497
  }
464
498
  if (isPresentId(bundleProductId)) {
465
499
  return bundleItems.find(function (item) {
466
- var _ref26, _item$bundle_product_2;
467
- return isSameId((_ref26 = (_item$bundle_product_2 = item.bundle_product_id) !== null && _item$bundle_product_2 !== void 0 ? _item$bundle_product_2 : item._bundle_product_id) !== null && _ref26 !== void 0 ? _ref26 : item.product_id, bundleProductId);
500
+ var _ref31, _item$bundle_product_2;
501
+ return isSameId((_ref31 = (_item$bundle_product_2 = item.bundle_product_id) !== null && _item$bundle_product_2 !== void 0 ? _item$bundle_product_2 : item._bundle_product_id) !== null && _ref31 !== void 0 ? _ref31 : item.product_id, bundleProductId);
468
502
  }) || null;
469
503
  }
470
504
  return null;
@@ -474,9 +508,9 @@ function flattenBundleItems(parentProduct) {
474
508
  return bundleGroups.flatMap(function (group) {
475
509
  var items = Array.isArray(group.bundle_item) ? group.bundle_item : [];
476
510
  return items.map(function (item) {
477
- var _ref27, _item$group_id2;
511
+ var _ref32, _item$group_id2;
478
512
  return _objectSpread(_objectSpread({}, item), {}, {
479
- group_id: (_ref27 = (_item$group_id2 = item.group_id) !== null && _item$group_id2 !== void 0 ? _item$group_id2 : group.id) !== null && _ref27 !== void 0 ? _ref27 : group.group_id
513
+ group_id: (_ref32 = (_item$group_id2 = item.group_id) !== null && _item$group_id2 !== void 0 ? _item$group_id2 : group.id) !== null && _ref32 !== void 0 ? _ref32 : group.group_id
480
514
  });
481
515
  });
482
516
  });
@@ -502,14 +536,15 @@ function buildOptionTitleSuffix(options) {
502
536
  return text ? "(".concat(text, ")") : '';
503
537
  }
504
538
  function formatBundlePrice(bundle, currencySymbol) {
505
- var _ref28, _ref29, _bundle$bundle_sellin;
506
- var value = (_ref28 = (_ref29 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref29 !== void 0 ? _ref29 : bundle.price) !== null && _ref28 !== void 0 ? _ref28 : 0;
539
+ var _ref33, _ref34, _bundle$bundle_sellin;
540
+ var value = (_ref33 = (_ref34 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref34 !== void 0 ? _ref34 : bundle.price) !== null && _ref33 !== void 0 ? _ref33 : 0;
507
541
  var amount = new Decimal(toMoneyNumber(value));
508
542
  var isNegative = bundle.price_type === 'markdown' || bundle.price_type === 'markup' && bundle.price_type_ext === 'product_price';
509
543
  if (isNegative) return "-".concat(currencySymbol).concat(amount.abs().toFixed(2));
510
544
  return formatMoney(amount, currencySymbol);
511
545
  }
512
546
  function buildFees(params) {
547
+ var _ref36, _order$shop_discount;
513
548
  var order = params.order,
514
549
  shopInfo = params.shopInfo,
515
550
  locale = params.locale,
@@ -518,20 +553,20 @@ function buildFees(params) {
518
553
  currencySymbol = params.currencySymbol;
519
554
  var fees = [];
520
555
  for (var _i = 0, _normalizeArray = normalizeArray(order.surcharges || summary.surcharges); _i < _normalizeArray.length; _i++) {
521
- var _ref30, _surcharge$amount;
556
+ var _ref35, _surcharge$amount;
522
557
  var surcharge = _normalizeArray[_i];
523
- var value = (_ref30 = (_surcharge$amount = surcharge.amount) !== null && _surcharge$amount !== void 0 ? _surcharge$amount : surcharge.value) !== null && _ref30 !== void 0 ? _ref30 : surcharge.total_amount;
558
+ var value = (_ref35 = (_surcharge$amount = surcharge.amount) !== null && _surcharge$amount !== void 0 ? _surcharge$amount : surcharge.value) !== null && _ref35 !== void 0 ? _ref35 : surcharge.total_amount;
524
559
  if (!isNonZero(value)) continue;
525
560
  fees.push({
526
561
  item: getLocalizedValue(surcharge.name || surcharge.title || surcharge.item, locale),
527
562
  value: formatMoney(value, currencySymbol)
528
563
  });
529
564
  }
530
- var discountAmount = summary.discount_amount || order.discount_amount || order.shop_discount;
565
+ var discountAmount = (_ref36 = (_order$shop_discount = order.shop_discount) !== null && _order$shop_discount !== void 0 ? _order$shop_discount : summary.discount_amount) !== null && _ref36 !== void 0 ? _ref36 : order.discount_amount;
531
566
  if (isNonZero(discountAmount)) {
532
567
  fees.push({
533
568
  item: label(locale, 'orderDiscount'),
534
- value: formatMoney(new Decimal(toMoneyNumber(discountAmount)).neg(), currencySymbol)
569
+ value: formatNegativeMoney(discountAmount, currencySymbol)
535
570
  });
536
571
  }
537
572
  var taxFee = summary.tax_fee || order.tax_fee;
@@ -655,8 +690,8 @@ function buildPaymentData(params) {
655
690
  currencySymbol: params.currencySymbol
656
691
  })));
657
692
  } else {
658
- var _ref31, _payment$remaining_am, _payment$metadata;
659
- var remainingAmount = (_ref31 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref31 !== void 0 ? _ref31 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
693
+ var _ref37, _payment$remaining_am, _payment$metadata;
694
+ var remainingAmount = (_ref37 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref37 !== void 0 ? _ref37 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
660
695
  if (remainingAmount !== undefined && remainingAmount !== null) {
661
696
  items.push({
662
697
  item: label(params.locale, 'remainingAmount'),
@@ -764,11 +799,12 @@ function label(locale, key) {
764
799
  return ((_LABELS$locale = LABELS[locale]) === null || _LABELS$locale === void 0 ? void 0 : _LABELS$locale[key]) || LABELS.en[key] || key;
765
800
  }
766
801
  function getLocalizedValue(value, locale) {
767
- var _ref32, _ref33, _ref34, _value$locale2;
802
+ var _ref38, _ref39, _ref40, _ref41, _ref42, _ref43, _value$locale2;
768
803
  if (value === undefined || value === null) return '';
769
804
  if (_typeof(value) !== 'object') return stringify(value);
770
805
  var dashedLocale = locale.replace('_', '-');
771
- return stringify((_ref32 = (_ref33 = (_ref34 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref34 !== void 0 ? _ref34 : value.default) !== null && _ref33 !== void 0 ? _ref33 : value.en) !== null && _ref32 !== void 0 ? _ref32 : '');
806
+ var underscoredLocale = locale.replace('-', '_');
807
+ return stringify((_ref38 = (_ref39 = (_ref40 = (_ref41 = (_ref42 = (_ref43 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref43 !== void 0 ? _ref43 : value[underscoredLocale]) !== null && _ref42 !== void 0 ? _ref42 : value.original) !== null && _ref41 !== void 0 ? _ref41 : value.auto) !== null && _ref40 !== void 0 ? _ref40 : value.default) !== null && _ref39 !== void 0 ? _ref39 : value.en) !== null && _ref38 !== void 0 ? _ref38 : '');
772
808
  }
773
809
  function serviceTypeToLabelKey(serviceType) {
774
810
  var normalized = serviceType.toLowerCase();
@@ -793,6 +829,10 @@ function formatMoney(value, currencySymbol) {
793
829
  var amount = new Decimal(toMoneyNumber(value));
794
830
  return "".concat(currencySymbol).concat(amount.toFixed(2));
795
831
  }
832
+ function formatNegativeMoney(value, currencySymbol) {
833
+ var amount = new Decimal(toMoneyNumber(value)).abs();
834
+ return "-".concat(currencySymbol).concat(amount.toFixed(2));
835
+ }
796
836
  function calculateReceiptPaidAmount(order, summary) {
797
837
  var _summary$pay_service_, _summary$total_amount;
798
838
  var paidAmount = sumPayments(order.payments);
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 6 | 3 | 4 | 5;
314
+ weekNum: 0 | 5 | 1 | 4 | 2 | 3 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -1,49 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/model/strategy/adapter/promotion/index.ts
30
- var promotion_exports = {};
31
- __export(promotion_exports, {
32
- BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
- PromotionAdapter: () => import_adapter.PromotionAdapter,
34
- PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
- X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
- default: () => import_adapter2.default
37
- });
38
- module.exports = __toCommonJS(promotion_exports);
39
- var import_evaluator = require("./evaluator");
40
- var import_adapter = require("./adapter");
41
- var import_adapter2 = __toESM(require("./adapter"));
42
- var import_examples = require("./examples");
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- BUY_X_GET_Y_FREE_STRATEGY,
46
- PromotionAdapter,
47
- PromotionEvaluator,
48
- X_ITEMS_FOR_Y_PRICE_STRATEGY
49
- });
@@ -26,6 +26,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
26
26
  private giftSelectResolver;
27
27
  /** applyPromotion 递归保护 flag(写路径同步调 applyPromotion,禁止重入) */
28
28
  private isApplyingPromotion;
29
+ /** 商品曾应用过客户券卡,客户变更剥离后需强制跑一次 calcDiscount 复位价格 */
30
+ private hasActiveCustomerBoundDiscount;
29
31
  /** 最近一次 applyPromotion 的未满足促销提示 */
30
32
  private lastUnfulfilledPromotions;
31
33
  /** 最近一次 applyPromotion 的赠品操作 diff(debug / SDK 读取使用) */
@@ -258,6 +260,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
258
260
  updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
259
261
  private buildTempOrderCustomer;
260
262
  private isCustomerBoundDiscount;
263
+ private productHasCustomerBoundDiscount;
264
+ private shouldSkipDiscountCalculation;
261
265
  private clearCustomerBoundDiscounts;
262
266
  /**
263
267
  * 更新当前 tempOrder 的客户协议字段。
@@ -76,6 +76,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
76
76
  this.giftSelectResolver = null;
77
77
  /** applyPromotion 递归保护 flag(写路径同步调 applyPromotion,禁止重入) */
78
78
  this.isApplyingPromotion = false;
79
+ /** 商品曾应用过客户券卡,客户变更剥离后需强制跑一次 calcDiscount 复位价格 */
80
+ this.hasActiveCustomerBoundDiscount = false;
79
81
  /** 最近一次 applyPromotion 的未满足促销提示 */
80
82
  this.lastUnfulfilledPromotions = [];
81
83
  /** 最近一次 applyPromotion 的赠品操作 diff(debug / SDK 读取使用) */
@@ -471,6 +473,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
471
473
  if (!tempOrder)
472
474
  return;
473
475
  delete tempOrder.discount_list;
476
+ if (this.shouldSkipDiscountCalculation(tempOrder))
477
+ return;
474
478
  const rulesModule = this.store.rules;
475
479
  if (!rulesModule)
476
480
  return;
@@ -512,6 +516,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
512
516
  );
513
517
  (_e = this.store.discount) == null ? void 0 : _e.setDiscountList(result.discountList);
514
518
  }
519
+ this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(
520
+ (product) => this.productHasCustomerBoundDiscount(product)
521
+ );
515
522
  }
516
523
  // ─── 促销/赠品 ──────────────────────────────────────
517
524
  /**
@@ -556,7 +563,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
556
563
  * - 不主动调用 applyDiscount / recalculateSummary,调用方负责跟进。
557
564
  */
558
565
  async applyPromotion() {
559
- var _a;
566
+ var _a, _b, _c;
560
567
  if (this.isApplyingPromotion) {
561
568
  return;
562
569
  }
@@ -567,6 +574,10 @@ var OrderModule = class extends import_BaseModule.BaseModule {
567
574
  if (!tempOrder) {
568
575
  return;
569
576
  }
577
+ const strategyConfigs = (_b = (_a = this.promotionEvaluator).getStrategyConfigs) == null ? void 0 : _b.call(_a);
578
+ if (Array.isArray(strategyConfigs) && strategyConfigs.length === 0) {
579
+ return;
580
+ }
570
581
  this.isApplyingPromotion = true;
571
582
  try {
572
583
  const result = (0, import_cartPromotion.processCartPromotion)(
@@ -608,11 +619,11 @@ var OrderModule = class extends import_BaseModule.BaseModule {
608
619
  if (addAction.giftOptions.length === 1) {
609
620
  const sameStrategy = result.products.find(
610
621
  (p) => {
611
- var _a2, _b;
612
- return ((_b = (_a2 = p.metadata) == null ? void 0 : _a2._giftInfo) == null ? void 0 : _b.strategyId) === addAction.strategyId;
622
+ var _a2, _b2;
623
+ return ((_b2 = (_a2 = p.metadata) == null ? void 0 : _a2._giftInfo) == null ? void 0 : _b2.strategyId) === addAction.strategyId;
613
624
  }
614
625
  );
615
- if (sameStrategy && !sameStrategy.booking_uid && !((_a = sameStrategy.metadata) == null ? void 0 : _a.booking_uid)) {
626
+ if (sameStrategy && !sameStrategy.booking_uid && !((_c = sameStrategy.metadata) == null ? void 0 : _c.booking_uid)) {
616
627
  sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
617
628
  continue;
618
629
  }
@@ -1977,12 +1988,37 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1977
1988
  const type = (discount == null ? void 0 : discount.type) ?? (discount == null ? void 0 : discount.tag);
1978
1989
  return type === "good_pass" || type === "discount_card" || type === "product_discount_card";
1979
1990
  }
1991
+ productHasCustomerBoundDiscount(product) {
1992
+ if (((product == null ? void 0 : product.discount_list) || []).some((discount) => this.isCustomerBoundDiscount(discount))) {
1993
+ return true;
1994
+ }
1995
+ return ((product == null ? void 0 : product.product_bundle) || []).some(
1996
+ (bundle) => ((bundle == null ? void 0 : bundle.discount_list) || []).some((discount) => this.isCustomerBoundDiscount(discount))
1997
+ );
1998
+ }
1999
+ shouldSkipDiscountCalculation(tempOrder) {
2000
+ var _a, _b;
2001
+ if (this.hasActiveCustomerBoundDiscount)
2002
+ return false;
2003
+ const discountList = ((_b = (_a = this.store.discount) == null ? void 0 : _a.getDiscountList) == null ? void 0 : _b.call(_a)) || [];
2004
+ if (discountList.length > 0)
2005
+ return false;
2006
+ return !(tempOrder.products || []).some(
2007
+ (product) => this.productHasCustomerBoundDiscount(product)
2008
+ );
2009
+ }
1980
2010
  clearCustomerBoundDiscounts(tempOrder) {
1981
2011
  var _a, _b, _c, _d;
2012
+ let didRemoveCustomerBoundDiscount = false;
1982
2013
  const filterDiscountList = (discountList) => {
1983
2014
  if (!Array.isArray(discountList))
1984
2015
  return [];
1985
- return discountList.filter((discount) => !this.isCustomerBoundDiscount(discount));
2016
+ return discountList.filter((discount) => {
2017
+ const shouldRemove = this.isCustomerBoundDiscount(discount);
2018
+ if (shouldRemove)
2019
+ didRemoveCustomerBoundDiscount = true;
2020
+ return !shouldRemove;
2021
+ });
1986
2022
  };
1987
2023
  tempOrder.products = (tempOrder.products || []).map((product) => {
1988
2024
  const nextProduct = {
@@ -1998,6 +2034,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1998
2034
  return nextProduct;
1999
2035
  });
2000
2036
  delete tempOrder.discount_list;
2037
+ if (didRemoveCustomerBoundDiscount) {
2038
+ this.hasActiveCustomerBoundDiscount = true;
2039
+ }
2001
2040
  const discountModule = this.store.discount;
2002
2041
  if (!discountModule)
2003
2042
  return;
@@ -34,6 +34,7 @@ export interface OrderPromotionEvaluator {
34
34
  products: any[];
35
35
  channel?: string;
36
36
  }, matchVariant?: boolean): any[];
37
+ getStrategyConfigs?: () => unknown[];
37
38
  }
38
39
  /** 赠品解析回调 context(OS → SDK 的请求体) */
39
40
  export interface OrderGiftSelectContext {
@@ -214,7 +214,7 @@ var WalletPassPaymentImpl = class {
214
214
  };
215
215
  const [allList, orderBasicDetail] = await Promise.all([
216
216
  this.getUserIdentificationCodeListAsync(identificationParams),
217
- baseParams.payment_order_id ? this.getOrderBasicDetailAsync(baseParams.payment_order_id) : Promise.resolve(null)
217
+ baseParams.payment_order_id && typeof baseParams.payment_order_id === "string" && !baseParams.payment_order_id.startsWith("LOCAL_") ? this.getOrderBasicDetailAsync(baseParams.payment_order_id) : Promise.resolve(null)
218
218
  ]);
219
219
  const walletPassEvaluator = (_b = (_a = this.paymentModule.window) == null ? void 0 : _a.getWalletPassEvaluator) == null ? void 0 : _b.call(_a);
220
220
  if (!walletPassEvaluator) {
@@ -35,6 +35,7 @@ export interface SmallTicketProduct {
35
35
  original_price: string;
36
36
  total_original_price: string;
37
37
  extension_list: any[];
38
+ discount_list?: any[];
38
39
  options?: Array<{
39
40
  name: string;
40
41
  num?: number;