ResourceController.cs 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448
  1. using OASystem.API.OAMethodLib;
  2. using OASystem.Domain.Dtos.Resource;
  3. using OASystem.Domain.Entities.Groups;
  4. using OASystem.Infrastructure.Repositories.Groups;
  5. using System.Collections.Generic;
  6. namespace OASystem.API.Controllers
  7. {
  8. /// <summary>
  9. /// 资料相关
  10. /// </summary>
  11. //[Authorize]
  12. [Route("api/[controller]/[action]")]
  13. public class ResourceController : ControllerBase
  14. {
  15. private readonly IMapper _mapper;
  16. private readonly IConfiguration _config;
  17. private readonly CarDataRepository _carDataRep;
  18. private readonly LocalGuideDataRepository _localGuideDataRep;
  19. private readonly ThreeCodeRepository _ThreeCodeRep;
  20. private readonly HotelDataRepository _hotelDataRep;
  21. private readonly ResItemInfoRepository _resItemInfoRep;
  22. private readonly SetDataRepository _setDataRepository;
  23. private readonly CountryFeeRepository _countryFeeRep;
  24. private readonly SetDataTypeRepository _setDataTypeRep;
  25. private readonly AirTicketAgentRepository _airTicketAgentRep;
  26. private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
  27. public ResourceController(IMapper mapper, IConfiguration config, CarDataRepository carDataRep,
  28. LocalGuideDataRepository localGuideDataRep, ThreeCodeRepository threeCodeRep,
  29. HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository,
  30. CountryFeeRepository countryFeeRep, SetDataTypeRepository setDataTypeRep, AirTicketAgentRepository airTicketAgentRep, InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep)
  31. {
  32. _mapper = mapper;
  33. _config = config;
  34. _carDataRep = carDataRep;
  35. _localGuideDataRep = localGuideDataRep;
  36. _ThreeCodeRep = threeCodeRep;
  37. _hotelDataRep = hotelDataRep;
  38. _resItemInfoRep = resItemInfoRep;
  39. _setDataRepository = setDataRepository;
  40. _countryFeeRep = countryFeeRep;
  41. _setDataTypeRep = setDataTypeRep;
  42. _airTicketAgentRep = airTicketAgentRep;
  43. _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
  44. }
  45. #region 车公司资料板块
  46. /// <summary>
  47. /// 车公司信息查询
  48. /// </summary>
  49. /// <returns></returns>
  50. [HttpPost]
  51. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  52. public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
  53. {
  54. try
  55. {
  56. Result LocalGuide = await _carDataRep.QueryCarData(dto);
  57. if (LocalGuide.Code == 0)
  58. {
  59. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  60. }
  61. else
  62. {
  63. return Ok(JsonView(false, LocalGuide.Msg));
  64. }
  65. }
  66. catch (Exception)
  67. {
  68. return Ok(JsonView(false, "程序错误!"));
  69. throw;
  70. }
  71. }
  72. /// <summary>
  73. /// 车公司资料下拉框数据
  74. /// </summary>
  75. /// <returns></returns>
  76. [HttpPost]
  77. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  78. public async Task<IActionResult> QueryCarSelect()
  79. {
  80. try
  81. {
  82. var CarData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
  83. if (CarData.Count == 0)
  84. {
  85. return Ok(JsonView(false, "暂无数据!"));
  86. }
  87. CarData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
  88. CarData = CarData.Where((x, i) => CarData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
  89. CarData = CarData.OrderBy(x => x.Id).ToList();
  90. List<CarDataSelectView> data = new List<CarDataSelectView>();
  91. foreach (CarDataSelectView car in CarData)
  92. {
  93. if (!string.IsNullOrWhiteSpace(car.UnitArea))
  94. {
  95. data.Add(car);
  96. }
  97. }
  98. return Ok(JsonView(true, "查询成功", data));
  99. }
  100. catch (Exception)
  101. {
  102. return Ok(JsonView(false, "程序错误!"));
  103. throw;
  104. }
  105. }
  106. /// <summary>
  107. /// 车公司信息添加
  108. /// </summary>
  109. /// <returns></returns>
  110. [HttpPost]
  111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  112. public async Task<IActionResult> AddCarData(AddCarDataDto dto)
  113. {
  114. try
  115. {
  116. if (dto.UnitArea == "")
  117. {
  118. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  119. }
  120. if (dto.UnitName == "")
  121. {
  122. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  123. }
  124. if (dto.Contact == "")
  125. {
  126. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  127. }
  128. if (dto.ContactTel == "")
  129. {
  130. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  131. }
  132. var carDada = _carDataRep.QueryDto<Res_CarData, CarDataView>(a => a.UnitArea == dto.UnitArea && a.UnitName == dto.UnitName && a.Contact == dto.Contact && a.ContactTel == dto.ContactTel).ToList();
  133. if (carDada.Count != 0)
  134. {
  135. return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
  136. }
  137. Res_CarData _CarData = _mapper.Map<Res_CarData>(dto);
  138. int id = await _carDataRep.AddAsyncReturnId(_CarData);
  139. if (id == 0)
  140. {
  141. return Ok(JsonView(false, "添加失败!"));
  142. }
  143. return Ok(JsonView(true, "添加成功", new { Id = id }));
  144. }
  145. catch (Exception ex)
  146. {
  147. return Ok(JsonView(false, "程序错误!"));
  148. throw;
  149. }
  150. }
  151. /// <summary>
  152. /// 车公司信息修改
  153. /// </summary>
  154. /// <returns></returns>
  155. [HttpPost]
  156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  157. public async Task<IActionResult> UpCarData(UpCarDataDto dto)
  158. {
  159. try
  160. {
  161. if (dto.UnitArea == "")
  162. {
  163. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  164. }
  165. if (dto.UnitName == "")
  166. {
  167. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  168. }
  169. if (dto.Contact == "")
  170. {
  171. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  172. }
  173. if (dto.ContactTel == "")
  174. {
  175. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  176. }
  177. bool res = await _carDataRep.UpdateAsync(a => a.Id == dto.Id, a => new Res_CarData
  178. {
  179. UnitArea = dto.UnitArea,
  180. UnitName = dto.UnitName,
  181. Address = dto.Address,
  182. Contact = dto.Contact,
  183. ContactTel = dto.ContactTel,
  184. ContactEmail = dto.ContactEmail,
  185. ContactFax = dto.ContactFax,
  186. CarDes = dto.CarDes,
  187. CarPicPaths = dto.CarPicPaths,
  188. OtherInfo = dto.OtherInfo,
  189. Score = dto.Score,
  190. QualificationScore = dto.QualificationScore,
  191. CarAgeScore = dto.CarAgeScore,
  192. CleanImgScore = dto.CleanImgScore,
  193. SmellScore = dto.SmellScore,
  194. WaterPaperScore = dto.WaterPaperScore,
  195. HardwareScore = dto.HardwareScore,
  196. TimeScore = dto.TimeScore,
  197. SafetyScore = dto.SafetyScore,
  198. DrivingAgeScore = dto.DrivingAgeScore,
  199. Remark = dto.Remark,
  200. });
  201. if (!res) { return Ok(JsonView(false, "修改失败!")); }
  202. return Ok(JsonView(true, "修改成功"));
  203. }
  204. catch (Exception ex)
  205. {
  206. return Ok(JsonView(false, "程序错误!"));
  207. throw;
  208. }
  209. }
  210. /// <summary>
  211. /// 车公司信息删除
  212. /// </summary>
  213. /// <returns></returns>
  214. [HttpPost]
  215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  216. public async Task<IActionResult> DelCarData(DelCarDataDto dto)
  217. {
  218. try
  219. {
  220. bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
  221. if (!res) { return Ok(JsonView(false, "删除失败!")); }
  222. return Ok(JsonView(true, "删除成功"));
  223. }
  224. catch (Exception ex)
  225. {
  226. return Ok(JsonView(false, "程序错误!"));
  227. throw;
  228. }
  229. }
  230. #endregion
  231. #region 导游地接资料板块
  232. /// <summary>
  233. /// 导游地接资料查询
  234. /// </summary>
  235. /// <param name="dto"></param>
  236. /// <returns></returns>
  237. [HttpPost]
  238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  239. public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
  240. {
  241. try
  242. {
  243. Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
  244. if (LocalGuide.Code == 0)
  245. {
  246. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  247. }
  248. else
  249. {
  250. return Ok(JsonView(false, LocalGuide.Msg));
  251. }
  252. }
  253. catch (Exception ex)
  254. {
  255. return Ok(JsonView(false, "程序错误!"));
  256. throw;
  257. }
  258. }
  259. /// <summary>
  260. /// 导游地接资料下拉框数据
  261. /// </summary>
  262. /// <returns></returns>
  263. [HttpPost]
  264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  265. public async Task<IActionResult> QueryLocalGuideSelect()
  266. {
  267. try
  268. {
  269. var LocalGuide = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
  270. if (LocalGuide.Count == 0)
  271. {
  272. return Ok(JsonView(false, "暂无数据!"));
  273. }
  274. LocalGuide.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
  275. LocalGuide = LocalGuide.Where((x, i) => LocalGuide.FindIndex(z => z.UnitArea == x.UnitArea && z.UnitArea != "") == i).ToList();
  276. LocalGuide = LocalGuide.OrderBy(x => x.Id).ToList();
  277. List<QueryLocalGuideSelectView> data = new List<QueryLocalGuideSelectView>();
  278. foreach (QueryLocalGuideSelectView Local in LocalGuide)
  279. {
  280. if (!string.IsNullOrWhiteSpace(Local.UnitArea))
  281. {
  282. data.Add(Local);
  283. }
  284. }
  285. return Ok(JsonView(true, "查询成功", data));
  286. }
  287. catch (Exception)
  288. {
  289. return Ok(JsonView(false, "程序错误!"));
  290. throw;
  291. }
  292. }
  293. /// <summary>
  294. /// 导游地接信息操作(Status:1.新增,2.修改)
  295. /// </summary>
  296. /// <returns></returns>
  297. [HttpPost]
  298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  299. public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
  300. {
  301. try
  302. {
  303. if (dto.UnitArea == "")
  304. {
  305. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  306. }
  307. if (dto.UnitName == "")
  308. {
  309. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  310. }
  311. if (dto.Contact == "")
  312. {
  313. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  314. }
  315. if (dto.ContactTel == "")
  316. {
  317. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  318. }
  319. Result result = await _localGuideDataRep.LocalGuideOperation(dto);
  320. if (result.Code != 0)
  321. {
  322. return Ok(JsonView(false, result.Msg));
  323. }
  324. return Ok(JsonView(true, result.Msg));
  325. }
  326. catch (Exception ex)
  327. {
  328. return Ok(JsonView(false, "程序错误!"));
  329. throw;
  330. }
  331. }
  332. /// <summary>
  333. /// 导游地接信息操作(删除)
  334. /// </summary>
  335. /// <returns></returns>
  336. [HttpPost]
  337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  338. public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
  339. {
  340. try
  341. {
  342. var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
  343. if (!res)
  344. {
  345. return Ok(JsonView(false, "删除失败"));
  346. }
  347. return Ok(JsonView(true, "删除成功!"));
  348. }
  349. catch (Exception ex)
  350. {
  351. return Ok(JsonView(false, "程序错误!"));
  352. throw;
  353. }
  354. }
  355. #endregion
  356. #region 机场三字码信息
  357. /// <summary>
  358. /// 机场三字码查询
  359. /// </summary>
  360. /// <param name="dto"></param>
  361. /// <returns></returns>
  362. [HttpPost]
  363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  364. public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
  365. {
  366. try
  367. {
  368. Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
  369. if (LocalGuide.Code == 0)
  370. {
  371. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  372. }
  373. else
  374. {
  375. return Ok(JsonView(false, LocalGuide.Msg));
  376. }
  377. }
  378. catch (Exception ex)
  379. {
  380. return Ok(JsonView(false, "程序错误!"));
  381. throw;
  382. }
  383. }
  384. /// <summary>
  385. /// 机场三字码数据城市下拉框数据
  386. /// </summary>
  387. /// <returns></returns>
  388. [HttpPost]
  389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  390. public async Task<IActionResult> QueryThreeCodeSelect()
  391. {
  392. try
  393. {
  394. var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
  395. if (ThreeCode.Count == 0)
  396. {
  397. return Ok(JsonView(false, "暂无数据!"));
  398. }
  399. ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
  400. ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  401. ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
  402. List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
  403. foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
  404. {
  405. if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
  406. {
  407. data.Add(_ThreeCode);
  408. }
  409. }
  410. return Ok(JsonView(true, "查询成功", data));
  411. }
  412. catch (Exception)
  413. {
  414. return Ok(JsonView(false, "程序错误!"));
  415. throw;
  416. }
  417. }
  418. /// <summary>
  419. /// 机场三字码资料操作(Status:1.新增,2.修改)
  420. /// </summary>
  421. /// <param name="dto"></param>
  422. /// <returns></returns>
  423. [HttpPost]
  424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  425. public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
  426. {
  427. try
  428. {
  429. if (dto.Three == "")
  430. {
  431. return Ok(JsonView(false, "请检查三字码是否填写!"));
  432. }
  433. if (dto.Country == "")
  434. {
  435. return Ok(JsonView(false, "请检查国家是否填写!"));
  436. }
  437. if (dto.City == "")
  438. {
  439. return Ok(JsonView(false, "请检查城市是否填写正确!"));
  440. }
  441. if (dto.AirPort == "")
  442. {
  443. return Ok(JsonView(false, "请检查机场是否填写正确!"));
  444. }
  445. Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
  446. if (result.Code != 0)
  447. {
  448. return Ok(JsonView(false, result.Msg));
  449. }
  450. return Ok(JsonView(true, result.Msg));
  451. }
  452. catch (Exception ex)
  453. {
  454. return Ok(JsonView(false, "程序错误!"));
  455. throw;
  456. }
  457. }
  458. /// <summary>
  459. /// 机场三字码资料操作(删除)
  460. /// </summary>
  461. /// <returns></returns>
  462. [HttpPost]
  463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  464. public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
  465. {
  466. try
  467. {
  468. var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
  469. if (!res)
  470. {
  471. return Ok(JsonView(false, "删除失败"));
  472. }
  473. return Ok(JsonView(true, "删除成功!"));
  474. }
  475. catch (Exception ex)
  476. {
  477. return Ok(JsonView(false, "程序错误!"));
  478. throw;
  479. }
  480. }
  481. #endregion
  482. #region 代理出票合作方资料
  483. /// <summary>
  484. /// 代理出票合作方资料
  485. /// </summary>
  486. /// <param name="dto"></param>
  487. /// <returns></returns>
  488. [HttpPost]
  489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  490. public async Task<IActionResult> QueryAirTicketAgent(DtoBase dto)
  491. {
  492. try
  493. {
  494. List<Res_AirTicketAgent> res_AirTicketAgents = _airTicketAgentRep.Query<Res_AirTicketAgent>(a => a.IsDel == 0).ToList();
  495. if (res_AirTicketAgents.Count != 0)
  496. {
  497. res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
  498. if (dto.PageSize == 0 && dto.PageIndex == 0)
  499. {
  500. return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
  501. }
  502. else
  503. {
  504. int count = res_AirTicketAgents.Count;
  505. float totalPage = (float)count / dto.PageSize;//总页数
  506. if (totalPage == 0) totalPage = 1;
  507. else totalPage = (int)Math.Ceiling((double)totalPage);
  508. List<Res_AirTicketAgent> _AirTicketAgent = new List<Res_AirTicketAgent>();
  509. for (int i = 0; i < dto.PageSize; i++)
  510. {
  511. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  512. if (RowIndex < res_AirTicketAgents.Count)
  513. {
  514. _AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
  515. }
  516. else
  517. {
  518. break;
  519. }
  520. }
  521. return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
  522. }
  523. }
  524. else
  525. {
  526. return Ok(JsonView(false, "暂无数据!"));
  527. }
  528. }
  529. catch (Exception ex)
  530. {
  531. return Ok(JsonView(false, "程序错误!"));
  532. throw;
  533. }
  534. }
  535. /// <summary>
  536. /// 代理出票合作方资料操作(Status:1.新增,2.修改)
  537. /// </summary>
  538. /// <param name="dto"></param>
  539. /// <returns></returns>
  540. [HttpPost]
  541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  542. public async Task<IActionResult> OpAirTicketAgent(OpAirTicketAgentDto dto)
  543. {
  544. try
  545. {
  546. if (dto.Account == "")
  547. {
  548. return Ok(JsonView(false, "请检查代理商账户是否填写!"));
  549. }
  550. if (dto.Bank == "")
  551. {
  552. return Ok(JsonView(false, "请检查代理商银行是否填写!"));
  553. }
  554. if (dto.Name == "")
  555. {
  556. return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
  557. }
  558. Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
  559. if (result.Code != 0)
  560. {
  561. return Ok(JsonView(false, result.Msg));
  562. }
  563. return Ok(JsonView(true, result.Msg));
  564. }
  565. catch (Exception ex)
  566. {
  567. return Ok(JsonView(false, "程序错误!"));
  568. throw;
  569. }
  570. }
  571. /// <summary>
  572. /// 代理出票合作方资料操作(删除)
  573. /// </summary>
  574. /// <returns></returns>
  575. [HttpPost]
  576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  577. public async Task<IActionResult> DelAirTicketAgent(DelBaseDto dto)
  578. {
  579. try
  580. {
  581. var res = await _airTicketAgentRep.SoftDeleteByIdAsync<Res_AirTicketAgent>(dto.Id.ToString(), dto.DeleteUserId);
  582. if (!res)
  583. {
  584. return Ok(JsonView(false, "删除失败"));
  585. }
  586. return Ok(JsonView(true, "删除成功!"));
  587. }
  588. catch (Exception ex)
  589. {
  590. return Ok(JsonView(false, "程序错误!"));
  591. throw;
  592. }
  593. }
  594. #endregion
  595. #region 酒店资料数据
  596. /// <summary>
  597. /// 酒店信息查询
  598. /// </summary>
  599. /// <param name="dto"></param>
  600. /// <returns></returns>
  601. [HttpPost]
  602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  603. public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
  604. {
  605. try
  606. {
  607. Result hotelData = await _hotelDataRep.QueryHotelData(dto);
  608. if (hotelData.Code == 0)
  609. {
  610. return Ok(JsonView(true, "查询成功", hotelData.Data));
  611. }
  612. else
  613. {
  614. return Ok(JsonView(false, hotelData.Msg));
  615. }
  616. }
  617. catch (Exception ex)
  618. {
  619. return Ok(JsonView(false, "程序错误!"));
  620. throw;
  621. }
  622. }
  623. /// <summary>
  624. /// 酒店资料下拉框数据
  625. /// </summary>
  626. /// <returns></returns>
  627. [HttpPost]
  628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  629. public async Task<IActionResult> QueryHotelDataSelect()
  630. {
  631. try
  632. {
  633. var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
  634. if (HotelData.Count == 0)
  635. {
  636. return Ok(JsonView(false, "暂无数据!"));
  637. }
  638. HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
  639. HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  640. HotelData = HotelData.OrderBy(x => x.Id).ToList();
  641. List<QueryHotelDataSelect> data = new List<QueryHotelDataSelect>();
  642. foreach (QueryHotelDataSelect Hotel in HotelData)
  643. {
  644. if (!string.IsNullOrWhiteSpace(Hotel.City))
  645. {
  646. data.Add(Hotel);
  647. }
  648. }
  649. return Ok(JsonView(true, "查询成功", data));
  650. }
  651. catch (Exception)
  652. {
  653. return Ok(JsonView(false, "程序错误!"));
  654. throw;
  655. }
  656. }
  657. /// <summary>
  658. /// 酒店资料操作(Status:1.新增,2.修改)
  659. /// </summary>
  660. /// <param name="dto"></param>
  661. /// <returns></returns>
  662. [HttpPost]
  663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  664. public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
  665. {
  666. try
  667. {
  668. if (dto.City == "")
  669. {
  670. return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
  671. }
  672. if (dto.Name == "")
  673. {
  674. return Ok(JsonView(false, "请检查酒店名称是否填写!"));
  675. }
  676. if (dto.Address == "")
  677. {
  678. return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
  679. }
  680. if (dto.Tel == "")
  681. {
  682. return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
  683. }
  684. Result result = await _hotelDataRep.OperationHotelData(dto);
  685. if (result.Code != 0)
  686. {
  687. return Ok(JsonView(false, result.Msg));
  688. }
  689. return Ok(JsonView(true, result.Msg));
  690. }
  691. catch (Exception ex)
  692. {
  693. return Ok(JsonView(false, "程序错误!"));
  694. throw;
  695. }
  696. }
  697. /// <summary>
  698. /// 酒店资料操作(删除)
  699. /// </summary>
  700. /// <returns></returns>
  701. [HttpPost]
  702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  703. public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
  704. {
  705. try
  706. {
  707. var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
  708. if (!res)
  709. {
  710. return Ok(JsonView(false, "删除失败"));
  711. }
  712. return Ok(JsonView(true, "删除成功!"));
  713. }
  714. catch (Exception ex)
  715. {
  716. return Ok(JsonView(false, "程序错误!"));
  717. throw;
  718. }
  719. }
  720. #endregion
  721. #region 签证费用资料
  722. /// <summary>
  723. /// 签证费用资料查询
  724. /// </summary>
  725. /// <param name="dto"></param>
  726. /// <returns></returns>
  727. [HttpPost]
  728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  729. public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
  730. {
  731. try
  732. {
  733. if (dto.PortType == 1)
  734. {
  735. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  736. if (CountryFee.Count == 0)
  737. {
  738. return Ok(JsonView(false, "暂无数据!"));
  739. }
  740. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  741. return Ok(JsonView(true, "查询成功", CountryFee));
  742. }
  743. else if (dto.PortType == 2)
  744. {
  745. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  746. if (CountryFee.Count == 0)
  747. {
  748. return Ok(JsonView(false, "暂无数据!"));
  749. }
  750. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  751. return Ok(JsonView(true, "查询成功", CountryFee));
  752. }
  753. else
  754. {
  755. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  756. }
  757. }
  758. catch (Exception ex)
  759. {
  760. return Ok(JsonView(false, "程序错误!"));
  761. throw;
  762. }
  763. }
  764. /// <summary>
  765. /// 签证费用资料操作(Status:1.新增,2.修改)
  766. /// </summary>
  767. /// <param name="dto"></param>
  768. /// <returns></returns>
  769. [HttpPost]
  770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  771. public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
  772. {
  773. try
  774. {
  775. if (dto.VisaContinent == "")
  776. {
  777. return Ok(JsonView(false, "请检查州名是否填写!"));
  778. }
  779. if (dto.VisaCountry == "")
  780. {
  781. return Ok(JsonView(false, "请检查国家名是否填写!"));
  782. }
  783. if (dto.VisaTime == "1")
  784. {
  785. return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
  786. }
  787. if (dto.UrgentTime == "1")
  788. {
  789. return Ok(JsonView(false, "请检加急时间是否填写正确!"));
  790. }
  791. if (dto.VisaPrice == 0)
  792. {
  793. return Ok(JsonView(false, "请检查签证费用是否填写正确,小数点后可1到2位!"));
  794. }
  795. if (dto.VisaPrice == 1)
  796. {
  797. return Ok(JsonView(false, "请检查签证加急费用是否填写正确,小数点后可1到2位!"));
  798. }
  799. Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
  800. if (result.Code != 0)
  801. {
  802. return Ok(JsonView(false, result.Msg));
  803. }
  804. return Ok(JsonView(true, result.Msg));
  805. }
  806. catch (Exception ex)
  807. {
  808. return Ok(JsonView(false, "程序错误!"));
  809. throw;
  810. }
  811. }
  812. /// <summary>
  813. /// 签证费用资料操作(删除)
  814. /// </summary>
  815. /// <returns></returns>
  816. [HttpPost]
  817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  818. public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
  819. {
  820. try
  821. {
  822. var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
  823. if (!res)
  824. {
  825. return Ok(JsonView(false, "删除失败"));
  826. }
  827. return Ok(JsonView(true, "删除成功!"));
  828. }
  829. catch (Exception ex)
  830. {
  831. return Ok(JsonView(false, "程序错误!"));
  832. throw;
  833. }
  834. }
  835. #endregion
  836. #region 物料信息、供应商维护
  837. #region 供应商
  838. /// <summary>
  839. /// 物料供应商查询
  840. /// </summary>
  841. /// <param name="paras">Json序列化</param>
  842. /// <returns></returns>
  843. [HttpPost]
  844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  845. public async Task<IActionResult> PostSearchItemVendor(JsonDtoBase _jsonDto)
  846. {
  847. if (string.IsNullOrEmpty(_jsonDto.Paras))
  848. {
  849. return Ok(JsonView(false, "参数为空"));
  850. }
  851. Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(_jsonDto.Paras);
  852. if (_ItemVendorDto != null)
  853. {
  854. if (_ItemVendorDto.SearchType == 2) //获取列表
  855. {
  856. Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
  857. return Ok(rstList);
  858. }
  859. else
  860. {
  861. Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
  862. return Ok(rstInfo);
  863. }
  864. }
  865. else
  866. {
  867. return Ok(JsonView(false, "参数反序列化失败"));
  868. }
  869. return Ok(JsonView(false));
  870. }
  871. /// <summary>
  872. /// 创建/编辑/删除供应商信息
  873. /// </summary>
  874. /// <param name="_dto"></param>
  875. /// <returns></returns>
  876. [HttpPost]
  877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  878. public async Task<IActionResult> PostEditItemVendor(Edit_ResItemVendorDto _dto)
  879. {
  880. bool rst = false;
  881. if (_dto.EditType >= 0)
  882. {
  883. if (string.IsNullOrEmpty(_dto.VendorFullName))
  884. {
  885. return Ok(JsonView(false, "全称未填写"));
  886. }
  887. if (string.IsNullOrEmpty(_dto.VendorLinker))
  888. {
  889. return Ok(JsonView(false, "联系人未填写"));
  890. }
  891. if (string.IsNullOrEmpty(_dto.VendorMobile))
  892. {
  893. return Ok(JsonView(false, "联系人手机号未填写"));
  894. }
  895. if (string.IsNullOrEmpty(_dto.BusRange))
  896. {
  897. return Ok(JsonView(false, "经营范围未选择"));
  898. }
  899. if (_dto.EditType == 0)
  900. {
  901. var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
  902. if (checkEmpty != null)
  903. {
  904. return Ok(JsonView(false, "已存在同名供应商"));
  905. }
  906. rst = await _resItemInfoRep.addVendorInfo(_dto);
  907. }
  908. else if (_dto.EditType == 1)
  909. {
  910. if (_dto.VendorId > 0)
  911. {
  912. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  913. rst = await _resItemInfoRep.updVendorInfo(_entity);
  914. }
  915. else
  916. {
  917. return Ok(JsonView(false, "供应商不存在"));
  918. }
  919. }
  920. }
  921. else
  922. {
  923. if (_dto.VendorId < 1 || _dto.SysUserId < 1)
  924. {
  925. return Ok(JsonView(false, "用户Id或供应商Id不存在"));
  926. }
  927. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  928. rst = await _resItemInfoRep.delVendorInfo(_entity);
  929. }
  930. return Ok(JsonView(rst));
  931. }
  932. #endregion
  933. #region 物料信息
  934. /// <summary>
  935. /// 物料信息查询
  936. /// </summary>
  937. /// <param name="paras">Json序列化</param>
  938. /// <returns></returns>
  939. [HttpPost]
  940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  941. public async Task<IActionResult> PostSearchItemInfo(string paras)
  942. {
  943. if (string.IsNullOrEmpty(paras))
  944. {
  945. return Ok(JsonView(false, "参数为空"));
  946. }
  947. Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
  948. if (_ItemInfoDto != null)
  949. {
  950. if (_ItemInfoDto.SearchType == 2) //获取列表
  951. {
  952. Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
  953. return Ok(rstList);
  954. }
  955. else
  956. {
  957. Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
  958. return Ok(rstInfo);
  959. }
  960. }
  961. else
  962. {
  963. return Ok(JsonView(false, "参数反序列化失败"));
  964. }
  965. return Ok(JsonView(false));
  966. }
  967. /// <summary>
  968. /// 创建/编辑/删除物料信息
  969. /// </summary>
  970. ///
  971. /// <returns></returns>
  972. [HttpPost]
  973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  974. public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
  975. {
  976. bool rst = false;
  977. if (_dto.EditType >= 0)
  978. {
  979. if (_dto.VendorId < 1)
  980. {
  981. return Ok(JsonView(false, "未选择供应商"));
  982. }
  983. if (string.IsNullOrEmpty(_dto.ItemName))
  984. {
  985. return Ok(JsonView(false, "物料名称为空"));
  986. }
  987. if (_dto.ItemTypeId < 1)
  988. {
  989. return Ok(JsonView(false, "未选择物料类型"));
  990. }
  991. if (_dto.SysUserId < 1)
  992. {
  993. return Ok(JsonView(false, "当前操作用户Id为空"));
  994. }
  995. if (_dto.CurrRate <= 0)
  996. {
  997. return Ok(JsonView(false, "物料录入价格不能小于等于0"));
  998. }
  999. if (_dto.EditType == 0)
  1000. {
  1001. //判断物料名称、类型、供应商全部重复
  1002. var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
  1003. if (checkEmpty != null)
  1004. {
  1005. return Ok(JsonView(false, "已存在重复物料信息"));
  1006. }
  1007. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1008. DateTime dtNow = DateTime.Now;
  1009. _entity.CreateUserId = _dto.SysUserId;
  1010. _entity.IsDel = 0;
  1011. _entity.MaxRate = _dto.CurrRate;
  1012. _entity.MaxDt = dtNow;
  1013. _entity.CurrRate = _dto.CurrRate;
  1014. _entity.CurrDt = dtNow;
  1015. _entity.MinRate = _dto.CurrRate;
  1016. _entity.MinDt = dtNow;
  1017. rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
  1018. }
  1019. else if (_dto.EditType == 1)
  1020. {
  1021. if (_dto.ItemId > 0)
  1022. {
  1023. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1024. _entity.Id = _dto.ItemId;
  1025. rst = await _resItemInfoRep.updItemInfo(_entity);
  1026. }
  1027. else
  1028. {
  1029. return Ok(JsonView(false, "供应商不存在"));
  1030. }
  1031. }
  1032. }
  1033. else
  1034. {
  1035. if (_dto.ItemId < 1 || _dto.SysUserId < 1)
  1036. {
  1037. return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
  1038. }
  1039. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1040. rst = await _resItemInfoRep.delItemInfo(_entity);
  1041. }
  1042. return Ok(JsonView(rst));
  1043. }
  1044. #endregion
  1045. #region 物料类型获取
  1046. #endregion
  1047. #endregion
  1048. #region 备忘录
  1049. /// <summary>
  1050. /// 备忘录查询
  1051. /// </summary>
  1052. /// <param name="paras">Json序列化</param>
  1053. /// <returns></returns>
  1054. [HttpPost]
  1055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1056. public async Task<IActionResult> PostSearchMemo(JsonDtoBase _jsonDto)
  1057. {
  1058. if (string.IsNullOrEmpty(_jsonDto.Paras))
  1059. {
  1060. return Ok(JsonView(false, "参数为空"));
  1061. }
  1062. Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject<Search_ResMemoDto>(_jsonDto.Paras);
  1063. if (_memoDto != null)
  1064. {
  1065. if (_memoDto.SearchType == 2)
  1066. {
  1067. //获取列表
  1068. string sqlWhere = string.Format(" Where IsDel=0 ");
  1069. #region SqlWhere
  1070. if (!string.IsNullOrEmpty(_memoDto.Abstracts))
  1071. {
  1072. sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
  1073. }
  1074. if (!string.IsNullOrEmpty(_memoDto.Title))
  1075. {
  1076. sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
  1077. }
  1078. if (_memoDto.ReadLevel > 0)
  1079. {
  1080. sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
  1081. }
  1082. #endregion
  1083. int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
  1084. int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
  1085. string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
  1086. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1087. m.LastedEditDt,m.LastedEditorId
  1088. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1089. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
  1090. ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
  1091. Res_MemoListView rst = new Res_MemoListView();
  1092. rst.CurrPageIndex = currPIndex;
  1093. rst.CurrPageSize = currPSize;
  1094. List<Res_MemoView> dataSource = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sql).ToList();
  1095. Dictionary<int, string> userDic = new Dictionary<int, string>();
  1096. foreach (var item in dataSource)
  1097. {
  1098. if (userDic.ContainsKey(item.LastedEditorId))
  1099. {
  1100. item.LastedEditor = userDic[item.LastedEditorId];
  1101. }
  1102. else
  1103. {
  1104. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == item.LastedEditorId).First();
  1105. userDic[item.LastedEditorId] = _sysUser.CnName;
  1106. item.LastedEditor = _sysUser.CnName;
  1107. }
  1108. }
  1109. rst.DataList = new List<Res_MemoView>(dataSource);
  1110. if (rst.DataList.Count > 0)
  1111. {
  1112. string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
  1113. int dataCount = _carDataRep._sqlSugar.SqlQueryable<Res_MemoInfo>(sqlCount).Count();
  1114. rst.DataCount = dataCount;
  1115. }
  1116. return Ok(JsonView(rst));
  1117. }
  1118. else
  1119. {
  1120. //获取对象
  1121. string sqlSingle = string.Format(@" Select
  1122. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1123. m.LastedEditDt,m.LastedEditor,m.MDFilePath
  1124. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1125. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
  1126. Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sqlSingle).First();
  1127. if (_result != null)
  1128. {
  1129. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == _result.LastedEditorId).First();
  1130. _result.LastedEditor = _sysUser.CnName;
  1131. _result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
  1132. return Ok(JsonView(_result));
  1133. }
  1134. }
  1135. }
  1136. else
  1137. {
  1138. return Ok(JsonView(false, "参数反序列化失败"));
  1139. }
  1140. return Ok(JsonView(false));
  1141. }
  1142. /// <summary>
  1143. /// 创建/编辑/删除备忘录信息
  1144. /// </summary>
  1145. /// <param name="_dto"></param>
  1146. /// <returns></returns>
  1147. [HttpPost]
  1148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1149. public async Task<IActionResult> PostEditMemo(Edit_ResMemoDto _dto)
  1150. {
  1151. bool rst = false;
  1152. if (_dto.SysUserId < 1)
  1153. {
  1154. return Ok(JsonView(false, "操作人失效"));
  1155. }
  1156. Sys_Users _sysUser = _resItemInfoRep.Query<Sys_Users>(s => s.Id == _dto.SysUserId).First();
  1157. if (_sysUser == null)
  1158. {
  1159. return Ok(JsonView(false, "操作人失效02"));
  1160. }
  1161. if (_dto.EditType >= 0)
  1162. {
  1163. if (_dto.ReadLevel < 1)
  1164. {
  1165. return Ok(JsonView(false, "未知的阅读等级"));
  1166. }
  1167. if (string.IsNullOrEmpty(_dto.Title.Trim()))
  1168. {
  1169. return Ok(JsonView(false, "标题不能为空"));
  1170. }
  1171. if (string.IsNullOrEmpty(_dto.Content.Trim()))
  1172. {
  1173. return Ok(JsonView(false, "正文内容不能为空"));
  1174. }
  1175. //新增备忘录
  1176. DateTime dtNow = DateTime.Now;
  1177. string dir = AppSettingsHelper.Get("MemoCurrPath");
  1178. string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
  1179. string content = JsonConvert.SerializeObject(_dto.Content);
  1180. if (_dto.EditType == 0)//新增
  1181. {
  1182. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1183. if (savePath.Length > 0)
  1184. {
  1185. Res_MemoInfo _insert = new Res_MemoInfo();
  1186. _insert.Abstracts = _dto.Abstracts;
  1187. _insert.Title = _dto.Title;
  1188. _insert.DepartmentId = _sysUser.DepId;
  1189. _insert.CreateUserId = _sysUser.Id;
  1190. _insert.LastedEditDt = dtNow;
  1191. _insert.LastedEditor = _sysUser.Id;
  1192. _insert.MDFilePath = savePath;
  1193. _insert.ReadLevel = _dto.ReadLevel;
  1194. _insert.Title = _dto.Title;
  1195. int result = await _resItemInfoRep.AddAsync(_insert);
  1196. return Ok(JsonView(result > 0));
  1197. }
  1198. else
  1199. {
  1200. return Ok(JsonView(false, "路径保存失败"));
  1201. }
  1202. }
  1203. else//修改
  1204. {
  1205. if (_dto.MemoId < 1)
  1206. {
  1207. return Ok(JsonView(false, "MemoId不存在"));
  1208. }
  1209. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1210. if (_source == null)
  1211. {
  1212. return Ok(JsonView(false, "MemoInfo不存在"));
  1213. }
  1214. //修改
  1215. string sourcePath = _source.MDFilePath;
  1216. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1217. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1218. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1219. if (savePath.Length > 0)
  1220. {
  1221. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1222. .SetColumns(it => it.LastedEditDt == DateTime.Now)
  1223. .SetColumns(it => it.LastedEditor == _sysUser.Id)
  1224. .SetColumns(it => it.Abstracts == _dto.Abstracts)
  1225. .SetColumns(it => it.MDFilePath == savePath)
  1226. .SetColumns(it => it.ReadLevel == _dto.ReadLevel)
  1227. .SetColumns(it => it.Title == _dto.Title)
  1228. .Where(s => s.Id == _source.Id)
  1229. .ExecuteCommandAsync();
  1230. return Ok(JsonView(result > 0));
  1231. }
  1232. }
  1233. }
  1234. else
  1235. {
  1236. //删除
  1237. if (_dto.MemoId < 1)
  1238. {
  1239. return Ok(JsonView(false, "MemoId不存在"));
  1240. }
  1241. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1242. if (_source == null)
  1243. {
  1244. return Ok(JsonView(false, "MemoInfo不存在"));
  1245. }
  1246. //修改
  1247. string sourcePath = _source.MDFilePath;
  1248. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1249. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1250. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1251. .SetColumns(it => it.IsDel == 1)
  1252. .SetColumns(it => it.DeleteUserId == _sysUser.Id)
  1253. .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  1254. .Where(s => s.Id == _source.Id)
  1255. .ExecuteCommandAsync();
  1256. return Ok(JsonView(result > 0));
  1257. }
  1258. return Ok(JsonView(rst));
  1259. }
  1260. #endregion
  1261. #region 商邀资料
  1262. /// <summary>
  1263. /// 商邀资料查询
  1264. /// </summary>
  1265. /// <param name="dto"></param>
  1266. /// <returns></returns>
  1267. [HttpPost]
  1268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1269. public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
  1270. {
  1271. try
  1272. {
  1273. Result groupData = await _InvitationOfficialActivityDataRep.QueryInvitationOfficialActivityData(dto);
  1274. if (groupData.Code != 0)
  1275. {
  1276. return Ok(JsonView(false, groupData.Msg));
  1277. }
  1278. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1279. }
  1280. catch (Exception ex)
  1281. {
  1282. return Ok(JsonView(false, "程序错误!"));
  1283. throw;
  1284. }
  1285. }
  1286. [HttpPost]
  1287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1288. public async Task<IActionResult> QueryInvitationOfficialActivityById(QueryInvitationOfficialActivityByIdDto dto)
  1289. {
  1290. try
  1291. {
  1292. Result groupData = await _InvitationOfficialActivityDataRep.QueryInvitationOfficialActivityById(dto);
  1293. if (groupData.Code != 0)
  1294. {
  1295. return Ok(JsonView(false, groupData.Msg));
  1296. }
  1297. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1298. }
  1299. catch (Exception ex)
  1300. {
  1301. return Ok(JsonView(false, "程序错误!"));
  1302. throw;
  1303. }
  1304. }
  1305. [HttpPost]
  1306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1307. public async Task<IActionResult> OpInvitationOfficialActivity(OpInvitationOfficialActivityDto dto)
  1308. {
  1309. try
  1310. {
  1311. Result groupData = await _InvitationOfficialActivityDataRep.OpInvitationOfficialActivity(dto);
  1312. if (groupData.Code != 0)
  1313. {
  1314. return Ok(JsonView(false, groupData.Msg));
  1315. }
  1316. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1317. }
  1318. catch (Exception ex)
  1319. {
  1320. return Ok(JsonView(false, "程序错误!"));
  1321. throw;
  1322. }
  1323. }
  1324. /// <summary>
  1325. /// 删除商邀资料信息
  1326. /// </summary>
  1327. /// <param name="dto"></param>
  1328. /// <returns></returns>
  1329. [HttpPost]
  1330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1331. public async Task<IActionResult> DelInvitationOfficialActivity(DelBaseDto dto)
  1332. {
  1333. try
  1334. {
  1335. var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync<Res_InvitationOfficialActivityData>(dto.Id.ToString(), dto.DeleteUserId);
  1336. if (!res)
  1337. {
  1338. return Ok(JsonView(false, "删除失败"));
  1339. }
  1340. return Ok(JsonView(true, "删除成功!"));
  1341. }
  1342. catch (Exception ex)
  1343. {
  1344. return Ok(JsonView(false, "程序错误!"));
  1345. throw;
  1346. }
  1347. }
  1348. }
  1349. #endregion
  1350. }