DelegationInfoRepository.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140
  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. var userDepDatas = new List<TextView>();
  459. userDepDatas.Insert(0, new TextView() { Text = "全部", Value = "全部" });
  460. userDepDatas.Insert(1, new TextView() { Text = "国交部", Value = "国交部" });
  461. userDepDatas.Insert(2, new TextView() { Text = "市场部", Value = "市场部" });
  462. userDepDatas.Insert(3, new TextView() { Text = "策划部", Value = "策划部" });
  463. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new TextView { Value = x.Id.ToString(), Text = x.Name }).ToListAsync();
  464. rankDatas.Insert(0, new TextView { Value = "0", Text = "全部" });
  465. result.Code = 0;
  466. result.Msg = "成功!";
  467. result.Data = new
  468. {
  469. teamTypeData = teamTypeData1,
  470. teamLevData = teamLevData1,
  471. userData = userData1,
  472. clientData = clientData1,
  473. depData = userDepDatas,
  474. rankData = rankDatas
  475. };
  476. }
  477. return result;
  478. }
  479. /// <summary>
  480. /// 团组信息操作
  481. /// </summary>
  482. /// <param name="dto"></param>
  483. /// <returns></returns>
  484. public async Task<Result>GroupOperation(GroupOperationDto dto)
  485. {
  486. Result result = new Result() { Code = -2, Msg = "未知错误" };
  487. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  488. {
  489. #region 添加出访起止时间
  490. var startTime = new DateTime();
  491. var endTime = new DateTime();
  492. if (DateTime.TryParse(dto.VisitDate, out startTime))
  493. {
  494. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  495. }
  496. #endregion
  497. if (dto.Status == 1) //添加
  498. {
  499. string selectSql = string.Format(@"Select * From Grp_DelegationInfo
  500. Where IsDel = 0
  501. And TeamName = '{0}'
  502. And ClientName = '{1}'
  503. And ClientUnit ='{2}'
  504. And VisitDate ='{3}'",dto.TeamName, dto.ClientName, dto.ClientUnit, dto.VisitDate);
  505. var selectGroupInfo = _sqlSugar.SqlQueryable<Grp_DelegationInfo>(selectSql).First();
  506. if (selectGroupInfo != null)
  507. {
  508. result.Msg = "数据已存在,请勿重复添加!";
  509. return result;
  510. }
  511. //string teamCodeSql = string.Format("Select SalesQuoteNo From Grp_DelegationInfo");
  512. //var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
  513. //string SalesQuoteNo = "";
  514. //while (true)
  515. //{
  516. // SalesQuoteNo = Tools.CommonFun.GetRandomStr(6);
  517. // if (!teamCodeItem.Equals(SalesQuoteNo))
  518. // {
  519. // break;
  520. // }
  521. //}
  522. string countrys = string.Empty;
  523. string countryReq = dto.VisitCountry;
  524. if (!string.IsNullOrEmpty(countryReq))
  525. {
  526. if (countryReq.Contains(",")) countrys = countryReq.Replace(',','|');
  527. else if (countryReq.Contains(",")) countrys = countryReq.Replace(',', '|');
  528. else if (countryReq.Contains(" ")) countrys = countryReq.Replace(' ', '|');
  529. else if (countryReq.Contains("、")) countrys = countryReq.Replace('、', '|');
  530. else if (countryReq.Contains(".")) countrys = countryReq.Replace('.', '|');
  531. else countrys = countryReq;
  532. }
  533. //建团时 默认出团 设置 团组code
  534. string teamCode="";
  535. string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
  536. var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
  537. while (true)
  538. {
  539. teamCode = Tools.CommonFun.GetRandomAllStr(6);
  540. if (!teamCodeItem.Equals(teamCode))
  541. {
  542. break;
  543. }
  544. }
  545. Grp_DelegationInfo delegationInfo = new Grp_DelegationInfo()
  546. {
  547. SalesQuoteNo = dto.SalesQuoteNo,
  548. TeamLevSId = dto.TeamLevSId,
  549. ClientName = dto.ClientName,
  550. ClientUnit = dto.ClientUnit,
  551. TeamName = dto.TeamName,
  552. TeamDid = dto.TeamDid,
  553. VisitDate = Convert.ToDateTime(dto.VisitDate),
  554. VisitCountry = countrys,
  555. VisitPurpose = dto.VisitPurpose,
  556. VisitDays = dto.VisitDays,
  557. VisitPNumber = dto.VisitPNumber,
  558. SpecialNeeds = dto.SpecialNeeds,
  559. OtherNeeds = dto.OtherNeeds,
  560. Remark = dto.Remark,
  561. JietuanOperator = dto.JietuanOperator,
  562. TellPhone = dto.TellPhone,
  563. WeChatNo = dto.WeChatNo,
  564. CGRWSPBMMC = dto.CGRWSPBMMC,
  565. CGRWSPWH = dto.CGRWSPWH,
  566. ZZSCBMMC = dto.ZZSCBMMC,
  567. ZZSCSPWH = dto.ZZSCSPWH,
  568. TontractTime = string.IsNullOrEmpty(dto.TontractTime) ? null : Convert.ToDateTime(dto.TontractTime),
  569. IsBid = dto.IsBid,
  570. PaymentMoney = dto.PaymentMoney,
  571. PayDay = dto.PayDay,
  572. TourCode = teamCode,
  573. GroupsOperator = dto.UserId,
  574. GroupsTime = DateTime.Now,
  575. SalesDate = DateTime.Now,
  576. IsState = 0, //默认团组未完成 0
  577. JietuanTime = DateTime.Now,
  578. IsDel = 0,
  579. BudgetCost = 0.00M,
  580. HotelComplain = 0,
  581. OPComplain = 0,
  582. OAComplain = 0,
  583. AirComplain = 0,
  584. VisaComplain = 0,
  585. CreateUserId = dto.UserId,
  586. CreateTime = DateTime.Now,
  587. DeleteUserId = null,
  588. DeleteTime = new DateTime(1990, 1, 1).ToString("yyyy-MM-dd HH:mm:ss"),
  589. OpRoyaltyLv = dto.OpRoyaltyLv,
  590. OpRoyaltyRemark=dto.opRoyaltyRemark,
  591. Officialneeds = dto.Officialneeds,
  592. VisitStartDate = startTime,
  593. VisitEndDate = endTime,
  594. };
  595. var addId = _sqlSugar.Insertable(delegationInfo).ExecuteReturnIdentity();
  596. if (addId > 0)
  597. {
  598. result.Code = 0;
  599. result.Msg = "添加成功!";
  600. result.Data = addId;
  601. }
  602. else
  603. {
  604. result.Msg = "添加失败!";
  605. }
  606. }
  607. else if (dto.Status == 2) //修改
  608. {
  609. var updateStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
  610. {
  611. SalesQuoteNo = dto.SalesQuoteNo,
  612. TeamLevSId = dto.TeamLevSId,
  613. ClientName = dto.ClientName,
  614. ClientUnit = dto.ClientUnit,
  615. TeamName = dto.TeamName,
  616. TeamDid = dto.TeamDid,
  617. VisitDate = Convert.ToDateTime(dto.VisitDate),
  618. VisitCountry = dto.VisitCountry,
  619. VisitPurpose = dto.VisitPurpose,
  620. VisitDays = dto.VisitDays,
  621. VisitPNumber = dto.VisitPNumber,
  622. SpecialNeeds = dto.SpecialNeeds,
  623. OtherNeeds = dto.OtherNeeds,
  624. Remark = dto.Remark,
  625. JietuanOperator = dto.JietuanOperator,
  626. TellPhone = dto.TellPhone,
  627. WeChatNo = dto.WeChatNo,
  628. CGRWSPBMMC = dto.CGRWSPBMMC,
  629. CGRWSPWH = dto.CGRWSPWH,
  630. ZZSCBMMC = dto.ZZSCBMMC,
  631. ZZSCSPWH = dto.ZZSCSPWH,
  632. TontractTime = string.IsNullOrEmpty(dto.TontractTime) ? null : Convert.ToDateTime(dto.TontractTime),
  633. IsBid = dto.IsBid,
  634. PaymentMoney = dto.PaymentMoney,
  635. PayDay = dto.PayDay,
  636. OpRoyaltyLv = dto.OpRoyaltyLv,
  637. OpRoyaltyRemark = dto.opRoyaltyRemark,
  638. Officialneeds = dto.Officialneeds,
  639. VisitStartDate = startTime,
  640. VisitEndDate = endTime,
  641. });
  642. if (updateStatus)
  643. {
  644. result.Code = 0;
  645. result.Msg = "修改成功!";
  646. }
  647. else
  648. {
  649. result.Msg = "修改失败!";
  650. }
  651. }
  652. else if (dto.Status == 3) //删除
  653. {
  654. var deleteStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
  655. {
  656. DeleteUserId = dto.UserId,
  657. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  658. IsDel = 1
  659. });
  660. if (deleteStatus)
  661. {
  662. result.Code = 0;
  663. result.Msg = "删除成功!";
  664. }
  665. else
  666. {
  667. result.Msg = "删除失败!";
  668. }
  669. }
  670. }
  671. return result;
  672. }
  673. /// <summary>
  674. /// 团组信息操作 - 删除
  675. /// </summary>
  676. /// <param name="dto"></param>
  677. /// <returns></returns>
  678. public async Task<Result> GroupDel(GroupDelDto dto)
  679. {
  680. Result result = new Result() { Code = -2, Msg = "未知错误" };
  681. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  682. {
  683. var deleteStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
  684. {
  685. DeleteUserId = dto.UserId,
  686. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  687. IsDel = 1
  688. });
  689. if (deleteStatus)
  690. {
  691. result.Code = 0;
  692. result.Msg = "删除成功!";
  693. }
  694. else
  695. {
  696. result.Msg = "删除失败!";
  697. }
  698. }
  699. return result;
  700. }
  701. /// <summary>
  702. /// 获取销售报价号
  703. /// </summary>
  704. /// <returns></returns>
  705. public async Task<Result> GetGroupSalesQuoteNo()
  706. {
  707. Result result = new Result() { Code = -2, Msg = "未知错误" };
  708. string teamCodeSql = string.Format("Select SalesQuoteNo From Grp_DelegationInfo");
  709. var teamCodeItem = await _sqlSugar.SqlQueryable<SalesQuoteNoView>(teamCodeSql).ToListAsync();
  710. string teamCode = "";
  711. while (true)
  712. {
  713. teamCode = Tools.CommonFun.GetRandomAllStr(6);
  714. if (!teamCodeItem.Equals(teamCode))
  715. {
  716. break;
  717. }
  718. }
  719. result.Code = 0;
  720. result.Msg = "成功!";
  721. result.Data = teamCode;
  722. return result;
  723. }
  724. /// <summary>
  725. /// 团组删除
  726. /// </summary>
  727. /// <returns></returns>
  728. public async Task<Result> GroupDeleteById()
  729. {
  730. Result result = new Result() { Code = -2, Msg = "未知错误" };
  731. string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
  732. var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
  733. string teamCode = "";
  734. while (true)
  735. {
  736. teamCode = Tools.CommonFun.GetRandomAllStr(6);
  737. if (!teamCodeItem.Equals(teamCode))
  738. {
  739. break;
  740. }
  741. }
  742. result.Code = 0;
  743. result.Msg = "成功!";
  744. result.Data = teamCode;
  745. return result;
  746. }
  747. /// <summary>
  748. /// 团组确认出团
  749. /// </summary>
  750. /// <returns></returns>
  751. public async Task<Result> ConfirmationGroup(ConfirmationGroupDto dto)
  752. {
  753. Result result = new Result() { Code = -2, Msg = "未知错误" };
  754. string teamCode = "";
  755. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  756. {
  757. string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
  758. var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
  759. while (true)
  760. {
  761. teamCode = Tools.CommonFun.GetRandomAllStr(6);
  762. if (!teamCodeItem.Equals(teamCode))
  763. {
  764. break;
  765. }
  766. }
  767. var deleteStatus = await UpdateAsync(a => a.Id == dto.GroupId, a => new Grp_DelegationInfo
  768. {
  769. TourCode = teamCode,
  770. GroupsOperator = dto.GroupsOperator,
  771. GroupsTime = DateTime.Now
  772. });
  773. if (deleteStatus)
  774. {
  775. result.Code = 0;
  776. result.Msg = "确认出团设置成功!";
  777. }
  778. else
  779. {
  780. result.Msg = "确认出团设置失败!";
  781. }
  782. }
  783. result.Code = 0;
  784. result.Msg = "成功!";
  785. result.Data = teamCode;
  786. return result;
  787. }
  788. /// <summary>
  789. /// 获取接团名称List
  790. /// </summary>
  791. /// <param name="dto"></param>
  792. /// <returns></returns>
  793. public async Task<Result> GetGroupNameList(GroupNameDto dto)
  794. {
  795. Result result = new Result() { Code = -2, Msg = "未知错误" };
  796. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  797. {
  798. string sql = string.Format(@"Select Id,TeamName GroupName From Grp_DelegationInfo
  799. Where TeamName != '' And IsDel = 0
  800. Order By Id Desc");
  801. var _groupNameList = await _sqlSugar.SqlQueryable<GroupNameView>(sql).ToListAsync();
  802. if (_groupNameList.Count > 0)
  803. {
  804. for (int i = 0; i < _groupNameList.Count; i++)
  805. {
  806. var info = _groupNameList[i];
  807. _groupNameList[i].GroupName = FormartTeamName(info.GroupName);
  808. }
  809. result.Code = 0;
  810. result.Msg = "成功!";
  811. result.Data = _groupNameList;
  812. }
  813. else
  814. {
  815. result.Msg = "暂无团组信息";
  816. }
  817. }
  818. return result;
  819. }
  820. //PostGroupNameScreen
  821. /// <summary>
  822. /// 获取接团名称 Page List
  823. /// </summary>
  824. /// <param name="dto"></param>
  825. /// <returns></returns>
  826. public async Task<JsonView> GetGroupNameList(int portType,int pageIndex,int pageSize, string groupName,int userId)
  827. {
  828. var _res = new JsonView() { Code = 400 , Msg = MsgTips.Fail };
  829. string sql = "";
  830. string sqlWhere = "";
  831. string mobileSqlWhere = "";
  832. if (!string.IsNullOrEmpty(groupName))
  833. {
  834. sqlWhere += string.Format($@"And TeamName Like '%{groupName}%'");
  835. mobileSqlWhere += string.Format($@"GroupName Like '%{groupName}%'");
  836. }
  837. List<int> userIds = new List<int>() { -1, 21 };
  838. if (!userIds.Contains(userId))
  839. {
  840. sqlWhere += string.Format($@"And JietuanOperator = {userId}");
  841. }
  842. sql = string.Format($@"Select ROW_NUMBER()Over(Order By Id Desc) as RowNumber,Id,TeamName GroupName From Grp_DelegationInfo
  843. Where IsDel = 0 {sqlWhere}");
  844. if (portType == 1) //web
  845. { }
  846. else if (portType == 2 || portType == 3)
  847. {
  848. //国交部 7 (主管 22,经理 32)团操操作权限 市场部 6 接团人
  849. var userInfo = await _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == userId && it.IsDel == 0).FirstAsync();
  850. if (userInfo != null)
  851. {
  852. if (userInfo.DepId == 7)
  853. {
  854. if (userInfo.JobPostId != 22 || userInfo.JobPostId != 32)
  855. {
  856. if (!string.IsNullOrEmpty(mobileSqlWhere)) mobileSqlWhere = $" Where {mobileSqlWhere}";
  857. sql = string.Format($@"Select
  858. ROW_NUMBER()Over(Order By Id Desc) as RowNumber,
  859. Id,
  860. GroupName
  861. From (
  862. Select
  863. distinct
  864. di.Id,
  865. di.TeamName GroupName
  866. From Grp_GroupsTaskAssignment gta With(NoLock)
  867. Inner Join Grp_DelegationInfo di With(NoLock) On gta.DIId = di.Id
  868. Where gta.IsDel = 0 And di.IsDel = 0 And gta.UId = {userId}
  869. ) Temp {mobileSqlWhere}");
  870. }
  871. }
  872. }
  873. }
  874. RefAsync<int> total = 0;
  875. var groupNamePageData = await _sqlSugar.SqlQueryable<GroupNamePageView>(sql).ToPageListAsync(pageIndex, pageSize, total);
  876. _res.Code = 200;
  877. _res.Data = groupNamePageData;
  878. _res.Msg = MsgTips.Succeed;
  879. _res.Count = total;
  880. return _res;
  881. }
  882. /// <summary>
  883. /// 获取接团名称List And 签证国别
  884. /// </summary>
  885. /// <param name="dto"></param>
  886. /// <returns></returns>
  887. public async Task<Result> GetGroupNameAndVisaNationality(GroupNameDto dto)
  888. {
  889. Result result = new Result() { Code = -2, Msg = "未知错误" };
  890. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  891. {
  892. string sql = string.Format(@"Select Id,TeamName GroupName From Grp_DelegationInfo
  893. Where TeamName != '' And IsDel = 0
  894. Order By Id Desc");
  895. var _groupNameList = await _sqlSugar.SqlQueryable<GroupNameView>(sql).ToListAsync();
  896. string visaSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = 41 And IsDel = 0");
  897. var _setDataList = await _sqlSugar.SqlQueryable<SetDataInfoView>(visaSql).ToListAsync();
  898. var data = new {
  899. groupNameData = _groupNameList,
  900. visaNationalityData = _setDataList
  901. };
  902. result.Data = data;
  903. result.Code = 0;
  904. }
  905. return result;
  906. }
  907. #endregion
  908. #region 团组&签证
  909. /// <summary>
  910. /// 根据团组Id查询客户
  911. /// </summary>
  912. /// <param name="dto"></param>
  913. /// <returns></returns>
  914. public async Task<Result> GetCrmByGroupId(ClientByGroupIdDto dto)
  915. {
  916. Result result = new Result() { Code = -2 };
  917. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
  918. {
  919. string sql = string.Format(@"Select gdjc.GrpDCId grpId,cdc.Id,cdc.LastName+cdc.FirstName clientName,cdc.Tel,ccc.CertNo CerdNo
  920. From Grp_DelegationJoinCustomer gdjc
  921. Inner join Crm_DeleClient cdc On gdjc.CrmDCId = cdc.Id
  922. Left Join Crm_CustomerCert ccc On ccc.SdId = 773 And cdc.Id = ccc.DcId
  923. Where gdjc.GrpDCId = {0}", dto.GroupId);
  924. var clientList = await _sqlSugar.SqlQueryable<CrmByGroupIdView>(sql).ToListAsync();
  925. if (clientList.Count > 0)
  926. {
  927. result.Code = 0;
  928. result.Msg = "成功!";
  929. result.Data = clientList;
  930. }
  931. else
  932. {
  933. result.Msg = "暂无数据!";
  934. }
  935. }
  936. return result;
  937. }
  938. #endregion
  939. #region 团组&出入境费用
  940. /// <summary>
  941. /// 获取单组名称并验证出入境费用明细是否填写
  942. /// </summary>
  943. /// <param name="dto"></param>
  944. /// <returns></returns>
  945. public async Task<Result> EnterExitCostGroupNameAsync()
  946. {
  947. var result = new Result() { Code = -2, Msg = "未知错误" };
  948. var groupSql = string.Format(@$"SELECT
  949. Id,
  950. TeamName GroupName,
  951. CASE
  952. WHEN (
  953. SELECT
  954. COUNT(*)
  955. FROM
  956. Grp_EnterExitCost
  957. WHERE
  958. IsDel = 0
  959. AND DiId = di.Id
  960. ) > 0 THEN 'false'
  961. ELSE 'true'
  962. END AS [IsNull]
  963. FROM
  964. Grp_DelegationInfo di
  965. WHERE
  966. di.Isdel = 0
  967. ORDER BY
  968. CreateTime Desc");
  969. result.Data = await _sqlSugar.SqlQueryable<EnterExitCostGroupNameView>(groupSql).ToListAsync();
  970. result.Code = 0;
  971. return result;
  972. }
  973. #endregion
  974. }
  975. }