Files
HIS-GUI/include/core/payment_management_service.h
2026-04-06 16:23:17 +08:00

142 lines
4.2 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef PAYMENT_MANAGEMENT_SERVICE_H
#define PAYMENT_MANAGEMENT_SERVICE_H
#include <functional>
#include <string>
#include <vector>
#include "core/his_context.h"
#include "models/payment.h"
#include "models/settlement.h"
namespace core {
// 支付统计信息
struct PaymentStatistics {
double TotalRevenue; // 总收入
double CompletedAmount; // 已完成支付金额
double PendingAmount; // 待支付金额
double RefundedAmount; // 已退款金额
int TotalPayments; // 总支付数
int CompletedPayments; // 已完成支付数
int PendingPayments; // 待支付数
int RefundedPayments; // 已退款数
};
// 支付方式统计
struct PaymentMethodStatistics {
std::string Method; // 支付方式
int Count; // 数量
double Amount; // 金额
};
/**
* 支付管理服务
* 供管理员查看和管理所有的支付记录及结算信息
*/
class PaymentManagementService {
public:
explicit PaymentManagementService(HisContext& ctx);
// ========== 支付管理 ==========
// 获取所有支付记录
void getAllPayments(
const std::function<void(const Payment&)>& visitor) const;
// 按状态过滤支付记录
void getPaymentsByStatus(
const std::string& status,
const std::function<void(const Payment&)>& visitor) const;
// 获取日期范围内的支付记录
void getPaymentsByDateRange(
time_t startTime,
time_t endTime,
const std::function<void(const Payment&)>& visitor) const;
// 按支付方式统计
std::vector<PaymentMethodStatistics> getPaymentMethodStatistics() const;
// ========== 支付统计 ==========
// 获取支付统计信息
PaymentStatistics getPaymentStatistics() const;
// 获取今日支付统计
PaymentStatistics getTodayPaymentStatistics() const;
// 获取本月支付统计
PaymentStatistics getMonthlyPaymentStatistics() const;
// ========== 结算管理 ==========
// 获取所有结算单
void getAllSettlements(
const std::function<void(const Settlement&)>& visitor) const;
// 按状态过滤结算单
void getSettlementsByStatus(
const std::string& status,
const std::function<void(const Settlement&)>& visitor) const;
// 获取某个病人的所有已支付结算记录
void getSettlementsByPatientId(
const std::string& patientId,
const std::function<void(const Settlement&)>& visitor) const;
// 获取所有已支付的结算记录(按病人分类)
void getSettlementsByPatients(
const std::function<void(const std::string&, const Settlement&)>& visitor) const;
// 搜索病人的结算记录支持ID、姓名、手机号模糊匹配
void searchSettlementsByPatientInfo(
const std::string& keyword,
const std::function<void(const Settlement&)>& visitor) const;
// ========== 报表生成 ==========
// 生成日报表
std::string generateDailyReport(const std::string& date);
// 生成月报表
std::string generateMonthlyReport(const std::string& month);
// 生成收入报表
std::string generateRevenueReport();
// 获取最近N天的每日收入数据
std::vector<std::pair<std::string, double>> getDailyRevenueData(int days = 7) const;
// 获取最近N个月的每月收入数据
std::vector<std::pair<std::string, double>> getMonthlyRevenueData(int months = 6) const;
// 获取收入分类数据(按支付类型)
std::vector<std::pair<std::string, double>> getRevenueByType() const;
// 生成患者账单
std::string generatePatientBill(const std::string& patientId);
// ========== 异常处理 ==========
// 获取异常支付记录
void getAnomalousPayments(
const std::function<void(const Payment&)>& visitor) const;
// 处理退款申请
bool processRefund(const std::string& paymentId, const std::string& reason);
private:
HisContext& ctx_;
// 检查时间是否在同一天
bool isSameDay(time_t t1, time_t t2) const;
// 检查时间是否在同一月
bool isSameMonth(time_t t1, time_t t2) const;
};
} // namespace core
#endif