@pisell/pisellos
Version:
一个可扩展的前端模块化SDK框架,支持插件系统
65 lines (63 loc) • 2.42 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/modules/Payment/cash.ts
var cash_exports = {};
__export(cash_exports, {
CashPaymentImpl: () => CashPaymentImpl
});
module.exports = __toCommonJS(cash_exports);
var import_cashRecommendationAlgorithm = require("./cashRecommendationAlgorithm");
var CashPaymentImpl = class {
constructor(paymentModule) {
this.paymentModule = paymentModule;
}
async processCashPayment(amount, orderUuid) {
const cashMethod = await this.paymentModule.getCashPaymentMethod();
if (!cashMethod) {
throw new Error("现金支付方式未找到");
}
const paymentItem = {
amount: amount.toString(),
code: cashMethod.code,
custom_payment_id: cashMethod.id,
name: cashMethod.name,
type: cashMethod.type,
voucher_id: ""
};
await this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
}
async getCashBalance() {
return 0;
}
/**
* 获取推荐支付金额
* 基于目标金额和货币类型,返回最优支付金额建议
* @param money 目标支付金额
* @param currency 货币代码 (如: 'CNY', 'USD', 'EUR' 等)
* @returns 推荐支付金额数组
*/
getRecommendedAmount(money, currency) {
const upperCurrency = currency.toUpperCase();
const denominations = import_cashRecommendationAlgorithm.CURRENCY_DENOMINATIONS[upperCurrency] || import_cashRecommendationAlgorithm.CURRENCY_DENOMINATIONS["DEFAULT"];
return (0, import_cashRecommendationAlgorithm.recommendOptimalPayments)(money, denominations);
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
CashPaymentImpl
});