ソースを参照

统计模块 团组报表
团组详情
已完成 团组收入小块

leiy 1 年間 前
コミット
c4faf05e39

+ 171 - 3
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -1,7 +1,11 @@
 using Microsoft.AspNetCore.Mvc;
+using NPOI.POIFS.Properties;
+using NPOI.SS.Formula.Functions;
 using OASystem.API.OAMethodLib;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Dtos.Statistics;
+using OASystem.Domain.Entities.Financial;
+using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.Statistics;
 using OASystem.Infrastructure.Repositories.Groups;
@@ -12,7 +16,7 @@ namespace OASystem.API.Controllers
     /// 统计模块
     /// </summary>
     [Route("api/[controller]")]
-    //[ApiController]
+    [ApiController]
     public class StatisticsController : ControllerBase
     {
 
@@ -36,13 +40,16 @@ namespace OASystem.API.Controllers
             _sqlSugar = sqlSugar;
         }
 
+
+        #region 团组报表
+
         /// <summary>
         ///  团组报表
         ///  Items 
         /// </summary>
         /// <param name="_dto">团组列表请求dto</param>
         /// <returns></returns>
-        [HttpPost]
+        [HttpPost("PostGroupStatementItems")]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostGroupStatementItems(GroupStatementItemsDto _dto)
         {
@@ -58,7 +65,7 @@ namespace OASystem.API.Controllers
             #endregion
 
             #endregion
-            if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
+            if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 3) // web/Android/IOS
             {
                 string sqlWhere = string.Empty;
                 if (_dto.IsSure == 0) //未完成
@@ -111,5 +118,166 @@ namespace OASystem.API.Controllers
             }
         }
 
+        /// <summary>
+        ///  团组报表
+        ///  Details 
+        /// </summary>
+        /// <param name="_dto">团组列表请求dto</param>
+        /// <returns></returns>
+        [HttpPost("PostGroupStatementDetails")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostGroupStatementDetails(GroupStatementDetailsDto _dto)
+        {
+            #region  参数验证
+            if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
+            if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
+            if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
+
+            PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
+            #region 页面操作权限验证
+            pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
+
+            if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
+            #endregion
+
+            #endregion
+            if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 3) // web/Android/IOS
+            {
+                GroupStatementDetailsView _view = new GroupStatementDetailsView();
+
+                #region 费用类型 币种,转账
+
+                List<Sys_SetData> _setDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToListAsync();
+
+                #endregion
+
+                #region 团组收入
+
+                GroupIncomeView _giView = new GroupIncomeView();
+
+                /*
+                 * 应收报表
+                 */
+                decimal frTotalAmount = 0.00M;//应收总金额
+                string _frSql = string.Format(@"Select fr.Id,fr.Diid,fr.PriceName,fr.Price,fr.Count,fr.Unit,fr.Currency,
+										        sd.Name As CurrencyCode,sd.Remark As CurrencyName,fr.Rate,fr.ItemSumPrice
+										        From Fin_ForeignReceivables fr
+										        Left Join Sys_SetData sd On fr.Currency = sd.Id
+										        Where fr.IsDel = 0 And fr.Diid = {0}",_dto.DiId);
+                List<Gsd_ForeignReceivablesView> _frViews = await _sqlSugar.SqlQueryable<Gsd_ForeignReceivablesView>(_frSql).ToListAsync();
+                frTotalAmount = _frViews.Sum(it => it.ItemSumPrice);
+                _giView.Receivables = _frViews;
+                _giView.ReceivableStr = string.Format(@"应收款合计:{0} CNY(人名币)", frTotalAmount.ConvertToDecimal1().ToString("#0.00"));
+
+                /*
+                 * 已收报表
+                 */
+                decimal prTotalAmount = 0.00M;//已收总金额
+                string _prSql = string.Format(@"Select pr.Id,pr.Diid,pr.SectionTime,pr.Price,pr.Currency,
+										        sd1.Name As CurrencyCode,sd1.Remark As CurrencyName,pr.Client,
+										        pr.ReceivablesType,sd2.Name As ReceivablesTypeName,pr.Remark
+										        From Fin_ProceedsReceived  pr
+										        Left Join Sys_SetData sd1 On pr.Currency = sd1.Id
+										        Left Join Sys_SetData sd2 On pr.ReceivablesType = sd2.Id
+										        Where pr.IsDel = 0 and pr.Diid = {0}", _dto.DiId);
+                List<Gsd_ProceedsReceivedView> _prViews = await _sqlSugar.SqlQueryable<Gsd_ProceedsReceivedView>(_prSql).ToListAsync();
+                prTotalAmount = _prViews.Sum(it => it.Price);
+                _giView.ProceedsReceiveds = _prViews;
+                _giView.ProceedsReceivedStr = string.Format(@"已收款合计:{0} CNY(人名币)", prTotalAmount.ConvertToDecimal1().ToString("#0.00"));
+
+
+                /*
+                 * 超支费用 
+                 * 未挪表
+                 */
+
+                /*
+                 * 收款退还
+                 */
+                decimal promTotalAmount = 0.00M;// 收款退还总金额
+                List<Gsd_PaymentRefundAndOtherMoneyView> _promView = new List<Gsd_PaymentRefundAndOtherMoneyView>();
+
+                string _ropSql = string.Format(@"Select u.CnName As Appliction,prom.Id As PrId,prom.DiId As PrDiId,prom.Price As PrPrice,
+										         prom.PriceName AS PrPriceName,prom.CurrencyId As PrCurrencyId,
+										         prom.PayType As PrPayType,prom.PriceType As PrPriceType,ccp.*
+										         From Fin_PaymentRefundAndOtherMoney prom
+										         Left Join Grp_CreditCardPayment ccp On prom.DiId = ccp.DIId And prom.Id = ccp.CId
+										         Left Join Sys_Users u On ccp.CreateUserId = u.Id
+										         Where prom.IsDel = 0  And prom.PayType = 1 And prom.PriceType = 1 And ccp.CTable = 285
+										         And ccp.IsAuditGM = 1 And ccp.IsPay = 1
+										         And prom.DiId =   {0}", _dto.DiId);
+                var _promDatas = await _sqlSugar.SqlQueryable<Gsd_PaymentRefundAndOtherMoneyDataSource1View>(_ropSql).ToListAsync();
+
+                
+
+                foreach (var ropItem in _promDatas)
+                {
+                    string thisCueencyCode = "Unknown";
+                    string thisCueencyName = "Unknown";
+                    var currency = _setDatas.Where(it => it.Id == ropItem.PaymentCurrency).FirstOrDefault();
+                    if (currency != null)
+                    {
+                        thisCueencyCode = currency.Name;
+                        thisCueencyName = currency.Remark;
+                    }
+
+                    string orbitalPrivateTransferStr = "Unknown";
+                    var orbitalPrivateTransfer = _setDatas.Where(it => it.Id == ropItem.OrbitalPrivateTransfer).FirstOrDefault();
+                    if (orbitalPrivateTransfer != null)
+                    {
+                        orbitalPrivateTransferStr = orbitalPrivateTransfer.Name;
+                    }
+
+                    string payStr = "Unknown";
+                    var pay = _setDatas.Where(it => it.Id == ropItem.PayDId).FirstOrDefault();
+                    if (pay != null)
+                    {
+                        payStr = pay.Name;
+                    }
+
+                    Gsd_PaymentRefundAndOtherMoneyView gsd_PaymentRefund = new Gsd_PaymentRefundAndOtherMoneyView()
+                    {
+                        Id = ropItem.Id,
+                        DiId = ropItem.DIId,
+                        PriceName = ropItem.PrPriceName,
+                        PayCurrencyCode = thisCueencyCode,
+                        PayCurrencyName = thisCueencyName,
+                        Price = ropItem.PrPrice,
+                        CNYPrice = ropItem.RMBPrice,
+                        ThisRate = ropItem.DayRate,
+                        Payee = ropItem.Payee,
+                        PayTime = ropItem.AuditGMDate,
+                        FeeType = orbitalPrivateTransferStr,
+                        PayType = payStr,
+                        PayStatus = ropItem.IsPay == 0 ? "未付款" : "已付款",
+                        Applicant = ropItem.Appliction
+
+                    };
+
+                    _promView.Add(gsd_PaymentRefund);
+                }
+
+                promTotalAmount = _promView.Sum(it => it.CNYPrice);
+                _giView.PaymentRefundAndOtherMoneys = _promView;
+                _giView.PaymentRefundAndOtherMoneyStr = string.Format(@"人名币总费用:{0} CNY", promTotalAmount.ConvertToDecimal1().ToString("#0.00"));
+
+                decimal BalancePayment = frTotalAmount - prTotalAmount + promTotalAmount;
+                _view.GroupIncome = _giView;
+                _view.GroupIncomeStr = string.Format(@"剩余尾款:{0} (包含了收款退还费用数据)", BalancePayment.ConvertToDecimal1().ToString("#0.00"));
+                #endregion
+
+
+
+
+                return Ok(JsonView(true, "查询成功!", _view));
+            }
+            else
+            {
+                return Ok(JsonView(false, "查询成功"));
+            }
+        }
+
+        #endregion
+
     }
 }

+ 13 - 0
OASystem/OASystem.Domain/Dtos/Statistics/GroupStatementDto.cs

@@ -28,4 +28,17 @@ namespace OASystem.Domain.Dtos.Statistics
         /// </summary>
         public string? SearchCriteria { get; set; }
     }
+
+    /// <summary>
+    /// 团组报表
+    /// Details Dto
+    /// </summary>
+    public class GroupStatementDetailsDto : UserPageFuncDtoBase
+    {
+        /// <summary>
+        /// 团组Id
+        /// </summary>
+        public int DiId { get; set; }
+    }
+
 }

+ 268 - 1
OASystem/OASystem.Domain/ViewModels/Statistics/GroupStatementView.cs

@@ -1,4 +1,6 @@
-using System;
+using OASystem.Domain.Entities.Financial;
+using OASystem.Domain.Entities.Groups;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -102,4 +104,269 @@ namespace OASystem.Domain.ViewModels.Statistics
         public DateTime? LastCollectionTime { get; set; }
 
     }
+
+    /// <summary>
+    /// 团组报表
+    /// Details View
+    /// </summary>
+    public class GroupStatementDetailsView
+    {
+        /// <summary>
+        /// 费用总计 描述
+        /// </summary>
+        public string? TotalStr { get; set; }
+
+        /// <summary>
+        /// 团组收入
+        /// Data View 
+        /// </summary>
+        public GroupIncomeView? GroupIncome { get; set; }
+
+        /// <summary>
+        /// 团组收入
+        /// 描述
+        /// </summary>
+        public string? GroupIncomeStr { get; set; }
+    }
+
+    #region 团组收入
+
+    /// <summary>
+    /// 团组收入 
+    /// Data View
+    /// </summary>
+    public class GroupIncomeView
+    {
+        /// <summary>
+        /// 应收 Items
+        /// </summary>
+        public List<Gsd_ForeignReceivablesView>? Receivables { get; set; }
+
+        /// <summary>
+        /// 应收 Str
+        /// </summary>
+        public string? ReceivableStr { get; set; }
+
+        /// <summary>
+        /// 已收 Items
+        /// </summary>
+        public List<Gsd_ProceedsReceivedView>? ProceedsReceiveds { get; set; }
+
+        /// <summary>
+        /// 已收 Str
+        /// </summary>
+        public string? ProceedsReceivedStr { get; set; }
+
+        /// <summary>
+        /// 收款退还
+        /// </summary>
+        public List<Gsd_PaymentRefundAndOtherMoneyView>? PaymentRefundAndOtherMoneys { get; set; }
+
+        /// <summary>
+        /// 收款退还 Str
+        /// </summary>
+        public string? PaymentRefundAndOtherMoneyStr { get; set; }
+    }
+
+    /// <summary>
+    /// 应收报表
+    /// </summary>
+    public class Gsd_ForeignReceivablesView
+    {
+        public int Id { get; set; }
+
+        public int diid { get; set; }
+
+        /// <summary>
+        /// 费用名称
+        /// </summary>
+        public string? PriceName { get; set; }
+
+        /// <summary>
+        /// 单价
+        /// </summary>
+        public decimal Price { get; set; }
+
+        /// <summary>
+        /// 数量
+        /// </summary>
+        public int Count { get; set; }
+
+        /// <summary>
+        /// 单位
+        /// </summary>
+        public string? Unit { get; set; }
+
+        /// <summary>
+        /// 币种
+        /// </summary>
+        public int Currency { get; set; }
+
+        /// <summary>
+        /// 币种 Code
+        /// </summary>
+        public string CurrencyCode { get; set; }
+
+        /// <summary>
+        /// 币种 Name
+        /// </summary>
+        public string CurrencyName { get; set; }
+
+        /// <summary>
+        /// 汇率
+        /// </summary>
+        public decimal Rate { get; set; }
+
+        /// <summary>
+        /// 应收金额
+        /// </summary>
+        public decimal ItemSumPrice { get; set; }
+    }
+
+    /// <summary>
+    /// 已收报表
+    /// </summary>
+    public class Gsd_ProceedsReceivedView
+    {
+        public int Id { get; set; }
+
+        public int Diid { get; set; }
+
+        /// <summary>
+        /// 到款时间
+        /// </summary>
+        public string? SectionTime { get; set; }
+
+        /// <summary>
+        /// 费用金额
+        /// </summary>
+        public decimal Price { get; set; }
+
+        /// <summary>
+        /// 币种
+        /// </summary>
+        public int Currency { get; set; }
+
+        /// <summary>
+        /// 币种 Code
+        /// </summary>
+        public string CurrencyCode { get; set; }
+
+        /// <summary>
+        /// 币种 Name
+        /// </summary>
+        public string CurrencyName { get; set; }
+
+        /// <summary>
+        /// 支出单位
+        /// </summary>
+        public string? Client { get; set; }
+
+        /// <summary>
+        /// 转账标识Id
+        /// </summary>
+        public int ReceivablesType { get; set; }
+
+        /// <summary>
+        /// 转账类型名称
+        /// </summary>
+        public string ReceivablesTypeName { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string? Remark { get; set; }
+    }
+
+    /// <summary>
+    /// 收款退还
+    /// </summary>
+    public class Gsd_PaymentRefundAndOtherMoneyView
+    {
+        public int Id { get; set; }
+
+        public int DiId { get; set; }
+
+        /// <summary>
+        /// 费用名称
+        /// </summary>
+        public string? PriceName { get; set; }
+
+        /// <summary>
+        /// 币种code
+        /// </summary>
+        public string? PayCurrencyCode { get; set; }
+
+        /// <summary>
+        /// 币种名称
+        /// </summary>
+        public string? PayCurrencyName { get; set; }
+
+        /// <summary>
+        /// 费用
+        /// </summary>
+        public decimal Price { get; set; }
+
+        /// <summary>
+        /// 人名币金额
+        /// </summary>
+        public decimal CNYPrice { get; set; }
+
+        /// <summary>
+        /// 当时汇率
+        /// </summary>
+        public decimal ThisRate { get; set; }
+
+        /// <summary>
+        /// 收款方
+        /// </summary>
+        public string? Payee { get; set; }
+
+        /// <summary>
+        /// 付款时间
+        /// </summary>
+        public string? PayTime { get; set; }
+
+        /// <summary>
+        /// 费用标识
+        /// </summary>
+        public string? FeeType { get; set; }
+
+        /// <summary>
+        /// 支付方式
+        /// </summary>
+        public string? PayType { get; set; }
+
+        /// <summary>
+        /// 付款状态
+        /// </summary>
+        public string? PayStatus { get; set; }
+
+        /// <summary>
+        /// 申请人
+        /// </summary>
+        public string? Applicant { get; set; }
+    }
+
+    #region 收款退还 View
+
+    public class Gsd_PaymentRefundAndOtherMoneyDataSource1View : Grp_CreditCardPayment 
+    {
+        /// <summary>
+        /// 申请人
+        /// </summary>
+        public string Appliction { get; set; }
+        public int PrId { get; set; }
+
+        public int PrDiId { get; set; }
+        public string PrPriceName { get; set; }
+        public decimal PrPrice { get; set; }
+        public int PrCurrencyId { get; set; }
+        public int PrPayType { get; set; }
+        public int PrPriceType { get; set; }
+    };
+
+    #endregion
+
+    #endregion
 }