DelegationInfoRepository.cs 49 KB

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