@pisell/pisellos 2.3.127 → 2.3.129
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.
- package/dist/modules/Order/index.d.ts +2 -1
- package/dist/modules/Order/index.js +117 -58
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Order/utils/weighedProduct.js +94 -0
- package/dist/modules/Order/utils.js +6 -4
- package/dist/modules/Rules/index.js +4 -2
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/server/utils/small-ticket.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +2 -2
- package/dist/solution/BaseSales/index.js +75 -39
- package/dist/solution/BaseSales/types.d.ts +5 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Order/index.d.ts +2 -1
- package/lib/modules/Order/index.js +70 -10
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Order/utils/weighedProduct.js +89 -0
- package/lib/modules/Order/utils.js +3 -2
- package/lib/modules/Rules/index.js +4 -2
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +2 -2
- package/lib/solution/BaseSales/index.js +15 -6
- package/lib/solution/BaseSales/types.d.ts +5 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/package.json +1 -1
|
@@ -35,6 +35,8 @@ export interface RulesCalcDiscountOptions {
|
|
|
35
35
|
preserveEntitlementSelection?: boolean;
|
|
36
36
|
/** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
|
|
37
37
|
reapplyBookingDiscountProductUids?: string[];
|
|
38
|
+
/** Reweighed order lines only: reapply selected wallet discounts against their new amount. */
|
|
39
|
+
reapplyWeighedDiscountProductUids?: string[];
|
|
38
40
|
}
|
|
39
41
|
export interface RulesModuleAPI {
|
|
40
42
|
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';
|
|
@@ -451,7 +451,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
451
451
|
private findCashPaymentMethod;
|
|
452
452
|
private getPendingWalletPaymentAmount;
|
|
453
453
|
/** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
|
|
454
|
-
getCashPaymentConfig(): Promise<BaseSalesCashPaymentConfig>;
|
|
454
|
+
getCashPaymentConfig(options?: BaseSalesCashPaymentOptions): Promise<BaseSalesCashPaymentConfig>;
|
|
455
455
|
/**
|
|
456
456
|
* 确认足额覆盖订单的 pending Wallet 支付并提交订单。
|
|
457
457
|
*
|
|
@@ -5461,12 +5461,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5461
5461
|
}
|
|
5462
5462
|
}, {
|
|
5463
5463
|
key: "findCashPaymentMethod",
|
|
5464
|
-
value: function findCashPaymentMethod(paymentMethods) {
|
|
5464
|
+
value: function findCashPaymentMethod(paymentMethods, paymentMethodId) {
|
|
5465
5465
|
return paymentMethods.find(function (method) {
|
|
5466
|
+
if ((method === null || method === void 0 ? void 0 : method.enabled) === false || (method === null || method === void 0 ? void 0 : method.enable) === false) return false;
|
|
5466
5467
|
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) {
|
|
5467
5468
|
return String(value || '').toUpperCase();
|
|
5468
5469
|
});
|
|
5469
|
-
|
|
5470
|
+
var isDefaultCash = identifiers.includes('CASHMANUAL');
|
|
5471
|
+
if (paymentMethodId === undefined) return isDefaultCash;
|
|
5472
|
+
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) {
|
|
5473
|
+
return typeof name === 'string' && /现金|現金|cash/i.test(name);
|
|
5474
|
+
});
|
|
5475
|
+
return String(method === null || method === void 0 ? void 0 : method.id) === String(paymentMethodId) && (isDefaultCash || isCustomCash);
|
|
5470
5476
|
});
|
|
5471
5477
|
}
|
|
5472
5478
|
}, {
|
|
@@ -5492,28 +5498,43 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5492
5498
|
value: (function () {
|
|
5493
5499
|
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
|
|
5494
5500
|
var _this$store$order22, _this$store$order22$g, _this$store$order23, _this$store$order23$g, _this$otherParams34;
|
|
5495
|
-
var
|
|
5501
|
+
var options,
|
|
5502
|
+
paymentMethods,
|
|
5503
|
+
paymentMethod,
|
|
5504
|
+
amountSnapshot,
|
|
5505
|
+
pendingWalletAmount,
|
|
5506
|
+
amountDue,
|
|
5507
|
+
currency,
|
|
5508
|
+
recommendedAmounts,
|
|
5509
|
+
_args53 = arguments;
|
|
5496
5510
|
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5497
5511
|
while (1) switch (_context53.prev = _context53.next) {
|
|
5498
5512
|
case 0:
|
|
5513
|
+
options = _args53.length > 0 && _args53[0] !== undefined ? _args53[0] : {};
|
|
5499
5514
|
if (this.store.payment) {
|
|
5500
|
-
_context53.next =
|
|
5515
|
+
_context53.next = 3;
|
|
5501
5516
|
break;
|
|
5502
5517
|
}
|
|
5503
5518
|
throw new Error('payment 模块未初始化');
|
|
5504
|
-
case
|
|
5519
|
+
case 3:
|
|
5505
5520
|
paymentMethods = this.getPaymentMethods();
|
|
5506
|
-
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
5521
|
+
paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
|
|
5507
5522
|
if (paymentMethod) {
|
|
5508
|
-
_context53.next =
|
|
5523
|
+
_context53.next = 10;
|
|
5509
5524
|
break;
|
|
5510
5525
|
}
|
|
5511
|
-
_context53.next =
|
|
5526
|
+
_context53.next = 8;
|
|
5512
5527
|
return this.getPaymentMethodsAsync();
|
|
5513
|
-
case
|
|
5528
|
+
case 8:
|
|
5514
5529
|
paymentMethods = _context53.sent;
|
|
5515
|
-
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
5516
|
-
case
|
|
5530
|
+
paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
|
|
5531
|
+
case 10:
|
|
5532
|
+
if (!(!paymentMethod && options.paymentMethodId !== undefined)) {
|
|
5533
|
+
_context53.next = 12;
|
|
5534
|
+
break;
|
|
5535
|
+
}
|
|
5536
|
+
throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u73B0\u91D1\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(options.paymentMethodId));
|
|
5537
|
+
case 12:
|
|
5517
5538
|
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);
|
|
5518
5539
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
5519
5540
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
|
|
@@ -5525,7 +5546,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5525
5546
|
amountDue: amountDue,
|
|
5526
5547
|
recommendedAmounts: recommendedAmounts
|
|
5527
5548
|
});
|
|
5528
|
-
case
|
|
5549
|
+
case 18:
|
|
5529
5550
|
case "end":
|
|
5530
5551
|
return _context53.stop();
|
|
5531
5552
|
}
|
|
@@ -5690,31 +5711,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5690
5711
|
}
|
|
5691
5712
|
throw new Error('现金支付金额必须大于 0');
|
|
5692
5713
|
case 5:
|
|
5693
|
-
|
|
5714
|
+
if (!(params.paymentMethodId === undefined)) {
|
|
5715
|
+
_context55.next = 11;
|
|
5716
|
+
break;
|
|
5717
|
+
}
|
|
5718
|
+
_context55.next = 8;
|
|
5694
5719
|
return this.getCashPaymentConfig();
|
|
5695
|
-
case
|
|
5696
|
-
|
|
5720
|
+
case 8:
|
|
5721
|
+
_context55.t0 = _context55.sent;
|
|
5722
|
+
_context55.next = 14;
|
|
5723
|
+
break;
|
|
5724
|
+
case 11:
|
|
5725
|
+
_context55.next = 13;
|
|
5726
|
+
return this.getCashPaymentConfig({
|
|
5727
|
+
paymentMethodId: params.paymentMethodId
|
|
5728
|
+
});
|
|
5729
|
+
case 13:
|
|
5730
|
+
_context55.t0 = _context55.sent;
|
|
5731
|
+
case 14:
|
|
5732
|
+
config = _context55.t0;
|
|
5697
5733
|
paymentMethod = config.paymentMethod;
|
|
5698
5734
|
if (paymentMethod) {
|
|
5699
|
-
_context55.next =
|
|
5735
|
+
_context55.next = 18;
|
|
5700
5736
|
break;
|
|
5701
5737
|
}
|
|
5702
5738
|
throw new Error('未找到可用的 CASHMANUAL 支付方式');
|
|
5703
|
-
case
|
|
5739
|
+
case 18:
|
|
5704
5740
|
if (!(config.amountDue <= 0)) {
|
|
5705
|
-
_context55.next =
|
|
5741
|
+
_context55.next = 20;
|
|
5706
5742
|
break;
|
|
5707
5743
|
}
|
|
5708
5744
|
throw new Error('当前订单没有待支付金额');
|
|
5709
|
-
case
|
|
5745
|
+
case 20:
|
|
5710
5746
|
roundingAmount = Number(params.roundingAmount || 0);
|
|
5711
5747
|
effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
|
|
5712
5748
|
if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
|
|
5713
|
-
_context55.next =
|
|
5749
|
+
_context55.next = 24;
|
|
5714
5750
|
break;
|
|
5715
5751
|
}
|
|
5716
5752
|
throw new Error('现金支付金额超过当前待支付金额');
|
|
5717
|
-
case
|
|
5753
|
+
case 24:
|
|
5718
5754
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
5719
5755
|
beforePaymentStatus = (_this$store$order$get13 = this.store.order.getTempOrder()) === null || _this$store$order$get13 === void 0 ? void 0 : _this$store$order$get13.payment_status;
|
|
5720
5756
|
uniquePaymentNumber = createUuidV4();
|
|
@@ -5723,11 +5759,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5723
5759
|
changeAmount = Number(params.changeAmount || 0);
|
|
5724
5760
|
shopWalletPassId = (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.shop_wallet_pass_id;
|
|
5725
5761
|
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
5726
|
-
_context55.next =
|
|
5762
|
+
_context55.next = 33;
|
|
5727
5763
|
break;
|
|
5728
5764
|
}
|
|
5729
5765
|
throw new Error('顾客实收现金不能小于支付金额');
|
|
5730
|
-
case
|
|
5766
|
+
case 33:
|
|
5731
5767
|
(_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, {
|
|
5732
5768
|
module: 'till',
|
|
5733
5769
|
key: 'open_till',
|
|
@@ -5758,57 +5794,57 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5758
5794
|
var _item$metadata2;
|
|
5759
5795
|
return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
|
|
5760
5796
|
});
|
|
5761
|
-
_context55.prev =
|
|
5762
|
-
_context55.next =
|
|
5797
|
+
_context55.prev = 36;
|
|
5798
|
+
_context55.next = 39;
|
|
5763
5799
|
return this.syncPaymentsToOrder({
|
|
5764
5800
|
payments: payments,
|
|
5765
5801
|
submitWhenPaid: true,
|
|
5766
5802
|
smallTicketDataFlag: 1,
|
|
5767
5803
|
confirmPendingVoucherPayments: true
|
|
5768
5804
|
});
|
|
5769
|
-
case
|
|
5805
|
+
case 39:
|
|
5770
5806
|
syncResult = _context55.sent;
|
|
5771
5807
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
5772
|
-
_context55.next =
|
|
5808
|
+
_context55.next = 42;
|
|
5773
5809
|
break;
|
|
5774
5810
|
}
|
|
5775
5811
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
5776
|
-
case
|
|
5812
|
+
case 42:
|
|
5777
5813
|
if (!this.store.payment) {
|
|
5778
|
-
_context55.next =
|
|
5814
|
+
_context55.next = 47;
|
|
5779
5815
|
break;
|
|
5780
5816
|
}
|
|
5781
5817
|
committed = this.getCommittedWalletAssets();
|
|
5782
5818
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
5783
|
-
_context55.next =
|
|
5819
|
+
_context55.next = 47;
|
|
5784
5820
|
return this.publishWalletAssetsState(walletState, 'local');
|
|
5785
|
-
case
|
|
5821
|
+
case 47:
|
|
5786
5822
|
return _context55.abrupt("return", {
|
|
5787
5823
|
payment: payment || {},
|
|
5788
5824
|
payments: this.store.order.getOrderPayments(),
|
|
5789
5825
|
syncResult: syncResult,
|
|
5790
5826
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
5791
5827
|
});
|
|
5792
|
-
case
|
|
5793
|
-
_context55.prev =
|
|
5794
|
-
_context55.
|
|
5828
|
+
case 50:
|
|
5829
|
+
_context55.prev = 50;
|
|
5830
|
+
_context55.t1 = _context55["catch"](36);
|
|
5795
5831
|
this.store.order.setOrderPayments(beforePayments);
|
|
5796
5832
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
5797
5833
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
5798
5834
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
5799
5835
|
this.store.order.persistTempOrder();
|
|
5800
5836
|
}
|
|
5801
|
-
_context55.next =
|
|
5837
|
+
_context55.next = 57;
|
|
5802
5838
|
return this.store.order.recalculateSummary({
|
|
5803
5839
|
createIfMissing: true
|
|
5804
5840
|
});
|
|
5805
|
-
case
|
|
5806
|
-
throw _context55.
|
|
5807
|
-
case
|
|
5841
|
+
case 57:
|
|
5842
|
+
throw _context55.t1;
|
|
5843
|
+
case 58:
|
|
5808
5844
|
case "end":
|
|
5809
5845
|
return _context55.stop();
|
|
5810
5846
|
}
|
|
5811
|
-
}, _callee55, this, [[
|
|
5847
|
+
}, _callee55, this, [[36, 50]]);
|
|
5812
5848
|
}));
|
|
5813
5849
|
function payCash(_x44) {
|
|
5814
5850
|
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,
|
|
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 = (
|
|
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
|
|
123
|
-
|
|
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: (
|
|
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
|
|
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((
|
|
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((
|
|
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 = (
|
|
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
|
-
//
|
|
186
|
-
|
|
187
|
-
var
|
|
188
|
-
var
|
|
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((
|
|
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 =
|
|
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$
|
|
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: (
|
|
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((
|
|
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$
|
|
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$
|
|
222
|
-
discount_per: (_payload$
|
|
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((
|
|
285
|
-
is_charge_tax: toNumber((
|
|
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 |
|
|
329
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -346,7 +346,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
346
346
|
* 获取当前的客户搜索条件
|
|
347
347
|
* @returns 当前搜索条件
|
|
348
348
|
*/
|
|
349
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
349
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
350
350
|
/**
|
|
351
351
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
352
352
|
* @returns 客户状态
|
|
@@ -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({
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -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
|
preferredEntitlementPassIds?: number[];
|
|
114
115
|
}): void;
|
|
115
116
|
/**
|
|
@@ -584,7 +585,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
584
585
|
generateIdempotencyToken(): string;
|
|
585
586
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
586
587
|
createOrder(params: CommitOrderParams['query']): {
|
|
587
|
-
type: "
|
|
588
|
+
type: "appointment_booking" | "virtual";
|
|
588
589
|
platform: string;
|
|
589
590
|
sales_channel: string;
|
|
590
591
|
order_sales_channel: string;
|