DelegationInfoRepository.cs 27 KB

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