From 6811251e2294fb7a73096e7097cd7449bc47da50 Mon Sep 17 00:00:00 2001 From: zpc Date: Sat, 27 Sep 2025 13:23:58 +0800 Subject: [PATCH] 312 --- CoreCms.Net.Task/SQReservationRefundJob.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CoreCms.Net.Task/SQReservationRefundJob.cs b/CoreCms.Net.Task/SQReservationRefundJob.cs index 6bea4d0..d9e0f62 100644 --- a/CoreCms.Net.Task/SQReservationRefundJob.cs +++ b/CoreCms.Net.Task/SQReservationRefundJob.cs @@ -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}");