银行卡支付在确认后才算报名成功
This commit is contained in:
parent
1e0f75ed3a
commit
4259236415
@ -314,6 +314,49 @@ public class UnifiedPaymentOutput
|
|||||||
public string? TradeType { get; set; }
|
public string? TradeType { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 确认银行转账输入DTO
|
||||||
|
/// </summary>
|
||||||
|
public class ConfirmBankTransferInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 报名ID
|
||||||
|
/// </summary>
|
||||||
|
[Required(ErrorMessage = "报名ID不能为空")]
|
||||||
|
public long RegistrationId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支付凭证URL (可选)
|
||||||
|
/// </summary>
|
||||||
|
public string? PaymentProofUrl { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 确认银行转账输出DTO
|
||||||
|
/// </summary>
|
||||||
|
public class ConfirmBankTransferOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 报名ID
|
||||||
|
/// </summary>
|
||||||
|
public long RegistrationId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支付状态
|
||||||
|
/// </summary>
|
||||||
|
public int PaymentStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否成功
|
||||||
|
/// </summary>
|
||||||
|
public bool Success { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 消息
|
||||||
|
/// </summary>
|
||||||
|
public string? Message { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 报名验证结果DTO
|
/// 报名验证结果DTO
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1103,6 +1103,29 @@ public class UnifiedRegistrationService : ITransient
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task<UnifiedPaymentOutput> HandleOfflinePaymentAsync(EventRegistration registration, UnifiedPaymentInput input)
|
private async Task<UnifiedPaymentOutput> HandleOfflinePaymentAsync(EventRegistration registration, UnifiedPaymentInput input)
|
||||||
{
|
{
|
||||||
|
// 如果是银行转账,先不设置支付状态,等用户确认转账后再处理
|
||||||
|
if (input.PaymentMethodType == PaymentMethodType.BankTransfer)
|
||||||
|
{
|
||||||
|
registration.PaymentProofUrl = input.PaymentProofUrl;
|
||||||
|
// 保持支付状态为未支付,等用户确认转账后再更新
|
||||||
|
registration.PaymentStatus = 4; // 临时状态:待确认转账
|
||||||
|
registration.UpdatedTime = DateTime.Now;
|
||||||
|
registration.UpdatedUserId = input.OperatorUserId;
|
||||||
|
await _registrationRepository.UpdateAsync(registration);
|
||||||
|
|
||||||
|
_logger.LogInformation("银行转账方式,等待用户确认,报名ID:{RegistrationId},凭证URL:{ProofUrl}",
|
||||||
|
registration.Id, input.PaymentProofUrl);
|
||||||
|
|
||||||
|
return new UnifiedPaymentOutput
|
||||||
|
{
|
||||||
|
RegistrationId = registration.Id,
|
||||||
|
OrderNo = registration.OrderNo,
|
||||||
|
PaymentStatus = 4, // 待确认转账
|
||||||
|
IsFree = false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 其他线下支付方式,保持原有逻辑
|
||||||
registration.PaymentProofUrl = input.PaymentProofUrl;
|
registration.PaymentProofUrl = input.PaymentProofUrl;
|
||||||
registration.PaymentStatus = 0; // 待审核
|
registration.PaymentStatus = 0; // 待审核
|
||||||
registration.UpdatedTime = DateTime.Now;
|
registration.UpdatedTime = DateTime.Now;
|
||||||
@ -1121,6 +1144,58 @@ public class UnifiedRegistrationService : ITransient
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 确认银行转账
|
||||||
|
/// </summary>
|
||||||
|
public async Task<ConfirmBankTransferOutput> ConfirmBankTransferAsync(ConfirmBankTransferInput input, long operatorUserId)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("开始确认银行转账,报名ID:{RegistrationId}", input.RegistrationId);
|
||||||
|
|
||||||
|
var registration = await _registrationRepository.GetByIdAsync(input.RegistrationId);
|
||||||
|
if (registration == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("未找到报名记录,报名ID:{RegistrationId}", input.RegistrationId);
|
||||||
|
return new ConfirmBankTransferOutput
|
||||||
|
{
|
||||||
|
RegistrationId = input.RegistrationId,
|
||||||
|
PaymentStatus = -1,
|
||||||
|
Success = false,
|
||||||
|
Message = "报名记录不存在"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否为银行转账方式
|
||||||
|
if (registration.PaymentMethodType != PaymentMethodType.BankTransfer)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("该报名不是银行转账方式,报名ID:{RegistrationId},支付方式:{PaymentMethodType}",
|
||||||
|
input.RegistrationId, registration.PaymentMethodType);
|
||||||
|
return new ConfirmBankTransferOutput
|
||||||
|
{
|
||||||
|
RegistrationId = input.RegistrationId,
|
||||||
|
PaymentStatus = registration.PaymentStatus,
|
||||||
|
Success = false,
|
||||||
|
Message = "该报名不是银行转账方式"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新报名记录状态为待审核
|
||||||
|
registration.PaymentProofUrl = input.PaymentProofUrl ?? registration.PaymentProofUrl;
|
||||||
|
registration.PaymentStatus = 0; // 待审核
|
||||||
|
registration.UpdatedTime = DateTime.Now;
|
||||||
|
registration.UpdatedUserId = operatorUserId;
|
||||||
|
await _registrationRepository.UpdateAsync(registration);
|
||||||
|
|
||||||
|
_logger.LogInformation("银行转账确认成功,报名ID:{RegistrationId},状态已更新为待审核", input.RegistrationId);
|
||||||
|
|
||||||
|
return new ConfirmBankTransferOutput
|
||||||
|
{
|
||||||
|
RegistrationId = input.RegistrationId,
|
||||||
|
PaymentStatus = 0,
|
||||||
|
Success = true,
|
||||||
|
Message = "转账确认成功,订单已提交审核"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查报名限制
|
/// 检查报名限制
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -1142,14 +1217,26 @@ public class UnifiedRegistrationService : ITransient
|
|||||||
|
|
||||||
// 先获取所有报名信息,供后续检查使用
|
// 先获取所有报名信息,供后续检查使用
|
||||||
// 线上支付类型的报名记录,仅统计PaymentStatus == 1(已支付)的记录
|
// 线上支付类型的报名记录,仅统计PaymentStatus == 1(已支付)的记录
|
||||||
// 线下支付类型的报名记录,同时统计PaymentStatus == 1(已支付)和PaymentStatus == 0(未支付)的记录
|
// 线下支付类型的报名记录:
|
||||||
|
// - 银行转账方式:仅统计PaymentStatus == 1(已支付)和PaymentStatus == 0(待审核)的记录,
|
||||||
|
// 不统计PaymentStatus == 4(待确认转账)的记录
|
||||||
|
// - 其他线下方式:统计PaymentStatus == 1(已支付)和PaymentStatus == 0(待审核)的记录
|
||||||
var eventRegistrationsQuery = _registrationRepository.AsQueryable().Where(x =>
|
var eventRegistrationsQuery = _registrationRepository.AsQueryable().Where(x =>
|
||||||
x.EventId == input.EventId && !x.DeleteMark &&
|
x.EventId == input.EventId && !x.DeleteMark &&
|
||||||
(
|
(
|
||||||
|
// 线上支付:仅已支付
|
||||||
(x.PaymentMethod == 2 && x.PaymentStatus == 1) ||
|
(x.PaymentMethod == 2 && x.PaymentStatus == 1) ||
|
||||||
(x.PaymentMethod == 1 && x.PaymentStatus == 1) ||
|
// 线下支付:
|
||||||
(x.PaymentMethod == 1 && x.PaymentStatus == 0)
|
(x.PaymentMethod == 1 && (
|
||||||
));
|
// 已支付的都统计
|
||||||
|
x.PaymentStatus == 1 ||
|
||||||
|
// 待审核的,且不是银行转账方式中待确认转账状态的
|
||||||
|
(x.PaymentStatus == 0 && !(x.PaymentMethodType == PaymentMethodType.BankTransfer && x.PaymentStatus == 4))
|
||||||
|
))
|
||||||
|
) &&
|
||||||
|
// 排除银行转账方式中待确认转账状态的记录
|
||||||
|
!(x.PaymentMethodType == PaymentMethodType.BankTransfer && x.PaymentStatus == 4)
|
||||||
|
);
|
||||||
|
|
||||||
// 如果指定了要排除的报名ID,则排除该记录
|
// 如果指定了要排除的报名ID,则排除该记录
|
||||||
if (excludeRegistrationId.HasValue)
|
if (excludeRegistrationId.HasValue)
|
||||||
|
|||||||
@ -751,6 +751,24 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 确认银行转账
|
||||||
|
/// </summary>
|
||||||
|
[DisplayName("确认银行转账")]
|
||||||
|
[HttpPost("bank-transfer/confirm")]
|
||||||
|
[UnitOfWork]
|
||||||
|
public async Task<ConfirmBankTransferOutput> ConfirmBankTransfer([FromBody] ConfirmBankTransferInput input)
|
||||||
|
{
|
||||||
|
var userId = _authManager.UserId;
|
||||||
|
|
||||||
|
_logger.LogInformation("用户确认银行转账,报名ID:{RegistrationId},用户ID:{UserId}", input.RegistrationId, userId);
|
||||||
|
|
||||||
|
// 调用统一报名服务处理确认转账
|
||||||
|
var result = await _unifiedRegistrationService.ConfirmBankTransferAsync(input, userId);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 微信支付回调
|
/// 微信支付回调
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -6983,6 +6983,46 @@
|
|||||||
交易类型
|
交易类型
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:YD_Event.Application.Event.Dtos.ConfirmBankTransferInput">
|
||||||
|
<summary>
|
||||||
|
确认银行转账输入DTO
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:YD_Event.Application.Event.Dtos.ConfirmBankTransferInput.RegistrationId">
|
||||||
|
<summary>
|
||||||
|
报名ID
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:YD_Event.Application.Event.Dtos.ConfirmBankTransferInput.PaymentProofUrl">
|
||||||
|
<summary>
|
||||||
|
支付凭证URL (可选)
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="T:YD_Event.Application.Event.Dtos.ConfirmBankTransferOutput">
|
||||||
|
<summary>
|
||||||
|
确认银行转账输出DTO
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:YD_Event.Application.Event.Dtos.ConfirmBankTransferOutput.RegistrationId">
|
||||||
|
<summary>
|
||||||
|
报名ID
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:YD_Event.Application.Event.Dtos.ConfirmBankTransferOutput.PaymentStatus">
|
||||||
|
<summary>
|
||||||
|
支付状态
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:YD_Event.Application.Event.Dtos.ConfirmBankTransferOutput.Success">
|
||||||
|
<summary>
|
||||||
|
是否成功
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:YD_Event.Application.Event.Dtos.ConfirmBankTransferOutput.Message">
|
||||||
|
<summary>
|
||||||
|
消息
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:YD_Event.Application.Event.Dtos.RegistrationValidationResult">
|
<member name="T:YD_Event.Application.Event.Dtos.RegistrationValidationResult">
|
||||||
<summary>
|
<summary>
|
||||||
报名验证结果DTO
|
报名验证结果DTO
|
||||||
@ -8855,6 +8895,11 @@
|
|||||||
处理线下支付
|
处理线下支付
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:YD_Event.Application.Event.UnifiedRegistrationService.ConfirmBankTransferAsync(YD_Event.Application.Event.Dtos.ConfirmBankTransferInput,System.Int64)">
|
||||||
|
<summary>
|
||||||
|
确认银行转账
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="M:YD_Event.Application.Event.UnifiedRegistrationService.CheckRegistrationLimitAsync(YD_Event.Application.Event.Dtos.UnifiedRegistrationInput,System.Nullable{System.Int64})">
|
<member name="M:YD_Event.Application.Event.UnifiedRegistrationService.CheckRegistrationLimitAsync(YD_Event.Application.Event.Dtos.UnifiedRegistrationInput,System.Nullable{System.Int64})">
|
||||||
<summary>
|
<summary>
|
||||||
检查报名限制
|
检查报名限制
|
||||||
@ -9193,6 +9238,11 @@
|
|||||||
创建支付订单
|
创建支付订单
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:YD_Event.Application.Event.UserEventRegistrationService.ConfirmBankTransfer(YD_Event.Application.Event.Dtos.ConfirmBankTransferInput)">
|
||||||
|
<summary>
|
||||||
|
确认银行转账
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="M:YD_Event.Application.Event.UserEventRegistrationService.WechatPayNotify">
|
<member name="M:YD_Event.Application.Event.UserEventRegistrationService.WechatPayNotify">
|
||||||
<summary>
|
<summary>
|
||||||
微信支付回调
|
微信支付回调
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user