@pisell/pisellos 2.3.73 → 2.3.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.js +111 -71
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +0 -1
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.js +2 -4
- package/dist/modules/OpenData/index.js +0 -2
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +36 -64
- package/dist/modules/Payment/index.js +97 -162
- package/dist/modules/Quotation/index.d.ts +6 -0
- package/dist/modules/Quotation/index.js +75 -19
- package/dist/modules/Rules/index.js +1 -4
- package/dist/modules/Schedule/index.js +0 -1
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/plugins/request.d.ts +1 -0
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.d.ts +8 -2
- package/dist/server/index.js +303 -269
- package/dist/server/modules/floor-plan/index.d.ts +4 -0
- package/dist/server/modules/floor-plan/index.js +240 -98
- package/dist/server/modules/menu/index.js +75 -59
- package/dist/server/modules/order/index.d.ts +17 -7
- package/dist/server/modules/order/index.js +421 -211
- package/dist/server/modules/products/index.d.ts +8 -2
- package/dist/server/modules/products/index.js +191 -117
- package/dist/server/modules/quotation/index.js +29 -38
- package/dist/server/modules/resource/index.js +24 -17
- package/dist/server/modules/schedule/index.js +27 -35
- package/dist/server/utils/product.js +0 -1
- package/dist/solution/BaseSales/index.js +38 -41
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.js +0 -2
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
- package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.js +177 -252
- package/dist/solution/Checkout/utils/index.js +4 -16
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/ScanOrder/index.js +50 -60
- package/dist/solution/ShopDiscount/index.js +2 -7
- package/dist/solution/VenueBooking/index.js +45 -55
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.d.ts +7 -0
- package/lib/core/index.js +149 -131
- package/lib/effects/index.js +46 -57
- package/lib/index.js +82 -49
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
- package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
- package/lib/model/strategy/adapter/promotion/examples.js +222 -234
- package/lib/model/strategy/adapter/promotion/index.js +1 -0
- package/lib/model/strategy/adapter/promotion/type.js +243 -36
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.js +23 -42
- package/lib/modules/BookingContext/index.js +158 -136
- package/lib/modules/BookingContext/types.js +46 -32
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
- package/lib/modules/BookingContext/utils/flexible.js +38 -55
- package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
- package/lib/modules/BookingContext/utils/index.js +124 -41
- package/lib/modules/BookingContext/utils/noResource.js +58 -70
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
- package/lib/modules/BookingContext/utils/productExtend.js +202 -155
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
- package/lib/modules/BookingContext/utils/resources.js +209 -167
- package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
- package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +321 -251
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +70 -78
- package/lib/modules/Cart/utils/changePrice.js +22 -50
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.js +235 -172
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.js +122 -127
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.js +70 -76
- package/lib/modules/OpenData/types.js +4 -16
- package/lib/modules/OpenData/utils.js +44 -78
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +1713 -2118
- package/lib/modules/Order/payment-utils.js +77 -120
- package/lib/modules/Order/types.js +88 -35
- package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
- package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
- package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
- package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
- package/lib/modules/Order/utils.js +814 -647
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.js +532 -399
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.js +230 -108
- package/lib/modules/Payment/utils.js +52 -51
- package/lib/modules/Payment/walletpass.js +485 -660
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.js +113 -123
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.d.ts +6 -0
- package/lib/modules/Quotation/index.js +110 -103
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/ResourcePlanner/index.js +25 -23
- package/lib/modules/ResourcePlanner/localClock.js +54 -119
- package/lib/modules/ResourcePlanner/planner.js +589 -770
- package/lib/modules/ResourcePlanner/types.js +10 -29
- package/lib/modules/Rules/index.js +1218 -959
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +85 -90
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +355 -430
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
- package/lib/modules/Schedule/index.js +100 -114
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -71
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +773 -418
- package/lib/modules/SurchargeList/index.js +46 -60
- package/lib/modules/SurchargeList/types.js +4 -16
- package/lib/modules/index.js +245 -63
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.d.ts +1 -0
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.d.ts +8 -2
- package/lib/server/index.js +3083 -2663
- package/lib/server/modules/floor-plan/index.d.ts +4 -0
- package/lib/server/modules/floor-plan/index.js +159 -127
- package/lib/server/modules/floor-plan/types.js +15 -30
- package/lib/server/modules/index.js +106 -68
- package/lib/server/modules/menu/index.js +170 -124
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.d.ts +17 -7
- package/lib/server/modules/order/index.js +916 -977
- package/lib/server/modules/order/types.js +122 -33
- package/lib/server/modules/order/utils/filterBookings.js +219 -194
- package/lib/server/modules/order/utils/filterOrders.js +118 -92
- package/lib/server/modules/payment/index.js +59 -83
- package/lib/server/modules/payment/types.js +4 -16
- package/lib/server/modules/products/index.d.ts +8 -2
- package/lib/server/modules/products/index.js +656 -471
- package/lib/server/modules/products/types.js +44 -34
- package/lib/server/modules/quotation/index.js +137 -172
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.js +225 -186
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.js +135 -123
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +196 -139
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/small-ticket.js +479 -456
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.js +1186 -1410
- package/lib/solution/BaseSales/types.js +42 -38
- package/lib/solution/BaseSales/utils/cartPromotion.js +642 -498
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
- package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
- package/lib/solution/BaseSales/utils.js +158 -143
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1527 -1340
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.js +607 -522
- package/lib/solution/BookingTicket/types.js +99 -77
- package/lib/solution/BookingTicket/utils/addProductDecision.js +226 -189
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
- package/lib/solution/BookingTicket/utils/cartView.js +114 -99
- package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.js +1451 -1158
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +228 -156
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +493 -460
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.js +328 -324
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.js +832 -864
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.js +409 -374
- package/lib/solution/ShopDiscount/index.js +226 -232
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +300 -172
- package/lib/solution/UnifiedBookingSales/index.js +1035 -1201
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
- package/lib/solution/UnifiedBookingSales/types.js +10 -32
- package/lib/solution/VenueBooking/index.js +811 -879
- package/lib/solution/VenueBooking/types.js +19 -39
- package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
- package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.js +124 -41
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.js +4 -16
- package/lib/utils/payment-number.js +26 -46
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
|
@@ -1,36 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(cash_exports, {
|
|
22
|
-
CashPaymentImpl: () => CashPaymentImpl
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
|
|
6
|
+
exports.CashPaymentImpl = void 0;
|
|
7
|
+
var _cashRecommendationAlgorithm = require("./cashRecommendationAlgorithm");
|
|
8
|
+
/**
|
|
9
|
+
* 现金支付实现
|
|
10
|
+
*/
|
|
11
|
+
class CashPaymentImpl {
|
|
27
12
|
constructor(paymentModule) {
|
|
28
13
|
this.paymentModule = paymentModule;
|
|
29
14
|
}
|
|
30
15
|
async processCashPayment(amount, orderUuid) {
|
|
31
16
|
const cashMethod = await this.paymentModule.getCashPaymentMethod();
|
|
32
17
|
if (!cashMethod) {
|
|
33
|
-
throw new Error(
|
|
18
|
+
throw new Error('现金支付方式未找到');
|
|
34
19
|
}
|
|
35
20
|
const paymentItem = {
|
|
36
21
|
amount: amount.toString(),
|
|
@@ -38,13 +23,15 @@ var CashPaymentImpl = class {
|
|
|
38
23
|
custom_payment_id: cashMethod.id,
|
|
39
24
|
name: cashMethod.name,
|
|
40
25
|
type: cashMethod.type,
|
|
41
|
-
voucher_id:
|
|
26
|
+
voucher_id: ''
|
|
42
27
|
};
|
|
43
28
|
await this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
|
|
44
29
|
}
|
|
45
30
|
async getCashBalance() {
|
|
31
|
+
// 现金余额逻辑可以根据实际业务需求实现
|
|
46
32
|
return 0;
|
|
47
33
|
}
|
|
34
|
+
|
|
48
35
|
/**
|
|
49
36
|
* 获取推荐支付金额
|
|
50
37
|
* 基于目标金额和货币类型,返回最优支付金额建议
|
|
@@ -53,12 +40,12 @@ var CashPaymentImpl = class {
|
|
|
53
40
|
* @returns 推荐支付金额数组
|
|
54
41
|
*/
|
|
55
42
|
getRecommendedAmount(money, currency) {
|
|
43
|
+
// 获取对应货币的面额配置
|
|
56
44
|
const upperCurrency = currency.toUpperCase();
|
|
57
|
-
const denominations =
|
|
58
|
-
|
|
45
|
+
const denominations = _cashRecommendationAlgorithm.CURRENCY_DENOMINATIONS[upperCurrency] || _cashRecommendationAlgorithm.CURRENCY_DENOMINATIONS['DEFAULT'];
|
|
46
|
+
|
|
47
|
+
// 直接调用算法,所有验证和容错处理都在算法内部
|
|
48
|
+
return (0, _cashRecommendationAlgorithm.recommendOptimalPayments)(money, denominations);
|
|
59
49
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
0 && (module.exports = {
|
|
63
|
-
CashPaymentImpl
|
|
64
|
-
});
|
|
50
|
+
}
|
|
51
|
+
exports.CashPaymentImpl = CashPaymentImpl;
|
|
@@ -1,83 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(cashRecommendationAlgorithm_exports, {
|
|
22
|
-
CURRENCY_DENOMINATIONS: () => CURRENCY_DENOMINATIONS,
|
|
23
|
-
recommendOptimalPayments: () => recommendOptimalPayments
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
24
5
|
});
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
exports.CURRENCY_DENOMINATIONS = void 0;
|
|
7
|
+
exports.recommendOptimalPayments = recommendOptimalPayments;
|
|
8
|
+
/**
|
|
9
|
+
* 现金支付推荐算法
|
|
10
|
+
*
|
|
11
|
+
* 核心原理:
|
|
12
|
+
* 1. 每个推荐金额都应该是独立的最优组合
|
|
13
|
+
* 2. 不推荐在已有最优解基础上添加额外面额的组合
|
|
14
|
+
* 3. 优先推荐使用不同数量币种的组合
|
|
15
|
+
* 4. 根据组合判断去重,避免扩展组合
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 常见国家货币面额配置
|
|
20
|
+
*/
|
|
21
|
+
const CURRENCY_DENOMINATIONS = exports.CURRENCY_DENOMINATIONS = {
|
|
27
22
|
// 美元
|
|
28
|
-
|
|
23
|
+
'USD': [100, 50, 20, 10, 5, 1, 0.5, 0.25, 0.1, 0.05, 0.01],
|
|
29
24
|
// 人民币
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
'CNY': [100, 50, 20, 10, 5, 1, 0.5, 0.1, 0.05, 0.01],
|
|
26
|
+
'RMB': [100, 50, 20, 10, 5, 1, 0.5, 0.1, 0.05, 0.01],
|
|
32
27
|
// 欧元
|
|
33
|
-
|
|
28
|
+
'EUR': [500, 200, 100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01],
|
|
34
29
|
// 日元
|
|
35
|
-
|
|
30
|
+
'JPY': [10000, 5000, 2000, 1000, 500, 100, 50, 10, 5, 1],
|
|
36
31
|
// 英镑
|
|
37
|
-
|
|
32
|
+
'GBP': [50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01],
|
|
38
33
|
// 澳元
|
|
39
|
-
|
|
34
|
+
'AUD': [100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1],
|
|
40
35
|
// 加元
|
|
41
|
-
|
|
36
|
+
'CAD': [100, 50, 20, 10, 5, 2, 1, 0.25, 0.1, 0.05],
|
|
42
37
|
// 港元
|
|
43
|
-
|
|
38
|
+
'HKD': [1000, 500, 100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1],
|
|
44
39
|
// 新台币
|
|
45
|
-
|
|
40
|
+
'TWD': [2000, 1000, 500, 200, 100, 50, 10, 5, 1],
|
|
46
41
|
// 韩元
|
|
47
|
-
|
|
42
|
+
'KRW': [50000, 10000, 5000, 1000, 500, 100, 50, 10, 5, 1],
|
|
48
43
|
// 新加坡元
|
|
49
|
-
|
|
44
|
+
'SGD': [10000, 1000, 100, 50, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01],
|
|
50
45
|
// 瑞士法郎
|
|
51
|
-
|
|
46
|
+
'CHF': [1000, 200, 100, 50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05],
|
|
52
47
|
// 默认通用面额(如果币种不在列表中)
|
|
53
|
-
|
|
48
|
+
'DEFAULT': [100, 50, 20, 10, 5, 1, 0.5, 0.25, 0.1, 0.05, 0.01]
|
|
54
49
|
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 支付组合类型定义
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 最优支付金额推荐算法
|
|
57
|
+
* 推荐通过不同数量面额组合刚好足够支付的最小金额
|
|
58
|
+
*
|
|
59
|
+
* @param targetAmount 目标金额
|
|
60
|
+
* @param denominations 币种面值数组
|
|
61
|
+
* @returns 推荐支付金额数组
|
|
62
|
+
*/
|
|
55
63
|
function recommendOptimalPayments(targetAmount, denominations) {
|
|
64
|
+
// 参数验证
|
|
56
65
|
if (targetAmount <= 0 || !isFinite(targetAmount) || isNaN(targetAmount)) {
|
|
57
66
|
return [];
|
|
58
67
|
}
|
|
59
68
|
if (!denominations || !Array.isArray(denominations) || denominations.length === 0) {
|
|
60
69
|
return [Math.ceil(targetAmount)];
|
|
61
70
|
}
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
|
|
72
|
+
// 过滤有效面额并限制搜索空间以提高性能
|
|
73
|
+
const maxReasonableDenom = targetAmount * 5; // 适度限制搜索空间
|
|
74
|
+
const validDenoms = denominations.filter(denom => denom > 0 && isFinite(denom) && !isNaN(denom) && denom <= maxReasonableDenom).slice(0, 8); // 限制面额数量以提高性能
|
|
75
|
+
|
|
64
76
|
if (validDenoms.length === 0) {
|
|
77
|
+
// 如果没有合适的面额,返回最接近的整数金额
|
|
65
78
|
return [Math.ceil(targetAmount)];
|
|
66
79
|
}
|
|
67
80
|
try {
|
|
68
|
-
|
|
81
|
+
// 处理精度问题,将金额转换为整数计算
|
|
82
|
+
const precision = 100; // 假设最小单位是0.01
|
|
69
83
|
const target = Math.round(targetAmount * precision);
|
|
70
|
-
const denoms = validDenoms.map(
|
|
84
|
+
const denoms = validDenoms.map(d => Math.round(d * precision)).sort((a, b) => b - a);
|
|
85
|
+
|
|
86
|
+
// 存储不同的支付组合方案
|
|
71
87
|
const paymentOptions = [];
|
|
88
|
+
|
|
89
|
+
// 首先尝试找到精确匹配的组合
|
|
72
90
|
const exactCombination = findExactCombination(target, denoms, precision);
|
|
73
91
|
if (exactCombination) {
|
|
74
92
|
paymentOptions.push(exactCombination);
|
|
75
93
|
}
|
|
94
|
+
|
|
95
|
+
// 为了提高效率,我们将按币种数量来生成组合
|
|
96
|
+
// 1币种组合:只用一种面额
|
|
76
97
|
for (let i = 0; i < Math.min(denoms.length, 6); i++) {
|
|
77
98
|
const denom = denoms[i];
|
|
78
99
|
const count = Math.ceil(target / denom);
|
|
79
100
|
const sum = count * denom;
|
|
80
101
|
if (sum >= target && count <= 12) {
|
|
102
|
+
// 限制硬币数量以提高性能
|
|
81
103
|
paymentOptions.push({
|
|
82
104
|
combination: Array(count).fill(denom / precision),
|
|
83
105
|
sum: sum / precision,
|
|
@@ -86,22 +108,23 @@ function recommendOptimalPayments(targetAmount, denominations) {
|
|
|
86
108
|
});
|
|
87
109
|
}
|
|
88
110
|
}
|
|
111
|
+
|
|
112
|
+
// 2币种组合:使用两种面额(大幅限制搜索范围以提高性能)
|
|
89
113
|
for (let i = 0; i < Math.min(denoms.length - 1, 5); i++) {
|
|
90
114
|
for (let j = i + 1; j < Math.min(denoms.length, 6); j++) {
|
|
91
115
|
const denom1 = denoms[i];
|
|
92
116
|
const denom2 = denoms[j];
|
|
117
|
+
|
|
118
|
+
// 大幅限制搜索范围,基于目标金额动态调整
|
|
93
119
|
const maxCount1 = Math.min(Math.ceil(target / denom1) + 1, 8);
|
|
94
120
|
const maxCount2 = Math.min(Math.ceil(target / denom2) + 1, 10);
|
|
95
121
|
for (let count1 = 1; count1 <= maxCount1; count1++) {
|
|
96
122
|
for (let count2 = 1; count2 <= maxCount2; count2++) {
|
|
97
123
|
const sum = count1 * denom1 + count2 * denom2;
|
|
98
124
|
if (sum >= target) {
|
|
99
|
-
const combination = [
|
|
100
|
-
...Array(count1).fill(denom1 / precision),
|
|
101
|
-
...Array(count2).fill(denom2 / precision)
|
|
102
|
-
];
|
|
125
|
+
const combination = [...Array(count1).fill(denom1 / precision), ...Array(count2).fill(denom2 / precision)];
|
|
103
126
|
paymentOptions.push({
|
|
104
|
-
combination,
|
|
127
|
+
combination: combination,
|
|
105
128
|
sum: sum / precision,
|
|
106
129
|
coinCount: count1 + count2,
|
|
107
130
|
denomTypes: 2
|
|
@@ -111,12 +134,16 @@ function recommendOptimalPayments(targetAmount, denominations) {
|
|
|
111
134
|
}
|
|
112
135
|
}
|
|
113
136
|
}
|
|
137
|
+
|
|
138
|
+
// 3币种组合:使用三种面额(大幅限制搜索以提高效率)
|
|
114
139
|
for (let i = 0; i < Math.min(denoms.length - 2, 3); i++) {
|
|
115
140
|
for (let j = i + 1; j < Math.min(denoms.length - 1, 4); j++) {
|
|
116
141
|
for (let k = j + 1; k < Math.min(denoms.length, 5); k++) {
|
|
117
142
|
const denom1 = denoms[i];
|
|
118
143
|
const denom2 = denoms[j];
|
|
119
144
|
const denom3 = denoms[k];
|
|
145
|
+
|
|
146
|
+
// 大幅限制搜索范围
|
|
120
147
|
const maxCount1 = Math.min(Math.ceil(target / denom1) + 1, 5);
|
|
121
148
|
const maxCount2 = Math.min(Math.ceil(target / denom2) + 1, 6);
|
|
122
149
|
const maxCount3 = Math.min(Math.ceil(target / denom3) + 1, 8);
|
|
@@ -125,13 +152,9 @@ function recommendOptimalPayments(targetAmount, denominations) {
|
|
|
125
152
|
for (let count3 = 1; count3 <= maxCount3; count3++) {
|
|
126
153
|
const sum = count1 * denom1 + count2 * denom2 + count3 * denom3;
|
|
127
154
|
if (sum >= target) {
|
|
128
|
-
const combination = [
|
|
129
|
-
...Array(count1).fill(denom1 / precision),
|
|
130
|
-
...Array(count2).fill(denom2 / precision),
|
|
131
|
-
...Array(count3).fill(denom3 / precision)
|
|
132
|
-
];
|
|
155
|
+
const combination = [...Array(count1).fill(denom1 / precision), ...Array(count2).fill(denom2 / precision), ...Array(count3).fill(denom3 / precision)];
|
|
133
156
|
paymentOptions.push({
|
|
134
|
-
combination,
|
|
157
|
+
combination: combination,
|
|
135
158
|
sum: sum / precision,
|
|
136
159
|
coinCount: count1 + count2 + count3,
|
|
137
160
|
denomTypes: 3
|
|
@@ -143,6 +166,8 @@ function recommendOptimalPayments(targetAmount, denominations) {
|
|
|
143
166
|
}
|
|
144
167
|
}
|
|
145
168
|
}
|
|
169
|
+
|
|
170
|
+
// 4币种组合:使用四种面额(极度限制搜索以提高性能)
|
|
146
171
|
for (let i = 0; i < Math.min(denoms.length - 3, 2); i++) {
|
|
147
172
|
for (let j = i + 1; j < Math.min(denoms.length - 2, 3); j++) {
|
|
148
173
|
for (let k = j + 1; k < Math.min(denoms.length - 1, 4); k++) {
|
|
@@ -151,6 +176,8 @@ function recommendOptimalPayments(targetAmount, denominations) {
|
|
|
151
176
|
const denom2 = denoms[j];
|
|
152
177
|
const denom3 = denoms[k];
|
|
153
178
|
const denom4 = denoms[l];
|
|
179
|
+
|
|
180
|
+
// 极度限制搜索范围
|
|
154
181
|
const maxCount1 = Math.min(Math.ceil(target / denom1) + 1, 3);
|
|
155
182
|
const maxCount2 = Math.min(Math.ceil(target / denom2) + 1, 4);
|
|
156
183
|
const maxCount3 = Math.min(Math.ceil(target / denom3) + 1, 5);
|
|
@@ -161,14 +188,9 @@ function recommendOptimalPayments(targetAmount, denominations) {
|
|
|
161
188
|
for (let count4 = 1; count4 <= maxCount4; count4++) {
|
|
162
189
|
const sum = count1 * denom1 + count2 * denom2 + count3 * denom3 + count4 * denom4;
|
|
163
190
|
if (sum >= target) {
|
|
164
|
-
const combination = [
|
|
165
|
-
...Array(count1).fill(denom1 / precision),
|
|
166
|
-
...Array(count2).fill(denom2 / precision),
|
|
167
|
-
...Array(count3).fill(denom3 / precision),
|
|
168
|
-
...Array(count4).fill(denom4 / precision)
|
|
169
|
-
];
|
|
191
|
+
const combination = [...Array(count1).fill(denom1 / precision), ...Array(count2).fill(denom2 / precision), ...Array(count3).fill(denom3 / precision), ...Array(count4).fill(denom4 / precision)];
|
|
170
192
|
paymentOptions.push({
|
|
171
|
-
combination,
|
|
193
|
+
combination: combination,
|
|
172
194
|
sum: sum / precision,
|
|
173
195
|
coinCount: count1 + count2 + count3 + count4,
|
|
174
196
|
denomTypes: 4
|
|
@@ -182,17 +204,25 @@ function recommendOptimalPayments(targetAmount, denominations) {
|
|
|
182
204
|
}
|
|
183
205
|
}
|
|
184
206
|
}
|
|
207
|
+
|
|
208
|
+
// 如果没有找到任何组合,提供默认建议
|
|
185
209
|
if (paymentOptions.length === 0) {
|
|
186
|
-
|
|
210
|
+
// 找到大于等于目标金额的最小面额
|
|
211
|
+
const minValidDenom = validDenoms.find(denom => denom >= targetAmount);
|
|
187
212
|
if (minValidDenom) {
|
|
188
213
|
return [minValidDenom];
|
|
189
214
|
} else {
|
|
215
|
+
// 使用最大面额的组合
|
|
190
216
|
const maxDenom = Math.max(...validDenoms);
|
|
191
217
|
const count = Math.ceil(targetAmount / maxDenom);
|
|
192
218
|
return [count * maxDenom];
|
|
193
219
|
}
|
|
194
220
|
}
|
|
221
|
+
|
|
222
|
+
// 移除重复和扩展组合
|
|
195
223
|
const uniqueCombinations = removeDuplicateAndExtendedCombinations(paymentOptions, targetAmount);
|
|
224
|
+
|
|
225
|
+
// 按币种类型数量排序,然后按总硬币数量排序,最后按金额排序
|
|
196
226
|
uniqueCombinations.sort((a, b) => {
|
|
197
227
|
if (a.denomTypes !== b.denomTypes) {
|
|
198
228
|
return a.denomTypes - b.denomTypes;
|
|
@@ -202,10 +232,12 @@ function recommendOptimalPayments(targetAmount, denominations) {
|
|
|
202
232
|
}
|
|
203
233
|
return a.sum - b.sum;
|
|
204
234
|
});
|
|
205
|
-
|
|
235
|
+
|
|
236
|
+
// 按金额去重并返回推荐的支付金额
|
|
237
|
+
const uniqueAmounts = new Set();
|
|
206
238
|
const finalResults = [];
|
|
207
239
|
for (const item of uniqueCombinations) {
|
|
208
|
-
const roundedAmount = Math.round(item.sum * 100) / 100;
|
|
240
|
+
const roundedAmount = Math.round(item.sum * 100) / 100; // 处理浮点数精度
|
|
209
241
|
if (!uniqueAmounts.has(roundedAmount) && finalResults.length < 10) {
|
|
210
242
|
uniqueAmounts.add(roundedAmount);
|
|
211
243
|
finalResults.push(roundedAmount);
|
|
@@ -213,12 +245,19 @@ function recommendOptimalPayments(targetAmount, denominations) {
|
|
|
213
245
|
}
|
|
214
246
|
return finalResults.sort((a, b) => a - b);
|
|
215
247
|
} catch (error) {
|
|
216
|
-
|
|
248
|
+
// 发生错误时返回安全的默认值
|
|
249
|
+
console.warn('推荐支付金额计算出错:', error);
|
|
250
|
+
// 返回最接近的整数金额作为兜底
|
|
217
251
|
const safeAmount = Math.ceil(targetAmount);
|
|
218
252
|
return [targetAmount, safeAmount];
|
|
219
253
|
}
|
|
220
254
|
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* 尝试找到精确匹配目标金额的组合
|
|
258
|
+
*/
|
|
221
259
|
function findExactCombination(target, denoms, precision) {
|
|
260
|
+
// 简单的深度优先搜索,限制搜索深度
|
|
222
261
|
function dfs(remaining, denomIndex, currentCombination) {
|
|
223
262
|
if (remaining === 0) {
|
|
224
263
|
return currentCombination;
|
|
@@ -227,6 +266,8 @@ function findExactCombination(target, denoms, precision) {
|
|
|
227
266
|
return null;
|
|
228
267
|
}
|
|
229
268
|
const denom = denoms[denomIndex];
|
|
269
|
+
|
|
270
|
+
// 尝试使用当前面额 0 到 maxCount 次
|
|
230
271
|
const maxCount = Math.min(Math.floor(remaining / denom), 8);
|
|
231
272
|
for (let count = maxCount; count >= 0; count--) {
|
|
232
273
|
const newCombination = [...currentCombination, ...Array(count).fill(denom)];
|
|
@@ -241,16 +282,23 @@ function findExactCombination(target, denoms, precision) {
|
|
|
241
282
|
if (exactMatch && exactMatch.length > 0) {
|
|
242
283
|
const denomTypes = new Set(exactMatch).size;
|
|
243
284
|
return {
|
|
244
|
-
combination: exactMatch.map(
|
|
285
|
+
combination: exactMatch.map(d => d / precision),
|
|
245
286
|
sum: target / precision,
|
|
246
287
|
coinCount: exactMatch.length,
|
|
247
|
-
denomTypes
|
|
288
|
+
denomTypes: denomTypes
|
|
248
289
|
};
|
|
249
290
|
}
|
|
250
291
|
return null;
|
|
251
292
|
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* 移除重复和扩展组合
|
|
296
|
+
* 核心原理:如果组合A包含组合B的所有硬币,并且还有额外硬币,则A是B的扩展,应该被移除
|
|
297
|
+
*/
|
|
252
298
|
function removeDuplicateAndExtendedCombinations(combinations, targetAmount) {
|
|
253
299
|
const result = [];
|
|
300
|
+
|
|
301
|
+
// 按币种类型数量、硬币数量、金额排序,确保较简单的组合在前面
|
|
254
302
|
combinations.sort((a, b) => {
|
|
255
303
|
if (a.denomTypes !== b.denomTypes) {
|
|
256
304
|
return a.denomTypes - b.denomTypes;
|
|
@@ -263,18 +311,27 @@ function removeDuplicateAndExtendedCombinations(combinations, targetAmount) {
|
|
|
263
311
|
for (let i = 0; i < combinations.length; i++) {
|
|
264
312
|
const current = combinations[i];
|
|
265
313
|
let shouldSkip = false;
|
|
314
|
+
|
|
315
|
+
// 检查当前组合是否与已添加的组合重复或者是扩展
|
|
266
316
|
for (let j = 0; j < result.length; j++) {
|
|
267
317
|
const existing = result[j];
|
|
318
|
+
|
|
319
|
+
// 如果完全相同,跳过
|
|
268
320
|
if (isSameCombination(current.combination, existing.combination)) {
|
|
269
321
|
shouldSkip = true;
|
|
270
322
|
break;
|
|
271
323
|
}
|
|
324
|
+
|
|
325
|
+
// 如果当前组合是已存在组合的扩展,跳过
|
|
272
326
|
if (isExtensionOf(current.combination, existing.combination)) {
|
|
273
327
|
shouldSkip = true;
|
|
274
328
|
break;
|
|
275
329
|
}
|
|
276
330
|
}
|
|
331
|
+
|
|
332
|
+
// 检查是否有其他组合是当前组合的扩展,如果有,移除那些扩展
|
|
277
333
|
if (!shouldSkip) {
|
|
334
|
+
// 移除所有当前组合的扩展
|
|
278
335
|
for (let j = result.length - 1; j >= 0; j--) {
|
|
279
336
|
if (isExtensionOf(result[j].combination, current.combination)) {
|
|
280
337
|
result.splice(j, 1);
|
|
@@ -285,23 +342,34 @@ function removeDuplicateAndExtendedCombinations(combinations, targetAmount) {
|
|
|
285
342
|
}
|
|
286
343
|
return result;
|
|
287
344
|
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* 检查组合A是否是组合B的扩展(即A包含B的所有硬币,并且还有额外的硬币)
|
|
348
|
+
*/
|
|
288
349
|
function isExtensionOf(combinationA, combinationB) {
|
|
350
|
+
// 如果A的硬币数量少于等于B,A不可能是B的扩展
|
|
289
351
|
if (combinationA.length <= combinationB.length) {
|
|
290
352
|
return false;
|
|
291
353
|
}
|
|
354
|
+
|
|
355
|
+
// 统计每个面额的数量
|
|
292
356
|
const countA = {};
|
|
293
357
|
const countB = {};
|
|
294
|
-
combinationA.forEach(
|
|
358
|
+
combinationA.forEach(coin => {
|
|
295
359
|
countA[coin] = (countA[coin] || 0) + 1;
|
|
296
360
|
});
|
|
297
|
-
combinationB.forEach(
|
|
361
|
+
combinationB.forEach(coin => {
|
|
298
362
|
countB[coin] = (countB[coin] || 0) + 1;
|
|
299
363
|
});
|
|
364
|
+
|
|
365
|
+
// 检查B的所有面额在A中是否都有足够的数量
|
|
300
366
|
for (const coin in countB) {
|
|
301
367
|
if (!countA[coin] || countA[coin] < countB[coin]) {
|
|
302
368
|
return false;
|
|
303
369
|
}
|
|
304
370
|
}
|
|
371
|
+
|
|
372
|
+
// 检查A是否有B没有的额外硬币
|
|
305
373
|
let hasExtra = false;
|
|
306
374
|
for (const coin in countA) {
|
|
307
375
|
if (countA[coin] > (countB[coin] || 0)) {
|
|
@@ -311,18 +379,24 @@ function isExtensionOf(combinationA, combinationB) {
|
|
|
311
379
|
}
|
|
312
380
|
return hasExtra;
|
|
313
381
|
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* 检查两个组合是否本质相同(相同的面额组合)
|
|
385
|
+
*/
|
|
314
386
|
function isSameCombination(combinationA, combinationB) {
|
|
315
387
|
if (combinationA.length !== combinationB.length) {
|
|
316
388
|
return false;
|
|
317
389
|
}
|
|
318
390
|
const countA = {};
|
|
319
391
|
const countB = {};
|
|
320
|
-
combinationA.forEach(
|
|
392
|
+
combinationA.forEach(coin => {
|
|
321
393
|
countA[coin] = (countA[coin] || 0) + 1;
|
|
322
394
|
});
|
|
323
|
-
combinationB.forEach(
|
|
395
|
+
combinationB.forEach(coin => {
|
|
324
396
|
countB[coin] = (countB[coin] || 0) + 1;
|
|
325
397
|
});
|
|
398
|
+
|
|
399
|
+
// 检查两个组合是否有相同的面额和数量
|
|
326
400
|
for (const coin in countA) {
|
|
327
401
|
if (countA[coin] !== (countB[coin] || 0)) {
|
|
328
402
|
return false;
|
|
@@ -334,9 +408,4 @@ function isSameCombination(combinationA, combinationB) {
|
|
|
334
408
|
}
|
|
335
409
|
}
|
|
336
410
|
return true;
|
|
337
|
-
}
|
|
338
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
339
|
-
0 && (module.exports = {
|
|
340
|
-
CURRENCY_DENOMINATIONS,
|
|
341
|
-
recommendOptimalPayments
|
|
342
|
-
});
|
|
411
|
+
}
|
|
@@ -1,51 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(eftpos_exports, {
|
|
22
|
-
EftposPaymentImpl: () => EftposPaymentImpl
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
exports.EftposPaymentImpl = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Eftpos支付实现
|
|
9
|
+
*/
|
|
10
|
+
class EftposPaymentImpl {
|
|
26
11
|
constructor(paymentModule) {
|
|
27
12
|
this.paymentModule = paymentModule;
|
|
28
13
|
}
|
|
29
14
|
async processEftposPayment(amount, orderUuid) {
|
|
30
15
|
const eftposMethod = await this.paymentModule.getEftposPaymentMethod();
|
|
31
16
|
if (!eftposMethod) {
|
|
32
|
-
throw new Error(
|
|
17
|
+
throw new Error('Eftpos支付方式未找到');
|
|
33
18
|
}
|
|
19
|
+
|
|
20
|
+
// 这里应该调用实际的Eftpos组件
|
|
21
|
+
// 假设Eftpos支付成功,创建支付项
|
|
34
22
|
const paymentItem = {
|
|
35
23
|
amount: amount.toString(),
|
|
36
24
|
code: eftposMethod.code,
|
|
37
25
|
custom_payment_id: eftposMethod.id,
|
|
38
26
|
name: eftposMethod.name,
|
|
39
27
|
type: eftposMethod.type,
|
|
40
|
-
voucher_id:
|
|
28
|
+
voucher_id: ''
|
|
41
29
|
};
|
|
42
30
|
await this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
|
|
43
31
|
}
|
|
44
32
|
async checkDeviceStatus() {
|
|
33
|
+
// 检查Eftpos设备状态的逻辑
|
|
45
34
|
return true;
|
|
46
35
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
0 && (module.exports = {
|
|
50
|
-
EftposPaymentImpl
|
|
51
|
-
});
|
|
36
|
+
}
|
|
37
|
+
exports.EftposPaymentImpl = EftposPaymentImpl;
|