This commit is contained in:
zpc 2025-09-27 13:23:58 +08:00
parent 28753d80bf
commit 6811251e22

View File

@ -1,7 +1,9 @@
using CoreCms.Net.Caching.AutoMate.RedisCache;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
@ -36,7 +38,7 @@ public class SQReservationRefundJob
Console.WriteLine($"[SQReservationRefundJob] 执行开始 @ {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
// 扫描需要退款的参与者is_refund=3发起退款、未退出(status=0)、有有效支付单号
var needRefundList = await _participantsServices.QueryListByClauseAsync(
p => p.is_refund == 3 && p.paymentId != null && p.paymentId != "",
p => p.is_refund == 3 && p.paymentId != null && p.paymentId != "",
p => p.id, OrderByType.Asc);
if (needRefundList == null || needRefundList.Count == 0)
@ -63,7 +65,7 @@ public class SQReservationRefundJob
var payInfoRes = await _billPaymentsServices.GetInfo(participant.paymentId, participant.user_id);
if (payInfoRes.status == false || payInfoRes.data is not CoreCmsBillPayments payInfo)
{
await _participantsServices.UpdateAsync(it => new SQReservationParticipants { is_refund = 9 }, it => it.id == participant.id);
await _participantsServices.UpdateAsync(it => new SQReservationParticipants { is_refund = 9, remarks = $"获取支付单失败" }, it => it.id == participant.id);
continue;
}
@ -79,7 +81,7 @@ public class SQReservationRefundJob
var addRefundRes = await _billRefundServices.ToAdd(participant.user_id, payInfo.sourceId, payInfo.type, refundMoney, "");
if (addRefundRes.status == false)
{
await _participantsServices.UpdateAsync(it => new SQReservationParticipants { is_refund = 9 }, it => it.id == participant.id);
await _participantsServices.UpdateAsync(it => new SQReservationParticipants { is_refund = 9, remarks = $"创建退款单失败" }, it => it.id == participant.id);
continue;
}
@ -88,7 +90,7 @@ public class SQReservationRefundJob
p.userId == participant.user_id && p.sourceId == payInfo.sourceId && p.type == payInfo.type && p.money == refundMoney && p.status == 1);
if (refundInfo == null)
{
await _participantsServices.UpdateAsync(it => new SQReservationParticipants { is_refund = 9 }, it => it.id == participant.id);
await _participantsServices.UpdateAsync(it => new SQReservationParticipants { is_refund = 9, remarks = $"查询退款单并执行原路退款失败" }, it => it.id == participant.id);
continue;
}
@ -99,13 +101,13 @@ public class SQReservationRefundJob
}
else
{
await _participantsServices.UpdateAsync(it => new SQReservationParticipants { is_refund = 9 }, it => it.id == participant.id);
await _participantsServices.UpdateAsync(it => new SQReservationParticipants { is_refund = 9, remarks = $"发起退款失败!" + refundInfo.refundId }, it => it.id == participant.id);
}
}
catch (Exception ex)
{
Console.WriteLine($"[SQReservationRefundJob] 处理失败 participantId={participant.id}, ex={ex.Message}");
await _participantsServices.UpdateAsync(it => new SQReservationParticipants { is_refund = 9 }, it => it.id == participant.id);
await _participantsServices.UpdateAsync(it => new SQReservationParticipants { is_refund = 9, remarks = $"出现异常,退款失败!{ex.Message}" }, it => it.id == participant.id);
}
}
Console.WriteLine($"[SQReservationRefundJob] 执行结束 @ {DateTime.Now:yyyy-MM-dd HH:mm:ss}");