@pisell/pisellos 0.0.230 → 0.0.232

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.
Files changed (54) hide show
  1. package/dist/modules/Order/index.d.ts +13 -2
  2. package/dist/modules/Order/index.js +93 -1
  3. package/dist/modules/Order/types.d.ts +45 -0
  4. package/dist/modules/Order/types.js +8 -0
  5. package/dist/modules/Payment/cash.d.ts +8 -0
  6. package/dist/modules/Payment/cash.js +20 -1
  7. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
  8. package/dist/modules/Payment/cashRecommendationAlgorithm.js +423 -0
  9. package/dist/modules/Payment/eftpos.js +1 -1
  10. package/dist/modules/Payment/index.d.ts +34 -124
  11. package/dist/modules/Payment/index.js +662 -1280
  12. package/dist/modules/Payment/mx51.d.ts +0 -0
  13. package/dist/modules/Payment/mx51.js +0 -0
  14. package/dist/modules/Payment/types.d.ts +323 -45
  15. package/dist/modules/Payment/types.js +101 -2
  16. package/dist/modules/Payment/utils.d.ts +17 -0
  17. package/dist/modules/Payment/utils.js +62 -0
  18. package/dist/modules/Payment/walletpass.d.ts +96 -0
  19. package/dist/modules/Payment/walletpass.js +492 -0
  20. package/dist/modules/Schedule/index.d.ts +9 -0
  21. package/dist/modules/Schedule/index.js +60 -0
  22. package/dist/solution/Checkout/index.d.ts +254 -2
  23. package/dist/solution/Checkout/index.js +2472 -320
  24. package/dist/solution/Checkout/types.d.ts +207 -6
  25. package/dist/solution/Checkout/types.js +5 -0
  26. package/lib/modules/Order/index.d.ts +13 -2
  27. package/lib/modules/Order/index.js +65 -1
  28. package/lib/modules/Order/types.d.ts +45 -0
  29. package/lib/modules/Payment/cash.d.ts +8 -0
  30. package/lib/modules/Payment/cash.js +14 -1
  31. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
  32. package/lib/modules/Payment/cashRecommendationAlgorithm.js +342 -0
  33. package/lib/modules/Payment/eftpos.js +1 -1
  34. package/lib/modules/Payment/index.d.ts +34 -124
  35. package/lib/modules/Payment/index.js +232 -533
  36. package/lib/modules/Payment/mx51.d.ts +0 -0
  37. package/lib/modules/Payment/mx51.js +0 -0
  38. package/lib/modules/Payment/types.d.ts +323 -45
  39. package/lib/modules/Payment/types.js +37 -2
  40. package/lib/modules/Payment/utils.d.ts +17 -0
  41. package/lib/modules/Payment/utils.js +67 -0
  42. package/lib/modules/Payment/walletpass.d.ts +96 -0
  43. package/lib/modules/Payment/walletpass.js +304 -0
  44. package/lib/modules/Schedule/index.d.ts +9 -0
  45. package/lib/modules/Schedule/index.js +36 -0
  46. package/lib/solution/Checkout/index.d.ts +254 -2
  47. package/lib/solution/Checkout/index.js +1361 -39
  48. package/lib/solution/Checkout/types.d.ts +207 -6
  49. package/lib/solution/Checkout/types.js +5 -0
  50. package/package.json +1 -1
  51. package/dist/modules/Payment/wallet.d.ts +0 -11
  52. package/dist/modules/Payment/wallet.js +0 -78
  53. package/lib/modules/Payment/wallet.d.ts +0 -11
  54. package/lib/modules/Payment/wallet.js +0 -51
@@ -1,6 +1,6 @@
1
1
  import { Module } from '../../types';
2
2
  import { OrderModule } from '../../modules/Order';
3
- import { PaymentModule, PaymentModuleAPI, PaymentOrder, PaymentMethod, PaymentStatus } from '../../modules/Payment';
3
+ import { PaymentModuleAPI, PaymentOrder, PaymentMethod, PaymentStatus, PaymentItem, PaymentItemInput } from '../../modules/Payment';
4
4
  import { CartItem } from '../../modules/Cart/types';
5
5
  /**
6
6
  * 结账状态枚举
@@ -125,6 +125,7 @@ export interface CreateLocalOrderParams {
125
125
  cartSummary: CartSummaryItem[];
126
126
  /** 是否自动进入支付流程 */
127
127
  autoPayment?: boolean;
128
+ totalInfo: any;
128
129
  }
129
130
  /**
130
131
  * 手动下单参数
@@ -159,6 +160,16 @@ export interface LocalOrderData {
159
160
  relation_products: any[];
160
161
  /** 关联表单 */
161
162
  relation_forms: any[];
163
+ /** 客户ID */
164
+ customer_id?: string;
165
+ /** 客户姓名 */
166
+ customer_name?: string;
167
+ /** 创建时间 (YYYY-MM-DD hh:mm:ss) */
168
+ created_at?: string;
169
+ /** 附加费用 */
170
+ surcharge_fee?: number;
171
+ /** 商店折扣金额 */
172
+ shop_discount?: number;
162
173
  }
163
174
  /**
164
175
  * 本地预订项
@@ -368,16 +379,22 @@ export declare enum CheckoutHooks {
368
379
  /** 结账取消 */
369
380
  OnCheckoutCancelled = "checkout:onCancelled",
370
381
  /** 错误发生 */
371
- OnError = "checkout:onError"
382
+ OnError = "checkout:onError",
383
+ /** 自定义支付金额变更 */
384
+ OnStateAmountChanged = "checkout:onStateAmountChanged",
385
+ /** 订单支付完成(待付款金额 ≤ 0) */
386
+ OnOrderPaymentCompleted = "checkout:onOrderPaymentCompleted",
387
+ /** 订单同步到后端完成 */
388
+ OnOrderSynced = "checkout:onOrderSynced",
389
+ /** 订单备注变更 */
390
+ OnOrderNoteChanged = "checkout:onOrderNoteChanged",
391
+ /** 商店折扣变更 */
392
+ OnShopDiscountChanged = "checkout:onShopDiscountChanged"
372
393
  }
373
394
  /**
374
395
  * 结账状态数据
375
396
  */
376
397
  export interface CheckoutState {
377
- /** 订单模块 */
378
- order: OrderModule;
379
- /** 支付模块 */
380
- payment: PaymentModule;
381
398
  /** 当前状态 */
382
399
  status: CheckoutStatus;
383
400
  /** 当前步骤 */
@@ -388,10 +405,21 @@ export interface CheckoutState {
388
405
  cartItems: CartItem[];
389
406
  /** 本地订单数据 */
390
407
  localOrderData?: LocalOrderData;
408
+ /** 购物车小计数据 */
409
+ cartSummary?: CartSummaryItem[];
391
410
  /** 可用支付方式 */
392
411
  paymentMethods: PaymentMethod[];
393
412
  /** 错误信息 */
394
413
  lastError?: CheckoutError;
414
+ /** UI 自定义支付金额 */
415
+ stateAmount: string;
416
+ /** 订单是否已同步到后端 */
417
+ isOrderSynced: boolean;
418
+ /** 当前客户信息 */
419
+ currentCustomer?: {
420
+ customer_id?: string;
421
+ customer_name?: string;
422
+ };
395
423
  }
396
424
  /**
397
425
  * 当前订单基础信息
@@ -485,6 +513,10 @@ export interface CheckoutModuleAPI extends Module {
485
513
  * 获取当前订单基础信息
486
514
  */
487
515
  getCurrentOrderInfo(): CurrentOrderInfo | null;
516
+ /**
517
+ * 获取当前订单的支付项
518
+ */
519
+ getCurrentOrderPaymentItemsAsync(): Promise<PaymentItem[]>;
488
520
  /**
489
521
  * 验证结账前置条件
490
522
  */
@@ -512,6 +544,137 @@ export interface CheckoutModuleAPI extends Module {
512
544
  * 替换本地订单ID为真实订单ID
513
545
  */
514
546
  replaceLocalOrderIdAsync(newOrderId: string): Promise<PaymentOrder | null>;
547
+ /**
548
+ * 设置自定义支付金额
549
+ */
550
+ setStateAmountAsync(amount: string): Promise<void>;
551
+ /**
552
+ * 获取当前自定义支付金额
553
+ */
554
+ getStateAmount(): string;
555
+ /**
556
+ * 刷新 stateAmount 为当前剩余未支付金额
557
+ */
558
+ refreshStateAmountAsync(): Promise<void>;
559
+ /**
560
+ * 获取购物车小计数据
561
+ */
562
+ getCartSummary(): CartSummaryItem[] | null;
563
+ /**
564
+ * 获取提取的金额详细信息
565
+ */
566
+ getExtractedAmountInfo(): ExtractedAmountInfo | null;
567
+ /**
568
+ * 获取支付方式列表(直接调用 Payment 模块)
569
+ */
570
+ getPaymentMethodsAsync(): Promise<PaymentMethod[]>;
571
+ /**
572
+ * 为当前订单添加支付项
573
+ */
574
+ addPaymentItemAsync(paymentItem: PaymentItemInput): Promise<void>;
575
+ /**
576
+ * 删除当前订单的支付项
577
+ */
578
+ deletePaymentItemAsync(paymentUuid: string): Promise<void>;
579
+ /**
580
+ * 批量更新当前订单的代金券支付项(覆盖更新)
581
+ */
582
+ updateVoucherPaymentItemsAsync(voucherPaymentItems: PaymentItemInput[]): Promise<void>;
583
+ /**
584
+ * 修改当前订单的定金状态
585
+ */
586
+ updateOrderDepositStatusAsync(isDeposit: number): Promise<void>;
587
+ /**
588
+ * 更新当前订单的客户信息
589
+ */
590
+ updateOrderCustomerAsync(customer: {
591
+ customer_id?: string;
592
+ customer_name?: string;
593
+ }): Promise<void>;
594
+ /**
595
+ * 获取当前订单的客户信息
596
+ */
597
+ getCurrentCustomer(): {
598
+ customer_id?: string;
599
+ customer_name?: string;
600
+ } | null;
601
+ /**
602
+ * 手动同步订单到后端
603
+ *
604
+ * 用于强制同步订单到后端,特别适用于纯代金券支付完成的订单
605
+ */
606
+ manualSyncOrderAsync(): Promise<{
607
+ success: boolean;
608
+ message?: string;
609
+ orderId?: string;
610
+ orderUuid?: string;
611
+ }>;
612
+ /**
613
+ * 检查订单是否需要手动同步
614
+ *
615
+ * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
616
+ */
617
+ needsManualSync(): boolean;
618
+ /**
619
+ * 更新订单备注
620
+ *
621
+ * @param note 订单备注内容
622
+ */
623
+ updateOrderNoteAsync(note: string): Promise<void>;
624
+ /**
625
+ * 获取当前订单备注
626
+ *
627
+ * @returns 当前订单的备注内容,如果没有则返回空字符串
628
+ */
629
+ getOrderNote(): string;
630
+ /**
631
+ * 获取当前订单ID
632
+ *
633
+ * @returns 当前订单的ID,如果没有订单则返回null
634
+ */
635
+ getCurrentOrderId(): string | null;
636
+ /**
637
+ * 更新订单商店折扣
638
+ *
639
+ * 同时更新cartSummary和localOrderData中的shop_discount值
640
+ *
641
+ * @param discountAmount 商店折扣金额
642
+ */
643
+ updateShopDiscountAsync(discountAmount: number): Promise<void>;
644
+ /**
645
+ * 获取当前商店折扣金额
646
+ *
647
+ * @returns 当前的商店折扣金额,如果没有则返回0
648
+ */
649
+ getShopDiscount(): number;
650
+ /**
651
+ * 保存订单并稍后支付
652
+ *
653
+ * 将当前订单保存到后端,但排除代金券类支付项(voucher_id),
654
+ * 适用于用户想要保存订单但稍后完成支付的场景
655
+ *
656
+ * @returns 保存结果,包含订单ID和状态
657
+ */
658
+ saveForLaterPaymentAsync(): Promise<{
659
+ success: boolean;
660
+ message?: string;
661
+ orderId?: string;
662
+ orderUuid?: string;
663
+ }>;
664
+ /**
665
+ * 通过订单ID编辑订单备注
666
+ *
667
+ * 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
668
+ *
669
+ * @param orderId 后端订单ID
670
+ * @param note 新的订单备注
671
+ * @returns 修改结果
672
+ */
673
+ editOrderNoteByOrderIdAsync(orderId: string | number, note: string): Promise<{
674
+ success: boolean;
675
+ message?: string;
676
+ orderId?: string | number;
677
+ }>;
515
678
  }
516
679
  /**
517
680
  * 结账事件数据类型
@@ -547,4 +710,42 @@ export interface CheckoutEventData {
547
710
  context?: any;
548
711
  timestamp: number;
549
712
  };
713
+ /** 自定义支付金额变更事件 */
714
+ stateAmountChanged: {
715
+ oldAmount: string;
716
+ newAmount: string;
717
+ timestamp: number;
718
+ };
719
+ /** 订单支付完成事件 */
720
+ orderPaymentCompleted: {
721
+ orderUuid: string;
722
+ orderId: string;
723
+ totalAmount: string;
724
+ paidAmount: string;
725
+ remainingAmount: string;
726
+ timestamp: number;
727
+ };
728
+ /** 订单同步到后端完成事件 */
729
+ orderSynced: {
730
+ orderUuid: string;
731
+ realOrderId: string;
732
+ virtualOrderId: string;
733
+ timestamp: number;
734
+ /** 是否为手动同步 */
735
+ isManual?: boolean;
736
+ };
737
+ /** 订单备注变更事件 */
738
+ orderNoteChanged: {
739
+ orderUuid?: string;
740
+ oldNote: string;
741
+ newNote: string;
742
+ timestamp: number;
743
+ };
744
+ /** 商店折扣变更事件 */
745
+ shopDiscountChanged: {
746
+ orderUuid?: string;
747
+ oldDiscount: number;
748
+ newDiscount: number;
749
+ timestamp: number;
750
+ };
550
751
  }
@@ -112,6 +112,11 @@ export var CheckoutHooks = /*#__PURE__*/function (CheckoutHooks) {
112
112
  CheckoutHooks["OnCheckoutCompleted"] = "checkout:onCompleted";
113
113
  CheckoutHooks["OnCheckoutCancelled"] = "checkout:onCancelled";
114
114
  CheckoutHooks["OnError"] = "checkout:onError";
115
+ CheckoutHooks["OnStateAmountChanged"] = "checkout:onStateAmountChanged";
116
+ CheckoutHooks["OnOrderPaymentCompleted"] = "checkout:onOrderPaymentCompleted";
117
+ CheckoutHooks["OnOrderSynced"] = "checkout:onOrderSynced";
118
+ CheckoutHooks["OnOrderNoteChanged"] = "checkout:onOrderNoteChanged";
119
+ CheckoutHooks["OnShopDiscountChanged"] = "checkout:onShopDiscountChanged";
115
120
  return CheckoutHooks;
116
121
  }({});
117
122
 
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { OrderModuleAPI, CommitOrderParams } from './types';
3
+ import { OrderModuleAPI, CommitOrderParams, CheckoutOrderParams } from './types';
4
4
  import { CartItem } from '../Cart/types';
5
5
  export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
6
6
  protected defaultName: string;
@@ -11,7 +11,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
11
11
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
12
12
  createOrder(params: CommitOrderParams['query']): {
13
13
  type: "virtual" | "appointment_booking";
14
- platform: string;
14
+ platform: "pc" | "h5";
15
15
  sales_channel: string;
16
16
  order_sales_channel: string;
17
17
  bookings: any[];
@@ -26,4 +26,15 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
26
26
  type: 'holder' | 'account';
27
27
  }): boolean;
28
28
  submitOrder(order: CommitOrderParams): Promise<void>;
29
+ /**
30
+ * Checkout 专用:创建订单到后端
31
+ *
32
+ * 专门为 Checkout 模块设计的订单创建方法,
33
+ * 直接调用 /order/checkout 接口创建订单
34
+ * 接收已经处理好的订单数据,无需再处理购物车
35
+ *
36
+ * @param params Checkout 订单参数(已处理的订单数据)
37
+ * @returns 后端返回的订单数据(包含订单ID等)
38
+ */
39
+ createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
29
40
  }
@@ -41,7 +41,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
41
41
  const order = {
42
42
  type: (params == null ? void 0 : params.type) || "appointment_booking",
43
43
  // 要从外面拿,virtual
44
- platform: (params == null ? void 0 : params.platform) === "pc" ? "PC" : "H5",
44
+ platform: (params == null ? void 0 : params.platform) || "pc",
45
45
  sales_channel: "my_pisel",
46
46
  order_sales_channel: "online_store",
47
47
  bookings: [],
@@ -101,6 +101,70 @@ var OrderModule = class extends import_BaseModule.BaseModule {
101
101
  const params = this.createOrder(query);
102
102
  return this.request.post(fetchUrl, params);
103
103
  }
104
+ /**
105
+ * Checkout 专用:创建订单到后端
106
+ *
107
+ * 专门为 Checkout 模块设计的订单创建方法,
108
+ * 直接调用 /order/checkout 接口创建订单
109
+ * 接收已经处理好的订单数据,无需再处理购物车
110
+ *
111
+ * @param params Checkout 订单参数(已处理的订单数据)
112
+ * @returns 后端返回的订单数据(包含订单ID等)
113
+ */
114
+ async createOrderByCheckout(params) {
115
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
116
+ console.log("[Order] createOrderByCheckout 开始创建订单:", {
117
+ type: params.type,
118
+ platform: params.platform,
119
+ is_deposit: params.is_deposit,
120
+ customer_id: params.customer_id,
121
+ bookingsCount: ((_a = params.bookings) == null ? void 0 : _a.length) || 0,
122
+ relationProductsCount: ((_b = params.relation_products) == null ? void 0 : _b.length) || 0,
123
+ paymentsCount: ((_c = params.payments) == null ? void 0 : _c.length) || 0
124
+ });
125
+ try {
126
+ const orderData = {
127
+ sales_channel: "my_pisel",
128
+ order_sales_channel: "online_store",
129
+ shop_note: "",
130
+ schedule_date: "",
131
+ is_deposit: 0,
132
+ bookings: [],
133
+ relation_products: [],
134
+ relation_forms: [],
135
+ payments: [],
136
+ ...params
137
+ // 使用传入的参数覆盖默认值
138
+ };
139
+ if ((_d = orderData.payments) == null ? void 0 : _d.length) {
140
+ orderData.small_ticket_data_flag = 1;
141
+ }
142
+ if (params.order_id) {
143
+ orderData.bookings = [];
144
+ orderData.relation_products = [];
145
+ }
146
+ console.log("[Order] 调用后端接口创建订单:", {
147
+ url: "/order/checkout",
148
+ orderType: orderData.type,
149
+ platform: orderData.platform,
150
+ isDeposit: orderData.is_deposit,
151
+ customerId: orderData.customer_id,
152
+ bookingsCount: ((_e = orderData.bookings) == null ? void 0 : _e.length) || 0,
153
+ relationProductsCount: ((_f = orderData.relation_products) == null ? void 0 : _f.length) || 0,
154
+ paymentsCount: ((_g = orderData.payments) == null ? void 0 : _g.length) || 0,
155
+ paymentsMethods: ((_h = orderData.payments) == null ? void 0 : _h.map((p) => p.code)) || []
156
+ });
157
+ const response = await this.request.post("/order/checkout", orderData);
158
+ console.log("[Order] 订单创建成功,后端响应:", {
159
+ success: !!response,
160
+ hasOrderId: !!(((_i = response == null ? void 0 : response.data) == null ? void 0 : _i.order_id) || (response == null ? void 0 : response.order_id))
161
+ });
162
+ return response;
163
+ } catch (error) {
164
+ console.error("[Order] createOrderByCheckout 创建订单失败:", error);
165
+ throw error;
166
+ }
167
+ }
104
168
  };
105
169
  // Annotate the CommonJS export names for ESM import in node:
106
170
  0 && (module.exports = {
@@ -18,6 +18,45 @@ export interface CommitOrderParams {
18
18
  platform?: 'pc' | 'h5';
19
19
  };
20
20
  }
21
+ /**
22
+ * 支付项数据
23
+ */
24
+ export interface PaymentItemData {
25
+ /** 当前支付项的唯一 ID */
26
+ uuid: string;
27
+ /** 当前支付方式付出去多少钱 */
28
+ amount: string;
29
+ /** 支付类型代码 */
30
+ code: string;
31
+ /** 支付类型id */
32
+ id: number;
33
+ /** 支付类型名称 */
34
+ name: string;
35
+ /** 支付类型 */
36
+ type: string;
37
+ /** 是否已同步到后端 */
38
+ isSynced?: boolean;
39
+ }
40
+ /**
41
+ * Checkout 专用订单创建参数
42
+ */
43
+ export interface CheckoutOrderParams {
44
+ type: 'virtual' | 'appointment_booking';
45
+ platform: 'PC' | 'H5';
46
+ sales_channel?: string;
47
+ order_sales_channel?: string;
48
+ bookings?: any[];
49
+ shop_note?: string;
50
+ schedule_date?: string;
51
+ is_deposit?: number;
52
+ relation_products?: any[];
53
+ relation_forms?: any[];
54
+ payments?: PaymentItemData[];
55
+ customer_id?: string;
56
+ /** 小票数据标记,当有支付项时设置为1 */
57
+ small_ticket_data_flag?: number;
58
+ [key: string]: any;
59
+ }
21
60
  /**
22
61
  * 订单模块 API
23
62
  */
@@ -40,4 +79,10 @@ export interface OrderModuleAPI {
40
79
  * @param params 订单信息
41
80
  */
42
81
  submitOrder: (params: CommitOrderParams) => Promise<void>;
82
+ /**
83
+ * Checkout 专用:创建订单到后端
84
+ * @param params 订单参数
85
+ * @returns 后端返回的订单数据
86
+ */
87
+ createOrderByCheckout: (params: CheckoutOrderParams) => Promise<any>;
43
88
  }
@@ -8,4 +8,12 @@ export declare class CashPaymentImpl implements CashPayment {
8
8
  constructor(paymentModule: PaymentModule);
9
9
  processCashPayment(amount: number, orderUuid: string): Promise<void>;
10
10
  getCashBalance(): Promise<number>;
11
+ /**
12
+ * 获取推荐支付金额
13
+ * 基于目标金额和货币类型,返回最优支付金额建议
14
+ * @param money 目标支付金额
15
+ * @param currency 货币代码 (如: 'CNY', 'USD', 'EUR' 等)
16
+ * @returns 推荐支付金额数组
17
+ */
18
+ getRecommendedAmount(money: number, currency: string): number[];
11
19
  }
@@ -22,6 +22,7 @@ __export(cash_exports, {
22
22
  CashPaymentImpl: () => CashPaymentImpl
23
23
  });
24
24
  module.exports = __toCommonJS(cash_exports);
25
+ var import_cashRecommendationAlgorithm = require("./cashRecommendationAlgorithm");
25
26
  var CashPaymentImpl = class {
26
27
  constructor(paymentModule) {
27
28
  this.paymentModule = paymentModule;
@@ -39,11 +40,23 @@ var CashPaymentImpl = class {
39
40
  type: cashMethod.type,
40
41
  voucher_id: ""
41
42
  };
42
- await this.paymentModule.pushPaymentAsync(orderUuid, paymentItem);
43
+ await this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
43
44
  }
44
45
  async getCashBalance() {
45
46
  return 0;
46
47
  }
48
+ /**
49
+ * 获取推荐支付金额
50
+ * 基于目标金额和货币类型,返回最优支付金额建议
51
+ * @param money 目标支付金额
52
+ * @param currency 货币代码 (如: 'CNY', 'USD', 'EUR' 等)
53
+ * @returns 推荐支付金额数组
54
+ */
55
+ getRecommendedAmount(money, currency) {
56
+ const upperCurrency = currency.toUpperCase();
57
+ const denominations = import_cashRecommendationAlgorithm.CURRENCY_DENOMINATIONS[upperCurrency] || import_cashRecommendationAlgorithm.CURRENCY_DENOMINATIONS["DEFAULT"];
58
+ return (0, import_cashRecommendationAlgorithm.recommendOptimalPayments)(money, denominations);
59
+ }
47
60
  };
48
61
  // Annotate the CommonJS export names for ESM import in node:
49
62
  0 && (module.exports = {
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 现金支付推荐算法
3
+ *
4
+ * 核心原理:
5
+ * 1. 每个推荐金额都应该是独立的最优组合
6
+ * 2. 不推荐在已有最优解基础上添加额外面额的组合
7
+ * 3. 优先推荐使用不同数量币种的组合
8
+ * 4. 根据组合判断去重,避免扩展组合
9
+ */
10
+ /**
11
+ * 常见国家货币面额配置
12
+ */
13
+ export declare const CURRENCY_DENOMINATIONS: Record<string, number[]>;
14
+ /**
15
+ * 最优支付金额推荐算法
16
+ * 推荐通过不同数量面额组合刚好足够支付的最小金额
17
+ *
18
+ * @param targetAmount 目标金额
19
+ * @param denominations 币种面值数组
20
+ * @returns 推荐支付金额数组
21
+ */
22
+ export declare function recommendOptimalPayments(targetAmount: number, denominations: number[]): number[];