GroupsController.cs 134 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. namespace OASystem.API.Controllers
  32. {
  33. /// <summary>
  34. /// 团组相关
  35. /// </summary>
  36. //[Authorize]
  37. [Route("api/[controller]/[action]")]
  38. public class GroupsController : ControllerBase
  39. {
  40. private readonly GrpScheduleRepository _grpScheduleRep;
  41. private readonly IMapper _mapper;
  42. private readonly DelegationInfoRepository _groupRepository;
  43. private readonly TaskAssignmentRepository _taskAssignmentRep;
  44. private readonly AirTicketResRepository _airTicketResRep;
  45. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  46. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  47. private readonly DelegationEnDataRepository _delegationEnDataRep;
  48. private readonly DelegationVisaRepository _delegationVisaRep;
  49. private readonly VisaPriceRepository _visaPriceRep;
  50. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  51. private readonly MessageRepository _message;
  52. private readonly SqlSugarClient _sqlSugar;
  53. private string url;
  54. private string path;
  55. private readonly EnterExitCostRepository _enterExitCostRep;
  56. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  57. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  58. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  59. , DelegationVisaRepository delegationVisaRep, MessageRepository message,VisaPriceRepository visaPriceRep,CarTouristGuideGroundRepository carTouristGuideGroundRep)
  60. {
  61. _mapper = mapper;
  62. _grpScheduleRep = grpScheduleRep;
  63. _groupRepository = groupRepository;
  64. _taskAssignmentRep = taskAssignmentRep;
  65. _airTicketResRep = airTicketResRep;
  66. _sqlSugar = sqlSugar;
  67. url = AppSettingsHelper.Get("ExcelBaseUrl");
  68. path = AppSettingsHelper.Get("ExcelBasePath");
  69. if (!System.IO.Directory.Exists(path))
  70. {
  71. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  72. }
  73. _decreasePaymentsRep = decreasePaymentsRep;
  74. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  75. _delegationEnDataRep = delegationEnDataRep;
  76. _enterExitCostRep = enterExitCostRep;
  77. _delegationVisaRep = delegationVisaRep;
  78. _message = message;
  79. _visaPriceRep= visaPriceRep;
  80. _carTouristGuideGroundRep= carTouristGuideGroundRep;
  81. }
  82. #region 流程管控
  83. /// <summary>
  84. /// 获取团组流程管控信息
  85. /// </summary>
  86. /// <param name="paras">参数Json字符串</param>
  87. /// <returns></returns>
  88. [HttpPost]
  89. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  90. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  91. {
  92. if (string.IsNullOrEmpty(_jsonDto.Paras))
  93. {
  94. return Ok(JsonView(false, "参数为空"));
  95. }
  96. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  97. if (_ScheduleDto != null)
  98. {
  99. if (_ScheduleDto.SearchType == 2)//获取列表
  100. {
  101. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  102. return Ok(JsonView(_grpScheduleViewList));
  103. }
  104. else//获取对象
  105. {
  106. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  107. if (_grpScheduleView != null)
  108. {
  109. return Ok(JsonView(_grpScheduleView));
  110. }
  111. }
  112. }
  113. else
  114. {
  115. return Ok(JsonView(false, "参数反序列化失败"));
  116. }
  117. return Ok(JsonView(false, "暂无数据!"));
  118. }
  119. /// <summary>
  120. /// 修改团组流程管控详细表数据
  121. /// </summary>
  122. /// <param name="paras"></param>
  123. /// <returns></returns>
  124. [HttpPost]
  125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  126. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  127. {
  128. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  129. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  130. .SetColumns(it => it.Duty == _detail.Duty)
  131. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  132. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  133. .SetColumns(it => it.JobContent == _detail.JobContent)
  134. .SetColumns(it => it.Remark == _detail.Remark)
  135. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  136. .Where(s => s.Id == dto.Id)
  137. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  138. .ExecuteCommandAsync();
  139. if (result > 0)
  140. {
  141. return Ok(JsonView(true, "保存成功!"));
  142. }
  143. return Ok(JsonView(false, "保存失败!"));
  144. }
  145. /// <summary>
  146. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  147. /// </summary>
  148. /// <param name="dto"></param>
  149. /// <returns></returns>
  150. [HttpPost]
  151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  152. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  153. {
  154. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  155. _detail.IsDel = 1;
  156. _detail.DeleteUserId = dto.Duty;
  157. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  158. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  159. .SetColumns(it => it.IsDel == _detail.IsDel)
  160. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  161. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  162. .Where(it => it.Id == dto.Id)
  163. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  164. //.WhereColumns(s => s.Id == dto.Id)
  165. .ExecuteCommandAsync();
  166. if (result > 0)
  167. {
  168. return Ok(JsonView(true, "删除成功!"));
  169. }
  170. return Ok(JsonView(false, "删除失败!"));
  171. }
  172. /// <summary>
  173. /// 增加团组流程管控详细表数据
  174. /// </summary>
  175. /// <param name="dto"></param>
  176. /// <returns></returns>
  177. [HttpPost]
  178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  179. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  180. {
  181. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  182. if (DateTime.Now < _detail.ExpectBeginDt)
  183. {
  184. _detail.StepStatus = 0;
  185. }
  186. else
  187. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  188. _detail.StepStatus = 1;
  189. }
  190. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  191. if (result > 0)
  192. {
  193. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  194. return Ok(JsonView(true, "添加成功!", _result));
  195. }
  196. return Ok(JsonView(false, "添加失败!"));
  197. }
  198. #endregion
  199. #region 团组基本信息
  200. /// <summary>
  201. /// 接团信息列表
  202. /// </summary>
  203. /// <param name="dto">团组列表请求dto</param>
  204. /// <returns></returns>
  205. [HttpPost]
  206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  207. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  208. {
  209. var groupData = await _groupRepository.GetGroupList(dto);
  210. if (groupData.Code != 0)
  211. {
  212. return Ok(JsonView(false, groupData.Msg));
  213. }
  214. return Ok(JsonView(groupData.Data));
  215. }
  216. /// <summary>
  217. /// 接团信息详情
  218. /// </summary>
  219. /// <param name="dto">团组info请求dto</param>
  220. /// <returns></returns>
  221. [HttpPost]
  222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  223. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  224. {
  225. var groupData = await _groupRepository.GetGroupInfo(dto);
  226. if (groupData.Code != 0)
  227. {
  228. return Ok(JsonView(false, groupData.Msg));
  229. }
  230. return Ok(JsonView(groupData.Data));
  231. }
  232. /// <summary>
  233. /// 接团信息 编辑添加
  234. /// 基础信息数据源
  235. /// </summary>
  236. /// <param name="dto"></param>
  237. /// <returns></returns>
  238. [HttpPost]
  239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  240. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  241. {
  242. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  243. if (groupData.Code != 0)
  244. {
  245. return Ok(JsonView(false, groupData.Msg));
  246. }
  247. return Ok(JsonView(groupData.Data));
  248. }
  249. /// <summary>
  250. /// 接团信息 操作(增改)
  251. /// </summary>
  252. /// <param name="dto"></param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  256. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  257. {
  258. try
  259. {
  260. var groupData = await _groupRepository.GroupOperation(dto);
  261. if (groupData.Code != 0)
  262. {
  263. return Ok(JsonView(false, groupData.Msg));
  264. }
  265. return Ok(JsonView(true));
  266. }
  267. catch (Exception ex)
  268. {
  269. Logs("[response]" + JsonConvert.SerializeObject(dto));
  270. Logs(ex.Message);
  271. return Ok(JsonView(false, ex.Message));
  272. }
  273. }
  274. /// <summary>
  275. /// 接团信息 操作(删除)
  276. /// </summary>
  277. /// <param name="dto"></param>
  278. /// <returns></returns>
  279. [HttpPost]
  280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  281. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  282. {
  283. try
  284. {
  285. var groupData = await _groupRepository.GroupDel(dto);
  286. if (groupData.Code != 0)
  287. {
  288. return Ok(JsonView(false, groupData.Msg));
  289. }
  290. return Ok(JsonView(true));
  291. }
  292. catch (Exception ex)
  293. {
  294. Logs("[response]" + JsonConvert.SerializeObject(dto));
  295. Logs(ex.Message);
  296. return Ok(JsonView(false, ex.Message));
  297. }
  298. }
  299. /// <summary>
  300. /// 获取团组销售报价号
  301. /// 团组添加时 使用
  302. /// </summary>
  303. /// <returns></returns>
  304. [HttpPost]
  305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  306. public async Task<IActionResult> GetGroupSalesQuoteNo()
  307. {
  308. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  309. if (groupData.Code != 0)
  310. {
  311. return Ok(JsonView(false, groupData.Msg));
  312. }
  313. object salesQuoteNo = new
  314. {
  315. SalesQuoteNo = groupData.Data
  316. };
  317. return Ok(JsonView(salesQuoteNo));
  318. }
  319. /// <summary>
  320. /// 设置确认出团
  321. /// </summary>
  322. /// <param name="dto"></param>
  323. /// <returns></returns>
  324. [HttpPost]
  325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  326. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  327. {
  328. var groupData = await _groupRepository.ConfirmationGroup(dto);
  329. if (groupData.Code != 0)
  330. {
  331. return Ok(JsonView(false, groupData.Msg));
  332. }
  333. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  334. return Ok(JsonView(true,"操作成功!",groupData.Data));
  335. }
  336. /// <summary>
  337. /// 获取团组名称data And 签证国别Data
  338. /// </summary>
  339. /// <param name="dto"></param>
  340. /// <returns></returns>
  341. [HttpPost]
  342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  343. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  344. {
  345. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  346. if (groupData.Code != 0)
  347. {
  348. return Ok(JsonView(false, groupData.Msg));
  349. }
  350. return Ok(JsonView(groupData.Data));
  351. }
  352. /// <summary>
  353. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  354. /// </summary>
  355. /// <returns></returns>
  356. [HttpPost]
  357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  358. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  359. {
  360. try
  361. {
  362. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  363. if (groupData.Code != 0)
  364. {
  365. return Ok(JsonView(false, groupData.Msg));
  366. }
  367. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  368. }
  369. catch (Exception ex)
  370. {
  371. return Ok(JsonView(false, "程序错误!"));
  372. throw;
  373. }
  374. }
  375. #endregion
  376. #region 团组&签证
  377. /// <summary>
  378. /// 根据团组Id获取签证客户信息List
  379. /// </summary>
  380. /// <param name="dto">请求dto</param>
  381. /// <returns></returns>
  382. [HttpPost]
  383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  384. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  385. {
  386. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  387. if (groupData.Code != 0)
  388. {
  389. return Ok(JsonView(false, groupData.Msg));
  390. }
  391. return Ok(JsonView(groupData.Data));
  392. }
  393. /// <summary>
  394. /// IOS获取团组签证拍照上传进度01(团组列表)
  395. /// </summary>
  396. /// <param name="dto">请求dto</param>
  397. /// <returns></returns>
  398. [HttpPost]
  399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  400. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  401. {
  402. if (dto == null)
  403. {
  404. return Ok(JsonView(false, "参数为空"));
  405. }
  406. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  407. return Ok(JsonView(visaList));
  408. }
  409. /// <summary>
  410. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  411. /// </summary>
  412. /// <returns></returns>
  413. [HttpPost]
  414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  415. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  416. {
  417. if (dto == null)
  418. {
  419. return Ok(JsonView(false, "请求错误:"));
  420. }
  421. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  422. return Ok(JsonView(list));
  423. }
  424. /// <summary>
  425. /// IOS获取团组签证拍照上传进度03(相册)
  426. /// </summary>
  427. /// <returns></returns>
  428. [HttpPost]
  429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  430. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  431. {
  432. if (dto == null)
  433. {
  434. return Ok(JsonView(false, "请求错误:"));
  435. }
  436. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  437. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  438. list.ForEach(s => s.url = url);
  439. return Ok(JsonView(list));
  440. }
  441. /// <summary>
  442. /// IOS获取团组签证拍照上传进度04(图片上传)
  443. /// </summary>
  444. /// <param name="dto"></param>
  445. /// <returns></returns>
  446. [HttpPost]
  447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  448. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  449. {
  450. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  451. //if (!string.IsNullOrEmpty(result))
  452. //{
  453. //}
  454. //else {
  455. // return Ok(JsonView(false, "上传失败"));
  456. //}
  457. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  458. int sucNum = 0;
  459. try
  460. {
  461. foreach (var item in dto.base64DataList)
  462. {
  463. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  464. string result = decodeBase64ToImage(item, imageName);
  465. if (!string.IsNullOrEmpty(result))
  466. {
  467. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  468. pic.CreateUserId = dto.CreateUserId;
  469. pic.PicName = imageName;
  470. pic.PicPath = result;
  471. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  472. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  473. if (insertResult > 0)
  474. {
  475. sucNum++;
  476. }
  477. }
  478. }
  479. }
  480. catch (Exception ex)
  481. {
  482. return Ok(JsonView(false, ex.Message));
  483. }
  484. string msg = string.Format(@"成功上传{0}张", sucNum);
  485. return Ok(JsonView(true, msg));
  486. }
  487. private string decodeBase64ToImage(string base64DataURL, string imgName)
  488. {
  489. string filename = "";//声明一个string类型的相对路径
  490. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  491. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  492. try//会有异常抛出,try,catch一下
  493. {
  494. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  495. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  496. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  497. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  498. //文件名称
  499. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  500. //上传的文件的路径
  501. string filePath = "";
  502. if (!Directory.Exists(fileDir))
  503. {
  504. Directory.CreateDirectory(fileDir);
  505. }
  506. //上传的文件的路径
  507. filePath = fileDir + filename;
  508. //string url = HttpRuntime.AppDomainAppPath.ToString();
  509. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  510. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  511. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  512. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  513. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  514. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  515. ms.Close();//关闭当前流,并释放所有与之关联的资源
  516. bitmap.Dispose();
  517. }
  518. catch (Exception e)
  519. {
  520. string massage = e.Message;
  521. Logs("IOS图片上传Error:" + massage);
  522. //filename = e.Message;
  523. }
  524. return filename;//返回相对路径
  525. }
  526. /// <summary>
  527. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  528. /// </summary>
  529. /// <param name="dto"></param>
  530. /// <returns></returns>
  531. [HttpPost]
  532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  533. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  534. {
  535. if (dto == null)
  536. {
  537. return Ok(JsonView(false, "请求错误:"));
  538. }
  539. string msg = "参数错误";
  540. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  541. {
  542. try
  543. {
  544. //_delegationVisaRep.BeginTran();
  545. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  546. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  547. .Where(s => s.Id == dto.visaProgressCustomerId)
  548. .ExecuteCommandAsync();
  549. if (updCount > 0 && dto.publishCode == 1) {
  550. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  551. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  552. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  553. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  554. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  555. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  556. if (groupData == null)
  557. {
  558. _delegationVisaRep.RollbackTran();
  559. }
  560. string title = string.Format(@"[签证进度更新]");
  561. string content = string.Format(@"测试文本");
  562. bool rst = await _message.AddMsg(new MessageDto()
  563. {
  564. Type = 5,
  565. IssuerId = dto.publisher,
  566. Title = title,
  567. Content = content,
  568. ReleaseTime = DateTime.Now,
  569. UIdList = new List<int> {
  570. 234
  571. }
  572. });
  573. if (rst) {
  574. return Ok(JsonView(true, "发送通知成功"));
  575. }
  576. }
  577. //_delegationVisaRep.CommitTran();
  578. }
  579. catch (Exception)
  580. {
  581. //_delegationVisaRep.RollbackTran();
  582. }
  583. }
  584. return Ok(JsonView(true, msg));
  585. }
  586. #endregion
  587. #region 团组任务分配
  588. /// <summary>
  589. /// 团组任务分配初始化
  590. /// </summary>
  591. /// <param name="dto"></param>
  592. /// <returns></returns>
  593. [HttpPost]
  594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  595. public async Task<IActionResult> GetTaskAssignmen()
  596. {
  597. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  598. if (groupData.Code != 0)
  599. {
  600. return Ok(JsonView(false, groupData.Msg));
  601. }
  602. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  603. }
  604. /// <summary>
  605. /// 团组任务分配查询
  606. /// </summary>
  607. /// <param name="dto"></param>
  608. /// <returns></returns>
  609. [HttpPost]
  610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  611. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  612. {
  613. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  614. if (groupData.Code != 0)
  615. {
  616. return Ok(JsonView(false, groupData.Msg));
  617. }
  618. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  619. }
  620. /// <summary>
  621. /// 团组任务分配操作
  622. /// </summary>
  623. /// <param name="dto"></param>
  624. /// <returns></returns>
  625. [HttpPost]
  626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  627. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  628. {
  629. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  630. if (groupData.Code != 0)
  631. {
  632. return Ok(JsonView(false, groupData.Msg));
  633. }
  634. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  635. }
  636. #endregion
  637. #region 团组费用审核
  638. /// <summary>
  639. /// 获取团组费用审核
  640. /// </summary>
  641. /// <param name="paras">参数Json字符串</param>
  642. /// <returns></returns>
  643. [HttpPost]
  644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  645. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  646. {
  647. if (_dto.DiId < 1)
  648. {
  649. return Ok(JsonView(false, "团组Id为空"));
  650. }
  651. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  652. #region 团组基本信息
  653. Grp_DelegationInfo _delegation = _groupRepository.Query<Grp_DelegationInfo>(s => s.Id == _dto.DiId).First();
  654. if (_delegation != null)
  655. {
  656. _view.ClientName = _delegation.ClientName;
  657. _view.DiId = _dto.DiId;
  658. _view.TeamName = _delegation.TeamName;
  659. _view.VisitCountry = _delegation.VisitCountry;
  660. _view.VisitDate = _delegation.VisitStartDate.ToString("yyyy-MM-dd") + " ~ " + _delegation.VisitEndDate.ToString("yyyy-MM-dd");
  661. _view.VisitDays = _delegation.VisitDays;
  662. _view.VisitPNumber = _delegation.VisitPNumber;
  663. }
  664. else
  665. {
  666. return Ok(JsonView(false, "团组信息为空"));
  667. }
  668. #endregion
  669. #region 费用清单
  670. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  671. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  672. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  673. List<Grp_CreditCardPayment> entityList = _groupRepository
  674. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  675. .Where(exp.ToExpression())
  676. .ToList();
  677. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  678. decimal CNY = 0;
  679. decimal PayCNY = 0;
  680. decimal BalanceCNY = 0;
  681. decimal YSFYCNY = 0;
  682. decimal USD = 0;
  683. decimal PayUSD = 0;
  684. decimal BalanceUSD = 0;
  685. decimal YSFYUSD = 0;
  686. decimal EUR = 0;
  687. decimal PayEUR = 0;
  688. decimal BalanceEUR = 0;
  689. decimal YSFYEUR = 0;
  690. foreach (var entity in entityList)
  691. {
  692. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  693. _detail.Id = entity.Id;
  694. /*
  695. * Bus名称
  696. */
  697. _detail.BusName = "";
  698. /*
  699. *费用所属
  700. */
  701. switch (entity.CTable)
  702. {
  703. case 85:
  704. Grp_AirTicketReservations jpRes = _groupRepository.Query<Grp_AirTicketReservations>(s => s.Id == entity.CId).First();
  705. if (jpRes != null)
  706. {
  707. string FlightsDescription = jpRes.FlightsDescription;
  708. string PriceDescription = jpRes.PriceDescription;
  709. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  710. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  711. }
  712. break;
  713. case 79:
  714. _detail.BusName = "待增加";
  715. break;
  716. case 98:
  717. Grp_DecreasePayments gdpRes = _groupRepository.Query<Grp_DecreasePayments>(s => s.Id == entity.CId).First();
  718. if (gdpRes != null)
  719. {
  720. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  721. _detail.PriceNameContent = gdpRes.PriceName;
  722. }
  723. break;
  724. default:
  725. break;
  726. }
  727. /*
  728. * 费用模块
  729. */
  730. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.CTable).First();
  731. if (sdPriceName != null)
  732. {
  733. _detail.PriceName = sdPriceName.Name;
  734. }
  735. /*
  736. * 应付款金额
  737. */
  738. Sys_SetData sdPaymentCurrency_WaitPay = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.PaymentCurrency).First();
  739. string PaymentCurrency_WaitPay = "Unknown";
  740. if (sdPaymentCurrency_WaitPay != null)
  741. {
  742. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  743. }
  744. _detail.WaitPay = entity.PayMoney.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  745. /*
  746. * 此次付款金额
  747. */
  748. decimal CurrPayStr = 0;
  749. if (entity.PayPercentage == 0)
  750. {
  751. if (entity.PayThenMoney != 0)
  752. CurrPayStr = entity.PayThenMoney * entity.DayRate;
  753. }
  754. else
  755. {
  756. CurrPayStr = entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * entity.DayRate);
  757. }
  758. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  759. /*
  760. * 剩余尾款
  761. */
  762. decimal BalanceStr = 0;
  763. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  764. BalanceStr = 0;
  765. else
  766. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate);
  767. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  768. /*
  769. * 申请人
  770. */
  771. string operatorName = "无";
  772. Sys_Users _opUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.CreateUserId).First();
  773. if (_opUser != null)
  774. {
  775. operatorName = _opUser.CnName;
  776. }
  777. _detail.OperatorName = operatorName;
  778. /*
  779. * 审核人
  780. */
  781. string auditOperatorName = "Unknown";
  782. if (entity.AuditGMOperate == 0)
  783. auditOperatorName = "无";
  784. else if (entity.AuditGMOperate == 4)
  785. auditOperatorName = "自动审核";
  786. else
  787. {
  788. Sys_Users _adUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.AuditGMOperate).First();
  789. if (_adUser != null)
  790. {
  791. auditOperatorName = _adUser.CnName;
  792. }
  793. }
  794. _detail.AuditOperatorName = auditOperatorName;
  795. /*
  796. *
  797. * *超预算比例
  798. */
  799. string overBudgetStr = "";
  800. if (entity.ExceedBudget == -1)
  801. overBudgetStr = sdPriceName.Name + "尚无预算";
  802. else if (entity.ExceedBudget == 0)
  803. overBudgetStr = "未超预算";
  804. else
  805. overBudgetStr = entity.ExceedBudget.ToString("P");
  806. _detail.OverBudget = overBudgetStr;
  807. /*
  808. * 费用总计
  809. */
  810. if (entity.PaymentCurrency == 48)
  811. {
  812. CNY += entity.PayMoney;
  813. PayCNY += CurrPayStr;
  814. BalanceCNY += BalanceStr;
  815. YSFYCNY += CurrPayStr;
  816. }
  817. if (entity.PaymentCurrency == 49)
  818. {
  819. USD += entity.PayMoney;
  820. PayUSD += CurrPayStr;
  821. BalanceUSD += BalanceStr;
  822. YSFYUSD += CurrPayStr;
  823. }
  824. if (entity.PaymentCurrency == 51)
  825. {
  826. EUR += entity.PayMoney;
  827. PayEUR += CurrPayStr;
  828. BalanceEUR += BalanceStr;
  829. YSFYEUR += CurrPayStr;
  830. }
  831. _detail.IsAuditGM = entity.IsAuditGM;
  832. detailList.Add(_detail);
  833. }
  834. #endregion
  835. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  836. _view.TotalStr1 = string.Format(@"应付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", CNY, USD, EUR);
  837. _view.TotalStr2 = string.Format(@"此次付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", PayCNY, PayUSD, PayEUR);
  838. _view.TotalStr3 = string.Format(@"目前剩余尾款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", BalanceCNY, BalanceUSD, BalanceEUR);
  839. _view.TotalStr4 = string.Format(@"已审费用总额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", YSFYCNY, YSFYUSD, YSFYEUR);
  840. return Ok(JsonView(_view));
  841. }
  842. /// <summary>
  843. /// 修改团组费用审核状态
  844. /// </summary>
  845. /// <param name="paras">参数Json字符串</param>
  846. /// <returns></returns>
  847. [HttpPost]
  848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  849. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  850. {
  851. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  852. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  853. DateTime dtNow = DateTime.Now;
  854. _groupRepository.BeginTran();
  855. int rst = 0;
  856. foreach (var item in idList)
  857. {
  858. int CreditId = int.Parse(item);
  859. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  860. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  861. .SetColumns(it => it.AuditGMOperate == _dto.User)
  862. .SetColumns(it => it.AuditGMDate == dtNow.ToString())
  863. .Where(s => s.Id == CreditId)
  864. .ExecuteCommandAsync();
  865. if (result < 1)
  866. {
  867. rst = -1;
  868. }
  869. else
  870. {
  871. _groupRepository.RollbackTran();
  872. return Ok(JsonView(false, "保存失败并回滚!"));
  873. }
  874. }
  875. _groupRepository.CommitTran();
  876. if (rst == 0)
  877. {
  878. return Ok(JsonView(true, "保存成功!"));
  879. }
  880. return Ok(JsonView(false, "保存失败!"));
  881. }
  882. #endregion
  883. #region 机票费用录入
  884. /// <summary>
  885. /// 机票录入当前登录人可操作团组
  886. /// </summary>
  887. /// <param name="dto"></param>
  888. /// <returns></returns>
  889. [HttpPost]
  890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  891. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  892. {
  893. try
  894. {
  895. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  896. if (groupData.Code != 0)
  897. {
  898. return Ok(JsonView(false, groupData.Msg));
  899. }
  900. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  901. }
  902. catch (Exception ex)
  903. {
  904. return Ok(JsonView(false, "程序错误!"));
  905. throw;
  906. }
  907. }
  908. /// <summary>
  909. /// 机票费用录入列表
  910. /// </summary>
  911. /// <param name="dto"></param>
  912. /// <returns></returns>
  913. [HttpPost]
  914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  915. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  916. {
  917. try
  918. {
  919. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  920. if (groupData.Code != 0)
  921. {
  922. return Ok(JsonView(false, groupData.Msg));
  923. }
  924. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  925. }
  926. catch (Exception ex)
  927. {
  928. return Ok(JsonView(false, "程序错误!"));
  929. throw;
  930. }
  931. }
  932. /// <summary>
  933. /// 根据id查询费用录入信息
  934. /// </summary>
  935. /// <param name="dto"></param>
  936. /// <returns></returns>
  937. [HttpPost]
  938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  939. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  940. {
  941. try
  942. {
  943. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  944. if (groupData.Code != 0)
  945. {
  946. return Ok(JsonView(false, groupData.Msg));
  947. }
  948. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  949. }
  950. catch (Exception ex)
  951. {
  952. return Ok(JsonView(false, "程序错误!"));
  953. throw;
  954. }
  955. }
  956. /// <summary>
  957. /// 机票费用录入操作(Status:1.新增,2.修改)
  958. /// </summary>
  959. /// <param name="dto"></param>
  960. /// <returns></returns>
  961. [HttpPost]
  962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  963. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  964. {
  965. try
  966. {
  967. Result groupData = await _airTicketResRep.OpAirTicketRes(dto);
  968. if (groupData.Code != 0)
  969. {
  970. return Ok(JsonView(false, groupData.Msg));
  971. }
  972. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  973. }
  974. catch (Exception ex)
  975. {
  976. return Ok(JsonView(false, "程序错误!"));
  977. throw;
  978. }
  979. }
  980. /// <summary>
  981. /// 根据舱位类型查询接团客户名单信息
  982. /// </summary>
  983. /// <param name="dto"></param>
  984. /// <returns></returns>
  985. [HttpPost]
  986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  987. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  988. {
  989. try
  990. {
  991. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  992. if (crm_Groups.Count != 0)
  993. {
  994. List<dynamic> Customer = new List<dynamic>();
  995. foreach (var item in crm_Groups)
  996. {
  997. var data = new
  998. {
  999. Id = item.Id,
  1000. Pinyin = item.Pinyin,
  1001. Name = item.LastName + item.FirstName
  1002. };
  1003. Customer.Add(data);
  1004. }
  1005. return Ok(JsonView(true, "查询成功!", Customer));
  1006. }
  1007. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1008. }
  1009. catch (Exception ex)
  1010. {
  1011. return Ok(JsonView(false, "程序错误!"));
  1012. throw;
  1013. }
  1014. }
  1015. /// <summary>
  1016. /// 机票费用录入,删除
  1017. /// </summary>
  1018. /// <param name="dto"></param>
  1019. /// <returns></returns>
  1020. [HttpPost]
  1021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1022. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1023. {
  1024. try
  1025. {
  1026. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1027. if (!res)
  1028. {
  1029. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1030. {
  1031. IsDel = 1,
  1032. DeleteUserId = dto.DeleteUserId,
  1033. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1034. }).ExecuteCommandAsync();
  1035. return Ok(JsonView(false, "删除失败"));
  1036. }
  1037. return Ok(JsonView(true, "删除成功!"));
  1038. }
  1039. catch (Exception ex)
  1040. {
  1041. return Ok(JsonView(false, "程序错误!"));
  1042. throw;
  1043. }
  1044. }
  1045. /// <summary>
  1046. /// 导出机票录入报表
  1047. /// </summary>
  1048. /// <param name="dto"></param>
  1049. /// <returns></returns>
  1050. [HttpPost]
  1051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1052. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  1053. {
  1054. try
  1055. {
  1056. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1057. if (groupData.Code != 0)
  1058. {
  1059. return Ok(JsonView(false, groupData.Msg));
  1060. }
  1061. else
  1062. {
  1063. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1064. if (AirTicketReservations.Count != 0)
  1065. {
  1066. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1067. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1068. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1069. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1070. WorkbookDesigner designer = new WorkbookDesigner();
  1071. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1072. decimal countCost = 0;
  1073. foreach (var item in AirTicketReservations)
  1074. {
  1075. if (item.BankType == "其他")
  1076. {
  1077. item.BankNo = "--";
  1078. }
  1079. else
  1080. {
  1081. item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
  1082. }
  1083. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1084. item.Price = System.Decimal.Round(item.Price, 2);
  1085. countCost += Convert.ToDecimal(item.Price);
  1086. }
  1087. designer.SetDataSource("Export", AirTicketReservations);
  1088. designer.SetDataSource("ExportDiCode", diCode);
  1089. designer.SetDataSource("ExportDiName", diName);
  1090. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1091. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1092. designer.Process();
  1093. string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  1094. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1095. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1096. return Ok(JsonView(true, "成功", url = rst));
  1097. }
  1098. else
  1099. {
  1100. return Ok(JsonView(false, "暂无数据!"));
  1101. }
  1102. }
  1103. }
  1104. catch (Exception ex)
  1105. {
  1106. return Ok(JsonView(false, "程序错误!"));
  1107. throw;
  1108. }
  1109. }
  1110. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1111. /// <summary>
  1112. /// 行程单导出
  1113. /// </summary>
  1114. /// <param name="dto"></param>
  1115. /// <returns></returns>
  1116. [HttpPost]
  1117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1118. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1119. {
  1120. try
  1121. {
  1122. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1123. if (groupData.Code != 0)
  1124. {
  1125. return Ok(JsonView(false, groupData.Msg));
  1126. }
  1127. else
  1128. {
  1129. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1130. if (dto.Language == "CN")
  1131. {
  1132. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1133. DocumentBuilder builder = new DocumentBuilder(doc);
  1134. int tableIndex = 0;//表格索引
  1135. //得到文档中的第一个表格
  1136. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1137. foreach (var item in _AirTicketReservations)
  1138. {
  1139. #region 处理固定数据
  1140. string[] FlightsCode = item.FlightsCode.Split('/');
  1141. if (FlightsCode.Length != 0)
  1142. {
  1143. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1144. if (_AirCompany != null)
  1145. {
  1146. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1147. }
  1148. else
  1149. {
  1150. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1151. }
  1152. }
  1153. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1154. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1155. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1156. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1157. string name = "";
  1158. foreach (string clientName in nameArray)
  1159. {
  1160. if (!name.Contains(clientName))
  1161. {
  1162. name += clientName + ",";
  1163. }
  1164. }
  1165. if (!string.IsNullOrWhiteSpace(name))
  1166. {
  1167. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1168. }
  1169. else
  1170. {
  1171. table.Range.Bookmarks["ClientName"].Text = "--";
  1172. }
  1173. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1174. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1175. table.Range.Bookmarks["JointTicket"].Text = "--";
  1176. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1177. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1178. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1179. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1180. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1181. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1182. #endregion
  1183. #region 循环数据处理
  1184. List<AirInfo> airs = new List<AirInfo>();
  1185. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1186. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1187. for (int i = 0; i < FlightsCode.Length; i++)
  1188. {
  1189. AirInfo air = new AirInfo();
  1190. string[] tempstr = DayArray[i]
  1191. .Replace("\r\n", string.Empty)
  1192. .Replace("\\r\\n", string.Empty)
  1193. .TrimStart().TrimEnd()
  1194. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1195. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1196. string starCity = "";
  1197. if (star_Three != null)
  1198. {
  1199. starCity = star_Three.AirPort;
  1200. }
  1201. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1202. string EndCity = "";
  1203. if (End_Three != null)
  1204. {
  1205. EndCity = End_Three.AirPort;
  1206. }
  1207. air.Destination = starCity + "/" + EndCity;
  1208. air.Flight = FlightsCode[i];
  1209. air.SeatingClass = item.CTypeName;
  1210. string dateTime = tempstr[2];
  1211. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1212. air.FlightDate = DateTemp;
  1213. air.DepartureTime = tempstr[5];
  1214. air.LandingTime = tempstr[6];
  1215. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1216. air.TicketStatus = "--";
  1217. air.Luggage = "--";
  1218. air.DepartureTerminal = "--";
  1219. air.LandingTerminal = "--";
  1220. airs.Add(air);
  1221. }
  1222. int row = 13;
  1223. for (int i = 0; i < airs.Count; i++)
  1224. {
  1225. if (airs.Count > 2)
  1226. {
  1227. for (int j = 0; j < airs.Count - 2; j++)
  1228. {
  1229. var CopyRow = table.Rows[12].Clone(true);
  1230. table.Rows.Add(CopyRow);
  1231. }
  1232. }
  1233. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1234. int index = 0;
  1235. foreach (PropertyInfo property in properties)
  1236. {
  1237. string value = property.GetValue(airs[i]).ToString();
  1238. Cell ishcel0 = table.Rows[row].Cells[index];
  1239. Paragraph p = new Paragraph(doc);
  1240. string s = value;
  1241. p.AppendChild(new Run(doc, s));
  1242. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1243. ishcel0.AppendChild(p);
  1244. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1245. index++;
  1246. }
  1247. row++;
  1248. }
  1249. #endregion
  1250. Paragraph lastParagraph = new Paragraph(doc);
  1251. //第一个表格末尾加段落
  1252. table.ParentNode.InsertAfter(lastParagraph, table);
  1253. //复制第一个表格
  1254. Table cloneTable = (Table)table.Clone(true);
  1255. //在文档末尾段落后面加入复制的表格
  1256. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1257. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1258. {
  1259. int rownewsIndex = 13;
  1260. for (int i = 0; i < 2; i++)
  1261. {
  1262. var CopyRow = table.Rows[12].Clone(true);
  1263. table.Rows.RemoveAt(13);
  1264. table.Rows.Add(CopyRow);
  1265. rownewsIndex++;
  1266. }
  1267. }
  1268. else
  1269. {
  1270. table.Rows.RemoveAt(12);
  1271. }
  1272. cloneTable.Rows.RemoveAt(12);
  1273. }
  1274. if (_AirTicketReservations.Count != 0)
  1275. {
  1276. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1277. if (FlightsCode.Length != 0)
  1278. {
  1279. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1280. if (_AirCompany != null)
  1281. {
  1282. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1283. }
  1284. else
  1285. {
  1286. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1287. }
  1288. }
  1289. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1290. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1291. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1292. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1293. string name = "";
  1294. foreach (string clientName in nameArray)
  1295. {
  1296. if (!name.Contains(clientName))
  1297. {
  1298. name += clientName + ",";
  1299. }
  1300. }
  1301. if (!string.IsNullOrWhiteSpace(name))
  1302. {
  1303. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1304. }
  1305. else
  1306. {
  1307. table.Range.Bookmarks["ClientName"].Text = "--";
  1308. }
  1309. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1310. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1311. table.Range.Bookmarks["JointTicket"].Text = "--";
  1312. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1313. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1314. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1315. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1316. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1317. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1318. }
  1319. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1320. //保存合并后的文档
  1321. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  1322. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1323. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1324. return Ok(JsonView(true, "成功!", rst));
  1325. }
  1326. else
  1327. {
  1328. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  1329. DocumentBuilder builder = new DocumentBuilder(doc);
  1330. int tableIndex = 0;//表格索引
  1331. //得到文档中的第一个表格
  1332. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1333. List<string> texts = new List<string>();
  1334. foreach (var item in _AirTicketReservations)
  1335. {
  1336. string[] FlightsCode = item.FlightsCode.Split('/');
  1337. if (FlightsCode.Length != 0)
  1338. {
  1339. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1340. if (_AirCompany != null)
  1341. {
  1342. if (!transDic.ContainsKey(_AirCompany.CnName))
  1343. {
  1344. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  1345. }
  1346. }
  1347. else
  1348. {
  1349. if (!transDic.ContainsKey("--"))
  1350. {
  1351. transDic.Add("--", "--");
  1352. }
  1353. }
  1354. }
  1355. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1356. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1357. string name = "";
  1358. foreach (string clientName in nameArray)
  1359. {
  1360. name += clientName + ",";
  1361. }
  1362. if (!texts.Contains(name))
  1363. {
  1364. texts.Add(name);
  1365. }
  1366. List<AirInfo> airs = new List<AirInfo>();
  1367. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1368. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1369. for (int i = 0; i < FlightsCode.Length; i++)
  1370. {
  1371. AirInfo air = new AirInfo();
  1372. string[] tempstr = DayArray[i]
  1373. .Replace("\r\n", string.Empty)
  1374. .Replace("\\r\\n", string.Empty)
  1375. .TrimStart().TrimEnd()
  1376. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1377. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1378. if (star_Three != null)
  1379. {
  1380. if (!transDic.ContainsKey(star_Three.AirPort))
  1381. {
  1382. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  1383. }
  1384. }
  1385. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1386. if (End_Three != null)
  1387. {
  1388. if (!transDic.ContainsKey(End_Three.AirPort))
  1389. {
  1390. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  1391. }
  1392. }
  1393. if (!texts.Contains(item.CTypeName))
  1394. {
  1395. texts.Add(item.CTypeName);
  1396. }
  1397. }
  1398. }
  1399. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  1400. if (transData.Count > 0)
  1401. {
  1402. foreach (TranslateResult item in transData)
  1403. {
  1404. if (!transDic.ContainsKey(item.Query))
  1405. {
  1406. transDic.Add(item.Query, item.Translation);
  1407. }
  1408. }
  1409. }
  1410. foreach (var item in _AirTicketReservations)
  1411. {
  1412. #region 处理固定数据
  1413. string[] FlightsCode = item.FlightsCode.Split('/');
  1414. if (FlightsCode.Length != 0)
  1415. {
  1416. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1417. if (_AirCompany != null)
  1418. {
  1419. string str = "--";
  1420. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1421. if (!string.IsNullOrEmpty(translateResult))
  1422. {
  1423. str = translateResult;
  1424. str = _airTicketResRep.Processing(str);
  1425. }
  1426. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1427. }
  1428. else
  1429. {
  1430. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1431. }
  1432. }
  1433. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1434. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1435. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1436. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1437. string names = "";
  1438. foreach (string clientName in nameArray)
  1439. {
  1440. names += clientName + ",";
  1441. }
  1442. if (!string.IsNullOrWhiteSpace(names))
  1443. {
  1444. string str = "--";
  1445. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1446. if (!string.IsNullOrEmpty(translateResult))
  1447. {
  1448. str = translateResult;
  1449. str = _airTicketResRep.Processing(str);
  1450. }
  1451. table.Range.Bookmarks["ClientName"].Text = str;
  1452. }
  1453. else
  1454. {
  1455. table.Range.Bookmarks["ClientName"].Text = "--";
  1456. }
  1457. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1458. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1459. table.Range.Bookmarks["JointTicket"].Text = "--";
  1460. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1461. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1462. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1463. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1464. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1465. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1466. #endregion
  1467. #region 循环数据处理
  1468. List<AirInfo> airs = new List<AirInfo>();
  1469. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1470. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1471. for (int i = 0; i < FlightsCode.Length; i++)
  1472. {
  1473. AirInfo air = new AirInfo();
  1474. string[] tempstr = DayArray[i]
  1475. .Replace("\r\n", string.Empty)
  1476. .Replace("\\r\\n", string.Empty)
  1477. .TrimStart().TrimEnd()
  1478. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1479. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1480. string starCity = "";
  1481. if (star_Three != null)
  1482. {
  1483. string str2 = "--";
  1484. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  1485. if (!string.IsNullOrEmpty(translateResult2))
  1486. {
  1487. str2 = translateResult2;
  1488. str2 = _airTicketResRep.Processing(str2);
  1489. }
  1490. starCity = str2;
  1491. }
  1492. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1493. string EndCity = "";
  1494. if (End_Three != null)
  1495. {
  1496. string str1 = "--";
  1497. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  1498. if (!string.IsNullOrEmpty(translateResult1))
  1499. {
  1500. str1 = translateResult1;
  1501. str1 = _airTicketResRep.Processing(str1);
  1502. }
  1503. EndCity = str1;
  1504. }
  1505. air.Destination = starCity + "/" + EndCity;
  1506. air.Flight = FlightsCode[i];
  1507. string str = "--";
  1508. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  1509. if (!string.IsNullOrEmpty(translateResult))
  1510. {
  1511. str = translateResult;
  1512. str = _airTicketResRep.Processing(str);
  1513. }
  1514. air.SeatingClass = str;
  1515. string dateTime = tempstr[2];
  1516. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1517. air.FlightDate = DateTemp;
  1518. air.DepartureTime = tempstr[5];
  1519. air.LandingTime = tempstr[6];
  1520. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1521. air.TicketStatus = "--";
  1522. air.Luggage = "--";
  1523. air.DepartureTerminal = "--";
  1524. air.LandingTerminal = "--";
  1525. airs.Add(air);
  1526. }
  1527. int row = 13;
  1528. for (int i = 0; i < airs.Count; i++)
  1529. {
  1530. if (airs.Count > 2)
  1531. {
  1532. for (int j = 0; j < airs.Count - 2; j++)
  1533. {
  1534. var CopyRow = table.Rows[12].Clone(true);
  1535. table.Rows.Add(CopyRow);
  1536. }
  1537. }
  1538. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1539. int index = 0;
  1540. foreach (PropertyInfo property in properties)
  1541. {
  1542. string value = property.GetValue(airs[i]).ToString();
  1543. Cell ishcel0 = table.Rows[row].Cells[index];
  1544. Paragraph p = new Paragraph(doc);
  1545. string s = value;
  1546. p.AppendChild(new Run(doc, s));
  1547. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1548. ishcel0.AppendChild(p);
  1549. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1550. //ishcel0.CellFormat.VerticalAlignment=
  1551. index++;
  1552. }
  1553. row++;
  1554. }
  1555. #endregion
  1556. Paragraph lastParagraph = new Paragraph(doc);
  1557. //第一个表格末尾加段落
  1558. table.ParentNode.InsertAfter(lastParagraph, table);
  1559. //复制第一个表格
  1560. Table cloneTable = (Table)table.Clone(true);
  1561. //在文档末尾段落后面加入复制的表格
  1562. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1563. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1564. {
  1565. int rownewsIndex = 13;
  1566. for (int i = 0; i < 2; i++)
  1567. {
  1568. var CopyRow = table.Rows[12].Clone(true);
  1569. table.Rows.RemoveAt(13);
  1570. table.Rows.Add(CopyRow);
  1571. rownewsIndex++;
  1572. }
  1573. }
  1574. else
  1575. {
  1576. table.Rows.RemoveAt(12);
  1577. }
  1578. cloneTable.Rows.RemoveAt(12);
  1579. }
  1580. if (_AirTicketReservations.Count != 0)
  1581. {
  1582. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1583. if (FlightsCode.Length != 0)
  1584. {
  1585. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1586. if (_AirCompany != null)
  1587. {
  1588. string str = "--";
  1589. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1590. if (!string.IsNullOrEmpty(translateResult))
  1591. {
  1592. str = translateResult;
  1593. str = _airTicketResRep.Processing(str);
  1594. }
  1595. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1596. }
  1597. else
  1598. {
  1599. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1600. }
  1601. }
  1602. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1603. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1604. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1605. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1606. string names = "";
  1607. foreach (string clientName in nameArray)
  1608. {
  1609. names += clientName + ",";
  1610. }
  1611. if (!string.IsNullOrWhiteSpace(names))
  1612. {
  1613. string str = "--";
  1614. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1615. if (!string.IsNullOrEmpty(translateResult))
  1616. {
  1617. str = translateResult;
  1618. str = _airTicketResRep.Processing(str);
  1619. }
  1620. table.Range.Bookmarks["ClientName"].Text = str;
  1621. }
  1622. else
  1623. {
  1624. table.Range.Bookmarks["ClientName"].Text = "--";
  1625. }
  1626. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1627. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1628. table.Range.Bookmarks["JointTicket"].Text = "--";
  1629. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1630. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1631. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1632. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1633. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1634. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1635. }
  1636. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1637. //保存合并后的文档
  1638. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  1639. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1640. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1641. return Ok(JsonView(true, "成功!", rst));
  1642. }
  1643. }
  1644. }
  1645. catch (Exception ex)
  1646. {
  1647. return Ok(JsonView(false, "程序错误!"));
  1648. throw;
  1649. }
  1650. }
  1651. #endregion
  1652. #region 团组增减款项
  1653. /// <summary>
  1654. /// 团组增减款项下拉框绑定
  1655. /// </summary>
  1656. /// <param name="dto"></param>
  1657. /// <returns></returns>
  1658. [HttpPost]
  1659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1660. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  1661. {
  1662. try
  1663. {
  1664. Result groupData = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  1665. if (groupData.Code != 0)
  1666. {
  1667. return Ok(JsonView(false, groupData.Msg));
  1668. }
  1669. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1670. }
  1671. catch (Exception ex)
  1672. {
  1673. return Ok(JsonView(false, "程序错误!"));
  1674. throw;
  1675. }
  1676. }
  1677. /// <summary>
  1678. /// 根据团组Id查询团组增减款项
  1679. /// </summary>
  1680. /// <param name="dto"></param>
  1681. /// <returns></returns>
  1682. [HttpPost]
  1683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1684. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  1685. {
  1686. try
  1687. {
  1688. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  1689. if (groupData.Code != 0)
  1690. {
  1691. return Ok(JsonView(false, groupData.Msg));
  1692. }
  1693. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1694. }
  1695. catch (Exception ex)
  1696. {
  1697. return Ok(JsonView(false, "程序错误!"));
  1698. throw;
  1699. }
  1700. }
  1701. /// <summary>
  1702. /// 团组增减款项操作(Status:1.新增,2.修改)
  1703. /// </summary>
  1704. /// <param name="dto"></param>
  1705. /// <returns></returns>
  1706. [HttpPost]
  1707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1708. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  1709. {
  1710. try
  1711. {
  1712. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  1713. if (groupData.Code != 0)
  1714. {
  1715. return Ok(JsonView(false, groupData.Msg));
  1716. }
  1717. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1718. }
  1719. catch (Exception ex)
  1720. {
  1721. return Ok(JsonView(false, "程序错误!"));
  1722. throw;
  1723. }
  1724. }
  1725. /// <summary>
  1726. /// 团组增减款项操作 删除
  1727. /// </summary>
  1728. /// <param name="dto"></param>
  1729. /// <returns></returns>
  1730. [HttpPost]
  1731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1732. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  1733. {
  1734. try
  1735. {
  1736. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  1737. if (!res)
  1738. {
  1739. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  1740. {
  1741. IsDel = 1,
  1742. DeleteUserId = dto.DeleteUserId,
  1743. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1744. }).ExecuteCommandAsync();
  1745. return Ok(JsonView(false, "删除失败"));
  1746. }
  1747. return Ok(JsonView(true, "删除成功!"));
  1748. }
  1749. catch (Exception ex)
  1750. {
  1751. return Ok(JsonView(false, "程序错误!"));
  1752. throw;
  1753. }
  1754. }
  1755. /// <summary>
  1756. /// 根据团组增减款项Id查询
  1757. /// </summary>
  1758. /// <param name="dto"></param>
  1759. /// <returns></returns>
  1760. [HttpPost]
  1761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1762. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  1763. {
  1764. try
  1765. {
  1766. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  1767. if (groupData.Code != 0)
  1768. {
  1769. return Ok(JsonView(false, groupData.Msg));
  1770. }
  1771. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1772. }
  1773. catch (Exception ex)
  1774. {
  1775. return Ok(JsonView(false, "程序错误!"));
  1776. throw;
  1777. }
  1778. }
  1779. #endregion
  1780. #region 文件上传、删除
  1781. /// <summary>
  1782. /// region 文件上传 可以带参数
  1783. /// </summary>
  1784. /// <param name="file"></param>
  1785. /// <returns></returns>
  1786. [HttpPost]
  1787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1788. public async Task<IActionResult> UploadProject(IFormFile file)
  1789. {
  1790. try
  1791. {
  1792. var TypeName = Request.Headers["TypeName"].ToString();
  1793. if (file != null)
  1794. {
  1795. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1796. //文件名称
  1797. string projectFileName = file.FileName;
  1798. //上传的文件的路径
  1799. string filePath = "";
  1800. if (TypeName == "A")//A代表团组增减款项
  1801. {
  1802. if (!Directory.Exists(fileDir))
  1803. {
  1804. Directory.CreateDirectory(fileDir);
  1805. }
  1806. //上传的文件的路径
  1807. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  1808. }
  1809. else if (TypeName == "B")//B代表商邀相关文件
  1810. {
  1811. if (!Directory.Exists(fileDir))
  1812. {
  1813. Directory.CreateDirectory(fileDir);
  1814. }
  1815. //上传的文件的路径
  1816. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  1817. }
  1818. using (FileStream fs = System.IO.File.Create(filePath))
  1819. {
  1820. file.CopyTo(fs);
  1821. fs.Flush();
  1822. }
  1823. return Ok(JsonView(true, "上传成功!", projectFileName));
  1824. }
  1825. else
  1826. {
  1827. return Ok(JsonView(false, "上传失败!"));
  1828. }
  1829. }
  1830. catch (Exception ex)
  1831. {
  1832. return Ok(JsonView(false, "程序错误!"));
  1833. throw;
  1834. }
  1835. }
  1836. /// <summary>
  1837. /// 删除指定文件
  1838. /// </summary>
  1839. /// <param name="dto"></param>
  1840. /// <returns></returns>
  1841. [HttpPost]
  1842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1843. public async Task<IActionResult> DelFile(DelFileDto dto)
  1844. {
  1845. try
  1846. {
  1847. var TypeName = Request.Headers["TypeName"].ToString();
  1848. string filePath = "";
  1849. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1850. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  1851. int id = 0;
  1852. if (TypeName == "A")
  1853. {
  1854. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  1855. // 删除该文件
  1856. System.IO.File.Delete(filePath);
  1857. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  1858. }
  1859. else if (TypeName == "B")
  1860. {
  1861. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  1862. // 删除该文件
  1863. System.IO.File.Delete(filePath);
  1864. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  1865. }
  1866. if (id != 0)
  1867. {
  1868. return Ok(JsonView(true, "成功!"));
  1869. }
  1870. else
  1871. {
  1872. return Ok(JsonView(false, "失败!"));
  1873. }
  1874. }
  1875. catch (Exception ex)
  1876. {
  1877. return Ok(JsonView(false, "程序错误!"));
  1878. throw;
  1879. }
  1880. }
  1881. #endregion
  1882. #region 商邀费用录入
  1883. /// <summary>
  1884. /// 根据团组Id查询商邀费用列表
  1885. /// </summary>
  1886. /// <param name="dto"></param>
  1887. /// <returns></returns>
  1888. [HttpPost]
  1889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1890. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  1891. {
  1892. try
  1893. {
  1894. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  1895. if (groupData.Code != 0)
  1896. {
  1897. return Ok(JsonView(false, groupData.Msg));
  1898. }
  1899. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1900. }
  1901. catch (Exception ex)
  1902. {
  1903. return Ok(JsonView(false, "程序错误!"));
  1904. throw;
  1905. }
  1906. }
  1907. /// <summary>
  1908. /// 根据商邀费用ID查询C表和商邀费用数据
  1909. /// </summary>
  1910. /// <param name="dto"></param>
  1911. /// <returns></returns>
  1912. [HttpPost]
  1913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1914. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  1915. {
  1916. try
  1917. {
  1918. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  1919. if (groupData.Code != 0)
  1920. {
  1921. return Ok(JsonView(false, groupData.Msg));
  1922. }
  1923. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1924. }
  1925. catch (Exception ex)
  1926. {
  1927. return Ok(JsonView(false, "程序错误!"));
  1928. throw;
  1929. }
  1930. }
  1931. /// <summary>
  1932. /// 商邀费用录入操作(Status:1.新增,2.修改)
  1933. /// </summary>
  1934. /// <param name="dto"></param>
  1935. /// <returns></returns>
  1936. [HttpPost]
  1937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1938. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  1939. {
  1940. try
  1941. {
  1942. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto);
  1943. if (groupData.Code != 0)
  1944. {
  1945. return Ok(JsonView(false, groupData.Msg));
  1946. }
  1947. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1948. }
  1949. catch (Exception ex)
  1950. {
  1951. return Ok(JsonView(false, "程序错误!"));
  1952. throw;
  1953. }
  1954. }
  1955. /// <summary>
  1956. /// 商邀删除
  1957. /// </summary>
  1958. /// <param name="dto"></param>
  1959. /// <returns></returns>
  1960. [HttpPost]
  1961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1962. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  1963. {
  1964. try
  1965. {
  1966. var res = await _InvitationOfficialActivitiesRep.SoftDeleteByIdAsync<Grp_InvitationOfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  1967. if (!res)
  1968. {
  1969. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 81).SetColumns(a => new Grp_CreditCardPayment()
  1970. {
  1971. IsDel = 1,
  1972. DeleteUserId = dto.DeleteUserId,
  1973. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1974. }).ExecuteCommandAsync();
  1975. return Ok(JsonView(false, "删除失败"));
  1976. }
  1977. return Ok(JsonView(true, "删除成功!"));
  1978. }
  1979. catch (Exception ex)
  1980. {
  1981. return Ok(JsonView(false, "程序错误!"));
  1982. throw;
  1983. }
  1984. }
  1985. #endregion
  1986. #region 团组英文资料
  1987. /// <summary>
  1988. /// 查询团组英文所有资料
  1989. /// </summary>
  1990. /// <param name="dto"></param>
  1991. /// <returns></returns>
  1992. [HttpPost]
  1993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1994. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  1995. {
  1996. try
  1997. {
  1998. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  1999. if (groupData.Code != 0)
  2000. {
  2001. return Ok(JsonView(false, groupData.Msg));
  2002. }
  2003. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2004. }
  2005. catch (Exception ex)
  2006. {
  2007. return Ok(JsonView(false, "程序错误!"));
  2008. throw;
  2009. }
  2010. }
  2011. /// <summary>
  2012. /// 团组英文资料操作(Status:1.新增,2.修改)
  2013. /// </summary>
  2014. /// <param name="dto"></param>
  2015. /// <returns></returns>
  2016. [HttpPost]
  2017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2018. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  2019. {
  2020. try
  2021. {
  2022. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  2023. if (groupData.Code != 0)
  2024. {
  2025. return Ok(JsonView(false, groupData.Msg));
  2026. }
  2027. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2028. }
  2029. catch (Exception ex)
  2030. {
  2031. return Ok(JsonView(false, "程序错误!"));
  2032. throw;
  2033. }
  2034. }
  2035. /// <summary>
  2036. /// 团组英文资料Id查询数据
  2037. /// </summary>
  2038. /// <param name="dto"></param>
  2039. /// <returns></returns>
  2040. [HttpPost]
  2041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2042. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  2043. {
  2044. try
  2045. {
  2046. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  2047. if (_DelegationEnData != null)
  2048. {
  2049. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  2050. }
  2051. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  2052. }
  2053. catch (Exception ex)
  2054. {
  2055. return Ok(JsonView(false, "程序错误!"));
  2056. throw;
  2057. }
  2058. }
  2059. /// <summary>
  2060. /// 团组英文资料删除
  2061. /// </summary>
  2062. /// <param name="dto"></param>
  2063. /// <returns></returns>
  2064. [HttpPost]
  2065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2066. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2067. {
  2068. try
  2069. {
  2070. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2071. if (!res)
  2072. {
  2073. return Ok(JsonView(false, "删除失败"));
  2074. }
  2075. return Ok(JsonView(true, "删除成功!"));
  2076. }
  2077. catch (Exception ex)
  2078. {
  2079. return Ok(JsonView(false, "程序错误!"));
  2080. throw;
  2081. }
  2082. }
  2083. #endregion
  2084. #region 导出邀请函
  2085. /// <summary>
  2086. /// 导出邀请函页面初始化
  2087. /// </summary>
  2088. /// <param name="dto"></param>
  2089. /// <returns></returns>
  2090. [HttpPost]
  2091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2092. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2093. {
  2094. try
  2095. {
  2096. List<Grp_DelegationInfo> grp_Delegations = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToListAsync();
  2097. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2098. if (dto.DiId == 0)
  2099. {
  2100. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2101. }
  2102. else
  2103. {
  2104. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2105. }
  2106. return Ok(JsonView(true, "查询成功!", new
  2107. {
  2108. deleClient = crm_Deles,
  2109. delegations = grp_Delegations
  2110. }));
  2111. }
  2112. catch (Exception ex)
  2113. {
  2114. return Ok(JsonView(false, "程序错误!"));
  2115. throw;
  2116. }
  2117. }
  2118. /// <summary>
  2119. /// 导出邀请函
  2120. /// </summary>
  2121. /// <param name="dto"></param>
  2122. /// <returns></returns>
  2123. [HttpPost]
  2124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2125. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2126. {
  2127. try
  2128. {
  2129. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2130. List<Crm_DeleClient> crm_DeleClients = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2131. List<string> texts = new List<string>();
  2132. if (crm_DeleClients.Count != 0)
  2133. {
  2134. foreach (Crm_DeleClient item in crm_DeleClients)
  2135. {
  2136. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2137. {
  2138. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2139. }
  2140. else
  2141. {
  2142. string name = item.LastName + item.FirstName;
  2143. texts.Add(name);
  2144. }
  2145. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  2146. {
  2147. if (!transDic.ContainsKey(item.Job))
  2148. {
  2149. texts.Add(item.Job);
  2150. }
  2151. }
  2152. if (item.CrmCompanyId != 0)
  2153. {
  2154. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == item.CrmCompanyId && a.IsDel == 0);
  2155. if (!transDic.ContainsKey(crm_Customer.CompanyName))
  2156. {
  2157. texts.Add(crm_Customer.CompanyName);
  2158. }
  2159. }
  2160. }
  2161. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2162. if (transData.Count > 0)
  2163. {
  2164. foreach (TranslateResult item in transData)
  2165. {
  2166. if (!transDic.ContainsKey(item.Query))
  2167. {
  2168. transDic.Add(item.Query, item.Translation);
  2169. }
  2170. }
  2171. }
  2172. List<guestList> list = new List<guestList>();
  2173. foreach (Crm_DeleClient dele in crm_DeleClients)
  2174. {
  2175. guestList guestList = new guestList();
  2176. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  2177. {
  2178. guestList.Name = dele.Pinyin;
  2179. }
  2180. else
  2181. {
  2182. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  2183. guestList.Name = Name;
  2184. }
  2185. if (dele.Sex == 0)
  2186. {
  2187. guestList.Sex = "Male";
  2188. }
  2189. else if (dele.Sex == 1)
  2190. {
  2191. guestList.Sex = "Female";
  2192. }
  2193. guestList.DOB = dele.BirthDay.Replace('-', '.');
  2194. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == dele.CrmCompanyId && a.IsDel == 0);
  2195. string jobName = transDic.Where(s => s.Key == crm_Customer.CompanyName).FirstOrDefault().Value + " " + transDic.Where(s => s.Key == dele.Job).FirstOrDefault().Value;
  2196. guestList.Job = jobName;
  2197. list.Add(guestList);
  2198. }
  2199. //载入模板
  2200. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  2201. DocumentBuilder builder = new DocumentBuilder(doc);
  2202. //获取word里所有表格
  2203. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2204. //获取所填表格的序数
  2205. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2206. var rowStart = tableOne.Rows[0]; //获取第1行
  2207. //循环赋值
  2208. for (int i = 0; i < list.Count; i++)
  2209. {
  2210. builder.MoveToCell(0, i + 1, 0, 0);
  2211. builder.Write(list[i].Name.ToString());
  2212. builder.MoveToCell(0, i + 1, 1, 0);
  2213. builder.Write(list[i].Sex.ToString());
  2214. builder.MoveToCell(0, i + 1, 2, 0);
  2215. builder.Write(list[i].DOB.ToString());
  2216. builder.MoveToCell(0, i + 1, 3, 0);
  2217. builder.Write(list[i].Job.ToString());
  2218. }
  2219. //删除多余行
  2220. while (tableOne.Rows.Count > list.Count + 1)
  2221. {
  2222. tableOne.Rows.RemoveAt(list.Count + 1);
  2223. }
  2224. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2225. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  2226. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  2227. doc.Save(filePath);
  2228. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件" + fileName;
  2229. return Ok(JsonView(true, "成功!", Url));
  2230. }
  2231. else
  2232. {
  2233. return Ok(JsonView(false, "失败,该团组没有客户名单!"));
  2234. }
  2235. }
  2236. catch (Exception ex)
  2237. {
  2238. return Ok(JsonView(false, "程序错误!"));
  2239. throw;
  2240. }
  2241. }
  2242. #endregion
  2243. #region 团组经理模块 出入境费用
  2244. ///// <summary>
  2245. ///// 团组模块 - 出入境费用
  2246. ///// </summary>
  2247. ///// <returns></returns>
  2248. //[HttpPost]
  2249. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2250. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  2251. //{
  2252. // try
  2253. // {
  2254. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  2255. // if (data.Code != 0)
  2256. // {
  2257. // return Ok(JsonView(false, data.Msg));
  2258. // }
  2259. // return Ok(JsonView(true, "查询成功!"));
  2260. // }
  2261. // catch (Exception ex)
  2262. // {
  2263. // return Ok(JsonView(false, ex.Message));
  2264. // throw;
  2265. // }
  2266. //}
  2267. /// <summary>
  2268. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  2269. /// </summary>
  2270. /// <returns></returns>
  2271. [HttpPost]
  2272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2273. public async Task<IActionResult> SetDayAndCostAreaChange()
  2274. {
  2275. try
  2276. {
  2277. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  2278. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  2279. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  2280. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  2281. foreach (var item in unite) //处理交集数据
  2282. {
  2283. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  2284. }
  2285. foreach (var item in merge) //处理差集数据
  2286. {
  2287. int nationalTravelFeeId = 0;
  2288. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  2289. if (cityData != null) nationalTravelFeeId = cityData.Id;
  2290. else
  2291. {
  2292. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  2293. if (countryData != null) nationalTravelFeeId = countryData.Id;
  2294. }
  2295. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  2296. }
  2297. //只更新dayAndCost 的 nationalTravelFeeId;
  2298. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  2299. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  2300. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  2301. }
  2302. catch (Exception ex)
  2303. {
  2304. return Ok(JsonView(false, ex.Message));
  2305. throw;
  2306. }
  2307. }
  2308. /// <summary>
  2309. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  2310. /// </summary>
  2311. /// <returns></returns>
  2312. [HttpPost]
  2313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2314. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  2315. {
  2316. try
  2317. {
  2318. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  2319. string currencySql = string.Format("Select * From Sys_SetData Where STid = 66 And IsDel = 0");
  2320. var currencyData = await _sqlSugar.SqlQueryable<SetDataInfoView>(currencySql).ToListAsync();
  2321. //string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2322. // Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2323. // Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2324. // Where gntf.Isdel = 0");
  2325. //var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2326. return Ok(JsonView(true, "查询成功!", new
  2327. {
  2328. GroupNameData = groupNameData.Data,
  2329. CurrencyData = currencyData,
  2330. //NationalTravelFeeData = nationalTravelFeeData
  2331. }));
  2332. }
  2333. catch (Exception ex)
  2334. {
  2335. return Ok(JsonView(false, ex.Message));
  2336. throw;
  2337. }
  2338. }
  2339. /// <summary>
  2340. /// 团组模块 - 出入境费用 - Info
  2341. /// </summary>
  2342. /// <returns></returns>
  2343. [HttpPost]
  2344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2345. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  2346. {
  2347. try
  2348. {
  2349. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  2350. if (data.Code != 0)
  2351. {
  2352. return Ok(JsonView(false, data.Msg));
  2353. }
  2354. return Ok(JsonView(true, "查询成功!", data.Data));
  2355. }
  2356. catch (Exception ex)
  2357. {
  2358. return Ok(JsonView(false, ex.Message));
  2359. }
  2360. }
  2361. /// <summary>
  2362. /// 团组模块 - 出入境费用 - Add And Update
  2363. /// </summary>
  2364. /// <returns></returns>
  2365. [HttpPost]
  2366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2367. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  2368. {
  2369. try
  2370. {
  2371. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2372. if (data.Code != 0)
  2373. {
  2374. return Ok(JsonView(false, data.Msg));
  2375. }
  2376. return Ok(JsonView(true, data.Msg, data.Data));
  2377. }
  2378. catch (Exception ex)
  2379. {
  2380. return Ok(JsonView(false, ex.Message));
  2381. }
  2382. }
  2383. /// <summary>
  2384. /// 团组模块 - 出入境费用 - 子项删除
  2385. /// </summary>
  2386. /// <returns></returns>
  2387. [HttpPost]
  2388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2389. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  2390. {
  2391. try
  2392. {
  2393. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  2394. if (data.Code != 0)
  2395. {
  2396. return Ok(JsonView(false, data.Msg));
  2397. }
  2398. return Ok(JsonView(true, "操作成功!", data.Data));
  2399. }
  2400. catch (Exception ex)
  2401. {
  2402. return Ok(JsonView(false, ex.Message));
  2403. }
  2404. }
  2405. /// <summary>
  2406. /// 团组模块 - 出入境国家费用标准 List
  2407. /// </summary>
  2408. /// <returns></returns>
  2409. [HttpPost]
  2410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2411. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  2412. {
  2413. try
  2414. {
  2415. Stopwatch sw = new Stopwatch();
  2416. sw.Start();
  2417. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2418. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2419. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2420. Where gntf.Isdel = 0");
  2421. var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2422. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  2423. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  2424. //foreach (var item in nationalTravel)
  2425. //{
  2426. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  2427. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  2428. // if (otherData != null)
  2429. // {
  2430. // cityData.Remove(otherData);
  2431. // cityData.Add(otherData);
  2432. // }
  2433. // nationalTravelFeeData1.Add(new
  2434. // {
  2435. // Country = item.Country,
  2436. // CityData = cityData
  2437. // });
  2438. //}
  2439. sw.Stop();
  2440. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  2441. }
  2442. catch (Exception ex)
  2443. {
  2444. return Ok(JsonView(false, ex.Message));
  2445. throw;
  2446. }
  2447. }
  2448. /// <summary>
  2449. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  2450. /// </summary>
  2451. /// <returns></returns>
  2452. [HttpPost]
  2453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2454. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  2455. {
  2456. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  2457. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  2458. List<string> countryData = new List<string>();
  2459. countryData.AddRange( nationalTravelFeeData.Select(it => it.Country ).ToList());
  2460. countryData = countryData.Distinct().ToList();
  2461. List<dynamic> dataSource = new List<dynamic>();
  2462. foreach (var item in countryData)
  2463. {
  2464. List<string> cityData1 = new List<string>();
  2465. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  2466. var countryData2 = new
  2467. {
  2468. CountryName = item,
  2469. CityData = cityData1
  2470. };
  2471. dataSource.Add(countryData2);
  2472. }
  2473. return Ok(JsonView(true, "查询成功!", dataSource));
  2474. }
  2475. /// <summary>
  2476. /// 团组模块 - 出入境国家费用标准 Page List
  2477. /// </summary>
  2478. /// <returns></returns>
  2479. [HttpPost]
  2480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2481. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  2482. {
  2483. int portId = dto.PortType;
  2484. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2485. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  2486. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  2487. string whereSql = string.Empty;
  2488. if (!string.IsNullOrEmpty(dto.Country))
  2489. {
  2490. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  2491. }
  2492. if (!string.IsNullOrEmpty(dto.City))
  2493. {
  2494. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  2495. }
  2496. string pageSql = string.Format(@"Select * From (
  2497. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  2498. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  2499. From Grp_NationalTravelFee gntf
  2500. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2501. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2502. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  2503. RefAsync<int> total = 0;
  2504. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  2505. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  2506. }
  2507. /// <summary>
  2508. /// 团组模块 - 出入境国家费用标准 根据城市查询
  2509. /// </summary>
  2510. /// <returns></returns>
  2511. [HttpPost]
  2512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2513. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  2514. {
  2515. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  2516. int portId = dto.PortType;
  2517. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2518. string whereSql = string.Empty;
  2519. if (!string.IsNullOrEmpty(dto.Country))
  2520. {
  2521. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  2522. }
  2523. if (!string.IsNullOrEmpty(dto.City))
  2524. {
  2525. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  2526. }
  2527. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  2528. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  2529. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  2530. From Grp_NationalTravelFee gntf
  2531. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2532. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2533. Where gntf.Isdel = 0 {0} ", whereSql);
  2534. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  2535. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  2536. }
  2537. /// <summary>
  2538. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  2539. /// </summary>
  2540. /// <returns></returns>
  2541. [HttpPost]
  2542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2543. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  2544. {
  2545. try
  2546. {
  2547. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  2548. if (data.Code != 0)
  2549. {
  2550. return Ok(JsonView(false, data.Msg));
  2551. }
  2552. return Ok(JsonView(true, "操作成功!", data.Data));
  2553. }
  2554. catch (Exception ex)
  2555. {
  2556. return Ok(JsonView(false, ex.Message));
  2557. }
  2558. }
  2559. /// <summary>
  2560. /// 团组模块 - 出入境国家费用标准 - Del
  2561. /// </summary>
  2562. /// <returns></returns>
  2563. [HttpPost]
  2564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2565. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  2566. {
  2567. try
  2568. {
  2569. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee() {
  2570. Id = dto.Id,
  2571. DeleteUserId = dto.DeleteUserId,
  2572. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  2573. IsDel = 1
  2574. };
  2575. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  2576. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  2577. .WhereColumns(it => new { it.Id })
  2578. .ExecuteCommandAsync();
  2579. if (delStatus <= 0)
  2580. {
  2581. return Ok(JsonView(false, "删除失败!"));
  2582. }
  2583. return Ok(JsonView(true, "操作成功!"));
  2584. }
  2585. catch (Exception ex)
  2586. {
  2587. return Ok(JsonView(false, ex.Message));
  2588. }
  2589. }
  2590. #endregion
  2591. #region 签证费用录入
  2592. /// <summary>
  2593. /// 根据diid查询签证费用列表
  2594. /// </summary>
  2595. /// <param name="dto"></param>
  2596. /// <returns></returns>
  2597. [HttpPost]
  2598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2599. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  2600. {
  2601. try
  2602. {
  2603. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  2604. if (groupData.Code != 0)
  2605. {
  2606. return Ok(JsonView(false, groupData.Msg));
  2607. }
  2608. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2609. }
  2610. catch (Exception ex)
  2611. {
  2612. return Ok(JsonView(false, ex.Message));
  2613. }
  2614. }
  2615. /// <summary>
  2616. /// 根据签证费用Id查询单条数据及c表数据
  2617. /// </summary>
  2618. /// <param name="dto"></param>
  2619. /// <returns></returns>
  2620. [HttpPost]
  2621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2622. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  2623. {
  2624. try
  2625. {
  2626. Result groupData = await _visaPriceRep.PostVisaById(dto);
  2627. if (groupData.Code != 0)
  2628. {
  2629. return Ok(JsonView(false, groupData.Msg));
  2630. }
  2631. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2632. }
  2633. catch (Exception ex)
  2634. {
  2635. return Ok(JsonView(false, ex.Message));
  2636. }
  2637. }
  2638. /// <summary>
  2639. /// 签证费用删除
  2640. /// </summary>
  2641. /// <param name="dto"></param>
  2642. /// <returns></returns>
  2643. [HttpPost]
  2644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2645. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  2646. {
  2647. try
  2648. {
  2649. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  2650. if (!res)
  2651. {
  2652. return Ok(JsonView(false, "删除失败"));
  2653. }
  2654. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
  2655. {
  2656. IsDel = 1,
  2657. DeleteUserId = dto.DeleteUserId,
  2658. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2659. }).ExecuteCommandAsync();
  2660. return Ok(JsonView(true, "删除成功!"));
  2661. }
  2662. catch (Exception ex)
  2663. {
  2664. return Ok(JsonView(false, "程序错误!"));
  2665. throw;
  2666. }
  2667. }
  2668. /// <summary>
  2669. /// 签证费用录入下拉框初始化
  2670. /// </summary>
  2671. /// <returns></returns>
  2672. [HttpPost]
  2673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2674. public async Task<IActionResult> VisaPriceAddSelect()
  2675. {
  2676. try
  2677. {
  2678. //支付方式
  2679. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  2680. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  2681. //币种
  2682. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  2683. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  2684. //乘客类型
  2685. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  2686. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  2687. //卡类型
  2688. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  2689. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  2690. var data = new
  2691. {
  2692. Payment = _Payment,
  2693. CurrencyList = _CurrencyList,
  2694. PassengerType = _PassengerType,
  2695. BankCard = _BankCard
  2696. };
  2697. return Ok(JsonView(true, "查询成功!",data));
  2698. }
  2699. catch (Exception ex)
  2700. {
  2701. return Ok(JsonView(false, "程序错误!"));
  2702. throw;
  2703. }
  2704. }
  2705. /// <summary>
  2706. /// 签证费用录入操作(Status:1.新增,2.修改)
  2707. /// </summary>
  2708. /// <param name="dto"></param>
  2709. /// <returns></returns>
  2710. [HttpPost]
  2711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2712. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  2713. {
  2714. try
  2715. {
  2716. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  2717. if (groupData.Code != 0)
  2718. {
  2719. return Ok(JsonView(false, groupData.Msg));
  2720. }
  2721. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2722. }
  2723. catch (Exception ex)
  2724. {
  2725. return Ok(JsonView(false, ex.Message));
  2726. }
  2727. }
  2728. #endregion
  2729. #region op费用录入
  2730. /// <summary>
  2731. /// 根据diid查询op费用列表
  2732. /// </summary>
  2733. /// <param name="dto"></param>
  2734. /// <returns></returns>
  2735. [HttpPost]
  2736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2737. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  2738. {
  2739. try
  2740. {
  2741. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  2742. if (groupData.Code != 0)
  2743. {
  2744. return Ok(JsonView(false, groupData.Msg));
  2745. }
  2746. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2747. }
  2748. catch (Exception ex)
  2749. {
  2750. return Ok(JsonView(false, ex.Message));
  2751. }
  2752. }
  2753. /// <summary>
  2754. /// 根据op费用Id查询单条数据及c表数据
  2755. /// </summary>
  2756. /// <param name="dto"></param>
  2757. /// <returns></returns>
  2758. [HttpPost]
  2759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2760. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  2761. {
  2762. try
  2763. {
  2764. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a=>a.Id==dto.Id && a.IsDel==0);
  2765. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable==79 && a.IsDel == 0);
  2766. var data = new
  2767. {
  2768. CarTouristGuideGround = _groupData,
  2769. CreditCardPayment = _creditCardPayment
  2770. };
  2771. return Ok(JsonView(true, "查询成功!", data));
  2772. }
  2773. catch (Exception ex)
  2774. {
  2775. return Ok(JsonView(false, "程序错误!"));
  2776. }
  2777. }
  2778. /// <summary>
  2779. /// op费用删除
  2780. /// </summary>
  2781. /// <param name="dto"></param>
  2782. /// <returns></returns>
  2783. [HttpPost]
  2784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2785. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  2786. {
  2787. try
  2788. {
  2789. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2790. if (!res)
  2791. {
  2792. return Ok(JsonView(false, "删除失败"));
  2793. }
  2794. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  2795. {
  2796. IsDel = 1,
  2797. DeleteUserId = dto.DeleteUserId,
  2798. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2799. }).ExecuteCommandAsync();
  2800. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable==79).SetColumns(a => new Grp_CreditCardPayment()
  2801. {
  2802. IsDel = 1,
  2803. DeleteUserId = dto.DeleteUserId,
  2804. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2805. }).ExecuteCommandAsync();
  2806. return Ok(JsonView(true, "删除成功!"));
  2807. }
  2808. catch (Exception ex)
  2809. {
  2810. return Ok(JsonView(false, "程序错误!"));
  2811. throw;
  2812. }
  2813. }
  2814. /// <summary>
  2815. /// op费用录入操作(Status:1.新增,2.修改)
  2816. /// </summary>
  2817. /// <param name="dto"></param>
  2818. /// <returns></returns>
  2819. [HttpPost]
  2820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2821. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  2822. {
  2823. try
  2824. {
  2825. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  2826. if (groupData.Code != 0)
  2827. {
  2828. return Ok(JsonView(false, groupData.Msg));
  2829. }
  2830. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2831. }
  2832. catch (Exception ex)
  2833. {
  2834. return Ok(JsonView(false, ex.Message));
  2835. }
  2836. }
  2837. /// <summary>
  2838. /// 填写费用详细页面初始化绑定
  2839. /// </summary>
  2840. /// <param name="dto"></param>
  2841. /// <returns></returns>
  2842. [HttpPost]
  2843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2844. public async Task<IActionResult> CarTouristGuideGroundContenInitialize(CarTouristGuideGroundContenDto dto)
  2845. {
  2846. try
  2847. {
  2848. Result groupData = await _carTouristGuideGroundRep.CarTouristGuideGroundConten(dto);
  2849. if (groupData.Code != 0)
  2850. {
  2851. return Ok(JsonView(false, groupData.Msg));
  2852. }
  2853. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2854. }
  2855. catch (Exception ex)
  2856. {
  2857. return Ok(JsonView(false, ex.Message));
  2858. }
  2859. }
  2860. /// <summary>
  2861. /// 根据op费用Id查询详细数据
  2862. /// </summary>
  2863. /// <param name="dto"></param>
  2864. /// <returns></returns>
  2865. [HttpPost]
  2866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2867. public async Task<IActionResult> OpCarTouristGuideGroundContenById(CarTouristGuideGroundIdDto dto)
  2868. {
  2869. try
  2870. {
  2871. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContenById(dto);
  2872. if (groupData.Code != 0)
  2873. {
  2874. return Ok(JsonView(false, groupData.Msg));
  2875. }
  2876. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2877. }
  2878. catch (Exception ex)
  2879. {
  2880. return Ok(JsonView(false, ex.Message));
  2881. }
  2882. }
  2883. [HttpPost]
  2884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2885. public async Task<IActionResult> OpCarTouristGuideGroundConten(OpCarTouristGuideGroundContenDto dto)
  2886. {
  2887. try
  2888. {
  2889. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundConten(dto);
  2890. if (groupData.Code != 0)
  2891. {
  2892. return Ok(JsonView(false, groupData.Msg));
  2893. }
  2894. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2895. }
  2896. catch (Exception ex)
  2897. {
  2898. return Ok(JsonView(false, ex.Message));
  2899. }
  2900. }
  2901. #endregion
  2902. }
  2903. }