|
|
@@ -1665,7 +1665,7 @@ public class AirTicketResRepository : BaseRepository<Grp_AirTicketReservations,
|
|
|
}
|
|
|
|
|
|
// 3. 开启事务
|
|
|
- _sqlSugar.Ado.BeginTran();
|
|
|
+ BeginTran();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
@@ -1748,7 +1748,7 @@ public class AirTicketResRepository : BaseRepository<Grp_AirTicketReservations,
|
|
|
index++;
|
|
|
}
|
|
|
|
|
|
- _sqlSugar.Ado.CommitTran();
|
|
|
+ CommitTran();
|
|
|
|
|
|
var view = new AppPushBodyView()
|
|
|
{
|
|
|
@@ -1773,6 +1773,9 @@ public class AirTicketResRepository : BaseRepository<Grp_AirTicketReservations,
|
|
|
/// <summary>
|
|
|
/// 整理数据(按舱位类型分组,分离退票和正常记录)
|
|
|
/// </summary>
|
|
|
+ /// <param name="airTicketFeeInfos"></param>
|
|
|
+ /// <param name="groupId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
private Task<List<AirTicketFeeInfo>> OrganizeAirTicketDataAsync(List<AirTicketFeeInfo> airTicketFeeInfos, int groupId)
|
|
|
{
|
|
|
var result = new List<AirTicketFeeInfo>();
|
|
|
@@ -1782,8 +1785,6 @@ public class AirTicketResRepository : BaseRepository<Grp_AirTicketReservations,
|
|
|
if (airInfo.CustTicketInfos == null || !airInfo.CustTicketInfos.Any())
|
|
|
continue;
|
|
|
|
|
|
- var custRecord = _mapper.Map<AirTicketFeeOpInfo>(airInfo);
|
|
|
-
|
|
|
// 按舱位类型分组
|
|
|
var groupByCabinType = airInfo.CustTicketInfos
|
|
|
.GroupBy(x => x.CType)
|
|
|
@@ -1793,38 +1794,53 @@ public class AirTicketResRepository : BaseRepository<Grp_AirTicketReservations,
|
|
|
{
|
|
|
var customers = cabinGroup.ToList();
|
|
|
|
|
|
- // 有退票的客户
|
|
|
- var refundCustomers = customers.Where(x => x.IsRefund).ToList();
|
|
|
-
|
|
|
- // 1. 同类型舱位(有退票信息的客户正常存储)- 合并成一条数据
|
|
|
- if (customers.Any())
|
|
|
+ // 1. 正常记录(非退票客户)- 按舱位类型合并成一条数据
|
|
|
+ var normalCustomers = customers.Where(x => !x.IsRefund).ToList();
|
|
|
+ if (normalCustomers.Any())
|
|
|
{
|
|
|
- custRecord.ClientNum = customers.Count;
|
|
|
- custRecord.ClientName = string.Join(",", customers.Select(x => x.ClientId));
|
|
|
- custRecord.CustTicketInfos = customers;
|
|
|
- custRecord.Price = customers.Sum(x => x.ActualPrice);
|
|
|
+ var custRecord = _mapper.Map<AirTicketFeeOpInfo>(airInfo);
|
|
|
+ custRecord.ClientNum = normalCustomers.Count;
|
|
|
+ custRecord.ClientName = string.Join(",", normalCustomers.Select(x => x.ClientId));
|
|
|
+ custRecord.CustTicketInfos = normalCustomers;
|
|
|
+ custRecord.Price = normalCustomers.Sum(x => x.ActualPrice);
|
|
|
custRecord.Currency = airInfo.PaymentCurrency;
|
|
|
- custRecord.PayMoney = customers.Sum(x => x.TotalTicketPrice);
|
|
|
+ custRecord.PayMoney = normalCustomers.Sum(x => x.TotalTicketPrice);
|
|
|
+ custRecord.RecordType = 0; // 正常记录
|
|
|
|
|
|
result.Add(custRecord);
|
|
|
}
|
|
|
|
|
|
- // 2. 有退票记录的客户信息 - 按舱位类型合并成一条数据
|
|
|
+ // 2. 退票记录 - 按舱位类型 + 退款卡类型 分组
|
|
|
+ var refundCustomers = customers.Where(x => x.IsRefund).ToList();
|
|
|
if (refundCustomers.Any())
|
|
|
{
|
|
|
- custRecord.RecordType = 1; // 退票记录
|
|
|
- custRecord.OriginalReservationId = custRecord.Id; // 关联原始记录
|
|
|
- custRecord.ClientNum = refundCustomers.Count;
|
|
|
- custRecord.ClientName = string.Join(",", refundCustomers.Select(x => x.ClientId));
|
|
|
- custRecord.CustTicketInfos = refundCustomers;
|
|
|
-
|
|
|
- // 计算退款金额, 当前金额为负数
|
|
|
- decimal totalRefundAmount = refundCustomers.Sum(x => (x.RefundRecord?.RefundAmount ?? 0) + (x.RefundRecord?.NonRefundableTax ?? 0));
|
|
|
- custRecord.Price = totalRefundAmount;
|
|
|
- custRecord.Currency = airInfo.PaymentCurrency;
|
|
|
- custRecord.PayMoney = totalRefundAmount;
|
|
|
- custRecord.CTDId = refundCustomers.FirstOrDefault()?.RefundRecord?.RefundAccount ?? 0;
|
|
|
- result.Add(custRecord);
|
|
|
+ // 按退款卡类型分组
|
|
|
+ var groupByRefundAccount = refundCustomers
|
|
|
+ .GroupBy(x => x.RefundRecord?.RefundAccount ?? 0)
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ foreach (var refundGroup in groupByRefundAccount)
|
|
|
+ {
|
|
|
+ var refundCustomersInGroup = refundGroup.ToList();
|
|
|
+ var refundAccount = refundGroup.Key;
|
|
|
+
|
|
|
+ var custRecord = _mapper.Map<AirTicketFeeOpInfo>(airInfo);
|
|
|
+ custRecord.RecordType = 1; // 退票记录
|
|
|
+ custRecord.OriginalReservationId = custRecord.Id; // 关联原始记录
|
|
|
+ custRecord.ClientNum = refundCustomersInGroup.Count;
|
|
|
+ custRecord.ClientName = string.Join(",", refundCustomersInGroup.Select(x => x.ClientId));
|
|
|
+ custRecord.CustTicketInfos = refundCustomersInGroup;
|
|
|
+
|
|
|
+ // 计算退款金额(负数)
|
|
|
+ decimal totalRefundAmount = refundCustomersInGroup.Sum(x =>
|
|
|
+ (x.RefundRecord?.RefundAmount ?? 0) + (x.RefundRecord?.NonRefundableTax ?? 0));
|
|
|
+ custRecord.Price = totalRefundAmount;
|
|
|
+ custRecord.Currency = airInfo.PaymentCurrency;
|
|
|
+ custRecord.PayMoney = totalRefundAmount;
|
|
|
+ custRecord.CTDId = refundAccount; // 退款账户
|
|
|
+
|
|
|
+ result.Add(custRecord);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1835,6 +1851,10 @@ public class AirTicketResRepository : BaseRepository<Grp_AirTicketReservations,
|
|
|
/// <summary>
|
|
|
/// 新增记录
|
|
|
/// </summary>
|
|
|
+ /// <param name="airFeeInfo"></param>
|
|
|
+ /// <param name="cardPaymentInfo"></param>
|
|
|
+ /// <param name="index"></param>
|
|
|
+ /// <returns></returns>
|
|
|
private async Task<(bool Success, string ErrorMessage, int AirId, int CardId)> InsertNewRecord(
|
|
|
Grp_AirTicketReservations airFeeInfo,
|
|
|
Grp_CreditCardPayment cardPaymentInfo,
|
|
|
@@ -1880,6 +1900,12 @@ public class AirTicketResRepository : BaseRepository<Grp_AirTicketReservations,
|
|
|
/// <summary>
|
|
|
/// 更新记录
|
|
|
/// </summary>
|
|
|
+ /// <param name="airFeeInfo"></param>
|
|
|
+ /// <param name="cardPaymentInfo"></param>
|
|
|
+ /// <param name="existingAir"></param>
|
|
|
+ /// <param name="groupId"></param>
|
|
|
+ /// <param name="index"></param>
|
|
|
+ /// <returns></returns>
|
|
|
private async Task<(bool Success, bool IsSkip, string ErrorMessage, int AirId, int CardId)> UpdateExistingRecord(
|
|
|
Grp_AirTicketReservations airFeeInfo,
|
|
|
Grp_CreditCardPayment cardPaymentInfo,
|
|
|
@@ -1975,12 +2001,13 @@ public class AirTicketResRepository : BaseRepository<Grp_AirTicketReservations,
|
|
|
return (true, false, string.Empty, airId, cardId);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 单条删除 2026版
|
|
|
/// </summary>
|
|
|
+ /// <param name="userId"></param>
|
|
|
+ /// <param name="id"></param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<JsonView> SoftDelAsync(int userId, int id)
|
|
|
{
|