|  | @@ -3,6 +3,7 @@ using NPOI.POIFS.Crypt.Dsig;
 | 
	
		
			
				|  |  |  using OASystem.Domain;
 | 
	
		
			
				|  |  |  using OASystem.Domain.Dtos.Financial;
 | 
	
		
			
				|  |  |  using OASystem.Domain.Dtos.Groups;
 | 
	
		
			
				|  |  | +using OASystem.Domain.Entities.Customer;
 | 
	
		
			
				|  |  |  using OASystem.Domain.Entities.Financial;
 | 
	
		
			
				|  |  |  using OASystem.Domain.Entities.Groups;
 | 
	
		
			
				|  |  |  using OASystem.Domain.ViewModels.Financial;
 | 
	
	
		
			
				|  | @@ -50,16 +51,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  |                      UserId = "0";
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                string sqlWhere = string.Empty;
 | 
	
		
			
				|  |  | -                if (!string.IsNullOrWhiteSpace(dto.ClientName))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    sqlWhere = string.Format(@"Where h.DiId={0} and h.IsDel={1} And h.CreateUserId in ({2}) and h.ClientName like '%{3}%'", dto.DiId, 0, UserId,dto.ClientName);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    sqlWhere = string.Format(@"Where h.DiId={0} and h.IsDel={1} And h.CreateUserId in ({2})", dto.DiId, 0, UserId);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | +                string sqlWhere = string.Format(@"Where h.DiId={0} and h.IsDel={1} And h.CreateUserId in ({2})", dto.DiId, 0, UserId);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
 | 
	
		
			
				|  |  |                  int endIndex = startIndex + dto.PageSize - 1;
 | 
	
	
		
			
				|  | @@ -71,6 +63,19 @@ namespace OASystem.Infrastructure.Repositories.Groups
 | 
	
		
			
				|  |  |                                                      left Join Sys_SetData s on  h.Currency=s.Id
 | 
	
		
			
				|  |  |                                                      left Join Sys_Users u on u.Id=h.CreateUserId {0} order by c.IsAuditGM,c.PayPercentage,h.CreateTime desc", sqlWhere);
 | 
	
		
			
				|  |  |                      List<CustomersView> Customers = _sqlSugar.SqlQueryable<CustomersView>(sql).ToList();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    var parseIntValue = 0;
 | 
	
		
			
				|  |  | +                    var CrmIds = (from item in Customers
 | 
	
		
			
				|  |  | +                                 where item.ClientName.Contains(",") || int.TryParse(item.ClientName, out parseIntValue)
 | 
	
		
			
				|  |  | +                                 select item.ClientName).ToList();
 | 
	
		
			
				|  |  | +                    var strCrmIds = string.Join(',', CrmIds);
 | 
	
		
			
				|  |  | +                    List<Crm_DeleClient> clietArr = new List<Crm_DeleClient>();
 | 
	
		
			
				|  |  | +                    if (!string.IsNullOrWhiteSpace(strCrmIds))
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        sql = string.Format("SELECT * FROM Crm_DeleClient cdc where id in ({0}) and IsDel  = 0", strCrmIds);
 | 
	
		
			
				|  |  | +                        clietArr = _sqlSugar.SqlQueryable<Crm_DeleClient>(sql).ToList();
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                      foreach (var item in Customers)
 | 
	
		
			
				|  |  |                      {
 | 
	
		
			
				|  |  |                          if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
 | 
	
	
		
			
				|  | @@ -81,7 +86,44 @@ namespace OASystem.Infrastructure.Repositories.Groups
 | 
	
		
			
				|  |  |                          if (item.OrbitalPrivateTransfer == 0) item.OrbitalPrivateTransferStr = "公转";
 | 
	
		
			
				|  |  |                          else if (item.OrbitalPrivateTransfer == 1) item.OrbitalPrivateTransferStr = "私转";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +                        if (item.ClientName.Contains(","))
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            var splitArr = item.ClientName.Split(',');
 | 
	
		
			
				|  |  | +                            var name = string.Empty;
 | 
	
		
			
				|  |  | +                            foreach (var client in splitArr)
 | 
	
		
			
				|  |  | +                            {
 | 
	
		
			
				|  |  | +                                if (int.TryParse(client, out parseIntValue))
 | 
	
		
			
				|  |  | +                                {
 | 
	
		
			
				|  |  | +                                   var clientObject = clietArr.Find(x => x.Id == parseIntValue);
 | 
	
		
			
				|  |  | +                                   name += (clientObject?.LastName + clientObject?.FirstName + " ");
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            if (!string.IsNullOrWhiteSpace(name))
 | 
	
		
			
				|  |  | +                            {
 | 
	
		
			
				|  |  | +                                item.ClientName = name;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            continue;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        if (int.TryParse(item.ClientName, out parseIntValue))
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            var name = string.Empty;
 | 
	
		
			
				|  |  | +                            var clientObject = clietArr.Find(x => x.Id == parseIntValue);
 | 
	
		
			
				|  |  | +                            name += (clientObject?.LastName + clientObject?.FirstName);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            if (!string.IsNullOrWhiteSpace(name))
 | 
	
		
			
				|  |  | +                            {
 | 
	
		
			
				|  |  | +                                item.ClientName = name;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            continue;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    if (!string.IsNullOrWhiteSpace(dto.ClientName))
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        Customers = Customers.Where(x => x.ClientName.Contains(dto.ClientName)).ToList();
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                      return result = new Result() { Code = 0, Msg = "查询成功!", Data = Customers };
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  else if (dto.PortType == 2 || dto.PortType == 3)
 | 
	
	
		
			
				|  | @@ -96,6 +138,19 @@ namespace OASystem.Infrastructure.Repositories.Groups
 | 
	
		
			
				|  |  |                                                  ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      List<CustomersView> Customers = _sqlSugar.SqlQueryable<CustomersView>(sql).ToList();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    var parseIntValue = 0;
 | 
	
		
			
				|  |  | +                    var CrmIds = (from item in Customers
 | 
	
		
			
				|  |  | +                                  where item.ClientName.Contains(",") || int.TryParse(item.ClientName, out parseIntValue)
 | 
	
		
			
				|  |  | +                                  select item.ClientName).ToList();
 | 
	
		
			
				|  |  | +                    var strCrmIds = string.Join(',', CrmIds);
 | 
	
		
			
				|  |  | +                    List<Crm_DeleClient> clietArr = new List<Crm_DeleClient>();
 | 
	
		
			
				|  |  | +                    if (!string.IsNullOrWhiteSpace(strCrmIds))
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        sql = string.Format("SELECT * FROM Crm_DeleClient cdc where id in ({0}) and IsDel  = 0", strCrmIds);
 | 
	
		
			
				|  |  | +                        clietArr = _sqlSugar.SqlQueryable<Crm_DeleClient>(sql).ToList();
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                      foreach (var item in Customers)
 | 
	
		
			
				|  |  |                      {
 | 
	
		
			
				|  |  |                          if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
 | 
	
	
		
			
				|  | @@ -105,6 +160,51 @@ namespace OASystem.Infrastructure.Repositories.Groups
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                          if (item.OrbitalPrivateTransfer == 0) item.OrbitalPrivateTransferStr = "公转";
 | 
	
		
			
				|  |  |                          else if (item.OrbitalPrivateTransfer == 1) item.OrbitalPrivateTransferStr = "私转";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        if (item.ClientName.Contains(","))
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            var splitArr = item.ClientName.Split(',');
 | 
	
		
			
				|  |  | +                            var name = string.Empty;
 | 
	
		
			
				|  |  | +                            var i = 0;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            while (i < splitArr.Count())
 | 
	
		
			
				|  |  | +                            {
 | 
	
		
			
				|  |  | +                                if (int.TryParse(splitArr[i], out parseIntValue))
 | 
	
		
			
				|  |  | +                                {
 | 
	
		
			
				|  |  | +                                    var clientObject = clietArr.Find(x => x.Id == parseIntValue);
 | 
	
		
			
				|  |  | +                                    name += (clientObject?.LastName + clientObject?.FirstName);
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                                i++;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                                if (i < splitArr.Count())
 | 
	
		
			
				|  |  | +                                {
 | 
	
		
			
				|  |  | +                                    name += "[*TuT*]";
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            if (!string.IsNullOrWhiteSpace(name))
 | 
	
		
			
				|  |  | +                            {
 | 
	
		
			
				|  |  | +                                item.ClientName = name.TrimEnd();
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            continue;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        if (int.TryParse(item.ClientName, out parseIntValue))
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            var name = string.Empty;
 | 
	
		
			
				|  |  | +                            var clientObject = clietArr.Find(x => x.Id == parseIntValue);
 | 
	
		
			
				|  |  | +                            name += (clientObject?.LastName + clientObject?.FirstName);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            if (!string.IsNullOrWhiteSpace(name))
 | 
	
		
			
				|  |  | +                            {
 | 
	
		
			
				|  |  | +                                item.ClientName = name;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            continue;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      string CountSql = string.Format(@"Select COUNT(1) as Count From (	
 | 
	
		
			
				|  |  |                                                      select h.Id,h.ClientName,InsuranceCosts,Currency,s.Name as CurrencyStr,Attachment,c.OrbitalPrivateTransfer,u.CnName,c.IsAuditGM
 | 
	
	
		
			
				|  | @@ -213,45 +313,45 @@ namespace OASystem.Infrastructure.Repositories.Groups
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  //卡类型
 | 
	
		
			
				|  |  |                  List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
 | 
	
		
			
				|  |  | -                List<SetDataCurrencyInfoView> _BankCard = _mapper.Map<List<SetDataCurrencyInfoView>>(BankCard).Where(s=> (s.Currency ?? "") == "CNY" ).ToList();
 | 
	
		
			
				|  |  | +                List<SetDataCurrencyInfoView> _BankCard = _mapper.Map<List<SetDataCurrencyInfoView>>(BankCard);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  //保险名称
 | 
	
		
			
				|  |  | -                //List<Grp_InsuranceCost> _InsuranceCosts=_sqlSugar.Queryable<Grp_InsuranceCost>().Where(a=>a.IsDel==0).ToList();
 | 
	
		
			
				|  |  | -                //List<InsuranceCostView> insuranceCostViews = new List<InsuranceCostView>();
 | 
	
		
			
				|  |  | -                //foreach (var item in _InsuranceCosts)
 | 
	
		
			
				|  |  | -                //{
 | 
	
		
			
				|  |  | -                //    InsuranceCostView costView=new InsuranceCostView();
 | 
	
		
			
				|  |  | -                //    costView.Id=item.Id;
 | 
	
		
			
				|  |  | -                //    costView.GName=item.GName;
 | 
	
		
			
				|  |  | -                //    costView.Balance = 0.00M;
 | 
	
		
			
				|  |  | -                //    string CountSql = string.Format(@"select sum(InsuranceCosts) as CountCost from Grp_Customers where isdel=0 and Iid=" + item.Id);
 | 
	
		
			
				|  |  | -                //    DataCountCost dataCount = _sqlSugar.SqlQueryable<DataCountCost>(CountSql).First();
 | 
	
		
			
				|  |  | -                //    costView.Balance = Math.Round(item.RechargeCost - dataCount.CountCost, 2);
 | 
	
		
			
				|  |  | -                //    insuranceCostViews.Add(costView);
 | 
	
		
			
				|  |  | -                //}
 | 
	
		
			
				|  |  | +                List<Grp_InsuranceCost> _InsuranceCosts=_sqlSugar.Queryable<Grp_InsuranceCost>().Where(a=>a.IsDel==0).ToList();
 | 
	
		
			
				|  |  | +                List<InsuranceCostView> insuranceCostViews = new List<InsuranceCostView>();
 | 
	
		
			
				|  |  | +                foreach (var item in _InsuranceCosts)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    InsuranceCostView costView=new InsuranceCostView();
 | 
	
		
			
				|  |  | +                    costView.Id=item.Id;
 | 
	
		
			
				|  |  | +                    costView.GName=item.GName;
 | 
	
		
			
				|  |  | +                    costView.Balance = 0.00M;
 | 
	
		
			
				|  |  | +                    string CountSql = string.Format(@"select sum(InsuranceCosts) as CountCost from Grp_Customers where isdel=0 and Iid=" + item.Id);
 | 
	
		
			
				|  |  | +                    DataCountCost dataCount = _sqlSugar.SqlQueryable<DataCountCost>(CountSql).First();
 | 
	
		
			
				|  |  | +                    costView.Balance = Math.Round(item.RechargeCost - dataCount.CountCost, 2);
 | 
	
		
			
				|  |  | +                    insuranceCostViews.Add(costView);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                  //币种
 | 
	
		
			
				|  |  | -                //GeneralTeamRateInfoDto PostGroupTeamRatedto = new GeneralTeamRateInfoDto();
 | 
	
		
			
				|  |  | -                //PostGroupTeamRatedto.DiId = dto.DiId;
 | 
	
		
			
				|  |  | -                //PostGroupTeamRatedto.CTable = 82;
 | 
	
		
			
				|  |  | -                //PostGroupTeamRatedto.PortType = dto.PortType;
 | 
	
		
			
				|  |  | -                //Result teamRateDescAddCurrencyIdViews = _hotel.PostGroupTeamRateByDiIdAndCTableId(PostGroupTeamRatedto);
 | 
	
		
			
				|  |  | +                GeneralTeamRateInfoDto PostGroupTeamRatedto = new GeneralTeamRateInfoDto();
 | 
	
		
			
				|  |  | +                PostGroupTeamRatedto.DiId = dto.DiId;
 | 
	
		
			
				|  |  | +                PostGroupTeamRatedto.CTable = 82;
 | 
	
		
			
				|  |  | +                PostGroupTeamRatedto.PortType = dto.PortType;
 | 
	
		
			
				|  |  | +                Result teamRateDescAddCurrencyIdViews = _hotel.PostGroupTeamRateByDiIdAndCTableId(PostGroupTeamRatedto);
 | 
	
		
			
				|  |  |                  List<TeamRateDescAddCurrencyIdView> Currency = new List<TeamRateDescAddCurrencyIdView>();
 | 
	
		
			
				|  |  | -                TeamRateDescAddCurrencyIdView cny = new TeamRateDescAddCurrencyIdView() { CurrencyCode = "CNY", CurrencyId = 836, CurrencyName = "人民币", Rate = 1 }; //保险修改,只要人民币
 | 
	
		
			
				|  |  | -                Currency.Add(cny);
 | 
	
		
			
				|  |  | -                //if (teamRateDescAddCurrencyIdViews.Code == 0)
 | 
	
		
			
				|  |  | -                //{
 | 
	
		
			
				|  |  | -                //    Currency = teamRateDescAddCurrencyIdViews.Data;
 | 
	
		
			
				|  |  | -                //}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                //insuranceCost = insuranceCostViews,
 | 
	
		
			
				|  |  | -                    var data = new
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        Payment = _Payment,
 | 
	
		
			
				|  |  | -                        CurrencyList = Currency,
 | 
	
		
			
				|  |  | -                        BankCard = _BankCard,
 | 
	
		
			
				|  |  | -                    };
 | 
	
		
			
				|  |  | -                    return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | +                if (teamRateDescAddCurrencyIdViews.Code == 0)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    Currency = teamRateDescAddCurrencyIdViews.Data;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                var data = new
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    Payment = _Payment,
 | 
	
		
			
				|  |  | +                    CurrencyList = Currency,
 | 
	
		
			
				|  |  | +                    BankCard = _BankCard,
 | 
	
		
			
				|  |  | +                    insuranceCost = insuranceCostViews,
 | 
	
		
			
				|  |  | +                };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              catch (Exception ex)
 | 
	
		
			
				|  |  |              {
 |