7 changed files with 393 additions and 1 deletions
-
10src/Shentun.Peis.Application.Contracts/ChargeReports/GetTollCollectorFeeReportInPayModeDto.cs
-
10src/Shentun.Peis.Application.Contracts/ChargeReports/GetTollCollectorFeeReportInPayModeRequestDto.cs
-
25src/Shentun.Peis.Application.Contracts/Charges/ChargeAndChargeBackSettlementRequestDto.cs
-
58src/Shentun.Peis.Application.Contracts/Charges/GetChargeAndChargeBackSummaryDto.cs
-
24src/Shentun.Peis.Application.Contracts/Charges/GetChargeAndChargeBackSummaryRequestDto.cs
-
64src/Shentun.Peis.Application/ChargeReports/ChargeReportAppService.cs
-
203src/Shentun.Peis.Application/Charges/ChargeAppService.cs
@ -0,0 +1,10 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.ChargeReports |
||||
|
{ |
||||
|
public class GetTollCollectorFeeReportInPayModeDto |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.ChargeReports |
||||
|
{ |
||||
|
public class GetTollCollectorFeeReportInPayModeRequestDto |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.Charges |
||||
|
{ |
||||
|
public class ChargeAndChargeBackSettlementRequestDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 收费员ID 集合
|
||||
|
/// </summary>
|
||||
|
public List<Guid> UserIds { get; set; } = new List<Guid>(); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 开始日期
|
||||
|
/// </summary>
|
||||
|
public string StartDate { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 结束日期
|
||||
|
/// </summary>
|
||||
|
public string EndDate { get; set; } |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.Charges |
||||
|
{ |
||||
|
public class GetChargeAndChargeBackSummaryDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 收费汇总
|
||||
|
/// </summary>
|
||||
|
public List<GetChargeAndChargeBackSummary_ChargeDetail> ChargeDetails { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 退费汇总
|
||||
|
/// </summary>
|
||||
|
public List<GetChargeAndChargeBackSummary_ChargeBackDetail> ChargeBackDetails { get; set; } |
||||
|
} |
||||
|
|
||||
|
public class GetChargeAndChargeBackSummary_ChargeDetail |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 收费员
|
||||
|
/// </summary>
|
||||
|
public string UserName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收费明细
|
||||
|
/// </summary>
|
||||
|
public List<GetChargeAndChargeBackSummary_PayModeDetail> PayModeDetails { get; set; } |
||||
|
} |
||||
|
|
||||
|
public class GetChargeAndChargeBackSummary_ChargeBackDetail |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 退费员
|
||||
|
/// </summary>
|
||||
|
public string UserName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 退费明细
|
||||
|
/// </summary>
|
||||
|
public List<GetChargeAndChargeBackSummary_PayModeDetail> PayModeDetails { get; set; } |
||||
|
} |
||||
|
|
||||
|
public class GetChargeAndChargeBackSummary_PayModeDetail |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 支付方式
|
||||
|
/// </summary>
|
||||
|
public string PayModeName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 收费或退费金额
|
||||
|
/// </summary>
|
||||
|
public string Money { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Shentun.Peis.Charges |
||||
|
{ |
||||
|
public class GetChargeAndChargeBackSummaryRequestDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 收费员ID 集合
|
||||
|
/// </summary>
|
||||
|
public List<Guid> UserIds { get; set; } = new List<Guid>(); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 开始日期
|
||||
|
/// </summary>
|
||||
|
public string StartDate { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 结束日期
|
||||
|
/// </summary>
|
||||
|
public string EndDate { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,64 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Shentun.Peis.Models; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
|
namespace Shentun.Peis.ChargeReports |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 收费统计报表
|
||||
|
/// </summary>
|
||||
|
[Authorize] |
||||
|
[ApiExplorerSettings(GroupName = "Work")] |
||||
|
public class ChargeReportAppService |
||||
|
{ |
||||
|
|
||||
|
private readonly IRepository<Charge, Guid> _chargeRepository; |
||||
|
private readonly IRepository<ChargePay> _chargePayRepository; |
||||
|
private readonly IRepository<PayMode> _payModeRepository; |
||||
|
private readonly IRepository<ChargeBack, Guid> _chargeBackRepository; |
||||
|
private readonly IRepository<ChargeBackPay> _chargeBackPayRepository; |
||||
|
private readonly IRepository<IdentityUser, Guid> _userRepository; |
||||
|
|
||||
|
|
||||
|
|
||||
|
public ChargeReportAppService( |
||||
|
IRepository<Charge, Guid> chargeRepository, |
||||
|
IRepository<ChargeBack, Guid> chargeBackRepository, |
||||
|
IRepository<ChargePay> chargePayRepository, |
||||
|
IRepository<PayMode> payModeRepository, |
||||
|
IRepository<ChargeBackPay> chargeBackPayRepository, |
||||
|
IRepository<IdentityUser, Guid> userRepository |
||||
|
) |
||||
|
{ |
||||
|
_chargeRepository = chargeRepository; |
||||
|
_chargeBackRepository = chargeBackRepository; |
||||
|
_chargePayRepository = chargePayRepository; |
||||
|
_payModeRepository = payModeRepository; |
||||
|
_chargeBackPayRepository = chargeBackPayRepository; |
||||
|
_userRepository = userRepository; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 收费员收费报表 按支付方式
|
||||
|
///// </summary>
|
||||
|
///// <param name="input"></param>
|
||||
|
///// <returns></returns>
|
||||
|
//[HttpPost("api/app/charge-report/get-toll-collector-fee-report-in-pay-mode")]
|
||||
|
//public async Task<GetTollCollectorFeeReportInPayModeDto> GetTollCollectorFeeReportInPayModeAsync(GetTollCollectorFeeReportInPayModeRequestDto input)
|
||||
|
//{
|
||||
|
|
||||
|
//}
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -1,17 +1,218 @@ |
|||||
using Microsoft.AspNetCore.Authorization; |
using Microsoft.AspNetCore.Authorization; |
||||
using Microsoft.AspNetCore.Mvc; |
using Microsoft.AspNetCore.Mvc; |
||||
|
using Shentun.Peis.Books; |
||||
|
using Shentun.Peis.Models; |
||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
|
using System.Collections.Immutable; |
||||
using System.Linq; |
using System.Linq; |
||||
using System.Text; |
using System.Text; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Volo.Abp.Application.Services; |
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
namespace Shentun.Peis.Charges |
namespace Shentun.Peis.Charges |
||||
{ |
{ |
||||
|
/// <summary>
|
||||
|
/// 收费
|
||||
|
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "Work")] |
[ApiExplorerSettings(GroupName = "Work")] |
||||
[Authorize] |
[Authorize] |
||||
public class ChargeAppService : ApplicationService |
public class ChargeAppService : ApplicationService |
||||
{ |
{ |
||||
|
|
||||
|
private readonly IRepository<Charge, Guid> _chargeRepository; |
||||
|
private readonly IRepository<ChargePay> _chargePayRepository; |
||||
|
private readonly IRepository<PayMode> _payModeRepository; |
||||
|
private readonly IRepository<ChargeBack, Guid> _chargeBackRepository; |
||||
|
private readonly IRepository<ChargeBackPay> _chargeBackPayRepository; |
||||
|
private readonly IRepository<IdentityUser, Guid> _userRepository; |
||||
|
private readonly ICurrentUser _currentUser; |
||||
|
|
||||
|
|
||||
|
public ChargeAppService( |
||||
|
IRepository<Charge, Guid> chargeRepository, |
||||
|
IRepository<ChargeBack, Guid> chargeBackRepository, |
||||
|
IRepository<ChargePay> chargePayRepository, |
||||
|
IRepository<PayMode> payModeRepository, |
||||
|
IRepository<ChargeBackPay> chargeBackPayRepository, |
||||
|
IRepository<IdentityUser, Guid> userRepository, |
||||
|
ICurrentUser currentUser) |
||||
|
{ |
||||
|
_chargeRepository = chargeRepository; |
||||
|
_chargeBackRepository = chargeBackRepository; |
||||
|
_chargePayRepository = chargePayRepository; |
||||
|
_payModeRepository = payModeRepository; |
||||
|
_chargeBackPayRepository = chargeBackPayRepository; |
||||
|
_userRepository = userRepository; |
||||
|
_currentUser = currentUser; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 查询收费、退费信息汇总 结算钱展示
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/charge/get-charge-and-charge-back-summary")] |
||||
|
public async Task<GetChargeAndChargeBackSummaryDto> GetChargeAndChargeBackSummaryAsync(GetChargeAndChargeBackSummaryRequestDto input) |
||||
|
{ |
||||
|
#region 收费
|
||||
|
var chargeQuery = from a in await _chargeRepository.GetQueryableAsync() |
||||
|
join b in await _chargePayRepository.GetQueryableAsync() on a.Id equals b.ChargeId |
||||
|
join c in await _payModeRepository.GetQueryableAsync() on b.PayModeId equals c.Id into cc |
||||
|
from ac in cc.DefaultIfEmpty() |
||||
|
join d in await _userRepository.GetQueryableAsync() on a.CreatorId equals d.Id into dd |
||||
|
from ad in dd.DefaultIfEmpty() |
||||
|
select new |
||||
|
{ |
||||
|
a, |
||||
|
b, |
||||
|
PayModeName = ac != null ? ac.DisplayName : "", |
||||
|
UserName = ad != null ? ad.UserName : "" |
||||
|
}; |
||||
|
|
||||
|
if (input.UserIds.Any()) |
||||
|
{ |
||||
|
chargeQuery = chargeQuery.Where(m => input.UserIds.Contains(m.a.CreatorId.Value)); |
||||
|
} |
||||
|
|
||||
|
if (!string.IsNullOrWhiteSpace(input.StartDate) && !string.IsNullOrWhiteSpace(input.EndDate)) |
||||
|
{ |
||||
|
chargeQuery = chargeQuery.Where(m => m.a.CreationTime >= Convert.ToDateTime(input.StartDate) |
||||
|
&& m.a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
||||
|
} |
||||
|
|
||||
|
//收费归总
|
||||
|
var ChargeDetails = chargeQuery.GroupBy(g => g.a.CreatorId).Select(s => new GetChargeAndChargeBackSummary_ChargeDetail |
||||
|
{ |
||||
|
UserName = s.FirstOrDefault().UserName, |
||||
|
PayModeDetails = s.GroupBy(gg => gg.b.PayModeId).Select(ss => new GetChargeAndChargeBackSummary_PayModeDetail |
||||
|
{ |
||||
|
PayModeName = ss.FirstOrDefault().PayModeName, |
||||
|
Money = Math.Round(ss.Sum(sss => sss.b.ChargeMoney), 2).ToString() |
||||
|
}).ToList() |
||||
|
}); |
||||
|
#endregion
|
||||
|
|
||||
|
#region 退费
|
||||
|
|
||||
|
var chargeBackQuery = from a in await _chargeBackRepository.GetQueryableAsync() |
||||
|
join b in await _chargeBackPayRepository.GetQueryableAsync() on a.Id equals b.ChargeBackId |
||||
|
join c in await _payModeRepository.GetQueryableAsync() on b.PayModeId equals c.Id into cc |
||||
|
from ac in cc.DefaultIfEmpty() |
||||
|
join d in await _userRepository.GetQueryableAsync() on a.CreatorId equals d.Id into dd |
||||
|
from ad in dd.DefaultIfEmpty() |
||||
|
select new |
||||
|
{ |
||||
|
a, |
||||
|
b, |
||||
|
PayModeName = ac != null ? ac.DisplayName : "", |
||||
|
UserName = ad != null ? ad.UserName : "" |
||||
|
}; |
||||
|
|
||||
|
if (input.UserIds.Any()) |
||||
|
{ |
||||
|
chargeBackQuery = chargeBackQuery.Where(m => input.UserIds.Contains(m.a.CreatorId.Value)); |
||||
|
} |
||||
|
|
||||
|
if (!string.IsNullOrWhiteSpace(input.StartDate) && !string.IsNullOrWhiteSpace(input.EndDate)) |
||||
|
{ |
||||
|
chargeBackQuery = chargeBackQuery.Where(m => m.a.CreationTime >= Convert.ToDateTime(input.StartDate) |
||||
|
&& m.a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
||||
|
} |
||||
|
|
||||
|
//收费归总
|
||||
|
var ChargeBackDetails = chargeBackQuery.GroupBy(g => g.a.CreatorId).Select(s => new GetChargeAndChargeBackSummary_ChargeBackDetail |
||||
|
{ |
||||
|
UserName = s.FirstOrDefault().UserName, |
||||
|
PayModeDetails = s.GroupBy(gg => gg.b.PayModeId).Select(ss => new GetChargeAndChargeBackSummary_PayModeDetail |
||||
|
{ |
||||
|
PayModeName = ss.FirstOrDefault().PayModeName, |
||||
|
Money = Math.Round(ss.Sum(sss => sss.b.BackMoeny), 2).ToString() |
||||
|
}).ToList() |
||||
|
}); |
||||
|
#endregion
|
||||
|
|
||||
|
var chargeAndChargeBackSummaryDto = new GetChargeAndChargeBackSummaryDto |
||||
|
{ |
||||
|
ChargeBackDetails = ChargeBackDetails.ToList(), |
||||
|
ChargeDetails = ChargeDetails.ToList() |
||||
|
}; |
||||
|
|
||||
|
return chargeAndChargeBackSummaryDto; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 财务结算接口
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("api/app/charge/charge-and-charge-back-settlement")] |
||||
|
public async Task ChargeAndChargeBackSettlementAsync(ChargeAndChargeBackSettlementRequestDto input) |
||||
|
{ |
||||
|
if (_currentUser.Id != null && _currentUser.Id != Guid.Empty) |
||||
|
{ |
||||
|
#region 收费
|
||||
|
var chargeQuery = (await _chargeRepository.GetQueryableAsync()).Where(m => m.SettleAccountId == null || m.SettleAccountId == Guid.Empty); |
||||
|
|
||||
|
if (input.UserIds.Any()) |
||||
|
{ |
||||
|
chargeQuery = chargeQuery.Where(m => input.UserIds.Contains(m.CreatorId.Value)); |
||||
|
} |
||||
|
|
||||
|
if (!string.IsNullOrWhiteSpace(input.StartDate) && !string.IsNullOrWhiteSpace(input.EndDate)) |
||||
|
{ |
||||
|
chargeQuery = chargeQuery.Where(m => m.CreationTime >= Convert.ToDateTime(input.StartDate) |
||||
|
&& m.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
||||
|
} |
||||
|
|
||||
|
var chargeList = chargeQuery.ToList(); |
||||
|
if (chargeList.Any()) |
||||
|
{ |
||||
|
foreach (var charge in chargeList) |
||||
|
{ |
||||
|
charge.SettleAccountId = _currentUser.Id; |
||||
|
charge.SettleTime = DateTime.Now; |
||||
|
} |
||||
|
} |
||||
|
#endregion
|
||||
|
|
||||
|
#region 退费
|
||||
|
var chargeBackQuery = (await _chargeBackRepository.GetQueryableAsync()).Where(m => m.SettleAccountId == null || m.SettleAccountId == Guid.Empty); |
||||
|
|
||||
|
if (input.UserIds.Any()) |
||||
|
{ |
||||
|
chargeBackQuery = chargeBackQuery.Where(m => input.UserIds.Contains(m.CreatorId.Value)); |
||||
|
} |
||||
|
|
||||
|
if (!string.IsNullOrWhiteSpace(input.StartDate) && !string.IsNullOrWhiteSpace(input.EndDate)) |
||||
|
{ |
||||
|
chargeBackQuery = chargeBackQuery.Where(m => m.CreationTime >= Convert.ToDateTime(input.StartDate) |
||||
|
&& m.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
||||
|
} |
||||
|
|
||||
|
var chargeBackList = chargeBackQuery.ToList(); |
||||
|
if (chargeBackList.Any()) |
||||
|
{ |
||||
|
foreach (var chargeBack in chargeBackList) |
||||
|
{ |
||||
|
chargeBack.SettleAccountId = _currentUser.Id; |
||||
|
chargeBack.SettleTime = DateTime.Now; |
||||
|
} |
||||
|
} |
||||
|
#endregion
|
||||
|
|
||||
|
await _chargeRepository.UpdateManyAsync(chargeList); |
||||
|
|
||||
|
await _chargeBackRepository.UpdateManyAsync(chargeBackList); |
||||
|
} |
||||
|
|
||||
|
} |
||||
} |
} |
||||
} |
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue