@pisell/pisellos 2.3.36 → 2.3.38
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/core/index.d.ts +2 -0
- package/dist/core/index.js +7 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/OpenData/index.d.ts +2 -0
- package/dist/modules/OpenData/index.js +8 -0
- package/dist/modules/Order/index.js +21 -14
- package/dist/modules/Order/utils.js +2 -1
- package/dist/modules/Payment/index.js +1 -1
- package/dist/modules/Payment/types.d.ts +73 -4
- package/dist/modules/Payment/types.js +18 -3
- package/dist/modules/Payment/walletpass.d.ts +25 -1
- package/dist/modules/Payment/walletpass.js +707 -157
- package/dist/modules/Rules/index.d.ts +1 -0
- package/dist/modules/Rules/index.js +75 -49
- package/dist/server/index.js +28 -24
- package/dist/server/modules/order/index.d.ts +5 -0
- package/dist/server/modules/order/index.js +52 -31
- package/dist/solution/BaseSales/index.d.ts +77 -11
- package/dist/solution/BaseSales/index.js +1476 -434
- package/dist/solution/BaseSales/types.d.ts +52 -0
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +7 -3
- package/dist/solution/BookingTicket/index.js +130 -48
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +172 -82
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/VenueBooking/index.js +30 -19
- package/dist/types/index.d.ts +1 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +2 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/OpenData/index.d.ts +2 -0
- package/lib/modules/OpenData/index.js +5 -0
- package/lib/modules/Order/index.js +10 -4
- package/lib/modules/Order/utils.js +6 -1
- package/lib/modules/Payment/index.js +1 -1
- package/lib/modules/Payment/types.d.ts +73 -4
- package/lib/modules/Payment/types.js +4 -3
- package/lib/modules/Payment/walletpass.d.ts +25 -1
- package/lib/modules/Payment/walletpass.js +470 -21
- package/lib/modules/Rules/index.d.ts +1 -0
- package/lib/modules/Rules/index.js +30 -7
- package/lib/server/index.js +11 -8
- package/lib/server/modules/order/index.d.ts +5 -0
- package/lib/server/modules/order/index.js +24 -2
- package/lib/solution/BaseSales/index.d.ts +77 -11
- package/lib/solution/BaseSales/index.js +699 -41
- package/lib/solution/BaseSales/types.d.ts +52 -0
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +7 -3
- package/lib/solution/BookingTicket/index.js +60 -8
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +36 -4
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/VenueBooking/index.js +8 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -37,7 +37,7 @@ import Decimal from 'decimal.js';
|
|
|
37
37
|
import { cloneDeep, mergeWith } from 'lodash-es';
|
|
38
38
|
import { createModule } from "../BookingByStep/types";
|
|
39
39
|
import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
40
|
-
import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
|
|
40
|
+
import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
|
|
41
41
|
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
42
42
|
import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
|
|
43
43
|
import dayjs from 'dayjs';
|
|
@@ -46,6 +46,89 @@ import { QuotationModule } from "../../modules/Quotation";
|
|
|
46
46
|
import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
|
|
47
47
|
import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
|
|
48
48
|
var SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
|
|
49
|
+
var WALLET_PAYMENT_CODE_BY_TAG = {
|
|
50
|
+
product_voucher: 'PRODUCTVOUCHER',
|
|
51
|
+
gift_card: 'GIFTCARD',
|
|
52
|
+
point_card: 'POINTCARD'
|
|
53
|
+
};
|
|
54
|
+
function getSharedWalletAssetId(asset) {
|
|
55
|
+
var _ref, _asset$id;
|
|
56
|
+
return (_ref = (_asset$id = asset === null || asset === void 0 ? void 0 : asset.id) !== null && _asset$id !== void 0 ? _asset$id : asset === null || asset === void 0 ? void 0 : asset.voucher_id) !== null && _ref !== void 0 ? _ref : asset === null || asset === void 0 ? void 0 : asset.code;
|
|
57
|
+
}
|
|
58
|
+
function getSharedWalletAssetAmount(asset) {
|
|
59
|
+
var _ref2, _ref3, _ref4, _ref5, _asset$edit_current_a;
|
|
60
|
+
var value = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_asset$edit_current_a = asset === null || asset === void 0 ? void 0 : asset.edit_current_amount) !== null && _asset$edit_current_a !== void 0 ? _asset$edit_current_a : asset === null || asset === void 0 ? void 0 : asset._available_max_amount) !== null && _ref5 !== void 0 ? _ref5 : (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' ? asset === null || asset === void 0 ? void 0 : asset.recommended_usage_amount : asset === null || asset === void 0 ? void 0 : asset.available_max_amount) !== null && _ref4 !== void 0 ? _ref4 : asset === null || asset === void 0 ? void 0 : asset.actualDeduction) !== null && _ref3 !== void 0 ? _ref3 : asset === null || asset === void 0 ? void 0 : asset.amount) !== null && _ref2 !== void 0 ? _ref2 : 0;
|
|
61
|
+
var amount = Number(value);
|
|
62
|
+
return Number.isFinite(amount) && amount > 0 ? amount : 0;
|
|
63
|
+
}
|
|
64
|
+
function isRejectedSalesSubmitResult(result) {
|
|
65
|
+
var _result$response, _result$response2;
|
|
66
|
+
var candidates = [result, result === null || result === void 0 ? void 0 : result.data, result === null || result === void 0 || (_result$response = result.response) === null || _result$response === void 0 ? void 0 : _result$response.data, result === null || result === void 0 || (_result$response2 = result.response) === null || _result$response2 === void 0 ? void 0 : _result$response2.body];
|
|
67
|
+
return candidates.some(function (candidate) {
|
|
68
|
+
var _candidate$code;
|
|
69
|
+
if (!candidate || _typeof(candidate) !== 'object') return false;
|
|
70
|
+
var responseCode = Number((_candidate$code = candidate.code) !== null && _candidate$code !== void 0 ? _candidate$code : candidate.statusCode);
|
|
71
|
+
if (Number.isFinite(responseCode) && responseCode >= 400) return true;
|
|
72
|
+
if (candidate.status === false || candidate.success === false || candidate.result === false) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return ['failed', 'error'].includes(String(candidate.status || '').toLowerCase());
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function getSalesSubmitErrorMessage(result) {
|
|
79
|
+
var _result$data, _result$data2;
|
|
80
|
+
return (result === null || result === void 0 ? void 0 : result.message) || (result === null || result === void 0 ? void 0 : result.msg) || (result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.message) || (result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.msg) || 'Wallet 支付确认失败';
|
|
81
|
+
}
|
|
82
|
+
function toWalletFundValue(value) {
|
|
83
|
+
try {
|
|
84
|
+
return new Decimal(value || 0).toDecimalPlaces(2).toFixed(2);
|
|
85
|
+
} catch (_unused) {
|
|
86
|
+
return '0.00';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function subtractWalletFundValue(left, right) {
|
|
90
|
+
try {
|
|
91
|
+
return new Decimal(left || 0).minus(right || 0).toDecimalPlaces(2).toFixed(2);
|
|
92
|
+
} catch (_unused2) {
|
|
93
|
+
return '0.00';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function getSharedWalletPassUseValue(params) {
|
|
97
|
+
var asset = params.asset,
|
|
98
|
+
amount = params.amount,
|
|
99
|
+
paymentMethod = params.paymentMethod;
|
|
100
|
+
var configuredValue = Number(asset === null || asset === void 0 ? void 0 : asset.wallet_pass_use_value);
|
|
101
|
+
if (Number.isFinite(configuredValue) && configuredValue > 0) {
|
|
102
|
+
return configuredValue;
|
|
103
|
+
}
|
|
104
|
+
var isPointCard = (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' || paymentMethod.code === 'POINTCARD';
|
|
105
|
+
var usageUnit = asset === null || asset === void 0 ? void 0 : asset.wallet_pass_usage_unit;
|
|
106
|
+
if (isPointCard && usageUnit !== null && usageUnit !== void 0 && usageUnit.points && usageUnit !== null && usageUnit !== void 0 && usageUnit.price) {
|
|
107
|
+
return new Decimal(amount).div(usageUnit.price).mul(usageUnit.points).toDecimalPlaces(2, Decimal.ROUND_DOWN).toNumber();
|
|
108
|
+
}
|
|
109
|
+
return amount;
|
|
110
|
+
}
|
|
111
|
+
function buildSharedWalletFundRecord(params) {
|
|
112
|
+
var _ref6, _ref7, _asset$balance_par_va, _asset$voucher_id;
|
|
113
|
+
var asset = params.asset,
|
|
114
|
+
amount = params.amount,
|
|
115
|
+
paymentMethod = params.paymentMethod;
|
|
116
|
+
var isPointCard = (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' || paymentMethod.code === 'POINTCARD';
|
|
117
|
+
var usingBeforeValue = (_ref6 = (_ref7 = (_asset$balance_par_va = asset === null || asset === void 0 ? void 0 : asset.balance_par_value) !== null && _asset$balance_par_va !== void 0 ? _asset$balance_par_va : asset === null || asset === void 0 ? void 0 : asset.balance) !== null && _ref7 !== void 0 ? _ref7 : asset === null || asset === void 0 ? void 0 : asset.using_before_value) !== null && _ref6 !== void 0 ? _ref6 : 0;
|
|
118
|
+
var walletPassUseValue = getSharedWalletPassUseValue(params);
|
|
119
|
+
var usingValue = isPointCard ? walletPassUseValue : amount;
|
|
120
|
+
var walletPassName = (asset === null || asset === void 0 ? void 0 : asset.wallet_pass_name) || (asset === null || asset === void 0 ? void 0 : asset.format_title) || (asset === null || asset === void 0 ? void 0 : asset.product_name) || (asset === null || asset === void 0 ? void 0 : asset.name) || paymentMethod.name;
|
|
121
|
+
return {
|
|
122
|
+
voucher_id: (_asset$voucher_id = asset === null || asset === void 0 ? void 0 : asset.voucher_id) !== null && _asset$voucher_id !== void 0 ? _asset$voucher_id : asset === null || asset === void 0 ? void 0 : asset.id,
|
|
123
|
+
wallet_pass_name: walletPassName && _typeof(walletPassName) === 'object' ? walletPassName : {
|
|
124
|
+
default: walletPassName || ''
|
|
125
|
+
},
|
|
126
|
+
code: (asset === null || asset === void 0 ? void 0 : asset.code) || (asset === null || asset === void 0 ? void 0 : asset.tag),
|
|
127
|
+
encoded: asset === null || asset === void 0 ? void 0 : asset.encoded,
|
|
128
|
+
using_before_value: toWalletFundValue(usingBeforeValue),
|
|
129
|
+
using_after_value: subtractWalletFundValue(usingBeforeValue, usingValue)
|
|
130
|
+
};
|
|
131
|
+
}
|
|
49
132
|
function isBaseSalesManualProductDiscountProduct(product) {
|
|
50
133
|
var _product$metadata, _product$metadata2;
|
|
51
134
|
return (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_manual_discount) === true || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.is_manual_discount) === 1 || ((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (item) {
|
|
@@ -269,6 +352,22 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
269
352
|
delete mergedRecord.request_unique_idempotency_token;
|
|
270
353
|
return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
|
|
271
354
|
}
|
|
355
|
+
function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
|
|
356
|
+
if (!sourceRecord || _typeof(sourceRecord) !== 'object') return sourceRecord;
|
|
357
|
+
var record = _objectSpread({}, sourceRecord);
|
|
358
|
+
if (Array.isArray(sourceRecord.payments)) {
|
|
359
|
+
record.payments = sourceRecord.payments.filter(function (payment) {
|
|
360
|
+
return !isPendingOrderPayment(payment);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
// 兼容少量历史详情数据使用的单数 payment 字段。
|
|
364
|
+
if (Array.isArray(sourceRecord.payment)) {
|
|
365
|
+
record.payment = sourceRecord.payment.filter(function (payment) {
|
|
366
|
+
return !isPendingOrderPayment(payment);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
return record;
|
|
370
|
+
}
|
|
272
371
|
export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
273
372
|
_inherits(BaseSalesImpl, _BaseModule);
|
|
274
373
|
var _super = _createSuper(BaseSalesImpl);
|
|
@@ -288,6 +387,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
288
387
|
});
|
|
289
388
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
290
389
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
390
|
+
/**
|
|
391
|
+
* 由已在初始化阶段解析过设备短号的业务解决方案写入。
|
|
392
|
+
* 未设置时,支付编号仍按原逻辑实时读取设备信息。
|
|
393
|
+
*/
|
|
394
|
+
_defineProperty(_assertThisInitialized(_this), "paymentNumberDevicePrefix", null);
|
|
291
395
|
/**
|
|
292
396
|
* window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
|
|
293
397
|
* `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
|
|
@@ -305,6 +409,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
305
409
|
_defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
|
|
306
410
|
_defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlightCount", 0);
|
|
307
411
|
_defineProperty(_assertThisInitialized(_this), "salesDetailLoadSequence", 0);
|
|
412
|
+
_defineProperty(_assertThisInitialized(_this), "walletAssetsRefreshSequence", 0);
|
|
308
413
|
_defineProperty(_assertThisInitialized(_this), "salesDetailHydrateQueue", Promise.resolve());
|
|
309
414
|
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
|
|
310
415
|
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
|
|
@@ -497,12 +602,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
497
602
|
return _context3.abrupt("return");
|
|
498
603
|
case 14:
|
|
499
604
|
this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
500
|
-
var _getTempOrder,
|
|
605
|
+
var _getTempOrder, _ref9;
|
|
501
606
|
var currentTempOrder, record, sales;
|
|
502
607
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
503
608
|
while (1) switch (_context2.prev = _context2.next) {
|
|
504
609
|
case 0:
|
|
505
|
-
currentTempOrder = (_getTempOrder = (
|
|
610
|
+
currentTempOrder = (_getTempOrder = (_ref9 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref9);
|
|
506
611
|
record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder, 'authoritative-incoming');
|
|
507
612
|
_context2.next = 4;
|
|
508
613
|
return _this2.store.order.hydrateTempOrderFromRecord(record, {
|
|
@@ -571,7 +676,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
571
676
|
hydratedSales = null;
|
|
572
677
|
skippedBeforeHydrate = false;
|
|
573
678
|
hydrateTask = /*#__PURE__*/function () {
|
|
574
|
-
var
|
|
679
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
575
680
|
var sales;
|
|
576
681
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
577
682
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -616,7 +721,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
616
721
|
}, _callee4);
|
|
617
722
|
}));
|
|
618
723
|
return function hydrateTask() {
|
|
619
|
-
return
|
|
724
|
+
return _ref10.apply(this, arguments);
|
|
620
725
|
};
|
|
621
726
|
}();
|
|
622
727
|
queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
|
|
@@ -710,10 +815,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
710
815
|
});
|
|
711
816
|
}
|
|
712
817
|
quotation.setScheduleResolver(function (id) {
|
|
713
|
-
var _scheduleModule$getSc, _getScheduleByIds,
|
|
818
|
+
var _scheduleModule$getSc, _getScheduleByIds, _ref11;
|
|
714
819
|
var scheduleId = String(id);
|
|
715
820
|
if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
|
|
716
|
-
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (
|
|
821
|
+
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref11 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref11, [id])) || [];
|
|
717
822
|
if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
|
|
718
823
|
return schedules[0];
|
|
719
824
|
});
|
|
@@ -900,10 +1005,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
900
1005
|
return groups.flatMap(function (group) {
|
|
901
1006
|
var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
|
|
902
1007
|
return items.map(function (item) {
|
|
903
|
-
var _item$group_id,
|
|
1008
|
+
var _item$group_id, _ref12, _item$bundle_group_id;
|
|
904
1009
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
905
1010
|
group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
|
|
906
|
-
bundle_group_id: (
|
|
1011
|
+
bundle_group_id: (_ref12 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref12 !== void 0 ? _ref12 : group === null || group === void 0 ? void 0 : group.id
|
|
907
1012
|
});
|
|
908
1013
|
});
|
|
909
1014
|
});
|
|
@@ -934,21 +1039,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
934
1039
|
}, {
|
|
935
1040
|
key: "getAuthoritativeBundleUnitPrice",
|
|
936
1041
|
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
937
|
-
var
|
|
938
|
-
return (
|
|
1042
|
+
var _ref13, _ref14, _ref15, _bundle$price;
|
|
1043
|
+
return (_ref13 = (_ref14 = (_ref15 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref15 !== void 0 ? _ref15 : bundle.custom_price) !== null && _ref14 !== void 0 ? _ref14 : bundle.product_price) !== null && _ref13 !== void 0 ? _ref13 : bundle.base_price;
|
|
939
1044
|
}
|
|
940
1045
|
}, {
|
|
941
1046
|
key: "mergeProductForPriceQuery",
|
|
942
1047
|
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
943
1048
|
var _this5 = this,
|
|
944
1049
|
_product$id,
|
|
945
|
-
|
|
1050
|
+
_ref16,
|
|
946
1051
|
_product$product_id2,
|
|
947
|
-
|
|
1052
|
+
_ref17,
|
|
948
1053
|
_product$product_vari,
|
|
949
|
-
|
|
1054
|
+
_ref18,
|
|
950
1055
|
_product$num,
|
|
951
|
-
|
|
1056
|
+
_ref19,
|
|
952
1057
|
_product$quantity,
|
|
953
1058
|
_product$metadata4;
|
|
954
1059
|
if (!authoritativeProduct) return product;
|
|
@@ -968,10 +1073,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
968
1073
|
});
|
|
969
1074
|
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
970
1075
|
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
971
|
-
product_id: (
|
|
972
|
-
product_variant_id: (
|
|
973
|
-
num: (
|
|
974
|
-
quantity: (
|
|
1076
|
+
product_id: (_ref16 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref16 !== void 0 ? _ref16 : authoritativeProduct.id,
|
|
1077
|
+
product_variant_id: (_ref17 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref17 !== void 0 ? _ref17 : 0,
|
|
1078
|
+
num: (_ref18 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref18 !== void 0 ? _ref18 : authoritativeProduct.num,
|
|
1079
|
+
quantity: (_ref19 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref19 !== void 0 ? _ref19 : authoritativeProduct.quantity,
|
|
975
1080
|
product_sku: function () {
|
|
976
1081
|
var authoritativeSku = ensureProductSku(authoritativeProduct);
|
|
977
1082
|
var productSku = ensureProductSku(product);
|
|
@@ -1047,24 +1152,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1047
1152
|
value: (function () {
|
|
1048
1153
|
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
|
|
1049
1154
|
var _this6 = this;
|
|
1050
|
-
var
|
|
1051
|
-
|
|
1155
|
+
var _ref20,
|
|
1156
|
+
_ref20$cover,
|
|
1052
1157
|
cover,
|
|
1053
1158
|
nextSubModuleOtherParams,
|
|
1054
1159
|
_args10 = arguments;
|
|
1055
1160
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1056
1161
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1057
1162
|
case 0:
|
|
1058
|
-
|
|
1163
|
+
_ref20 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref20$cover = _ref20.cover, cover = _ref20$cover === void 0 ? false : _ref20$cover;
|
|
1059
1164
|
nextSubModuleOtherParams = this.buildSubModuleOtherParams();
|
|
1060
1165
|
_context10.next = 4;
|
|
1061
1166
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
1062
|
-
var
|
|
1063
|
-
var
|
|
1167
|
+
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref21) {
|
|
1168
|
+
var _ref23, moduleName, subModule, targetModule;
|
|
1064
1169
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1065
1170
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1066
1171
|
case 0:
|
|
1067
|
-
|
|
1172
|
+
_ref23 = _slicedToArray(_ref21, 2), moduleName = _ref23[0], subModule = _ref23[1];
|
|
1068
1173
|
if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
|
|
1069
1174
|
_context9.next = 3;
|
|
1070
1175
|
break;
|
|
@@ -1090,7 +1195,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1090
1195
|
}, _callee9);
|
|
1091
1196
|
}));
|
|
1092
1197
|
return function (_x9) {
|
|
1093
|
-
return
|
|
1198
|
+
return _ref22.apply(this, arguments);
|
|
1094
1199
|
};
|
|
1095
1200
|
}()));
|
|
1096
1201
|
case 4:
|
|
@@ -1118,7 +1223,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1118
1223
|
if (!sessionData) return {};
|
|
1119
1224
|
var data = JSON.parse(sessionData);
|
|
1120
1225
|
return data && data[this.cacheId] || {};
|
|
1121
|
-
} catch (
|
|
1226
|
+
} catch (_unused3) {
|
|
1122
1227
|
return {};
|
|
1123
1228
|
}
|
|
1124
1229
|
}
|
|
@@ -1132,6 +1237,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1132
1237
|
var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
|
|
1133
1238
|
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1134
1239
|
}
|
|
1240
|
+
|
|
1241
|
+
/**
|
|
1242
|
+
* 复用业务解决方案初始化时已解析的支付设备短号。
|
|
1243
|
+
* 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
|
|
1244
|
+
*/
|
|
1245
|
+
}, {
|
|
1246
|
+
key: "setPaymentNumberDevicePrefix",
|
|
1247
|
+
value: function setPaymentNumberDevicePrefix(prefix) {
|
|
1248
|
+
var normalized = String(prefix !== null && prefix !== void 0 ? prefix : '').trim();
|
|
1249
|
+
this.paymentNumberDevicePrefix = normalized || null;
|
|
1250
|
+
}
|
|
1135
1251
|
}, {
|
|
1136
1252
|
key: "getPaymentNumberDevicePrefixSync",
|
|
1137
1253
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
@@ -1146,6 +1262,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1146
1262
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1147
1263
|
var _this8 = this;
|
|
1148
1264
|
if (!this.appPlugin) return Promise.resolve('LOCAL');
|
|
1265
|
+
if (this.paymentNumberDevicePrefix) {
|
|
1266
|
+
return Promise.resolve(this.paymentNumberDevicePrefix);
|
|
1267
|
+
}
|
|
1149
1268
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1150
1269
|
return _this8.getAppData(key);
|
|
1151
1270
|
});
|
|
@@ -1206,6 +1325,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1206
1325
|
options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
1207
1326
|
this.core = core;
|
|
1208
1327
|
this.initializeOptions = options || {};
|
|
1328
|
+
this.paymentNumberDevicePrefix = null;
|
|
1209
1329
|
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
1210
1330
|
this.otherParams = options.otherParams || {};
|
|
1211
1331
|
this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
|
|
@@ -1216,11 +1336,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1216
1336
|
// 获取 logger 实例
|
|
1217
1337
|
this.appPlugin = core.getPlugin('app');
|
|
1218
1338
|
if (this.appPlugin) {
|
|
1219
|
-
_context11.next =
|
|
1339
|
+
_context11.next = 12;
|
|
1220
1340
|
break;
|
|
1221
1341
|
}
|
|
1222
1342
|
throw new Error('Checkout 解决方案需要 app 插件支持');
|
|
1223
|
-
case
|
|
1343
|
+
case 12:
|
|
1224
1344
|
app = this.appPlugin.getApp();
|
|
1225
1345
|
this.logger = app.logger;
|
|
1226
1346
|
targetCacheData = this.readSessionCacheData();
|
|
@@ -1247,21 +1367,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1247
1367
|
}));
|
|
1248
1368
|
});
|
|
1249
1369
|
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
1250
|
-
_context11.next =
|
|
1370
|
+
_context11.next = 20;
|
|
1251
1371
|
break;
|
|
1252
1372
|
}
|
|
1253
|
-
_context11.next =
|
|
1373
|
+
_context11.next = 20;
|
|
1254
1374
|
return this.store.schedule.loadAllSchedule();
|
|
1255
|
-
case
|
|
1375
|
+
case 20:
|
|
1256
1376
|
if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
|
|
1257
1377
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
1258
1378
|
}
|
|
1259
|
-
_context11.next =
|
|
1379
|
+
_context11.next = 23;
|
|
1260
1380
|
return this.getPaymentMethodsAsync();
|
|
1261
|
-
case
|
|
1381
|
+
case 23:
|
|
1262
1382
|
this.registerServerOrderChangeSync();
|
|
1263
1383
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
1264
|
-
case
|
|
1384
|
+
case 25:
|
|
1265
1385
|
case "end":
|
|
1266
1386
|
return _context11.stop();
|
|
1267
1387
|
}
|
|
@@ -1295,13 +1415,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1295
1415
|
}
|
|
1296
1416
|
});
|
|
1297
1417
|
this.currentSalesDetail = null;
|
|
1418
|
+
this.paymentNumberDevicePrefix = null;
|
|
1298
1419
|
this.queuedServerOrderChanges = [];
|
|
1299
1420
|
this.salesDetailLoadSequence += 1;
|
|
1300
|
-
|
|
1421
|
+
this.walletAssetsRefreshSequence += 1;
|
|
1422
|
+
_context12.next = 10;
|
|
1301
1423
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
1302
|
-
case
|
|
1424
|
+
case 10:
|
|
1303
1425
|
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
1304
|
-
case
|
|
1426
|
+
case 11:
|
|
1305
1427
|
case "end":
|
|
1306
1428
|
return _context12.stop();
|
|
1307
1429
|
}
|
|
@@ -1323,7 +1445,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1323
1445
|
key: "loadSalesDetail",
|
|
1324
1446
|
value: (function () {
|
|
1325
1447
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
|
|
1326
|
-
var loadSequence,
|
|
1448
|
+
var loadSequence, _ref24, _ref25, _ref26, _ref27, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, mergedRecord, record;
|
|
1327
1449
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1328
1450
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1329
1451
|
case 0:
|
|
@@ -1341,7 +1463,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1341
1463
|
};
|
|
1342
1464
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
1343
1465
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1344
|
-
lookup = (
|
|
1466
|
+
lookup = (_ref24 = (_ref25 = (_ref26 = (_ref27 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref27 !== void 0 ? _ref27 : params.orderNumber) !== null && _ref26 !== void 0 ? _ref26 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref25 !== void 0 ? _ref25 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref24 !== void 0 ? _ref24 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1345
1467
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1346
1468
|
_context13.next = 11;
|
|
1347
1469
|
break;
|
|
@@ -1372,39 +1494,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1372
1494
|
message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
|
|
1373
1495
|
throw new Error(message);
|
|
1374
1496
|
case 22:
|
|
1375
|
-
remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
|
|
1497
|
+
remoteRecord = filterPendingPaymentsFromLoadedSalesDetail(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data);
|
|
1376
1498
|
currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1377
|
-
|
|
1378
|
-
|
|
1499
|
+
mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
|
|
1500
|
+
record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
|
|
1501
|
+
_context13.next = 28;
|
|
1379
1502
|
return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
|
|
1380
|
-
case 27:
|
|
1381
|
-
return _context13.abrupt("return", _context13.sent);
|
|
1382
1503
|
case 28:
|
|
1383
|
-
_context13.
|
|
1504
|
+
return _context13.abrupt("return", _context13.sent);
|
|
1505
|
+
case 29:
|
|
1506
|
+
_context13.prev = 29;
|
|
1384
1507
|
this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
|
|
1385
1508
|
if (!(this.salesDetailLoadInFlightCount === 0)) {
|
|
1386
|
-
_context13.next =
|
|
1509
|
+
_context13.next = 40;
|
|
1387
1510
|
break;
|
|
1388
1511
|
}
|
|
1389
|
-
_context13.prev =
|
|
1390
|
-
_context13.next =
|
|
1512
|
+
_context13.prev = 32;
|
|
1513
|
+
_context13.next = 35;
|
|
1391
1514
|
return this.drainQueuedServerOrderChanges();
|
|
1392
|
-
case
|
|
1393
|
-
_context13.next =
|
|
1515
|
+
case 35:
|
|
1516
|
+
_context13.next = 40;
|
|
1394
1517
|
break;
|
|
1395
|
-
case
|
|
1396
|
-
_context13.prev =
|
|
1397
|
-
_context13.t1 = _context13["catch"](
|
|
1518
|
+
case 37:
|
|
1519
|
+
_context13.prev = 37;
|
|
1520
|
+
_context13.t1 = _context13["catch"](32);
|
|
1398
1521
|
this.logError('drain queued server order changes failed', {
|
|
1399
1522
|
error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
|
|
1400
1523
|
});
|
|
1401
|
-
case 39:
|
|
1402
|
-
return _context13.finish(28);
|
|
1403
1524
|
case 40:
|
|
1525
|
+
return _context13.finish(29);
|
|
1526
|
+
case 41:
|
|
1404
1527
|
case "end":
|
|
1405
1528
|
return _context13.stop();
|
|
1406
1529
|
}
|
|
1407
|
-
}, _callee13, this, [[4,,
|
|
1530
|
+
}, _callee13, this, [[4,, 29, 41], [32, 37]]);
|
|
1408
1531
|
}));
|
|
1409
1532
|
function loadSalesDetail(_x11) {
|
|
1410
1533
|
return _loadSalesDetail.apply(this, arguments);
|
|
@@ -1681,7 +1804,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1681
1804
|
key: "restoreOrder",
|
|
1682
1805
|
value: function () {
|
|
1683
1806
|
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1684
|
-
var tempOrder;
|
|
1807
|
+
var _this$store$payment, tempOrder, wallet;
|
|
1685
1808
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1686
1809
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1687
1810
|
case 0:
|
|
@@ -1697,29 +1820,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1697
1820
|
this.currentSalesDetail = null;
|
|
1698
1821
|
this.discountConfigCacheKey = null;
|
|
1699
1822
|
this.hasManualDiscountSelection = false;
|
|
1700
|
-
|
|
1823
|
+
wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
|
|
1824
|
+
if (!wallet) {
|
|
1825
|
+
_context17.next = 13;
|
|
1826
|
+
break;
|
|
1827
|
+
}
|
|
1828
|
+
this.walletAssetsRefreshSequence += 1;
|
|
1829
|
+
wallet.clearAllCache();
|
|
1830
|
+
_context17.next = 13;
|
|
1831
|
+
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
1832
|
+
case 13:
|
|
1833
|
+
_context17.next = 15;
|
|
1701
1834
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1702
1835
|
tempOrder: tempOrder
|
|
1703
1836
|
});
|
|
1704
|
-
case
|
|
1837
|
+
case 15:
|
|
1705
1838
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1706
|
-
_context17.next =
|
|
1839
|
+
_context17.next = 19;
|
|
1707
1840
|
break;
|
|
1708
1841
|
}
|
|
1709
1842
|
this.store.order.persistTempOrder();
|
|
1710
|
-
_context17.next =
|
|
1843
|
+
_context17.next = 19;
|
|
1711
1844
|
return this.store.order.saveDraft();
|
|
1712
|
-
case
|
|
1845
|
+
case 19:
|
|
1713
1846
|
return _context17.abrupt("return", tempOrder);
|
|
1714
|
-
case
|
|
1715
|
-
_context17.prev =
|
|
1847
|
+
case 22:
|
|
1848
|
+
_context17.prev = 22;
|
|
1716
1849
|
_context17.t0 = _context17["catch"](0);
|
|
1717
1850
|
throw _context17.t0;
|
|
1718
|
-
case
|
|
1851
|
+
case 25:
|
|
1719
1852
|
case "end":
|
|
1720
1853
|
return _context17.stop();
|
|
1721
1854
|
}
|
|
1722
|
-
}, _callee17, this, [[0,
|
|
1855
|
+
}, _callee17, this, [[0, 22]]);
|
|
1723
1856
|
}));
|
|
1724
1857
|
function restoreOrder() {
|
|
1725
1858
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -2478,10 +2611,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2478
2611
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
2479
2612
|
if (Array.isArray(product.product_bundle)) {
|
|
2480
2613
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
2481
|
-
var
|
|
2614
|
+
var _ref28, _bundle$original_pric;
|
|
2482
2615
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
2483
2616
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
2484
|
-
var restoredBundlePrice = (
|
|
2617
|
+
var restoredBundlePrice = (_ref28 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref28 !== void 0 ? _ref28 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
2485
2618
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
2486
2619
|
price: restoredBundlePrice,
|
|
2487
2620
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -2705,7 +2838,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2705
2838
|
key: "saveSalesOrderDraft",
|
|
2706
2839
|
value: function () {
|
|
2707
2840
|
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2708
|
-
var _params$platform, _this$otherParams10,
|
|
2841
|
+
var _params$platform, _this$otherParams10, _this$otherParams11, _this$otherParams12, _params$channel, _params$type, _this$otherParams13;
|
|
2709
2842
|
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2710
2843
|
while (1) switch (_context28.prev = _context28.next) {
|
|
2711
2844
|
case 0:
|
|
@@ -2718,7 +2851,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2718
2851
|
return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
|
|
2719
2852
|
cacheId: this.cacheId,
|
|
2720
2853
|
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
|
|
2721
|
-
businessCode: (
|
|
2854
|
+
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code),
|
|
2722
2855
|
channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
|
|
2723
2856
|
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
|
|
2724
2857
|
}, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
@@ -2856,7 +2989,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2856
2989
|
if (!amountSnapshot) return undefined;
|
|
2857
2990
|
try {
|
|
2858
2991
|
return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
|
|
2859
|
-
} catch (
|
|
2992
|
+
} catch (_unused4) {
|
|
2860
2993
|
return undefined;
|
|
2861
2994
|
}
|
|
2862
2995
|
}
|
|
@@ -2864,7 +2997,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2864
2997
|
key: "syncPaymentsToOrder",
|
|
2865
2998
|
value: function () {
|
|
2866
2999
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
2867
|
-
var
|
|
3000
|
+
var _ref29, _params$businessCode, _this$otherParams22, _this$otherParams23, _params$channel2;
|
|
2868
3001
|
var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
2869
3002
|
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2870
3003
|
while (1) switch (_context31.prev = _context31.next) {
|
|
@@ -2875,7 +3008,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2875
3008
|
}
|
|
2876
3009
|
throw new Error('order 模块未初始化');
|
|
2877
3010
|
case 2:
|
|
2878
|
-
businessCode = (
|
|
3011
|
+
businessCode = (_ref29 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode) !== null && _ref29 !== void 0 ? _ref29 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.business_code;
|
|
2879
3012
|
channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
|
|
2880
3013
|
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
|
|
2881
3014
|
businessCode: businessCode
|
|
@@ -3089,7 +3222,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3089
3222
|
return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
|
|
3090
3223
|
}
|
|
3091
3224
|
|
|
3092
|
-
/**
|
|
3225
|
+
/**
|
|
3226
|
+
* 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
|
|
3227
|
+
* 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
|
|
3228
|
+
*/
|
|
3093
3229
|
}, {
|
|
3094
3230
|
key: "addOrderPaymentAsync",
|
|
3095
3231
|
value: (function () {
|
|
@@ -3132,7 +3268,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3132
3268
|
var _this$otherParams24,
|
|
3133
3269
|
_paymentRecord$paymen,
|
|
3134
3270
|
_paymentRecord$create,
|
|
3135
|
-
|
|
3271
|
+
_ref30,
|
|
3136
3272
|
_paymentRecord$origin,
|
|
3137
3273
|
_this14 = this;
|
|
3138
3274
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
@@ -3154,7 +3290,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3154
3290
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
3155
3291
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
3156
3292
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
3157
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
3293
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref30 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref30 !== void 0 ? _ref30 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
3158
3294
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
|
|
3159
3295
|
service_fee: calculatedServiceFee
|
|
3160
3296
|
} : {}), {}, {
|
|
@@ -3357,7 +3493,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3357
3493
|
key: "confirmPendingVoucherPayments",
|
|
3358
3494
|
value: function confirmPendingVoucherPayments() {
|
|
3359
3495
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3360
|
-
|
|
3496
|
+
var payments = this.store.order.confirmPendingVoucherPayments();
|
|
3497
|
+
if (this.store.payment) {
|
|
3498
|
+
var committed = this.getCommittedWalletAssets();
|
|
3499
|
+
var state = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
3500
|
+
void this.publishWalletAssetsState(state);
|
|
3501
|
+
}
|
|
3502
|
+
return payments;
|
|
3361
3503
|
}
|
|
3362
3504
|
}, {
|
|
3363
3505
|
key: "discardPendingVoucherPayments",
|
|
@@ -3426,12 +3568,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3426
3568
|
});
|
|
3427
3569
|
return walletProducts;
|
|
3428
3570
|
}
|
|
3571
|
+
}, {
|
|
3572
|
+
key: "buildWalletInitBusinessData",
|
|
3573
|
+
value: function buildWalletInitBusinessData(params) {
|
|
3574
|
+
var _this$store$order8, _params$order_wait_pa, _ref31, _tempOrder$is_price_i;
|
|
3575
|
+
var snapshot = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getOrderSnapshot();
|
|
3576
|
+
var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
3577
|
+
var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
3578
|
+
if (!tempOrder || !amount) return null;
|
|
3579
|
+
return _objectSpread({
|
|
3580
|
+
customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : undefined,
|
|
3581
|
+
holder: tempOrder.holder,
|
|
3582
|
+
amountInfo: {
|
|
3583
|
+
totalAmount: amount.totalAmount,
|
|
3584
|
+
subTotal: amount.summary.product_amount || amount.summary.product_expect_amount || amount.totalAmount,
|
|
3585
|
+
depositAmount: amount.depositAmount,
|
|
3586
|
+
isDeposit: tempOrder.is_deposit
|
|
3587
|
+
},
|
|
3588
|
+
products: this.getWalletProductList(),
|
|
3589
|
+
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
3590
|
+
is_price_include_tax: (_ref31 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref31 !== void 0 ? _ref31 : 1
|
|
3591
|
+
}, snapshot.identity.orderId ? {
|
|
3592
|
+
payment_order_id: String(snapshot.identity.orderId)
|
|
3593
|
+
} : {});
|
|
3594
|
+
}
|
|
3429
3595
|
}, {
|
|
3430
3596
|
key: "initWalletData",
|
|
3431
3597
|
value: function () {
|
|
3432
3598
|
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
3433
|
-
var
|
|
3434
|
-
var snapshot,
|
|
3599
|
+
var _snapshot$identity;
|
|
3600
|
+
var snapshot, walletBusinessData, result;
|
|
3435
3601
|
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3436
3602
|
while (1) switch (_context36.prev = _context36.next) {
|
|
3437
3603
|
case 0:
|
|
@@ -3448,10 +3614,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3448
3614
|
throw new Error('payment 模块未初始化');
|
|
3449
3615
|
case 4:
|
|
3450
3616
|
snapshot = this.store.order.getOrderSnapshot();
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
_context36.next = 9;
|
|
3617
|
+
walletBusinessData = this.buildWalletInitBusinessData(params);
|
|
3618
|
+
if (walletBusinessData) {
|
|
3619
|
+
_context36.next = 8;
|
|
3455
3620
|
break;
|
|
3456
3621
|
}
|
|
3457
3622
|
return _context36.abrupt("return", {
|
|
@@ -3461,29 +3626,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3461
3626
|
noApplicableVoucher: [],
|
|
3462
3627
|
products: []
|
|
3463
3628
|
});
|
|
3464
|
-
case
|
|
3465
|
-
|
|
3466
|
-
customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : undefined,
|
|
3467
|
-
holder: tempOrder.holder,
|
|
3468
|
-
amountInfo: {
|
|
3469
|
-
totalAmount: amount.totalAmount,
|
|
3470
|
-
subTotal: amount.summary.product_amount || amount.summary.product_expect_amount || amount.totalAmount,
|
|
3471
|
-
depositAmount: amount.depositAmount,
|
|
3472
|
-
isDeposit: tempOrder.is_deposit
|
|
3473
|
-
},
|
|
3474
|
-
products: this.getWalletProductList(),
|
|
3475
|
-
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
3476
|
-
is_price_include_tax: (_ref25 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref25 !== void 0 ? _ref25 : 1
|
|
3477
|
-
}, snapshot.identity.orderId ? {
|
|
3478
|
-
payment_order_id: String(snapshot.identity.orderId)
|
|
3479
|
-
} : {});
|
|
3480
|
-
_context36.next = 12;
|
|
3629
|
+
case 8:
|
|
3630
|
+
_context36.next = 10;
|
|
3481
3631
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
3482
|
-
case
|
|
3632
|
+
case 10:
|
|
3483
3633
|
result = _context36.sent;
|
|
3484
|
-
_context36.next =
|
|
3634
|
+
_context36.next = 13;
|
|
3485
3635
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
3486
|
-
orderId: snapshot.identity.orderId,
|
|
3636
|
+
orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
|
|
3487
3637
|
customerId: walletBusinessData.customer_id,
|
|
3488
3638
|
walletBusinessData: {
|
|
3489
3639
|
customer_id: walletBusinessData.customer_id,
|
|
@@ -3492,9 +3642,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3492
3642
|
},
|
|
3493
3643
|
timestamp: Date.now()
|
|
3494
3644
|
});
|
|
3495
|
-
case
|
|
3645
|
+
case 13:
|
|
3496
3646
|
return _context36.abrupt("return", result);
|
|
3497
|
-
case
|
|
3647
|
+
case 14:
|
|
3498
3648
|
case "end":
|
|
3499
3649
|
return _context36.stop();
|
|
3500
3650
|
}
|
|
@@ -3505,232 +3655,1124 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3505
3655
|
}
|
|
3506
3656
|
return initWalletData;
|
|
3507
3657
|
}()
|
|
3508
|
-
/**
|
|
3509
|
-
* 更新当前订单客户字段。
|
|
3510
|
-
*
|
|
3511
|
-
* 这是 PaymentModal 客户切换的订单事实入口;外部客户模块同步应由
|
|
3512
|
-
* 调用方通过 onCustomerChange 回调完成。
|
|
3513
|
-
*/
|
|
3514
3658
|
}, {
|
|
3515
|
-
key: "
|
|
3516
|
-
value: function
|
|
3517
|
-
|
|
3518
|
-
var
|
|
3519
|
-
|
|
3520
|
-
|
|
3659
|
+
key: "getCommittedWalletAssets",
|
|
3660
|
+
value: function getCommittedWalletAssets() {
|
|
3661
|
+
var _this$store$order9, _this$store$order9$ge;
|
|
3662
|
+
var payments = ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || (_this$store$order9$ge = _this$store$order9.getOrderPayments) === null || _this$store$order9$ge === void 0 ? void 0 : _this$store$order9$ge.call(_this$store$order9)) || [];
|
|
3663
|
+
var committed = payments.filter(function (payment) {
|
|
3664
|
+
var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
|
|
3665
|
+
if (voucherId === undefined || voucherId === null || voucherId === 0) {
|
|
3666
|
+
return false;
|
|
3667
|
+
}
|
|
3668
|
+
return (payment === null || payment === void 0 ? void 0 : payment.status) === 'paid' || (payment === null || payment === void 0 ? void 0 : payment.isSynced) === true || (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== undefined && (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== null && (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== '';
|
|
3521
3669
|
});
|
|
3522
|
-
|
|
3523
|
-
|
|
3670
|
+
return {
|
|
3671
|
+
ids: committed.map(function (payment) {
|
|
3672
|
+
return payment.voucher_id;
|
|
3673
|
+
}),
|
|
3674
|
+
assets: committed.map(function (payment) {
|
|
3675
|
+
var _Object$entries$find;
|
|
3676
|
+
var fundRecord = (payment === null || payment === void 0 ? void 0 : payment.fund_record) || {};
|
|
3677
|
+
var walletPassName = fundRecord.wallet_pass_name;
|
|
3678
|
+
var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
|
|
3679
|
+
var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
|
|
3680
|
+
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref32) {
|
|
3681
|
+
var _ref33 = _slicedToArray(_ref32, 2),
|
|
3682
|
+
paymentCode = _ref33[1];
|
|
3683
|
+
return paymentCode === code;
|
|
3684
|
+
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
|
|
3685
|
+
return {
|
|
3686
|
+
id: payment.voucher_id,
|
|
3687
|
+
voucher_id: payment.voucher_id,
|
|
3688
|
+
code: fundRecord.code,
|
|
3689
|
+
tag: tag,
|
|
3690
|
+
product_name: title || payment.name,
|
|
3691
|
+
name: title || payment.name,
|
|
3692
|
+
amount: Number(payment.amount || 0),
|
|
3693
|
+
_available_max_amount: Number(payment.amount || 0),
|
|
3694
|
+
unified_available_status: 1,
|
|
3695
|
+
_unified_available_status: 1,
|
|
3696
|
+
_committed_payment: payment
|
|
3697
|
+
};
|
|
3698
|
+
})
|
|
3699
|
+
};
|
|
3524
3700
|
}
|
|
3525
|
-
|
|
3526
|
-
/** 获取可用支付方式列表,供 PaymentModal 渲染支付选项。 */
|
|
3527
3701
|
}, {
|
|
3528
|
-
key: "
|
|
3529
|
-
value:
|
|
3530
|
-
var
|
|
3531
|
-
var response, paymentMethods;
|
|
3702
|
+
key: "publishWalletAssetsState",
|
|
3703
|
+
value: function () {
|
|
3704
|
+
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(state) {
|
|
3532
3705
|
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3533
3706
|
while (1) switch (_context37.prev = _context37.next) {
|
|
3534
3707
|
case 0:
|
|
3535
|
-
_context37.
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
filterPaymentMethods: true
|
|
3539
|
-
}, {
|
|
3540
|
-
osServer: true
|
|
3708
|
+
_context37.next = 2;
|
|
3709
|
+
return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
|
|
3710
|
+
state: state
|
|
3541
3711
|
});
|
|
3712
|
+
case 2:
|
|
3713
|
+
return _context37.abrupt("return", state);
|
|
3542
3714
|
case 3:
|
|
3543
|
-
response = _context37.sent;
|
|
3544
|
-
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
3545
|
-
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
3546
|
-
return _context37.abrupt("return", this.getPaymentMethods());
|
|
3547
|
-
case 9:
|
|
3548
|
-
_context37.prev = 9;
|
|
3549
|
-
_context37.t0 = _context37["catch"](0);
|
|
3550
|
-
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
3551
|
-
error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
|
|
3552
|
-
});
|
|
3553
|
-
return _context37.abrupt("return", this.getPaymentMethods());
|
|
3554
|
-
case 13:
|
|
3555
3715
|
case "end":
|
|
3556
3716
|
return _context37.stop();
|
|
3557
3717
|
}
|
|
3558
|
-
}, _callee37, this
|
|
3718
|
+
}, _callee37, this);
|
|
3559
3719
|
}));
|
|
3560
|
-
function
|
|
3561
|
-
return
|
|
3562
|
-
}
|
|
3563
|
-
return getPaymentMethodsAsync;
|
|
3564
|
-
}() /** 同步读取初始化时缓存的支付方式列表。 */)
|
|
3565
|
-
}, {
|
|
3566
|
-
key: "getPaymentMethods",
|
|
3567
|
-
value: function getPaymentMethods() {
|
|
3568
|
-
return _toConsumableArray(this.paymentMethodsCache);
|
|
3569
|
-
}
|
|
3570
|
-
|
|
3571
|
-
/** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
|
|
3572
|
-
}, {
|
|
3573
|
-
key: "roundAmount",
|
|
3574
|
-
value: function roundAmount(params) {
|
|
3575
|
-
var amount = new Decimal(params.amount || 0);
|
|
3576
|
-
var interval = new Decimal(params.interval || 0.05);
|
|
3577
|
-
var rule = params.rule || 'standard_rounding';
|
|
3578
|
-
var quotient = amount.div(interval);
|
|
3579
|
-
var roundedQuotient;
|
|
3580
|
-
if (rule === 'always_up') {
|
|
3581
|
-
roundedQuotient = quotient.ceil();
|
|
3582
|
-
} else if (rule === 'always_down') {
|
|
3583
|
-
roundedQuotient = quotient.floor();
|
|
3584
|
-
} else if (rule === 'standard_down') {
|
|
3585
|
-
roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_DOWN);
|
|
3586
|
-
} else {
|
|
3587
|
-
roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_UP);
|
|
3720
|
+
function publishWalletAssetsState(_x32) {
|
|
3721
|
+
return _publishWalletAssetsState.apply(this, arguments);
|
|
3588
3722
|
}
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
originalAmount: amount.toFixed(2),
|
|
3592
|
-
roundedAmount: roundedAmount.toFixed(2),
|
|
3593
|
-
roundingDifference: roundedAmount.minus(amount).toFixed(2)
|
|
3594
|
-
};
|
|
3595
|
-
}
|
|
3596
|
-
|
|
3597
|
-
/**
|
|
3598
|
-
* 发送支付链接。
|
|
3599
|
-
*
|
|
3600
|
-
* 如果没有 orderIds 或显式 submitBeforeSend,会先提交当前本地订单到云端;
|
|
3601
|
-
* 只有成功拿到远端 order_id 后才调用 OrderModule 发送邮件。
|
|
3602
|
-
*/
|
|
3723
|
+
return publishWalletAssetsState;
|
|
3724
|
+
}()
|
|
3603
3725
|
}, {
|
|
3604
|
-
key: "
|
|
3605
|
-
value:
|
|
3606
|
-
var
|
|
3607
|
-
var
|
|
3726
|
+
key: "syncSelectedWalletAssets",
|
|
3727
|
+
value: function () {
|
|
3728
|
+
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(state) {
|
|
3729
|
+
var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
|
|
3608
3730
|
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3609
3731
|
while (1) switch (_context38.prev = _context38.next) {
|
|
3610
3732
|
case 0:
|
|
3611
|
-
if (this.store.order) {
|
|
3733
|
+
if (!(!this.store.order || !this.store.payment)) {
|
|
3612
3734
|
_context38.next = 2;
|
|
3613
3735
|
break;
|
|
3614
3736
|
}
|
|
3615
|
-
throw new Error('
|
|
3737
|
+
throw new Error('订单或支付模块未初始化');
|
|
3616
3738
|
case 2:
|
|
3617
|
-
|
|
3618
|
-
if (!(!
|
|
3619
|
-
_context38.next =
|
|
3739
|
+
paymentMethods = this.getPaymentMethods();
|
|
3740
|
+
if (!(!paymentMethods.length && state.selectedItems.length)) {
|
|
3741
|
+
_context38.next = 7;
|
|
3620
3742
|
break;
|
|
3621
3743
|
}
|
|
3622
3744
|
_context38.next = 6;
|
|
3623
|
-
return this.
|
|
3624
|
-
smallTicketDataFlag: 1
|
|
3625
|
-
});
|
|
3745
|
+
return this.getPaymentMethodsAsync();
|
|
3626
3746
|
case 6:
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
break;
|
|
3632
|
-
}
|
|
3633
|
-
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
3634
|
-
case 10:
|
|
3635
|
-
orderIds = [orderId];
|
|
3636
|
-
case 11:
|
|
3637
|
-
return _context38.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
3638
|
-
emails: params.emails,
|
|
3639
|
-
notify_action: params.notify_action,
|
|
3640
|
-
order_ids: orderIds
|
|
3747
|
+
paymentMethods = _context38.sent;
|
|
3748
|
+
case 7:
|
|
3749
|
+
methodByCode = new Map(paymentMethods.map(function (method) {
|
|
3750
|
+
return [String(method.code || '').toUpperCase(), method];
|
|
3641
3751
|
}));
|
|
3642
|
-
|
|
3752
|
+
preparePayments = this.store.payment.wallet.formatWalletPassList2PreparePayments(state.selectedItems);
|
|
3753
|
+
selectedAssetById = new Map(state.selectedItems.map(function (asset) {
|
|
3754
|
+
return [String(getSharedWalletAssetId(asset)), asset];
|
|
3755
|
+
}));
|
|
3756
|
+
voucherPayments = preparePayments.flatMap(function (item) {
|
|
3757
|
+
var asset = selectedAssetById.get(String(item.voucher_id));
|
|
3758
|
+
var paymentCode = WALLET_PAYMENT_CODE_BY_TAG[String(item.tag || (asset === null || asset === void 0 ? void 0 : asset.tag) || '')] || String(item.tag || (asset === null || asset === void 0 ? void 0 : asset.tag) || '').toUpperCase();
|
|
3759
|
+
var paymentMethod = methodByCode.get(paymentCode);
|
|
3760
|
+
var formattedAmount = Number(item.amount);
|
|
3761
|
+
var amount = Number.isFinite(formattedAmount) && formattedAmount > 0 ? formattedAmount : getSharedWalletAssetAmount(asset);
|
|
3762
|
+
if (!asset || !paymentMethod || !Number.isFinite(amount) || amount <= 0) {
|
|
3763
|
+
return [];
|
|
3764
|
+
}
|
|
3765
|
+
var walletPassUseValue = getSharedWalletPassUseValue({
|
|
3766
|
+
asset: asset,
|
|
3767
|
+
amount: amount,
|
|
3768
|
+
paymentMethod: paymentMethod
|
|
3769
|
+
});
|
|
3770
|
+
return [{
|
|
3771
|
+
amount: amount.toFixed(2),
|
|
3772
|
+
code: paymentMethod.code,
|
|
3773
|
+
custom_payment_id: paymentMethod.id,
|
|
3774
|
+
name: paymentMethod.name,
|
|
3775
|
+
type: paymentMethod.type,
|
|
3776
|
+
voucher_id: item.voucher_id,
|
|
3777
|
+
wallet_pass_usage_unit: item.wallet_pass_usage_unit,
|
|
3778
|
+
wallet_pass_use_value: walletPassUseValue,
|
|
3779
|
+
fund_record: buildSharedWalletFundRecord({
|
|
3780
|
+
asset: asset,
|
|
3781
|
+
amount: amount,
|
|
3782
|
+
paymentMethod: paymentMethod
|
|
3783
|
+
})
|
|
3784
|
+
}];
|
|
3785
|
+
});
|
|
3786
|
+
payments = this.updateVoucherOrderPayments(voucherPayments, {
|
|
3787
|
+
status: 'payment_pending'
|
|
3788
|
+
});
|
|
3789
|
+
_context38.next = 14;
|
|
3790
|
+
return this.store.order.recalculateSummary({
|
|
3791
|
+
createIfMissing: true
|
|
3792
|
+
});
|
|
3793
|
+
case 14:
|
|
3794
|
+
return _context38.abrupt("return", payments);
|
|
3795
|
+
case 15:
|
|
3643
3796
|
case "end":
|
|
3644
3797
|
return _context38.stop();
|
|
3645
3798
|
}
|
|
3646
3799
|
}, _callee38, this);
|
|
3647
3800
|
}));
|
|
3648
|
-
function
|
|
3649
|
-
return
|
|
3801
|
+
function syncSelectedWalletAssets(_x33) {
|
|
3802
|
+
return _syncSelectedWalletAssets.apply(this, arguments);
|
|
3650
3803
|
}
|
|
3651
|
-
return
|
|
3652
|
-
}()
|
|
3804
|
+
return syncSelectedWalletAssets;
|
|
3805
|
+
}() /** 读取购物车与 Shared Checkout 共用的钱包资产状态。 */
|
|
3653
3806
|
}, {
|
|
3654
|
-
key: "
|
|
3655
|
-
value: function
|
|
3656
|
-
|
|
3807
|
+
key: "getWalletAssetsState",
|
|
3808
|
+
value: function getWalletAssetsState() {
|
|
3809
|
+
if (!this.store.payment) throw new Error('payment 模块未初始化');
|
|
3810
|
+
return this.store.payment.wallet.getWalletAssetsState();
|
|
3657
3811
|
}
|
|
3812
|
+
|
|
3813
|
+
/** 导出 Shared Checkout 跨运行时恢复所需的钱包状态与搜索缓存。 */
|
|
3658
3814
|
}, {
|
|
3659
|
-
key: "
|
|
3660
|
-
value: function () {
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3815
|
+
key: "exportWalletAssetsSnapshot",
|
|
3816
|
+
value: function exportWalletAssetsSnapshot() {
|
|
3817
|
+
if (!this.store.payment) throw new Error('payment 模块未初始化');
|
|
3818
|
+
return this.store.payment.wallet.exportWalletAssetsSnapshot();
|
|
3819
|
+
}
|
|
3820
|
+
|
|
3821
|
+
/**
|
|
3822
|
+
* 恢复 Shared Checkout 钱包快照,并把选择重新同步为订单 pending payment。
|
|
3823
|
+
*/
|
|
3824
|
+
}, {
|
|
3825
|
+
key: "importWalletAssetsSnapshot",
|
|
3826
|
+
value: (function () {
|
|
3827
|
+
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(snapshot) {
|
|
3828
|
+
var state;
|
|
3664
3829
|
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3665
3830
|
while (1) switch (_context39.prev = _context39.next) {
|
|
3666
3831
|
case 0:
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
_context39.next =
|
|
3675
|
-
return this.
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
});
|
|
3680
|
-
case 8:
|
|
3681
|
-
return _context39.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
3682
|
-
product: product,
|
|
3683
|
-
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
3684
|
-
customer_id: customerId,
|
|
3685
|
-
quotation: quotation
|
|
3686
|
-
})));
|
|
3687
|
-
case 9:
|
|
3832
|
+
if (this.store.payment) {
|
|
3833
|
+
_context39.next = 2;
|
|
3834
|
+
break;
|
|
3835
|
+
}
|
|
3836
|
+
throw new Error('payment 模块未初始化');
|
|
3837
|
+
case 2:
|
|
3838
|
+
state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
|
|
3839
|
+
_context39.next = 5;
|
|
3840
|
+
return this.syncSelectedWalletAssets(state);
|
|
3841
|
+
case 5:
|
|
3842
|
+
return _context39.abrupt("return", this.publishWalletAssetsState(state));
|
|
3843
|
+
case 6:
|
|
3688
3844
|
case "end":
|
|
3689
3845
|
return _context39.stop();
|
|
3690
3846
|
}
|
|
3691
3847
|
}, _callee39, this);
|
|
3692
3848
|
}));
|
|
3693
|
-
function
|
|
3694
|
-
return
|
|
3849
|
+
function importWalletAssetsSnapshot(_x34) {
|
|
3850
|
+
return _importWalletAssetsSnapshot.apply(this, arguments);
|
|
3695
3851
|
}
|
|
3696
|
-
return
|
|
3852
|
+
return importWalletAssetsSnapshot;
|
|
3697
3853
|
}()
|
|
3854
|
+
/**
|
|
3855
|
+
* 基于当前订单快照刷新钱包资产。商品变化保留并重验选择;客户变化强制清空。
|
|
3856
|
+
*/
|
|
3857
|
+
)
|
|
3698
3858
|
}, {
|
|
3699
|
-
key: "
|
|
3700
|
-
value: function
|
|
3701
|
-
var
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
return
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3859
|
+
key: "refreshWalletAssets",
|
|
3860
|
+
value: (function () {
|
|
3861
|
+
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
3862
|
+
var _previousState$custom, _businessData$custome;
|
|
3863
|
+
var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
|
|
3864
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3865
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3866
|
+
case 0:
|
|
3867
|
+
if (this.store.order) {
|
|
3868
|
+
_context40.next = 2;
|
|
3869
|
+
break;
|
|
3870
|
+
}
|
|
3871
|
+
throw new Error('order 模块未初始化');
|
|
3872
|
+
case 2:
|
|
3873
|
+
if (this.store.payment) {
|
|
3874
|
+
_context40.next = 4;
|
|
3875
|
+
break;
|
|
3876
|
+
}
|
|
3877
|
+
throw new Error('payment 模块未初始化');
|
|
3878
|
+
case 4:
|
|
3879
|
+
refreshSequence = ++this.walletAssetsRefreshSequence;
|
|
3880
|
+
wallet = this.store.payment.wallet;
|
|
3881
|
+
businessData = this.buildWalletInitBusinessData(params);
|
|
3882
|
+
if (businessData) {
|
|
3883
|
+
_context40.next = 12;
|
|
3884
|
+
break;
|
|
3885
|
+
}
|
|
3886
|
+
wallet.clearAllCache();
|
|
3887
|
+
emptyState = wallet.getWalletAssetsState();
|
|
3888
|
+
this.updateVoucherOrderPayments([], {
|
|
3889
|
+
status: 'payment_pending'
|
|
3890
|
+
});
|
|
3891
|
+
return _context40.abrupt("return", this.publishWalletAssetsState(emptyState));
|
|
3892
|
+
case 12:
|
|
3893
|
+
previousState = wallet.getWalletAssetsState();
|
|
3894
|
+
hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
|
|
3895
|
+
customerChanged = hasPreviousWalletContext && String((_previousState$custom = previousState.customerId) !== null && _previousState$custom !== void 0 ? _previousState$custom : '') !== String((_businessData$custome = businessData.customer_id) !== null && _businessData$custome !== void 0 ? _businessData$custome : '');
|
|
3896
|
+
if (!customerChanged) {
|
|
3897
|
+
_context40.next = 20;
|
|
3898
|
+
break;
|
|
3899
|
+
}
|
|
3900
|
+
clearedState = wallet.clearWalletAssetSelection();
|
|
3901
|
+
this.updateVoucherOrderPayments([], {
|
|
3902
|
+
status: 'payment_pending'
|
|
3903
|
+
});
|
|
3904
|
+
_context40.next = 20;
|
|
3905
|
+
return this.publishWalletAssetsState(clearedState);
|
|
3906
|
+
case 20:
|
|
3907
|
+
refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
|
|
3908
|
+
preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
|
|
3909
|
+
});
|
|
3910
|
+
_context40.next = 23;
|
|
3911
|
+
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
3912
|
+
case 23:
|
|
3913
|
+
_context40.next = 25;
|
|
3914
|
+
return refreshTask;
|
|
3915
|
+
case 25:
|
|
3916
|
+
state = _context40.sent;
|
|
3917
|
+
if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
|
|
3918
|
+
_context40.next = 28;
|
|
3919
|
+
break;
|
|
3920
|
+
}
|
|
3921
|
+
return _context40.abrupt("return", wallet.getWalletAssetsState());
|
|
3922
|
+
case 28:
|
|
3923
|
+
if (state.status !== 'error') {
|
|
3924
|
+
committed = this.getCommittedWalletAssets();
|
|
3925
|
+
state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
3926
|
+
}
|
|
3927
|
+
_context40.next = 31;
|
|
3928
|
+
return this.syncSelectedWalletAssets(state);
|
|
3929
|
+
case 31:
|
|
3930
|
+
return _context40.abrupt("return", this.publishWalletAssetsState(state));
|
|
3931
|
+
case 32:
|
|
3932
|
+
case "end":
|
|
3933
|
+
return _context40.stop();
|
|
3934
|
+
}
|
|
3935
|
+
}, _callee40, this);
|
|
3936
|
+
}));
|
|
3937
|
+
function refreshWalletAssets(_x35) {
|
|
3938
|
+
return _refreshWalletAssets.apply(this, arguments);
|
|
3939
|
+
}
|
|
3940
|
+
return refreshWalletAssets;
|
|
3941
|
+
}() /** 选择或取消单张钱包资产,并立即同步 pending wallet payments。 */)
|
|
3942
|
+
}, {
|
|
3943
|
+
key: "selectWalletAsset",
|
|
3944
|
+
value: (function () {
|
|
3945
|
+
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
3946
|
+
var state;
|
|
3947
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3948
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3949
|
+
case 0:
|
|
3950
|
+
if (this.store.payment) {
|
|
3951
|
+
_context41.next = 2;
|
|
3952
|
+
break;
|
|
3953
|
+
}
|
|
3954
|
+
throw new Error('payment 模块未初始化');
|
|
3955
|
+
case 2:
|
|
3956
|
+
state = this.store.payment.wallet.selectWalletAsset(params.assetId, {
|
|
3957
|
+
selected: params.selected,
|
|
3958
|
+
source: params.source
|
|
3959
|
+
});
|
|
3960
|
+
_context41.next = 5;
|
|
3961
|
+
return this.syncSelectedWalletAssets(state);
|
|
3962
|
+
case 5:
|
|
3963
|
+
return _context41.abrupt("return", this.publishWalletAssetsState(state));
|
|
3964
|
+
case 6:
|
|
3965
|
+
case "end":
|
|
3966
|
+
return _context41.stop();
|
|
3967
|
+
}
|
|
3968
|
+
}, _callee41, this);
|
|
3969
|
+
}));
|
|
3970
|
+
function selectWalletAsset(_x36) {
|
|
3971
|
+
return _selectWalletAsset.apply(this, arguments);
|
|
3972
|
+
}
|
|
3973
|
+
return selectWalletAsset;
|
|
3974
|
+
}() /** 扫码精确查券;仅可用资产会被自动选中。 */)
|
|
3975
|
+
}, {
|
|
3976
|
+
key: "scanWalletAsset",
|
|
3977
|
+
value: (function () {
|
|
3978
|
+
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(code) {
|
|
3979
|
+
var result;
|
|
3980
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3981
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3982
|
+
case 0:
|
|
3983
|
+
if (this.store.payment) {
|
|
3984
|
+
_context42.next = 2;
|
|
3985
|
+
break;
|
|
3986
|
+
}
|
|
3987
|
+
throw new Error('payment 模块未初始化');
|
|
3988
|
+
case 2:
|
|
3989
|
+
_context42.next = 4;
|
|
3990
|
+
return this.store.payment.wallet.scanWalletAssetAsync(code);
|
|
3991
|
+
case 4:
|
|
3992
|
+
result = _context42.sent;
|
|
3993
|
+
if (!(result.type === 'normalCode')) {
|
|
3994
|
+
_context42.next = 10;
|
|
3995
|
+
break;
|
|
3996
|
+
}
|
|
3997
|
+
_context42.next = 8;
|
|
3998
|
+
return this.syncSelectedWalletAssets(result.state);
|
|
3999
|
+
case 8:
|
|
4000
|
+
_context42.next = 10;
|
|
4001
|
+
return this.publishWalletAssetsState(result.state);
|
|
4002
|
+
case 10:
|
|
4003
|
+
return _context42.abrupt("return", result);
|
|
4004
|
+
case 11:
|
|
4005
|
+
case "end":
|
|
4006
|
+
return _context42.stop();
|
|
4007
|
+
}
|
|
4008
|
+
}, _callee42, this);
|
|
4009
|
+
}));
|
|
4010
|
+
function scanWalletAsset(_x37) {
|
|
4011
|
+
return _scanWalletAsset.apply(this, arguments);
|
|
4012
|
+
}
|
|
4013
|
+
return scanWalletAsset;
|
|
4014
|
+
}() /** 清空全部未确认钱包选择,已支付钱包项由 Order 模块继续保留。 */)
|
|
4015
|
+
}, {
|
|
4016
|
+
key: "clearWalletAssetSelection",
|
|
4017
|
+
value: (function () {
|
|
4018
|
+
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
4019
|
+
var state;
|
|
4020
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4021
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4022
|
+
case 0:
|
|
4023
|
+
if (this.store.payment) {
|
|
4024
|
+
_context43.next = 2;
|
|
4025
|
+
break;
|
|
4026
|
+
}
|
|
4027
|
+
throw new Error('payment 模块未初始化');
|
|
4028
|
+
case 2:
|
|
4029
|
+
state = this.store.payment.wallet.clearWalletAssetSelection();
|
|
4030
|
+
_context43.next = 5;
|
|
4031
|
+
return this.syncSelectedWalletAssets(state);
|
|
4032
|
+
case 5:
|
|
4033
|
+
return _context43.abrupt("return", this.publishWalletAssetsState(state));
|
|
4034
|
+
case 6:
|
|
4035
|
+
case "end":
|
|
4036
|
+
return _context43.stop();
|
|
4037
|
+
}
|
|
4038
|
+
}, _callee43, this);
|
|
4039
|
+
}));
|
|
4040
|
+
function clearWalletAssetSelection() {
|
|
4041
|
+
return _clearWalletAssetSelection.apply(this, arguments);
|
|
4042
|
+
}
|
|
4043
|
+
return clearWalletAssetSelection;
|
|
4044
|
+
}()
|
|
4045
|
+
/**
|
|
4046
|
+
* 更新当前订单客户字段。
|
|
4047
|
+
*
|
|
4048
|
+
* 这是 PaymentModal 客户切换的订单事实入口;外部客户模块同步应由
|
|
4049
|
+
* 调用方通过 onCustomerChange 回调完成。
|
|
4050
|
+
*/
|
|
4051
|
+
)
|
|
4052
|
+
}, {
|
|
4053
|
+
key: "updateOrderCustomer",
|
|
4054
|
+
value: function updateOrderCustomer(customer) {
|
|
4055
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
4056
|
+
var result = this.store.order.updateTempOrderCustomer(customer);
|
|
4057
|
+
this.store.order.recalculateSummary({
|
|
4058
|
+
createIfMissing: true
|
|
4059
|
+
});
|
|
4060
|
+
this.store.order.persistTempOrder();
|
|
4061
|
+
return result;
|
|
4062
|
+
}
|
|
4063
|
+
|
|
4064
|
+
/** 获取可用支付方式列表,供 PaymentModal 渲染支付选项。 */
|
|
4065
|
+
}, {
|
|
4066
|
+
key: "getPaymentMethodsAsync",
|
|
4067
|
+
value: (function () {
|
|
4068
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
4069
|
+
var response, paymentMethods;
|
|
4070
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4071
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4072
|
+
case 0:
|
|
4073
|
+
_context44.prev = 0;
|
|
4074
|
+
_context44.next = 3;
|
|
4075
|
+
return this.request.get('/pay/custom-payment/all', {
|
|
4076
|
+
filterPaymentMethods: true
|
|
4077
|
+
}, {
|
|
4078
|
+
osServer: true
|
|
4079
|
+
});
|
|
4080
|
+
case 3:
|
|
4081
|
+
response = _context44.sent;
|
|
4082
|
+
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
4083
|
+
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
4084
|
+
return _context44.abrupt("return", this.getPaymentMethods());
|
|
4085
|
+
case 9:
|
|
4086
|
+
_context44.prev = 9;
|
|
4087
|
+
_context44.t0 = _context44["catch"](0);
|
|
4088
|
+
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
4089
|
+
error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
|
|
4090
|
+
});
|
|
4091
|
+
return _context44.abrupt("return", this.getPaymentMethods());
|
|
4092
|
+
case 13:
|
|
4093
|
+
case "end":
|
|
4094
|
+
return _context44.stop();
|
|
4095
|
+
}
|
|
4096
|
+
}, _callee44, this, [[0, 9]]);
|
|
4097
|
+
}));
|
|
4098
|
+
function getPaymentMethodsAsync() {
|
|
4099
|
+
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
4100
|
+
}
|
|
4101
|
+
return getPaymentMethodsAsync;
|
|
4102
|
+
}() /** 同步读取初始化时缓存的支付方式列表。 */)
|
|
4103
|
+
}, {
|
|
4104
|
+
key: "getPaymentMethods",
|
|
4105
|
+
value: function getPaymentMethods() {
|
|
4106
|
+
return _toConsumableArray(this.paymentMethodsCache);
|
|
4107
|
+
}
|
|
4108
|
+
}, {
|
|
4109
|
+
key: "findCashPaymentMethod",
|
|
4110
|
+
value: function findCashPaymentMethod(paymentMethods) {
|
|
4111
|
+
return paymentMethods.find(function (method) {
|
|
4112
|
+
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) {
|
|
4113
|
+
return String(value || '').toUpperCase();
|
|
4114
|
+
});
|
|
4115
|
+
return identifiers.includes('CASHMANUAL') && (method === null || method === void 0 ? void 0 : method.enabled) !== false && (method === null || method === void 0 ? void 0 : method.enable) !== false;
|
|
4116
|
+
});
|
|
4117
|
+
}
|
|
4118
|
+
}, {
|
|
4119
|
+
key: "getPendingWalletPaymentAmount",
|
|
4120
|
+
value: function getPendingWalletPaymentAmount() {
|
|
4121
|
+
var _this$store$order10, _this$store$order10$g;
|
|
4122
|
+
var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order10 = this.store.order) === null || _this$store$order10 === void 0 || (_this$store$order10$g = _this$store$order10.getOrderPayments) === null || _this$store$order10$g === void 0 ? void 0 : _this$store$order10$g.call(_this$store$order10)) || [];
|
|
4123
|
+
return payments.reduce(function (total, payment) {
|
|
4124
|
+
if ((payment === null || payment === void 0 ? void 0 : payment.status) !== 'payment_pending' || (payment === null || payment === void 0 ? void 0 : payment.voucher_id) === undefined || Number(payment.voucher_id) === 0) {
|
|
4125
|
+
return total;
|
|
4126
|
+
}
|
|
4127
|
+
try {
|
|
4128
|
+
return total.plus(payment.amount || 0).plus(payment.rounding_amount || 0);
|
|
4129
|
+
} catch (_unused5) {
|
|
4130
|
+
return total;
|
|
4131
|
+
}
|
|
4132
|
+
}, new Decimal(0));
|
|
4133
|
+
}
|
|
4134
|
+
|
|
4135
|
+
/** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
|
|
4136
|
+
}, {
|
|
4137
|
+
key: "getCashPaymentConfig",
|
|
4138
|
+
value: (function () {
|
|
4139
|
+
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
4140
|
+
var _this$store$order11, _this$store$order11$g, _this$store$order12, _this$store$order12$g, _this$otherParams25;
|
|
4141
|
+
var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
|
|
4142
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4143
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4144
|
+
case 0:
|
|
4145
|
+
if (this.store.payment) {
|
|
4146
|
+
_context45.next = 2;
|
|
4147
|
+
break;
|
|
4148
|
+
}
|
|
4149
|
+
throw new Error('payment 模块未初始化');
|
|
4150
|
+
case 2:
|
|
4151
|
+
paymentMethods = this.getPaymentMethods();
|
|
4152
|
+
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4153
|
+
if (paymentMethod) {
|
|
4154
|
+
_context45.next = 9;
|
|
4155
|
+
break;
|
|
4156
|
+
}
|
|
4157
|
+
_context45.next = 7;
|
|
4158
|
+
return this.getPaymentMethodsAsync();
|
|
4159
|
+
case 7:
|
|
4160
|
+
paymentMethods = _context45.sent;
|
|
4161
|
+
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4162
|
+
case 9:
|
|
4163
|
+
amountSnapshot = (_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$g = _this$store$order11.getOrderAmountSnapshot) === null || _this$store$order11$g === void 0 ? void 0 : _this$store$order11$g.call(_this$store$order11);
|
|
4164
|
+
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
4165
|
+
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
|
|
4166
|
+
currency = ((_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getTempOrder) === null || _this$store$order12$g === void 0 || (_this$store$order12$g = _this$store$order12$g.call(_this$store$order12)) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.currency_code) || ((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.currency) || 'USD';
|
|
4167
|
+
recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
|
|
4168
|
+
return _context45.abrupt("return", {
|
|
4169
|
+
available: Boolean(paymentMethod && amountDue > 0),
|
|
4170
|
+
paymentMethod: paymentMethod,
|
|
4171
|
+
amountDue: amountDue,
|
|
4172
|
+
recommendedAmounts: recommendedAmounts
|
|
4173
|
+
});
|
|
4174
|
+
case 15:
|
|
4175
|
+
case "end":
|
|
4176
|
+
return _context45.stop();
|
|
4177
|
+
}
|
|
4178
|
+
}, _callee45, this);
|
|
4179
|
+
}));
|
|
4180
|
+
function getCashPaymentConfig() {
|
|
4181
|
+
return _getCashPaymentConfig.apply(this, arguments);
|
|
4182
|
+
}
|
|
4183
|
+
return getCashPaymentConfig;
|
|
4184
|
+
}()
|
|
4185
|
+
/**
|
|
4186
|
+
* 确认足额覆盖订单的 pending Wallet 支付并提交订单。
|
|
4187
|
+
*
|
|
4188
|
+
* Order 模块在构造提交参数时将 pending voucher 转为 paid;只有提交成功后
|
|
4189
|
+
* 才同步 Wallet committed 状态。失败时恢复调用前 payments,允许用户重试。
|
|
4190
|
+
*/
|
|
4191
|
+
)
|
|
4192
|
+
}, {
|
|
4193
|
+
key: "confirmWalletPayment",
|
|
4194
|
+
value: (function () {
|
|
4195
|
+
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
4196
|
+
var _this$store$order$get3, _this$store$order13, _this$store$order$get4, _this$store$order$get5, _this$store$order14;
|
|
4197
|
+
var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
|
|
4198
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4199
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4200
|
+
case 0:
|
|
4201
|
+
if (this.store.order) {
|
|
4202
|
+
_context46.next = 2;
|
|
4203
|
+
break;
|
|
4204
|
+
}
|
|
4205
|
+
throw new Error('order 模块未初始化');
|
|
4206
|
+
case 2:
|
|
4207
|
+
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
4208
|
+
pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
4209
|
+
if (!pendingWalletAmount.lte(0)) {
|
|
4210
|
+
_context46.next = 6;
|
|
4211
|
+
break;
|
|
4212
|
+
}
|
|
4213
|
+
throw new Error('当前订单没有待确认的 Wallet 支付');
|
|
4214
|
+
case 6:
|
|
4215
|
+
amountSnapshot = (_this$store$order$get3 = (_this$store$order13 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order13);
|
|
4216
|
+
effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4217
|
+
if (!effectiveAmountDue.gt(0.01)) {
|
|
4218
|
+
_context46.next = 10;
|
|
4219
|
+
break;
|
|
4220
|
+
}
|
|
4221
|
+
throw new Error('Wallet 支付尚未覆盖全部待支付金额');
|
|
4222
|
+
case 10:
|
|
4223
|
+
beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
|
|
4224
|
+
_context46.prev = 11;
|
|
4225
|
+
_context46.next = 14;
|
|
4226
|
+
return this.submitSalesOrder({
|
|
4227
|
+
smallTicketDataFlag: 1,
|
|
4228
|
+
confirmPendingVoucherPayments: true
|
|
4229
|
+
});
|
|
4230
|
+
case 14:
|
|
4231
|
+
submitResult = _context46.sent;
|
|
4232
|
+
if (!isRejectedSalesSubmitResult(submitResult)) {
|
|
4233
|
+
_context46.next = 17;
|
|
4234
|
+
break;
|
|
4235
|
+
}
|
|
4236
|
+
throw new Error(getSalesSubmitErrorMessage(submitResult));
|
|
4237
|
+
case 17:
|
|
4238
|
+
_context46.next = 27;
|
|
4239
|
+
break;
|
|
4240
|
+
case 19:
|
|
4241
|
+
_context46.prev = 19;
|
|
4242
|
+
_context46.t0 = _context46["catch"](11);
|
|
4243
|
+
this.store.order.setOrderPayments(beforePayments);
|
|
4244
|
+
restoredTempOrder = this.store.order.getTempOrder();
|
|
4245
|
+
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4246
|
+
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4247
|
+
this.store.order.persistTempOrder();
|
|
4248
|
+
}
|
|
4249
|
+
_context46.next = 26;
|
|
4250
|
+
return this.store.order.recalculateSummary({
|
|
4251
|
+
createIfMissing: true
|
|
4252
|
+
});
|
|
4253
|
+
case 26:
|
|
4254
|
+
throw _context46.t0;
|
|
4255
|
+
case 27:
|
|
4256
|
+
if (!this.store.payment) {
|
|
4257
|
+
_context46.next = 38;
|
|
4258
|
+
break;
|
|
4259
|
+
}
|
|
4260
|
+
_context46.prev = 28;
|
|
4261
|
+
committed = this.getCommittedWalletAssets();
|
|
4262
|
+
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4263
|
+
_context46.next = 33;
|
|
4264
|
+
return this.publishWalletAssetsState(walletState);
|
|
4265
|
+
case 33:
|
|
4266
|
+
_context46.next = 38;
|
|
4267
|
+
break;
|
|
4268
|
+
case 35:
|
|
4269
|
+
_context46.prev = 35;
|
|
4270
|
+
_context46.t1 = _context46["catch"](28);
|
|
4271
|
+
this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
|
|
4272
|
+
error: _context46.t1 instanceof Error ? _context46.t1.message : String(_context46.t1)
|
|
4273
|
+
});
|
|
4274
|
+
case 38:
|
|
4275
|
+
latestAmountSnapshot = (_this$store$order$get5 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.call(_this$store$order14);
|
|
4276
|
+
return _context46.abrupt("return", {
|
|
4277
|
+
submitResult: submitResult,
|
|
4278
|
+
payments: this.store.order.getOrderPayments(),
|
|
4279
|
+
isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
4280
|
+
});
|
|
4281
|
+
case 40:
|
|
4282
|
+
case "end":
|
|
4283
|
+
return _context46.stop();
|
|
4284
|
+
}
|
|
4285
|
+
}, _callee46, this, [[11, 19], [28, 35]]);
|
|
4286
|
+
}));
|
|
4287
|
+
function confirmWalletPayment() {
|
|
4288
|
+
return _confirmWalletPayment.apply(this, arguments);
|
|
4289
|
+
}
|
|
4290
|
+
return confirmWalletPayment;
|
|
4291
|
+
}()
|
|
4292
|
+
/**
|
|
4293
|
+
* 购物车现金直付:写入现金记录并等待支付同步完成。
|
|
4294
|
+
* 同步失败会恢复调用前 payments(包含 Wallet pending 状态)。
|
|
4295
|
+
*/
|
|
4296
|
+
)
|
|
4297
|
+
}, {
|
|
4298
|
+
key: "payCash",
|
|
4299
|
+
value: (function () {
|
|
4300
|
+
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
4301
|
+
var _this$store$order$get6, _params$actualPaidAmo, _this$window, _this$window$postMess;
|
|
4302
|
+
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4303
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4304
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4305
|
+
case 0:
|
|
4306
|
+
if (this.store.order) {
|
|
4307
|
+
_context47.next = 2;
|
|
4308
|
+
break;
|
|
4309
|
+
}
|
|
4310
|
+
throw new Error('order 模块未初始化');
|
|
4311
|
+
case 2:
|
|
4312
|
+
amount = Number(params.amount || 0);
|
|
4313
|
+
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
4314
|
+
_context47.next = 5;
|
|
4315
|
+
break;
|
|
4316
|
+
}
|
|
4317
|
+
throw new Error('现金支付金额必须大于 0');
|
|
4318
|
+
case 5:
|
|
4319
|
+
_context47.next = 7;
|
|
4320
|
+
return this.getCashPaymentConfig();
|
|
4321
|
+
case 7:
|
|
4322
|
+
config = _context47.sent;
|
|
4323
|
+
paymentMethod = config.paymentMethod;
|
|
4324
|
+
if (paymentMethod) {
|
|
4325
|
+
_context47.next = 11;
|
|
4326
|
+
break;
|
|
4327
|
+
}
|
|
4328
|
+
throw new Error('未找到可用的 CASHMANUAL 支付方式');
|
|
4329
|
+
case 11:
|
|
4330
|
+
if (!(config.amountDue <= 0)) {
|
|
4331
|
+
_context47.next = 13;
|
|
4332
|
+
break;
|
|
4333
|
+
}
|
|
4334
|
+
throw new Error('当前订单没有待支付金额');
|
|
4335
|
+
case 13:
|
|
4336
|
+
roundingAmount = Number(params.roundingAmount || 0);
|
|
4337
|
+
effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
|
|
4338
|
+
if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
|
|
4339
|
+
_context47.next = 17;
|
|
4340
|
+
break;
|
|
4341
|
+
}
|
|
4342
|
+
throw new Error('现金支付金额超过当前待支付金额');
|
|
4343
|
+
case 17:
|
|
4344
|
+
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
4345
|
+
beforePaymentStatus = (_this$store$order$get6 = this.store.order.getTempOrder()) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.payment_status;
|
|
4346
|
+
uniquePaymentNumber = createUuidV4();
|
|
4347
|
+
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4348
|
+
actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
|
|
4349
|
+
changeAmount = Number(params.changeAmount || 0);
|
|
4350
|
+
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
4351
|
+
_context47.next = 25;
|
|
4352
|
+
break;
|
|
4353
|
+
}
|
|
4354
|
+
throw new Error('顾客实收现金不能小于支付金额');
|
|
4355
|
+
case 25:
|
|
4356
|
+
(_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, {
|
|
4357
|
+
module: 'till',
|
|
4358
|
+
key: 'open_till',
|
|
4359
|
+
data: {
|
|
4360
|
+
type: 'cash'
|
|
4361
|
+
}
|
|
4362
|
+
});
|
|
4363
|
+
payments = this.store.order.addOrderPayment({
|
|
4364
|
+
amount: amount.toFixed(2),
|
|
4365
|
+
code: paymentMethod.code,
|
|
4366
|
+
custom_payment_id: paymentMethod.id,
|
|
4367
|
+
name: paymentMethod.name,
|
|
4368
|
+
custom_payment_type: paymentMethod.type,
|
|
4369
|
+
voucher_id: 0,
|
|
4370
|
+
rounding_amount: roundingAmount.toFixed(2),
|
|
4371
|
+
metadata: {
|
|
4372
|
+
unique_payment_number: uniquePaymentNumber,
|
|
4373
|
+
actual_paid_amount: Number.isFinite(actualPaidAmount) ? actualPaidAmount : amount,
|
|
4374
|
+
change_given_amount: Number.isFinite(changeAmount) ? changeAmount : 0
|
|
4375
|
+
},
|
|
4376
|
+
payment_time: paymentTimestamp,
|
|
4377
|
+
created_at: paymentTimestamp
|
|
4378
|
+
});
|
|
4379
|
+
payment = payments.find(function (item) {
|
|
4380
|
+
var _item$metadata2;
|
|
4381
|
+
return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
|
|
4382
|
+
});
|
|
4383
|
+
_context47.prev = 28;
|
|
4384
|
+
_context47.next = 31;
|
|
4385
|
+
return this.syncPaymentsToOrder({
|
|
4386
|
+
payments: payments,
|
|
4387
|
+
submitWhenPaid: true,
|
|
4388
|
+
smallTicketDataFlag: 1,
|
|
4389
|
+
confirmPendingVoucherPayments: true
|
|
4390
|
+
});
|
|
4391
|
+
case 31:
|
|
4392
|
+
syncResult = _context47.sent;
|
|
4393
|
+
if (!this.store.payment) {
|
|
4394
|
+
_context47.next = 37;
|
|
4395
|
+
break;
|
|
4396
|
+
}
|
|
4397
|
+
committed = this.getCommittedWalletAssets();
|
|
4398
|
+
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4399
|
+
_context47.next = 37;
|
|
4400
|
+
return this.publishWalletAssetsState(walletState);
|
|
4401
|
+
case 37:
|
|
4402
|
+
return _context47.abrupt("return", {
|
|
4403
|
+
payment: payment || {},
|
|
4404
|
+
payments: this.store.order.getOrderPayments(),
|
|
4405
|
+
syncResult: syncResult,
|
|
4406
|
+
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4407
|
+
});
|
|
4408
|
+
case 40:
|
|
4409
|
+
_context47.prev = 40;
|
|
4410
|
+
_context47.t0 = _context47["catch"](28);
|
|
4411
|
+
this.store.order.setOrderPayments(beforePayments);
|
|
4412
|
+
restoredTempOrder = this.store.order.getTempOrder();
|
|
4413
|
+
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4414
|
+
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4415
|
+
this.store.order.persistTempOrder();
|
|
4416
|
+
}
|
|
4417
|
+
_context47.next = 47;
|
|
4418
|
+
return this.store.order.recalculateSummary({
|
|
4419
|
+
createIfMissing: true
|
|
4420
|
+
});
|
|
4421
|
+
case 47:
|
|
4422
|
+
throw _context47.t0;
|
|
4423
|
+
case 48:
|
|
4424
|
+
case "end":
|
|
4425
|
+
return _context47.stop();
|
|
4426
|
+
}
|
|
4427
|
+
}, _callee47, this, [[28, 40]]);
|
|
4428
|
+
}));
|
|
4429
|
+
function payCash(_x38) {
|
|
4430
|
+
return _payCash.apply(this, arguments);
|
|
4431
|
+
}
|
|
4432
|
+
return payCash;
|
|
4433
|
+
}()
|
|
4434
|
+
/**
|
|
4435
|
+
* 提交一次已由支付设备确认成功的非 Wallet 支付。
|
|
4436
|
+
*
|
|
4437
|
+
* 与 addOrderPayment 不同,本入口不会启动后台 fire-and-forget 同步;调用方会等待
|
|
4438
|
+
* 本次 payment、当前 pending Wallet 以及订单提交共同完成。任何同步失败都会恢复
|
|
4439
|
+
* 调用前的 payments 与 payment_status,便于 UI 安全解锁并重试。
|
|
4440
|
+
*/
|
|
4441
|
+
)
|
|
4442
|
+
}, {
|
|
4443
|
+
key: "commitPaymentMethodPayment",
|
|
4444
|
+
value: (function () {
|
|
4445
|
+
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
4446
|
+
var _this$store$order$get7, _this$store$order15, _this$store$order$get8, _params$metadata, _params$originAmount;
|
|
4447
|
+
var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4448
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4449
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4450
|
+
case 0:
|
|
4451
|
+
if (this.store.order) {
|
|
4452
|
+
_context48.next = 2;
|
|
4453
|
+
break;
|
|
4454
|
+
}
|
|
4455
|
+
throw new Error('order 模块未初始化');
|
|
4456
|
+
case 2:
|
|
4457
|
+
amount = Number(params.amount || 0);
|
|
4458
|
+
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
4459
|
+
_context48.next = 5;
|
|
4460
|
+
break;
|
|
4461
|
+
}
|
|
4462
|
+
throw new Error('支付金额必须大于 0');
|
|
4463
|
+
case 5:
|
|
4464
|
+
paymentMethods = this.getPaymentMethods();
|
|
4465
|
+
findPaymentMethod = function findPaymentMethod() {
|
|
4466
|
+
var methodCode = String(params.paymentMethodCode || '').toUpperCase();
|
|
4467
|
+
return paymentMethods.find(function (method) {
|
|
4468
|
+
var idMatched = params.paymentMethodId !== undefined && String(method.id) === String(params.paymentMethodId);
|
|
4469
|
+
var codeMatched = Boolean(methodCode) && String(method.code || '').toUpperCase() === methodCode;
|
|
4470
|
+
return (idMatched || codeMatched) && method.enabled !== false && method.enable !== false;
|
|
4471
|
+
});
|
|
4472
|
+
};
|
|
4473
|
+
paymentMethod = findPaymentMethod();
|
|
4474
|
+
if (paymentMethod) {
|
|
4475
|
+
_context48.next = 13;
|
|
4476
|
+
break;
|
|
4477
|
+
}
|
|
4478
|
+
_context48.next = 11;
|
|
4479
|
+
return this.getPaymentMethodsAsync();
|
|
4480
|
+
case 11:
|
|
4481
|
+
paymentMethods = _context48.sent;
|
|
4482
|
+
paymentMethod = findPaymentMethod();
|
|
4483
|
+
case 13:
|
|
4484
|
+
if (paymentMethod) {
|
|
4485
|
+
_context48.next = 15;
|
|
4486
|
+
break;
|
|
4487
|
+
}
|
|
4488
|
+
throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
|
|
4489
|
+
case 15:
|
|
4490
|
+
amountSnapshot = (_this$store$order$get7 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order15);
|
|
4491
|
+
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
4492
|
+
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4493
|
+
if (!amountDue.lte(0)) {
|
|
4494
|
+
_context48.next = 20;
|
|
4495
|
+
break;
|
|
4496
|
+
}
|
|
4497
|
+
throw new Error('当前订单没有待支付金额');
|
|
4498
|
+
case 20:
|
|
4499
|
+
if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
|
|
4500
|
+
_context48.next = 22;
|
|
4501
|
+
break;
|
|
4502
|
+
}
|
|
4503
|
+
throw new Error('支付金额超过当前待支付金额');
|
|
4504
|
+
case 22:
|
|
4505
|
+
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
4506
|
+
beforePaymentStatus = (_this$store$order$get8 = this.store.order.getTempOrder()) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.payment_status;
|
|
4507
|
+
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4508
|
+
metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
|
|
4509
|
+
unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
|
|
4510
|
+
});
|
|
4511
|
+
serviceCharge = params.serviceCharge ? {
|
|
4512
|
+
amount: String(params.serviceCharge.amount || 0),
|
|
4513
|
+
percentage: String(params.serviceCharge.percentage || 0)
|
|
4514
|
+
} : undefined;
|
|
4515
|
+
serviceFee = serviceCharge ? new Decimal((_params$originAmount = params.originAmount) !== null && _params$originAmount !== void 0 ? _params$originAmount : amount).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
4516
|
+
payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params.paymentData || {}), {}, {
|
|
4517
|
+
amount: amount.toFixed(2)
|
|
4518
|
+
}, params.originAmount !== undefined ? {
|
|
4519
|
+
origin_amount: Number(params.originAmount).toFixed(2)
|
|
4520
|
+
} : {}), {}, {
|
|
4521
|
+
code: paymentMethod.code,
|
|
4522
|
+
custom_payment_id: paymentMethod.id,
|
|
4523
|
+
name: paymentMethod.name,
|
|
4524
|
+
custom_payment_type: paymentMethod.type,
|
|
4525
|
+
voucher_id: 0
|
|
4526
|
+
}, serviceCharge ? {
|
|
4527
|
+
service_charge: serviceCharge
|
|
4528
|
+
} : {}), serviceFee !== undefined ? {
|
|
4529
|
+
service_fee: serviceFee
|
|
4530
|
+
} : {}), {}, {
|
|
4531
|
+
metadata: metadata,
|
|
4532
|
+
payment_time: paymentTimestamp,
|
|
4533
|
+
created_at: paymentTimestamp
|
|
4534
|
+
}));
|
|
4535
|
+
payment = payments.find(function (item) {
|
|
4536
|
+
var _item$metadata3;
|
|
4537
|
+
return (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_payment_number) === metadata.unique_payment_number;
|
|
4538
|
+
});
|
|
4539
|
+
_context48.prev = 30;
|
|
4540
|
+
_context48.next = 33;
|
|
4541
|
+
return this.syncPaymentsToOrder({
|
|
4542
|
+
payments: payments,
|
|
4543
|
+
submitWhenPaid: true,
|
|
4544
|
+
smallTicketDataFlag: 1,
|
|
4545
|
+
confirmPendingVoucherPayments: true
|
|
4546
|
+
});
|
|
4547
|
+
case 33:
|
|
4548
|
+
syncResult = _context48.sent;
|
|
4549
|
+
if (!this.store.payment) {
|
|
4550
|
+
_context48.next = 39;
|
|
4551
|
+
break;
|
|
4552
|
+
}
|
|
4553
|
+
committed = this.getCommittedWalletAssets();
|
|
4554
|
+
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4555
|
+
_context48.next = 39;
|
|
4556
|
+
return this.publishWalletAssetsState(walletState);
|
|
4557
|
+
case 39:
|
|
4558
|
+
return _context48.abrupt("return", {
|
|
4559
|
+
payment: payment || {},
|
|
4560
|
+
payments: this.store.order.getOrderPayments(),
|
|
4561
|
+
syncResult: syncResult,
|
|
4562
|
+
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4563
|
+
});
|
|
4564
|
+
case 42:
|
|
4565
|
+
_context48.prev = 42;
|
|
4566
|
+
_context48.t0 = _context48["catch"](30);
|
|
4567
|
+
this.store.order.setOrderPayments(beforePayments);
|
|
4568
|
+
restoredTempOrder = this.store.order.getTempOrder();
|
|
4569
|
+
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4570
|
+
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4571
|
+
this.store.order.persistTempOrder();
|
|
4572
|
+
}
|
|
4573
|
+
_context48.next = 49;
|
|
4574
|
+
return this.store.order.recalculateSummary({
|
|
4575
|
+
createIfMissing: true
|
|
4576
|
+
});
|
|
4577
|
+
case 49:
|
|
4578
|
+
throw _context48.t0;
|
|
4579
|
+
case 50:
|
|
4580
|
+
case "end":
|
|
4581
|
+
return _context48.stop();
|
|
4582
|
+
}
|
|
4583
|
+
}, _callee48, this, [[30, 42]]);
|
|
4584
|
+
}));
|
|
4585
|
+
function commitPaymentMethodPayment(_x39) {
|
|
4586
|
+
return _commitPaymentMethodPayment.apply(this, arguments);
|
|
4587
|
+
}
|
|
4588
|
+
return commitPaymentMethodPayment;
|
|
4589
|
+
}()
|
|
4590
|
+
/**
|
|
4591
|
+
* 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
|
|
4592
|
+
*
|
|
4593
|
+
* 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
|
|
4594
|
+
* otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
|
|
4595
|
+
*/
|
|
4596
|
+
)
|
|
4597
|
+
}, {
|
|
4598
|
+
key: "roundAmount",
|
|
4599
|
+
value: (function () {
|
|
4600
|
+
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
|
|
4601
|
+
var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
|
|
4602
|
+
var amount, cashManualPayment;
|
|
4603
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4604
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4605
|
+
case 0:
|
|
4606
|
+
amount = params.amount;
|
|
4607
|
+
cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
|
|
4608
|
+
return paymentMethod.code === 'CASHMANUAL';
|
|
4609
|
+
});
|
|
4610
|
+
if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
|
|
4611
|
+
_context49.next = 4;
|
|
4612
|
+
break;
|
|
4613
|
+
}
|
|
4614
|
+
return _context49.abrupt("return", {
|
|
4615
|
+
originalAmount: amount.toString(),
|
|
4616
|
+
roundedAmount: amount.toString(),
|
|
4617
|
+
roundingDifference: '0.00'
|
|
4618
|
+
});
|
|
4619
|
+
case 4:
|
|
4620
|
+
if (this.payment) {
|
|
4621
|
+
_context49.next = 6;
|
|
4622
|
+
break;
|
|
4623
|
+
}
|
|
4624
|
+
throw new Error('payment 模块未初始化');
|
|
4625
|
+
case 6:
|
|
4626
|
+
return _context49.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
|
|
4627
|
+
case 7:
|
|
4628
|
+
case "end":
|
|
4629
|
+
return _context49.stop();
|
|
4630
|
+
}
|
|
4631
|
+
}, _callee49, this);
|
|
4632
|
+
}));
|
|
4633
|
+
function roundAmount(_x40) {
|
|
4634
|
+
return _roundAmount.apply(this, arguments);
|
|
4635
|
+
}
|
|
4636
|
+
return roundAmount;
|
|
4637
|
+
}()
|
|
4638
|
+
/**
|
|
4639
|
+
* 发送支付链接。
|
|
4640
|
+
*
|
|
4641
|
+
* 如果没有 orderIds 或显式 submitBeforeSend,会先提交当前本地订单到云端;
|
|
4642
|
+
* 只有成功拿到远端 order_id 后才调用 OrderModule 发送邮件。
|
|
4643
|
+
*/
|
|
4644
|
+
)
|
|
4645
|
+
}, {
|
|
4646
|
+
key: "sendCustomerPayLink",
|
|
4647
|
+
value: (function () {
|
|
4648
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
4649
|
+
var orderIds, _ref34, _ref35, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
4650
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4651
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4652
|
+
case 0:
|
|
4653
|
+
if (this.store.order) {
|
|
4654
|
+
_context50.next = 2;
|
|
4655
|
+
break;
|
|
4656
|
+
}
|
|
4657
|
+
throw new Error('order 模块未初始化');
|
|
4658
|
+
case 2:
|
|
4659
|
+
orderIds = params.order_ids || params.orderIds || [];
|
|
4660
|
+
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
4661
|
+
_context50.next = 11;
|
|
4662
|
+
break;
|
|
4663
|
+
}
|
|
4664
|
+
_context50.next = 6;
|
|
4665
|
+
return this.submitSalesOrder({
|
|
4666
|
+
smallTicketDataFlag: 1
|
|
4667
|
+
});
|
|
4668
|
+
case 6:
|
|
4669
|
+
submitResult = _context50.sent;
|
|
4670
|
+
orderId = (_ref34 = (_ref35 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref35 !== void 0 ? _ref35 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref34 !== void 0 ? _ref34 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
4671
|
+
if (orderId) {
|
|
4672
|
+
_context50.next = 10;
|
|
4673
|
+
break;
|
|
4674
|
+
}
|
|
4675
|
+
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
4676
|
+
case 10:
|
|
4677
|
+
orderIds = [orderId];
|
|
4678
|
+
case 11:
|
|
4679
|
+
return _context50.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
4680
|
+
emails: params.emails,
|
|
4681
|
+
notify_action: params.notify_action,
|
|
4682
|
+
order_ids: orderIds
|
|
4683
|
+
}));
|
|
4684
|
+
case 12:
|
|
4685
|
+
case "end":
|
|
4686
|
+
return _context50.stop();
|
|
4687
|
+
}
|
|
4688
|
+
}, _callee50, this);
|
|
4689
|
+
}));
|
|
4690
|
+
function sendCustomerPayLink(_x41) {
|
|
4691
|
+
return _sendCustomerPayLink.apply(this, arguments);
|
|
4692
|
+
}
|
|
4693
|
+
return sendCustomerPayLink;
|
|
4694
|
+
}())
|
|
4695
|
+
}, {
|
|
4696
|
+
key: "transformBaseProductToOrderProduct",
|
|
4697
|
+
value: function transformBaseProductToOrderProduct(params) {
|
|
4698
|
+
return _transformBaseProductToOrderProduct(params);
|
|
4699
|
+
}
|
|
4700
|
+
}, {
|
|
4701
|
+
key: "calculateProductBookingPrice",
|
|
4702
|
+
value: function () {
|
|
4703
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
4704
|
+
var _params$customer_id;
|
|
4705
|
+
var quotation, customerId, authoritativeProduct, product;
|
|
4706
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4707
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4708
|
+
case 0:
|
|
4709
|
+
quotation = this.store.quotation;
|
|
4710
|
+
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
4711
|
+
_context51.next = 4;
|
|
4712
|
+
return this.loadProductForPriceQuery(params, customerId);
|
|
4713
|
+
case 4:
|
|
4714
|
+
authoritativeProduct = _context51.sent;
|
|
4715
|
+
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
4716
|
+
_context51.next = 8;
|
|
4717
|
+
return this.loadQuotationForPriceQuery({
|
|
4718
|
+
quotation: quotation,
|
|
4719
|
+
customer_id: customerId,
|
|
4720
|
+
channel: params.channel
|
|
4721
|
+
});
|
|
4722
|
+
case 8:
|
|
4723
|
+
return _context51.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
4724
|
+
product: product,
|
|
4725
|
+
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
4726
|
+
customer_id: customerId,
|
|
4727
|
+
quotation: quotation
|
|
4728
|
+
})));
|
|
4729
|
+
case 9:
|
|
4730
|
+
case "end":
|
|
4731
|
+
return _context51.stop();
|
|
4732
|
+
}
|
|
4733
|
+
}, _callee51, this);
|
|
4734
|
+
}));
|
|
4735
|
+
function calculateProductBookingPrice(_x42) {
|
|
4736
|
+
return _calculateProductBookingPrice.apply(this, arguments);
|
|
4737
|
+
}
|
|
4738
|
+
return calculateProductBookingPrice;
|
|
4739
|
+
}()
|
|
4740
|
+
}, {
|
|
4741
|
+
key: "getQuotationCustomerScopeInfo",
|
|
4742
|
+
value: function getQuotationCustomerScopeInfo() {
|
|
4743
|
+
var _this15 = this;
|
|
4744
|
+
var quotation = this.store.quotation;
|
|
4745
|
+
if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
|
|
4746
|
+
return quotation.getQuotationCustomerScopeInfo();
|
|
4747
|
+
}
|
|
4748
|
+
var list = typeof (quotation === null || quotation === void 0 ? void 0 : quotation.getQuotationList) === 'function' ? quotation.getQuotationList() : [];
|
|
4749
|
+
var customerById = new Map();
|
|
4750
|
+
var quotationScopes = (Array.isArray(list) ? list : []).filter(function (item) {
|
|
4751
|
+
return Array.isArray(item === null || item === void 0 ? void 0 : item.customer) && item.customer.length > 0;
|
|
4752
|
+
}).map(function (item) {
|
|
4753
|
+
var localSeen = new Set();
|
|
4754
|
+
var customers = item.customer.filter(function (customer) {
|
|
4755
|
+
var customerId = _this15.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
4756
|
+
if (!customerId || localSeen.has(customerId)) return false;
|
|
4757
|
+
localSeen.add(customerId);
|
|
4758
|
+
if (!customerById.has(customerId)) customerById.set(customerId, customer);
|
|
4759
|
+
return true;
|
|
4760
|
+
});
|
|
4761
|
+
return {
|
|
4762
|
+
quotationId: item.id,
|
|
4763
|
+
quotationName: item.name,
|
|
4764
|
+
customerIds: customers.map(function (customer) {
|
|
4765
|
+
return String(customer.id);
|
|
4766
|
+
}),
|
|
4767
|
+
customers: customers
|
|
4768
|
+
};
|
|
4769
|
+
});
|
|
4770
|
+
return {
|
|
4771
|
+
quotationCount: Array.isArray(list) ? list.length : 0,
|
|
4772
|
+
hasCustomerScopedQuotations: quotationScopes.length > 0,
|
|
4773
|
+
allQuotationsCustomerScoped: Array.isArray(list) && list.length > 0 && quotationScopes.length === list.length,
|
|
4774
|
+
customerIds: Array.from(customerById.keys()),
|
|
4775
|
+
customers: Array.from(customerById.values()),
|
|
3734
4776
|
quotationScopes: quotationScopes
|
|
3735
4777
|
};
|
|
3736
4778
|
}
|
|
@@ -3760,20 +4802,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3760
4802
|
}, {
|
|
3761
4803
|
key: "calculateProductBookingPrices",
|
|
3762
4804
|
value: function () {
|
|
3763
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4805
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(paramsList) {
|
|
3764
4806
|
var _paramsList$0$custome,
|
|
3765
4807
|
_paramsList$,
|
|
3766
4808
|
_this16 = this,
|
|
3767
4809
|
_paramsList$2;
|
|
3768
4810
|
var quotation, customerId, productMapsByGroup, groups;
|
|
3769
|
-
return _regeneratorRuntime().wrap(function
|
|
3770
|
-
while (1) switch (
|
|
4811
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
4812
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
3771
4813
|
case 0:
|
|
3772
4814
|
if (paramsList.length) {
|
|
3773
|
-
|
|
4815
|
+
_context53.next = 2;
|
|
3774
4816
|
break;
|
|
3775
4817
|
}
|
|
3776
|
-
return
|
|
4818
|
+
return _context53.abrupt("return", []);
|
|
3777
4819
|
case 2:
|
|
3778
4820
|
quotation = this.store.quotation;
|
|
3779
4821
|
customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
|
|
@@ -3795,15 +4837,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3795
4837
|
group.ids.add(productId);
|
|
3796
4838
|
groups.set(groupKey, group);
|
|
3797
4839
|
});
|
|
3798
|
-
|
|
4840
|
+
_context53.next = 9;
|
|
3799
4841
|
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
3800
|
-
var
|
|
3801
|
-
var
|
|
3802
|
-
return _regeneratorRuntime().wrap(function
|
|
3803
|
-
while (1) switch (
|
|
4842
|
+
var _ref37 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(_ref36) {
|
|
4843
|
+
var _ref38, groupKey, group, productsById;
|
|
4844
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
4845
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
3804
4846
|
case 0:
|
|
3805
|
-
|
|
3806
|
-
|
|
4847
|
+
_ref38 = _slicedToArray(_ref36, 2), groupKey = _ref38[0], group = _ref38[1];
|
|
4848
|
+
_context52.next = 3;
|
|
3807
4849
|
return _this16.loadProductsForPriceQuery({
|
|
3808
4850
|
ids: Array.from(group.ids),
|
|
3809
4851
|
schedule: group.schedule,
|
|
@@ -3811,27 +4853,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3811
4853
|
channel: group.channel
|
|
3812
4854
|
});
|
|
3813
4855
|
case 3:
|
|
3814
|
-
productsById =
|
|
4856
|
+
productsById = _context52.sent;
|
|
3815
4857
|
productMapsByGroup.set(groupKey, productsById);
|
|
3816
4858
|
case 5:
|
|
3817
4859
|
case "end":
|
|
3818
|
-
return
|
|
4860
|
+
return _context52.stop();
|
|
3819
4861
|
}
|
|
3820
|
-
},
|
|
4862
|
+
}, _callee52);
|
|
3821
4863
|
}));
|
|
3822
|
-
return function (
|
|
3823
|
-
return
|
|
4864
|
+
return function (_x44) {
|
|
4865
|
+
return _ref37.apply(this, arguments);
|
|
3824
4866
|
};
|
|
3825
4867
|
}()));
|
|
3826
4868
|
case 9:
|
|
3827
|
-
|
|
4869
|
+
_context53.next = 11;
|
|
3828
4870
|
return this.loadQuotationForPriceQuery({
|
|
3829
4871
|
quotation: quotation,
|
|
3830
4872
|
customer_id: customerId,
|
|
3831
4873
|
channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
|
|
3832
4874
|
});
|
|
3833
4875
|
case 11:
|
|
3834
|
-
return
|
|
4876
|
+
return _context53.abrupt("return", paramsList.map(function (params) {
|
|
3835
4877
|
var _this16$otherParams2, _productMapsByGroup$g;
|
|
3836
4878
|
var productInput = params.product || {};
|
|
3837
4879
|
var productId = _this16.getPriceQueryProductId(productInput);
|
|
@@ -3849,11 +4891,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3849
4891
|
}));
|
|
3850
4892
|
case 12:
|
|
3851
4893
|
case "end":
|
|
3852
|
-
return
|
|
4894
|
+
return _context53.stop();
|
|
3853
4895
|
}
|
|
3854
|
-
},
|
|
4896
|
+
}, _callee53, this);
|
|
3855
4897
|
}));
|
|
3856
|
-
function calculateProductBookingPrices(
|
|
4898
|
+
function calculateProductBookingPrices(_x43) {
|
|
3857
4899
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
3858
4900
|
}
|
|
3859
4901
|
return calculateProductBookingPrices;
|
|
@@ -3861,34 +4903,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3861
4903
|
}, {
|
|
3862
4904
|
key: "addProductToOrder",
|
|
3863
4905
|
value: function () {
|
|
3864
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4906
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(product, booking) {
|
|
3865
4907
|
var products;
|
|
3866
|
-
return _regeneratorRuntime().wrap(function
|
|
3867
|
-
while (1) switch (
|
|
4908
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
4909
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
3868
4910
|
case 0:
|
|
3869
|
-
|
|
4911
|
+
_context54.prev = 0;
|
|
3870
4912
|
if (this.store.order) {
|
|
3871
|
-
|
|
4913
|
+
_context54.next = 3;
|
|
3872
4914
|
break;
|
|
3873
4915
|
}
|
|
3874
4916
|
throw new Error('order 模块未初始化');
|
|
3875
4917
|
case 3:
|
|
3876
|
-
|
|
4918
|
+
_context54.next = 5;
|
|
3877
4919
|
return this.store.order.addProductToOrder(product, booking);
|
|
3878
4920
|
case 5:
|
|
3879
|
-
products =
|
|
3880
|
-
return
|
|
4921
|
+
products = _context54.sent;
|
|
4922
|
+
return _context54.abrupt("return", products);
|
|
3881
4923
|
case 9:
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
throw
|
|
4924
|
+
_context54.prev = 9;
|
|
4925
|
+
_context54.t0 = _context54["catch"](0);
|
|
4926
|
+
throw _context54.t0;
|
|
3885
4927
|
case 12:
|
|
3886
4928
|
case "end":
|
|
3887
|
-
return
|
|
4929
|
+
return _context54.stop();
|
|
3888
4930
|
}
|
|
3889
|
-
},
|
|
4931
|
+
}, _callee54, this, [[0, 9]]);
|
|
3890
4932
|
}));
|
|
3891
|
-
function addProductToOrder(
|
|
4933
|
+
function addProductToOrder(_x45, _x46) {
|
|
3892
4934
|
return _addProductToOrder.apply(this, arguments);
|
|
3893
4935
|
}
|
|
3894
4936
|
return addProductToOrder;
|
|
@@ -3896,34 +4938,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3896
4938
|
}, {
|
|
3897
4939
|
key: "updateOrderProduct",
|
|
3898
4940
|
value: function () {
|
|
3899
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4941
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
3900
4942
|
var products;
|
|
3901
|
-
return _regeneratorRuntime().wrap(function
|
|
3902
|
-
while (1) switch (
|
|
4943
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
4944
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
3903
4945
|
case 0:
|
|
3904
|
-
|
|
4946
|
+
_context55.prev = 0;
|
|
3905
4947
|
if (this.store.order) {
|
|
3906
|
-
|
|
4948
|
+
_context55.next = 3;
|
|
3907
4949
|
break;
|
|
3908
4950
|
}
|
|
3909
4951
|
throw new Error('order 模块未初始化');
|
|
3910
4952
|
case 3:
|
|
3911
|
-
|
|
4953
|
+
_context55.next = 5;
|
|
3912
4954
|
return this.store.order.updateOrderProduct(params);
|
|
3913
4955
|
case 5:
|
|
3914
|
-
products =
|
|
3915
|
-
return
|
|
4956
|
+
products = _context55.sent;
|
|
4957
|
+
return _context55.abrupt("return", products);
|
|
3916
4958
|
case 9:
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
throw
|
|
4959
|
+
_context55.prev = 9;
|
|
4960
|
+
_context55.t0 = _context55["catch"](0);
|
|
4961
|
+
throw _context55.t0;
|
|
3920
4962
|
case 12:
|
|
3921
4963
|
case "end":
|
|
3922
|
-
return
|
|
4964
|
+
return _context55.stop();
|
|
3923
4965
|
}
|
|
3924
|
-
},
|
|
4966
|
+
}, _callee55, this, [[0, 9]]);
|
|
3925
4967
|
}));
|
|
3926
|
-
function updateOrderProduct(
|
|
4968
|
+
function updateOrderProduct(_x47) {
|
|
3927
4969
|
return _updateOrderProduct.apply(this, arguments);
|
|
3928
4970
|
}
|
|
3929
4971
|
return updateOrderProduct;
|
|
@@ -3931,34 +4973,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3931
4973
|
}, {
|
|
3932
4974
|
key: "updateOrderProducts",
|
|
3933
4975
|
value: function () {
|
|
3934
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4976
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(paramsList) {
|
|
3935
4977
|
var products;
|
|
3936
|
-
return _regeneratorRuntime().wrap(function
|
|
3937
|
-
while (1) switch (
|
|
4978
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
4979
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
3938
4980
|
case 0:
|
|
3939
|
-
|
|
4981
|
+
_context56.prev = 0;
|
|
3940
4982
|
if (this.store.order) {
|
|
3941
|
-
|
|
4983
|
+
_context56.next = 3;
|
|
3942
4984
|
break;
|
|
3943
4985
|
}
|
|
3944
4986
|
throw new Error('order 模块未初始化');
|
|
3945
4987
|
case 3:
|
|
3946
|
-
|
|
4988
|
+
_context56.next = 5;
|
|
3947
4989
|
return this.store.order.updateOrderProducts(paramsList);
|
|
3948
4990
|
case 5:
|
|
3949
|
-
products =
|
|
3950
|
-
return
|
|
4991
|
+
products = _context56.sent;
|
|
4992
|
+
return _context56.abrupt("return", products);
|
|
3951
4993
|
case 9:
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
throw
|
|
4994
|
+
_context56.prev = 9;
|
|
4995
|
+
_context56.t0 = _context56["catch"](0);
|
|
4996
|
+
throw _context56.t0;
|
|
3955
4997
|
case 12:
|
|
3956
4998
|
case "end":
|
|
3957
|
-
return
|
|
4999
|
+
return _context56.stop();
|
|
3958
5000
|
}
|
|
3959
|
-
},
|
|
5001
|
+
}, _callee56, this, [[0, 9]]);
|
|
3960
5002
|
}));
|
|
3961
|
-
function updateOrderProducts(
|
|
5003
|
+
function updateOrderProducts(_x48) {
|
|
3962
5004
|
return _updateOrderProducts.apply(this, arguments);
|
|
3963
5005
|
}
|
|
3964
5006
|
return updateOrderProducts;
|
|
@@ -3966,34 +5008,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3966
5008
|
}, {
|
|
3967
5009
|
key: "updateOrderProductQuantity",
|
|
3968
5010
|
value: function () {
|
|
3969
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5011
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
3970
5012
|
var products;
|
|
3971
|
-
return _regeneratorRuntime().wrap(function
|
|
3972
|
-
while (1) switch (
|
|
5013
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5014
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
3973
5015
|
case 0:
|
|
3974
|
-
|
|
5016
|
+
_context57.prev = 0;
|
|
3975
5017
|
if (this.store.order) {
|
|
3976
|
-
|
|
5018
|
+
_context57.next = 3;
|
|
3977
5019
|
break;
|
|
3978
5020
|
}
|
|
3979
5021
|
throw new Error('order 模块未初始化');
|
|
3980
5022
|
case 3:
|
|
3981
|
-
|
|
5023
|
+
_context57.next = 5;
|
|
3982
5024
|
return this.store.order.updateOrderProductQuantity(params);
|
|
3983
5025
|
case 5:
|
|
3984
|
-
products =
|
|
3985
|
-
return
|
|
5026
|
+
products = _context57.sent;
|
|
5027
|
+
return _context57.abrupt("return", products);
|
|
3986
5028
|
case 9:
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
throw
|
|
5029
|
+
_context57.prev = 9;
|
|
5030
|
+
_context57.t0 = _context57["catch"](0);
|
|
5031
|
+
throw _context57.t0;
|
|
3990
5032
|
case 12:
|
|
3991
5033
|
case "end":
|
|
3992
|
-
return
|
|
5034
|
+
return _context57.stop();
|
|
3993
5035
|
}
|
|
3994
|
-
},
|
|
5036
|
+
}, _callee57, this, [[0, 9]]);
|
|
3995
5037
|
}));
|
|
3996
|
-
function updateOrderProductQuantity(
|
|
5038
|
+
function updateOrderProductQuantity(_x49) {
|
|
3997
5039
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
3998
5040
|
}
|
|
3999
5041
|
return updateOrderProductQuantity;
|
|
@@ -4016,12 +5058,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4016
5058
|
}, {
|
|
4017
5059
|
key: "setOrderProductLineNote",
|
|
4018
5060
|
value: (function () {
|
|
4019
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5061
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(identity, note) {
|
|
4020
5062
|
var params, products;
|
|
4021
|
-
return _regeneratorRuntime().wrap(function
|
|
4022
|
-
while (1) switch (
|
|
5063
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5064
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
4023
5065
|
case 0:
|
|
4024
|
-
|
|
5066
|
+
_context58.prev = 0;
|
|
4025
5067
|
params = {
|
|
4026
5068
|
product_id: identity.product_id,
|
|
4027
5069
|
product_variant_id: identity.product_variant_id,
|
|
@@ -4036,22 +5078,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4036
5078
|
params.product_sku = identity.product_sku;
|
|
4037
5079
|
}
|
|
4038
5080
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
4039
|
-
|
|
5081
|
+
_context58.next = 7;
|
|
4040
5082
|
return this.updateOrderProduct(params);
|
|
4041
5083
|
case 7:
|
|
4042
|
-
products =
|
|
4043
|
-
return
|
|
5084
|
+
products = _context58.sent;
|
|
5085
|
+
return _context58.abrupt("return", products);
|
|
4044
5086
|
case 11:
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
throw
|
|
5087
|
+
_context58.prev = 11;
|
|
5088
|
+
_context58.t0 = _context58["catch"](0);
|
|
5089
|
+
throw _context58.t0;
|
|
4048
5090
|
case 14:
|
|
4049
5091
|
case "end":
|
|
4050
|
-
return
|
|
5092
|
+
return _context58.stop();
|
|
4051
5093
|
}
|
|
4052
|
-
},
|
|
5094
|
+
}, _callee58, this, [[0, 11]]);
|
|
4053
5095
|
}));
|
|
4054
|
-
function setOrderProductLineNote(
|
|
5096
|
+
function setOrderProductLineNote(_x50, _x51) {
|
|
4055
5097
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
4056
5098
|
}
|
|
4057
5099
|
return setOrderProductLineNote;
|
|
@@ -4066,32 +5108,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4066
5108
|
}, {
|
|
4067
5109
|
key: "removeProductsFromOrder",
|
|
4068
5110
|
value: (function () {
|
|
4069
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4070
|
-
return _regeneratorRuntime().wrap(function
|
|
4071
|
-
while (1) switch (
|
|
5111
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(identities) {
|
|
5112
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5113
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
4072
5114
|
case 0:
|
|
4073
|
-
|
|
5115
|
+
_context59.prev = 0;
|
|
4074
5116
|
if (this.store.order) {
|
|
4075
|
-
|
|
5117
|
+
_context59.next = 3;
|
|
4076
5118
|
break;
|
|
4077
5119
|
}
|
|
4078
5120
|
throw new Error('order 模块未初始化');
|
|
4079
5121
|
case 3:
|
|
4080
|
-
|
|
5122
|
+
_context59.next = 5;
|
|
4081
5123
|
return this.store.order.removeProductsFromOrder(identities);
|
|
4082
5124
|
case 5:
|
|
4083
|
-
return
|
|
5125
|
+
return _context59.abrupt("return", _context59.sent);
|
|
4084
5126
|
case 8:
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
throw
|
|
5127
|
+
_context59.prev = 8;
|
|
5128
|
+
_context59.t0 = _context59["catch"](0);
|
|
5129
|
+
throw _context59.t0;
|
|
4088
5130
|
case 11:
|
|
4089
5131
|
case "end":
|
|
4090
|
-
return
|
|
5132
|
+
return _context59.stop();
|
|
4091
5133
|
}
|
|
4092
|
-
},
|
|
5134
|
+
}, _callee59, this, [[0, 8]]);
|
|
4093
5135
|
}));
|
|
4094
|
-
function removeProductsFromOrder(
|
|
5136
|
+
function removeProductsFromOrder(_x52) {
|
|
4095
5137
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4096
5138
|
}
|
|
4097
5139
|
return removeProductsFromOrder;
|
|
@@ -4099,18 +5141,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4099
5141
|
}, {
|
|
4100
5142
|
key: "removeProductFromOrder",
|
|
4101
5143
|
value: function () {
|
|
4102
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4103
|
-
return _regeneratorRuntime().wrap(function
|
|
4104
|
-
while (1) switch (
|
|
5144
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(identity) {
|
|
5145
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5146
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
4105
5147
|
case 0:
|
|
4106
|
-
return
|
|
5148
|
+
return _context60.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
4107
5149
|
case 1:
|
|
4108
5150
|
case "end":
|
|
4109
|
-
return
|
|
5151
|
+
return _context60.stop();
|
|
4110
5152
|
}
|
|
4111
|
-
},
|
|
5153
|
+
}, _callee60, this);
|
|
4112
5154
|
}));
|
|
4113
|
-
function removeProductFromOrder(
|
|
5155
|
+
function removeProductFromOrder(_x53) {
|
|
4114
5156
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4115
5157
|
}
|
|
4116
5158
|
return removeProductFromOrder;
|
|
@@ -4160,23 +5202,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4160
5202
|
}, {
|
|
4161
5203
|
key: "applyPromotion",
|
|
4162
5204
|
value: (function () {
|
|
4163
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4164
|
-
return _regeneratorRuntime().wrap(function
|
|
4165
|
-
while (1) switch (
|
|
5205
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61() {
|
|
5206
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5207
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
4166
5208
|
case 0:
|
|
4167
5209
|
if (this.store.order) {
|
|
4168
|
-
|
|
5210
|
+
_context61.next = 2;
|
|
4169
5211
|
break;
|
|
4170
5212
|
}
|
|
4171
5213
|
throw new Error('order 模块未初始化');
|
|
4172
5214
|
case 2:
|
|
4173
|
-
|
|
5215
|
+
_context61.next = 4;
|
|
4174
5216
|
return this.store.order.applyPromotion();
|
|
4175
5217
|
case 4:
|
|
4176
5218
|
case "end":
|
|
4177
|
-
return
|
|
5219
|
+
return _context61.stop();
|
|
4178
5220
|
}
|
|
4179
|
-
},
|
|
5221
|
+
}, _callee61, this);
|
|
4180
5222
|
}));
|
|
4181
5223
|
function applyPromotion() {
|
|
4182
5224
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -4186,16 +5228,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4186
5228
|
}, {
|
|
4187
5229
|
key: "getUnfulfilledPromotions",
|
|
4188
5230
|
value: function getUnfulfilledPromotions() {
|
|
4189
|
-
var _this$store$
|
|
4190
|
-
return ((_this$store$
|
|
5231
|
+
var _this$store$order16;
|
|
5232
|
+
return ((_this$store$order16 = this.store.order) === null || _this$store$order16 === void 0 ? void 0 : _this$store$order16.getUnfulfilledPromotions()) || [];
|
|
4191
5233
|
}
|
|
4192
5234
|
|
|
4193
5235
|
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
4194
5236
|
}, {
|
|
4195
5237
|
key: "getLastGiftActions",
|
|
4196
5238
|
value: function getLastGiftActions() {
|
|
4197
|
-
var _this$store$
|
|
4198
|
-
return ((_this$store$
|
|
5239
|
+
var _this$store$order17;
|
|
5240
|
+
return ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 ? void 0 : _this$store$order17.getLastGiftActions()) || null;
|
|
4199
5241
|
}
|
|
4200
5242
|
|
|
4201
5243
|
// 获取商品列表
|
|
@@ -4203,18 +5245,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4203
5245
|
}, {
|
|
4204
5246
|
key: "getProductList",
|
|
4205
5247
|
value: function () {
|
|
4206
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4207
|
-
var _this$
|
|
5248
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
|
|
5249
|
+
var _this$otherParams26;
|
|
4208
5250
|
var menu_list_ids, _this$store$products, res;
|
|
4209
|
-
return _regeneratorRuntime().wrap(function
|
|
4210
|
-
while (1) switch (
|
|
5251
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
5252
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
4211
5253
|
case 0:
|
|
4212
5254
|
// 可以直接通过配置里的 menu 读取
|
|
4213
|
-
menu_list_ids = ((_this$
|
|
5255
|
+
menu_list_ids = ((_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 || (_this$otherParams26 = _this$otherParams26.dineInConfig) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26['menu.associated_menus'].map(function (n) {
|
|
4214
5256
|
return Number(n.value);
|
|
4215
5257
|
})) || [];
|
|
4216
|
-
|
|
4217
|
-
|
|
5258
|
+
_context62.prev = 1;
|
|
5259
|
+
_context62.next = 4;
|
|
4218
5260
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
4219
5261
|
menu_list_ids: menu_list_ids,
|
|
4220
5262
|
cacheId: this.cacheId,
|
|
@@ -4222,17 +5264,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4222
5264
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
4223
5265
|
});
|
|
4224
5266
|
case 4:
|
|
4225
|
-
res =
|
|
4226
|
-
return
|
|
5267
|
+
res = _context62.sent;
|
|
5268
|
+
return _context62.abrupt("return", res);
|
|
4227
5269
|
case 8:
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
throw
|
|
5270
|
+
_context62.prev = 8;
|
|
5271
|
+
_context62.t0 = _context62["catch"](1);
|
|
5272
|
+
throw _context62.t0;
|
|
4231
5273
|
case 11:
|
|
4232
5274
|
case "end":
|
|
4233
|
-
return
|
|
5275
|
+
return _context62.stop();
|
|
4234
5276
|
}
|
|
4235
|
-
},
|
|
5277
|
+
}, _callee62, this, [[1, 8]]);
|
|
4236
5278
|
}));
|
|
4237
5279
|
function getProductList() {
|
|
4238
5280
|
return _getProductList.apply(this, arguments);
|
|
@@ -4247,33 +5289,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4247
5289
|
}, {
|
|
4248
5290
|
key: "setOtherParams",
|
|
4249
5291
|
value: function () {
|
|
4250
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4251
|
-
var _this$
|
|
4252
|
-
var
|
|
4253
|
-
|
|
5292
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
|
|
5293
|
+
var _this$otherParams27;
|
|
5294
|
+
var _ref39,
|
|
5295
|
+
_ref39$cover,
|
|
4254
5296
|
cover,
|
|
4255
|
-
|
|
4256
|
-
return _regeneratorRuntime().wrap(function
|
|
4257
|
-
while (1) switch (
|
|
5297
|
+
_args63 = arguments;
|
|
5298
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
5299
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
4258
5300
|
case 0:
|
|
4259
|
-
|
|
5301
|
+
_ref39 = _args63.length > 1 && _args63[1] !== undefined ? _args63[1] : {}, _ref39$cover = _ref39.cover, cover = _ref39$cover === void 0 ? false : _ref39$cover;
|
|
4260
5302
|
if (cover) {
|
|
4261
5303
|
this.otherParams = _objectSpread({}, params);
|
|
4262
5304
|
} else {
|
|
4263
5305
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
4264
5306
|
}
|
|
4265
|
-
this.cacheId = (_this$
|
|
4266
|
-
|
|
5307
|
+
this.cacheId = (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.cacheId;
|
|
5308
|
+
_context63.next = 5;
|
|
4267
5309
|
return this.syncOtherParamsToSubModules(params, {
|
|
4268
5310
|
cover: cover
|
|
4269
5311
|
});
|
|
4270
5312
|
case 5:
|
|
4271
5313
|
case "end":
|
|
4272
|
-
return
|
|
5314
|
+
return _context63.stop();
|
|
4273
5315
|
}
|
|
4274
|
-
},
|
|
5316
|
+
}, _callee63, this);
|
|
4275
5317
|
}));
|
|
4276
|
-
function setOtherParams(
|
|
5318
|
+
function setOtherParams(_x54) {
|
|
4277
5319
|
return _setOtherParams.apply(this, arguments);
|
|
4278
5320
|
}
|
|
4279
5321
|
return setOtherParams;
|