GroupsController.cs 147 KB

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