DelegationInfoRepository.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  1. using AutoMapper;
  2. using Newtonsoft.Json;
  3. using NPOI.OpenXmlFormats.Wordprocessing;
  4. using NPOI.SS.Formula.Functions;
  5. using OASystem.Domain;
  6. using OASystem.Domain.AesEncryption;
  7. using OASystem.Domain.Dtos;
  8. using OASystem.Domain.Dtos.Financial;
  9. using OASystem.Domain.Dtos.Groups;
  10. using OASystem.Domain.Dtos.UserDto;
  11. using OASystem.Domain.Entities.Customer;
  12. using OASystem.Domain.Entities.Groups;
  13. using OASystem.Domain.ViewModels.CRM;
  14. using OASystem.Domain.ViewModels.Financial;
  15. using OASystem.Domain.ViewModels.Groups;
  16. using OASystem.Infrastructure.Repositories.System;
  17. using Org.BouncyCastle.Asn1.Cms;
  18. using Org.BouncyCastle.Utilities.Collections;
  19. using Serilog;
  20. using SqlSugar;
  21. using System;
  22. using System.Collections.Generic;
  23. using System.Linq;
  24. using System.Text;
  25. using System.Threading.Tasks;
  26. namespace OASystem.Infrastructure.Repositories.Groups
  27. {
  28. /// <summary>
  29. /// 接团信息
  30. /// </summary>
  31. public class DelegationInfoRepository : BaseRepository<Grp_DelegationInfo, DelegationInfoView>
  32. {
  33. private readonly SetDataRepository _setDataRepository;
  34. private readonly UsersRepository _usersRepository;
  35. private readonly TaskAssignmentRepository _taskAssignmentRep;
  36. private readonly IMapper _mapper;
  37. //private readonly TeamRateRepository _teamRateRep;
  38. //public readonly Logs _logs;
  39. public DelegationInfoRepository(SqlSugarClient sqlSugar, SetDataRepository setDataRepository, UsersRepository usersRepository,
  40. TaskAssignmentRepository taskAssignmentRep, IMapper mapper)
  41. : base(sqlSugar)
  42. {
  43. _setDataRepository = setDataRepository;
  44. _usersRepository = usersRepository;
  45. _taskAssignmentRep = taskAssignmentRep;
  46. _mapper = mapper;
  47. //_teamRateRep = teamRateRep;
  48. }
  49. #region 团组信息 团组详情共享Api
  50. /// <summary>
  51. /// 团组信息 团组预览详情共享Api
  52. /// </summary>
  53. /// <param name="dto"></param>
  54. /// <returns></returns>
  55. public async Task<Result> PostShareGroupInfo(ShareGroupInfoDto dto)
  56. {
  57. Result result = new Result() { Code = -2, Msg = "未知错误" };
  58. string sql = string.Format(@"Select Id,TeamName,TourCode,ClientName,VisitCountry,VisitStartDate,VisitEndDate,VisitDays,VisitPNumber
  59. From Grp_DelegationInfo Where Id = {0} And IsDel = 0", dto.Id);
  60. if (dto.PortType == 1) //Web
  61. {
  62. var _DelegationInfo = await _sqlSugar.SqlQueryable<Web_ShareGroupInfoView>(sql).FirstAsync();
  63. if (_DelegationInfo != null)
  64. {
  65. _DelegationInfo.VisitCountry = FormartTeamName(_DelegationInfo.VisitCountry);
  66. }
  67. else result.Msg = "暂无该团组信息";
  68. result.Data = _DelegationInfo;
  69. }
  70. else if (dto.PortType == 2 || dto.PortType == 3) //IOS Or Android
  71. {
  72. var _DelegationInfo = await _sqlSugar.SqlQueryable<IOSOrAndroid_ShareGroupInfoView>(sql).FirstAsync();
  73. if (_DelegationInfo != null)
  74. {
  75. _DelegationInfo.VisitCountry = FormartTeamName(_DelegationInfo.VisitCountry);
  76. result.Data = _DelegationInfo;
  77. }
  78. else result.Msg = "暂无该团组信息";
  79. result.Data = _DelegationInfo;
  80. }
  81. else result.Msg = "请输入正确的端口号。1 Web 2 Android 3 IOS";
  82. result.Code = 0;
  83. result.Msg = "成功!";
  84. return result;
  85. }
  86. /// <summary>
  87. /// 团组信息List 团组预览详情共享Api
  88. /// </summary>
  89. /// <param name="dto"></param>
  90. /// <returns></returns>
  91. public async Task<Result> PostShareGroupInfos(int portType)
  92. {
  93. Result result = new Result() { Code = -2, Msg = "未知错误", Data = new List<object>() { } };
  94. string sql = string.Format(@"Select Id,TeamName,TourCode,ClientName,VisitCountry,VisitStartDate,VisitEndDate,VisitDays,VisitPNumber
  95. From Grp_DelegationInfo With(NoLock) Where IsDel = 0 Order By Id Desc");
  96. var _DelegationInfo = await _sqlSugar.SqlQueryable<Web_ShareGroupInfoView>(sql).ToListAsync();
  97. if (_DelegationInfo.Count > 0)
  98. {
  99. foreach (var item in _DelegationInfo)
  100. {
  101. item.VisitCountry = FormartTeamName(item.VisitCountry);
  102. }
  103. }
  104. else { result.Msg = "暂无该团组信息"; return result; }
  105. if (portType == 1) //Web
  106. {
  107. result.Data = _DelegationInfo;
  108. }
  109. else if (portType == 2 || portType == 3) //IOS Or Android
  110. {
  111. result.Data = _DelegationInfo;
  112. }
  113. else { result.Msg = "请输入正确的端口号。1 Web 2 Android 3 IOS"; return result; }
  114. result.Code = 0;
  115. result.Msg = "成功!";
  116. return result;
  117. }
  118. #endregion
  119. /// <summary>
  120. /// 获取接团信息Info
  121. /// </summary>
  122. /// <param name="dto"></param>
  123. /// <returns></returns>
  124. public async Task<Result> PostGroupInfo(GroupInfoDto dto)
  125. {
  126. Result result = new Result() { Code = -2, Msg = "未知错误" };
  127. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //Web Or Android
  128. {
  129. string sql = string.Format(@"Select Id,SalesQuoteNo,TourCode,JietuanOperator,TeamLevSId,TeamDid,TeamName,ClientName,
  130. ClientUnit,VisitCountry,VisitDate,VisitDays,VisitPNumber,TontractTime,
  131. PayDay,PaymentMoney,VisitPurpose,SpecialNeeds,OtherNeeds,CGRWSPBMMC,CGRWSPWH,
  132. ZZSCBMMC,ZZSCSPWH,Remark,TellPhone,Officialneeds
  133. From Grp_DelegationInfo Where Id = {0} And IsDel = 0", dto.Id);
  134. var _DelegationInfo = await _sqlSugar.SqlQueryable<DelegationInfoWebView>(sql).FirstAsync();
  135. if (_DelegationInfo != null)
  136. {
  137. _DelegationInfo.TeamName = FormartTeamName(_DelegationInfo.TeamName);
  138. result.Code = 0;
  139. result.Msg = "成功!";
  140. result.Data = _DelegationInfo;
  141. }
  142. else result.Msg = "暂无该团组信息";
  143. }
  144. return result;
  145. }
  146. #region 团组
  147. /// <summary>
  148. /// 统一团组国家分割字符
  149. /// </summary>
  150. /// <param name="teamName"></param>
  151. /// <returns></returns>
  152. public string FormartTeamName(string? teamName)
  153. {
  154. string str = "";
  155. if (!string.IsNullOrEmpty(teamName))
  156. {
  157. str = teamName;
  158. List<string> searchreplaces = new List<string>() { "|", " ", "/", ",", "," };
  159. foreach (var item in searchreplaces)
  160. {
  161. if (str.Contains(item))
  162. {
  163. str = str.Replace(item, "、");
  164. break;
  165. }
  166. }
  167. }
  168. return str.Trim();
  169. }
  170. /// <summary>
  171. /// 团组国家分割字符
  172. /// 返回 国家数组
  173. /// </summary>
  174. /// <param name="teamName"></param>
  175. /// <returns></returns>
  176. public List<string> GroupSplitCountry (string visitCountry)
  177. {
  178. List<string> countrys = new List<string>();
  179. if (!string.IsNullOrEmpty(visitCountry))
  180. {
  181. if (visitCountry.Contains("、")) countrys = visitCountry.Split("、").ToList();
  182. else if (visitCountry.Contains("|")) countrys = visitCountry.Split("|").ToList();
  183. else countrys.Add(visitCountry);
  184. }
  185. return countrys;
  186. }
  187. /// <summary>
  188. /// 获取接团信息 Page List
  189. /// </summary>
  190. /// <param name="dto"></param>
  191. /// <returns></returns>
  192. public async Task<Result> GetGroupPageList(GroupCommissionDto dto)
  193. {
  194. Result result = new Result() { Code = -2, Msg = "未知错误" };
  195. ListViewBase<DelegationPageListView> groupsInfoPageList = new ListViewBase<DelegationPageListView>()
  196. {
  197. ReceiveDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  198. };
  199. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  200. {
  201. int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
  202. int endIndex = startIndex + dto.PageSize - 1;
  203. //int taskUserId = -1;
  204. string taskGroupIds = string.Empty;
  205. #region 处理用户团组操作权限
  206. if (dto.UserId != -1)
  207. {
  208. }
  209. #endregion
  210. string sql = string.Format(@"Select * From(Select row_number() over (order by gdi.Id Desc) as RowNumber,
  211. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,ssd1.Id TeamLevId,
  212. ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,VisitDate,VisitDays,VisitPNumber,
  213. su.CnName JietuanOperator,IsSure
  214. From Grp_DelegationInfo gdi
  215. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  216. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  217. Left Join Sys_Users su On gdi.CreateUserId = su.Id
  218. Where gdi.IsDel = 0
  219. )temp Where RowNumber Between {0} and {1}", startIndex, endIndex);
  220. string sqlCount = string.Format(@"Select Count(1) as Count From Grp_DelegationInfo gdi
  221. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  222. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  223. Left Join Sys_Users su On gdi.CreateUserId = su.Id
  224. Where gdi.IsDel = 0 ");
  225. List<DelegationPageListView> _DeleInfoList = await _sqlSugar.SqlQueryable<DelegationPageListView>(sql).ToListAsync();
  226. DelegationPageCountView _DeleCount = await _sqlSugar.SqlQueryable<DelegationPageCountView>(sqlCount).FirstAsync();
  227. int count = _DeleCount.Count;
  228. groupsInfoPageList = new ListViewBase<DelegationPageListView>
  229. {
  230. CurrPageIndex = dto.PageIndex,
  231. CurrPageSize = dto.PageSize,
  232. DataCount = count,
  233. DataList = _DeleInfoList
  234. };
  235. result.Code = 0;
  236. result.Msg = "成功!";
  237. result.Data = groupsInfoPageList;
  238. }
  239. return result;
  240. }
  241. /// <summary>
  242. /// 获取接团信息List
  243. /// </summary>
  244. /// <param name="dto"></param>
  245. /// <returns></returns>
  246. public async Task<Result> GetGroupList(GroupListDto dto)
  247. {
  248. Result result = new Result() { Code = -2, Msg = "未知错误" };
  249. if (dto.PortType == 1) {
  250. string sql = string.Format(@"Select gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure
  251. ,gs.Id as GrpScheduleId
  252. From Grp_DelegationInfo gdi
  253. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  254. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  255. Left Join Sys_Users su On gdi.CreateUserId = su.Id
  256. left Join Grp_Schedule gs On gdi.Id = gs.DiId
  257. Where gdi.IsDel = 0
  258. Order By gdi.CreateTime Desc");
  259. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  260. if (_DelegationList.Count > 0)
  261. {
  262. result.Code = 0;
  263. result.Msg = "成功!";
  264. result.Data = _DelegationList;
  265. }
  266. else
  267. {
  268. result.Msg = "暂无该团组信息";
  269. }
  270. }
  271. else if (dto.PortType == 2 || dto.PortType == 3) //web
  272. {
  273. string sql = string.Format(@"Select gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure
  274. From Grp_DelegationInfo gdi
  275. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  276. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  277. Left Join Sys_Users su On gdi.CreateUserId = su.Id
  278. Where gdi.IsDel = 0
  279. Order By gdi.CreateTime Desc");
  280. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  281. if (_DelegationList.Count > 0)
  282. {
  283. result.Code = 0;
  284. result.Msg = "成功!";
  285. result.Data = _DelegationList;
  286. }
  287. else
  288. {
  289. result.Msg = "暂无该团组信息";
  290. }
  291. }
  292. return result;
  293. }
  294. /// <summary>
  295. /// 获取接团信息Info
  296. /// </summary>
  297. /// <param name="dto"></param>
  298. /// <returns></returns>
  299. public async Task<Result> GetGroupInfo(GroupInfoDto dto)
  300. {
  301. Result result = new Result() { Code = -2, Msg = "未知错误" };
  302. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //Web Or Android
  303. {
  304. string sql = string.Format(@"Select Id,SalesQuoteNo,TourCode,JietuanOperator,TeamLevSId,TeamDid,TeamName,ClientName,
  305. ClientUnit,VisitCountry,VisitDate,VisitDays,VisitPNumber,TontractTime,IsBid,
  306. PayDay,PaymentMoney,VisitPurpose,SpecialNeeds,OtherNeeds,CGRWSPBMMC,CGRWSPWH,
  307. ZZSCBMMC,ZZSCSPWH,Remark,TellPhone,WeChatNo,OpRoyaltyLv,OpRoyaltyRemark,Officialneeds
  308. From Grp_DelegationInfo Where Id = {0} And IsDel = 0", dto.Id);
  309. var _DelegationInfo = await _sqlSugar.SqlQueryable<DelegationInfoWebView>(sql).FirstAsync();
  310. if (_DelegationInfo != null)
  311. {
  312. _DelegationInfo.TeamName = FormartTeamName(_DelegationInfo.TeamName);
  313. _DelegationInfo.VisitCountry = FormartTeamName(_DelegationInfo.VisitCountry);
  314. //if (_DelegationInfo.TontractTime)
  315. //{
  316. //}
  317. result.Code = 0;
  318. result.Msg = "成功!";
  319. result.Data = _DelegationInfo;
  320. if (dto.PortType == 2)
  321. {
  322. var GroupProcessOperationDtoParam = new GroupProcessOperationDto();
  323. GroupProcessOperationDtoParam = _mapper.Map<DelegationInfoWebView, GroupProcessOperationDto>(_DelegationInfo);
  324. List<Crm_DeleClient> DeleClientArr = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync(); //客户信息
  325. List<Grp_TourClientList> _DeleClients = await _sqlSugar.Queryable<Grp_TourClientList>().Where(it => it.IsDel == 0 && it.DiId == dto.Id).ToListAsync(); // 接团客户名单
  326. List<Crm_CustomerCert> _CustomerCerts = await _sqlSugar.Queryable<Crm_CustomerCert>().Where(it => it.IsDel == 0 && it.SdId == 773).ToListAsync(); // 身份证类型证件信息
  327. List<Crm_CustomerCompany> CompanyArr = await _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToListAsync();
  328. var TourClientListInfoArr = new List<TourClientListProcessInfo>();
  329. var timeParam = new DateTime();
  330. foreach (var item in _DeleClients)
  331. {
  332. var param = new TourClientListProcessInfo();
  333. var clientInfo = DeleClientArr.FirstOrDefault(x => x.Id == item.ClientId);
  334. if (clientInfo == null) clientInfo = new Crm_DeleClient();
  335. var clientIDInfo = _CustomerCerts.FirstOrDefault(x=>x.DcId == item.ClientId); //身份证信息
  336. if (clientIDInfo == null) clientIDInfo = new Crm_CustomerCert();
  337. var Company = CompanyArr.FirstOrDefault(x => x.Id == clientInfo.CrmCompanyId);
  338. if(Company == null) Company = new Crm_CustomerCompany();
  339. param.IDCardNo = clientIDInfo.CertNo;
  340. param.Remark = item.Remark;
  341. param.BirthDay = clientInfo.BirthDay == null ? "" : DateTime.TryParse(Convert.ToDateTime( clientInfo.BirthDay).ToString("yyyy-MM-dd"), out timeParam) ? timeParam.ToString("yyyy-MM-dd") : "";
  342. param.FirstName = clientInfo.FirstName;
  343. param.LastName = clientInfo.LastName;
  344. param.CompanyFullName = Company.CompanyFullName;
  345. param.Job = clientInfo.Job;
  346. param.Sex = clientInfo.Sex;
  347. param.Phone = clientInfo.Phone;
  348. param.Pinyin = clientInfo.Pinyin;
  349. param.HotelSpecialNeeds = item.HotelSpecialNeeds;
  350. param.MealSpecialNeeds = item.MealSpecialNeeds;
  351. param.ShippingSpaceSpecialNeeds = item.ShippingSpaceSpecialNeeds;
  352. param.ShippingSpaceTypeId = item.ShippingSpaceTypeId;
  353. param.Id = clientInfo.Id;
  354. EncryptionProcessor.DecryptProperties(param);
  355. TourClientListInfoArr.Add(param);
  356. }
  357. GroupProcessOperationDtoParam.PortType = dto.PortType;
  358. GroupProcessOperationDtoParam.TourClientListInfos = TourClientListInfoArr;
  359. GroupProcessOperationDtoParam.VisitDate = DateTime.TryParse(GroupProcessOperationDtoParam.VisitDate, out timeParam) ? timeParam.ToString("yyyy-MM-dd") : "";
  360. GroupProcessOperationDtoParam.VisitDate = DateTime.TryParse(GroupProcessOperationDtoParam.VisitDate, out timeParam) ? timeParam.ToString("yyyy-MM-dd") : "";
  361. GroupProcessOperationDtoParam.TontractTime = DateTime.TryParse(GroupProcessOperationDtoParam.TontractTime, out timeParam) ? timeParam.ToString("yyyy-MM-dd") : "";
  362. result.Data = GroupProcessOperationDtoParam;
  363. }
  364. else if (dto.PortType == 3)
  365. {
  366. var GroupProcessOperationDtoParam = new GroupProcessOperationDto();
  367. GroupProcessOperationDtoParam = _mapper.Map<DelegationInfoWebView, GroupProcessOperationDto>(_DelegationInfo);
  368. List<Crm_DeleClient> DeleClientArr = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync(); //客户信息
  369. List<Grp_TourClientList> _DeleClients = await _sqlSugar.Queryable<Grp_TourClientList>().Where(it => it.IsDel == 0 && it.DiId == dto.Id).ToListAsync(); // 接团客户名单
  370. List<Crm_CustomerCert> _CustomerCerts = await _sqlSugar.Queryable<Crm_CustomerCert>().Where(it => it.IsDel == 0 && it.SdId == 773).ToListAsync(); // 身份证类型证件信息
  371. List<Crm_CustomerCompany> CompanyArr = await _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToListAsync();
  372. var TourClientListInfoArr = new List<TourClientListProcessInfo>();
  373. var timeParam = new DateTime();
  374. foreach (var item in _DeleClients)
  375. {
  376. var param = new TourClientListProcessInfo();
  377. var clientInfo = DeleClientArr.FirstOrDefault(x => x.Id == item.ClientId);
  378. if (clientInfo == null) clientInfo = new Crm_DeleClient();
  379. var clientIDInfo = _CustomerCerts.FirstOrDefault(x => x.DcId == item.ClientId); //身份证信息
  380. if (clientIDInfo == null) clientIDInfo = new Crm_CustomerCert();
  381. var Company = CompanyArr.FirstOrDefault(x => x.Id == clientInfo.CrmCompanyId);
  382. if (Company == null) Company = new Crm_CustomerCompany();
  383. param.IDCardNo = clientIDInfo.CertNo;
  384. param.Remark = item.Remark;
  385. param.BirthDay = clientInfo.BirthDay == null ? "" : DateTime.TryParse(Convert.ToDateTime(clientInfo.BirthDay).ToString("yyyy-MM-dd"), out timeParam) ? timeParam.ToString("yyyy-MM-dd") : "";
  386. param.FirstName = clientInfo.FirstName;
  387. param.LastName = clientInfo.LastName;
  388. param.CompanyFullName = Company.CompanyFullName;
  389. param.Job = clientInfo.Job;
  390. param.Sex = clientInfo.Sex;
  391. param.Phone = clientInfo.Phone;
  392. param.Pinyin = clientInfo.Pinyin;
  393. param.HotelSpecialNeeds = item.HotelSpecialNeeds;
  394. param.MealSpecialNeeds = item.MealSpecialNeeds;
  395. param.ShippingSpaceSpecialNeeds = item.ShippingSpaceSpecialNeeds;
  396. param.ShippingSpaceTypeId = item.ShippingSpaceTypeId;
  397. param.Id = item.Id;
  398. EncryptionProcessor.DecryptProperties(param);
  399. TourClientListInfoArr.Add(param);
  400. }
  401. GroupProcessOperationDtoParam.PortType = dto.PortType;
  402. GroupProcessOperationDtoParam.TourClientListInfos = TourClientListInfoArr;
  403. GroupProcessOperationDtoParam.VisitDate = DateTime.TryParse(GroupProcessOperationDtoParam.VisitDate, out timeParam) ? timeParam.ToString("yyyy-MM-dd") : "";
  404. GroupProcessOperationDtoParam.TontractTime = DateTime.TryParse(GroupProcessOperationDtoParam.TontractTime, out timeParam) ? timeParam.ToString("yyyy-MM-dd") : "";
  405. result.Data = GroupProcessOperationDtoParam;
  406. }
  407. }
  408. else result.Msg = "暂无该团组信息";
  409. }
  410. return result;
  411. }
  412. /// <summary>
  413. /// 获取接团信息 编辑
  414. /// 基础 数据源
  415. /// </summary>
  416. /// <param name="dto"></param>
  417. /// <returns></returns>
  418. public async Task<Result> GroupEditBasicSource(GroupListDto dto)
  419. {
  420. Result result = new Result() { Code = -2, Msg = "未知错误" };
  421. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  422. {
  423. dynamic? teamTypeData1 = null;
  424. string teamTypeSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = {0} And IsDel = {1}", 10, 0);
  425. var teamTypeData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamTypeSql).ToListAsync(); ; //团组分类 10
  426. if (teamTypeData.Any())
  427. {
  428. teamTypeData1 = teamTypeData;
  429. }
  430. dynamic? teamLevData1 = null;
  431. string teamLevSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = {0} And IsDel = {1}", 56, 0);
  432. var teamLevData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamLevSql).ToListAsync(); ; //团组等级 56
  433. if (teamLevData.Any())
  434. {
  435. teamLevData1 = teamLevData;
  436. }
  437. dynamic? userData1 = null;
  438. string userSql = string.Format(@"Select Id,CnName From Sys_Users Where IsDel = {0}", 0);
  439. var userData = await _sqlSugar.SqlQueryable<UserNameView>(userSql).ToListAsync();
  440. if (userData.Any())
  441. {
  442. userData1 = userData;
  443. }
  444. //客户单位数据源 来源市场客户资料
  445. dynamic? clientData1 = null;
  446. string clientSql = $@"Select Client,Contact,Telephone,WeChat From Crm_NewClientData Where IsDel = 0";
  447. var clientData = await _sqlSugar.SqlQueryable<Crm_NewClientData>(clientSql).ToListAsync();
  448. if (clientData.Any())
  449. {
  450. clientData1 = clientData.Select(it => new
  451. {
  452. Client = AesEncryptionHelper.Decrypt(it.Client),
  453. Contact = AesEncryptionHelper.Decrypt(it.Contact),
  454. Telephone = AesEncryptionHelper.Decrypt(it.Telephone),
  455. Wechat = AesEncryptionHelper.Decrypt(it.Wechat)
  456. }).ToList();
  457. }
  458. result.Code = 0;
  459. result.Msg = "成功!";
  460. result.Data = new
  461. {
  462. teamTypeData = teamTypeData1,
  463. teamLevData = teamLevData1,
  464. userData = userData1,
  465. clientData = clientData1
  466. };
  467. }
  468. return result;
  469. }
  470. /// <summary>
  471. /// 团组信息操作
  472. /// </summary>
  473. /// <param name="dto"></param>
  474. /// <returns></returns>
  475. public async Task<Result>GroupOperation(GroupOperationDto dto)
  476. {
  477. Result result = new Result() { Code = -2, Msg = "未知错误" };
  478. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  479. {
  480. #region 添加出访起止时间
  481. var startTime = new DateTime();
  482. var endTime = new DateTime();
  483. if (DateTime.TryParse(dto.VisitDate, out startTime))
  484. {
  485. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  486. }
  487. #endregion
  488. if (dto.Status == 1) //添加
  489. {
  490. string selectSql = string.Format(@"Select * From Grp_DelegationInfo
  491. Where IsDel = 0
  492. And TeamName = '{0}'
  493. And ClientName = '{1}'
  494. And ClientUnit ='{2}'
  495. And VisitDate ='{3}'",dto.TeamName, dto.ClientName, dto.ClientUnit, dto.VisitDate);
  496. var selectGroupInfo = _sqlSugar.SqlQueryable<Grp_DelegationInfo>(selectSql).First();
  497. if (selectGroupInfo != null)
  498. {
  499. result.Msg = "数据已存在,请勿重复添加!";
  500. return result;
  501. }
  502. //string teamCodeSql = string.Format("Select SalesQuoteNo From Grp_DelegationInfo");
  503. //var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
  504. //string SalesQuoteNo = "";
  505. //while (true)
  506. //{
  507. // SalesQuoteNo = Tools.CommonFun.GetRandomStr(6);
  508. // if (!teamCodeItem.Equals(SalesQuoteNo))
  509. // {
  510. // break;
  511. // }
  512. //}
  513. string countrys = string.Empty;
  514. string countryReq = dto.VisitCountry;
  515. if (!string.IsNullOrEmpty(countryReq))
  516. {
  517. if (countryReq.Contains(",")) countrys = countryReq.Replace(',','|');
  518. else if (countryReq.Contains(",")) countrys = countryReq.Replace(',', '|');
  519. else if (countryReq.Contains(" ")) countrys = countryReq.Replace(' ', '|');
  520. else if (countryReq.Contains("、")) countrys = countryReq.Replace('、', '|');
  521. else if (countryReq.Contains(".")) countrys = countryReq.Replace('.', '|');
  522. else countrys = countryReq;
  523. }
  524. //建团时 默认出团 设置 团组code
  525. string teamCode="";
  526. string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
  527. var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
  528. while (true)
  529. {
  530. teamCode = Tools.CommonFun.GetRandomAllStr(6);
  531. if (!teamCodeItem.Equals(teamCode))
  532. {
  533. break;
  534. }
  535. }
  536. Grp_DelegationInfo delegationInfo = new Grp_DelegationInfo()
  537. {
  538. SalesQuoteNo = dto.SalesQuoteNo,
  539. TeamLevSId = dto.TeamLevSId,
  540. ClientName = dto.ClientName,
  541. ClientUnit = dto.ClientUnit,
  542. TeamName = dto.TeamName,
  543. TeamDid = dto.TeamDid,
  544. VisitDate = Convert.ToDateTime(dto.VisitDate),
  545. VisitCountry = countrys,
  546. VisitPurpose = dto.VisitPurpose,
  547. VisitDays = dto.VisitDays,
  548. VisitPNumber = dto.VisitPNumber,
  549. SpecialNeeds = dto.SpecialNeeds,
  550. OtherNeeds = dto.OtherNeeds,
  551. Remark = dto.Remark,
  552. JietuanOperator = dto.JietuanOperator,
  553. TellPhone = dto.TellPhone,
  554. WeChatNo = dto.WeChatNo,
  555. CGRWSPBMMC = dto.CGRWSPBMMC,
  556. CGRWSPWH = dto.CGRWSPWH,
  557. ZZSCBMMC = dto.ZZSCBMMC,
  558. ZZSCSPWH = dto.ZZSCSPWH,
  559. TontractTime = string.IsNullOrEmpty(dto.TontractTime) ? null : Convert.ToDateTime(dto.TontractTime),
  560. IsBid = dto.IsBid,
  561. PaymentMoney = dto.PaymentMoney,
  562. PayDay = dto.PayDay,
  563. TourCode = teamCode,
  564. GroupsOperator = dto.UserId,
  565. GroupsTime = DateTime.Now,
  566. SalesDate = DateTime.Now,
  567. IsState = 0, //默认团组未完成 0
  568. JietuanTime = DateTime.Now,
  569. IsDel = 0,
  570. BudgetCost = 0.00M,
  571. HotelComplain = 0,
  572. OPComplain = 0,
  573. OAComplain = 0,
  574. AirComplain = 0,
  575. VisaComplain = 0,
  576. CreateUserId = dto.UserId,
  577. CreateTime = DateTime.Now,
  578. DeleteUserId = null,
  579. DeleteTime = new DateTime(1990, 1, 1).ToString("yyyy-MM-dd HH:mm:ss"),
  580. OpRoyaltyLv = dto.OpRoyaltyLv,
  581. OpRoyaltyRemark=dto.opRoyaltyRemark,
  582. Officialneeds = dto.Officialneeds,
  583. VisitStartDate = startTime,
  584. VisitEndDate = endTime,
  585. };
  586. var addId = _sqlSugar.Insertable(delegationInfo).ExecuteReturnIdentity();
  587. if (addId > 0)
  588. {
  589. result.Code = 0;
  590. result.Msg = "添加成功!";
  591. result.Data = addId;
  592. }
  593. else
  594. {
  595. result.Msg = "添加失败!";
  596. }
  597. }
  598. else if (dto.Status == 2) //修改
  599. {
  600. var updateStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
  601. {
  602. SalesQuoteNo = dto.SalesQuoteNo,
  603. TeamLevSId = dto.TeamLevSId,
  604. ClientName = dto.ClientName,
  605. ClientUnit = dto.ClientUnit,
  606. TeamName = dto.TeamName,
  607. TeamDid = dto.TeamDid,
  608. VisitDate = Convert.ToDateTime(dto.VisitDate),
  609. VisitCountry = dto.VisitCountry,
  610. VisitPurpose = dto.VisitPurpose,
  611. VisitDays = dto.VisitDays,
  612. VisitPNumber = dto.VisitPNumber,
  613. SpecialNeeds = dto.SpecialNeeds,
  614. OtherNeeds = dto.OtherNeeds,
  615. Remark = dto.Remark,
  616. JietuanOperator = dto.JietuanOperator,
  617. TellPhone = dto.TellPhone,
  618. WeChatNo = dto.WeChatNo,
  619. CGRWSPBMMC = dto.CGRWSPBMMC,
  620. CGRWSPWH = dto.CGRWSPWH,
  621. ZZSCBMMC = dto.ZZSCBMMC,
  622. ZZSCSPWH = dto.ZZSCSPWH,
  623. TontractTime = string.IsNullOrEmpty(dto.TontractTime) ? null : Convert.ToDateTime(dto.TontractTime),
  624. IsBid = dto.IsBid,
  625. PaymentMoney = dto.PaymentMoney,
  626. PayDay = dto.PayDay,
  627. OpRoyaltyLv = dto.OpRoyaltyLv,
  628. OpRoyaltyRemark = dto.opRoyaltyRemark,
  629. Officialneeds = dto.Officialneeds,
  630. VisitStartDate = startTime,
  631. VisitEndDate = endTime,
  632. });
  633. if (updateStatus)
  634. {
  635. result.Code = 0;
  636. result.Msg = "修改成功!";
  637. }
  638. else
  639. {
  640. result.Msg = "修改失败!";
  641. }
  642. }
  643. else if (dto.Status == 3) //删除
  644. {
  645. var deleteStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
  646. {
  647. DeleteUserId = dto.UserId,
  648. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  649. IsDel = 1
  650. });
  651. if (deleteStatus)
  652. {
  653. result.Code = 0;
  654. result.Msg = "删除成功!";
  655. }
  656. else
  657. {
  658. result.Msg = "删除失败!";
  659. }
  660. }
  661. }
  662. return result;
  663. }
  664. /// <summary>
  665. /// 团组信息操作 - 删除
  666. /// </summary>
  667. /// <param name="dto"></param>
  668. /// <returns></returns>
  669. public async Task<Result> GroupDel(GroupDelDto dto)
  670. {
  671. Result result = new Result() { Code = -2, Msg = "未知错误" };
  672. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  673. {
  674. var deleteStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
  675. {
  676. DeleteUserId = dto.UserId,
  677. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  678. IsDel = 1
  679. });
  680. if (deleteStatus)
  681. {
  682. result.Code = 0;
  683. result.Msg = "删除成功!";
  684. }
  685. else
  686. {
  687. result.Msg = "删除失败!";
  688. }
  689. }
  690. return result;
  691. }
  692. /// <summary>
  693. /// 获取销售报价号
  694. /// </summary>
  695. /// <returns></returns>
  696. public async Task<Result> GetGroupSalesQuoteNo()
  697. {
  698. Result result = new Result() { Code = -2, Msg = "未知错误" };
  699. string teamCodeSql = string.Format("Select SalesQuoteNo From Grp_DelegationInfo");
  700. var teamCodeItem = await _sqlSugar.SqlQueryable<SalesQuoteNoView>(teamCodeSql).ToListAsync();
  701. string teamCode = "";
  702. while (true)
  703. {
  704. teamCode = Tools.CommonFun.GetRandomAllStr(6);
  705. if (!teamCodeItem.Equals(teamCode))
  706. {
  707. break;
  708. }
  709. }
  710. result.Code = 0;
  711. result.Msg = "成功!";
  712. result.Data = teamCode;
  713. return result;
  714. }
  715. /// <summary>
  716. /// 团组删除
  717. /// </summary>
  718. /// <returns></returns>
  719. public async Task<Result> GroupDeleteById()
  720. {
  721. Result result = new Result() { Code = -2, Msg = "未知错误" };
  722. string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
  723. var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
  724. string teamCode = "";
  725. while (true)
  726. {
  727. teamCode = Tools.CommonFun.GetRandomAllStr(6);
  728. if (!teamCodeItem.Equals(teamCode))
  729. {
  730. break;
  731. }
  732. }
  733. result.Code = 0;
  734. result.Msg = "成功!";
  735. result.Data = teamCode;
  736. return result;
  737. }
  738. /// <summary>
  739. /// 团组确认出团
  740. /// </summary>
  741. /// <returns></returns>
  742. public async Task<Result> ConfirmationGroup(ConfirmationGroupDto dto)
  743. {
  744. Result result = new Result() { Code = -2, Msg = "未知错误" };
  745. string teamCode = "";
  746. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  747. {
  748. string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
  749. var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
  750. while (true)
  751. {
  752. teamCode = Tools.CommonFun.GetRandomAllStr(6);
  753. if (!teamCodeItem.Equals(teamCode))
  754. {
  755. break;
  756. }
  757. }
  758. var deleteStatus = await UpdateAsync(a => a.Id == dto.GroupId, a => new Grp_DelegationInfo
  759. {
  760. TourCode = teamCode,
  761. GroupsOperator = dto.GroupsOperator,
  762. GroupsTime = DateTime.Now
  763. });
  764. if (deleteStatus)
  765. {
  766. result.Code = 0;
  767. result.Msg = "确认出团设置成功!";
  768. }
  769. else
  770. {
  771. result.Msg = "确认出团设置失败!";
  772. }
  773. }
  774. result.Code = 0;
  775. result.Msg = "成功!";
  776. result.Data = teamCode;
  777. return result;
  778. }
  779. /// <summary>
  780. /// 获取接团名称List
  781. /// </summary>
  782. /// <param name="dto"></param>
  783. /// <returns></returns>
  784. public async Task<Result> GetGroupNameList(GroupNameDto dto)
  785. {
  786. Result result = new Result() { Code = -2, Msg = "未知错误" };
  787. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  788. {
  789. string sql = string.Format(@"Select Id,TeamName GroupName From Grp_DelegationInfo
  790. Where TeamName != '' And IsDel = 0
  791. Order By Id Desc");
  792. var _groupNameList = await _sqlSugar.SqlQueryable<GroupNameView>(sql).ToListAsync();
  793. if (_groupNameList.Count > 0)
  794. {
  795. for (int i = 0; i < _groupNameList.Count; i++)
  796. {
  797. var info = _groupNameList[i];
  798. _groupNameList[i].GroupName = FormartTeamName(info.GroupName);
  799. }
  800. result.Code = 0;
  801. result.Msg = "成功!";
  802. result.Data = _groupNameList;
  803. }
  804. else
  805. {
  806. result.Msg = "暂无团组信息";
  807. }
  808. }
  809. return result;
  810. }
  811. //PostGroupNameScreen
  812. /// <summary>
  813. /// 获取接团名称 Page List
  814. /// </summary>
  815. /// <param name="dto"></param>
  816. /// <returns></returns>
  817. public async Task<JsonView> GetGroupNameList(int portType,int pageIndex,int pageSize, string groupName,int userId)
  818. {
  819. var _res = new JsonView() { Code = 400 , Msg = MsgTips.Fail };
  820. string sql = "";
  821. string sqlWhere = "";
  822. string mobileSqlWhere = "";
  823. if (!string.IsNullOrEmpty(groupName))
  824. {
  825. sqlWhere += string.Format($@"And TeamName Like '%{groupName}%'");
  826. mobileSqlWhere += string.Format($@"GroupName Like '%{groupName}%'");
  827. }
  828. List<int> userIds = new List<int>() { -1, 21 };
  829. if (!userIds.Contains(userId))
  830. {
  831. sqlWhere += string.Format($@"And JietuanOperator = {userId}");
  832. }
  833. sql = string.Format($@"Select ROW_NUMBER()Over(Order By Id Desc) as RowNumber,Id,TeamName GroupName From Grp_DelegationInfo
  834. Where IsDel = 0 {sqlWhere}");
  835. if (portType == 1) //web
  836. { }
  837. else if (portType == 2 || portType == 3)
  838. {
  839. //国交部 7 (主管 22,经理 32)团操操作权限 市场部 6 接团人
  840. var userInfo = await _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == userId && it.IsDel == 0).FirstAsync();
  841. if (userInfo != null)
  842. {
  843. if (userInfo.DepId == 7)
  844. {
  845. if (userInfo.JobPostId != 22 || userInfo.JobPostId != 32)
  846. {
  847. if (!string.IsNullOrEmpty(mobileSqlWhere)) mobileSqlWhere = $" Where {mobileSqlWhere}";
  848. sql = string.Format($@"Select
  849. ROW_NUMBER()Over(Order By Id Desc) as RowNumber,
  850. Id,
  851. GroupName
  852. From (
  853. Select
  854. distinct
  855. di.Id,
  856. di.TeamName GroupName
  857. From Grp_GroupsTaskAssignment gta With(NoLock)
  858. Inner Join Grp_DelegationInfo di With(NoLock) On gta.DIId = di.Id
  859. Where gta.IsDel = 0 And di.IsDel = 0 And gta.UId = {userId}
  860. ) Temp {mobileSqlWhere}");
  861. }
  862. }
  863. }
  864. }
  865. RefAsync<int> total = 0;
  866. var groupNamePageData = await _sqlSugar.SqlQueryable<GroupNamePageView>(sql).ToPageListAsync(pageIndex, pageSize, total);
  867. _res.Code = 200;
  868. _res.Data = groupNamePageData;
  869. _res.Msg = MsgTips.Succeed;
  870. _res.Count = total;
  871. return _res;
  872. }
  873. /// <summary>
  874. /// 获取接团名称List And 签证国别
  875. /// </summary>
  876. /// <param name="dto"></param>
  877. /// <returns></returns>
  878. public async Task<Result> GetGroupNameAndVisaNationality(GroupNameDto dto)
  879. {
  880. Result result = new Result() { Code = -2, Msg = "未知错误" };
  881. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  882. {
  883. string sql = string.Format(@"Select Id,TeamName GroupName From Grp_DelegationInfo
  884. Where TeamName != '' And IsDel = 0
  885. Order By Id Desc");
  886. var _groupNameList = await _sqlSugar.SqlQueryable<GroupNameView>(sql).ToListAsync();
  887. string visaSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = 41 And IsDel = 0");
  888. var _setDataList = await _sqlSugar.SqlQueryable<SetDataInfoView>(visaSql).ToListAsync();
  889. var data = new {
  890. groupNameData = _groupNameList,
  891. visaNationalityData = _setDataList
  892. };
  893. result.Data = data;
  894. result.Code = 0;
  895. }
  896. return result;
  897. }
  898. #endregion
  899. #region 团组&签证
  900. /// <summary>
  901. /// 根据团组Id查询客户
  902. /// </summary>
  903. /// <param name="dto"></param>
  904. /// <returns></returns>
  905. public async Task<Result> GetCrmByGroupId(ClientByGroupIdDto dto)
  906. {
  907. Result result = new Result() { Code = -2 };
  908. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
  909. {
  910. string sql = string.Format(@"Select gdjc.GrpDCId grpId,cdc.Id,cdc.LastName+cdc.FirstName clientName,cdc.Tel,ccc.CertNo CerdNo
  911. From Grp_DelegationJoinCustomer gdjc
  912. Inner join Crm_DeleClient cdc On gdjc.CrmDCId = cdc.Id
  913. Left Join Crm_CustomerCert ccc On ccc.SdId = 773 And cdc.Id = ccc.DcId
  914. Where gdjc.GrpDCId = {0}", dto.GroupId);
  915. var clientList = await _sqlSugar.SqlQueryable<CrmByGroupIdView>(sql).ToListAsync();
  916. if (clientList.Count > 0)
  917. {
  918. result.Code = 0;
  919. result.Msg = "成功!";
  920. result.Data = clientList;
  921. }
  922. else
  923. {
  924. result.Msg = "暂无数据!";
  925. }
  926. }
  927. return result;
  928. }
  929. #endregion
  930. #region 团组&出入境费用
  931. /// <summary>
  932. /// 获取单组名称并验证出入境费用明细是否填写
  933. /// </summary>
  934. /// <param name="dto"></param>
  935. /// <returns></returns>
  936. public async Task<Result> EnterExitCostGroupNameAsync()
  937. {
  938. var result = new Result() { Code = -2, Msg = "未知错误" };
  939. var groupSql = string.Format(@$"SELECT
  940. Id,
  941. TeamName GroupName,
  942. CASE
  943. WHEN (
  944. SELECT
  945. COUNT(*)
  946. FROM
  947. Grp_EnterExitCost
  948. WHERE
  949. IsDel = 0
  950. AND DiId = di.Id
  951. ) > 0 THEN 'false'
  952. ELSE 'true'
  953. END AS [IsNull]
  954. FROM
  955. Grp_DelegationInfo di
  956. WHERE
  957. di.Isdel = 0
  958. ORDER BY
  959. CreateTime Desc");
  960. result.Data = await _sqlSugar.SqlQueryable<EnterExitCostGroupNameView>(groupSql).ToListAsync();
  961. result.Code = 0;
  962. return result;
  963. }
  964. #endregion
  965. }
  966. }