75 lines
2.2 KiB
C++
75 lines
2.2 KiB
C++
#ifndef PAYMENT_SERVICE_H
|
|
#define PAYMENT_SERVICE_H
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
#include "core/his_context.h"
|
|
#include "models/payment.h"
|
|
|
|
namespace core {
|
|
|
|
/**
|
|
* 支付服务
|
|
* 负责处理所有支付相关的操作,包括创建支付记录、查询支付、更新支付状态等
|
|
*/
|
|
class PaymentService {
|
|
public:
|
|
explicit PaymentService(HisContext& ctx);
|
|
|
|
// 创建支付记录
|
|
bool createPayment(const std::string& patientID,
|
|
double amount,
|
|
PaymentMethod method,
|
|
const std::string& paymentType,
|
|
const std::string& operationID,
|
|
const std::string& description,
|
|
std::string& outPaymentID);
|
|
|
|
// 查询支付记录
|
|
size_t paymentCount() const;
|
|
const Payment* findPayment(const std::string& paymentId) const;
|
|
Payment* findPayment(const std::string& paymentId);
|
|
|
|
// 按患者ID查询支付记录
|
|
void findByPatientId(
|
|
const std::string& patientId,
|
|
const std::function<void(const std::string&, const Payment&)>& visitor) const;
|
|
|
|
// 按支付类型查询
|
|
void findByPaymentType(
|
|
const std::string& paymentType,
|
|
const std::function<void(const std::string&, const Payment&)>& visitor) const;
|
|
|
|
// 遍历所有支付记录
|
|
void for_eachPayment(
|
|
const std::function<void(const std::string&, const Payment&)>& visitor) const;
|
|
|
|
// 更新支付状态
|
|
bool updatePaymentStatus(const std::string& paymentId, const std::string& newStatus);
|
|
|
|
// 完成支付
|
|
bool completePayment(const std::string& paymentId);
|
|
|
|
// 退款
|
|
bool refundPayment(const std::string& paymentId);
|
|
|
|
// 获取患者的总支付金额
|
|
double getTotalPaymentAmount(const std::string& patientId) const;
|
|
|
|
// 获取患者特定类型的支付记录列表
|
|
void getPaymentsByType(const std::string& patientId,
|
|
const std::string& paymentType,
|
|
const std::function<void(const Payment&)>& visitor) const;
|
|
|
|
// 删除支付记录(一般用于测试或数据清理)
|
|
bool removePayment(const std::string& paymentId);
|
|
|
|
private:
|
|
HisContext& ctx_;
|
|
};
|
|
|
|
} // namespace core
|
|
|
|
#endif
|