@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
@@ -41,7 +41,8 @@ var import_utils = require("@pisell/utils");
|
|
41
41
|
var import_decimal = __toESM(require("decimal.js"));
|
42
42
|
var import_locales = __toESM(require("../../locales"));
|
43
43
|
var import_PaymentDetailModal = __toESM(require("../PaymentDetailModal"));
|
44
|
-
var
|
44
|
+
var import_pisellSimplePriceKeyboardPopover = __toESM(require("../../../../pro/pisellSimplePriceKeyboardPopover"));
|
45
|
+
var import_priceKeyboard = require("../../../../pro/priceKeyboard");
|
45
46
|
var import_index = require("./index.less");
|
46
47
|
var import_classnames = __toESM(require("classnames"));
|
47
48
|
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
|
@@ -105,6 +106,7 @@ function AmountSummary({
|
|
105
106
|
const [summaryData, setSummaryData] = (0, import_react.useState)([]);
|
106
107
|
const [partialPaidAmount, setPartialPaidAmount] = (0, import_react.useState)("0");
|
107
108
|
const checkoutModule = pisellos.getModule("checkout");
|
109
|
+
const [isKeyboardVisible, setIsKeyboardVisible] = (0, import_react.useState)(false);
|
108
110
|
const labelMaps = {
|
109
111
|
deposit: getText("pisell2.subtotal.deposit") || "Deposit",
|
110
112
|
total: getText("pisell2.subtotal.total") || "Total",
|
@@ -117,13 +119,15 @@ function AmountSummary({
|
|
117
119
|
expect_amount: getText("pisell2.subtotal.expect-amount") || "Expected Amount"
|
118
120
|
};
|
119
121
|
const getBalanceDueAmount = () => {
|
120
|
-
|
121
|
-
(
|
122
|
-
);
|
123
|
-
if (expectAmountItem) {
|
124
|
-
return expectAmountItem.value;
|
122
|
+
if (paymentType === "deposit") {
|
123
|
+
return (orderInfo == null ? void 0 : orderInfo.depositAmount) || "0";
|
125
124
|
}
|
126
|
-
return 0
|
125
|
+
return (paymentItems == null ? void 0 : paymentItems.reduce((acc, item) => {
|
126
|
+
if (item.isSynced || !item.voucher_id) {
|
127
|
+
return acc;
|
128
|
+
}
|
129
|
+
return acc.plus(item.amount);
|
130
|
+
}, new import_decimal.default(0)).toNumber()) || 0;
|
127
131
|
};
|
128
132
|
const parseFormattedAmount = (formattedAmount) => {
|
129
133
|
if (typeof formattedAmount === "number") {
|
@@ -155,6 +159,7 @@ function AmountSummary({
|
|
155
159
|
if (Array.isArray(summary)) {
|
156
160
|
setSummaryData(summary);
|
157
161
|
}
|
162
|
+
setPaymentType(orderInfo.isDeposit ? "deposit" : "regular");
|
158
163
|
} catch (error) {
|
159
164
|
console.warn("Failed to get cart summary:", error);
|
160
165
|
}
|
@@ -223,20 +228,10 @@ function AmountSummary({
|
|
223
228
|
);
|
224
229
|
return totalDecimal.toNumber();
|
225
230
|
};
|
226
|
-
const getOrderDueAmount = () => {
|
227
|
-
const expectAmountItem = summaryData.find(
|
228
|
-
(item) => item.key === "expect_amount"
|
229
|
-
);
|
230
|
-
if (expectAmountItem) {
|
231
|
-
return expectAmountItem.value;
|
232
|
-
}
|
233
|
-
return paymentType === "deposit" ? 15.1 : 130.2;
|
234
|
-
};
|
235
231
|
const getKeyboardLimits = () => {
|
236
232
|
const walletTotal = getWalletTotalAmount();
|
237
|
-
const orderDue = getOrderDueAmount();
|
238
233
|
const walletTotalDecimal = new import_decimal.default(walletTotal);
|
239
|
-
const orderDueDecimal = new import_decimal.default(
|
234
|
+
const orderDueDecimal = new import_decimal.default(Number(balanceDueAmount || 0));
|
240
235
|
const minDecimal = new import_decimal.default(0.01);
|
241
236
|
const diffDecimal = orderDueDecimal.minus(walletTotalDecimal);
|
242
237
|
const maxAmountDecimal = import_decimal.default.max(minDecimal, diffDecimal);
|
@@ -302,7 +297,7 @@ function AmountSummary({
|
|
302
297
|
var _a2;
|
303
298
|
const partialPaidAmountDecimal = new import_decimal.default(partialPaidAmount || "0");
|
304
299
|
const voucherPaymentAmount = ((_a2 = paymentItems == null ? void 0 : paymentItems.reduce((acc, item) => {
|
305
|
-
if (item.voucher_id) {
|
300
|
+
if (item.voucher_id && !item.isSynced) {
|
306
301
|
try {
|
307
302
|
const amount = new import_decimal.default(item.amount || "0");
|
308
303
|
const roundingAmount = new import_decimal.default(item.rounding_amount || "0");
|
@@ -314,6 +309,10 @@ function AmountSummary({
|
|
314
309
|
return acc;
|
315
310
|
}, new import_decimal.default(0))) == null ? void 0 : _a2.toNumber()) || 0;
|
316
311
|
const totalPaidAmount = partialPaidAmountDecimal.plus(voucherPaymentAmount).toNumber();
|
312
|
+
const syncedPaymentItems = (paymentItems == null ? void 0 : paymentItems.filter((item) => item.isSynced && !item.voucher_id)) || [];
|
313
|
+
if ((syncedPaymentItems == null ? void 0 : syncedPaymentItems.length) > 0 && totalPaidAmount < totalAmount) {
|
314
|
+
return true;
|
315
|
+
}
|
317
316
|
if (totalPaidAmount >= totalAmount) {
|
318
317
|
return false;
|
319
318
|
}
|
@@ -351,7 +350,8 @@ function AmountSummary({
|
|
351
350
|
return false;
|
352
351
|
}
|
353
352
|
if (amount <= 0) {
|
354
|
-
const
|
353
|
+
const unSyncedPaymentItems = paymentItems == null ? void 0 : paymentItems.filter((item) => !item.isSynced);
|
354
|
+
const allItemsHaveVoucherId = unSyncedPaymentItems == null ? void 0 : unSyncedPaymentItems.every(
|
355
355
|
(item) => item.voucher_id
|
356
356
|
);
|
357
357
|
return allItemsHaveVoucherId || (((_a2 = walletPassData == null ? void 0 : walletPassData.selectedDiscountList) == null ? void 0 : _a2.length) ?? 0) > 0;
|
@@ -393,7 +393,7 @@ function AmountSummary({
|
|
393
393
|
};
|
394
394
|
const getMiddleContent = () => {
|
395
395
|
if (paymentType === "deposit") {
|
396
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("payment-details") }, shouldShowPartialPaidCard() && /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("partial-paid-card") }, /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("partial-paid-label") }, getText("partial.paid") || "Partial Paid"), /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("partial-paid-amount") }, (0, import_utils.formatAmountWithOptions)(partialPaidAmount, amountSymbol, {
|
396
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("payment-details") }, shouldShowPartialPaidCard() && /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("partial-paid-card") }, /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("partial-paid-label") }, paymentType === "deposit" ? getText("deposit.partial.paid") || "Deposit Paid" : getText("partial.paid") || "Partial Paid"), /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("partial-paid-amount") }, (0, import_utils.formatAmountWithOptions)(partialPaidAmount, amountSymbol, {
|
397
397
|
precision: 2,
|
398
398
|
hideDecimalForWholeNumbers: false,
|
399
399
|
useThousandsSeparator: true,
|
@@ -440,6 +440,33 @@ function AmountSummary({
|
|
440
440
|
));
|
441
441
|
}
|
442
442
|
};
|
443
|
+
const canSwitch = (0, import_react.useMemo)(() => {
|
444
|
+
if (Number(orderInfo == null ? void 0 : orderInfo.totalAmount) === 0) {
|
445
|
+
return false;
|
446
|
+
}
|
447
|
+
if (paymentType === "regular") {
|
448
|
+
const depositPaidAmount = paymentItems == null ? void 0 : paymentItems.reduce((acc, item) => {
|
449
|
+
if (item.order_payment_type === "deposit") {
|
450
|
+
return acc.plus(item.amount).plus(Math.abs(item.rounding_amount));
|
451
|
+
}
|
452
|
+
return acc;
|
453
|
+
}, new import_decimal.default(0)).toNumber();
|
454
|
+
const depositFlag = depositPaidAmount >= new import_decimal.default((orderInfo == null ? void 0 : orderInfo.depositAmount) || "0").toNumber() && Number(orderInfo == null ? void 0 : orderInfo.depositAmount) > 0;
|
455
|
+
return !(paymentItems == null ? void 0 : paymentItems.some((item) => item.order_payment_type === "normal")) && !depositFlag;
|
456
|
+
} else {
|
457
|
+
const depositPaidAmount = paymentItems == null ? void 0 : paymentItems.reduce((acc, item) => {
|
458
|
+
if (item.order_payment_type === "deposit") {
|
459
|
+
return acc.plus(item.amount);
|
460
|
+
}
|
461
|
+
return acc;
|
462
|
+
}, new import_decimal.default(0)).toNumber();
|
463
|
+
return depositPaidAmount < new import_decimal.default(totalAmount).toNumber();
|
464
|
+
}
|
465
|
+
}, [paymentItems, paymentType, totalAmount]);
|
466
|
+
const handleChangeDepositAmount = (value) => {
|
467
|
+
console.log("handleChangeDepositAmount", value);
|
468
|
+
checkoutModule == null ? void 0 : checkoutModule.setDepositAmountAsync(value);
|
469
|
+
};
|
443
470
|
return /* @__PURE__ */ import_react2.default.createElement(
|
444
471
|
"div",
|
445
472
|
{
|
@@ -448,7 +475,7 @@ function AmountSummary({
|
|
448
475
|
"amount-summary-container"
|
449
476
|
)
|
450
477
|
},
|
451
|
-
/* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("left-section") }, open_deposit ? /* @__PURE__ */ import_react2.default.createElement(
|
478
|
+
/* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("left-section") }, open_deposit && canSwitch ? /* @__PURE__ */ import_react2.default.createElement(
|
452
479
|
import_antd.Dropdown,
|
453
480
|
{
|
454
481
|
menu: {
|
@@ -475,11 +502,35 @@ function AmountSummary({
|
|
475
502
|
/* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("middle-section") }, getMiddleContent()),
|
476
503
|
/* @__PURE__ */ import_react2.default.createElement(
|
477
504
|
"div",
|
478
|
-
{
|
479
|
-
"
|
480
|
-
|
505
|
+
{
|
506
|
+
className: (0, import_classnames.default)("balance-due-card", {
|
507
|
+
"confirm-mode": shouldShowConfirmMode()
|
508
|
+
})
|
509
|
+
},
|
481
510
|
// 如果应该显示确认模式,直接返回确认界面
|
482
|
-
shouldShowConfirmMode() ? renderConfirmMode() : /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-info") },
|
511
|
+
shouldShowConfirmMode() ? renderConfirmMode() : /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-info") }, paymentType === "deposit" ? /* @__PURE__ */ import_react2.default.createElement(
|
512
|
+
import_pisellSimplePriceKeyboardPopover.default,
|
513
|
+
{
|
514
|
+
value: (orderInfo == null ? void 0 : orderInfo.depositAmount) || "0",
|
515
|
+
onConfirm: handleChangeDepositAmount,
|
516
|
+
showCurrencySymbol: true,
|
517
|
+
useThousandsSeparator: true,
|
518
|
+
selectType: "dark",
|
519
|
+
overlayClassName: "cash-payment-keyboard-popover"
|
520
|
+
},
|
521
|
+
/* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-label") }, getText("deposit.due") || "Deposit Due"), /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-amount") }, (0, import_utils.formatAmountWithOptions)(balanceDueAmount, amountSymbol, {
|
522
|
+
precision: 2,
|
523
|
+
hideDecimalForWholeNumbers: false,
|
524
|
+
useThousandsSeparator: true,
|
525
|
+
showCurrencySymbol: true
|
526
|
+
}), /* @__PURE__ */ import_react2.default.createElement(
|
527
|
+
import_icon.Edit05,
|
528
|
+
{
|
529
|
+
className: (0, import_classnames.default)("edit-icon"),
|
530
|
+
style: { color: "#7F56DA" }
|
531
|
+
}
|
532
|
+
)))
|
533
|
+
) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-label") }, getText("balance.due") || "Balance Due"), /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-amount"), onClick: () => {
|
483
534
|
onBalanceDueAmountClick == null ? void 0 : onBalanceDueAmountClick("manual-discount");
|
484
535
|
} }, (0, import_utils.formatAmountWithOptions)(balanceDueAmount, amountSymbol, {
|
485
536
|
precision: 2,
|
@@ -492,8 +543,8 @@ function AmountSummary({
|
|
492
543
|
className: (0, import_classnames.default)("edit-icon"),
|
493
544
|
style: { color: "#7F56DA" }
|
494
545
|
}
|
495
|
-
))),
|
496
|
-
/* @__PURE__ */ import_react2.default.createElement(
|
546
|
+
)))),
|
547
|
+
Number(currentAmount) > 0 && /* @__PURE__ */ import_react2.default.createElement(
|
497
548
|
"div",
|
498
549
|
{
|
499
550
|
className: (0, import_classnames.default)("pay-section"),
|
@@ -520,20 +571,43 @@ function AmountSummary({
|
|
520
571
|
)
|
521
572
|
),
|
522
573
|
!shouldShowConfirmMode() && /* @__PURE__ */ import_react2.default.createElement(
|
523
|
-
|
574
|
+
import_antd.Popover,
|
524
575
|
{
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
576
|
+
content: /* @__PURE__ */ import_react2.default.createElement("div", { onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ import_react2.default.createElement(
|
577
|
+
import_priceKeyboard.PaymentKeyboard,
|
578
|
+
{
|
579
|
+
paymentOriginalValue: balanceDueAmount,
|
580
|
+
paymentDefaultValue: String(customAmount || 0),
|
581
|
+
enableExceedMaxAmount: false,
|
582
|
+
payment: {
|
583
|
+
enable: true
|
584
|
+
},
|
585
|
+
surcharge: {
|
586
|
+
enable: false
|
587
|
+
},
|
588
|
+
surchargeDefaultValue: {
|
589
|
+
percent: "0",
|
590
|
+
fixed: "0"
|
591
|
+
},
|
592
|
+
selectType: "light",
|
593
|
+
onChange: (value) => {
|
594
|
+
console.log(value);
|
595
|
+
},
|
596
|
+
doneText: getText("confirm"),
|
597
|
+
onPay: (args) => {
|
598
|
+
console.log(args);
|
599
|
+
setIsKeyboardVisible(false);
|
600
|
+
handleKeyboardConfirm(args.amount);
|
601
|
+
}
|
530
602
|
}
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
overlayClassName: "
|
603
|
+
)),
|
604
|
+
trigger: "click",
|
605
|
+
open: isKeyboardVisible,
|
606
|
+
onOpenChange: setIsKeyboardVisible,
|
607
|
+
placement: "bottom",
|
608
|
+
overlayClassName: "payment-keyboard-popover",
|
609
|
+
arrow: true,
|
610
|
+
destroyTooltipOnHide: true
|
537
611
|
},
|
538
612
|
/* @__PURE__ */ import_react2.default.createElement(import_antd.Button, { className: (0, import_classnames.default)("split-payment-button") }, getText("split.payment") || "拆分支付")
|
539
613
|
),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import './index.less';
|
3
2
|
import { CurrentOrderInfo } from '../../types';
|
3
|
+
import './index.less';
|
4
4
|
export interface CashPaymentModuleProps {
|
5
5
|
amountSymbol?: string;
|
6
6
|
orderInfo?: CurrentOrderInfo;
|
@@ -13,8 +13,10 @@ export interface CashPaymentModuleProps {
|
|
13
13
|
roundingDifference: number;
|
14
14
|
}>;
|
15
15
|
balanceDueAmount?: string;
|
16
|
+
syncingLock?: boolean;
|
16
17
|
}
|
17
|
-
export declare function CashPaymentModule({ amountSymbol, orderInfo, onPaymentComplete, customAmount, amountButtons, //
|
18
|
+
export declare function CashPaymentModule({ amountSymbol, orderInfo, onPaymentComplete, customAmount, amountButtons, // 按钮列表,默认5个推荐金额
|
18
19
|
disabled, // 禁用状态
|
19
|
-
roundingFunction, balanceDueAmount,
|
20
|
+
roundingFunction, balanceDueAmount, // 剩余支付金额
|
21
|
+
syncingLock, }: CashPaymentModuleProps): JSX.Element;
|
20
22
|
export default CashPaymentModule;
|
@@ -34,39 +34,36 @@ __export(CashPaymentModule_exports, {
|
|
34
34
|
});
|
35
35
|
module.exports = __toCommonJS(CashPaymentModule_exports);
|
36
36
|
var import_react = __toESM(require("react"));
|
37
|
-
var import_index = require("./index.less");
|
38
|
-
var import_classnames = __toESM(require("classnames"));
|
39
|
-
var import_icon = require("@pisell/icon");
|
40
|
-
var import_pisellPriceKeyboardPopover = __toESM(require("../../../../pro/pisellPriceKeyboardPopover"));
|
41
37
|
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
|
42
38
|
var import_utils = require("@pisell/utils");
|
43
39
|
var import_locales = __toESM(require("../../locales"));
|
44
40
|
var import_useToast = __toESM(require("../../../../hooks/useToast"));
|
41
|
+
var import_priceKeyboard = require("../../../../pro/priceKeyboard");
|
42
|
+
var import_ahooks = require("ahooks");
|
43
|
+
var import_index = require("./index.less");
|
45
44
|
function CashPaymentModule({
|
46
45
|
amountSymbol,
|
47
46
|
orderInfo,
|
48
47
|
onPaymentComplete,
|
49
48
|
customAmount,
|
50
49
|
amountButtons = [],
|
51
|
-
//
|
50
|
+
// 按钮列表,默认5个推荐金额
|
52
51
|
disabled = false,
|
53
52
|
// 禁用状态
|
54
53
|
roundingFunction,
|
55
|
-
balanceDueAmount = "0"
|
54
|
+
balanceDueAmount = "0",
|
56
55
|
// 剩余支付金额
|
56
|
+
syncingLock = false
|
57
|
+
// 是否锁定
|
57
58
|
}) {
|
58
59
|
const [amount, setAmount] = (0, import_react.useState)(customAmount || "");
|
59
60
|
const [roundingAmount, setRoundingAmount] = (0, import_react.useState)(0);
|
60
|
-
const [amountList, setAmountList] = (0, import_react.useState)(amountButtons.length ? amountButtons : new Array(6).fill(0));
|
61
|
-
(0, import_react.useEffect)(() => {
|
62
|
-
setAmountList(amountButtons.length ? amountButtons : new Array(6).fill(0));
|
63
|
-
}, [amountButtons]);
|
64
61
|
const context = (0, import_useEngineContext.default)();
|
65
62
|
const Toast = (0, import_useToast.default)();
|
66
63
|
const getText = (key, fallback) => {
|
67
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
68
|
-
const currentLang = ((_e = (_d = (_c = (_b = (_a = context.appHelper.utils) == null ? void 0 :
|
69
|
-
const checkoutText = (
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
65
|
+
const currentLang = ((_f = (_e = (_d = (_c = (_b = (_a = context.appHelper) == null ? void 0 : _a.utils) == null ? void 0 : _b.getApp) == null ? void 0 : _c.call(_b)) == null ? void 0 : _d.locales) == null ? void 0 : _e.getLocale) == null ? void 0 : _f.call(_e)) || ((_h = (_g = context.appHelper.utils) == null ? void 0 : _g.storage) == null ? void 0 : _h.get("umi_locale")) || "en";
|
66
|
+
const checkoutText = (_i = import_locales.default[currentLang]) == null ? void 0 : _i[key];
|
70
67
|
if (checkoutText) {
|
71
68
|
return checkoutText;
|
72
69
|
}
|
@@ -77,17 +74,16 @@ function CashPaymentModule({
|
|
77
74
|
}, [customAmount, balanceDueAmount]);
|
78
75
|
const isAmountButtonsDisabled = disabled || Number(customAmount || 0) === 0;
|
79
76
|
const isInputDisabled = disabled || Number(customAmount || 0) === 0;
|
80
|
-
const
|
81
|
-
if (isAmountButtonsDisabled) return;
|
82
|
-
const amountStr = clickedAmount.toString();
|
83
|
-
setAmount(amountStr);
|
84
|
-
setRoundingAmount(0);
|
85
|
-
};
|
86
|
-
const handleCashPay = () => {
|
77
|
+
const handleCashPayInternal = () => {
|
87
78
|
if (isAmountButtonsDisabled) return;
|
88
79
|
if (onPaymentComplete) {
|
89
80
|
if (Number(amount) === 0 && Math.abs(roundingAmount) === 0) {
|
90
|
-
Toast.fail(
|
81
|
+
Toast.fail(
|
82
|
+
getText(
|
83
|
+
"cash-payment-amount-cannot-be-zero",
|
84
|
+
"The amount cannot be 0"
|
85
|
+
)
|
86
|
+
);
|
91
87
|
return;
|
92
88
|
}
|
93
89
|
const finalAmount = typeof amount === "number" ? amount : Number(amount) || 0;
|
@@ -100,17 +96,21 @@ function CashPaymentModule({
|
|
100
96
|
});
|
101
97
|
}
|
102
98
|
};
|
99
|
+
const { run: handleCashPay } = (0, import_ahooks.useDebounceFn)(handleCashPayInternal, {
|
100
|
+
wait: 500
|
101
|
+
});
|
103
102
|
const handleKeyboardConfirm = async (value) => {
|
104
103
|
if (isInputDisabled) {
|
105
104
|
setAmount("0.00");
|
106
105
|
setRoundingAmount(0);
|
107
106
|
return;
|
108
107
|
}
|
109
|
-
;
|
110
108
|
const finalValue = String(value);
|
111
109
|
console.log("键盘确认:", finalValue);
|
112
110
|
if (Number(finalValue) === 0) {
|
113
|
-
Toast.fail(
|
111
|
+
Toast.fail(
|
112
|
+
getText("cash-payment-amount-cannot-be-zero", "The amount cannot be 0")
|
113
|
+
);
|
114
114
|
return;
|
115
115
|
}
|
116
116
|
if (finalValue === "" || finalValue === null || finalValue === void 0) {
|
@@ -127,9 +127,21 @@ function CashPaymentModule({
|
|
127
127
|
const { roundedAmount = numValue, roundingDifference = 0 } = result || {};
|
128
128
|
finalAmount = roundedAmount;
|
129
129
|
roundingDiff = roundingDifference;
|
130
|
-
console.log(
|
130
|
+
console.log(
|
131
|
+
"应用抹零:",
|
132
|
+
numValue,
|
133
|
+
"->",
|
134
|
+
roundedAmount,
|
135
|
+
"差额:",
|
136
|
+
roundingDifference
|
137
|
+
);
|
131
138
|
} else {
|
132
|
-
console.log(
|
139
|
+
console.log(
|
140
|
+
"不应用抹零,用户输入金额:",
|
141
|
+
numValue,
|
142
|
+
"剩余支付金额:",
|
143
|
+
balanceDue
|
144
|
+
);
|
133
145
|
}
|
134
146
|
setRoundingAmount(roundingDiff);
|
135
147
|
if (isNaN(numValue)) {
|
@@ -140,126 +152,77 @@ function CashPaymentModule({
|
|
140
152
|
}
|
141
153
|
}
|
142
154
|
};
|
143
|
-
const
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
const
|
149
|
-
|
150
|
-
|
155
|
+
const handleReset = async () => {
|
156
|
+
if (isAmountButtonsDisabled) return;
|
157
|
+
const resetAmount = balanceDueAmount || "0";
|
158
|
+
const cleanValue = resetAmount.replace(/[$\s]/g, "");
|
159
|
+
const numValue = parseFloat(cleanValue);
|
160
|
+
const balanceDue = parseFloat(balanceDueAmount);
|
161
|
+
const shouldApplyRounding = Math.abs(numValue - balanceDue) < 0.01;
|
162
|
+
let finalAmount = numValue;
|
163
|
+
let roundingDiff = 0;
|
164
|
+
if (shouldApplyRounding && roundingFunction) {
|
165
|
+
const result = await roundingFunction(finalAmount);
|
166
|
+
const { roundedAmount = numValue, roundingDifference = 0 } = result || {};
|
167
|
+
finalAmount = roundedAmount;
|
168
|
+
roundingDiff = roundingDifference;
|
169
|
+
console.log(
|
170
|
+
"应用抹零:",
|
171
|
+
numValue,
|
172
|
+
"->",
|
173
|
+
roundedAmount,
|
174
|
+
"差额:",
|
175
|
+
roundingDifference
|
176
|
+
);
|
177
|
+
} else {
|
178
|
+
console.log(
|
179
|
+
"不应用抹零,用户输入金额:",
|
180
|
+
numValue,
|
181
|
+
"剩余支付金额:",
|
182
|
+
balanceDue
|
183
|
+
);
|
184
|
+
}
|
185
|
+
setAmount(finalAmount.toString());
|
186
|
+
setRoundingAmount(roundingDiff);
|
151
187
|
};
|
152
188
|
return /* @__PURE__ */ import_react.default.createElement(
|
153
|
-
|
189
|
+
import_priceKeyboard.CashKeyboard,
|
154
190
|
{
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
className: (0, import_classnames.default)("cash-pay-main-content", {
|
164
|
-
"cash-pay-main-content--disabled": disabled
|
165
|
-
})
|
191
|
+
variant: "intact",
|
192
|
+
originalValue: customAmount,
|
193
|
+
value: amount,
|
194
|
+
disabled,
|
195
|
+
hiddenChangeDue: roundingAmount > 0,
|
196
|
+
onChange: (value) => {
|
197
|
+
setAmount(value);
|
198
|
+
setRoundingAmount(0);
|
166
199
|
},
|
167
|
-
|
168
|
-
|
169
|
-
{
|
170
|
-
|
171
|
-
onConfirm: handleKeyboardConfirm,
|
172
|
-
onCancel: handleKeyboardCancel,
|
173
|
-
showCurrencySymbol: true,
|
174
|
-
useThousandsSeparator: true,
|
175
|
-
selectType: "dark",
|
176
|
-
overlayClassName: "cash-payment-keyboard-popover",
|
177
|
-
disabled: isInputDisabled
|
178
|
-
},
|
179
|
-
/* @__PURE__ */ import_react.default.createElement(
|
180
|
-
"div",
|
181
|
-
{
|
182
|
-
className: (0, import_classnames.default)("cash-pay-amount-input-area", {
|
183
|
-
"cash-pay-amount-input-area--disabled": isInputDisabled
|
184
|
-
})
|
185
|
-
},
|
186
|
-
/* @__PURE__ */ import_react.default.createElement(
|
187
|
-
import_icon.Edit05,
|
188
|
-
{
|
189
|
-
className: (0, import_classnames.default)("cash-pay-amount-edit-icon", {
|
190
|
-
"cash-pay-amount-edit-icon--disabled": isInputDisabled
|
191
|
-
})
|
192
|
-
}
|
193
|
-
),
|
194
|
-
/* @__PURE__ */ import_react.default.createElement(
|
195
|
-
"div",
|
196
|
-
{
|
197
|
-
className: (0, import_classnames.default)("cash-pay-amount-input-wrapper", {
|
198
|
-
"cash-pay-amount-input-wrapper--disabled": isInputDisabled
|
199
|
-
})
|
200
|
-
},
|
201
|
-
/* @__PURE__ */ import_react.default.createElement(
|
202
|
-
"span",
|
203
|
-
{
|
204
|
-
className: (0, import_classnames.default)("cash-pay-currency-symbol", {
|
205
|
-
"cash-pay-currency-symbol--disabled": isInputDisabled
|
206
|
-
})
|
207
|
-
},
|
208
|
-
amountSymbol
|
209
|
-
),
|
210
|
-
/* @__PURE__ */ import_react.default.createElement(
|
211
|
-
"div",
|
212
|
-
{
|
213
|
-
className: (0, import_classnames.default)("cash-pay-amount-display", {
|
214
|
-
"cash-pay-amount-display--disabled": isInputDisabled
|
215
|
-
})
|
216
|
-
},
|
217
|
-
amount || "0.00"
|
218
|
-
)
|
219
|
-
)
|
220
|
-
)
|
221
|
-
), /* @__PURE__ */ import_react.default.createElement(
|
222
|
-
"div",
|
223
|
-
{
|
224
|
-
className: (0, import_classnames.default)("cash-pay-button", {
|
225
|
-
"cash-pay-button--disabled": isAmountButtonsDisabled
|
226
|
-
}),
|
227
|
-
...isAmountButtonsDisabled ? {} : { onClick: handleCashPay },
|
228
|
-
style: { cursor: isAmountButtonsDisabled ? "not-allowed" : "pointer" }
|
200
|
+
titleArea: {
|
201
|
+
visible: true,
|
202
|
+
title: {
|
203
|
+
text: getText("cash-payment-title", "Cash Payment")
|
229
204
|
},
|
230
|
-
|
231
|
-
|
232
|
-
{
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
},
|
252
|
-
/* @__PURE__ */ import_react.default.createElement(
|
253
|
-
"div",
|
254
|
-
{
|
255
|
-
className: (0, import_classnames.default)("cash-pay-amount-button-text", {
|
256
|
-
"cash-pay-amount-button-text--disabled": isAmountButtonsDisabled
|
257
|
-
})
|
258
|
-
},
|
259
|
-
(0, import_utils.formatAmount)(amount2, 2, amountSymbol)
|
260
|
-
)
|
261
|
-
)))
|
262
|
-
)
|
205
|
+
subtitle: {
|
206
|
+
visible: Math.abs(roundingAmount) > 0,
|
207
|
+
text: `${getText(
|
208
|
+
"cash-payment-rounding",
|
209
|
+
"Rounding"
|
210
|
+
)}: ${(0, import_utils.formatAmount)(roundingAmount, 2, amountSymbol)}`
|
211
|
+
}
|
212
|
+
},
|
213
|
+
style: {
|
214
|
+
width: "100%",
|
215
|
+
backgroundColor: "transparent"
|
216
|
+
},
|
217
|
+
presets: amountButtons.slice(0, 5).map((buttonAmount) => {
|
218
|
+
return {
|
219
|
+
label: (0, import_utils.formatAmount)(buttonAmount, 2, amountSymbol),
|
220
|
+
value: buttonAmount
|
221
|
+
};
|
222
|
+
}),
|
223
|
+
onReset: handleReset,
|
224
|
+
onEnter: syncingLock ? void 0 : handleCashPay
|
225
|
+
}
|
263
226
|
);
|
264
227
|
}
|
265
228
|
var CashPaymentModule_default = CashPaymentModule;
|