ResourceController.cs 35 KB

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