ResourceController.cs 36 KB

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