多门店聚合收款
public class MoreStorePaymentsAggregations : IRequest
{
public MoreStorePaymentsAggregations(List paymentInfoList)
{
this.PaymentInfoList = paymentInfoList;
}
public List PaymentInfoList { get; }
}
//聚合支付结果
public class GetPaymentResult
{
public GetPaymentResult(decimal amount)
{
this.Amount = amount;
}
public decimal Amount { get; }
}
//收款信息
public class GetPaymentInfo
{
public GetPaymentInfo(decimal amount, string storeId)
{
this.Amount = amount;
this.StoreId = storeId;
}
public decimal Amount { get; }
public string StoreId { get; }
}
Step2:实现聚合多门店收款
public class MoreStorePaymentsAggregationsHandler : IRequestHandler<MoreStorePaymentsAggregations, GetPaymentResult>
{
public Task<GetPaymentResult> Handle(MoreStorePaymentsAggregations request, CancellationToken cancellationToken)
{
decimal totalAmount = 0;
foreach (var info in request.PaymentInfoList)
{
//收款逻辑
totalAmount += info.Amount;
}
return Task.FromResult(new GetPaymentResult(totalAmount));
}
}
具体使用方法:
//使用MediatR发送请求
1、首先,将所有门店的收款款项归并到一个总的资金账号;
2、然后,在收银系统中设置在不同门店的收款,将每笔收款记入相应门店的账款账户;
3、最后,在每日结算时,将每个门店的收款总额转入总的资金账号,完成门店聚合收款。
多门店聚合收款什么意思多门店聚合收款指的是在多个不同的商家门店(例如超市、百货、药店等)使用同一个收款系统,实现统一的结算及支付功能,实现消费者的支付体验一致性。它能够提供给消费者更简单、更方便、更安全的支付方式,简化支付流程,满足消费者不同支付需求,同时可为商家节省大量的结算费用。