DelegationInfoRepository.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. using Newtonsoft.Json;
  2. using OASystem.Domain;
  3. using OASystem.Domain.Dtos;
  4. using OASystem.Domain.Dtos.Financial;
  5. using OASystem.Domain.Dtos.Groups;
  6. using OASystem.Domain.Dtos.UserDto;
  7. using OASystem.Domain.Entities.Groups;
  8. using OASystem.Domain.ViewModels.CRM;
  9. using OASystem.Domain.ViewModels.Financial;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.System;
  12. using Org.BouncyCastle.Asn1.Cms;
  13. using Org.BouncyCastle.Utilities.Collections;
  14. using Serilog;
  15. using SqlSugar;
  16. using System;
  17. using System.Collections.Generic;
  18. using System.Linq;
  19. using System.Text;
  20. using System.Threading.Tasks;
  21. namespace OASystem.Infrastructure.Repositories.Groups
  22. {
  23. /// <summary>
  24. /// 接团信息
  25. /// </summary>
  26. public class DelegationInfoRepository : BaseRepository<Grp_DelegationInfo, DelegationInfoView>
  27. {
  28. private readonly SetDataRepository _setDataRepository;
  29. private readonly UsersRepository _usersRepository;
  30. private readonly TaskAssignmentRepository _taskAssignmentRep;
  31. //public readonly Logs _logs;
  32. public DelegationInfoRepository(SqlSugarClient sqlSugar, SetDataRepository setDataRepository, UsersRepository usersRepository, TaskAssignmentRepository taskAssignmentRep)
  33. : base(sqlSugar)
  34. {
  35. _setDataRepository = setDataRepository;
  36. _usersRepository = usersRepository;
  37. _taskAssignmentRep = taskAssignmentRep;
  38. }
  39. #region 团组信息 团组详情共享Api
  40. /// <summary>
  41. /// 团组信息 团组详情共享Api
  42. /// </summary>
  43. /// <param name="dto"></param>
  44. /// <returns></returns>
  45. public async Task<Result> PostShareGroupInfo(ShareGroupInfoDto dto)
  46. {
  47. Result result = new Result() { Code = -2, Msg = "未知错误" };
  48. if (dto.PortType == 1 || dto.PortType == 2) //Web Or Android
  49. {
  50. string sql = string.Format(@"Select Id,TourCode,ClientName,VisitCountry,VisitStartDate,VisitEndDate,VisitDays,VisitPNumber
  51. From Grp_DelegationInfo Where Id = {0} And IsDel = 0", dto.Id);
  52. var _DelegationInfo = await _sqlSugar.SqlQueryable<ShareGroupInfoView>(sql).FirstAsync();
  53. if (_DelegationInfo != null)
  54. {
  55. if (_DelegationInfo.VisitCountry.Contains("|"))
  56. {
  57. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  58. }
  59. result.Code = 0;
  60. result.Msg = "成功!";
  61. result.Data = _DelegationInfo;
  62. }
  63. else result.Msg = "暂无该团组信息";
  64. }
  65. return result;
  66. }
  67. #endregion
  68. /// <summary>
  69. /// 获取接团信息Info
  70. /// </summary>
  71. /// <param name="dto"></param>
  72. /// <returns></returns>
  73. public async Task<Result> PostGroupInfo(GroupInfoDto dto)
  74. {
  75. Result result = new Result() { Code = -2, Msg = "未知错误" };
  76. if (dto.PortType == 1 || dto.PortType == 2) //Web Or Android
  77. {
  78. string sql = string.Format(@"Select Id,SalesQuoteNo,TourCode,JietuanOperator,TeamLevSId,TeamDid,TeamName,ClientName,
  79. ClientUnit,VisitCountry,VisitDate,VisitDays,VisitPNumber,TontractTime,
  80. PayDay,PaymentMoney,VisitPurpose,SpecialNeeds,OtherNeeds,CGRWSPBMMC,CGRWSPWH,
  81. ZZSCBMMC,ZZSCSPWH,Remark,TellPhone
  82. From Grp_DelegationInfo Where Id = {0} And IsDel = 0", dto.Id);
  83. var _DelegationInfo = await _sqlSugar.SqlQueryable<DelegationInfoWebView>(sql).FirstAsync();
  84. if (_DelegationInfo != null)
  85. {
  86. result.Code = 0;
  87. result.Msg = "成功!";
  88. result.Data = _DelegationInfo;
  89. }
  90. else result.Msg = "暂无该团组信息";
  91. }
  92. return result;
  93. }
  94. #region 团组
  95. /// <summary>
  96. /// 获取接团信息 Page List
  97. /// </summary>
  98. /// <param name="dto"></param>
  99. /// <returns></returns>
  100. public async Task<Result> GetGroupPageList(GroupCommissionDto dto)
  101. {
  102. Result result = new Result() { Code = -2, Msg = "未知错误" };
  103. ListViewBase<DelegationPageListView> groupsInfoPageList = new ListViewBase<DelegationPageListView>()
  104. {
  105. ReceiveDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  106. };
  107. if (dto.PortType == 1 || dto.PortType == 2) //web
  108. {
  109. int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
  110. int endIndex = startIndex + dto.PageSize - 1;
  111. int taskUserId = -1;
  112. string taskGroupIds = string.Empty;
  113. #region 处理用户团组操作权限
  114. if (dto.UserId != -1)
  115. {
  116. }
  117. #endregion
  118. string sql = string.Format(@"Select * From(Select row_number() over (order by gdi.Id Desc) as RowNumber,
  119. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,ssd1.Id TeamLevId,
  120. ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,VisitDate,VisitDays,VisitPNumber,
  121. su.CnName JietuanOperator,IsSure
  122. From Grp_DelegationInfo gdi
  123. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  124. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  125. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  126. Where gdi.IsDel = 0
  127. )temp Where RowNumber Between {0} and {1}", startIndex, endIndex);
  128. string sqlCount = string.Format(@"Select Count(1) as Count From Grp_DelegationInfo gdi
  129. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  130. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  131. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  132. Where gdi.IsDel = 0 ");
  133. List<DelegationPageListView> _DeleInfoList = await _sqlSugar.SqlQueryable<DelegationPageListView>(sql).ToListAsync();
  134. DelegationPageCountView _DeleCount = await _sqlSugar.SqlQueryable<DelegationPageCountView>(sqlCount).FirstAsync();
  135. int count = _DeleCount.Count;
  136. groupsInfoPageList = new ListViewBase<DelegationPageListView>
  137. {
  138. CurrPageIndex = dto.PageIndex,
  139. CurrPageSize = dto.PageSize,
  140. DataCount = count,
  141. DataList = _DeleInfoList
  142. };
  143. result.Code = 0;
  144. result.Msg = "成功!";
  145. result.Data = groupsInfoPageList;
  146. }
  147. return result;
  148. }
  149. /// <summary>
  150. /// 获取接团信息List
  151. /// </summary>
  152. /// <param name="dto"></param>
  153. /// <returns></returns>
  154. public async Task<Result> GetGroupList(GroupListDto dto)
  155. {
  156. Result result = new Result() { Code = -2, Msg = "未知错误" };
  157. if (dto.PortType == 1 || dto.PortType == 2) //web
  158. {
  159. 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
  160. From Grp_DelegationInfo gdi
  161. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  162. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  163. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  164. Where gdi.IsDel = 0
  165. Order By gdi.CreateTime Desc");
  166. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  167. if (_DelegationList.Count > 0)
  168. {
  169. result.Code = 0;
  170. result.Msg = "成功!";
  171. result.Data = _DelegationList;
  172. }
  173. else
  174. {
  175. result.Msg = "暂无该团组信息";
  176. }
  177. }
  178. return result;
  179. }
  180. /// <summary>
  181. /// 获取接团信息Info
  182. /// </summary>
  183. /// <param name="dto"></param>
  184. /// <returns></returns>
  185. public async Task<Result> GetGroupInfo(GroupInfoDto dto)
  186. {
  187. Result result = new Result() { Code = -2, Msg = "未知错误" };
  188. if (dto.PortType == 1 || dto.PortType == 2) //Web Or Android
  189. {
  190. string sql = string.Format(@"Select Id,SalesQuoteNo,TourCode,JietuanOperator,TeamLevSId,TeamDid,TeamName,ClientName,
  191. ClientUnit,VisitCountry,VisitDate,VisitDays,VisitPNumber,TontractTime,
  192. PayDay,PaymentMoney,VisitPurpose,SpecialNeeds,OtherNeeds,CGRWSPBMMC,CGRWSPWH,
  193. ZZSCBMMC,ZZSCSPWH,Remark,TellPhone
  194. From Grp_DelegationInfo Where Id = {0} And IsDel = 0", dto.Id);
  195. var _DelegationInfo = await _sqlSugar.SqlQueryable<DelegationInfoWebView>(sql).FirstAsync();
  196. if (_DelegationInfo != null)
  197. {
  198. result.Code = 0;
  199. result.Msg = "成功!";
  200. result.Data = _DelegationInfo;
  201. }
  202. else result.Msg = "暂无该团组信息";
  203. }
  204. return result;
  205. }
  206. /// <summary>
  207. /// 获取接团信息 编辑
  208. /// 基础 数据源
  209. /// </summary>
  210. /// <param name="dto"></param>
  211. /// <returns></returns>
  212. public async Task<Result> GroupEditBasicSource(GroupListDto dto)
  213. {
  214. Result result = new Result() { Code = -2, Msg = "未知错误" };
  215. try
  216. {
  217. if (dto.PortType == 1 || dto.PortType == 2) //web
  218. {
  219. dynamic? teamTypeData1 = null;
  220. string teamTypeSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = {0} And IsDel = {1}", 10, 0);
  221. var teamTypeData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamTypeSql).ToListAsync(); ; //团组分类 10
  222. if (teamTypeData.Count > 0)
  223. {
  224. teamTypeData1 = teamTypeData;
  225. }
  226. dynamic? teamLevData1 = null;
  227. string teamLevSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = {0} And IsDel = {1}", 56, 0);
  228. var teamLevData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamLevSql).ToListAsync(); ; //团组等级 56
  229. if (teamLevData.Count > 0)
  230. {
  231. teamLevData1 = teamLevData;
  232. }
  233. dynamic? userData1 = null;
  234. string userSql = string.Format(@"Select Id,CnName From Sys_Users Where IsDel = {0}", 0);
  235. var userData = await _sqlSugar.SqlQueryable<UserNameView>(userSql).ToListAsync(); ;
  236. if (userData.Count > 0)
  237. {
  238. userData1 = userData;
  239. }
  240. result.Code = 0;
  241. result.Msg = "成功!";
  242. result.Data = new
  243. {
  244. teamTypeData = teamTypeData1,
  245. teamLevData = teamLevData1,
  246. userData = userData1
  247. };
  248. }
  249. }
  250. catch (Exception)
  251. {
  252. throw;
  253. }
  254. return result;
  255. }
  256. /// <summary>
  257. /// 团组信息操作
  258. /// </summary>
  259. /// <param name="dto"></param>
  260. /// <returns></returns>
  261. public async Task<Result> GroupOperation(GroupOperationDto dto)
  262. {
  263. Result result = new Result() { Code = -2, Msg = "未知错误" };
  264. if (dto.PortType == 1 || dto.PortType == 2) //web
  265. {
  266. if (dto.Status == 1) //添加
  267. {
  268. string selectSql = string.Format(@"Select * From Grp_DelegationInfo
  269. Where IsDel = 0
  270. And TeamName = '{0}'
  271. And ClientName = '{1}'
  272. And ClientUnit ='{2}'
  273. And VisitDate ='{3}'",dto.TeamName, dto.ClientName, dto.ClientUnit, dto.VisitDate);
  274. var selectGroupInfo = await _sqlSugar.SqlQueryable<Grp_DelegationInfo>(selectSql).FirstAsync();
  275. if (selectGroupInfo != null)
  276. {
  277. result.Msg = "数据已存在,请勿重复添加!";
  278. return result;
  279. }
  280. //string teamCodeSql = string.Format("Select SalesQuoteNo From Grp_DelegationInfo");
  281. //var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
  282. //string SalesQuoteNo = "";
  283. //while (true)
  284. //{
  285. // SalesQuoteNo = Tools.CommonFun.GetRandomStr(6);
  286. // if (!teamCodeItem.Equals(SalesQuoteNo))
  287. // {
  288. // break;
  289. // }
  290. //}
  291. Grp_DelegationInfo delegationInfo = new Grp_DelegationInfo()
  292. {
  293. SalesQuoteNo = dto.SalesQuoteNo,
  294. TeamLevSId = dto.TeamLevSId,
  295. ClientName = dto.ClientName,
  296. ClientUnit = dto.ClientUnit,
  297. TeamName = dto.TeamName,
  298. TeamDid = dto.TeamDid,
  299. VisitDate = Convert.ToDateTime(dto.VisitDate),
  300. VisitCountry = dto.VisitCountry,
  301. VisitPurpose = dto.VisitPurpose,
  302. VisitDays = dto.VisitDays,
  303. VisitPNumber = dto.VisitPNumber,
  304. SpecialNeeds = dto.SpecialNeeds,
  305. OtherNeeds = dto.OtherNeeds,
  306. Remark = dto.Remark,
  307. JietuanOperator = dto.UserId,
  308. TellPhone = dto.TellPhone,
  309. CGRWSPBMMC = dto.CGRWSPBMMC,
  310. CGRWSPWH = dto.CGRWSPWH,
  311. ZZSCBMMC = dto.ZZSCBMMC,
  312. ZZSCSPWH = dto.ZZSCSPWH,
  313. TontractTime = Convert.ToDateTime(dto.TontractTime),
  314. PaymentMoney = dto.PaymentMoney,
  315. PayDay = dto.PayDay,
  316. TourCode = "",
  317. SalesDate = DateTime.Now,
  318. IsState = 0, //默认团组未完成 0
  319. JietuanTime = DateTime.Now,
  320. IsDel = 0,
  321. BudgetCost = 0.00M,
  322. HotelComplain = 0,
  323. OPComplain = 0,
  324. OAComplain = 0,
  325. AirComplain = 0,
  326. VisaComplain = 0,
  327. CreateUserId = dto.UserId,
  328. CreateTime = DateTime.Now,
  329. DeleteUserId = null,
  330. DeleteTime = new DateTime(1990, 1, 1).ToString("yyyy-MM-dd HH:mm:ss")
  331. };
  332. Log.Information("添加:"+ JsonConvert.SerializeObject(delegationInfo));
  333. var addId = await _sqlSugar.Insertable(delegationInfo).ExecuteReturnIdentityAsync();
  334. if (addId > 0)
  335. {
  336. result.Code = 0;
  337. result.Msg = "添加成功!";
  338. }
  339. else
  340. {
  341. result.Msg = "添加失败!";
  342. }
  343. }
  344. else if (dto.Status == 2) //修改
  345. {
  346. var updateStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
  347. {
  348. SalesQuoteNo = dto.SalesQuoteNo,
  349. TeamLevSId = dto.TeamLevSId,
  350. ClientName = dto.ClientName,
  351. ClientUnit = dto.ClientUnit,
  352. TeamName = dto.TeamName,
  353. TeamDid = dto.TeamDid,
  354. VisitDate = Convert.ToDateTime(dto.VisitDate),
  355. VisitCountry = dto.VisitCountry,
  356. VisitPurpose = dto.VisitPurpose,
  357. VisitDays = dto.VisitDays,
  358. VisitPNumber = dto.VisitPNumber,
  359. SpecialNeeds = dto.SpecialNeeds,
  360. OtherNeeds = dto.OtherNeeds,
  361. Remark = dto.Remark,
  362. JietuanOperator = dto.UserId,
  363. TellPhone = dto.TellPhone,
  364. CGRWSPBMMC = dto.CGRWSPBMMC,
  365. CGRWSPWH = dto.CGRWSPWH,
  366. ZZSCBMMC = dto.ZZSCBMMC,
  367. ZZSCSPWH = dto.ZZSCSPWH,
  368. TontractTime = Convert.ToDateTime(dto.TontractTime),
  369. PaymentMoney = dto.PaymentMoney,
  370. PayDay = dto.PayDay
  371. });
  372. if (updateStatus)
  373. {
  374. result.Code = 0;
  375. result.Msg = "修改成功!";
  376. }
  377. else
  378. {
  379. result.Msg = "修改失败!";
  380. }
  381. }
  382. else if (dto.Status == 3) //删除
  383. {
  384. var deleteStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
  385. {
  386. DeleteUserId = dto.UserId,
  387. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  388. IsDel = 1
  389. });
  390. if (deleteStatus)
  391. {
  392. result.Code = 0;
  393. result.Msg = "删除成功!";
  394. }
  395. else
  396. {
  397. result.Msg = "删除失败!";
  398. }
  399. }
  400. }
  401. return result;
  402. }
  403. /// <summary>
  404. /// 团组信息操作 - 删除
  405. /// </summary>
  406. /// <param name="dto"></param>
  407. /// <returns></returns>
  408. public async Task<Result> GroupDel(GroupDelDto dto)
  409. {
  410. Result result = new Result() { Code = -2, Msg = "未知错误" };
  411. if (dto.PortType == 1 || dto.PortType == 2) //web
  412. {
  413. var deleteStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
  414. {
  415. DeleteUserId = dto.UserId,
  416. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  417. IsDel = 1
  418. });
  419. if (deleteStatus)
  420. {
  421. result.Code = 0;
  422. result.Msg = "删除成功!";
  423. }
  424. else
  425. {
  426. result.Msg = "删除失败!";
  427. }
  428. }
  429. return result;
  430. }
  431. /// <summary>
  432. /// 获取销售报价号
  433. /// </summary>
  434. /// <returns></returns>
  435. public async Task<Result> GetGroupSalesQuoteNo()
  436. {
  437. Result result = new Result() { Code = -2, Msg = "未知错误" };
  438. string teamCodeSql = string.Format("Select SalesQuoteNo From Grp_DelegationInfo");
  439. var teamCodeItem = await _sqlSugar.SqlQueryable<SalesQuoteNoView>(teamCodeSql).ToListAsync();
  440. string teamCode = "";
  441. while (true)
  442. {
  443. teamCode = Tools.CommonFun.GetRandomAllStr(6);
  444. if (!teamCodeItem.Equals(teamCode))
  445. {
  446. break;
  447. }
  448. }
  449. result.Code = 0;
  450. result.Msg = "成功!";
  451. result.Data = teamCode;
  452. return result;
  453. }
  454. /// <summary>
  455. /// 团组删除
  456. /// </summary>
  457. /// <returns></returns>
  458. public async Task<Result> GroupDeleteById()
  459. {
  460. Result result = new Result() { Code = -2, Msg = "未知错误" };
  461. string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
  462. var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
  463. string teamCode = "";
  464. while (true)
  465. {
  466. teamCode = Tools.CommonFun.GetRandomAllStr(6);
  467. if (!teamCodeItem.Equals(teamCode))
  468. {
  469. break;
  470. }
  471. }
  472. result.Code = 0;
  473. result.Msg = "成功!";
  474. result.Data = teamCode;
  475. return result;
  476. }
  477. /// <summary>
  478. /// 团组确认出团
  479. /// </summary>
  480. /// <returns></returns>
  481. public async Task<Result> ConfirmationGroup(ConfirmationGroupDto dto)
  482. {
  483. Result result = new Result() { Code = -2, Msg = "未知错误" };
  484. string teamCode = "";
  485. if (dto.PortType == 1 || dto.PortType == 2) //web
  486. {
  487. string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
  488. var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
  489. while (true)
  490. {
  491. teamCode = Tools.CommonFun.GetRandomAllStr(6);
  492. if (!teamCodeItem.Equals(teamCode))
  493. {
  494. break;
  495. }
  496. }
  497. var deleteStatus = await UpdateAsync(a => a.Id == dto.GroupId, a => new Grp_DelegationInfo
  498. {
  499. TourCode = teamCode,
  500. GroupsOperator = dto.GroupsOperator,
  501. GroupsTime = DateTime.Now
  502. });
  503. if (deleteStatus)
  504. {
  505. result.Code = 0;
  506. result.Msg = "确认出团设置成功!";
  507. }
  508. else
  509. {
  510. result.Msg = "确认出团设置失败!";
  511. }
  512. }
  513. result.Code = 0;
  514. result.Msg = "成功!";
  515. result.Data = teamCode;
  516. return result;
  517. }
  518. /// <summary>
  519. /// 获取接团名称List
  520. /// </summary>
  521. /// <param name="dto"></param>
  522. /// <returns></returns>
  523. public async Task<Result> GetGroupNameList(GroupNameDto dto)
  524. {
  525. Result result = new Result() { Code = -2, Msg = "未知错误" };
  526. if (dto.PortType == 1 || dto.PortType == 2) //web
  527. {
  528. string sql = string.Format(@"Select Id,TeamName GroupName From Grp_DelegationInfo
  529. Where TeamName != '' And IsDel = 0
  530. Order By Id Desc");
  531. var _groupNameList = await _sqlSugar.SqlQueryable<GroupNameView>(sql).ToListAsync();
  532. if (_groupNameList.Count > 0)
  533. {
  534. result.Code = 0;
  535. result.Msg = "成功!";
  536. result.Data = _groupNameList;
  537. }
  538. else
  539. {
  540. result.Msg = "暂无团组信息";
  541. }
  542. }
  543. return result;
  544. }
  545. /// <summary>
  546. /// 获取接团名称List And 签证国别
  547. /// </summary>
  548. /// <param name="dto"></param>
  549. /// <returns></returns>
  550. public async Task<Result> GetGroupNameAndVisaNationality(GroupNameDto dto)
  551. {
  552. Result result = new Result() { Code = -2, Msg = "未知错误" };
  553. if (dto.PortType == 1 || dto.PortType == 2) //web
  554. {
  555. string sql = string.Format(@"Select Id,TeamName GroupName From Grp_DelegationInfo
  556. Where TeamName != '' And IsDel = 0
  557. Order By Id Desc");
  558. var _groupNameList = await _sqlSugar.SqlQueryable<GroupNameView>(sql).ToListAsync();
  559. string visaSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = 41 And IsDel = 0");
  560. var _setDataList = await _sqlSugar.SqlQueryable<SetDataInfoView>(visaSql).ToListAsync();
  561. var data = new {
  562. groupNameData = _groupNameList,
  563. visaNationalityData = _setDataList
  564. };
  565. result.Data = data;
  566. result.Code = 0;
  567. }
  568. return result;
  569. }
  570. #endregion
  571. #region 团组&签证
  572. /// <summary>
  573. /// 根据团组Id查询客户
  574. /// </summary>
  575. /// <param name="dto"></param>
  576. /// <returns></returns>
  577. public async Task<Result> GetCrmByGroupId(ClientByGroupIdDto dto)
  578. {
  579. Result result = new Result() { Code = -2 };
  580. if (dto.PortType == 1 || dto.PortType == 2)
  581. {
  582. string sql = string.Format(@"Select gdjc.GrpDCId grpId,cdc.Id,cdc.LastName+cdc.FirstName clientName,cdc.Tel,ccc.CertNo CerdNo
  583. From Grp_DelegationJoinCustomer gdjc
  584. Inner join Crm_DeleClient cdc On gdjc.CrmDCId = cdc.Id
  585. Left Join Crm_CustomerCert ccc On ccc.SdId = 773 And cdc.Id = ccc.DcId
  586. Where gdjc.GrpDCId = {0}", dto.GroupId);
  587. var clientList = await _sqlSugar.SqlQueryable<CrmByGroupIdView>(sql).ToListAsync();
  588. if (clientList.Count > 0)
  589. {
  590. result.Code = 0;
  591. result.Msg = "成功!";
  592. result.Data = clientList;
  593. }
  594. else
  595. {
  596. result.Msg = "暂无数据!";
  597. }
  598. }
  599. return result;
  600. }
  601. #endregion
  602. }
  603. }