ResourceController.cs 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. 
  2. using OASystem.Infrastructure.Repositories.System;
  3. namespace OASystem.API.Controllers
  4. {
  5. /// <summary>
  6. /// 资料相关
  7. /// </summary>
  8. //[Authorize]
  9. [Route("api/[controller]/[action]")]
  10. public class ResourceController : ControllerBase
  11. {
  12. private readonly IMapper _mapper;
  13. private readonly IConfiguration _config;
  14. private readonly CarDataRepository _carDataRep;
  15. private readonly LocalGuideDataRepository _localGuideDataRep;
  16. private readonly ThreeCodeRepository _ThreeCodeRep;
  17. private readonly HotelDataRepository _hotelDataRep;
  18. private readonly ResItemInfoRepository _resItemInfoRep;
  19. private readonly SetDataRepository _setDataRepository;
  20. private readonly CountryFeeRepository _countryFeeRep;
  21. public ResourceController(IMapper mapper, IConfiguration config, CarDataRepository carDataRep,
  22. LocalGuideDataRepository localGuideDataRep, ThreeCodeRepository threeCodeRep,
  23. HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository, CountryFeeRepository countryFeeRep)
  24. {
  25. _mapper = mapper;
  26. _config = config;
  27. _carDataRep = carDataRep;
  28. _localGuideDataRep = localGuideDataRep;
  29. _ThreeCodeRep = threeCodeRep;
  30. _hotelDataRep = hotelDataRep;
  31. _resItemInfoRep = resItemInfoRep;
  32. _setDataRepository = setDataRepository;
  33. _countryFeeRep = countryFeeRep;
  34. }
  35. #region 数据类型资料
  36. [HttpPost]
  37. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  38. public async Task<IActionResult> QuerySetData(SetDataDto dto)
  39. {
  40. try
  41. {
  42. if (dto.DataType == 0)
  43. {
  44. return Ok(JsonView(false, "请传类型Id!"));
  45. }
  46. var setData = _setDataRepository.QueryDto<Sys_SetData, SetDataView>(s => s.STid == dto.DataType).ToList();
  47. if (setData.Count == 0)
  48. {
  49. return Ok(JsonView(false, "暂无数据!"));
  50. }
  51. return Ok(JsonView(true, "查询成功!", setData));
  52. }
  53. catch (Exception ex)
  54. {
  55. return Ok(JsonView(false, "程序错误!"));
  56. throw;
  57. }
  58. }
  59. #endregion
  60. #region 车公司资料板块
  61. /// <summary>
  62. /// 车公司信息查询
  63. /// </summary>
  64. /// <returns></returns>
  65. [HttpPost]
  66. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  67. public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
  68. {
  69. try
  70. {
  71. Result LocalGuide = await _carDataRep.QueryCarData(dto);
  72. if (LocalGuide.Code == 0)
  73. {
  74. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  75. }
  76. else
  77. {
  78. return Ok(JsonView(false, LocalGuide.Msg));
  79. }
  80. }
  81. catch (Exception)
  82. {
  83. return Ok(JsonView(false, "程序错误!"));
  84. throw;
  85. }
  86. }
  87. /// <summary>
  88. /// 车公司资料下拉框数据
  89. /// </summary>
  90. /// <returns></returns>
  91. [HttpPost]
  92. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  93. public async Task<IActionResult> QueryCarSelect()
  94. {
  95. try
  96. {
  97. var CarData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
  98. if (CarData.Count == 0)
  99. {
  100. return Ok(JsonView(false, "暂无数据!"));
  101. }
  102. CarData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
  103. CarData = CarData.Where((x, i) => CarData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
  104. CarData = CarData.OrderBy(x => x.Id).ToList();
  105. List<CarDataSelectView> data= new List<CarDataSelectView>();
  106. foreach (CarDataSelectView car in CarData)
  107. {
  108. if (!string.IsNullOrWhiteSpace(car.UnitArea))
  109. {
  110. data.Add(car);
  111. }
  112. }
  113. return Ok(JsonView(true, "查询成功", data));
  114. }
  115. catch (Exception)
  116. {
  117. return Ok(JsonView(false, "程序错误!"));
  118. throw;
  119. }
  120. }
  121. /// <summary>
  122. /// 车公司信息添加
  123. /// </summary>
  124. /// <returns></returns>
  125. [HttpPost]
  126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  127. public async Task<IActionResult> AddCarData(AddCarDataDto dto)
  128. {
  129. try
  130. {
  131. if (dto.UnitArea == "")
  132. {
  133. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  134. }
  135. if (dto.UnitName == "")
  136. {
  137. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  138. }
  139. if (dto.Contact == "")
  140. {
  141. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  142. }
  143. if (dto.ContactTel == "")
  144. {
  145. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  146. }
  147. 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();
  148. if (carDada.Count != 0)
  149. {
  150. return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
  151. }
  152. Res_CarData _CarData = _mapper.Map<Res_CarData>(dto);
  153. int id = await _carDataRep.AddAsyncReturnId(_CarData);
  154. if (id == 0)
  155. {
  156. return Ok(JsonView(false, "添加失败!"));
  157. }
  158. return Ok(JsonView(true, "添加成功", new { Id = id }));
  159. }
  160. catch (Exception ex)
  161. {
  162. return Ok(JsonView(false, "程序错误!"));
  163. throw;
  164. }
  165. }
  166. /// <summary>
  167. /// 车公司信息修改
  168. /// </summary>
  169. /// <returns></returns>
  170. [HttpPost]
  171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  172. public async Task<IActionResult> UpCarData(UpCarDataDto dto)
  173. {
  174. try
  175. {
  176. if (dto.UnitArea == "")
  177. {
  178. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  179. }
  180. if (dto.UnitName == "")
  181. {
  182. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  183. }
  184. if (dto.Contact == "")
  185. {
  186. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  187. }
  188. if (dto.ContactTel == "")
  189. {
  190. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  191. }
  192. bool res = await _carDataRep.UpdateAsync(a => a.Id == dto.Id, a => new Res_CarData
  193. {
  194. UnitArea = dto.UnitArea,
  195. UnitName = dto.UnitName,
  196. Address = dto.Address,
  197. Contact = dto.Contact,
  198. ContactTel = dto.ContactTel,
  199. ContactEmail = dto.ContactEmail,
  200. ContactFax = dto.ContactFax,
  201. CarDes = dto.CarDes,
  202. CarPicPaths = dto.CarPicPaths,
  203. OtherInfo = dto.OtherInfo,
  204. Score = dto.Score,
  205. QualificationScore = dto.QualificationScore,
  206. CarAgeScore = dto.CarAgeScore,
  207. CleanImgScore = dto.CleanImgScore,
  208. SmellScore = dto.SmellScore,
  209. WaterPaperScore = dto.WaterPaperScore,
  210. HardwareScore = dto.HardwareScore,
  211. TimeScore = dto.TimeScore,
  212. SafetyScore = dto.SafetyScore,
  213. DrivingAgeScore = dto.DrivingAgeScore,
  214. Remark = dto.Remark,
  215. });
  216. if (!res) { return Ok(JsonView(false, "修改失败!")); }
  217. return Ok(JsonView(true, "修改成功"));
  218. }
  219. catch (Exception ex)
  220. {
  221. return Ok(JsonView(false, "程序错误!"));
  222. throw;
  223. }
  224. }
  225. /// <summary>
  226. /// 车公司信息删除
  227. /// </summary>
  228. /// <returns></returns>
  229. [HttpPost]
  230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  231. public async Task<IActionResult> DelCarData(DelCarDataDto dto)
  232. {
  233. try
  234. {
  235. bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
  236. if (!res) { return Ok(JsonView(false, "删除失败!")); }
  237. return Ok(JsonView(true, "删除成功"));
  238. }
  239. catch (Exception ex)
  240. {
  241. return Ok(JsonView(false, "程序错误!"));
  242. throw;
  243. }
  244. }
  245. #endregion
  246. #region 导游地接资料板块
  247. /// <summary>
  248. /// 导游地接资料查询
  249. /// </summary>
  250. /// <param name="dto"></param>
  251. /// <returns></returns>
  252. [HttpPost]
  253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  254. public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
  255. {
  256. try
  257. {
  258. Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
  259. if (LocalGuide.Code == 0)
  260. {
  261. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  262. }
  263. else
  264. {
  265. return Ok(JsonView(false, LocalGuide.Msg));
  266. }
  267. }
  268. catch (Exception ex)
  269. {
  270. return Ok(JsonView(false, "程序错误!"));
  271. throw;
  272. }
  273. }
  274. /// <summary>
  275. /// 导游地接资料下拉框数据
  276. /// </summary>
  277. /// <returns></returns>
  278. [HttpPost]
  279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  280. public async Task<IActionResult> QueryLocalGuideSelect()
  281. {
  282. try
  283. {
  284. var LocalGuide = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
  285. if (LocalGuide.Count == 0)
  286. {
  287. return Ok(JsonView(false, "暂无数据!"));
  288. }
  289. LocalGuide.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
  290. LocalGuide = LocalGuide.Where((x, i) => LocalGuide.FindIndex(z => z.UnitArea == x.UnitArea && z.UnitArea != "") == i).ToList();
  291. LocalGuide = LocalGuide.OrderBy(x => x.Id).ToList();
  292. List<QueryLocalGuideSelectView> data = new List<QueryLocalGuideSelectView>();
  293. foreach (QueryLocalGuideSelectView Local in LocalGuide)
  294. {
  295. if (!string.IsNullOrWhiteSpace(Local.UnitArea))
  296. {
  297. data.Add(Local);
  298. }
  299. }
  300. return Ok(JsonView(true, "查询成功", data));
  301. }
  302. catch (Exception)
  303. {
  304. return Ok(JsonView(false, "程序错误!"));
  305. throw;
  306. }
  307. }
  308. /// <summary>
  309. /// 导游地接信息操作(Status:1.新增,2.修改)
  310. /// </summary>
  311. /// <returns></returns>
  312. [HttpPost]
  313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  314. public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
  315. {
  316. try
  317. {
  318. if (dto.UnitArea == "")
  319. {
  320. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  321. }
  322. if (dto.UnitName == "")
  323. {
  324. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  325. }
  326. if (dto.Contact == "")
  327. {
  328. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  329. }
  330. if (dto.ContactTel == "")
  331. {
  332. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  333. }
  334. Result result = await _localGuideDataRep.LocalGuideOperation(dto);
  335. if (result.Code != 0)
  336. {
  337. return Ok(JsonView(false, result.Msg));
  338. }
  339. return Ok(JsonView(true, result.Msg));
  340. }
  341. catch (Exception ex)
  342. {
  343. return Ok(JsonView(false, "程序错误!"));
  344. throw;
  345. }
  346. }
  347. /// <summary>
  348. /// 导游地接信息操作(删除)
  349. /// </summary>
  350. /// <returns></returns>
  351. [HttpPost]
  352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  353. public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
  354. {
  355. try
  356. {
  357. var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
  358. if (!res)
  359. {
  360. return Ok(JsonView(false, "删除失败"));
  361. }
  362. return Ok(JsonView(true, "删除成功!"));
  363. }
  364. catch (Exception ex)
  365. {
  366. return Ok(JsonView(false, "程序错误!"));
  367. throw;
  368. }
  369. }
  370. #endregion
  371. #region 机场三字码信息
  372. /// <summary>
  373. /// 机场三字码查询
  374. /// </summary>
  375. /// <param name="dto"></param>
  376. /// <returns></returns>
  377. [HttpPost]
  378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  379. public async Task<IActionResult> QueryThreeCode(DtoBase dto)
  380. {
  381. try
  382. {
  383. if (dto.PortType == 1)
  384. {
  385. var ThreeCode = _localGuideDataRep.QueryDto<Res_ThreeCode, ThreeCodeView>().ToList();
  386. if (ThreeCode.Count == 0)
  387. {
  388. return Ok(JsonView(false, "暂无数据!"));
  389. }
  390. ThreeCode = ThreeCode.OrderByDescending(s => s.CreateTime).ToList();
  391. return Ok(JsonView(true, "查询成功", ThreeCode));
  392. }
  393. else if (dto.PortType == 2)
  394. {
  395. //分页写法
  396. if (dto.PageIndex == 0 || dto.PageSize == 0)
  397. {
  398. return Ok(JsonView(false, "请传入PageIndex和PageSize参数"));
  399. }
  400. JsonView _ThreeCode = await _ThreeCodeRep.QuerThreeCode(dto.PageIndex, dto.PageSize);
  401. if (_ThreeCode.Code != 0)
  402. {
  403. return Ok(JsonView(false, _ThreeCode.Msg));
  404. }
  405. return Ok(_ThreeCode);
  406. }
  407. else
  408. {
  409. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  410. }
  411. }
  412. catch (Exception ex)
  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> QueryHotelData(QueryHotelDataDto dto)
  491. {
  492. try
  493. {
  494. Result hotelData = await _hotelDataRep.QueryHotelData(dto);
  495. if (hotelData.Code == 0)
  496. {
  497. return Ok(JsonView(true, "查询成功", hotelData.Data));
  498. }
  499. else
  500. {
  501. return Ok(JsonView(false, hotelData.Msg));
  502. }
  503. }
  504. catch (Exception ex)
  505. {
  506. return Ok(JsonView(false, "程序错误!"));
  507. throw;
  508. }
  509. }
  510. /// <summary>
  511. /// 酒店资料下拉框数据
  512. /// </summary>
  513. /// <returns></returns>
  514. [HttpPost]
  515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  516. public async Task<IActionResult> QueryHotelDataSelect()
  517. {
  518. try
  519. {
  520. var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
  521. if (HotelData.Count == 0)
  522. {
  523. return Ok(JsonView(false, "暂无数据!"));
  524. }
  525. HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
  526. HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  527. HotelData = HotelData.OrderBy(x => x.Id).ToList();
  528. List<QueryHotelDataSelect> data = new List<QueryHotelDataSelect>();
  529. foreach (QueryHotelDataSelect Hotel in HotelData)
  530. {
  531. if (!string.IsNullOrWhiteSpace(Hotel.City))
  532. {
  533. data.Add(Hotel);
  534. }
  535. }
  536. return Ok(JsonView(true, "查询成功", data));
  537. }
  538. catch (Exception)
  539. {
  540. return Ok(JsonView(false, "程序错误!"));
  541. throw;
  542. }
  543. }
  544. /// <summary>
  545. /// 酒店资料操作(Status:1.新增,2.修改)
  546. /// </summary>
  547. /// <param name="dto"></param>
  548. /// <returns></returns>
  549. [HttpPost]
  550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  551. public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
  552. {
  553. try
  554. {
  555. if (dto.City == "")
  556. {
  557. return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
  558. }
  559. if (dto.Name == "")
  560. {
  561. return Ok(JsonView(false, "请检查酒店名称是否填写!"));
  562. }
  563. if (dto.Address == "")
  564. {
  565. return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
  566. }
  567. if (dto.Tel == "")
  568. {
  569. return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
  570. }
  571. Result result = await _hotelDataRep.OperationHotelData(dto);
  572. if (result.Code != 0)
  573. {
  574. return Ok(JsonView(false, result.Msg));
  575. }
  576. return Ok(JsonView(true, result.Msg));
  577. }
  578. catch (Exception ex)
  579. {
  580. return Ok(JsonView(false, "程序错误!"));
  581. throw;
  582. }
  583. }
  584. /// <summary>
  585. /// 酒店资料操作(删除)
  586. /// </summary>
  587. /// <returns></returns>
  588. [HttpPost]
  589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  590. public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
  591. {
  592. try
  593. {
  594. var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
  595. if (!res)
  596. {
  597. return Ok(JsonView(false, "删除失败"));
  598. }
  599. return Ok(JsonView(true, "删除成功!"));
  600. }
  601. catch (Exception ex)
  602. {
  603. return Ok(JsonView(false, "程序错误!"));
  604. throw;
  605. }
  606. }
  607. #endregion
  608. #region 签证费用资料
  609. /// <summary>
  610. /// 签证费用资料查询
  611. /// </summary>
  612. /// <param name="dto"></param>
  613. /// <returns></returns>
  614. [HttpPost]
  615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  616. public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
  617. {
  618. try
  619. {
  620. if (dto.PortType == 1)
  621. {
  622. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  623. if (CountryFee.Count == 0)
  624. {
  625. return Ok(JsonView(false, "暂无数据!"));
  626. }
  627. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  628. return Ok(JsonView(true, "查询成功", CountryFee));
  629. }
  630. else if (dto.PortType == 2)
  631. {
  632. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  633. if (CountryFee.Count == 0)
  634. {
  635. return Ok(JsonView(false, "暂无数据!"));
  636. }
  637. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  638. return Ok(JsonView(true, "查询成功", CountryFee));
  639. }
  640. else
  641. {
  642. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  643. }
  644. }
  645. catch (Exception ex)
  646. {
  647. return Ok(JsonView(false, "程序错误!"));
  648. throw;
  649. }
  650. }
  651. /// <summary>
  652. /// 签证费用资料操作(Status:1.新增,2.修改)
  653. /// </summary>
  654. /// <param name="dto"></param>
  655. /// <returns></returns>
  656. [HttpPost]
  657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  658. public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
  659. {
  660. try
  661. {
  662. if (dto.VisaContinent == "")
  663. {
  664. return Ok(JsonView(false, "请检查州名是否填写!"));
  665. }
  666. if (dto.VisaCountry == "")
  667. {
  668. return Ok(JsonView(false, "请检查国家名是否填写!"));
  669. }
  670. if (dto.VisaTime == "1")
  671. {
  672. return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
  673. }
  674. if (dto.UrgentTime == "1")
  675. {
  676. return Ok(JsonView(false, "请检加急时间是否填写正确!"));
  677. }
  678. if (dto.VisaPrice == 0)
  679. {
  680. return Ok(JsonView(false, "请检查签证费用是否填写正确,小数点后可1到2位!"));
  681. }
  682. if (dto.VisaPrice == 1)
  683. {
  684. return Ok(JsonView(false, "请检查签证加急费用是否填写正确,小数点后可1到2位!"));
  685. }
  686. Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
  687. if (result.Code != 0)
  688. {
  689. return Ok(JsonView(false, result.Msg));
  690. }
  691. return Ok(JsonView(true, result.Msg));
  692. }
  693. catch (Exception ex)
  694. {
  695. return Ok(JsonView(false, "程序错误!"));
  696. throw;
  697. }
  698. }
  699. /// <summary>
  700. /// 签证费用资料操作(删除)
  701. /// </summary>
  702. /// <returns></returns>
  703. [HttpPost]
  704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  705. public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
  706. {
  707. try
  708. {
  709. var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
  710. if (!res)
  711. {
  712. return Ok(JsonView(false, "删除失败"));
  713. }
  714. return Ok(JsonView(true, "删除成功!"));
  715. }
  716. catch (Exception ex)
  717. {
  718. return Ok(JsonView(false, "程序错误!"));
  719. throw;
  720. }
  721. }
  722. #endregion
  723. #region 物料信息、供应商维护
  724. #region 供应商
  725. /// <summary>
  726. /// 物料供应商查询
  727. /// </summary>
  728. /// <param name="paras">Json序列化</param>
  729. /// <returns></returns>
  730. [HttpPost]
  731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  732. public async Task<IActionResult> PostSearchItemVendor(string paras)
  733. {
  734. if (string.IsNullOrEmpty(paras))
  735. {
  736. return Ok(JsonView(false, "参数为空"));
  737. }
  738. Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(paras);
  739. if (_ItemVendorDto != null)
  740. {
  741. if (_ItemVendorDto.SearchType == 2) //获取列表
  742. {
  743. Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
  744. return Ok(rstList);
  745. }
  746. else
  747. {
  748. Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
  749. return Ok(rstInfo);
  750. }
  751. }
  752. else
  753. {
  754. return Ok(JsonView(false, "参数反序列化失败"));
  755. }
  756. return Ok(JsonView(false));
  757. }
  758. /// <summary>
  759. /// 创建/编辑/删除供应商信息
  760. /// </summary>
  761. /// <param name="_dto"></param>
  762. /// <returns></returns>
  763. [HttpPost]
  764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  765. public async Task<IActionResult> PostEditItemVendor(Edit_ResItemVendorDto _dto)
  766. {
  767. bool rst = false;
  768. if (_dto.EditType >= 0)
  769. {
  770. if (string.IsNullOrEmpty(_dto.VendorFullName))
  771. {
  772. return Ok(JsonView(false, "全称未填写"));
  773. }
  774. if (string.IsNullOrEmpty(_dto.VendorLinker))
  775. {
  776. return Ok(JsonView(false, "联系人未填写"));
  777. }
  778. if (string.IsNullOrEmpty(_dto.VendorMobile))
  779. {
  780. return Ok(JsonView(false, "联系人手机号未填写"));
  781. }
  782. if (_dto.EditType == 0)
  783. {
  784. var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
  785. if (checkEmpty != null)
  786. {
  787. return Ok(JsonView(false, "已存在同名供应商"));
  788. }
  789. rst = await _resItemInfoRep.addVendorInfo(_dto);
  790. }
  791. else if (_dto.EditType == 1)
  792. {
  793. if (_dto.VendorId > 0)
  794. {
  795. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  796. rst = await _resItemInfoRep.updVendorInfo(_entity);
  797. }
  798. else
  799. {
  800. return Ok(JsonView(false, "供应商不存在"));
  801. }
  802. }
  803. }
  804. else
  805. {
  806. if (_dto.VendorId < 1 || _dto.SysUserId < 1)
  807. {
  808. return Ok(JsonView(false, "用户Id或供应商Id不存在"));
  809. }
  810. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  811. rst = await _resItemInfoRep.delVendorInfo(_entity);
  812. }
  813. return Ok(JsonView(rst));
  814. }
  815. #endregion
  816. #region 物料信息
  817. /// <summary>
  818. /// 物料信息查询
  819. /// </summary>
  820. /// <param name="paras">Json序列化</param>
  821. /// <returns></returns>
  822. [HttpPost]
  823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  824. public async Task<IActionResult> PostSearchItemInfo(string paras)
  825. {
  826. if (string.IsNullOrEmpty(paras))
  827. {
  828. return Ok(JsonView(false, "参数为空"));
  829. }
  830. Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
  831. if (_ItemInfoDto != null)
  832. {
  833. if (_ItemInfoDto.SearchType == 2) //获取列表
  834. {
  835. Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
  836. return Ok(rstList);
  837. }
  838. else
  839. {
  840. Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
  841. return Ok(rstInfo);
  842. }
  843. }
  844. else
  845. {
  846. return Ok(JsonView(false, "参数反序列化失败"));
  847. }
  848. return Ok(JsonView(false));
  849. }
  850. /// <summary>
  851. /// 创建/编辑/删除物料信息
  852. /// </summary>
  853. ///
  854. /// <returns></returns>
  855. [HttpPost]
  856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  857. public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
  858. {
  859. bool rst = false;
  860. if (_dto.EditType >= 0)
  861. {
  862. if (_dto.VendorId < 1)
  863. {
  864. return Ok(JsonView(false, "未选择供应商"));
  865. }
  866. if (string.IsNullOrEmpty(_dto.ItemName))
  867. {
  868. return Ok(JsonView(false, "物料名称为空"));
  869. }
  870. if (_dto.SetDataId < 1)
  871. {
  872. return Ok(JsonView(false, "未选择物料类型"));
  873. }
  874. if (_dto.SysUserId < 1)
  875. {
  876. return Ok(JsonView(false, "当前操作用户Id为空"));
  877. }
  878. if (_dto.CurrRate <= 0)
  879. {
  880. return Ok(JsonView(false, "物料录入价格不能小于等于0"));
  881. }
  882. if (_dto.EditType == 0)
  883. {
  884. //判断物料名称、类型、供应商全部重复
  885. var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.SetDataId == _dto.SetDataId && s.VendorId == _dto.VendorId).First();
  886. if (checkEmpty != null)
  887. {
  888. return Ok(JsonView(false, "已存在重复物料信息"));
  889. }
  890. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  891. DateTime dtNow = DateTime.Now;
  892. _entity.CreateUserId = _dto.SysUserId;
  893. _entity.IsDel = 0;
  894. _entity.MaxRate = _dto.CurrRate;
  895. _entity.MaxDt = dtNow;
  896. _entity.CurrRate = _dto.CurrRate;
  897. _entity.CurrDt = dtNow;
  898. _entity.MinRate = _dto.CurrRate;
  899. _entity.MinDt = dtNow;
  900. rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
  901. }
  902. else if (_dto.EditType == 1)
  903. {
  904. if (_dto.ItemId > 0)
  905. {
  906. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  907. _entity.Id = _dto.ItemId;
  908. rst = await _resItemInfoRep.updItemInfo(_entity);
  909. }
  910. else
  911. {
  912. return Ok(JsonView(false, "供应商不存在"));
  913. }
  914. }
  915. }
  916. else
  917. {
  918. if (_dto.ItemId < 1 || _dto.SysUserId < 1)
  919. {
  920. return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
  921. }
  922. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  923. rst = await _resItemInfoRep.delItemInfo(_entity);
  924. }
  925. return Ok(JsonView(rst));
  926. }
  927. #endregion
  928. #region 物料类型获取
  929. /// <summary>
  930. /// 物料类型列表获取
  931. /// </summary>
  932. /// <param name="paras">Json序列化</param>
  933. /// <returns></returns>
  934. [HttpGet]
  935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  936. public async Task<IActionResult> GetItemTypeListBySetData()
  937. {
  938. List<SetDataView> list = _resItemInfoRep.GetItemTypeListBySetData();
  939. return Ok(JsonView(list));
  940. }
  941. #endregion
  942. #endregion
  943. }
  944. }