123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- using OASystem.Domain;
- using OASystem.Domain.Dtos;
- using OASystem.Domain.Dtos.Group;
- using OASystem.Domain.Dtos.UserDto;
- using OASystem.Domain.Entities.Groups;
- using OASystem.Domain.ViewModels.Group;
- using OASystem.Infrastructure.Repositories.System;
- using Org.BouncyCastle.Utilities.Collections;
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OASystem.Infrastructure.Repositories.Group
- {
- /// <summary>
- /// 接团信息
- /// </summary>
- public class DelegationInfoRepository : BaseRepository<Grp_DelegationInfo, DelegationInfoView>
- {
- private readonly SetDataRepository _setDataRepository;
- private readonly UsersRepository _usersRepository;
- public DelegationInfoRepository(SqlSugarClient sqlSugar, SetDataRepository setDataRepository, UsersRepository usersRepository)
- : base(sqlSugar)
- {
- this._setDataRepository = setDataRepository;
- this._usersRepository = usersRepository;
- }
- /// <summary>
- /// 获取接团信息List
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- public async Task<Result> GetGroupList(GroupListDto dto)
- {
- Result result = new Result() { Code = -2,Msg="未知错误" };
- if (dto.PortType == 1) //web
- {
- string sql = string.Format(@"Select gdi.Id,SalesQuoteNo,TourCode,ssd.Name TeamType,ssd1.Name TeamLev,TeamName,ClientName,
- ClientUnit,VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure
- From Grp_DelegationInfo gdi
- Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0
- Order By VisitDate Desc");
-
- var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
- if (_DelegationList.Count > 0)
- {
- result.Code = 0;
- result.Msg = "成功!";
- result.Data = _DelegationList;
- }
- else
- {
- result.Msg = "暂无该团组信息";
- }
- }
-
-
- return result;
- }
- /// <summary>
- /// 获取接团信息Info
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- public async Task<Result> GetGroupInfo(GroupInfoDto dto)
- {
- Result result = new Result() { Code = -2, Msg = "未知错误" };
- if (dto.PortType == 1) //web
- {
- string sql = string.Format(@"Select Id,SalesQuoteNo,JietuanOperator,TeamLevSId,TeamDid,TeamName,ClientName,
- ClientUnit,VisitCountry,VisitDate,VisitDays,VisitPNumber,TontractTime,
- PayDay,PaymentMoney,VisitPurpose,SpecialNeeds,OtherNeeds,CGRWSPBMMC,CGRWSPWH,
- ZZSCBMMC,ZZSCSPWH,Remark,TellPhone
- From Grp_DelegationInfo Where Id = {0} And IsDel=0",dto.Id);
- var _DelegationInfo = await _sqlSugar.SqlQueryable<DelegationInfoWebView>(sql).ToListAsync();
- if (_DelegationInfo != null)
- {
- result.Code = 0;
- result.Msg = "成功!";
- result.Data = _DelegationInfo;
- }
- else
- {
- result.Msg = "暂无该团组信息";
- }
- }
- return result;
- }
- /// <summary>
- /// 获取接团信息 编辑
- /// 基础 数据源
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- public async Task<Result> GetGroupEditBasicSource(GroupListDto dto)
- {
- Result result = new Result() { Code = -2, Msg = "未知错误" };
- if (dto.PortType == 1) //web
- {
- dynamic? teamTypeData1 = null;
- string teamTypeSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = {0} And IsDel = {1}", 10, 0);
- var teamTypeData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamTypeSql).ToListAsync(); ; //团组分类 10
- if (teamTypeData.Count > 0)
- {
- teamTypeData1 = teamTypeData;
- }
- dynamic? teamLevData1 = null;
- string teamLevSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = {0} And IsDel = {1}", 56, 0);
- var teamLevData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamLevSql).ToListAsync(); ; //团组等级 56
- if (teamLevData.Count > 0)
- {
- teamLevData1 = teamLevData;
- }
- dynamic? userData1 = null;
- string userSql = string.Format(@"Select Id,CnName From Sys_Users Where IsDel = {0}", 0);
- var userData = await _sqlSugar.SqlQueryable<UserNameView>(userSql).ToListAsync(); ;
- if (userData.Count > 0)
- {
- userData1 = userData;
- }
- result.Code = 0;
- result.Msg = "成功!";
- result.Data = new {
- teamTypeData = teamTypeData1,
- teamLevData = teamLevData1,
- userData = userData1
- };
- }
- return result;
- }
- /// <summary>
- /// 团组信息操作
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- public async Task<Result> GroupOperation(GroupOperationDto dto)
- {
- Result result = new Result() { Code = -2, Msg = "未知错误" };
- if (dto.PortType == 1) //web
- {
- Grp_DelegationInfo groupInfo = new Grp_DelegationInfo()
- {
- SalesQuoteNo = dto.SalesQuoteNo,
- TeamLevSId = dto.TeamLevSId,
- ClientName = dto.ClientName,
- ClientUnit = dto.ClientUnit,
- TeamName = dto.TeamName,
- TeamDid = dto.TeamDid,
- VisitDate = dto.VisitDate,
- VisitCountry = dto.VisitCountry,
- VisitPurpose = dto.VisitPurpose,
- VisitDays = dto.VisitDays,
- VisitPNumber = dto.VisitPNumber,
- SpecialNeeds = dto.SpecialNeeds,
- OtherNeeds = dto.OtherNeeds,
- Remark = dto.Remark,
- JietuanOperator = dto.UserId,
- TellPhone = dto.TellPhone,
- CGRWSPBMMC = dto.CGRWSPBMMC,
- CGRWSPWH = dto.CGRWSPWH,
- ZZSCBMMC = dto.ZZSCBMMC,
- ZZSCSPWH = dto.ZZSCSPWH,
- TontractTime = dto.TontractTime,
- PaymentMoney = dto.PaymentMoney,
- PayDay = dto.PayDay
- };
- if (dto.Status == 1) //添加
- {
- string selectSql = string.Format(@"Select * From Grp_DelegationInfo
- Where IsDel = 0
- And SalesQuoteNo = '{0}'
- And TeamName = '{1}'
- And ClientName = '{2}'
- And ClientUnit ='{3}'
- And VisitDate ='{4}'",dto.SalesQuoteNo,dto.TeamName,dto.ClientName,dto.ClientUnit,dto.VisitDate);
- var selectGroupInfo = await _sqlSugar.SqlQueryable<Grp_DelegationInfo>(selectSql).FirstAsync();
- if (selectGroupInfo != null)
- {
- result.Msg = "数据已存在,请勿重复添加!";
- return result;
- }
- string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
- var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).FirstAsync();
- string teamCode = "";
- while (true)
- {
- teamCode = Tools.CommonFun.GetRandomAllStr(6);
-
- if (!teamCodeItem.Equals(teamCode))
- {
- break;
- }
- }
- groupInfo.TourCode = teamCode;
- groupInfo.SalesDate = DateTime.Now;
- groupInfo.IsState = 0; //默认团组未完成 0
- groupInfo.JietuanTime = DateTime.Now;
- groupInfo.IsDel = 0;
- groupInfo.BudgetCost = 0.00M;
- groupInfo.HotelComplain = 0;
- groupInfo.OPComplain = 0;
- groupInfo.OAComplain = 0;
- groupInfo.AirComplain = 0;
- groupInfo.VisaComplain = 0;
- groupInfo.CreateUserId = dto.UserId;
- groupInfo.CreateTime = DateTime.Now;
- groupInfo.DeleteUserId = null;
- groupInfo.DeleteTime = new DateTime(1990, 1, 1).ToString("yyyy-MM-dd HH:mm:ss");
- var addId = await _sqlSugar.Insertable(groupInfo).ExecuteReturnIdentityAsync();
- if (addId > 0)
- {
- result.Code = 0;
- result.Msg = "添加成功!";
- }
- else
- {
- result.Msg = "添加失败!";
- }
- }
- else if (dto.Status == 2) //修改
- {
- var updateStatus = await UpdateAsync(a => a.Id == dto.Id,a=> groupInfo);
- if (updateStatus)
- {
- result.Code = 0;
- result.Msg = "修改成功!";
- }
- else
- {
- result.Msg = "修改失败!";
- }
- }
- }
-
- return result;
- }
- }
- }
|