diff --git a/src/Shentun.Peis.Application.Contracts/ChargeReports/GetTollCollectorFeeReportInPayModeDto.cs b/src/Shentun.Peis.Application.Contracts/ChargeReports/GetTollCollectorFeeReportInPayModeDto.cs
new file mode 100644
index 0000000..245dae4
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/ChargeReports/GetTollCollectorFeeReportInPayModeDto.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.ChargeReports
+{
+ public class GetTollCollectorFeeReportInPayModeDto
+ {
+ }
+}
diff --git a/src/Shentun.Peis.Application.Contracts/ChargeReports/GetTollCollectorFeeReportInPayModeRequestDto.cs b/src/Shentun.Peis.Application.Contracts/ChargeReports/GetTollCollectorFeeReportInPayModeRequestDto.cs
new file mode 100644
index 0000000..8f4e13e
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/ChargeReports/GetTollCollectorFeeReportInPayModeRequestDto.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.ChargeReports
+{
+ public class GetTollCollectorFeeReportInPayModeRequestDto
+ {
+ }
+}
diff --git a/src/Shentun.Peis.Application.Contracts/Charges/ChargeAndChargeBackSettlementRequestDto.cs b/src/Shentun.Peis.Application.Contracts/Charges/ChargeAndChargeBackSettlementRequestDto.cs
new file mode 100644
index 0000000..2bde758
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/Charges/ChargeAndChargeBackSettlementRequestDto.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.Charges
+{
+ public class ChargeAndChargeBackSettlementRequestDto
+ {
+ ///
+ /// 收费员ID 集合
+ ///
+ public List UserIds { get; set; } = new List();
+
+ ///
+ /// 开始日期
+ ///
+ public string StartDate { get; set; }
+
+ ///
+ /// 结束日期
+ ///
+ public string EndDate { get; set; }
+ }
+}
+}
diff --git a/src/Shentun.Peis.Application.Contracts/Charges/GetChargeAndChargeBackSummaryDto.cs b/src/Shentun.Peis.Application.Contracts/Charges/GetChargeAndChargeBackSummaryDto.cs
new file mode 100644
index 0000000..2d59f56
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/Charges/GetChargeAndChargeBackSummaryDto.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.Charges
+{
+ public class GetChargeAndChargeBackSummaryDto
+ {
+ ///
+ /// 收费汇总
+ ///
+ public List ChargeDetails { get; set; }
+
+ ///
+ /// 退费汇总
+ ///
+ public List ChargeBackDetails { get; set; }
+ }
+
+ public class GetChargeAndChargeBackSummary_ChargeDetail
+ {
+ ///
+ /// 收费员
+ ///
+ public string UserName { get; set; }
+
+ ///
+ /// 收费明细
+ ///
+ public List PayModeDetails { get; set; }
+ }
+
+ public class GetChargeAndChargeBackSummary_ChargeBackDetail
+ {
+ ///
+ /// 退费员
+ ///
+ public string UserName { get; set; }
+
+ ///
+ /// 退费明细
+ ///
+ public List PayModeDetails { get; set; }
+ }
+
+ public class GetChargeAndChargeBackSummary_PayModeDetail
+ {
+ ///
+ /// 支付方式
+ ///
+ public string PayModeName { get; set; }
+
+ ///
+ /// 收费或退费金额
+ ///
+ public string Money { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application.Contracts/Charges/GetChargeAndChargeBackSummaryRequestDto.cs b/src/Shentun.Peis.Application.Contracts/Charges/GetChargeAndChargeBackSummaryRequestDto.cs
new file mode 100644
index 0000000..4ecb233
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/Charges/GetChargeAndChargeBackSummaryRequestDto.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.Charges
+{
+ public class GetChargeAndChargeBackSummaryRequestDto
+ {
+ ///
+ /// 收费员ID 集合
+ ///
+ public List UserIds { get; set; } = new List();
+
+ ///
+ /// 开始日期
+ ///
+ public string StartDate { get; set; }
+
+ ///
+ /// 结束日期
+ ///
+ public string EndDate { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application/ChargeReports/ChargeReportAppService.cs b/src/Shentun.Peis.Application/ChargeReports/ChargeReportAppService.cs
new file mode 100644
index 0000000..61cf159
--- /dev/null
+++ b/src/Shentun.Peis.Application/ChargeReports/ChargeReportAppService.cs
@@ -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
+{
+ ///
+ /// 收费统计报表
+ ///
+ [Authorize]
+ [ApiExplorerSettings(GroupName = "Work")]
+ public class ChargeReportAppService
+ {
+
+ private readonly IRepository _chargeRepository;
+ private readonly IRepository _chargePayRepository;
+ private readonly IRepository _payModeRepository;
+ private readonly IRepository _chargeBackRepository;
+ private readonly IRepository _chargeBackPayRepository;
+ private readonly IRepository _userRepository;
+
+
+
+ public ChargeReportAppService(
+ IRepository chargeRepository,
+ IRepository chargeBackRepository,
+ IRepository chargePayRepository,
+ IRepository payModeRepository,
+ IRepository chargeBackPayRepository,
+ IRepository userRepository
+ )
+ {
+ _chargeRepository = chargeRepository;
+ _chargeBackRepository = chargeBackRepository;
+ _chargePayRepository = chargePayRepository;
+ _payModeRepository = payModeRepository;
+ _chargeBackPayRepository = chargeBackPayRepository;
+ _userRepository = userRepository;
+ }
+
+
+
+ /////
+ ///// 收费员收费报表 按支付方式
+ /////
+ /////
+ /////
+ //[HttpPost("api/app/charge-report/get-toll-collector-fee-report-in-pay-mode")]
+ //public async Task GetTollCollectorFeeReportInPayModeAsync(GetTollCollectorFeeReportInPayModeRequestDto input)
+ //{
+
+ //}
+
+
+ }
+}
diff --git a/src/Shentun.Peis.Application/Charges/ChargeAppService.cs b/src/Shentun.Peis.Application/Charges/ChargeAppService.cs
index ccb13e1..5570de2 100644
--- a/src/Shentun.Peis.Application/Charges/ChargeAppService.cs
+++ b/src/Shentun.Peis.Application/Charges/ChargeAppService.cs
@@ -1,17 +1,218 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using Shentun.Peis.Books;
+using Shentun.Peis.Models;
using System;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
+using Volo.Abp.Domain.Repositories;
+using Volo.Abp.Identity;
+using Volo.Abp.Users;
namespace Shentun.Peis.Charges
{
+ ///
+ /// 收费
+ ///
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class ChargeAppService : ApplicationService
{
+
+ private readonly IRepository _chargeRepository;
+ private readonly IRepository _chargePayRepository;
+ private readonly IRepository _payModeRepository;
+ private readonly IRepository _chargeBackRepository;
+ private readonly IRepository _chargeBackPayRepository;
+ private readonly IRepository _userRepository;
+ private readonly ICurrentUser _currentUser;
+
+
+ public ChargeAppService(
+ IRepository chargeRepository,
+ IRepository chargeBackRepository,
+ IRepository chargePayRepository,
+ IRepository payModeRepository,
+ IRepository chargeBackPayRepository,
+ IRepository userRepository,
+ ICurrentUser currentUser)
+ {
+ _chargeRepository = chargeRepository;
+ _chargeBackRepository = chargeBackRepository;
+ _chargePayRepository = chargePayRepository;
+ _payModeRepository = payModeRepository;
+ _chargeBackPayRepository = chargeBackPayRepository;
+ _userRepository = userRepository;
+ _currentUser = currentUser;
+ }
+
+
+
+ ///
+ /// 查询收费、退费信息汇总 结算钱展示
+ ///
+ ///
+ [HttpPost("api/app/charge/get-charge-and-charge-back-summary")]
+ public async Task 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;
+
+ }
+
+
+
+
+ ///
+ /// 财务结算接口
+ ///
+ ///
+ [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);
+ }
+
+ }
}
-}
+}
\ No newline at end of file