ResourceController.cs 38 KB

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