ResourceController.cs 35 KB

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