@pisell/private-materials 6.4.42 → 6.4.43
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +146 -146
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +8 -8
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +8 -8
- package/es/components/booking/components/actionButtons/index.js +37 -42
- package/es/components/booking/components/actionButtons/index.less +0 -28
- package/es/components/booking/components/footer/amount.d.ts +3 -3
- package/es/components/booking/components/footer/amount.js +13 -2
- package/es/components/booking/components/footer/index.js +168 -68
- package/es/components/booking/components/footer/utils.js +62 -33
- package/es/components/booking/info/model.js +5 -0
- package/es/components/booking/info/service/addService/index.js +2 -1
- package/es/components/booking/info2/index.js +42 -2
- package/es/components/booking/info2/service/addService/index.js +2 -1
- package/es/components/booking/info2/service/editService/index.js +12 -4
- package/es/components/checkout/PaymentModal.d.ts +2 -0
- package/es/components/checkout/PaymentModal.js +395 -240
- package/es/components/checkout/components/AdditionalModule/index.less +1 -1
- package/es/components/checkout/components/AmountSummary/index.js +161 -54
- package/es/components/checkout/components/CashPaymentModule/index.d.ts +5 -3
- package/es/components/checkout/components/CashPaymentModule/index.js +114 -137
- package/es/components/checkout/components/CashPaymentModule/index.less +200 -176
- package/es/components/checkout/components/PaymentDetailModal/index.js +2 -2
- package/es/components/checkout/components/PaymentOptionsModule/PaymentMethodItem.d.ts +29 -0
- package/es/components/checkout/components/PaymentOptionsModule/PaymentMethodItem.js +210 -0
- package/es/components/checkout/components/PaymentOptionsModule/index.d.ts +2 -4
- package/es/components/checkout/components/PaymentOptionsModule/index.js +12 -114
- package/es/components/checkout/components/PaymentOptionsModule/index.less +29 -0
- package/es/components/checkout/components/SavePayLaterHandler/index.js +1 -1
- package/es/components/checkout/components/SearchAndClientModule/index.js +40 -39
- package/es/components/checkout/components/WalletPassModule/index.js +3 -2
- package/es/components/checkout/components/WalletPassModule/utils.js +6 -1
- package/es/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/es/components/checkout/hooks/useWalletPass.js +2 -0
- package/es/components/checkout/index.less +1 -1
- package/es/components/checkout/locales.d.ts +33 -0
- package/es/components/checkout/locales.js +39 -3
- package/es/components/checkout/types.d.ts +1 -0
- package/es/components/eftposPay/hooks.d.ts +1 -1
- package/es/components/eftposPay/store/index.d.ts +2 -2
- package/es/components/shoppingCart/components/Cart/Product.js +143 -71
- package/es/components/shoppingCart/components/Cart/index.js +1 -1
- package/es/components/shoppingCart/components/Cart/index.less +31 -0
- package/es/components/shoppingCart/locales.d.ts +3 -0
- package/es/components/shoppingCart/locales.js +12 -3
- package/es/components/ticketBooking/utils/index.js +2 -1
- package/es/pro/pisellPriceKeyboardPopover/PisellPriceKeyboardPopover.js +1 -1
- package/es/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.d.ts +5 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.js +148 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.less +23 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/index.d.ts +2 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/index.js +1 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/types.d.ts +33 -0
- package/es/pro/pisellSimplePriceKeyboardPopover/types.js +1 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/CashKeyboardIntact.d.ts +4 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/CashKeyboardIntact.js +310 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/CashKeyboardSimple.d.ts +13 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/CashKeyboardSimple.js +349 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/index.d.ts +11 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/index.js +49 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/index.less +103 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/locales.d.ts +39 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/locales.js +41 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/types.d.ts +97 -0
- package/es/pro/priceKeyboard/components/cashKeyboard/types.js +1 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/index.d.ts +22 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/index.js +442 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/index.less +47 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/locales.d.ts +42 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/locales.js +44 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/types.d.ts +17 -0
- package/es/pro/priceKeyboard/components/discountKeyboard/types.js +1 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/index.d.ts +11 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/index.js +444 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/index.less +64 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/locales.d.ts +45 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/locales.js +47 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/types.d.ts +39 -0
- package/es/pro/priceKeyboard/components/paymentKeyboard/types.js +1 -0
- package/es/pro/priceKeyboard/components/shortcuts/index.d.ts +17 -0
- package/es/pro/priceKeyboard/components/shortcuts/index.js +47 -0
- package/es/pro/priceKeyboard/components/shortcuts/index.less +39 -0
- package/es/pro/priceKeyboard/hooks/keyActions.d.ts +28 -0
- package/es/pro/priceKeyboard/hooks/keyActions.js +252 -0
- package/es/pro/priceKeyboard/hooks/rightItems.d.ts +27 -0
- package/es/pro/priceKeyboard/hooks/rightItems.js +50 -0
- package/es/pro/priceKeyboard/index.d.ts +3 -0
- package/es/pro/priceKeyboard/index.js +3 -0
- package/es/pro/priceKeyboard/index.less +215 -0
- package/es/pro/priceKeyboard/utils.d.ts +31 -0
- package/es/pro/priceKeyboard/utils.js +51 -0
- package/es/pro/skuDetailModal/index.js +19 -16
- package/lib/components/booking/components/actionButtons/index.js +31 -28
- package/lib/components/booking/components/actionButtons/index.less +0 -28
- package/lib/components/booking/components/footer/amount.d.ts +3 -3
- package/lib/components/booking/components/footer/amount.js +10 -4
- package/lib/components/booking/components/footer/index.js +107 -40
- package/lib/components/booking/components/footer/utils.js +35 -7
- package/lib/components/booking/info/model.js +3 -0
- package/lib/components/booking/info/service/addService/index.js +2 -1
- package/lib/components/booking/info2/index.js +18 -1
- package/lib/components/booking/info2/service/addService/index.js +2 -1
- package/lib/components/booking/info2/service/editService/index.js +12 -4
- package/lib/components/checkout/PaymentModal.d.ts +2 -0
- package/lib/components/checkout/PaymentModal.js +152 -73
- package/lib/components/checkout/components/AdditionalModule/index.less +1 -1
- package/lib/components/checkout/components/AmountSummary/index.js +114 -40
- package/lib/components/checkout/components/CashPaymentModule/index.d.ts +5 -3
- package/lib/components/checkout/components/CashPaymentModule/index.js +103 -140
- package/lib/components/checkout/components/CashPaymentModule/index.less +200 -176
- package/lib/components/checkout/components/PaymentDetailModal/index.js +2 -2
- package/lib/components/checkout/components/PaymentOptionsModule/PaymentMethodItem.d.ts +29 -0
- package/lib/components/checkout/components/PaymentOptionsModule/PaymentMethodItem.js +172 -0
- package/lib/components/checkout/components/PaymentOptionsModule/index.d.ts +2 -4
- package/lib/components/checkout/components/PaymentOptionsModule/index.js +11 -123
- package/lib/components/checkout/components/PaymentOptionsModule/index.less +29 -0
- package/lib/components/checkout/components/SavePayLaterHandler/index.js +1 -1
- package/lib/components/checkout/components/SearchAndClientModule/index.js +3 -29
- package/lib/components/checkout/components/WalletPassModule/index.js +3 -2
- package/lib/components/checkout/components/WalletPassModule/utils.js +4 -1
- package/lib/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/lib/components/checkout/hooks/useWalletPass.js +2 -0
- package/lib/components/checkout/index.less +1 -1
- package/lib/components/checkout/locales.d.ts +33 -0
- package/lib/components/checkout/locales.js +39 -3
- package/lib/components/checkout/types.d.ts +1 -0
- package/lib/components/eftposPay/hooks.d.ts +1 -1
- package/lib/components/eftposPay/store/index.d.ts +2 -2
- package/lib/components/shoppingCart/components/Cart/Product.js +111 -51
- package/lib/components/shoppingCart/components/Cart/index.js +1 -1
- package/lib/components/shoppingCart/components/Cart/index.less +31 -0
- package/lib/components/shoppingCart/locales.d.ts +3 -0
- package/lib/components/shoppingCart/locales.js +6 -3
- package/lib/components/ticketBooking/index.js +5 -1
- package/lib/components/ticketBooking/utils/index.js +2 -1
- package/lib/pro/pisellPriceKeyboardPopover/PisellPriceKeyboardPopover.js +2 -2
- package/lib/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.d.ts +5 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.js +144 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.less +23 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/index.d.ts +2 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/index.js +35 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/types.d.ts +33 -0
- package/lib/pro/pisellSimplePriceKeyboardPopover/types.js +17 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/CashKeyboardIntact.d.ts +4 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/CashKeyboardIntact.js +332 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/CashKeyboardSimple.d.ts +13 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/CashKeyboardSimple.js +399 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/index.d.ts +11 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/index.js +76 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/index.less +103 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/locales.d.ts +39 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/locales.js +65 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/types.d.ts +97 -0
- package/lib/pro/priceKeyboard/components/cashKeyboard/types.js +17 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/index.d.ts +22 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/index.js +485 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/index.less +47 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/locales.d.ts +42 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/locales.js +68 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/types.d.ts +17 -0
- package/lib/pro/priceKeyboard/components/discountKeyboard/types.js +17 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/index.d.ts +11 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/index.js +488 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/index.less +64 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/locales.d.ts +45 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/locales.js +71 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/types.d.ts +39 -0
- package/lib/pro/priceKeyboard/components/paymentKeyboard/types.js +17 -0
- package/lib/pro/priceKeyboard/components/shortcuts/index.d.ts +17 -0
- package/lib/pro/priceKeyboard/components/shortcuts/index.js +79 -0
- package/lib/pro/priceKeyboard/components/shortcuts/index.less +39 -0
- package/lib/pro/priceKeyboard/hooks/keyActions.d.ts +28 -0
- package/lib/pro/priceKeyboard/hooks/keyActions.js +176 -0
- package/lib/pro/priceKeyboard/hooks/rightItems.d.ts +27 -0
- package/lib/pro/priceKeyboard/hooks/rightItems.js +81 -0
- package/lib/pro/priceKeyboard/index.d.ts +3 -0
- package/lib/pro/priceKeyboard/index.js +45 -0
- package/lib/pro/priceKeyboard/index.less +215 -0
- package/lib/pro/priceKeyboard/utils.d.ts +31 -0
- package/lib/pro/priceKeyboard/utils.js +75 -0
- package/lib/pro/skuDetailModal/index.js +18 -22
- package/package.json +4 -4
@@ -16,13 +16,14 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
16
16
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
17
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
18
18
|
import React, { useRef, useState, useEffect, useCallback, useMemo, useImperativeHandle, forwardRef } from 'react';
|
19
|
+
import Decimal from 'decimal.js';
|
19
20
|
import { locales, webPrint } from '@pisell/utils';
|
20
21
|
import { getLocale } from "../../utils/locales";
|
21
22
|
import { useMemoizedFn } from 'ahooks';
|
22
23
|
import { createPortal } from 'react-dom';
|
23
24
|
import ReactDOM from 'react-dom';
|
24
25
|
import checkoutLocales from "./locales";
|
25
|
-
import { PisellContainer,
|
26
|
+
import { PisellContainer, Icon, useToast, ConfigProvider } from '@pisell/materials';
|
26
27
|
import useEngineContext from "../../hooks/useEngineContext";
|
27
28
|
import NoteModal from "../../plus/noteModal";
|
28
29
|
import SendPaymentLinkModal from "./components/SendPaymentLinkModal";
|
@@ -45,6 +46,7 @@ import { cloneDeep } from 'lodash';
|
|
45
46
|
import { getShopWalletPassId, reorderPaymentMethodList } from "./utils";
|
46
47
|
import usePaymentLogger from "./hooks/usePaymentLogger";
|
47
48
|
import { Button } from 'antd';
|
49
|
+
import { DiscountKeyboard } from "../../pro/priceKeyboard";
|
48
50
|
|
49
51
|
// Checkout 模块的事件常量
|
50
52
|
var CheckoutHooks = {
|
@@ -86,7 +88,9 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
86
88
|
dynamicMaxHeight = _ref$dynamicMaxHeight === void 0 ? '600px' : _ref$dynamicMaxHeight,
|
87
89
|
onOrderSyncFailed = _ref.onOrderSyncFailed,
|
88
90
|
generateActionButtons = _ref.generateActionButtons,
|
89
|
-
paymentResultToastConfig = _ref.paymentResultToastConfig
|
91
|
+
paymentResultToastConfig = _ref.paymentResultToastConfig,
|
92
|
+
updateOrderInfo = _ref.updateOrderInfo,
|
93
|
+
setCurrentEditOrderId = _ref.setCurrentEditOrderId;
|
90
94
|
var context = useEngineContext();
|
91
95
|
var utils = context.appHelper.utils || {};
|
92
96
|
var pisellos = utils.pisellos,
|
@@ -137,6 +141,10 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
137
141
|
_useState16 = _slicedToArray(_useState15, 2),
|
138
142
|
walletPassData = _useState16[0],
|
139
143
|
setWalletPassData = _useState16[1];
|
144
|
+
var _useState17 = useState(false),
|
145
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
146
|
+
syncingLock = _useState18[0],
|
147
|
+
setSyncingLock = _useState18[1];
|
140
148
|
var isOrderFree = useMemo(function () {
|
141
149
|
if (!customAmount) return false;
|
142
150
|
var amount = parseFloat(customAmount);
|
@@ -144,14 +152,14 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
144
152
|
}, [customAmount]);
|
145
153
|
|
146
154
|
// 新增状态:订单备注和手动折扣
|
147
|
-
var _useState17 = useState(false),
|
148
|
-
_useState18 = _slicedToArray(_useState17, 2),
|
149
|
-
paymentLinkModalOpen = _useState18[0],
|
150
|
-
setPaymentLinkModalOpen = _useState18[1];
|
151
155
|
var _useState19 = useState(false),
|
152
156
|
_useState20 = _slicedToArray(_useState19, 2),
|
153
|
-
|
154
|
-
|
157
|
+
paymentLinkModalOpen = _useState20[0],
|
158
|
+
setPaymentLinkModalOpen = _useState20[1];
|
159
|
+
var _useState21 = useState(false),
|
160
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
161
|
+
showPriceAdjustModal = _useState22[0],
|
162
|
+
setShowPriceAdjustModal = _useState22[1];
|
155
163
|
var logger = usePaymentLogger();
|
156
164
|
var currency = getData('shop_currency_code') || 'USD';
|
157
165
|
|
@@ -239,11 +247,13 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
239
247
|
};
|
240
248
|
var onPaymentOptionClick = /*#__PURE__*/function () {
|
241
249
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(method) {
|
242
|
-
var
|
250
|
+
var _method$totalAmount;
|
251
|
+
var _ref4, id, code, name, type, finalAmount, eftposCodes, mx51Code, payType, _paymentMethodsRef$cu, data, isSynced, _orderId, _method$metadata, service_charge, _interaction$utils2, _interaction$utils2$p;
|
243
252
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
244
253
|
while (1) switch (_context2.prev = _context2.next) {
|
245
254
|
case 0:
|
246
|
-
_ref4 = method || {}, id = _ref4.id, code = _ref4.code, name = _ref4.name, type = _ref4.type;
|
255
|
+
_ref4 = method || {}, id = _ref4.id, code = _ref4.code, name = _ref4.name, type = _ref4.type;
|
256
|
+
finalAmount = (_method$totalAmount = method.totalAmount) !== null && _method$totalAmount !== void 0 ? _method$totalAmount : customAmount; // 这里需要根据支付方式来判断是 eftpos 还是 mx51
|
247
257
|
eftposCodes = ['EFTPOS_LINKLY', 'EFTPOS_PAYO', 'EFTPOS_WINDCAVE', 'EFTPOS_TYRO'];
|
248
258
|
mx51Code = 'EFTPOS';
|
249
259
|
payType = '';
|
@@ -253,32 +263,32 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
253
263
|
payType = 'mx51';
|
254
264
|
}
|
255
265
|
if (!payType) {
|
256
|
-
_context2.next =
|
266
|
+
_context2.next = 23;
|
257
267
|
break;
|
258
268
|
}
|
259
|
-
_context2.next =
|
269
|
+
_context2.next = 9;
|
260
270
|
return checkoutModule.isCurrentOrderSynced();
|
261
|
-
case
|
271
|
+
case 9:
|
262
272
|
isSynced = _context2.sent;
|
263
273
|
if (isSynced) {
|
264
|
-
_context2.next =
|
274
|
+
_context2.next = 16;
|
265
275
|
break;
|
266
276
|
}
|
267
|
-
_context2.next =
|
277
|
+
_context2.next = 13;
|
268
278
|
return checkoutModule.manualSyncOrderAsync();
|
269
|
-
case
|
279
|
+
case 13:
|
270
280
|
data = _context2.sent;
|
271
|
-
_context2.next =
|
281
|
+
_context2.next = 20;
|
272
282
|
break;
|
273
|
-
case
|
274
|
-
_context2.next =
|
283
|
+
case 16:
|
284
|
+
_context2.next = 18;
|
275
285
|
return checkoutModule.getCurrentOrderId();
|
276
|
-
case
|
277
|
-
|
286
|
+
case 18:
|
287
|
+
_orderId = _context2.sent;
|
278
288
|
data = {
|
279
|
-
orderId:
|
289
|
+
orderId: _orderId
|
280
290
|
};
|
281
|
-
case
|
291
|
+
case 20:
|
282
292
|
(_paymentMethodsRef$cu = paymentMethodsRef.current) === null || _paymentMethodsRef$cu === void 0 || _paymentMethodsRef$cu.onPay(payType, {
|
283
293
|
source: 'normal',
|
284
294
|
data: {
|
@@ -291,7 +301,7 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
291
301
|
params: {
|
292
302
|
orderId: data.orderId,
|
293
303
|
symbol: getData('shop_symbol'),
|
294
|
-
amount:
|
304
|
+
amount: finalAmount,
|
295
305
|
surcharge: processSurcharge(method.surcharge)
|
296
306
|
},
|
297
307
|
mode: 'pay'
|
@@ -342,9 +352,9 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
342
352
|
}
|
343
353
|
}
|
344
354
|
});
|
345
|
-
_context2.next =
|
355
|
+
_context2.next = 28;
|
346
356
|
break;
|
347
|
-
case
|
357
|
+
case 23:
|
348
358
|
service_charge = null;
|
349
359
|
if (method !== null && method !== void 0 && method.fixed || method !== null && method !== void 0 && method.percentage) {
|
350
360
|
service_charge = {
|
@@ -352,10 +362,23 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
352
362
|
percentage: (method === null || method === void 0 ? void 0 : method.percentage) || '0'
|
353
363
|
};
|
354
364
|
}
|
365
|
+
// 如果是自定义支付并且开启了钱箱,则先打开钱箱
|
366
|
+
if (method.type === 'custom' && (_method$metadata = method.metadata) !== null && _method$metadata !== void 0 && _method$metadata.order_open_cash_drawer) {
|
367
|
+
logger === null || logger === void 0 || logger.addLog({
|
368
|
+
type: 'info',
|
369
|
+
title: 'open_till',
|
370
|
+
metadata: {}
|
371
|
+
});
|
372
|
+
// handleToastClose();
|
373
|
+
interaction === null || interaction === void 0 || (_interaction$utils2 = interaction.utils) === null || _interaction$utils2 === void 0 || (_interaction$utils2$p = _interaction$utils2.postMessageToApp) === null || _interaction$utils2$p === void 0 || _interaction$utils2$p.call(_interaction$utils2, {
|
374
|
+
module: 'till',
|
375
|
+
key: 'open_till'
|
376
|
+
});
|
377
|
+
}
|
355
378
|
// 从支付方式列表中查找现金支付方式
|
356
|
-
_context2.next =
|
379
|
+
_context2.next = 28;
|
357
380
|
return checkoutModule === null || checkoutModule === void 0 ? void 0 : checkoutModule.addPaymentItemAsync({
|
358
|
-
amount:
|
381
|
+
amount: finalAmount,
|
359
382
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
360
383
|
code: method.code,
|
361
384
|
/** 支付类型id,跟支付列表上对应的支付方式保持一致 */
|
@@ -369,7 +392,7 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
369
392
|
/** 支付手续费 */
|
370
393
|
service_charge: service_charge
|
371
394
|
});
|
372
|
-
case
|
395
|
+
case 28:
|
373
396
|
case "end":
|
374
397
|
return _context2.stop();
|
375
398
|
}
|
@@ -435,6 +458,9 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
435
458
|
return _ref6.apply(this, arguments);
|
436
459
|
};
|
437
460
|
}());
|
461
|
+
checkoutModule.getCurrentOrderPaymentItemsAsync().then(function (items) {
|
462
|
+
setPaymentItems(items);
|
463
|
+
});
|
438
464
|
}
|
439
465
|
}, [checkoutModule, orderInfo]);
|
440
466
|
|
@@ -491,9 +517,11 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
491
517
|
});
|
492
518
|
var orderSubmitStartUnsubscribe = core.effects.on(CheckoutHooks.OnOrderSubmitStart, function () {
|
493
519
|
var _Toast$loading;
|
520
|
+
setSyncingLock(true);
|
494
521
|
Toast === null || Toast === void 0 || (_Toast$loading = Toast.loading) === null || _Toast$loading === void 0 || _Toast$loading.call(Toast);
|
495
522
|
});
|
496
523
|
var orderSubmitEndUnsubscribe = core.effects.on(CheckoutHooks.OnOrderSubmitEnd, function (res) {
|
524
|
+
setSyncingLock(false);
|
497
525
|
if (res.success) {
|
498
526
|
var _Toast$hide;
|
499
527
|
Toast === null || Toast === void 0 || (_Toast$hide = Toast.hide) === null || _Toast$hide === void 0 || _Toast$hide.call(Toast);
|
@@ -519,22 +547,46 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
519
547
|
// );
|
520
548
|
var orderPaymentAddedUnsubscribe = core.effects.on(CheckoutHooks.OnOrderPaymentAdded, /*#__PURE__*/function () {
|
521
549
|
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(data) {
|
522
|
-
var balanceDueAmount, autoCloseConfig,
|
550
|
+
var orderInfo, balanceDueAmount, autoCloseConfig, _paymentItems, _totalAmount, serviceChargeTotal, paymentMethodName, isCashPayment, _interaction$utils3, _interaction$utils3$p;
|
523
551
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
524
552
|
while (1) switch (_context5.prev = _context5.next) {
|
525
553
|
case 0:
|
526
554
|
console.log('orderPaymentAddedUnsubscribe>>>>', data);
|
555
|
+
// 需要更新 order_info
|
556
|
+
orderInfo = checkoutModule.getCurrentOrderInfo();
|
557
|
+
updateOrderInfo === null || updateOrderInfo === void 0 || updateOrderInfo(orderInfo);
|
527
558
|
balanceDueAmount = checkoutModule.getBalanceDueAmount();
|
528
559
|
if (!(Number(balanceDueAmount) > 0)) {
|
529
|
-
_context5.next =
|
560
|
+
_context5.next = 13;
|
530
561
|
break;
|
531
562
|
}
|
532
563
|
autoCloseConfig = calculateAutoCloseConfig('partially_paid', false); // 获取订单总金额
|
533
|
-
|
534
|
-
|
564
|
+
_context5.next = 8;
|
565
|
+
return checkoutModule.getCurrentOrderPaymentItemsAsync();
|
566
|
+
case 8:
|
567
|
+
_paymentItems = _context5.sent;
|
568
|
+
_totalAmount = new Decimal(orderInfo.isDeposit ? orderInfo.depositAmount : orderInfo.totalAmount); // 如果现在有支付项了,而且还有手续费产生,totalAmount 的计算需要加上手续费
|
569
|
+
if (_paymentItems.length > 0 && _paymentItems.filter(function (n) {
|
570
|
+
return n.isSynced;
|
571
|
+
}).some(function (item) {
|
572
|
+
return item.service_charge;
|
573
|
+
})) {
|
574
|
+
serviceChargeTotal = _paymentItems.reduce(function (acc, item) {
|
575
|
+
var _item$service_charge, _item$service_charge2;
|
576
|
+
var chargeAmount = new Decimal(((_item$service_charge = item.service_charge) === null || _item$service_charge === void 0 ? void 0 : _item$service_charge.amount) || 0);
|
577
|
+
var chargePercentage = new Decimal(((_item$service_charge2 = item.service_charge) === null || _item$service_charge2 === void 0 ? void 0 : _item$service_charge2.percentage) || 0);
|
578
|
+
var itemAmount = new Decimal(item.amount || 0);
|
579
|
+
var itemServiceCharge = chargeAmount.add(chargePercentage.mul(itemAmount));
|
580
|
+
return acc.add(itemServiceCharge);
|
581
|
+
}, new Decimal(0));
|
582
|
+
_totalAmount = _totalAmount.add(serviceChargeTotal);
|
583
|
+
}
|
584
|
+
|
585
|
+
// 根据支付状态展示不同的 toast
|
586
|
+
_context5.next = 13;
|
535
587
|
return displayPaymentResultToast({
|
536
588
|
paymentStatus: 'partially_paid',
|
537
|
-
orderTotalAmount:
|
589
|
+
orderTotalAmount: _totalAmount.toNumber(),
|
538
590
|
gapAmount: balanceDueAmount,
|
539
591
|
failureReason: '',
|
540
592
|
autoCloseConfig: autoCloseConfig,
|
@@ -549,7 +601,23 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
549
601
|
// 不自动关闭Modal,让两个弹窗独立管理
|
550
602
|
}
|
551
603
|
}));
|
552
|
-
case
|
604
|
+
case 13:
|
605
|
+
// 判断是否为现金支付
|
606
|
+
paymentMethodName = data.paymentMethodName || data.name || '';
|
607
|
+
isCashPayment = data.paymentMethodCode === 'CASHMANUAL' || /现金|現金/i.test(paymentMethodName) || /cash/i.test(paymentMethodName);
|
608
|
+
if (isCashPayment) {
|
609
|
+
logger === null || logger === void 0 || logger.addLog({
|
610
|
+
type: 'info',
|
611
|
+
title: 'open_till',
|
612
|
+
metadata: {}
|
613
|
+
});
|
614
|
+
// handleToastClose();
|
615
|
+
interaction === null || interaction === void 0 || (_interaction$utils3 = interaction.utils) === null || _interaction$utils3 === void 0 || (_interaction$utils3$p = _interaction$utils3.postMessageToApp) === null || _interaction$utils3$p === void 0 || _interaction$utils3$p.call(_interaction$utils3, {
|
616
|
+
module: 'till',
|
617
|
+
key: 'open_till'
|
618
|
+
});
|
619
|
+
}
|
620
|
+
case 16:
|
553
621
|
case "end":
|
554
622
|
return _context5.stop();
|
555
623
|
}
|
@@ -652,7 +720,7 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
652
720
|
// 当 walletpass 直接就满足订单支付时,触发此方法
|
653
721
|
var handleWalletPassConfirmPay = /*#__PURE__*/function () {
|
654
722
|
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(action) {
|
655
|
-
var result, _result$response, responseData, _responseData$payment, params;
|
723
|
+
var result, _result$response, _orderInfo, responseData, _responseData$payment, params;
|
656
724
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
657
725
|
while (1) switch (_context8.prev = _context8.next) {
|
658
726
|
case 0:
|
@@ -679,30 +747,42 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
679
747
|
_context8.next = 12;
|
680
748
|
return showSuccessToast === null || showSuccessToast === void 0 ? void 0 : showSuccessToast(result);
|
681
749
|
case 12:
|
682
|
-
if (result.success) {
|
683
|
-
|
684
|
-
|
685
|
-
try {
|
686
|
-
params = {
|
687
|
-
type: '99',
|
688
|
-
// 打印订单全部信息
|
689
|
-
data: {
|
690
|
-
order_id: responseData.order_id,
|
691
|
-
machine_code_print_info: responseData === null || responseData === void 0 ? void 0 : responseData.machine_code_print_info,
|
692
|
-
small_ticket_data: responseData === null || responseData === void 0 || (_responseData$payment = responseData.payment_info) === null || _responseData$payment === void 0 ? void 0 : _responseData$payment.small_ticket_data
|
693
|
-
}
|
694
|
-
};
|
695
|
-
console.log('print_order_onOrderSynced_params>>>>', params);
|
696
|
-
webPrint(params, function (res) {
|
697
|
-
console.log('print_order_onOrderSynced_res>>>>', res);
|
698
|
-
});
|
699
|
-
} catch (error) {
|
700
|
-
console.error('print_order_onOrderSynced_error>>>>', error);
|
701
|
-
}
|
702
|
-
// 支付成功时关闭 PaymentModal
|
703
|
-
onPaymentCancel(true);
|
750
|
+
if (!result.success) {
|
751
|
+
_context8.next = 22;
|
752
|
+
break;
|
704
753
|
}
|
705
|
-
|
754
|
+
// 检查订单此时是不是定金支付订单
|
755
|
+
_orderInfo = checkoutModule.getCurrentOrderInfo();
|
756
|
+
setCurrentEditOrderId === null || setCurrentEditOrderId === void 0 || setCurrentEditOrderId(result.orderId);
|
757
|
+
if (!(result.is_deposit && Number(_orderInfo.depositAmount < _orderInfo.totalAmount))) {
|
758
|
+
_context8.next = 18;
|
759
|
+
break;
|
760
|
+
}
|
761
|
+
updateOrderInfo === null || updateOrderInfo === void 0 || updateOrderInfo(_orderInfo);
|
762
|
+
return _context8.abrupt("return");
|
763
|
+
case 18:
|
764
|
+
responseData = (_result$response = result.response) === null || _result$response === void 0 ? void 0 : _result$response.data; // 打印订单完整信息
|
765
|
+
console.log('print_order_onOrderSynced>>>>', result);
|
766
|
+
try {
|
767
|
+
params = {
|
768
|
+
type: '99',
|
769
|
+
// 打印订单全部信息
|
770
|
+
data: {
|
771
|
+
order_id: responseData.order_id,
|
772
|
+
machine_code_print_info: responseData === null || responseData === void 0 ? void 0 : responseData.machine_code_print_info,
|
773
|
+
small_ticket_data: responseData === null || responseData === void 0 || (_responseData$payment = responseData.payment_info) === null || _responseData$payment === void 0 ? void 0 : _responseData$payment.small_ticket_data
|
774
|
+
}
|
775
|
+
};
|
776
|
+
console.log('print_order_onOrderSynced_params>>>>', params);
|
777
|
+
webPrint(params, function (res) {
|
778
|
+
console.log('print_order_onOrderSynced_res>>>>', res);
|
779
|
+
});
|
780
|
+
} catch (error) {
|
781
|
+
console.error('print_order_onOrderSynced_error>>>>', error);
|
782
|
+
}
|
783
|
+
// 支付成功时关闭 PaymentModal
|
784
|
+
onPaymentCancel(true);
|
785
|
+
case 22:
|
706
786
|
case "end":
|
707
787
|
return _context8.stop();
|
708
788
|
}
|
@@ -834,6 +914,11 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
834
914
|
return 0;
|
835
915
|
}
|
836
916
|
}, [state, showPriceAdjustModal]);
|
917
|
+
|
918
|
+
// 手动折扣后订单总价
|
919
|
+
var currentTotalPriceAfterDiscount = useMemo(function () {
|
920
|
+
return new Decimal(currentTotalPrice).minus(state.shop_discount || 0).toNumber();
|
921
|
+
}, [state.shop_discount, currentTotalPrice]);
|
837
922
|
var handleSelectWalletChange = useMemoizedFn( /*#__PURE__*/function () {
|
838
923
|
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(select) {
|
839
924
|
var voucherItems, data;
|
@@ -891,32 +976,19 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
891
976
|
|
892
977
|
// 手动折扣相关处理函数
|
893
978
|
var handlePriceAdjustConfirm = /*#__PURE__*/function () {
|
894
|
-
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(
|
895
|
-
var ScheduleModule, _getSumTotal2, productAmount, discountAmount;
|
979
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(discountAmount) {
|
896
980
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
897
981
|
while (1) switch (_context11.prev = _context11.next) {
|
898
982
|
case 0:
|
899
983
|
try {
|
900
984
|
if (checkoutModule && orderInfo !== null && orderInfo !== void 0 && orderInfo.totalAmount) {
|
901
985
|
if (dispatch) {
|
902
|
-
ScheduleModule = pisellosAllModule.ScheduleModule;
|
903
|
-
_getSumTotal2 = getSumTotal(state, {
|
904
|
-
isEdit: true,
|
905
|
-
ScheduleModule: ScheduleModule
|
906
|
-
}), productAmount = _getSumTotal2.productAmount; // 计算折扣金额(商品总金额 - 新价格)
|
907
|
-
// 存储正数:正数表示折扣,0表示无折扣
|
908
|
-
discountAmount = Math.max(0, productAmount - newPrice); // 转换为金额字符串格式(2位小数)
|
909
|
-
// const discountAmountStr = formatAmount(discountAmount, 2, '');
|
910
|
-
// 修改os 中折扣的数据
|
911
|
-
// await checkoutModule.updateShopDiscountAsync(discountAmountStr);
|
912
|
-
// 同步修改购物车的数据
|
913
986
|
dispatch({
|
914
987
|
type: 'setState',
|
915
988
|
payload: {
|
916
989
|
shop_discount: discountAmount
|
917
990
|
}
|
918
991
|
});
|
919
|
-
// 修改 pisellos 中 shop_discount 的值
|
920
992
|
}
|
921
993
|
}
|
922
994
|
} catch (error) {
|
@@ -936,7 +1008,7 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
936
1008
|
var handleButtonClick = /*#__PURE__*/function () {
|
937
1009
|
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(key) {
|
938
1010
|
var _savePayLaterHandlerR;
|
939
|
-
var data, isSynced,
|
1011
|
+
var data, isSynced, _orderId2, params, _paymentItems2;
|
940
1012
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
941
1013
|
while (1) switch (_context12.prev = _context12.next) {
|
942
1014
|
case 0:
|
@@ -969,9 +1041,9 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
969
1041
|
_context12.next = 19;
|
970
1042
|
return checkoutModule.getCurrentOrderId();
|
971
1043
|
case 19:
|
972
|
-
|
1044
|
+
_orderId2 = _context12.sent;
|
973
1045
|
data = {
|
974
|
-
orderId:
|
1046
|
+
orderId: _orderId2
|
975
1047
|
};
|
976
1048
|
case 21:
|
977
1049
|
console.log('handleButtonClick_print-receipt_data>>>>', data);
|
@@ -1006,8 +1078,8 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
1006
1078
|
_context12.next = 29;
|
1007
1079
|
return checkoutModule.getCurrentOrderPaymentItemsAsync();
|
1008
1080
|
case 29:
|
1009
|
-
|
1010
|
-
if (!(
|
1081
|
+
_paymentItems2 = _context12.sent;
|
1082
|
+
if (!(_paymentItems2 !== null && _paymentItems2 !== void 0 && _paymentItems2.length)) {
|
1011
1083
|
_context12.next = 33;
|
1012
1084
|
break;
|
1013
1085
|
}
|
@@ -1165,7 +1237,7 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
1165
1237
|
onSearch: handleSearch
|
1166
1238
|
}, searchAndClientProps)), moduleConfig.showWalletPass && /*#__PURE__*/React.createElement(WalletPassModule, {
|
1167
1239
|
clientId: state === null || state === void 0 || (_state$client2 = state.client) === null || _state$client2 === void 0 || (_state$client2 = _state$client2.value) === null || _state$client2 === void 0 ? void 0 : _state$client2.id,
|
1168
|
-
customAmount:
|
1240
|
+
customAmount: balanceDueAmount,
|
1169
1241
|
orderInfo: orderInfo || undefined,
|
1170
1242
|
ref: walletPassRef,
|
1171
1243
|
paymentItems: paymentItems,
|
@@ -1193,8 +1265,10 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
1193
1265
|
gridRow: '1'
|
1194
1266
|
} : {}
|
1195
1267
|
}, /*#__PURE__*/React.createElement(CashPaymentModule, {
|
1268
|
+
disabled: isOrderFree,
|
1196
1269
|
isModalOpen: isModalOpen,
|
1197
|
-
|
1270
|
+
syncingLock: syncingLock,
|
1271
|
+
amountSymbol: getData('shop_symbol'),
|
1198
1272
|
orderInfo: orderInfo || undefined,
|
1199
1273
|
onPaymentComplete: handleAddCashPayment,
|
1200
1274
|
amountButtons: recommendAmounts,
|
@@ -1242,34 +1316,20 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
1242
1316
|
return setPaymentLinkModalOpen(false);
|
1243
1317
|
},
|
1244
1318
|
sendPaymentLink: handleSendCustomerPaymentLink
|
1245
|
-
}),
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
background: 'transparent',
|
1253
|
-
width: '100%',
|
1254
|
-
height: '100%',
|
1255
|
-
position: 'absolute',
|
1256
|
-
top: 0,
|
1257
|
-
left: 0
|
1258
|
-
},
|
1259
|
-
onClick: function onClick() {
|
1260
|
-
return setShowPriceAdjustModal(false);
|
1319
|
+
}), /*#__PURE__*/React.createElement(DiscountKeyboard, {
|
1320
|
+
containerProps: {
|
1321
|
+
renderType: 'modal',
|
1322
|
+
open: showPriceAdjustModal,
|
1323
|
+
onCancel: function onCancel() {
|
1324
|
+
return setShowPriceAdjustModal(false);
|
1325
|
+
}
|
1261
1326
|
},
|
1262
|
-
"aria-label": locales.getText('pisell2.checkout.modal.close-price-adjustment') || 'Close price adjustment modal'
|
1263
|
-
}), /*#__PURE__*/React.createElement("div", {
|
1264
|
-
className: "pisell-price-adjust-container"
|
1265
|
-
}, /*#__PURE__*/React.createElement(PisellAdjustPrice, {
|
1266
1327
|
selectType: "dark",
|
1267
|
-
|
1268
|
-
|
1269
|
-
onChange: handlePriceAdjustConfirm,
|
1328
|
+
originalValue: currentTotalPrice,
|
1329
|
+
defaultValue: currentTotalPriceAfterDiscount,
|
1270
1330
|
resetText: locales.getText('pisell2.checkout.modal.reset-price-adjustment'),
|
1271
|
-
|
1272
|
-
})
|
1331
|
+
onEnter: handlePriceAdjustConfirm
|
1332
|
+
}), /*#__PURE__*/React.createElement(SavePayLaterHandler, {
|
1273
1333
|
ref: savePayLaterHandlerRef,
|
1274
1334
|
amountSymbol: state.amountSymbol,
|
1275
1335
|
walletPassData: walletPassData,
|
@@ -1286,33 +1346,39 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1286
1346
|
callback = _ref18.callback,
|
1287
1347
|
onClose = _ref18.onClose,
|
1288
1348
|
dispatch = _ref18.dispatch,
|
1289
|
-
state = _ref18.state
|
1349
|
+
state = _ref18.state,
|
1350
|
+
setEditCartMode = _ref18.setEditCartMode,
|
1351
|
+
editOrderId = _ref18.editOrderId;
|
1290
1352
|
var context = useEngineContext();
|
1291
1353
|
locales.init(checkoutLocales, ((_context$appHelper$ut = context.appHelper.utils) === null || _context$appHelper$ut === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut.getApp) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut2.call(_context$appHelper$ut)) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut2.locales) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut3 = _context$appHelper$ut2.getLocale) === null || _context$appHelper$ut3 === void 0 ? void 0 : _context$appHelper$ut3.call(_context$appHelper$ut2)) || ((_context$appHelper$ut4 = context.appHelper.utils) === null || _context$appHelper$ut4 === void 0 || (_context$appHelper$ut4 = _context$appHelper$ut4.storage) === null || _context$appHelper$ut4 === void 0 ? void 0 : _context$appHelper$ut4.get('umi_locale')) || 'en');
|
1292
1354
|
var _ref19 = (context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {},
|
1293
1355
|
pisellos = _ref19.pisellos,
|
1294
1356
|
getData = _ref19.getData,
|
1295
1357
|
interaction = _ref19.interaction;
|
1296
|
-
var
|
1297
|
-
_useState22 = _slicedToArray(_useState21, 2),
|
1298
|
-
orderInfo = _useState22[0],
|
1299
|
-
setOrderInfo = _useState22[1];
|
1300
|
-
var _useState23 = useState(0),
|
1358
|
+
var _useState23 = useState(null),
|
1301
1359
|
_useState24 = _slicedToArray(_useState23, 2),
|
1302
|
-
|
1303
|
-
|
1304
|
-
var _useState25 = useState(
|
1360
|
+
orderInfo = _useState24[0],
|
1361
|
+
setOrderInfo = _useState24[1];
|
1362
|
+
var _useState25 = useState(0),
|
1305
1363
|
_useState26 = _slicedToArray(_useState25, 2),
|
1306
|
-
|
1307
|
-
|
1308
|
-
var _useState27 = useState(
|
1364
|
+
totalAmount = _useState26[0],
|
1365
|
+
setTotalAmount = _useState26[1];
|
1366
|
+
var _useState27 = useState(true),
|
1309
1367
|
_useState28 = _slicedToArray(_useState27, 2),
|
1310
|
-
|
1311
|
-
|
1312
|
-
var _useState29 = useState(
|
1368
|
+
actualShowCashPayment = _useState28[0],
|
1369
|
+
setActualShowCashPayment = _useState28[1];
|
1370
|
+
var _useState29 = useState(0),
|
1313
1371
|
_useState30 = _slicedToArray(_useState29, 2),
|
1314
|
-
|
1315
|
-
|
1372
|
+
windowHeight = _useState30[0],
|
1373
|
+
setWindowHeight = _useState30[1];
|
1374
|
+
var _useState31 = useState(false),
|
1375
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
1376
|
+
showRetryModal = _useState32[0],
|
1377
|
+
setShowRetryModal = _useState32[1];
|
1378
|
+
var _useState33 = useState(editOrderId || 0),
|
1379
|
+
_useState34 = _slicedToArray(_useState33, 2),
|
1380
|
+
currentEditOrderId = _useState34[0],
|
1381
|
+
_setCurrentEditOrderId = _useState34[1];
|
1316
1382
|
var Toast = useToast();
|
1317
1383
|
|
1318
1384
|
// 重试处理函数(逻辑由用户自己实现)
|
@@ -1377,17 +1443,17 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1377
1443
|
|
1378
1444
|
// 初始化 tillButton 数据
|
1379
1445
|
useEffect(function () {
|
1380
|
-
var _interaction$
|
1446
|
+
var _interaction$utils5;
|
1381
1447
|
var initTillButtonData = /*#__PURE__*/function () {
|
1382
1448
|
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
1383
|
-
var _interaction$
|
1449
|
+
var _interaction$utils4, _interaction$utils4$a, tillButtonData;
|
1384
1450
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
1385
1451
|
while (1) switch (_context16.prev = _context16.next) {
|
1386
1452
|
case 0:
|
1387
1453
|
console.log('准备获取tillButton数据');
|
1388
1454
|
_context16.prev = 1;
|
1389
1455
|
_context16.next = 4;
|
1390
|
-
return interaction === null || interaction === void 0 || (_interaction$
|
1456
|
+
return interaction === null || interaction === void 0 || (_interaction$utils4 = interaction.utils) === null || _interaction$utils4 === void 0 || (_interaction$utils4$a = _interaction$utils4.asyncDataManager) === null || _interaction$utils4$a === void 0 ? void 0 : _interaction$utils4$a.call(_interaction$utils4, {
|
1391
1457
|
module: 'get',
|
1392
1458
|
key: 'till_button'
|
1393
1459
|
});
|
@@ -1417,7 +1483,7 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1417
1483
|
}();
|
1418
1484
|
|
1419
1485
|
// 只在 PaymentModal 打开时初始化 tillButton 数据
|
1420
|
-
if (interaction !== null && interaction !== void 0 && (_interaction$
|
1486
|
+
if (interaction !== null && interaction !== void 0 && (_interaction$utils5 = interaction.utils) !== null && _interaction$utils5 !== void 0 && _interaction$utils5.asyncDataManager) {
|
1421
1487
|
initTillButtonData();
|
1422
1488
|
}
|
1423
1489
|
}, [interaction]);
|
@@ -1431,7 +1497,7 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1431
1497
|
var matrix = new DOMMatrix(bodyTransform);
|
1432
1498
|
scaleY = matrix.d;
|
1433
1499
|
}
|
1434
|
-
return "".concat(Math.floor(
|
1500
|
+
return "".concat(Math.floor(windowHeight * 0.9 / scaleY), "px");
|
1435
1501
|
}, [windowHeight]);
|
1436
1502
|
|
1437
1503
|
// 模块配置 - 控制显示哪些支付模块
|
@@ -1445,23 +1511,23 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1445
1511
|
}, []);
|
1446
1512
|
|
1447
1513
|
// 订单备注相关状态
|
1448
|
-
var
|
1449
|
-
_useState32 = _slicedToArray(_useState31, 2),
|
1450
|
-
noteModalOpen = _useState32[0],
|
1451
|
-
setNoteModalOpen = _useState32[1];
|
1452
|
-
var _useState33 = useState(''),
|
1453
|
-
_useState34 = _slicedToArray(_useState33, 2),
|
1454
|
-
orderNote = _useState34[0],
|
1455
|
-
setOrderNote = _useState34[1];
|
1456
|
-
var _useState35 = useState('payment-content'),
|
1514
|
+
var _useState35 = useState(false),
|
1457
1515
|
_useState36 = _slicedToArray(_useState35, 2),
|
1458
|
-
|
1459
|
-
|
1516
|
+
noteModalOpen = _useState36[0],
|
1517
|
+
setNoteModalOpen = _useState36[1];
|
1518
|
+
var _useState37 = useState(''),
|
1519
|
+
_useState38 = _slicedToArray(_useState37, 2),
|
1520
|
+
orderNote = _useState38[0],
|
1521
|
+
setOrderNote = _useState38[1];
|
1522
|
+
var _useState39 = useState('payment-content'),
|
1523
|
+
_useState40 = _slicedToArray(_useState39, 2),
|
1524
|
+
noteModalSource = _useState40[0],
|
1525
|
+
setNoteModalSource = _useState40[1];
|
1460
1526
|
|
1461
1527
|
// 订单备注相关处理函数
|
1462
1528
|
var handleNoteConfirm = /*#__PURE__*/function () {
|
1463
1529
|
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(noteValue) {
|
1464
|
-
var checkoutModule,
|
1530
|
+
var checkoutModule, _orderId3, _checkoutModule$editO, _checkoutModule, _checkoutModule$updat;
|
1465
1531
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
1466
1532
|
while (1) switch (_context17.prev = _context17.next) {
|
1467
1533
|
case 0:
|
@@ -1470,9 +1536,9 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1470
1536
|
break;
|
1471
1537
|
}
|
1472
1538
|
checkoutModule = pisellos === null || pisellos === void 0 ? void 0 : pisellos.getModule('checkout');
|
1473
|
-
|
1539
|
+
_orderId3 = checkoutModule === null || checkoutModule === void 0 ? void 0 : checkoutModule.getCurrentOrderId();
|
1474
1540
|
if (checkoutModule) {
|
1475
|
-
(_checkoutModule$editO = checkoutModule.editOrderNoteByOrderIdAsync) === null || _checkoutModule$editO === void 0 || _checkoutModule$editO.call(checkoutModule,
|
1541
|
+
(_checkoutModule$editO = checkoutModule.editOrderNoteByOrderIdAsync) === null || _checkoutModule$editO === void 0 || _checkoutModule$editO.call(checkoutModule, _orderId3, noteValue);
|
1476
1542
|
setOrderNote(noteValue);
|
1477
1543
|
Toast === null || Toast === void 0 || Toast.success(locales.getText('pisell2.checkout.order-note.updated-successfully'));
|
1478
1544
|
}
|
@@ -1614,19 +1680,19 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1614
1680
|
};
|
1615
1681
|
var handleNoteConfirm = /*#__PURE__*/function () {
|
1616
1682
|
var _ref24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(noteValue) {
|
1617
|
-
var checkoutModule,
|
1683
|
+
var checkoutModule, _orderId4, _checkoutModule$editO2;
|
1618
1684
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
1619
1685
|
while (1) switch (_context19.prev = _context19.next) {
|
1620
1686
|
case 0:
|
1621
1687
|
_context19.prev = 0;
|
1622
1688
|
checkoutModule = pisellos === null || pisellos === void 0 ? void 0 : pisellos.getModule('checkout');
|
1623
|
-
|
1624
|
-
if (!(checkoutModule &&
|
1689
|
+
_orderId4 = checkoutModule === null || checkoutModule === void 0 ? void 0 : checkoutModule.getCurrentOrderId();
|
1690
|
+
if (!(checkoutModule && _orderId4)) {
|
1625
1691
|
_context19.next = 8;
|
1626
1692
|
break;
|
1627
1693
|
}
|
1628
1694
|
_context19.next = 6;
|
1629
|
-
return (_checkoutModule$editO2 = checkoutModule.editOrderNoteByOrderIdAsync) === null || _checkoutModule$editO2 === void 0 ? void 0 : _checkoutModule$editO2.call(checkoutModule,
|
1695
|
+
return (_checkoutModule$editO2 = checkoutModule.editOrderNoteByOrderIdAsync) === null || _checkoutModule$editO2 === void 0 ? void 0 : _checkoutModule$editO2.call(checkoutModule, _orderId4, noteValue);
|
1630
1696
|
case 6:
|
1631
1697
|
setOrderNote(noteValue);
|
1632
1698
|
showToast('success', locales.getText('pisell2.checkout.order-note.updated-successfully'));
|
@@ -1656,19 +1722,19 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1656
1722
|
}();
|
1657
1723
|
var handleNoteDelete = /*#__PURE__*/function () {
|
1658
1724
|
var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
1659
|
-
var checkoutModule,
|
1725
|
+
var checkoutModule, _orderId5, _checkoutModule$editO3;
|
1660
1726
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
1661
1727
|
while (1) switch (_context20.prev = _context20.next) {
|
1662
1728
|
case 0:
|
1663
1729
|
_context20.prev = 0;
|
1664
1730
|
checkoutModule = pisellos === null || pisellos === void 0 ? void 0 : pisellos.getModule('checkout');
|
1665
|
-
|
1666
|
-
if (!(checkoutModule &&
|
1731
|
+
_orderId5 = checkoutModule === null || checkoutModule === void 0 ? void 0 : checkoutModule.getCurrentOrderId();
|
1732
|
+
if (!(checkoutModule && _orderId5)) {
|
1667
1733
|
_context20.next = 8;
|
1668
1734
|
break;
|
1669
1735
|
}
|
1670
1736
|
_context20.next = 6;
|
1671
|
-
return (_checkoutModule$editO3 = checkoutModule.editOrderNoteByOrderIdAsync) === null || _checkoutModule$editO3 === void 0 ? void 0 : _checkoutModule$editO3.call(checkoutModule,
|
1737
|
+
return (_checkoutModule$editO3 = checkoutModule.editOrderNoteByOrderIdAsync) === null || _checkoutModule$editO3 === void 0 ? void 0 : _checkoutModule$editO3.call(checkoutModule, _orderId5, '');
|
1672
1738
|
case 6:
|
1673
1739
|
setOrderNote('');
|
1674
1740
|
showToast('success', locales.getText('pisell2.checkout.order-note.deleted-successfully'));
|
@@ -1814,6 +1880,52 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1814
1880
|
onClose === null || onClose === void 0 || onClose(reset || false);
|
1815
1881
|
};
|
1816
1882
|
|
1883
|
+
// 如果订单已经同步过,此时点击左上角返回,需要通知购物车进入编辑态
|
1884
|
+
var handleSetEditCartMode = /*#__PURE__*/function () {
|
1885
|
+
var _ref27 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
1886
|
+
var closeModal,
|
1887
|
+
checkout,
|
1888
|
+
orderId,
|
1889
|
+
paymentData,
|
1890
|
+
paidAmount,
|
1891
|
+
paidAmountWithoutSurcharge,
|
1892
|
+
_args21 = arguments;
|
1893
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
1894
|
+
while (1) switch (_context21.prev = _context21.next) {
|
1895
|
+
case 0:
|
1896
|
+
closeModal = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : false;
|
1897
|
+
checkout = pisellos.getModule('checkout');
|
1898
|
+
orderId = checkout.getCurrentOrderId();
|
1899
|
+
_context21.next = 5;
|
1900
|
+
return checkout.getCurrentOrderPaymentItemsAsync();
|
1901
|
+
case 5:
|
1902
|
+
paymentData = _context21.sent;
|
1903
|
+
// 计算订单已付款和已付款(不包含手续费)的金额
|
1904
|
+
paidAmount = paymentData.reduce(function (total, item) {
|
1905
|
+
return total + Number(item.amount);
|
1906
|
+
}, 0);
|
1907
|
+
paidAmountWithoutSurcharge = paymentData.reduce(function (total, item) {
|
1908
|
+
var _item$service_charge3;
|
1909
|
+
return total + Number(item.amount) - Number(((_item$service_charge3 = item.service_charge) === null || _item$service_charge3 === void 0 ? void 0 : _item$service_charge3.amount) || 0);
|
1910
|
+
}, 0);
|
1911
|
+
console.log('paidAmount>>>>', paidAmount, paidAmountWithoutSurcharge);
|
1912
|
+
// 清空临时选择的 voucher
|
1913
|
+
checkout.updateVoucherPaymentItemsAsync([]);
|
1914
|
+
setEditCartMode === null || setEditCartMode === void 0 || setEditCartMode(orderId, {
|
1915
|
+
paidAmount: paidAmount,
|
1916
|
+
paidAmountWithoutSurcharge: paidAmountWithoutSurcharge
|
1917
|
+
}, closeModal);
|
1918
|
+
case 11:
|
1919
|
+
case "end":
|
1920
|
+
return _context21.stop();
|
1921
|
+
}
|
1922
|
+
}, _callee21);
|
1923
|
+
}));
|
1924
|
+
return function handleSetEditCartMode() {
|
1925
|
+
return _ref27.apply(this, arguments);
|
1926
|
+
};
|
1927
|
+
}();
|
1928
|
+
|
1817
1929
|
// 自定义头部组件
|
1818
1930
|
var CustomHeader = function CustomHeader() {
|
1819
1931
|
return /*#__PURE__*/React.createElement("div", {
|
@@ -1830,7 +1942,7 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1830
1942
|
onClick: function onClick() {
|
1831
1943
|
var checkout = pisellos.getModule('checkout');
|
1832
1944
|
if (checkout.isCurrentOrderSynced()) {
|
1833
|
-
|
1945
|
+
handleSetEditCartMode(true);
|
1834
1946
|
} else {
|
1835
1947
|
handlePaymentCancel(false);
|
1836
1948
|
}
|
@@ -1862,23 +1974,23 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1862
1974
|
// 初始化checkout数据
|
1863
1975
|
useEffect(function () {
|
1864
1976
|
var initCheckoutData = /*#__PURE__*/function () {
|
1865
|
-
var
|
1866
|
-
var checkout, _newData$subtotal_inf,
|
1867
|
-
return _regeneratorRuntime().wrap(function
|
1868
|
-
while (1) switch (
|
1977
|
+
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
1978
|
+
var checkout, shop_wallet_pass_id, newData, _newData$subtotal_inf, _newData$subtotal_inf2, _orderInfo2, _data$subtotal_info, _data$subtotal_info2, _orderInfo4;
|
1979
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
1980
|
+
while (1) switch (_context23.prev = _context23.next) {
|
1869
1981
|
case 0:
|
1870
|
-
|
1982
|
+
_context23.prev = 0;
|
1871
1983
|
// 获取 checkout 模块并处理订单数据
|
1872
1984
|
checkout = pisellos === null || pisellos === void 0 ? void 0 : pisellos.getModule('checkout');
|
1873
1985
|
if (!(checkout && data && !isLocalOrderCreated.current)) {
|
1874
|
-
|
1986
|
+
_context23.next = 24;
|
1875
1987
|
break;
|
1876
1988
|
}
|
1877
1989
|
isLocalOrderCreated.current = true;
|
1878
|
-
|
1990
|
+
_context23.next = 6;
|
1879
1991
|
return getShopWalletPassId(interaction);
|
1880
1992
|
case 6:
|
1881
|
-
shop_wallet_pass_id =
|
1993
|
+
shop_wallet_pass_id = _context23.sent;
|
1882
1994
|
checkout.setOtherParams({
|
1883
1995
|
is_price_include_tax: getData('is_price_include_tax'),
|
1884
1996
|
tax_rate: getData('tax_rate') || '10',
|
@@ -1893,16 +2005,33 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1893
2005
|
});
|
1894
2006
|
newData = cloneDeep(data); // setTotalAmount(newData.total.expectAmount);
|
1895
2007
|
// 先往 checkout 解决方案推送一条 local 数据
|
1896
|
-
|
1897
|
-
|
2008
|
+
if (!(editOrderId || currentEditOrderId)) {
|
2009
|
+
_context23.next = 14;
|
2010
|
+
break;
|
2011
|
+
}
|
2012
|
+
_context23.next = 12;
|
2013
|
+
return checkout.updateLocalOrderAsync({
|
2014
|
+
orderId: editOrderId || currentEditOrderId,
|
1898
2015
|
orderData: newData.order_info,
|
1899
2016
|
cartSummary: (_newData$subtotal_inf = newData.subtotal_info) === null || _newData$subtotal_inf === void 0 ? void 0 : _newData$subtotal_inf.subTotalList,
|
1900
2017
|
autoPayment: true,
|
1901
2018
|
totalInfo: newData.subtotal_info
|
1902
2019
|
});
|
1903
|
-
case
|
2020
|
+
case 12:
|
2021
|
+
_context23.next = 16;
|
2022
|
+
break;
|
2023
|
+
case 14:
|
2024
|
+
_context23.next = 16;
|
2025
|
+
return checkout.createLocalOrderAsync({
|
2026
|
+
orderData: newData.order_info,
|
2027
|
+
cartSummary: (_newData$subtotal_inf2 = newData.subtotal_info) === null || _newData$subtotal_inf2 === void 0 ? void 0 : _newData$subtotal_inf2.subTotalList,
|
2028
|
+
autoPayment: true,
|
2029
|
+
totalInfo: newData.subtotal_info
|
2030
|
+
});
|
2031
|
+
case 16:
|
1904
2032
|
// 获取订单总金额
|
1905
2033
|
_orderInfo2 = checkout.getCurrentOrderInfo();
|
2034
|
+
console.log(_orderInfo2);
|
1906
2035
|
if (_orderInfo2 && _orderInfo2.totalAmount) {
|
1907
2036
|
setTotalAmount(_orderInfo2.totalAmount);
|
1908
2037
|
}
|
@@ -1918,37 +2047,40 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
1918
2047
|
}
|
1919
2048
|
// 监听订单同步完成,同步完成后显示订单完成 toast,关闭当前弹窗
|
1920
2049
|
unsubscribeRef.current = checkout.core.effects.on('checkout:onOrderSynced', /*#__PURE__*/function () {
|
1921
|
-
var
|
2050
|
+
var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(data) {
|
1922
2051
|
var _data$response, _responseData$payment2;
|
1923
|
-
var responseData, paymentStatus, orderTotalAmount, gapAmount, currentChangeGivenAmount, failureReason, _interaction$
|
1924
|
-
return _regeneratorRuntime().wrap(function
|
1925
|
-
while (1) switch (
|
2052
|
+
var currentOrderId, responseData, paymentStatus, orderTotalAmount, gapAmount, currentChangeGivenAmount, failureReason, _interaction$utils6, _interaction$utils6$a, _responseData$payment3, params, statusClassName, autoCloseConfig, enabledAutoPrint, _orderInfo3, paymentResult;
|
2053
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
2054
|
+
while (1) switch (_context22.prev = _context22.next) {
|
1926
2055
|
case 0:
|
2056
|
+
// handleSetEditCartMode(false)
|
2057
|
+
currentOrderId = checkout.getCurrentOrderId();
|
2058
|
+
_setCurrentEditOrderId(currentOrderId);
|
1927
2059
|
// 获取支付状态和相关信息
|
1928
2060
|
responseData = (_data$response = data.response) === null || _data$response === void 0 ? void 0 : _data$response.data; // 获取支付状态
|
1929
2061
|
paymentStatus = responseData === null || responseData === void 0 ? void 0 : responseData.payment_status;
|
1930
2062
|
if (!data.isManual) {
|
1931
|
-
|
2063
|
+
_context22.next = 6;
|
1932
2064
|
break;
|
1933
2065
|
}
|
1934
|
-
return
|
1935
|
-
case
|
2066
|
+
return _context22.abrupt("return");
|
2067
|
+
case 6:
|
1936
2068
|
handlePaymentComplete(data);
|
1937
2069
|
// 如果正在显示现金支付 toast,跳过自动关闭逻辑
|
1938
2070
|
if (!showingCashToastRef.current) {
|
1939
|
-
|
2071
|
+
_context22.next = 9;
|
1940
2072
|
break;
|
1941
2073
|
}
|
1942
|
-
return
|
1943
|
-
case
|
2074
|
+
return _context22.abrupt("return");
|
2075
|
+
case 9:
|
1944
2076
|
// 获取订单总金额
|
1945
2077
|
orderTotalAmount = Number((responseData === null || responseData === void 0 ? void 0 : responseData.total_amount) || 0);
|
1946
2078
|
gapAmount = Number((responseData === null || responseData === void 0 ? void 0 : responseData.amount_gap) || 0);
|
1947
|
-
currentChangeGivenAmount = Number(
|
2079
|
+
currentChangeGivenAmount = Number(responseData === null || responseData === void 0 || (_responseData$payment2 = responseData.payment_info) === null || _responseData$payment2 === void 0 ? void 0 : _responseData$payment2.current_change_given_amount); // const changeDue = Number(responseData?.amount_gap || 0);
|
1948
2080
|
// 获取失败原因
|
1949
2081
|
failureReason = responseData === null || responseData === void 0 ? void 0 : responseData.failure_reason; // 根据支付状态弹出对应的支付结果toast
|
1950
2082
|
if (!paymentStatus) {
|
1951
|
-
|
2083
|
+
_context22.next = 30;
|
1952
2084
|
break;
|
1953
2085
|
}
|
1954
2086
|
// 打印订单完整信息
|
@@ -2002,23 +2134,24 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
2002
2134
|
// 确定支付状态
|
2003
2135
|
statusClassName = calculateStatusClassName(paymentStatus);
|
2004
2136
|
autoCloseConfig = calculateAutoCloseConfig(paymentStatus, !!currentChangeGivenAmount);
|
2005
|
-
|
2006
|
-
return interaction === null || interaction === void 0 || (_interaction$
|
2137
|
+
_context22.next = 21;
|
2138
|
+
return interaction === null || interaction === void 0 || (_interaction$utils6 = interaction.utils) === null || _interaction$utils6 === void 0 || (_interaction$utils6$a = _interaction$utils6.asyncDataManager) === null || _interaction$utils6$a === void 0 ? void 0 : _interaction$utils6$a.call(_interaction$utils6, {
|
2007
2139
|
module: 'get',
|
2008
2140
|
key: 'auto_print_receipt'
|
2009
2141
|
});
|
2010
|
-
case
|
2011
|
-
enabledAutoPrint =
|
2012
|
-
|
2142
|
+
case 21:
|
2143
|
+
enabledAutoPrint = _context22.sent;
|
2144
|
+
_orderInfo3 = checkout.getCurrentOrderInfo(); // 根据支付状态展示不同的 toast
|
2145
|
+
_context22.next = 25;
|
2013
2146
|
return displayPaymentResultToast({
|
2014
2147
|
paymentStatus: paymentStatus,
|
2015
|
-
orderTotalAmount: orderTotalAmount,
|
2148
|
+
orderTotalAmount: _orderInfo3.isDeposit ? _orderInfo3.depositAmount : orderTotalAmount,
|
2016
2149
|
gapAmount: paymentStatus === 'partially_paid' ? gapAmount : currentChangeGivenAmount,
|
2017
2150
|
failureReason: failureReason,
|
2018
2151
|
autoCloseConfig: autoCloseConfig,
|
2019
2152
|
actionButtons: generateActionButtons(paymentStatus, enabledAutoPrint)
|
2020
2153
|
}, paymentResultToastConfig);
|
2021
|
-
case
|
2154
|
+
case 25:
|
2022
2155
|
// 当支付状态为 paid 时,关闭 paymentModal
|
2023
2156
|
if (paymentStatus === 'paid') {
|
2024
2157
|
handleModalClose();
|
@@ -2034,70 +2167,86 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
2034
2167
|
}
|
2035
2168
|
});
|
2036
2169
|
handlePaymentComplete(paymentResult);
|
2037
|
-
|
2170
|
+
_context22.next = 31;
|
2038
2171
|
break;
|
2039
|
-
case
|
2172
|
+
case 30:
|
2040
2173
|
handlePaymentComplete(data);
|
2041
|
-
case
|
2174
|
+
case 31:
|
2042
2175
|
case "end":
|
2043
|
-
return
|
2176
|
+
return _context22.stop();
|
2044
2177
|
}
|
2045
|
-
},
|
2178
|
+
}, _callee22);
|
2046
2179
|
}));
|
2047
2180
|
return function (_x17) {
|
2048
|
-
return
|
2181
|
+
return _ref29.apply(this, arguments);
|
2049
2182
|
};
|
2050
2183
|
}());
|
2051
|
-
|
2184
|
+
_context23.next = 40;
|
2052
2185
|
break;
|
2053
|
-
case
|
2186
|
+
case 24:
|
2054
2187
|
if (!isLocalOrderCreated.current) {
|
2055
|
-
|
2188
|
+
_context23.next = 40;
|
2056
2189
|
break;
|
2057
2190
|
}
|
2058
2191
|
// // 如果本地订单已创建,这时候还更新了 data,则需要销毁当前的订单数据,然后更新新的订单数据了
|
2059
2192
|
console.log('🔄 PaymentModal: data changed, updating checkout data...');
|
2060
2193
|
isLocalOrderCreated.current = false;
|
2061
|
-
|
2194
|
+
_context23.next = 29;
|
2062
2195
|
return checkout.cancelCurrentOrderAsync();
|
2063
|
-
case
|
2064
|
-
|
2065
|
-
|
2196
|
+
case 29:
|
2197
|
+
if (!(editOrderId || currentEditOrderId)) {
|
2198
|
+
_context23.next = 34;
|
2199
|
+
break;
|
2200
|
+
}
|
2201
|
+
_context23.next = 32;
|
2202
|
+
return checkout.updateLocalOrderAsync({
|
2203
|
+
orderId: editOrderId || currentEditOrderId,
|
2066
2204
|
orderData: data === null || data === void 0 ? void 0 : data.order_info,
|
2067
2205
|
cartSummary: data === null || data === void 0 || (_data$subtotal_info = data.subtotal_info) === null || _data$subtotal_info === void 0 ? void 0 : _data$subtotal_info.subTotalList,
|
2068
2206
|
autoPayment: true,
|
2069
2207
|
totalInfo: data === null || data === void 0 ? void 0 : data.subtotal_info
|
2070
2208
|
});
|
2071
|
-
case
|
2209
|
+
case 32:
|
2210
|
+
_context23.next = 36;
|
2211
|
+
break;
|
2212
|
+
case 34:
|
2213
|
+
_context23.next = 36;
|
2214
|
+
return checkout.createLocalOrderAsync({
|
2215
|
+
orderData: data === null || data === void 0 ? void 0 : data.order_info,
|
2216
|
+
cartSummary: data === null || data === void 0 || (_data$subtotal_info2 = data.subtotal_info) === null || _data$subtotal_info2 === void 0 ? void 0 : _data$subtotal_info2.subTotalList,
|
2217
|
+
autoPayment: true,
|
2218
|
+
totalInfo: data === null || data === void 0 ? void 0 : data.subtotal_info
|
2219
|
+
});
|
2220
|
+
case 36:
|
2072
2221
|
// 获取订单总金额
|
2073
|
-
|
2074
|
-
if (
|
2075
|
-
setTotalAmount(
|
2222
|
+
_orderInfo4 = checkout.getCurrentOrderInfo();
|
2223
|
+
if (_orderInfo4 && _orderInfo4.totalAmount) {
|
2224
|
+
setTotalAmount(_orderInfo4.totalAmount);
|
2076
2225
|
}
|
2077
|
-
setOrderInfo(
|
2226
|
+
setOrderInfo(_orderInfo4);
|
2078
2227
|
isLocalOrderCreated.current = true;
|
2079
|
-
case
|
2080
|
-
|
2228
|
+
case 40:
|
2229
|
+
_context23.next = 46;
|
2081
2230
|
break;
|
2082
|
-
case
|
2083
|
-
|
2084
|
-
|
2085
|
-
console.error('Failed to initialize checkout data:',
|
2231
|
+
case 42:
|
2232
|
+
_context23.prev = 42;
|
2233
|
+
_context23.t0 = _context23["catch"](0);
|
2234
|
+
console.error('Failed to initialize checkout data:', _context23.t0);
|
2086
2235
|
logger === null || logger === void 0 || logger.addLog({
|
2087
2236
|
type: 'error',
|
2088
2237
|
title: 'Failed to initialize checkout data',
|
2089
2238
|
metadata: {
|
2090
|
-
error:
|
2239
|
+
error: _context23.t0
|
2091
2240
|
}
|
2092
2241
|
});
|
2093
|
-
case
|
2242
|
+
case 46:
|
2094
2243
|
case "end":
|
2095
|
-
return
|
2244
|
+
return _context23.stop();
|
2096
2245
|
}
|
2097
|
-
},
|
2246
|
+
}, _callee23, null, [[0, 42]]);
|
2098
2247
|
}));
|
2099
2248
|
return function initCheckoutData() {
|
2100
|
-
return
|
2249
|
+
return _ref28.apply(this, arguments);
|
2101
2250
|
};
|
2102
2251
|
}();
|
2103
2252
|
if (data) {
|
@@ -2133,11 +2282,11 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
2133
2282
|
|
2134
2283
|
// 通用回调函数
|
2135
2284
|
var handleDetailsClick = /*#__PURE__*/function () {
|
2136
|
-
var
|
2285
|
+
var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
2137
2286
|
var _context$appHelper2;
|
2138
|
-
var _context$appHelper$ut9, isTerminal, isWebPos, checkout,
|
2139
|
-
return _regeneratorRuntime().wrap(function
|
2140
|
-
while (1) switch (
|
2287
|
+
var _context$appHelper$ut9, isTerminal, isWebPos, checkout, _orderId6;
|
2288
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
2289
|
+
while (1) switch (_context24.prev = _context24.next) {
|
2141
2290
|
case 0:
|
2142
2291
|
setTimeout(function () {
|
2143
2292
|
// 主动关闭PaymentResultToast
|
@@ -2146,37 +2295,37 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
2146
2295
|
}, 0);
|
2147
2296
|
_context$appHelper$ut9 = (_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 ? void 0 : _context$appHelper2.utils, isTerminal = _context$appHelper$ut9.isTerminal, isWebPos = _context$appHelper$ut9.isWebPos;
|
2148
2297
|
if (!(isTerminal !== null && isTerminal !== void 0 && isTerminal())) {
|
2149
|
-
|
2298
|
+
_context24.next = 8;
|
2150
2299
|
break;
|
2151
2300
|
}
|
2152
2301
|
checkout = pisellos.getModule('checkout');
|
2153
|
-
|
2302
|
+
_context24.next = 6;
|
2154
2303
|
return checkout.getCurrentOrderId();
|
2155
2304
|
case 6:
|
2156
|
-
|
2157
|
-
return
|
2305
|
+
_orderId6 = _context24.sent;
|
2306
|
+
return _context24.abrupt("return", interaction.utils.postMessageToApp({
|
2158
2307
|
module: 'booking',
|
2159
2308
|
key: 'view_order',
|
2160
2309
|
data: {
|
2161
|
-
order_id:
|
2310
|
+
order_id: _orderId6
|
2162
2311
|
},
|
2163
2312
|
origin: '/booking'
|
2164
2313
|
}));
|
2165
2314
|
case 8:
|
2166
2315
|
case "end":
|
2167
|
-
return
|
2316
|
+
return _context24.stop();
|
2168
2317
|
}
|
2169
|
-
},
|
2318
|
+
}, _callee24);
|
2170
2319
|
}));
|
2171
2320
|
return function handleDetailsClick() {
|
2172
|
-
return
|
2321
|
+
return _ref30.apply(this, arguments);
|
2173
2322
|
};
|
2174
2323
|
}();
|
2175
2324
|
var handlePrintReceiptClick = /*#__PURE__*/function () {
|
2176
|
-
var
|
2177
|
-
var checkoutModule, data, isSynced,
|
2178
|
-
return _regeneratorRuntime().wrap(function
|
2179
|
-
while (1) switch (
|
2325
|
+
var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
2326
|
+
var checkoutModule, data, isSynced, _orderId7, params;
|
2327
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
2328
|
+
while (1) switch (_context25.prev = _context25.next) {
|
2180
2329
|
case 0:
|
2181
2330
|
setTimeout(function () {
|
2182
2331
|
// 主动关闭PaymentResultToast
|
@@ -2185,32 +2334,32 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
2185
2334
|
}, 0);
|
2186
2335
|
checkoutModule = pisellos === null || pisellos === void 0 ? void 0 : pisellos.getModule('checkout');
|
2187
2336
|
if (checkoutModule) {
|
2188
|
-
|
2337
|
+
_context25.next = 4;
|
2189
2338
|
break;
|
2190
2339
|
}
|
2191
|
-
return
|
2340
|
+
return _context25.abrupt("return");
|
2192
2341
|
case 4:
|
2193
|
-
|
2342
|
+
_context25.next = 6;
|
2194
2343
|
return checkoutModule.isCurrentOrderSynced();
|
2195
2344
|
case 6:
|
2196
|
-
isSynced =
|
2345
|
+
isSynced = _context25.sent;
|
2197
2346
|
if (isSynced) {
|
2198
|
-
|
2347
|
+
_context25.next = 13;
|
2199
2348
|
break;
|
2200
2349
|
}
|
2201
|
-
|
2350
|
+
_context25.next = 10;
|
2202
2351
|
return checkoutModule.manualSyncOrderAsync();
|
2203
2352
|
case 10:
|
2204
|
-
data =
|
2205
|
-
|
2353
|
+
data = _context25.sent;
|
2354
|
+
_context25.next = 17;
|
2206
2355
|
break;
|
2207
2356
|
case 13:
|
2208
|
-
|
2357
|
+
_context25.next = 15;
|
2209
2358
|
return checkoutModule.getCurrentOrderId();
|
2210
2359
|
case 15:
|
2211
|
-
|
2360
|
+
_orderId7 = _context25.sent;
|
2212
2361
|
data = {
|
2213
|
-
orderId:
|
2362
|
+
orderId: _orderId7
|
2214
2363
|
};
|
2215
2364
|
case 17:
|
2216
2365
|
// data.orderId 就是订单号,可以用来打印小票
|
@@ -2234,12 +2383,12 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
2234
2383
|
}
|
2235
2384
|
case 18:
|
2236
2385
|
case "end":
|
2237
|
-
return
|
2386
|
+
return _context25.stop();
|
2238
2387
|
}
|
2239
|
-
},
|
2388
|
+
}, _callee25);
|
2240
2389
|
}));
|
2241
2390
|
return function handlePrintReceiptClick() {
|
2242
|
-
return
|
2391
|
+
return _ref31.apply(this, arguments);
|
2243
2392
|
};
|
2244
2393
|
}();
|
2245
2394
|
var handleRetryClick = function handleRetryClick() {
|
@@ -2514,7 +2663,13 @@ var PaymentModal = function PaymentModal(_ref18) {
|
|
2514
2663
|
return setShowRetryModal(true);
|
2515
2664
|
},
|
2516
2665
|
generateActionButtons: generateActionButtons,
|
2517
|
-
paymentResultToastConfig: paymentResultToastConfig
|
2666
|
+
paymentResultToastConfig: paymentResultToastConfig,
|
2667
|
+
updateOrderInfo: function updateOrderInfo(orderInfo) {
|
2668
|
+
return setOrderInfo(orderInfo);
|
2669
|
+
},
|
2670
|
+
setCurrentEditOrderId: function setCurrentEditOrderId(orderId) {
|
2671
|
+
return _setCurrentEditOrderId(orderId);
|
2672
|
+
}
|
2518
2673
|
})), noteModalOpen && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(NoteModal, {
|
2519
2674
|
open: noteModalOpen,
|
2520
2675
|
title: locales.getText('pisell2.text.add-order-notes'),
|