leiy 11 months ago
parent
commit
364e9e6771

+ 346 - 0
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -1823,5 +1823,351 @@ namespace OASystem.API.Controllers
         }
 
         #endregion
+
+        #region 超支费用
+
+        /// <summary>
+        /// 超支费用
+        /// 1增、2改、3删
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostGroupExtraCost_Operator(Fin_GroupExtraCostDto_OP dto)
+        {
+            #region 验证
+
+            #endregion
+
+            Fin_GroupExtraCost _entity = new Fin_GroupExtraCost();
+            _entity.DiId = dto.diId;
+            _entity.PriceName = dto.priceName;
+            _entity.Price = dto.price;
+            _entity.PriceCurrency = dto.currency;
+            _entity.PriceType = dto.priceType;
+            _entity.Coefficient = dto.coefficient;
+            _entity.PriceDetailType = dto.priceDetailType;
+            _entity.FilePath = dto.filePath;
+            _entity.Remark = dto.remark;
+
+            _daiRep.BeginTran();
+            if (dto.editType == 1)
+            {
+                _entity.CreateUserId = dto.createUser;
+                _entity.CreateTime = DateTime.Now;
+                _entity.IsDel = 0;
+
+                int returnId = await _daiRep.AddAsyncReturnId<Fin_GroupExtraCost>(_entity);
+                if (returnId > 0)
+                {
+                    dto.Id = returnId;
+                }
+            }
+            else if (dto.editType == 2)
+            {
+                bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
+                {
+                    PriceName = dto.priceName,
+                    Price = dto.price,
+                    PriceCurrency = dto.currency,
+                    PriceType = dto.priceType,
+                    PriceDetailType = dto.priceDetailType,
+                    Coefficient = dto.coefficient,
+                    FilePath = dto.filePath,
+                    Remark = dto.remark
+                });
+                if (!res)
+                {
+                    _daiRep.RollbackTran();
+                    return Ok(JsonView(false, "2操作失败!"));
+                }
+            }
+            else if (dto.editType == 3)
+            {
+                string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
+                bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
+                {
+                    IsDel = 1,
+                    DeleteTime = delTime,
+                    DeleteUserId = dto.createUser
+                });
+                if (!res)
+                {
+                    _daiRep.RollbackTran();
+                    return Ok(JsonView(false, "3操作失败!"));
+                }
+            }
+            else
+            {
+                _daiRep.RollbackTran();
+                return Ok(JsonView(false, "未知的editType"));
+            }
+
+            if (!extraCost_editCreditCardPayment(dto))
+            {
+                return Ok(JsonView(false, "ccp操作失败"));
+            }
+
+
+            _daiRep.CommitTran();
+            return Ok(JsonView(false, "操作成功"));
+        }
+
+        private bool extraCost_editCreditCardPayment(Fin_GroupExtraCostDto_OP costDto)
+        {
+            //设置团组汇率
+            decimal dcm_dayrate = 1M;
+            decimal dcm_rmbPrice = costDto.price;
+            int ispay = costDto.payType == 72 ? 1 : 0;
+
+            if (costDto.costSign != 3)
+            {
+                Grp_TeamRate tr = _daiRep.Query<Grp_TeamRate>(s => s.DiId == costDto.diId && s.CTable == 1015).First();
+
+                if (tr != null)
+                {
+                    if (costDto.currency == 49)
+                    {
+                        dcm_dayrate = tr.RateU;
+                        dcm_rmbPrice = dcm_rmbPrice * tr.RateU;
+                    }
+                    else if (costDto.currency == 51)
+                    {
+                        dcm_dayrate = tr.RateE;
+                        dcm_rmbPrice = dcm_rmbPrice * tr.RateE;
+                    }
+                }
+            }
+
+            Grp_CreditCardPayment ccp = _daiRep.Query<Grp_CreditCardPayment>(s => s.CId == costDto.Id && s.CTable == 1015).First();
+            if (ccp == null)
+            {
+                ccp = new Grp_CreditCardPayment();
+
+                ccp.PayDId = costDto.payType;// dto
+                ccp.ConsumptionPatterns = "";
+                ccp.ConsumptionDate = "";
+                ccp.CTDId = costDto.payCardId;// dto
+                ccp.BankNo = "";
+
+                ccp.CardholderName = "";
+                ccp.PayMoney = costDto.price;// dto
+                ccp.PaymentCurrency = costDto.currency;// dto
+                ccp.CompanyBankNo = "";
+                ccp.OtherBankName = "";
+
+                ccp.OtherSideNo = "";
+                ccp.OtherSideName = "";
+                ccp.Remark = "";
+                ccp.CreateUserId = costDto.createUser;
+                ccp.CreateTime = DateTime.Now;
+
+                ccp.MFOperator = 0;
+                ccp.MFOperatorDate = "";
+                ccp.IsAuditDM = 0;
+                ccp.AuditDMOperate = 0;
+                ccp.AuditDMDate = "";
+
+                ccp.IsAuditMF = 0;
+                ccp.AuditMFOperate = 0;
+                ccp.AuditMFDate = "";
+                ccp.IsAuditGM = 0;
+                ccp.AuditGMOperate = 0;
+
+                ccp.AuditGMDate = "";
+                ccp.IsPay = ispay; // upd
+                ccp.DIId = costDto.diId;// dto
+                ccp.CId = costDto.Id;// dto
+                ccp.CTable = 1015; //超支费用指向id
+
+                ccp.IsDel = 0;
+                ccp.PayPercentage = 100M;
+                ccp.PayThenMoney = 0M;
+                ccp.PayPercentageOld = 100M;
+                ccp.PayThenMoneyOld = 0M;
+
+                ccp.UpdateDate = "";
+                ccp.Payee = costDto.payee;// dto
+                ccp.OrbitalPrivateTransfer = costDto.costSign;// dto
+                ccp.ExceedBudget = 0;
+                ccp.DayRate = dcm_dayrate; //upd
+
+                ccp.RMBPrice = dcm_rmbPrice; //upd
+
+                int ccpInsertId = _daiRep.AddReturnId<Grp_CreditCardPayment>(ccp);
+                if (ccpInsertId > 0)
+                {
+                    return true;
+                }
+            }
+            else
+            {
+                if (costDto.editType == 2)
+                {
+                    bool res = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
+                    {
+                        PayDId = costDto.payType,
+                        CTDId = costDto.payCardId,
+                        PayMoney = costDto.price,
+                        PaymentCurrency = costDto.currency,
+                        IsPay = ispay,
+
+                        Payee = costDto.payee,
+                        OrbitalPrivateTransfer = costDto.costSign,
+                        DayRate = dcm_dayrate,
+                        RMBPrice = dcm_rmbPrice
+                    });
+                    return res;
+                }
+                else if (costDto.editType == 3)
+                {
+                    string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
+                    bool res2 = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
+                    {
+                        IsDel = 1,
+                        DeleteTime = delTime,
+                        DeleteUserId = costDto.createUser
+                    });
+                    return res2;
+                }
+            }
+
+
+            return false;
+        }
+
+        /// <summary>
+        /// 超支费用
+        /// 列表查询
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostGroupExtraCost_Search(Fin_GroupExtraCostDto_Search dto)
+        {
+            string sqlWhere = string.Format(@" And f.DiId = {0} ", dto.diId);
+            int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
+            int endIndex = startIndex + dto.PageSize - 1;
+            string sql_data = string.Format(@"Select * From (	
+                                                Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
+												f.PriceName,f.Price,f.FilePath,f.CreateUserId,f.CreateTime,c.IsAuditGM
+                                                From Fin_GroupExtraCost f
+                                                Inner Join Grp_CreditCardPayment c On f.Id = c.CId
+                                                Left Join Sys_Users u On f.CreateUserId = u.Id
+                                                Where f.IsDel=0 And c.CTable = 1015 {0}
+                                                ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
+            string sql_count = string.Format(@"Select Count(1) as DataCount From (	
+                                                Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
+												f.PriceName,f.PriceType,f.Price,f.FilePath,f.CreateUserId,f.CreateTime,c.IsAuditGM
+                                                From Fin_GroupExtraCost f
+                                                Inner Join Grp_CreditCardPayment c On f.Id = c.CId
+                                                Left Join Sys_Users u On f.CreateUserId = u.Id
+                                                Where f.IsDel=0 And c.CTable = 1015 {0}
+                                                ) temp ", sqlWhere);
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
+            {
+                //Fin_DailyFeePaymentPageCount
+                var count = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostViewDataCount>(sql_count).FirstAsync();
+                List<Fin_GroupExtraCostView> dataList = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostView>(sql_data).ToListAsync();
+
+                Dictionary<int, string> dic_setData = new Dictionary<int, string>();
+                Dictionary<int, string> dic_user = new Dictionary<int, string>();
+
+                foreach (var item in dataList)
+                {
+                    //费用详细类型
+                    if (dic_setData.ContainsKey(item.PriceType))
+                    {
+                        item.PriceTypeStr = dic_setData[item.PriceType];
+                    }
+                    else
+                    {
+                        Sys_SetData sd_priceTypeDetail = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceType).First();
+                        if (sd_priceTypeDetail != null)
+                        {
+                            string tempName = sd_priceTypeDetail.Name.Replace("n", "");
+                            item.PriceTypeStr = tempName;
+                            dic_setData.Add(item.PriceType, tempName);
+                        }
+                    }
+
+                    //系统用户
+                    if (dic_user.ContainsKey(item.CreateUserId))
+                    {
+                        item.CreateUserIdStr = dic_setData[item.CreateUserId];
+                    }
+                    else
+                    {
+                        Sys_Users users = _daiRep.Query<Sys_Users>(s => s.Id == item.CreateUserId).First();
+                        if (users != null)
+                        {
+                            item.CreateUserIdStr = users.CnName;
+                            dic_setData.Add(item.CreateUserId, users.CnName);
+                        }
+                    }
+
+                    switch (item.IsAuditGM)
+                    {
+                        case 0: item.IsAuditGMStr = "未审核"; break;
+                        case 1: item.IsAuditGMStr = "已通过"; break;
+                        case 2: item.IsAuditGMStr = "未通过"; break;
+                        default: item.IsAuditGMStr = "未知状态"; break;
+                    }
+                }
+
+
+                var result = new ListViewBase<Fin_GroupExtraCostView>
+                {
+                    CurrPageIndex = dto.PageIndex,
+                    CurrPageSize = dto.PageSize,
+                    DataCount = count.DataCount,
+                    DataList = dataList
+                };
+
+                return Ok(JsonView(true, "查询成功", result));
+
+            }
+
+
+            return Ok(JsonView(false, "查询成功"));
+        }
+
+        /// <summary>
+        /// 超支费用
+        /// 数据集合配置
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostGroupExtraCost_ListDataInit(Fin_GroupExtraCostDto_DataListInit dto)
+        {
+            //支付方式
+            List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
+            List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
+
+            //超支费用类型
+            List<Sys_SetData> PriceType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 79 && a.IsDel == 0).ToList();
+            List<SetDataInfoView> _PriceType = _mapper.Map<List<SetDataInfoView>>(PriceType);
+
+            //超支费用详细类型
+            List<Sys_SetData> PriceDetailType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 80 && a.IsDel == 0).ToList();
+            PriceDetailType.ForEach(a => { a.Name = a.Name.Replace("n", ""); });
+            List<SetDataInfoView> _PriceDetailType = _mapper.Map<List<SetDataInfoView>>(PriceDetailType);
+
+            var data = new
+            {
+                Payment = _Payment,
+                PriceType = _PriceType,
+                PriceDetailType = _PriceDetailType
+            };
+
+
+            return Ok(JsonView(true, "", data));
+        }
+
+        #endregion
     }
 }

+ 94 - 0
OASystem/OASystem.Domain/Dtos/Financial/Fin_GroupExtraCostDto.cs

@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.Financial
+{
+    public class Fin_GroupExtraCostDto_OP : PortDtoBase
+    {
+
+        /// <summary>
+        /// 1新增,2修改,3删除
+        /// </summary>
+        public int editType { get; set; }
+
+        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>
+        /// 费用类型Id
+        /// </summary>
+        public int priceType { get; set; }
+
+        /// <summary>
+        /// 费用详细类型Id
+        /// </summary>
+        public int priceDetailType { get; set; }
+
+        /// <summary>
+        /// 系数
+        /// </summary>
+        public decimal coefficient { get; set; }
+
+        /// <summary>
+        /// 费用币种
+        /// </summary>
+        public int currency { get; set; }
+
+        /// <summary>
+        /// 收款方
+        /// </summary>
+        public string payee { get; set; }
+
+        /// <summary>
+        /// 费用标识
+        /// </summary>
+        public int costSign { get; set; }
+
+        /// <summary>
+        /// 支付方式
+        /// </summary>
+        public int payType { get; set; }
+
+        /// <summary>
+        /// 卡类型,支付方式为刷卡时有效
+        /// </summary>
+        public int payCardId { get; set; }
+
+        /// <summary>
+        /// 附件路径
+        /// </summary>
+        public string filePath { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string remark { get; set; }
+
+        /// <summary>
+        /// 操作人员
+        /// </summary>
+        public int createUser { get; set; }
+    }
+
+    public class Fin_GroupExtraCostDto_Search : DtoBase
+    {
+        public int diId { get; set; }
+    }
+
+    public class Fin_GroupExtraCostDto_DataListInit : PortDtoBase
+    {
+    }
+}

+ 35 - 0
OASystem/OASystem.Domain/ViewModels/Financial/Fin_GroupExtraCostView.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.Financial
+{
+    public class Fin_GroupExtraCostView
+    {
+        public int RowNumber { get; set; }
+        public int Id { get; set; }
+        public int DiId { get; set; }
+        public string PriceName { get; set; }
+        public int PriceType { get; set; }
+        public string PriceTypeStr { get; set; }
+        public decimal Price { get; set; }
+        public string FilePath { get; set; }
+        public int CreateUserId { get; set; }
+        public string CreateUserIdStr { get; set; }
+        public string CreateTime { get; set; }
+        public int IsAuditGM { get; set; }
+        public string IsAuditGMStr { get; set; }
+    }
+
+    public class Fin_GroupExtraCostViewDataCount
+    {
+        public int DataCount { get; set; }
+    }
+
+    public class Fin_GroupExtraCostView_List
+    {
+
+    }
+}

+ 26 - 0
OASystem/OASystem.Infrastructure/Repositories/BaseRepository.cs

@@ -132,6 +132,26 @@ namespace OASystem.Infrastructure.Repositories
             return _sqlSugar.Insertable(entity).ExecuteReturnIdentityAsync();
         }
 
+        /// <summary>
+        /// 添加返回主键Id(泛型)
+        /// </summary>
+        /// <param name="entity"></param>
+        /// <returns></returns>
+        public virtual Task<int> AddAsyncReturnId<T>(T entity) where T : EntityBase, new()
+        {
+            return _sqlSugar.Insertable<T>(entity).ExecuteReturnIdentityAsync();
+        }
+
+        /// <summary>
+        /// 添加返回主键Id(同步、泛型)
+        /// </summary>
+        /// <param name="entity"></param>
+        /// <returns></returns>
+        public virtual int AddReturnId<T>(T entity) where T : EntityBase, new()
+        {
+            return _sqlSugar.Insertable<T>(entity).ExecuteReturnIdentity();
+        }
+
         /// <summary>
         /// 删除单挑数据,加上删除者Id
         /// </summary>
@@ -262,6 +282,12 @@ namespace OASystem.Infrastructure.Repositories
             var result = await _sqlSugar.Updateable<T>().Where(wherexp).SetColumns(upexp).ExecuteCommandAsync();
             return result > 0;
         }
+
+        public virtual bool Update<T>(Expression<Func<T, bool>> wherexp, Expression<Func<T, T>> upexp) where T : EntityBase, new()
+        {
+            var result = _sqlSugar.Updateable<T>().Where(wherexp).SetColumns(upexp).ExecuteCommand();
+            return result > 0;
+        }
         public virtual async Task<bool> DeleteAsync<T>(Expression<Func<T, bool>> wherexp) where T : EntityBase, new()
         {
             var result = await _sqlSugar.Deleteable<T>().Where(wherexp).ExecuteCommandAsync();

+ 6 - 1
OASystem/OASystem.Infrastructure/Repositories/Groups/CarTouristGuideGroundRepository.cs

@@ -253,6 +253,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                 //获取成本选中
                 var checkTopArr = _checkRep.GetCheckBoxsByDiid(grpCarOp.DiId);
+                var checkedItem = new List<string>();
                 if (checkTopArr.Count > 0)
                 {
                     var FindTop = checkTopArr.Find(x => x.CbType == "Top");
@@ -265,7 +266,10 @@ namespace OASystem.Infrastructure.Repositories.Groups
                             if (find == null)
                             {
                                 var Lindex =  carTouristGuides.FindIndex(x=>x.SidName == soureKey);
-                                carTouristGuides.RemoveRange(Lindex , day + 1);
+                                //carTouristGuides.RemoveRange(Lindex, day + 1);
+                            } else
+                            {
+                                checkedItem.Add(soureKey);
                             }
                         }
                     }
@@ -280,6 +284,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     start,
                     end,
                     ssdv,
+                    checkedItem
                 };
 
                 return result = new Result() { Code = 0, Msg = "查询成功",Data=data };