@pisell/pisellos 2.3.126 → 2.3.128

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 (31) hide show
  1. package/dist/modules/Order/index.d.ts +1 -0
  2. package/dist/modules/Order/index.js +118 -59
  3. package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
  4. package/dist/modules/Order/utils/weighedProduct.js +94 -0
  5. package/dist/modules/Order/utils.js +6 -4
  6. package/dist/modules/Rules/index.js +4 -2
  7. package/dist/modules/Rules/types.d.ts +2 -0
  8. package/dist/server/utils/small-ticket.js +1 -1
  9. package/dist/solution/BaseSales/index.d.ts +2 -2
  10. package/dist/solution/BaseSales/index.js +75 -39
  11. package/dist/solution/BaseSales/types.d.ts +5 -1
  12. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
  13. package/dist/solution/BaseSales/utils.js +3 -2
  14. package/dist/solution/BookingByStep/index.d.ts +1 -1
  15. package/dist/solution/ScanOrder/utils.js +3 -2
  16. package/lib/modules/Order/index.d.ts +1 -0
  17. package/lib/modules/Order/index.js +71 -11
  18. package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
  19. package/lib/modules/Order/utils/weighedProduct.js +89 -0
  20. package/lib/modules/Order/utils.js +3 -2
  21. package/lib/modules/Rules/index.js +4 -2
  22. package/lib/modules/Rules/types.d.ts +2 -0
  23. package/lib/server/utils/small-ticket.js +1 -1
  24. package/lib/solution/BaseSales/index.d.ts +2 -2
  25. package/lib/solution/BaseSales/index.js +15 -6
  26. package/lib/solution/BaseSales/types.d.ts +5 -1
  27. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
  28. package/lib/solution/BaseSales/utils.js +2 -1
  29. package/lib/solution/BookingByStep/index.d.ts +1 -1
  30. package/lib/solution/ScanOrder/utils.js +2 -1
  31. package/package.json +1 -1
@@ -31,6 +31,8 @@ export interface RulesCalcDiscountOptions {
31
31
  scan?: boolean;
32
32
  /** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
33
33
  reapplyBookingDiscountProductUids?: string[];
34
+ /** Reweighed order lines only: reapply selected wallet discounts against their new amount. */
35
+ reapplyWeighedDiscountProductUids?: string[];
34
36
  }
35
37
  export interface RulesModuleAPI {
36
38
  setRulesList: (rulesList: Rules[]) => Promise<void>;
@@ -994,7 +994,7 @@ function resolveVariantItem(group, itemPositionId) {
994
994
  }
995
995
  function getProductTitleSource(source, locale) {
996
996
  if (!source || _typeof(source) !== 'object') return '';
997
- return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title_i18n, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
997
+ return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title_i18n, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name_i18n, locale) || resolveTitleValue(source.name, locale);
998
998
  }
999
999
  function getBundleProductTitleSource(source, locale) {
1000
1000
  if (!source || _typeof(source) !== 'object') return '';
@@ -1,6 +1,6 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
- import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
3
+ import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentOptions, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
4
4
  import { OrderModule } from '../../modules/Order';
5
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';
@@ -450,7 +450,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
450
450
  private findCashPaymentMethod;
451
451
  private getPendingWalletPaymentAmount;
452
452
  /** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
453
- getCashPaymentConfig(): Promise<BaseSalesCashPaymentConfig>;
453
+ getCashPaymentConfig(options?: BaseSalesCashPaymentOptions): Promise<BaseSalesCashPaymentConfig>;
454
454
  /**
455
455
  * 确认足额覆盖订单的 pending Wallet 支付并提交订单。
456
456
  *
@@ -5458,12 +5458,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5458
5458
  }
5459
5459
  }, {
5460
5460
  key: "findCashPaymentMethod",
5461
- value: function findCashPaymentMethod(paymentMethods) {
5461
+ value: function findCashPaymentMethod(paymentMethods, paymentMethodId) {
5462
5462
  return paymentMethods.find(function (method) {
5463
+ if ((method === null || method === void 0 ? void 0 : method.enabled) === false || (method === null || method === void 0 ? void 0 : method.enable) === false) return false;
5463
5464
  var identifiers = [method === null || method === void 0 ? void 0 : method.code, method === null || method === void 0 ? void 0 : method.type, method === null || method === void 0 ? void 0 : method.tag].map(function (value) {
5464
5465
  return String(value || '').toUpperCase();
5465
5466
  });
5466
- return identifiers.includes('CASHMANUAL') && (method === null || method === void 0 ? void 0 : method.enabled) !== false && (method === null || method === void 0 ? void 0 : method.enable) !== false;
5467
+ var isDefaultCash = identifiers.includes('CASHMANUAL');
5468
+ if (paymentMethodId === undefined) return isDefaultCash;
5469
+ var isCustomCash = String((method === null || method === void 0 ? void 0 : method.type) || '').trim().toLowerCase() === 'custom' && [method === null || method === void 0 ? void 0 : method.name, method === null || method === void 0 ? void 0 : method.nameEn].some(function (name) {
5470
+ return typeof name === 'string' && /现金|現金|cash/i.test(name);
5471
+ });
5472
+ return String(method === null || method === void 0 ? void 0 : method.id) === String(paymentMethodId) && (isDefaultCash || isCustomCash);
5467
5473
  });
5468
5474
  }
5469
5475
  }, {
@@ -5489,28 +5495,43 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5489
5495
  value: (function () {
5490
5496
  var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
5491
5497
  var _this$store$order22, _this$store$order22$g, _this$store$order23, _this$store$order23$g, _this$otherParams34;
5492
- var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
5498
+ var options,
5499
+ paymentMethods,
5500
+ paymentMethod,
5501
+ amountSnapshot,
5502
+ pendingWalletAmount,
5503
+ amountDue,
5504
+ currency,
5505
+ recommendedAmounts,
5506
+ _args53 = arguments;
5493
5507
  return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5494
5508
  while (1) switch (_context53.prev = _context53.next) {
5495
5509
  case 0:
5510
+ options = _args53.length > 0 && _args53[0] !== undefined ? _args53[0] : {};
5496
5511
  if (this.store.payment) {
5497
- _context53.next = 2;
5512
+ _context53.next = 3;
5498
5513
  break;
5499
5514
  }
5500
5515
  throw new Error('payment 模块未初始化');
5501
- case 2:
5516
+ case 3:
5502
5517
  paymentMethods = this.getPaymentMethods();
5503
- paymentMethod = this.findCashPaymentMethod(paymentMethods);
5518
+ paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
5504
5519
  if (paymentMethod) {
5505
- _context53.next = 9;
5520
+ _context53.next = 10;
5506
5521
  break;
5507
5522
  }
5508
- _context53.next = 7;
5523
+ _context53.next = 8;
5509
5524
  return this.getPaymentMethodsAsync();
5510
- case 7:
5525
+ case 8:
5511
5526
  paymentMethods = _context53.sent;
5512
- paymentMethod = this.findCashPaymentMethod(paymentMethods);
5513
- case 9:
5527
+ paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
5528
+ case 10:
5529
+ if (!(!paymentMethod && options.paymentMethodId !== undefined)) {
5530
+ _context53.next = 12;
5531
+ break;
5532
+ }
5533
+ throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u73B0\u91D1\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(options.paymentMethodId));
5534
+ case 12:
5514
5535
  amountSnapshot = (_this$store$order22 = this.store.order) === null || _this$store$order22 === void 0 || (_this$store$order22$g = _this$store$order22.getOrderAmountSnapshot) === null || _this$store$order22$g === void 0 ? void 0 : _this$store$order22$g.call(_this$store$order22);
5515
5536
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
5516
5537
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
@@ -5522,7 +5543,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5522
5543
  amountDue: amountDue,
5523
5544
  recommendedAmounts: recommendedAmounts
5524
5545
  });
5525
- case 15:
5546
+ case 18:
5526
5547
  case "end":
5527
5548
  return _context53.stop();
5528
5549
  }
@@ -5687,31 +5708,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5687
5708
  }
5688
5709
  throw new Error('现金支付金额必须大于 0');
5689
5710
  case 5:
5690
- _context55.next = 7;
5711
+ if (!(params.paymentMethodId === undefined)) {
5712
+ _context55.next = 11;
5713
+ break;
5714
+ }
5715
+ _context55.next = 8;
5691
5716
  return this.getCashPaymentConfig();
5692
- case 7:
5693
- config = _context55.sent;
5717
+ case 8:
5718
+ _context55.t0 = _context55.sent;
5719
+ _context55.next = 14;
5720
+ break;
5721
+ case 11:
5722
+ _context55.next = 13;
5723
+ return this.getCashPaymentConfig({
5724
+ paymentMethodId: params.paymentMethodId
5725
+ });
5726
+ case 13:
5727
+ _context55.t0 = _context55.sent;
5728
+ case 14:
5729
+ config = _context55.t0;
5694
5730
  paymentMethod = config.paymentMethod;
5695
5731
  if (paymentMethod) {
5696
- _context55.next = 11;
5732
+ _context55.next = 18;
5697
5733
  break;
5698
5734
  }
5699
5735
  throw new Error('未找到可用的 CASHMANUAL 支付方式');
5700
- case 11:
5736
+ case 18:
5701
5737
  if (!(config.amountDue <= 0)) {
5702
- _context55.next = 13;
5738
+ _context55.next = 20;
5703
5739
  break;
5704
5740
  }
5705
5741
  throw new Error('当前订单没有待支付金额');
5706
- case 13:
5742
+ case 20:
5707
5743
  roundingAmount = Number(params.roundingAmount || 0);
5708
5744
  effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
5709
5745
  if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
5710
- _context55.next = 17;
5746
+ _context55.next = 24;
5711
5747
  break;
5712
5748
  }
5713
5749
  throw new Error('现金支付金额超过当前待支付金额');
5714
- case 17:
5750
+ case 24:
5715
5751
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5716
5752
  beforePaymentStatus = (_this$store$order$get13 = this.store.order.getTempOrder()) === null || _this$store$order$get13 === void 0 ? void 0 : _this$store$order$get13.payment_status;
5717
5753
  uniquePaymentNumber = createUuidV4();
@@ -5720,11 +5756,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5720
5756
  changeAmount = Number(params.changeAmount || 0);
5721
5757
  shopWalletPassId = (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.shop_wallet_pass_id;
5722
5758
  if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
5723
- _context55.next = 26;
5759
+ _context55.next = 33;
5724
5760
  break;
5725
5761
  }
5726
5762
  throw new Error('顾客实收现金不能小于支付金额');
5727
- case 26:
5763
+ case 33:
5728
5764
  (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.interaction) === null || _this$window === void 0 || (_this$window = _this$window.utils) === null || _this$window === void 0 || (_this$window$postMess = _this$window.postMessageToApp) === null || _this$window$postMess === void 0 || _this$window$postMess.call(_this$window, {
5729
5765
  module: 'till',
5730
5766
  key: 'open_till',
@@ -5755,57 +5791,57 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5755
5791
  var _item$metadata2;
5756
5792
  return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
5757
5793
  });
5758
- _context55.prev = 29;
5759
- _context55.next = 32;
5794
+ _context55.prev = 36;
5795
+ _context55.next = 39;
5760
5796
  return this.syncPaymentsToOrder({
5761
5797
  payments: payments,
5762
5798
  submitWhenPaid: true,
5763
5799
  smallTicketDataFlag: 1,
5764
5800
  confirmPendingVoucherPayments: true
5765
5801
  });
5766
- case 32:
5802
+ case 39:
5767
5803
  syncResult = _context55.sent;
5768
5804
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
5769
- _context55.next = 35;
5805
+ _context55.next = 42;
5770
5806
  break;
5771
5807
  }
5772
5808
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
5773
- case 35:
5809
+ case 42:
5774
5810
  if (!this.store.payment) {
5775
- _context55.next = 40;
5811
+ _context55.next = 47;
5776
5812
  break;
5777
5813
  }
5778
5814
  committed = this.getCommittedWalletAssets();
5779
5815
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5780
- _context55.next = 40;
5816
+ _context55.next = 47;
5781
5817
  return this.publishWalletAssetsState(walletState, 'local');
5782
- case 40:
5818
+ case 47:
5783
5819
  return _context55.abrupt("return", {
5784
5820
  payment: payment || {},
5785
5821
  payments: this.store.order.getOrderPayments(),
5786
5822
  syncResult: syncResult,
5787
5823
  isOrderFullyPaid: syncResult.isOrderFullyPaid
5788
5824
  });
5789
- case 43:
5790
- _context55.prev = 43;
5791
- _context55.t0 = _context55["catch"](29);
5825
+ case 50:
5826
+ _context55.prev = 50;
5827
+ _context55.t1 = _context55["catch"](36);
5792
5828
  this.store.order.setOrderPayments(beforePayments);
5793
5829
  restoredTempOrder = this.store.order.getTempOrder();
5794
5830
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
5795
5831
  restoredTempOrder.payment_status = beforePaymentStatus;
5796
5832
  this.store.order.persistTempOrder();
5797
5833
  }
5798
- _context55.next = 50;
5834
+ _context55.next = 57;
5799
5835
  return this.store.order.recalculateSummary({
5800
5836
  createIfMissing: true
5801
5837
  });
5802
- case 50:
5803
- throw _context55.t0;
5804
- case 51:
5838
+ case 57:
5839
+ throw _context55.t1;
5840
+ case 58:
5805
5841
  case "end":
5806
5842
  return _context55.stop();
5807
5843
  }
5808
- }, _callee55, this, [[29, 43]]);
5844
+ }, _callee55, this, [[36, 50]]);
5809
5845
  }));
5810
5846
  function payCash(_x44) {
5811
5847
  return _payCash.apply(this, arguments);
@@ -23,13 +23,17 @@ export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSales
23
23
  export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
24
24
  export type BaseSalesStatus = 'idle' | 'initializing' | 'ready' | 'error';
25
25
  export type BaseSalesPaymentStatus = 'paid' | 'partially_paid' | 'unpaid' | 'payment_processing' | string;
26
+ export interface BaseSalesCashPaymentOptions {
27
+ /** 指定现金支付方式;省略时使用默认 CASHMANUAL。 */
28
+ paymentMethodId?: number | string;
29
+ }
26
30
  export interface BaseSalesCashPaymentConfig {
27
31
  available: boolean;
28
32
  paymentMethod?: PaymentMethod;
29
33
  amountDue: number;
30
34
  recommendedAmounts: number[];
31
35
  }
32
- export interface BaseSalesPayCashParams {
36
+ export interface BaseSalesPayCashParams extends BaseSalesCashPaymentOptions {
33
37
  /** 实际计入订单的现金支付金额(部分支付时小于待付金额)。 */
34
38
  amount: number;
35
39
  /** 顾客实际交付现金;可大于 amount。 */
@@ -11,6 +11,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
11
11
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
12
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
13
  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; }
14
+ import { resolveWeighedSourcePrice, withOriginalBundleOptionPrices } from "../../../modules/Order/utils/weighedProduct";
14
15
  import { composeLinePrice, getBundleSellingMagnitude, normalizeProductSkuOptions, sumOptionUnitPrice } from "../../../modules/Order/utils";
15
16
  import { buildManualProductDiscountItem, mergeManualProductDiscountIntoList, resolveManualDiscountOriginTotal, resolveManualDiscountReasonFromSources, shouldBuildManualProductDiscount } from "../../../modules/Order/utils/manualProductDiscount";
16
17
  function toNumber(value) {
@@ -101,11 +102,12 @@ function appendDataVariantIds(base) {
101
102
  return Array.isArray(base) || result.length ? result : undefined;
102
103
  }
103
104
  function normalizeOptionItems(optionItems) {
105
+ var useOriginalPrice = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
104
106
  if (!Array.isArray(optionItems)) return [];
105
107
  return optionItems.map(function (optionItem) {
106
- var _optionItem$option_gr, _ref, _optionItem$price, _optionItem$num;
108
+ var _optionItem$option_gr, _ref, _ref2, _ref3, _optionItem$num;
107
109
  var optionGroupItemId = toNumber((_optionItem$option_gr = optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id) !== null && _optionItem$option_gr !== void 0 ? _optionItem$option_gr : optionItem === null || optionItem === void 0 ? void 0 : optionItem.id);
108
- var price = (_ref = (_optionItem$price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _optionItem$price !== void 0 ? _optionItem$price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref !== void 0 ? _ref : 0;
110
+ var price = (_ref = (_ref2 = (_ref3 = useOriginalPrice ? optionItem === null || optionItem === void 0 ? void 0 : optionItem.original_price : undefined) !== null && _ref3 !== void 0 ? _ref3 : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref2 !== void 0 ? _ref2 : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref !== void 0 ? _ref : 0;
109
111
  return _objectSpread(_objectSpread({}, optionItem), {}, {
110
112
  option_group_item_id: optionGroupItemId,
111
113
  option_group_id: toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_id),
@@ -117,10 +119,13 @@ function normalizeOptionItems(optionItems) {
117
119
  }
118
120
  function normalizeBundleItems(bundleItems) {
119
121
  var preferPriceField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
122
+ var preferBundleSellingPrice = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
120
123
  if (!Array.isArray(bundleItems)) return [];
121
124
  return bundleItems.map(function (bundleItem) {
122
- var _ref2, _ref3, _ref4, _bundleItem$price, _ref5, _ref6, _ref7, _bundleItem$bundle_se, _bundleItem$num, _bundleItem$price2, _bundleItem$quantity, _bundleItem$price3, _ref8, _ref9, _bundleItem$original_, _normalizedItem$price;
123
- var unitSelling = preferPriceField ? (_ref2 = (_ref3 = (_ref4 = (_bundleItem$price = bundleItem.price) !== null && _bundleItem$price !== void 0 ? _bundleItem$price : bundleItem.bundle_selling_price) !== null && _ref4 !== void 0 ? _ref4 : bundleItem.custom_price) !== null && _ref3 !== void 0 ? _ref3 : bundleItem.product_price) !== null && _ref2 !== void 0 ? _ref2 : '0' : (_ref5 = (_ref6 = (_ref7 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref7 !== void 0 ? _ref7 : bundleItem.custom_price) !== null && _ref6 !== void 0 ? _ref6 : bundleItem.product_price) !== null && _ref5 !== void 0 ? _ref5 : '0';
125
+ var _ref4, _ref5, _ref6, _bundleItem$price, _ref7, _ref8, _ref9, _bundleItem$bundle_se, _bundleItem$num, _bundleItem$price2, _bundleItem$quantity, _bundleItem$price3, _ref10, _ref11, _bundleItem$original_, _normalizedItem$price;
126
+ // Weighed manual prices distribute the bundle base and nested options separately.
127
+ // Its explicit selling amount already includes those options.
128
+ var unitSelling = preferPriceField && !preferBundleSellingPrice ? (_ref4 = (_ref5 = (_ref6 = (_bundleItem$price = bundleItem.price) !== null && _bundleItem$price !== void 0 ? _bundleItem$price : bundleItem.bundle_selling_price) !== null && _ref6 !== void 0 ? _ref6 : bundleItem.custom_price) !== null && _ref5 !== void 0 ? _ref5 : bundleItem.product_price) !== null && _ref4 !== void 0 ? _ref4 : '0' : (_ref7 = (_ref8 = (_ref9 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref9 !== void 0 ? _ref9 : bundleItem.custom_price) !== null && _ref8 !== void 0 ? _ref8 : bundleItem.product_price) !== null && _ref7 !== void 0 ? _ref7 : '0';
124
129
  var unitStr = toPriceString(unitSelling, '0.00');
125
130
  var num = toSafePositiveInt((_bundleItem$num = bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.num) !== null && _bundleItem$num !== void 0 ? _bundleItem$num : bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.quantity, 1);
126
131
  var magnitudeSource = _objectSpread(_objectSpread({}, bundleItem), {}, {
@@ -135,7 +140,7 @@ function normalizeBundleItems(bundleItems) {
135
140
  // price 保留毛价(markdown 仍为正),由 price_type 决定符号。
136
141
  price: (_bundleItem$price3 = bundleItem.price) !== null && _bundleItem$price3 !== void 0 ? _bundleItem$price3 : unitStr,
137
142
  bundle_selling_price: unitStr,
138
- original_price: (_ref8 = (_ref9 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref9 !== void 0 ? _ref9 : bundleItem.price) !== null && _ref8 !== void 0 ? _ref8 : unitStr,
143
+ original_price: (_ref10 = (_ref11 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref11 !== void 0 ? _ref11 : bundleItem.price) !== null && _ref10 !== void 0 ? _ref10 : unitStr,
139
144
  option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option),
140
145
  discount_list: preferPriceField ? [] : bundleItem.discount_list
141
146
  });
@@ -163,49 +168,55 @@ function findVariantById(origin, variantId) {
163
168
  * 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
164
169
  */
165
170
  export function transformBaseProductToOrderProduct(params) {
166
- var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _payload$metadata, _sourceProduct$metada, _callbackOrigin$metad, _origin$metadata, _payload$metadata2, _payload$_extend, _sourceProduct$metada2, _sourceProduct$_exten, _callbackOrigin$metad2, _callbackOrigin$_exte, _payload$_dataVariant, _sourceProduct$_dataV, _callbackOrigin$_data, _origin$_dataVariant, _ref15, _findVariantById, _origin$production_co, _ref16, _ref17, _ref18, _ref19, _ref20, _matchedVariant$price, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend2, _ref24, _ref25, _payload$product_sku$, _payload$product_sku, _payload$bundle, _payload$quantity, _payload$_extend3, _extend, _extend2, _ref26, _ref27, _origin$base_price, _ref28, _ref29, _payload$line_total2, _payload$_extend4, _payload$_extend5, _extend3, _payload$_extend6, _payload$_extend7, _ref30, _ref31, _payload$tax_fee, _ref32, _ref33, _payload$is_charge_ta;
171
+ var _ref12, _ref13, _ref14, _payload$product_id, _ref15, _ref16, _payload$product_vari, _payload$_origin, _payload$_origin2, _payload$metadata, _sourceProduct$metada, _callbackOrigin$metad, _origin$metadata, _payload$metadata2, _payload$_extend, _sourceProduct$metada2, _sourceProduct$_exten, _callbackOrigin$metad2, _callbackOrigin$_exte, _payload$_dataVariant, _sourceProduct$_dataV, _callbackOrigin$_data, _origin$_dataVariant, _ref17, _findVariantById, _origin$production_co, _ref18, _ref19, _ref20, _ref21, _ref22, _matchedVariant$price, _payload$product_sku, _payload$_extend$weig, _payload$_extend2, _origin$_extend, _ref23, _ref24, _payload$price, _ref25, _payload$line_total, _payload$_extend3, _ref26, _ref27, _payload$product_sku$, _payload$product_sku2, _payload$bundle, _payload$quantity, _payload$_extend4, _extend, _extend2, _ref28, _ref29, _origin$base_price, _ref30, _ref31, _payload$line_total2, _payload$_extend5, _payload$_extend6, _extend3, _payload$_extend7, _payload$_extend8, _ref32, _ref33, _payload$tax_fee, _ref34, _ref35, _payload$is_charge_ta;
167
172
  var payload = params.payload,
168
173
  _params$fallbackProdu = params.fallbackProductId,
169
174
  fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
170
175
  if (!payload || _typeof(payload) !== 'object') return null;
171
176
  var sourceProduct = params.sourceProduct || params.sourceItem || {};
172
- var productId = toProductId((_ref10 = (_ref11 = (_ref12 = (_payload$product_id = payload.product_id) !== null && _payload$product_id !== void 0 ? _payload$product_id : payload.id) !== null && _ref12 !== void 0 ? _ref12 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_id) !== null && _ref11 !== void 0 ? _ref11 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id) !== null && _ref10 !== void 0 ? _ref10 : fallbackProductId);
177
+ var productId = toProductId((_ref12 = (_ref13 = (_ref14 = (_payload$product_id = payload.product_id) !== null && _payload$product_id !== void 0 ? _payload$product_id : payload.id) !== null && _ref14 !== void 0 ? _ref14 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_id) !== null && _ref13 !== void 0 ? _ref13 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id) !== null && _ref12 !== void 0 ? _ref12 : fallbackProductId);
173
178
  if (productId === null) return null;
174
- var productVariantId = toNumber((_ref13 = (_ref14 = (_payload$product_vari = payload.product_variant_id) !== null && _payload$product_vari !== void 0 ? _payload$product_vari : payload.variant_id) !== null && _ref14 !== void 0 ? _ref14 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_variant_id) !== null && _ref13 !== void 0 ? _ref13 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.variant_id, 0);
179
+ var productVariantId = toNumber((_ref15 = (_ref16 = (_payload$product_vari = payload.product_variant_id) !== null && _payload$product_vari !== void 0 ? _payload$product_vari : payload.variant_id) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_variant_id) !== null && _ref15 !== void 0 ? _ref15 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.variant_id, 0);
175
180
  var callbackOrigin = payload.origin || ((_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.sourceProduct) || ((_payload$_origin2 = payload._origin) === null || _payload$_origin2 === void 0 ? void 0 : _payload$_origin2.sourceItem) || payload._origin || {};
176
181
  var origin = _objectSpread(_objectSpread({}, sourceProduct || {}), callbackOrigin || {});
177
182
  var authoritativeDataVariantIds = cloneFirstDataVariantIds((_payload$metadata = payload.metadata) === null || _payload$metadata === void 0 ? void 0 : _payload$metadata.data_variant_ids, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.data_variant_ids, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$metad = callbackOrigin.metadata) === null || _callbackOrigin$metad === void 0 ? void 0 : _callbackOrigin$metad.data_variant_ids, origin === null || origin === void 0 || (_origin$metadata = origin.metadata) === null || _origin$metadata === void 0 ? void 0 : _origin$metadata.data_variant_ids);
178
183
  var selectedSettlementSnapshot = firstNonBlank(payload.selected_settlement_snapshot, (_payload$metadata2 = payload.metadata) === null || _payload$metadata2 === void 0 ? void 0 : _payload$metadata2.selected_settlement_snapshot, (_payload$_extend = payload._extend) === null || _payload$_extend === void 0 || (_payload$_extend = _payload$_extend.metadata) === null || _payload$_extend === void 0 ? void 0 : _payload$_extend.selected_settlement_snapshot, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$metada2 = sourceProduct.metadata) === null || _sourceProduct$metada2 === void 0 ? void 0 : _sourceProduct$metada2.selected_settlement_snapshot, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$_exten = sourceProduct._extend) === null || _sourceProduct$_exten === void 0 || (_sourceProduct$_exten = _sourceProduct$_exten.metadata) === null || _sourceProduct$_exten === void 0 ? void 0 : _sourceProduct$_exten.selected_settlement_snapshot, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$metad2 = callbackOrigin.metadata) === null || _callbackOrigin$metad2 === void 0 ? void 0 : _callbackOrigin$metad2.selected_settlement_snapshot, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$_exte = callbackOrigin._extend) === null || _callbackOrigin$_exte === void 0 || (_callbackOrigin$_exte = _callbackOrigin$_exte.metadata) === null || _callbackOrigin$_exte === void 0 ? void 0 : _callbackOrigin$_exte.selected_settlement_snapshot);
179
184
  var locallyAppliedVariantIds = authoritativeDataVariantIds === undefined ? cloneFirstDataVariantIds((_payload$_dataVariant = payload._dataVariant) === null || _payload$_dataVariant === void 0 ? void 0 : _payload$_dataVariant.appliedVariantIds, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$_dataV = sourceProduct._dataVariant) === null || _sourceProduct$_dataV === void 0 ? void 0 : _sourceProduct$_dataV.appliedVariantIds, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$_data = callbackOrigin._dataVariant) === null || _callbackOrigin$_data === void 0 ? void 0 : _callbackOrigin$_data.appliedVariantIds, origin === null || origin === void 0 || (_origin$_dataVariant = origin._dataVariant) === null || _origin$_dataVariant === void 0 ? void 0 : _origin$_dataVariant.appliedVariantIds) : undefined;
180
185
  var dataVariantIds = appendDataVariantIds(authoritativeDataVariantIds, locallyAppliedVariantIds, selectedSettlementSnapshot === null || selectedSettlementSnapshot === void 0 ? void 0 : selectedSettlementSnapshot.data_variant_id);
181
- var matchedVariant = (_ref15 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref15 !== void 0 ? _ref15 : findVariantById(origin, productVariantId);
186
+ var matchedVariant = (_ref17 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref17 !== void 0 ? _ref17 : findVariantById(origin, productVariantId);
182
187
  var productionCode = normalizeProductionCode(Object.prototype.hasOwnProperty.call(payload, 'production_code') ? payload.production_code : productVariantId > 0 ? matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.production_code : (_origin$production_co = origin === null || origin === void 0 ? void 0 : origin.production_code) !== null && _origin$production_co !== void 0 ? _origin$production_co : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.production_code);
183
188
  var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
184
189
  // 手动改价后 payload.price 是分摊后的主商品售价,不能再作为券前 source。
185
- // 此时优先从商品/variant 快照读取目录价;售价仍由 line_total - bundle 推导。
186
- var catalogSourcePrice = (_ref16 = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_matchedVariant$price = matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _matchedVariant$price !== void 0 ? _matchedVariant$price : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref20 !== void 0 ? _ref20 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref19 !== void 0 ? _ref19 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref17 !== void 0 ? _ref17 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price;
187
- var sourceProductPrice = toPriceString(hasPriceOverride ? (_ref21 = catalogSourcePrice !== null && catalogSourcePrice !== void 0 ? catalogSourcePrice : payload.price) !== null && _ref21 !== void 0 ? _ref21 : payload.selling_price : (_ref22 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref22 !== void 0 ? _ref22 : catalogSourcePrice, '0.00');
188
- var explicitLineTotal = (_ref23 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref23 !== void 0 ? _ref23 : (_payload$_extend2 = payload._extend) === null || _payload$_extend2 === void 0 ? void 0 : _payload$_extend2.total;
190
+ // 称重商品使用改价前净重金额;其它商品从商品/variant 快照读取目录价。
191
+ // 售价仍由 line_total - bundle 推导。
192
+ var catalogSourcePrice = (_ref18 = (_ref19 = (_ref20 = (_ref21 = (_ref22 = (_matchedVariant$price = matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _matchedVariant$price !== void 0 ? _matchedVariant$price : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref22 !== void 0 ? _ref22 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref21 !== void 0 ? _ref21 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref20 !== void 0 ? _ref20 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref19 !== void 0 ? _ref19 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price;
193
+ var weighedSourcePrice = resolveWeighedSourcePrice((_payload$product_sku = payload.product_sku) !== null && _payload$product_sku !== void 0 ? _payload$product_sku : origin.product_sku, (_payload$_extend$weig = (_payload$_extend2 = payload._extend) === null || _payload$_extend2 === void 0 ? void 0 : _payload$_extend2.weighing) !== null && _payload$_extend$weig !== void 0 ? _payload$_extend$weig : (_origin$_extend = origin._extend) === null || _origin$_extend === void 0 ? void 0 : _origin$_extend.weighing);
194
+ var sourceProductPrice = toPriceString(weighedSourcePrice !== null && weighedSourcePrice !== void 0 ? weighedSourcePrice : hasPriceOverride ? (_ref23 = catalogSourcePrice !== null && catalogSourcePrice !== void 0 ? catalogSourcePrice : payload.price) !== null && _ref23 !== void 0 ? _ref23 : payload.selling_price : (_ref24 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref24 !== void 0 ? _ref24 : catalogSourcePrice, '0.00');
195
+ var explicitLineTotal = (_ref25 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref25 !== void 0 ? _ref25 : (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.total;
189
196
  var hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
190
197
  var lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
191
- var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref24 = (_ref25 = (_payload$product_sku$ = (_payload$product_sku = payload.product_sku) === null || _payload$product_sku === void 0 ? void 0 : _payload$product_sku.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref25 !== void 0 ? _ref25 : payload.options) !== null && _ref24 !== void 0 ? _ref24 : payload.product_option_item));
192
- var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride);
198
+ var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref26 = (_ref27 = (_payload$product_sku$ = (_payload$product_sku2 = payload.product_sku) === null || _payload$product_sku2 === void 0 ? void 0 : _payload$product_sku2.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref27 !== void 0 ? _ref27 : payload.options) !== null && _ref26 !== void 0 ? _ref26 : payload.product_option_item, hasPriceOverride || weighedSourcePrice !== undefined));
199
+ var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride, hasPriceOverride && weighedSourcePrice !== undefined);
193
200
  // `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
194
201
  // 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
195
202
  var uniqueIdentificationNumber = payload.unique_identification_number;
196
203
  var resolvedQuantity = toSafePositiveInt((_payload$quantity = payload.quantity) !== null && _payload$quantity !== void 0 ? _payload$quantity : payload.num, 1);
197
- var originTotal = resolveManualDiscountOriginTotal({
204
+ var originTotal = weighedSourcePrice !== undefined ? Number(composeLinePrice({
205
+ mainPrice: Number(weighedSourcePrice) + sumOptionUnitPrice(productOptionItem).toNumber(),
206
+ bundle: hasPriceOverride ? withOriginalBundleOptionPrices(productBundle) : productBundle,
207
+ useOriginalBundle: true
208
+ })) : resolveManualDiscountOriginTotal({
198
209
  originTotal: payload.origin_total,
199
- extendOriginTotal: (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.origin_total,
210
+ extendOriginTotal: (_payload$_extend4 = payload._extend) === null || _payload$_extend4 === void 0 ? void 0 : _payload$_extend4.origin_total,
200
211
  originExtendOriginTotal: origin === null || origin === void 0 || (_extend = origin._extend) === null || _extend === void 0 ? void 0 : _extend.origin_total,
201
212
  sourceExtendOriginTotal: sourceProduct === null || sourceProduct === void 0 || (_extend2 = sourceProduct._extend) === null || _extend2 === void 0 ? void 0 : _extend2.origin_total,
202
- catalogUnitPrice: (_ref26 = (_ref27 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref27 !== void 0 ? _ref27 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref26 !== void 0 ? _ref26 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
213
+ catalogUnitPrice: (_ref28 = (_ref29 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref29 !== void 0 ? _ref29 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref28 !== void 0 ? _ref28 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
203
214
  quantity: resolvedQuantity
204
215
  });
205
- var sellingTotal = Number((_ref28 = (_ref29 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref29 !== void 0 ? _ref29 : (_payload$_extend4 = payload._extend) === null || _payload$_extend4 === void 0 ? void 0 : _payload$_extend4.total) !== null && _ref28 !== void 0 ? _ref28 : lineCompositeTotal);
216
+ var sellingTotal = Number((_ref30 = (_ref31 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref31 !== void 0 ? _ref31 : (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.total) !== null && _ref30 !== void 0 ? _ref30 : lineCompositeTotal);
206
217
  var discountReason = resolveManualDiscountReasonFromSources({
207
218
  discountReason: payload.discount_reason,
208
- extendDiscountReason: (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.discount_reason,
219
+ extendDiscountReason: (_payload$_extend6 = payload._extend) === null || _payload$_extend6 === void 0 ? void 0 : _payload$_extend6.discount_reason,
209
220
  originExtendDiscountReason: origin === null || origin === void 0 || (_extend3 = origin._extend) === null || _extend3 === void 0 ? void 0 : _extend3.discount_reason
210
221
  });
211
222
  var lineOriginalPrice = hasPriceOverride && Number.isFinite(originTotal) ? toPriceString(originTotal) : lineCompositeTotal;
@@ -218,8 +229,8 @@ export function transformBaseProductToOrderProduct(params) {
218
229
  sellingTotal: Number.isFinite(sellingTotal) ? sellingTotal : Number(lineCompositeTotal),
219
230
  quantity: resolvedQuantity,
220
231
  message: discountReason,
221
- discountway: (_payload$_extend6 = payload._extend) === null || _payload$_extend6 === void 0 ? void 0 : _payload$_extend6.discountway,
222
- discount_per: (_payload$_extend7 = payload._extend) === null || _payload$_extend7 === void 0 ? void 0 : _payload$_extend7.discount_per
232
+ discountway: (_payload$_extend7 = payload._extend) === null || _payload$_extend7 === void 0 ? void 0 : _payload$_extend7.discountway,
233
+ discount_per: (_payload$_extend8 = payload._extend) === null || _payload$_extend8 === void 0 ? void 0 : _payload$_extend8.discount_per
223
234
  })) : payload.discount_list || [];
224
235
 
225
236
  // v2:source 不含 option;main_product_* 含 option(与 normalizeOrderProduct 一致)
@@ -281,13 +292,17 @@ export function transformBaseProductToOrderProduct(params) {
281
292
  // 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
282
293
  selling_price: lineCompositeTotal,
283
294
  original_price: lineOriginalPrice,
284
- tax_fee: toPriceString((_ref30 = (_ref31 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref31 !== void 0 ? _ref31 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref30 !== void 0 ? _ref30 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
285
- is_charge_tax: toNumber((_ref32 = (_ref33 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref33 !== void 0 ? _ref33 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref32 !== void 0 ? _ref32 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
295
+ tax_fee: toPriceString((_ref32 = (_ref33 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref33 !== void 0 ? _ref33 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref32 !== void 0 ? _ref32 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
296
+ is_charge_tax: toNumber((_ref34 = (_ref35 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref35 !== void 0 ? _ref35 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref34 !== void 0 ? _ref34 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
286
297
  metadata: metadata,
287
298
  note: payload.note != null ? String(payload.note) : '',
288
299
  product_title: productTitle,
289
300
  product_cover: firstNonBlank(matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.cover, sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover),
290
- _origin: _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
301
+ _origin: _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), weighedSourcePrice !== undefined && hasPriceOverride ? {
302
+ _extend: _objectSpread(_objectSpread({}, sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct._extend), {}, {
303
+ origin_total: originTotal
304
+ })
305
+ } : {}), {}, {
291
306
  callbackData: payload
292
307
  })
293
308
  });
@@ -4,9 +4,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  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; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  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); }
7
+ import { withOriginalBundleOptionPrices } from "../../modules/Order/utils/weighedProduct";
7
8
  import Decimal from 'decimal.js';
8
9
  import { composeLinePrice, createUuidV4, ensureProductSku, normalizeProductSkuOptions, resolveManualOverrideLineOriginalPrice, sumOptionUnitPrice } from "../../modules/Order/utils";
9
- import { ensureManualProductDiscountList } from "../../modules/Order/utils/manualProductDiscount";
10
+ import { ensureManualProductDiscountList, hasManualProductDiscountFlag } from "../../modules/Order/utils/manualProductDiscount";
10
11
 
11
12
  /**
12
13
  * 构建金额全为 0 的空 summary。
@@ -241,7 +242,7 @@ export function normalizeOrderProduct(product) {
241
242
  });
242
243
  var composedOriginalPrice = composeLinePrice({
243
244
  mainPrice: mainOriginalStr,
244
- bundle: normalizedBundle,
245
+ bundle: Number(productSku.open_sold_weight) === 1 && hasManualProductDiscountFlag(metadata) ? withOriginalBundleOptionPrices(normalizedBundle) : normalizedBundle,
245
246
  useOriginalBundle: true
246
247
  });
247
248
  var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
@@ -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 | 2 | 1 | 6 | 4 | 5 | 3;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -11,10 +11,11 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
11
11
  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; } } }; }
12
12
  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); }
13
13
  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; }
14
+ import { withOriginalBundleOptionPrices } from "../../modules/Order/utils/weighedProduct";
14
15
  import dayjs from 'dayjs';
15
16
  import Decimal from 'decimal.js';
16
17
  import { composeLinePrice, createUuidV4, ensureProductSku, getBundleSellingMagnitude, getProductSkuOptions, normalizeProductSkuOptions, resolveManualOverrideLineOriginalPrice, sumOptionUnitPrice } from "../../modules/Order/utils";
17
- import { ensureManualProductDiscountList } from "../../modules/Order/utils/manualProductDiscount";
18
+ import { ensureManualProductDiscountList, hasManualProductDiscountFlag } from "../../modules/Order/utils/manualProductDiscount";
18
19
 
19
20
  /**
20
21
  * 构建金额全为 0 的空 summary。
@@ -643,7 +644,7 @@ export function normalizeOrderProduct(product) {
643
644
  });
644
645
  var composedOriginalPrice = composeLinePrice({
645
646
  mainPrice: mainOriginalStr,
646
- bundle: normalizedBundle,
647
+ bundle: Number(productSku.open_sold_weight) === 1 && hasManualProductDiscountFlag(metadata) ? withOriginalBundleOptionPrices(normalizedBundle) : normalizedBundle,
647
648
  useOriginalBundle: true
648
649
  });
649
650
  var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
@@ -110,6 +110,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
110
110
  }>;
111
111
  applyDiscount(options?: {
112
112
  reapplyBookingDiscountProductUids?: string[];
113
+ reapplyWeighedDiscountProductUids?: string[];
113
114
  }): void;
114
115
  /**
115
116
  * 注入促销评估器。