GroupsController.cs 199 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709
  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. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. using Microsoft.AspNetCore.Mvc.ViewEngines;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.Entities.Financial;
  41. namespace OASystem.API.Controllers
  42. {
  43. /// <summary>
  44. /// 团组相关
  45. /// </summary>
  46. //[Authorize]
  47. [Route("api/[controller]/[action]")]
  48. public class GroupsController : ControllerBase
  49. {
  50. private readonly GrpScheduleRepository _grpScheduleRep;
  51. private readonly IMapper _mapper;
  52. private readonly DelegationInfoRepository _groupRepository;
  53. private readonly TaskAssignmentRepository _taskAssignmentRep;
  54. private readonly AirTicketResRepository _airTicketResRep;
  55. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  56. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  57. private readonly DelegationEnDataRepository _delegationEnDataRep;
  58. private readonly DelegationVisaRepository _delegationVisaRep;
  59. private readonly VisaPriceRepository _visaPriceRep;
  60. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  61. private readonly HotelPriceRepository _hotelPriceRep;
  62. private readonly CustomersRepository _customersRep;
  63. private readonly MessageRepository _message;
  64. private readonly SqlSugarClient _sqlSugar;
  65. #region 成本相关
  66. private readonly CheckBoxsRepository _checkBoxs;
  67. private readonly GroupCostRepository _GroupCostRepository;
  68. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  69. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  70. #endregion
  71. private readonly SetDataRepository _setDataRep;
  72. private string url;
  73. private string path;
  74. private readonly EnterExitCostRepository _enterExitCostRep;
  75. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  76. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  77. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  78. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  79. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  80. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep)
  81. {
  82. _mapper = mapper;
  83. _grpScheduleRep = grpScheduleRep;
  84. _groupRepository = groupRepository;
  85. _taskAssignmentRep = taskAssignmentRep;
  86. _airTicketResRep = airTicketResRep;
  87. _sqlSugar = sqlSugar;
  88. url = AppSettingsHelper.Get("ExcelBaseUrl");
  89. path = AppSettingsHelper.Get("ExcelBasePath");
  90. if (!System.IO.Directory.Exists(path))
  91. {
  92. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  93. }
  94. _decreasePaymentsRep = decreasePaymentsRep;
  95. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  96. _delegationEnDataRep = delegationEnDataRep;
  97. _enterExitCostRep = enterExitCostRep;
  98. _delegationVisaRep = delegationVisaRep;
  99. _message = message;
  100. _visaPriceRep = visaPriceRep;
  101. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  102. _checkBoxs = checkBoxs;
  103. _GroupCostRepository = GroupCostRepository;
  104. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  105. _GroupCostParameterRepository = GroupCostParameterRepository;
  106. _hotelPriceRep = hotelPriceRep;
  107. _customersRep = customersRep;
  108. _setDataRep = setDataRep;
  109. }
  110. #region 流程管控
  111. /// <summary>
  112. /// 获取团组流程管控信息
  113. /// </summary>
  114. /// <param name="paras">参数Json字符串</param>
  115. /// <returns></returns>
  116. [HttpPost]
  117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  118. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  119. {
  120. if (string.IsNullOrEmpty(_jsonDto.Paras))
  121. {
  122. return Ok(JsonView(false, "参数为空"));
  123. }
  124. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  125. if (_ScheduleDto != null)
  126. {
  127. if (_ScheduleDto.SearchType == 2)//获取列表
  128. {
  129. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  130. return Ok(JsonView(_grpScheduleViewList));
  131. }
  132. else//获取对象
  133. {
  134. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  135. if (_grpScheduleView != null)
  136. {
  137. return Ok(JsonView(_grpScheduleView));
  138. }
  139. }
  140. }
  141. else
  142. {
  143. return Ok(JsonView(false, "参数反序列化失败"));
  144. }
  145. return Ok(JsonView(false, "暂无数据!"));
  146. }
  147. /// <summary>
  148. /// 修改团组流程管控详细表数据
  149. /// </summary>
  150. /// <param name="paras"></param>
  151. /// <returns></returns>
  152. [HttpPost]
  153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  154. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  155. {
  156. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  157. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  158. .SetColumns(it => it.Duty == _detail.Duty)
  159. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  160. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  161. .SetColumns(it => it.JobContent == _detail.JobContent)
  162. .SetColumns(it => it.Remark == _detail.Remark)
  163. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  164. .Where(s => s.Id == dto.Id)
  165. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  166. .ExecuteCommandAsync();
  167. if (result > 0)
  168. {
  169. return Ok(JsonView(true, "保存成功!"));
  170. }
  171. return Ok(JsonView(false, "保存失败!"));
  172. }
  173. /// <summary>
  174. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  175. /// </summary>
  176. /// <param name="dto"></param>
  177. /// <returns></returns>
  178. [HttpPost]
  179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  180. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  181. {
  182. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  183. _detail.IsDel = 1;
  184. _detail.DeleteUserId = dto.Duty;
  185. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  186. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  187. .SetColumns(it => it.IsDel == _detail.IsDel)
  188. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  189. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  190. .Where(it => it.Id == dto.Id)
  191. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  192. //.WhereColumns(s => s.Id == dto.Id)
  193. .ExecuteCommandAsync();
  194. if (result > 0)
  195. {
  196. return Ok(JsonView(true, "删除成功!"));
  197. }
  198. return Ok(JsonView(false, "删除失败!"));
  199. }
  200. /// <summary>
  201. /// 增加团组流程管控详细表数据
  202. /// </summary>
  203. /// <param name="dto"></param>
  204. /// <returns></returns>
  205. [HttpPost]
  206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  207. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  208. {
  209. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  210. if (DateTime.Now < _detail.ExpectBeginDt)
  211. {
  212. _detail.StepStatus = 0;
  213. }
  214. else
  215. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  216. _detail.StepStatus = 1;
  217. }
  218. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  219. if (result > 0)
  220. {
  221. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  222. return Ok(JsonView(true, "添加成功!", _result));
  223. }
  224. return Ok(JsonView(false, "添加失败!"));
  225. }
  226. #endregion
  227. #region 团组基本信息
  228. /// <summary>
  229. /// 接团信息列表
  230. /// </summary>
  231. /// <param name="dto">团组列表请求dto</param>
  232. /// <returns></returns>
  233. [HttpPost]
  234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  235. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  236. {
  237. var groupData = await _groupRepository.GetGroupList(dto);
  238. if (groupData.Code != 0)
  239. {
  240. return Ok(JsonView(false, groupData.Msg));
  241. }
  242. return Ok(JsonView(groupData.Data));
  243. }
  244. /// <summary>
  245. /// 接团信息列表 Page
  246. /// </summary>
  247. /// <param name="dto">团组列表请求dto</param>
  248. /// <returns></returns>
  249. [HttpPost]
  250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  251. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  252. {
  253. #region 参数验证
  254. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  255. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  256. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  257. #region 页面操作权限验证
  258. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  259. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  260. #endregion
  261. #endregion
  262. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  263. {
  264. string sqlWhere = string.Empty;
  265. if (dto.IsSure == 0) //未完成
  266. {
  267. sqlWhere += string.Format(@" And IsSure = 0");
  268. }
  269. else if (dto.IsSure == 1) //已完成
  270. {
  271. sqlWhere += string.Format(@" And IsSure = 1");
  272. }
  273. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  274. {
  275. string tj = dto.SearchCriteria;
  276. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  277. tj, tj, tj, tj, tj);
  278. }
  279. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  280. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  281. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  282. From (
  283. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  284. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  285. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  286. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  287. From Grp_DelegationInfo gdi
  288. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  289. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  290. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  291. Where gdi.IsDel = 0 {0}
  292. ) temp ", sqlWhere);
  293. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  294. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  295. var _view = new
  296. {
  297. PageFuncAuth = pageFunAuthView,
  298. Data = _DelegationList
  299. };
  300. return Ok(JsonView(true, "查询成功!", _view, total));
  301. }
  302. else
  303. {
  304. return Ok(JsonView(false, "查询失败"));
  305. }
  306. }
  307. /// <summary>
  308. /// 接团信息详情
  309. /// </summary>
  310. /// <param name="dto">团组info请求dto</param>
  311. /// <returns></returns>
  312. [HttpPost]
  313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  314. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  315. {
  316. var groupData = await _groupRepository.GetGroupInfo(dto);
  317. if (groupData.Code != 0)
  318. {
  319. return Ok(JsonView(false, groupData.Msg));
  320. }
  321. return Ok(JsonView(groupData.Data));
  322. }
  323. /// <summary>
  324. /// 接团信息 编辑添加
  325. /// 基础信息数据源
  326. /// </summary>
  327. /// <param name="dto"></param>
  328. /// <returns></returns>
  329. [HttpPost]
  330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  331. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  332. {
  333. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  334. if (groupData.Code != 0)
  335. {
  336. return Ok(JsonView(false, groupData.Msg));
  337. }
  338. return Ok(JsonView(groupData.Data));
  339. }
  340. /// <summary>
  341. /// 接团信息 操作(增改)
  342. /// </summary>
  343. /// <param name="dto"></param>
  344. /// <returns></returns>
  345. [HttpPost]
  346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  347. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  348. {
  349. try
  350. {
  351. var groupData = await _groupRepository.GroupOperation(dto);
  352. if (groupData.Code != 0)
  353. {
  354. return Ok(JsonView(false, groupData.Msg));
  355. }
  356. return Ok(JsonView(true));
  357. }
  358. catch (Exception ex)
  359. {
  360. Logs("[response]" + JsonConvert.SerializeObject(dto));
  361. Logs(ex.Message);
  362. return Ok(JsonView(false, ex.Message));
  363. }
  364. }
  365. /// <summary>
  366. /// 接团信息 操作(删除)
  367. /// </summary>
  368. /// <param name="dto"></param>
  369. /// <returns></returns>
  370. [HttpPost]
  371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  372. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  373. {
  374. try
  375. {
  376. var groupData = await _groupRepository.GroupDel(dto);
  377. if (groupData.Code != 0)
  378. {
  379. return Ok(JsonView(false, groupData.Msg));
  380. }
  381. return Ok(JsonView(true));
  382. }
  383. catch (Exception ex)
  384. {
  385. Logs("[response]" + JsonConvert.SerializeObject(dto));
  386. Logs(ex.Message);
  387. return Ok(JsonView(false, ex.Message));
  388. }
  389. }
  390. /// <summary>
  391. /// 获取团组销售报价号
  392. /// 团组添加时 使用
  393. /// </summary>
  394. /// <returns></returns>
  395. [HttpPost]
  396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  397. public async Task<IActionResult> GetGroupSalesQuoteNo()
  398. {
  399. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  400. if (groupData.Code != 0)
  401. {
  402. return Ok(JsonView(false, groupData.Msg));
  403. }
  404. object salesQuoteNo = new
  405. {
  406. SalesQuoteNo = groupData.Data
  407. };
  408. return Ok(JsonView(salesQuoteNo));
  409. }
  410. /// <summary>
  411. /// 设置确认出团
  412. /// </summary>
  413. /// <param name="dto"></param>
  414. /// <returns></returns>
  415. [HttpPost]
  416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  417. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  418. {
  419. var groupData = await _groupRepository.ConfirmationGroup(dto);
  420. if (groupData.Code != 0)
  421. {
  422. return Ok(JsonView(false, groupData.Msg));
  423. }
  424. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  425. return Ok(JsonView(true, "操作成功!", groupData.Data));
  426. }
  427. /// <summary>
  428. /// 获取团组名称data And 签证国别Data
  429. /// </summary>
  430. /// <param name="dto"></param>
  431. /// <returns></returns>
  432. [HttpPost]
  433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  434. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  435. {
  436. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  437. if (groupData.Code != 0)
  438. {
  439. return Ok(JsonView(false, groupData.Msg));
  440. }
  441. return Ok(JsonView(groupData.Data));
  442. }
  443. /// <summary>
  444. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  445. /// </summary>
  446. /// <returns></returns>
  447. [HttpPost]
  448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  449. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  450. {
  451. try
  452. {
  453. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  454. if (groupData.Code != 0)
  455. {
  456. return Ok(JsonView(false, groupData.Msg));
  457. }
  458. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  459. }
  460. catch (Exception ex)
  461. {
  462. return Ok(JsonView(false, "程序错误!"));
  463. throw;
  464. }
  465. }
  466. #endregion
  467. #region 团组&签证
  468. /// <summary>
  469. /// 根据团组Id获取签证客户信息List
  470. /// </summary>
  471. /// <param name="dto">请求dto</param>
  472. /// <returns></returns>
  473. [HttpPost]
  474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  475. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  476. {
  477. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  478. if (groupData.Code != 0)
  479. {
  480. return Ok(JsonView(false, groupData.Msg));
  481. }
  482. return Ok(JsonView(groupData.Data));
  483. }
  484. /// <summary>
  485. /// IOS获取团组签证拍照上传进度01(团组列表)
  486. /// </summary>
  487. /// <param name="dto">请求dto</param>
  488. /// <returns></returns>
  489. [HttpPost]
  490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  491. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  492. {
  493. if (dto == null)
  494. {
  495. return Ok(JsonView(false, "参数为空"));
  496. }
  497. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  498. return Ok(JsonView(visaList));
  499. }
  500. /// <summary>
  501. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  502. /// </summary>
  503. /// <returns></returns>
  504. [HttpPost]
  505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  506. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  507. {
  508. if (dto == null)
  509. {
  510. return Ok(JsonView(false, "请求错误:"));
  511. }
  512. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  513. return Ok(JsonView(list));
  514. }
  515. /// <summary>
  516. /// IOS获取团组签证拍照上传进度03(相册)
  517. /// </summary>
  518. /// <returns></returns>
  519. [HttpPost]
  520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  521. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  522. {
  523. if (dto == null)
  524. {
  525. return Ok(JsonView(false, "请求错误:"));
  526. }
  527. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  528. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  529. list.ForEach(s => s.url = url);
  530. return Ok(JsonView(list));
  531. }
  532. /// <summary>
  533. /// IOS获取团组签证拍照上传进度04(图片上传)
  534. /// </summary>
  535. /// <param name="dto"></param>
  536. /// <returns></returns>
  537. [HttpPost]
  538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  539. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  540. {
  541. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  542. //if (!string.IsNullOrEmpty(result))
  543. //{
  544. //}
  545. //else {
  546. // return Ok(JsonView(false, "上传失败"));
  547. //}
  548. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  549. int sucNum = 0;
  550. try
  551. {
  552. foreach (var item in dto.base64DataList)
  553. {
  554. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  555. string result = decodeBase64ToImage(item, imageName);
  556. if (!string.IsNullOrEmpty(result))
  557. {
  558. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  559. pic.CreateUserId = dto.CreateUserId;
  560. pic.PicName = imageName;
  561. pic.PicPath = result;
  562. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  563. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  564. if (insertResult > 0)
  565. {
  566. sucNum++;
  567. }
  568. }
  569. }
  570. }
  571. catch (Exception ex)
  572. {
  573. return Ok(JsonView(false, ex.Message));
  574. }
  575. string msg = string.Format(@"成功上传{0}张", sucNum);
  576. return Ok(JsonView(true, msg));
  577. }
  578. private string decodeBase64ToImage(string base64DataURL, string imgName)
  579. {
  580. string filename = "";//声明一个string类型的相对路径
  581. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  582. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  583. try//会有异常抛出,try,catch一下
  584. {
  585. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  586. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  587. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  588. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  589. //文件名称
  590. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  591. //上传的文件的路径
  592. string filePath = "";
  593. if (!Directory.Exists(fileDir))
  594. {
  595. Directory.CreateDirectory(fileDir);
  596. }
  597. //上传的文件的路径
  598. filePath = fileDir + filename;
  599. //string url = HttpRuntime.AppDomainAppPath.ToString();
  600. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  601. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  602. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  603. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  604. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  605. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  606. ms.Close();//关闭当前流,并释放所有与之关联的资源
  607. bitmap.Dispose();
  608. }
  609. catch (Exception e)
  610. {
  611. string massage = e.Message;
  612. Logs("IOS图片上传Error:" + massage);
  613. //filename = e.Message;
  614. }
  615. return filename;//返回相对路径
  616. }
  617. /// <summary>
  618. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  619. /// </summary>
  620. /// <param name="dto"></param>
  621. /// <returns></returns>
  622. [HttpPost]
  623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  624. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  625. {
  626. if (dto == null)
  627. {
  628. return Ok(JsonView(false, "请求错误:"));
  629. }
  630. string msg = "参数错误";
  631. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  632. {
  633. try
  634. {
  635. //_delegationVisaRep.BeginTran();
  636. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  637. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  638. .Where(s => s.Id == dto.visaProgressCustomerId)
  639. .ExecuteCommandAsync();
  640. if (updCount > 0 && dto.publishCode == 1)
  641. {
  642. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  643. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  644. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  645. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  646. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  647. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  648. if (groupData == null)
  649. {
  650. _delegationVisaRep.RollbackTran();
  651. }
  652. string title = string.Format(@"[签证进度更新]");
  653. string content = string.Format(@"测试文本");
  654. bool rst = await _message.AddMsg(new MessageDto()
  655. {
  656. Type = 5,
  657. IssuerId = dto.publisher,
  658. Title = title,
  659. Content = content,
  660. ReleaseTime = DateTime.Now,
  661. UIdList = new List<int> {
  662. 234
  663. }
  664. });
  665. if (rst)
  666. {
  667. return Ok(JsonView(true, "发送通知成功"));
  668. }
  669. }
  670. //_delegationVisaRep.CommitTran();
  671. }
  672. catch (Exception)
  673. {
  674. //_delegationVisaRep.RollbackTran();
  675. }
  676. }
  677. return Ok(JsonView(true, msg));
  678. }
  679. #endregion
  680. #region 团组任务分配
  681. /// <summary>
  682. /// 团组任务分配初始化
  683. /// </summary>
  684. /// <param name="dto"></param>
  685. /// <returns></returns>
  686. [HttpPost]
  687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  688. public async Task<IActionResult> GetTaskAssignmen()
  689. {
  690. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  691. if (groupData.Code != 0)
  692. {
  693. return Ok(JsonView(false, groupData.Msg));
  694. }
  695. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  696. }
  697. /// <summary>
  698. /// 团组任务分配查询
  699. /// </summary>
  700. /// <param name="dto"></param>
  701. /// <returns></returns>
  702. [HttpPost]
  703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  704. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  705. {
  706. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  707. if (groupData.Code != 0)
  708. {
  709. return Ok(JsonView(false, groupData.Msg));
  710. }
  711. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  712. }
  713. /// <summary>
  714. /// 团组任务分配操作
  715. /// </summary>
  716. /// <param name="dto"></param>
  717. /// <returns></returns>
  718. [HttpPost]
  719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  720. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  721. {
  722. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  723. if (groupData.Code != 0)
  724. {
  725. return Ok(JsonView(false, groupData.Msg));
  726. }
  727. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  728. }
  729. #endregion
  730. #region 团组费用审核
  731. /// <summary>
  732. /// 费用审核
  733. /// 团组列表 Page
  734. /// </summary>
  735. /// <param name="_dto">团组列表请求dto</param>
  736. /// <returns></returns>
  737. [HttpPost]
  738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  739. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  740. {
  741. #region 参数验证
  742. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  743. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  744. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  745. #region 页面操作权限验证
  746. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  747. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  748. #endregion
  749. #endregion
  750. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  751. {
  752. string sqlWhere = string.Empty;
  753. if (_dto.IsSure == 0) //未完成
  754. {
  755. sqlWhere += string.Format(@" And IsSure = 0");
  756. }
  757. else if (_dto.IsSure == 1) //已完成
  758. {
  759. sqlWhere += string.Format(@" And IsSure = 1");
  760. }
  761. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  762. {
  763. string tj = _dto.SearchCriteria;
  764. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  765. tj, tj, tj, tj, tj);
  766. }
  767. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  768. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  769. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  770. From (
  771. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  772. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  773. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  774. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  775. From Grp_DelegationInfo gdi
  776. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  777. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  778. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  779. Where gdi.IsDel = 0 {0}
  780. ) temp ", sqlWhere);
  781. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  782. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  783. var _view = new
  784. {
  785. PageFuncAuth = pageFunAuthView,
  786. Data = _DelegationList
  787. };
  788. return Ok(JsonView(true, "查询成功!", _view, total));
  789. }
  790. else
  791. {
  792. return Ok(JsonView(false, "查询失败"));
  793. }
  794. }
  795. /// <summary>
  796. /// 获取团组费用审核
  797. /// </summary>
  798. /// <param name="paras">参数Json字符串</param>
  799. /// <returns></returns>
  800. [HttpPost]
  801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  802. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  803. {
  804. try
  805. {
  806. #region 参数验证
  807. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  808. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  809. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  810. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  811. #region 页面操作权限验证
  812. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  813. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  814. #endregion
  815. #endregion
  816. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  817. #region 费用清单
  818. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  819. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  820. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  821. List<Grp_CreditCardPayment> entityList = _groupRepository
  822. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  823. .Where(exp.ToExpression())
  824. .ToList();
  825. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  826. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  827. /*
  828. * 76://酒店预订
  829. */
  830. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  831. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  832. .ToListAsync();
  833. /*
  834. * 79://车/导游地接
  835. */
  836. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  837. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  838. .ToListAsync();
  839. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  840. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  841. .ToListAsync();
  842. /*
  843. * 80: //签证
  844. */
  845. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  846. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  847. .ToListAsync();
  848. /*
  849. *81: //邀请/公务活动
  850. */
  851. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  852. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  853. .ToListAsync();
  854. /*
  855. * 82: //团组客户保险
  856. */
  857. /*
  858. * Label = 98 其他款项
  859. */
  860. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  861. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  862. .ToListAsync();
  863. /*
  864. * Lable = 85 机票预订
  865. */
  866. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  867. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  868. .ToListAsync();
  869. /*
  870. * 285://收款退还
  871. */
  872. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys= await _groupRepository
  873. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  874. .ToListAsync();
  875. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0) .ToListAsync();
  876. /*
  877. * 币种信息
  878. */
  879. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  880. /*
  881. * 车/导游地接 费用类型
  882. */
  883. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  884. /*
  885. * 用户信息
  886. */
  887. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  888. /*
  889. * 费用模块
  890. */
  891. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  892. string priceModule = string.Empty;
  893. if (sdPriceName != null)
  894. {
  895. priceModule = sdPriceName.Name;
  896. }
  897. /*
  898. * 处理详情数据
  899. */
  900. foreach (var entity in entityList)
  901. {
  902. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  903. _detail.Id = entity.Id;
  904. _detail.PriceName = priceModule;
  905. /*
  906. * 应付款金额
  907. */
  908. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  909. string PaymentCurrency_WaitPay = "Unknown";
  910. string hotelCurrncyCode = "Unknown";
  911. string hotelCurrncyName = "Unknown";
  912. if (sdPaymentCurrency_WaitPay != null)
  913. {
  914. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  915. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  916. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  917. }
  918. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1() + " " + PaymentCurrency_WaitPay;
  919. /*
  920. * 此次付款金额
  921. */
  922. decimal CurrPayStr = 0;
  923. if (entity.PayPercentage == 0)
  924. {
  925. if (entity.PayThenMoney != 0)
  926. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  927. }
  928. else
  929. {
  930. CurrPayStr = (entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * entity.DayRate)).ConvertToDecimal1();
  931. }
  932. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  933. /*
  934. * 剩余尾款
  935. */
  936. decimal BalanceStr = 0;
  937. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  938. BalanceStr = 0;
  939. else
  940. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  941. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  942. /*
  943. * Bus名称
  944. */
  945. _detail.BusName = "待增加";
  946. /*
  947. *费用所属
  948. */
  949. switch (entity.CTable)
  950. {
  951. case 76://酒店预订
  952. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  953. if (hotelReservations != null)
  954. {
  955. _detail.PriceMsgContent = "信用卡金额:" + _detail.WaitPay + " " + hotelCurrncyCode + "(" + hotelCurrncyName + ")<br/>" +
  956. "房间说明:" + hotelReservations.Remark;
  957. _detail.PriceNameContent = hotelReservations.HotelName;
  958. }
  959. break;
  960. case 79://车/导游地接
  961. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  962. if (touristGuideGroundReservations != null)
  963. {
  964. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  965. {
  966. _detail.BusName = touristGuideGroundReservations.BusName;
  967. }
  968. _detail.PriceNameContent = touristGuideGroundReservations.Area;
  969. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  970. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  971. string priceMsg = string.Empty;
  972. foreach (var item in touristGuideGroundReservationsContents)
  973. {
  974. string typeName = "Unknown";
  975. string carCurrencyCode = "Unknown";
  976. string carCurrencyName = "Unknown";
  977. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  978. if (carTypeData != null) typeName = carTypeData.Name;
  979. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  980. if (currencyData != null) {
  981. carCurrencyCode = currencyData.Name;
  982. carCurrencyName = currencyData.Remark;
  983. }
  984. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  985. "明细:" + item.PriceContent + "<br/>" +
  986. "备注:" + item.Remark + "<br/><br/>";
  987. }
  988. _detail.PriceMsgContent = priceMsg;
  989. }
  990. break;
  991. case 80: //签证
  992. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  993. if (visaInfo != null)
  994. {
  995. _detail.PriceNameContent = visaInfo.VisaClient;
  996. _detail.PriceMsgContent = "备注:" + visaInfo.Remark;
  997. }
  998. break;
  999. case 81: //邀请/公务活动
  1000. Grp_InvitationOfficialActivities invitationOfficialActivities = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1001. if (invitationOfficialActivities != null)
  1002. {
  1003. string ioaCurrencyCode = "Unknown";
  1004. string ioaCurrencyName= "Unknown";
  1005. var currencyData = currencyItems.Where(s => s.Id == invitationOfficialActivities.Currency && s.IsDel == 0).FirstOrDefault();
  1006. if (currencyData != null)
  1007. {
  1008. ioaCurrencyCode = currencyData.Name;
  1009. ioaCurrencyName = currencyData.Remark;
  1010. }
  1011. _detail.PriceNameContent = invitationOfficialActivities.InviterArea;
  1012. _detail.PriceMsgContent = "邀请费用:" + invitationOfficialActivities.InviteCosts + " "+ ioaCurrencyCode + "("+ ioaCurrencyName+ ")<br/>" +
  1013. "活动费用:- <br/>" +
  1014. "备注:" + invitationOfficialActivities.Remark + "<br/>";
  1015. }
  1016. break;
  1017. case 82: //团组客户保险
  1018. Grp_Customers customers = _Customers.Where(s => s.Id == entity.Id && s.IsDel == 0).FirstOrDefault();
  1019. if (customers != null)
  1020. {
  1021. _detail.PriceNameContent = customers.ClientName;
  1022. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1023. }
  1024. break;
  1025. case 85: //机票预订
  1026. Grp_AirTicketReservations jpRes = _groupRepository.Query<Grp_AirTicketReservations>(s => s.Id == entity.CId).First();
  1027. if (jpRes != null)
  1028. {
  1029. string FlightsDescription = jpRes.FlightsDescription;
  1030. string PriceDescription = jpRes.PriceDescription;
  1031. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1032. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1033. }
  1034. break;
  1035. case 98://其他款项
  1036. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1037. if (gdpRes != null)
  1038. {
  1039. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1040. _detail.PriceNameContent = gdpRes.PriceName;
  1041. }
  1042. break;
  1043. case 285://收款退还Fin_PaymentRefundAndOtherMoney
  1044. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1045. if (refundAndOtherMoney != null)
  1046. {
  1047. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1048. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1049. }
  1050. break;
  1051. case 751://酒店早餐
  1052. break;
  1053. default:
  1054. break;
  1055. }
  1056. /*
  1057. * 申请人
  1058. */
  1059. string operatorName = " - ";
  1060. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1061. if (_opUser != null)
  1062. {
  1063. operatorName = _opUser.CnName;
  1064. }
  1065. _detail.OperatorName = operatorName;
  1066. /*
  1067. * 审核人
  1068. */
  1069. string auditOperatorName = "Unknown";
  1070. if (entity.AuditGMOperate == 0)
  1071. auditOperatorName = " - ";
  1072. else if (entity.AuditGMOperate == 4)
  1073. auditOperatorName = "自动审核";
  1074. else
  1075. {
  1076. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1077. if (_adUser != null)
  1078. {
  1079. auditOperatorName = _adUser.CnName;
  1080. }
  1081. }
  1082. _detail.AuditOperatorName = auditOperatorName;
  1083. /*
  1084. * 超预算比例
  1085. */
  1086. string overBudgetStr = "";
  1087. if (entity.ExceedBudget == -1)
  1088. overBudgetStr = sdPriceName.Name + "尚无预算";
  1089. else if (entity.ExceedBudget == 0)
  1090. overBudgetStr = "未超预算";
  1091. else
  1092. overBudgetStr = entity.ExceedBudget.ToString("P");
  1093. _detail.OverBudget = overBudgetStr;
  1094. /*
  1095. * 费用总计
  1096. */
  1097. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1098. {
  1099. CurrencyId = entity.PaymentCurrency,
  1100. CurrencyName = PaymentCurrency_WaitPay,
  1101. AmountPayable = entity.PayMoney,
  1102. ThisPayment = CurrPayStr,
  1103. BalancePayment = BalanceStr,
  1104. AuditedFunds = CurrPayStr
  1105. });
  1106. _detail.IsAuditGM = entity.IsAuditGM;
  1107. detailList.Add(_detail);
  1108. }
  1109. #endregion
  1110. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1111. /*
  1112. * 下方描述处理
  1113. */
  1114. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1115. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1116. if (ccpCurrencyPrice != null)
  1117. {
  1118. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1119. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1120. }
  1121. else
  1122. {
  1123. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1124. }
  1125. string amountPayableStr = string.Format(@"应付款总金额: ");
  1126. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1127. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1128. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1129. foreach (var item in nonDuplicat)
  1130. {
  1131. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1132. if (strs.Count > 0)
  1133. {
  1134. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1135. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1136. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1137. //单独处理此次付款金额
  1138. if (item.CurrencyId == 836) //人名币
  1139. {
  1140. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1141. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1142. }
  1143. else
  1144. {
  1145. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|","0.00", item.CurrencyName);
  1146. }
  1147. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1148. //单独处理已审核费用
  1149. if (item.CurrencyId == 836) //人名币
  1150. {
  1151. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1152. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1153. }
  1154. else
  1155. {
  1156. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1157. }
  1158. }
  1159. }
  1160. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1161. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1162. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1163. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1164. var _view1 = new
  1165. {
  1166. PageFuncAuth = pageFunAuthView,
  1167. Data = _view
  1168. };
  1169. return Ok(JsonView(_view1));
  1170. }
  1171. catch (Exception ex)
  1172. {
  1173. return Ok(JsonView(false, ex.Message));
  1174. }
  1175. }
  1176. /// <summary>
  1177. /// 费用审核
  1178. /// 修改团组费用审核状态
  1179. /// </summary>
  1180. /// <param name="_dto">参数Json字符串</param>
  1181. /// <returns></returns>
  1182. [HttpPost]
  1183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1184. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1185. {
  1186. #region 参数验证
  1187. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1188. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1189. #endregion
  1190. #region 页面操作权限验证
  1191. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1192. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1193. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1194. #endregion
  1195. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1196. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1197. DateTime dtNow = DateTime.Now;
  1198. _groupRepository.BeginTran();
  1199. int rst = 0;
  1200. foreach (var item in idList)
  1201. {
  1202. int CreditId = int.Parse(item);
  1203. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1204. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1205. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1206. .SetColumns(it => it.AuditGMDate == dtNow.ToString())
  1207. .Where(s => s.Id == CreditId)
  1208. .ExecuteCommandAsync();
  1209. if (result < 1)
  1210. {
  1211. rst = -1;
  1212. _groupRepository.RollbackTran();
  1213. return Ok(JsonView(false, "保存失败并回滚!"));
  1214. }
  1215. else
  1216. {
  1217. }
  1218. }
  1219. _groupRepository.CommitTran();
  1220. if (rst == 0)
  1221. {
  1222. return Ok(JsonView(true, "保存成功!"));
  1223. }
  1224. return Ok(JsonView(false, "保存失败!"));
  1225. }
  1226. #endregion
  1227. #region 机票费用录入
  1228. /// <summary>
  1229. /// 机票录入当前登录人可操作团组
  1230. /// </summary>
  1231. /// <param name="dto"></param>
  1232. /// <returns></returns>
  1233. [HttpPost]
  1234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1235. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1236. {
  1237. try
  1238. {
  1239. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1240. if (groupData.Code != 0)
  1241. {
  1242. return Ok(JsonView(false, groupData.Msg));
  1243. }
  1244. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1245. }
  1246. catch (Exception ex)
  1247. {
  1248. return Ok(JsonView(false, "程序错误!"));
  1249. throw;
  1250. }
  1251. }
  1252. /// <summary>
  1253. /// 机票费用录入列表
  1254. /// </summary>
  1255. /// <param name="dto"></param>
  1256. /// <returns></returns>
  1257. [HttpPost]
  1258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1259. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1260. {
  1261. try
  1262. {
  1263. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1264. if (groupData.Code != 0)
  1265. {
  1266. return Ok(JsonView(false, groupData.Msg));
  1267. }
  1268. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1269. }
  1270. catch (Exception ex)
  1271. {
  1272. return Ok(JsonView(false, "程序错误!"));
  1273. throw;
  1274. }
  1275. }
  1276. /// <summary>
  1277. /// 根据id查询费用录入信息
  1278. /// </summary>
  1279. /// <param name="dto"></param>
  1280. /// <returns></returns>
  1281. [HttpPost]
  1282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1283. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1284. {
  1285. try
  1286. {
  1287. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1288. if (groupData.Code != 0)
  1289. {
  1290. return Ok(JsonView(false, groupData.Msg));
  1291. }
  1292. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1293. }
  1294. catch (Exception ex)
  1295. {
  1296. return Ok(JsonView(false, "程序错误!"));
  1297. throw;
  1298. }
  1299. }
  1300. /// <summary>
  1301. /// 机票费用录入操作(Status:1.新增,2.修改)
  1302. /// </summary>
  1303. /// <param name="dto"></param>
  1304. /// <returns></returns>
  1305. [HttpPost]
  1306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1307. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1308. {
  1309. try
  1310. {
  1311. Result groupData = await _airTicketResRep.OpAirTicketRes(dto);
  1312. if (groupData.Code != 0)
  1313. {
  1314. return Ok(JsonView(false, groupData.Msg));
  1315. }
  1316. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1317. }
  1318. catch (Exception ex)
  1319. {
  1320. return Ok(JsonView(false, "程序错误!"));
  1321. throw;
  1322. }
  1323. }
  1324. /// <summary>
  1325. /// 根据舱位类型查询接团客户名单信息
  1326. /// </summary>
  1327. /// <param name="dto"></param>
  1328. /// <returns></returns>
  1329. [HttpPost]
  1330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1331. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1332. {
  1333. try
  1334. {
  1335. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1336. if (crm_Groups.Count != 0)
  1337. {
  1338. List<dynamic> Customer = new List<dynamic>();
  1339. foreach (var item in crm_Groups)
  1340. {
  1341. var data = new
  1342. {
  1343. Id = item.Id,
  1344. Pinyin = item.Pinyin,
  1345. Name = item.LastName + item.FirstName
  1346. };
  1347. Customer.Add(data);
  1348. }
  1349. return Ok(JsonView(true, "查询成功!", Customer));
  1350. }
  1351. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1352. }
  1353. catch (Exception ex)
  1354. {
  1355. return Ok(JsonView(false, "程序错误!"));
  1356. throw;
  1357. }
  1358. }
  1359. /// <summary>
  1360. /// 机票费用录入,删除
  1361. /// </summary>
  1362. /// <param name="dto"></param>
  1363. /// <returns></returns>
  1364. [HttpPost]
  1365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1366. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1367. {
  1368. try
  1369. {
  1370. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1371. if (!res)
  1372. {
  1373. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1374. {
  1375. IsDel = 1,
  1376. DeleteUserId = dto.DeleteUserId,
  1377. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1378. }).ExecuteCommandAsync();
  1379. return Ok(JsonView(false, "删除失败"));
  1380. }
  1381. return Ok(JsonView(true, "删除成功!"));
  1382. }
  1383. catch (Exception ex)
  1384. {
  1385. return Ok(JsonView(false, "程序错误!"));
  1386. throw;
  1387. }
  1388. }
  1389. /// <summary>
  1390. /// 导出机票录入报表
  1391. /// </summary>
  1392. /// <param name="dto"></param>
  1393. /// <returns></returns>
  1394. [HttpPost]
  1395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1396. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  1397. {
  1398. try
  1399. {
  1400. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1401. if (groupData.Code != 0)
  1402. {
  1403. return Ok(JsonView(false, groupData.Msg));
  1404. }
  1405. else
  1406. {
  1407. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1408. if (AirTicketReservations.Count != 0)
  1409. {
  1410. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1411. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1412. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1413. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1414. WorkbookDesigner designer = new WorkbookDesigner();
  1415. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1416. decimal countCost = 0;
  1417. foreach (var item in AirTicketReservations)
  1418. {
  1419. if (item.BankType == "其他")
  1420. {
  1421. item.BankNo = "--";
  1422. }
  1423. else
  1424. {
  1425. item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
  1426. }
  1427. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1428. item.Price = System.Decimal.Round(item.Price, 2);
  1429. countCost += Convert.ToDecimal(item.Price);
  1430. }
  1431. designer.SetDataSource("Export", AirTicketReservations);
  1432. designer.SetDataSource("ExportDiCode", diCode);
  1433. designer.SetDataSource("ExportDiName", diName);
  1434. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1435. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1436. designer.Process();
  1437. string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  1438. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1439. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1440. return Ok(JsonView(true, "成功", url = rst));
  1441. }
  1442. else
  1443. {
  1444. return Ok(JsonView(false, "暂无数据!"));
  1445. }
  1446. }
  1447. }
  1448. catch (Exception ex)
  1449. {
  1450. return Ok(JsonView(false, "程序错误!"));
  1451. throw;
  1452. }
  1453. }
  1454. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1455. /// <summary>
  1456. /// 行程单导出
  1457. /// </summary>
  1458. /// <param name="dto"></param>
  1459. /// <returns></returns>
  1460. [HttpPost]
  1461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1462. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1463. {
  1464. try
  1465. {
  1466. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1467. if (groupData.Code != 0)
  1468. {
  1469. return Ok(JsonView(false, groupData.Msg));
  1470. }
  1471. else
  1472. {
  1473. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1474. if (dto.Language == "CN")
  1475. {
  1476. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1477. DocumentBuilder builder = new DocumentBuilder(doc);
  1478. int tableIndex = 0;//表格索引
  1479. //得到文档中的第一个表格
  1480. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1481. foreach (var item in _AirTicketReservations)
  1482. {
  1483. #region 处理固定数据
  1484. string[] FlightsCode = item.FlightsCode.Split('/');
  1485. if (FlightsCode.Length != 0)
  1486. {
  1487. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1488. if (_AirCompany != null)
  1489. {
  1490. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1491. }
  1492. else
  1493. {
  1494. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1495. }
  1496. }
  1497. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1498. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1499. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1500. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1501. string name = "";
  1502. foreach (string clientName in nameArray)
  1503. {
  1504. if (!name.Contains(clientName))
  1505. {
  1506. name += clientName + ",";
  1507. }
  1508. }
  1509. if (!string.IsNullOrWhiteSpace(name))
  1510. {
  1511. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1512. }
  1513. else
  1514. {
  1515. table.Range.Bookmarks["ClientName"].Text = "--";
  1516. }
  1517. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1518. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1519. table.Range.Bookmarks["JointTicket"].Text = "--";
  1520. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1521. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1522. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1523. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1524. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1525. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1526. #endregion
  1527. #region 循环数据处理
  1528. List<AirInfo> airs = new List<AirInfo>();
  1529. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1530. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1531. for (int i = 0; i < FlightsCode.Length; i++)
  1532. {
  1533. AirInfo air = new AirInfo();
  1534. string[] tempstr = DayArray[i]
  1535. .Replace("\r\n", string.Empty)
  1536. .Replace("\\r\\n", string.Empty)
  1537. .TrimStart().TrimEnd()
  1538. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1539. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1540. string starCity = "";
  1541. if (star_Three != null)
  1542. {
  1543. starCity = star_Three.AirPort;
  1544. }
  1545. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1546. string EndCity = "";
  1547. if (End_Three != null)
  1548. {
  1549. EndCity = End_Three.AirPort;
  1550. }
  1551. air.Destination = starCity + "/" + EndCity;
  1552. air.Flight = FlightsCode[i];
  1553. air.SeatingClass = item.CTypeName;
  1554. string dateTime = tempstr[2];
  1555. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1556. air.FlightDate = DateTemp;
  1557. air.DepartureTime = tempstr[5];
  1558. air.LandingTime = tempstr[6];
  1559. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1560. air.TicketStatus = "--";
  1561. air.Luggage = "--";
  1562. air.DepartureTerminal = "--";
  1563. air.LandingTerminal = "--";
  1564. airs.Add(air);
  1565. }
  1566. int row = 13;
  1567. for (int i = 0; i < airs.Count; i++)
  1568. {
  1569. if (airs.Count > 2)
  1570. {
  1571. for (int j = 0; j < airs.Count - 2; j++)
  1572. {
  1573. var CopyRow = table.Rows[12].Clone(true);
  1574. table.Rows.Add(CopyRow);
  1575. }
  1576. }
  1577. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1578. int index = 0;
  1579. foreach (PropertyInfo property in properties)
  1580. {
  1581. string value = property.GetValue(airs[i]).ToString();
  1582. Cell ishcel0 = table.Rows[row].Cells[index];
  1583. Paragraph p = new Paragraph(doc);
  1584. string s = value;
  1585. p.AppendChild(new Run(doc, s));
  1586. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1587. ishcel0.AppendChild(p);
  1588. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1589. index++;
  1590. }
  1591. row++;
  1592. }
  1593. #endregion
  1594. Paragraph lastParagraph = new Paragraph(doc);
  1595. //第一个表格末尾加段落
  1596. table.ParentNode.InsertAfter(lastParagraph, table);
  1597. //复制第一个表格
  1598. Table cloneTable = (Table)table.Clone(true);
  1599. //在文档末尾段落后面加入复制的表格
  1600. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1601. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1602. {
  1603. int rownewsIndex = 13;
  1604. for (int i = 0; i < 2; i++)
  1605. {
  1606. var CopyRow = table.Rows[12].Clone(true);
  1607. table.Rows.RemoveAt(13);
  1608. table.Rows.Add(CopyRow);
  1609. rownewsIndex++;
  1610. }
  1611. }
  1612. else
  1613. {
  1614. table.Rows.RemoveAt(12);
  1615. }
  1616. cloneTable.Rows.RemoveAt(12);
  1617. }
  1618. if (_AirTicketReservations.Count != 0)
  1619. {
  1620. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1621. if (FlightsCode.Length != 0)
  1622. {
  1623. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1624. if (_AirCompany != null)
  1625. {
  1626. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1627. }
  1628. else
  1629. {
  1630. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1631. }
  1632. }
  1633. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1634. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1635. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1636. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1637. string name = "";
  1638. foreach (string clientName in nameArray)
  1639. {
  1640. if (!name.Contains(clientName))
  1641. {
  1642. name += clientName + ",";
  1643. }
  1644. }
  1645. if (!string.IsNullOrWhiteSpace(name))
  1646. {
  1647. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1648. }
  1649. else
  1650. {
  1651. table.Range.Bookmarks["ClientName"].Text = "--";
  1652. }
  1653. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1654. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1655. table.Range.Bookmarks["JointTicket"].Text = "--";
  1656. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1657. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1658. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1659. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1660. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1661. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1662. }
  1663. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1664. //保存合并后的文档
  1665. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  1666. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1667. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1668. return Ok(JsonView(true, "成功!", rst));
  1669. }
  1670. else
  1671. {
  1672. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  1673. DocumentBuilder builder = new DocumentBuilder(doc);
  1674. int tableIndex = 0;//表格索引
  1675. //得到文档中的第一个表格
  1676. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1677. List<string> texts = new List<string>();
  1678. foreach (var item in _AirTicketReservations)
  1679. {
  1680. string[] FlightsCode = item.FlightsCode.Split('/');
  1681. if (FlightsCode.Length != 0)
  1682. {
  1683. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1684. if (_AirCompany != null)
  1685. {
  1686. if (!transDic.ContainsKey(_AirCompany.CnName))
  1687. {
  1688. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  1689. }
  1690. }
  1691. else
  1692. {
  1693. if (!transDic.ContainsKey("--"))
  1694. {
  1695. transDic.Add("--", "--");
  1696. }
  1697. }
  1698. }
  1699. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1700. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1701. string name = "";
  1702. foreach (string clientName in nameArray)
  1703. {
  1704. name += clientName + ",";
  1705. }
  1706. if (!texts.Contains(name))
  1707. {
  1708. texts.Add(name);
  1709. }
  1710. List<AirInfo> airs = new List<AirInfo>();
  1711. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1712. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1713. for (int i = 0; i < FlightsCode.Length; i++)
  1714. {
  1715. AirInfo air = new AirInfo();
  1716. string[] tempstr = DayArray[i]
  1717. .Replace("\r\n", string.Empty)
  1718. .Replace("\\r\\n", string.Empty)
  1719. .TrimStart().TrimEnd()
  1720. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1721. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1722. if (star_Three != null)
  1723. {
  1724. if (!transDic.ContainsKey(star_Three.AirPort))
  1725. {
  1726. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  1727. }
  1728. }
  1729. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1730. if (End_Three != null)
  1731. {
  1732. if (!transDic.ContainsKey(End_Three.AirPort))
  1733. {
  1734. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  1735. }
  1736. }
  1737. if (!texts.Contains(item.CTypeName))
  1738. {
  1739. texts.Add(item.CTypeName);
  1740. }
  1741. }
  1742. }
  1743. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  1744. if (transData.Count > 0)
  1745. {
  1746. foreach (TranslateResult item in transData)
  1747. {
  1748. if (!transDic.ContainsKey(item.Query))
  1749. {
  1750. transDic.Add(item.Query, item.Translation);
  1751. }
  1752. }
  1753. }
  1754. foreach (var item in _AirTicketReservations)
  1755. {
  1756. #region 处理固定数据
  1757. string[] FlightsCode = item.FlightsCode.Split('/');
  1758. if (FlightsCode.Length != 0)
  1759. {
  1760. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1761. if (_AirCompany != null)
  1762. {
  1763. string str = "--";
  1764. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1765. if (!string.IsNullOrEmpty(translateResult))
  1766. {
  1767. str = translateResult;
  1768. str = _airTicketResRep.Processing(str);
  1769. }
  1770. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1771. }
  1772. else
  1773. {
  1774. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1775. }
  1776. }
  1777. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1778. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1779. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1780. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1781. string names = "";
  1782. foreach (string clientName in nameArray)
  1783. {
  1784. names += clientName + ",";
  1785. }
  1786. if (!string.IsNullOrWhiteSpace(names))
  1787. {
  1788. string str = "--";
  1789. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1790. if (!string.IsNullOrEmpty(translateResult))
  1791. {
  1792. str = translateResult;
  1793. str = _airTicketResRep.Processing(str);
  1794. }
  1795. table.Range.Bookmarks["ClientName"].Text = str;
  1796. }
  1797. else
  1798. {
  1799. table.Range.Bookmarks["ClientName"].Text = "--";
  1800. }
  1801. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1802. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1803. table.Range.Bookmarks["JointTicket"].Text = "--";
  1804. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1805. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1806. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1807. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1808. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1809. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1810. #endregion
  1811. #region 循环数据处理
  1812. List<AirInfo> airs = new List<AirInfo>();
  1813. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1814. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1815. for (int i = 0; i < FlightsCode.Length; i++)
  1816. {
  1817. AirInfo air = new AirInfo();
  1818. string[] tempstr = DayArray[i]
  1819. .Replace("\r\n", string.Empty)
  1820. .Replace("\\r\\n", string.Empty)
  1821. .TrimStart().TrimEnd()
  1822. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1823. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1824. string starCity = "";
  1825. if (star_Three != null)
  1826. {
  1827. string str2 = "--";
  1828. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  1829. if (!string.IsNullOrEmpty(translateResult2))
  1830. {
  1831. str2 = translateResult2;
  1832. str2 = _airTicketResRep.Processing(str2);
  1833. }
  1834. starCity = str2;
  1835. }
  1836. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1837. string EndCity = "";
  1838. if (End_Three != null)
  1839. {
  1840. string str1 = "--";
  1841. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  1842. if (!string.IsNullOrEmpty(translateResult1))
  1843. {
  1844. str1 = translateResult1;
  1845. str1 = _airTicketResRep.Processing(str1);
  1846. }
  1847. EndCity = str1;
  1848. }
  1849. air.Destination = starCity + "/" + EndCity;
  1850. air.Flight = FlightsCode[i];
  1851. string str = "--";
  1852. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  1853. if (!string.IsNullOrEmpty(translateResult))
  1854. {
  1855. str = translateResult;
  1856. str = _airTicketResRep.Processing(str);
  1857. }
  1858. air.SeatingClass = str;
  1859. string dateTime = tempstr[2];
  1860. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1861. air.FlightDate = DateTemp;
  1862. air.DepartureTime = tempstr[5];
  1863. air.LandingTime = tempstr[6];
  1864. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1865. air.TicketStatus = "--";
  1866. air.Luggage = "--";
  1867. air.DepartureTerminal = "--";
  1868. air.LandingTerminal = "--";
  1869. airs.Add(air);
  1870. }
  1871. int row = 13;
  1872. for (int i = 0; i < airs.Count; i++)
  1873. {
  1874. if (airs.Count > 2)
  1875. {
  1876. for (int j = 0; j < airs.Count - 2; j++)
  1877. {
  1878. var CopyRow = table.Rows[12].Clone(true);
  1879. table.Rows.Add(CopyRow);
  1880. }
  1881. }
  1882. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1883. int index = 0;
  1884. foreach (PropertyInfo property in properties)
  1885. {
  1886. string value = property.GetValue(airs[i]).ToString();
  1887. Cell ishcel0 = table.Rows[row].Cells[index];
  1888. Paragraph p = new Paragraph(doc);
  1889. string s = value;
  1890. p.AppendChild(new Run(doc, s));
  1891. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1892. ishcel0.AppendChild(p);
  1893. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1894. //ishcel0.CellFormat.VerticalAlignment=
  1895. index++;
  1896. }
  1897. row++;
  1898. }
  1899. #endregion
  1900. Paragraph lastParagraph = new Paragraph(doc);
  1901. //第一个表格末尾加段落
  1902. table.ParentNode.InsertAfter(lastParagraph, table);
  1903. //复制第一个表格
  1904. Table cloneTable = (Table)table.Clone(true);
  1905. //在文档末尾段落后面加入复制的表格
  1906. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1907. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1908. {
  1909. int rownewsIndex = 13;
  1910. for (int i = 0; i < 2; i++)
  1911. {
  1912. var CopyRow = table.Rows[12].Clone(true);
  1913. table.Rows.RemoveAt(13);
  1914. table.Rows.Add(CopyRow);
  1915. rownewsIndex++;
  1916. }
  1917. }
  1918. else
  1919. {
  1920. table.Rows.RemoveAt(12);
  1921. }
  1922. cloneTable.Rows.RemoveAt(12);
  1923. }
  1924. if (_AirTicketReservations.Count != 0)
  1925. {
  1926. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1927. if (FlightsCode.Length != 0)
  1928. {
  1929. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1930. if (_AirCompany != null)
  1931. {
  1932. string str = "--";
  1933. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1934. if (!string.IsNullOrEmpty(translateResult))
  1935. {
  1936. str = translateResult;
  1937. str = _airTicketResRep.Processing(str);
  1938. }
  1939. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1940. }
  1941. else
  1942. {
  1943. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1944. }
  1945. }
  1946. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1947. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1948. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1949. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1950. string names = "";
  1951. foreach (string clientName in nameArray)
  1952. {
  1953. names += clientName + ",";
  1954. }
  1955. if (!string.IsNullOrWhiteSpace(names))
  1956. {
  1957. string str = "--";
  1958. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1959. if (!string.IsNullOrEmpty(translateResult))
  1960. {
  1961. str = translateResult;
  1962. str = _airTicketResRep.Processing(str);
  1963. }
  1964. table.Range.Bookmarks["ClientName"].Text = str;
  1965. }
  1966. else
  1967. {
  1968. table.Range.Bookmarks["ClientName"].Text = "--";
  1969. }
  1970. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1971. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1972. table.Range.Bookmarks["JointTicket"].Text = "--";
  1973. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1974. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1975. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1976. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1977. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1978. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1979. }
  1980. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1981. //保存合并后的文档
  1982. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  1983. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1984. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1985. return Ok(JsonView(true, "成功!", rst));
  1986. }
  1987. }
  1988. }
  1989. catch (Exception ex)
  1990. {
  1991. return Ok(JsonView(false, "程序错误!"));
  1992. throw;
  1993. }
  1994. }
  1995. #endregion
  1996. #region 团组增减款项
  1997. /// <summary>
  1998. /// 团组增减款项下拉框绑定
  1999. /// </summary>
  2000. /// <param name="dto"></param>
  2001. /// <returns></returns>
  2002. [HttpPost]
  2003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2004. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2005. {
  2006. try
  2007. {
  2008. Result groupData = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  2009. if (groupData.Code != 0)
  2010. {
  2011. return Ok(JsonView(false, groupData.Msg));
  2012. }
  2013. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2014. }
  2015. catch (Exception ex)
  2016. {
  2017. return Ok(JsonView(false, "程序错误!"));
  2018. throw;
  2019. }
  2020. }
  2021. /// <summary>
  2022. /// 根据团组Id查询团组增减款项
  2023. /// </summary>
  2024. /// <param name="dto"></param>
  2025. /// <returns></returns>
  2026. [HttpPost]
  2027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2028. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2029. {
  2030. try
  2031. {
  2032. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  2033. if (groupData.Code != 0)
  2034. {
  2035. return Ok(JsonView(false, groupData.Msg));
  2036. }
  2037. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2038. }
  2039. catch (Exception ex)
  2040. {
  2041. return Ok(JsonView(false, "程序错误!"));
  2042. throw;
  2043. }
  2044. }
  2045. /// <summary>
  2046. /// 团组增减款项操作(Status:1.新增,2.修改)
  2047. /// </summary>
  2048. /// <param name="dto"></param>
  2049. /// <returns></returns>
  2050. [HttpPost]
  2051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2052. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2053. {
  2054. try
  2055. {
  2056. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2057. if (groupData.Code != 0)
  2058. {
  2059. return Ok(JsonView(false, groupData.Msg));
  2060. }
  2061. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2062. }
  2063. catch (Exception ex)
  2064. {
  2065. return Ok(JsonView(false, "程序错误!"));
  2066. throw;
  2067. }
  2068. }
  2069. /// <summary>
  2070. /// 团组增减款项操作 删除
  2071. /// </summary>
  2072. /// <param name="dto"></param>
  2073. /// <returns></returns>
  2074. [HttpPost]
  2075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2076. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2077. {
  2078. try
  2079. {
  2080. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  2081. if (!res)
  2082. {
  2083. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  2084. {
  2085. IsDel = 1,
  2086. DeleteUserId = dto.DeleteUserId,
  2087. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2088. }).ExecuteCommandAsync();
  2089. return Ok(JsonView(false, "删除失败"));
  2090. }
  2091. return Ok(JsonView(true, "删除成功!"));
  2092. }
  2093. catch (Exception ex)
  2094. {
  2095. return Ok(JsonView(false, "程序错误!"));
  2096. throw;
  2097. }
  2098. }
  2099. /// <summary>
  2100. /// 根据团组增减款项Id查询
  2101. /// </summary>
  2102. /// <param name="dto"></param>
  2103. /// <returns></returns>
  2104. [HttpPost]
  2105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2106. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2107. {
  2108. try
  2109. {
  2110. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  2111. if (groupData.Code != 0)
  2112. {
  2113. return Ok(JsonView(false, groupData.Msg));
  2114. }
  2115. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2116. }
  2117. catch (Exception ex)
  2118. {
  2119. return Ok(JsonView(false, "程序错误!"));
  2120. throw;
  2121. }
  2122. }
  2123. #endregion
  2124. #region 文件上传、删除
  2125. /// <summary>
  2126. /// region 文件上传 可以带参数
  2127. /// </summary>
  2128. /// <param name="file"></param>
  2129. /// <returns></returns>
  2130. [HttpPost]
  2131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2132. public async Task<IActionResult> UploadProject(IFormFile file)
  2133. {
  2134. try
  2135. {
  2136. var TypeName = Request.Headers["TypeName"].ToString();
  2137. if (file != null)
  2138. {
  2139. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2140. //文件名称
  2141. string projectFileName = file.FileName;
  2142. //上传的文件的路径
  2143. string filePath = "";
  2144. if (TypeName == "A")//A代表团组增减款项
  2145. {
  2146. if (!Directory.Exists(fileDir))
  2147. {
  2148. Directory.CreateDirectory(fileDir);
  2149. }
  2150. //上传的文件的路径
  2151. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2152. }
  2153. else if (TypeName == "B")//B代表商邀相关文件
  2154. {
  2155. if (!Directory.Exists(fileDir))
  2156. {
  2157. Directory.CreateDirectory(fileDir);
  2158. }
  2159. //上传的文件的路径
  2160. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2161. }
  2162. using (FileStream fs = System.IO.File.Create(filePath))
  2163. {
  2164. file.CopyTo(fs);
  2165. fs.Flush();
  2166. }
  2167. return Ok(JsonView(true, "上传成功!", projectFileName));
  2168. }
  2169. else
  2170. {
  2171. return Ok(JsonView(false, "上传失败!"));
  2172. }
  2173. }
  2174. catch (Exception ex)
  2175. {
  2176. return Ok(JsonView(false, "程序错误!"));
  2177. throw;
  2178. }
  2179. }
  2180. /// <summary>
  2181. /// 删除指定文件
  2182. /// </summary>
  2183. /// <param name="dto"></param>
  2184. /// <returns></returns>
  2185. [HttpPost]
  2186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2187. public async Task<IActionResult> DelFile(DelFileDto dto)
  2188. {
  2189. try
  2190. {
  2191. var TypeName = Request.Headers["TypeName"].ToString();
  2192. string filePath = "";
  2193. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2194. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2195. int id = 0;
  2196. if (TypeName == "A")
  2197. {
  2198. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2199. // 删除该文件
  2200. System.IO.File.Delete(filePath);
  2201. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2202. }
  2203. else if (TypeName == "B")
  2204. {
  2205. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2206. // 删除该文件
  2207. System.IO.File.Delete(filePath);
  2208. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2209. }
  2210. if (id != 0)
  2211. {
  2212. return Ok(JsonView(true, "成功!"));
  2213. }
  2214. else
  2215. {
  2216. return Ok(JsonView(false, "失败!"));
  2217. }
  2218. }
  2219. catch (Exception ex)
  2220. {
  2221. return Ok(JsonView(false, "程序错误!"));
  2222. throw;
  2223. }
  2224. }
  2225. #endregion
  2226. #region 商邀费用录入
  2227. /// <summary>
  2228. /// 根据团组Id查询商邀费用列表
  2229. /// </summary>
  2230. /// <param name="dto"></param>
  2231. /// <returns></returns>
  2232. [HttpPost]
  2233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2234. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2235. {
  2236. try
  2237. {
  2238. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2239. if (groupData.Code != 0)
  2240. {
  2241. return Ok(JsonView(false, groupData.Msg));
  2242. }
  2243. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2244. }
  2245. catch (Exception ex)
  2246. {
  2247. return Ok(JsonView(false, "程序错误!"));
  2248. throw;
  2249. }
  2250. }
  2251. /// <summary>
  2252. /// 根据商邀费用ID查询C表和商邀费用数据
  2253. /// </summary>
  2254. /// <param name="dto"></param>
  2255. /// <returns></returns>
  2256. [HttpPost]
  2257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2258. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2259. {
  2260. try
  2261. {
  2262. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2263. if (groupData.Code != 0)
  2264. {
  2265. return Ok(JsonView(false, groupData.Msg));
  2266. }
  2267. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2268. }
  2269. catch (Exception ex)
  2270. {
  2271. return Ok(JsonView(false, "程序错误!"));
  2272. throw;
  2273. }
  2274. }
  2275. /// <summary>
  2276. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2277. /// </summary>
  2278. /// <param name="dto"></param>
  2279. /// <returns></returns>
  2280. [HttpPost]
  2281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2282. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2283. {
  2284. try
  2285. {
  2286. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto);
  2287. if (groupData.Code != 0)
  2288. {
  2289. return Ok(JsonView(false, groupData.Msg));
  2290. }
  2291. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2292. }
  2293. catch (Exception ex)
  2294. {
  2295. return Ok(JsonView(false, "程序错误!"));
  2296. throw;
  2297. }
  2298. }
  2299. /// <summary>
  2300. /// 商邀删除
  2301. /// </summary>
  2302. /// <param name="dto"></param>
  2303. /// <returns></returns>
  2304. [HttpPost]
  2305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2306. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2307. {
  2308. try
  2309. {
  2310. var res = await _InvitationOfficialActivitiesRep.SoftDeleteByIdAsync<Grp_InvitationOfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  2311. if (!res)
  2312. {
  2313. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 81).SetColumns(a => new Grp_CreditCardPayment()
  2314. {
  2315. IsDel = 1,
  2316. DeleteUserId = dto.DeleteUserId,
  2317. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2318. }).ExecuteCommandAsync();
  2319. return Ok(JsonView(false, "删除失败"));
  2320. }
  2321. return Ok(JsonView(true, "删除成功!"));
  2322. }
  2323. catch (Exception ex)
  2324. {
  2325. return Ok(JsonView(false, "程序错误!"));
  2326. throw;
  2327. }
  2328. }
  2329. #endregion
  2330. #region 团组英文资料
  2331. /// <summary>
  2332. /// 查询团组英文所有资料
  2333. /// </summary>
  2334. /// <param name="dto"></param>
  2335. /// <returns></returns>
  2336. [HttpPost]
  2337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2338. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2339. {
  2340. try
  2341. {
  2342. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  2343. if (groupData.Code != 0)
  2344. {
  2345. return Ok(JsonView(false, groupData.Msg));
  2346. }
  2347. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2348. }
  2349. catch (Exception ex)
  2350. {
  2351. return Ok(JsonView(false, "程序错误!"));
  2352. throw;
  2353. }
  2354. }
  2355. /// <summary>
  2356. /// 团组英文资料操作(Status:1.新增,2.修改)
  2357. /// </summary>
  2358. /// <param name="dto"></param>
  2359. /// <returns></returns>
  2360. [HttpPost]
  2361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2362. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  2363. {
  2364. try
  2365. {
  2366. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  2367. if (groupData.Code != 0)
  2368. {
  2369. return Ok(JsonView(false, groupData.Msg));
  2370. }
  2371. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2372. }
  2373. catch (Exception ex)
  2374. {
  2375. return Ok(JsonView(false, "程序错误!"));
  2376. throw;
  2377. }
  2378. }
  2379. /// <summary>
  2380. /// 团组英文资料Id查询数据
  2381. /// </summary>
  2382. /// <param name="dto"></param>
  2383. /// <returns></returns>
  2384. [HttpPost]
  2385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2386. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  2387. {
  2388. try
  2389. {
  2390. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  2391. if (_DelegationEnData != null)
  2392. {
  2393. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  2394. }
  2395. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  2396. }
  2397. catch (Exception ex)
  2398. {
  2399. return Ok(JsonView(false, "程序错误!"));
  2400. throw;
  2401. }
  2402. }
  2403. /// <summary>
  2404. /// 团组英文资料删除
  2405. /// </summary>
  2406. /// <param name="dto"></param>
  2407. /// <returns></returns>
  2408. [HttpPost]
  2409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2410. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2411. {
  2412. try
  2413. {
  2414. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2415. if (!res)
  2416. {
  2417. return Ok(JsonView(false, "删除失败"));
  2418. }
  2419. return Ok(JsonView(true, "删除成功!"));
  2420. }
  2421. catch (Exception ex)
  2422. {
  2423. return Ok(JsonView(false, "程序错误!"));
  2424. throw;
  2425. }
  2426. }
  2427. #endregion
  2428. #region 导出邀请函
  2429. /// <summary>
  2430. /// 导出邀请函页面初始化
  2431. /// </summary>
  2432. /// <param name="dto"></param>
  2433. /// <returns></returns>
  2434. [HttpPost]
  2435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2436. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2437. {
  2438. try
  2439. {
  2440. List<Grp_DelegationInfo> grp_Delegations = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToListAsync();
  2441. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2442. if (dto.DiId == 0)
  2443. {
  2444. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2445. }
  2446. else
  2447. {
  2448. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2449. }
  2450. return Ok(JsonView(true, "查询成功!", new
  2451. {
  2452. deleClient = crm_Deles,
  2453. delegations = grp_Delegations
  2454. }));
  2455. }
  2456. catch (Exception ex)
  2457. {
  2458. return Ok(JsonView(false, "程序错误!"));
  2459. throw;
  2460. }
  2461. }
  2462. /// <summary>
  2463. /// 导出邀请函
  2464. /// </summary>
  2465. /// <param name="dto"></param>
  2466. /// <returns></returns>
  2467. [HttpPost]
  2468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2469. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2470. {
  2471. try
  2472. {
  2473. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2474. List<Crm_DeleClient> crm_DeleClients = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2475. List<string> texts = new List<string>();
  2476. if (crm_DeleClients.Count != 0)
  2477. {
  2478. foreach (Crm_DeleClient item in crm_DeleClients)
  2479. {
  2480. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2481. {
  2482. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2483. }
  2484. else
  2485. {
  2486. string name = item.LastName + item.FirstName;
  2487. texts.Add(name);
  2488. }
  2489. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  2490. {
  2491. if (!transDic.ContainsKey(item.Job))
  2492. {
  2493. texts.Add(item.Job);
  2494. }
  2495. }
  2496. if (item.CrmCompanyId != 0)
  2497. {
  2498. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == item.CrmCompanyId && a.IsDel == 0);
  2499. if (!transDic.ContainsKey(crm_Customer.CompanyName))
  2500. {
  2501. texts.Add(crm_Customer.CompanyName);
  2502. }
  2503. }
  2504. }
  2505. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2506. if (transData.Count > 0)
  2507. {
  2508. foreach (TranslateResult item in transData)
  2509. {
  2510. if (!transDic.ContainsKey(item.Query))
  2511. {
  2512. transDic.Add(item.Query, item.Translation);
  2513. }
  2514. }
  2515. }
  2516. List<guestList> list = new List<guestList>();
  2517. foreach (Crm_DeleClient dele in crm_DeleClients)
  2518. {
  2519. guestList guestList = new guestList();
  2520. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  2521. {
  2522. guestList.Name = dele.Pinyin;
  2523. }
  2524. else
  2525. {
  2526. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  2527. guestList.Name = Name;
  2528. }
  2529. if (dele.Sex == 0)
  2530. {
  2531. guestList.Sex = "Male";
  2532. }
  2533. else if (dele.Sex == 1)
  2534. {
  2535. guestList.Sex = "Female";
  2536. }
  2537. guestList.DOB = dele.BirthDay.Replace('-', '.');
  2538. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == dele.CrmCompanyId && a.IsDel == 0);
  2539. string jobName = transDic.Where(s => s.Key == crm_Customer.CompanyName).FirstOrDefault().Value + " " + transDic.Where(s => s.Key == dele.Job).FirstOrDefault().Value;
  2540. guestList.Job = jobName;
  2541. list.Add(guestList);
  2542. }
  2543. //载入模板
  2544. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  2545. DocumentBuilder builder = new DocumentBuilder(doc);
  2546. //获取word里所有表格
  2547. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2548. //获取所填表格的序数
  2549. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2550. var rowStart = tableOne.Rows[0]; //获取第1行
  2551. //循环赋值
  2552. for (int i = 0; i < list.Count; i++)
  2553. {
  2554. builder.MoveToCell(0, i + 1, 0, 0);
  2555. builder.Write(list[i].Name.ToString());
  2556. builder.MoveToCell(0, i + 1, 1, 0);
  2557. builder.Write(list[i].Sex.ToString());
  2558. builder.MoveToCell(0, i + 1, 2, 0);
  2559. builder.Write(list[i].DOB.ToString());
  2560. builder.MoveToCell(0, i + 1, 3, 0);
  2561. builder.Write(list[i].Job.ToString());
  2562. }
  2563. //删除多余行
  2564. while (tableOne.Rows.Count > list.Count + 1)
  2565. {
  2566. tableOne.Rows.RemoveAt(list.Count + 1);
  2567. }
  2568. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2569. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  2570. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  2571. doc.Save(filePath);
  2572. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件" + fileName;
  2573. return Ok(JsonView(true, "成功!", Url));
  2574. }
  2575. else
  2576. {
  2577. return Ok(JsonView(false, "失败,该团组没有客户名单!"));
  2578. }
  2579. }
  2580. catch (Exception ex)
  2581. {
  2582. return Ok(JsonView(false, "程序错误!"));
  2583. throw;
  2584. }
  2585. }
  2586. #endregion
  2587. #region 团组经理模块 出入境费用
  2588. ///// <summary>
  2589. ///// 团组模块 - 出入境费用
  2590. ///// </summary>
  2591. ///// <returns></returns>
  2592. //[HttpPost]
  2593. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2594. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  2595. //{
  2596. // try
  2597. // {
  2598. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  2599. // if (data.Code != 0)
  2600. // {
  2601. // return Ok(JsonView(false, data.Msg));
  2602. // }
  2603. // return Ok(JsonView(true, "查询成功!"));
  2604. // }
  2605. // catch (Exception ex)
  2606. // {
  2607. // return Ok(JsonView(false, ex.Message));
  2608. // throw;
  2609. // }
  2610. //}
  2611. /// <summary>
  2612. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  2613. /// </summary>
  2614. /// <returns></returns>
  2615. [HttpPost]
  2616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2617. public async Task<IActionResult> SetDayAndCostAreaChange()
  2618. {
  2619. try
  2620. {
  2621. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  2622. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  2623. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  2624. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  2625. foreach (var item in unite) //处理交集数据
  2626. {
  2627. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  2628. }
  2629. foreach (var item in merge) //处理差集数据
  2630. {
  2631. int nationalTravelFeeId = 0;
  2632. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  2633. if (cityData != null) nationalTravelFeeId = cityData.Id;
  2634. else
  2635. {
  2636. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  2637. if (countryData != null) nationalTravelFeeId = countryData.Id;
  2638. }
  2639. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  2640. }
  2641. //只更新dayAndCost 的 nationalTravelFeeId;
  2642. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  2643. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  2644. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  2645. }
  2646. catch (Exception ex)
  2647. {
  2648. return Ok(JsonView(false, ex.Message));
  2649. throw;
  2650. }
  2651. }
  2652. /// <summary>
  2653. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  2654. /// </summary>
  2655. /// <returns></returns>
  2656. [HttpPost]
  2657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2658. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  2659. {
  2660. try
  2661. {
  2662. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  2663. string currencySql = string.Format("Select * From Sys_SetData Where STid = 66 And IsDel = 0");
  2664. var currencyData = await _sqlSugar.SqlQueryable<SetDataInfoView>(currencySql).ToListAsync();
  2665. //string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2666. // Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2667. // Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2668. // Where gntf.Isdel = 0");
  2669. //var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2670. return Ok(JsonView(true, "查询成功!", new
  2671. {
  2672. GroupNameData = groupNameData.Data,
  2673. CurrencyData = currencyData,
  2674. //NationalTravelFeeData = nationalTravelFeeData
  2675. }));
  2676. }
  2677. catch (Exception ex)
  2678. {
  2679. return Ok(JsonView(false, ex.Message));
  2680. throw;
  2681. }
  2682. }
  2683. /// <summary>
  2684. /// 团组模块 - 出入境费用 - Info
  2685. /// </summary>
  2686. /// <returns></returns>
  2687. [HttpPost]
  2688. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2689. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  2690. {
  2691. try
  2692. {
  2693. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  2694. if (data.Code != 0)
  2695. {
  2696. return Ok(JsonView(false, data.Msg));
  2697. }
  2698. return Ok(JsonView(true, "查询成功!", data.Data));
  2699. }
  2700. catch (Exception ex)
  2701. {
  2702. return Ok(JsonView(false, ex.Message));
  2703. }
  2704. }
  2705. /// <summary>
  2706. /// 团组模块 - 出入境费用 - Add And Update
  2707. /// </summary>
  2708. /// <returns></returns>
  2709. [HttpPost]
  2710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2711. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  2712. {
  2713. try
  2714. {
  2715. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2716. if (data.Code != 0)
  2717. {
  2718. return Ok(JsonView(false, data.Msg));
  2719. }
  2720. return Ok(JsonView(true, data.Msg, data.Data));
  2721. }
  2722. catch (Exception ex)
  2723. {
  2724. return Ok(JsonView(false, ex.Message));
  2725. }
  2726. }
  2727. /// <summary>
  2728. /// 团组模块 - 出入境费用 - 明细表导出
  2729. /// </summary>
  2730. /// <returns></returns>
  2731. [HttpPost]
  2732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2733. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  2734. {
  2735. try
  2736. {
  2737. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2738. if (data.Code != 0)
  2739. {
  2740. return Ok(JsonView(false, data.Msg));
  2741. }
  2742. return Ok(JsonView(true, data.Msg, data.Data));
  2743. }
  2744. catch (Exception ex)
  2745. {
  2746. return Ok(JsonView(false, ex.Message));
  2747. }
  2748. }
  2749. /// <summary>
  2750. /// 团组模块 - 出入境费用 - 子项删除
  2751. /// </summary>
  2752. /// <returns></returns>
  2753. [HttpPost]
  2754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2755. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  2756. {
  2757. try
  2758. {
  2759. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  2760. if (data.Code != 0)
  2761. {
  2762. return Ok(JsonView(false, data.Msg));
  2763. }
  2764. return Ok(JsonView(true, "操作成功!", data.Data));
  2765. }
  2766. catch (Exception ex)
  2767. {
  2768. return Ok(JsonView(false, ex.Message));
  2769. }
  2770. }
  2771. /// <summary>
  2772. /// 团组模块 - 出入境国家费用标准 List
  2773. /// </summary>
  2774. /// <returns></returns>
  2775. [HttpPost]
  2776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2777. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  2778. {
  2779. try
  2780. {
  2781. Stopwatch sw = new Stopwatch();
  2782. sw.Start();
  2783. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2784. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2785. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2786. Where gntf.Isdel = 0");
  2787. var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2788. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  2789. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  2790. //foreach (var item in nationalTravel)
  2791. //{
  2792. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  2793. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  2794. // if (otherData != null)
  2795. // {
  2796. // cityData.Remove(otherData);
  2797. // cityData.Add(otherData);
  2798. // }
  2799. // nationalTravelFeeData1.Add(new
  2800. // {
  2801. // Country = item.Country,
  2802. // CityData = cityData
  2803. // });
  2804. //}
  2805. sw.Stop();
  2806. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  2807. }
  2808. catch (Exception ex)
  2809. {
  2810. return Ok(JsonView(false, ex.Message));
  2811. throw;
  2812. }
  2813. }
  2814. /// <summary>
  2815. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  2816. /// </summary>
  2817. /// <returns></returns>
  2818. [HttpPost]
  2819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2820. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  2821. {
  2822. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  2823. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  2824. List<string> countryData = new List<string>();
  2825. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  2826. countryData = countryData.Distinct().ToList();
  2827. List<dynamic> dataSource = new List<dynamic>();
  2828. foreach (var item in countryData)
  2829. {
  2830. List<string> cityData1 = new List<string>();
  2831. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  2832. var countryData2 = new
  2833. {
  2834. CountryName = item,
  2835. CityData = cityData1
  2836. };
  2837. dataSource.Add(countryData2);
  2838. }
  2839. return Ok(JsonView(true, "查询成功!", dataSource));
  2840. }
  2841. /// <summary>
  2842. /// 团组模块 - 出入境国家费用标准 Page List
  2843. /// </summary>
  2844. /// <returns></returns>
  2845. [HttpPost]
  2846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2847. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  2848. {
  2849. int portId = dto.PortType;
  2850. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2851. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  2852. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  2853. string whereSql = string.Empty;
  2854. if (!string.IsNullOrEmpty(dto.Country))
  2855. {
  2856. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  2857. }
  2858. if (!string.IsNullOrEmpty(dto.City))
  2859. {
  2860. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  2861. }
  2862. string pageSql = string.Format(@"Select * From (
  2863. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  2864. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  2865. From Grp_NationalTravelFee gntf
  2866. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2867. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2868. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  2869. RefAsync<int> total = 0;
  2870. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  2871. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  2872. }
  2873. /// <summary>
  2874. /// 团组模块 - 出入境国家费用标准 根据城市查询
  2875. /// </summary>
  2876. /// <returns></returns>
  2877. [HttpPost]
  2878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2879. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  2880. {
  2881. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  2882. int portId = dto.PortType;
  2883. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2884. string whereSql = string.Empty;
  2885. if (!string.IsNullOrEmpty(dto.Country))
  2886. {
  2887. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  2888. }
  2889. if (!string.IsNullOrEmpty(dto.City))
  2890. {
  2891. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  2892. }
  2893. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  2894. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  2895. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  2896. From Grp_NationalTravelFee gntf
  2897. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2898. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2899. Where gntf.Isdel = 0 {0} ", whereSql);
  2900. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  2901. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  2902. }
  2903. /// <summary>
  2904. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  2905. /// </summary>
  2906. /// <returns></returns>
  2907. [HttpPost]
  2908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2909. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  2910. {
  2911. try
  2912. {
  2913. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  2914. if (data.Code != 0)
  2915. {
  2916. return Ok(JsonView(false, data.Msg));
  2917. }
  2918. return Ok(JsonView(true, "操作成功!", data.Data));
  2919. }
  2920. catch (Exception ex)
  2921. {
  2922. return Ok(JsonView(false, ex.Message));
  2923. }
  2924. }
  2925. /// <summary>
  2926. /// 团组模块 - 出入境国家费用标准 - Del
  2927. /// </summary>
  2928. /// <returns></returns>
  2929. [HttpPost]
  2930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2931. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  2932. {
  2933. try
  2934. {
  2935. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  2936. {
  2937. Id = dto.Id,
  2938. DeleteUserId = dto.DeleteUserId,
  2939. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  2940. IsDel = 1
  2941. };
  2942. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  2943. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  2944. .WhereColumns(it => new { it.Id })
  2945. .ExecuteCommandAsync();
  2946. if (delStatus <= 0)
  2947. {
  2948. return Ok(JsonView(false, "删除失败!"));
  2949. }
  2950. return Ok(JsonView(true, "操作成功!"));
  2951. }
  2952. catch (Exception ex)
  2953. {
  2954. return Ok(JsonView(false, ex.Message));
  2955. }
  2956. }
  2957. #endregion
  2958. #region 签证费用录入
  2959. /// <summary>
  2960. /// 根据diid查询签证费用列表
  2961. /// </summary>
  2962. /// <param name="dto"></param>
  2963. /// <returns></returns>
  2964. [HttpPost]
  2965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2966. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  2967. {
  2968. try
  2969. {
  2970. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  2971. if (groupData.Code != 0)
  2972. {
  2973. return Ok(JsonView(false, groupData.Msg));
  2974. }
  2975. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2976. }
  2977. catch (Exception ex)
  2978. {
  2979. return Ok(JsonView(false, ex.Message));
  2980. }
  2981. }
  2982. /// <summary>
  2983. /// 根据签证费用Id查询单条数据及c表数据
  2984. /// </summary>
  2985. /// <param name="dto"></param>
  2986. /// <returns></returns>
  2987. [HttpPost]
  2988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2989. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  2990. {
  2991. try
  2992. {
  2993. Result groupData = await _visaPriceRep.PostVisaById(dto);
  2994. if (groupData.Code != 0)
  2995. {
  2996. return Ok(JsonView(false, groupData.Msg));
  2997. }
  2998. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2999. }
  3000. catch (Exception ex)
  3001. {
  3002. return Ok(JsonView(false, ex.Message));
  3003. }
  3004. }
  3005. /// <summary>
  3006. /// 签证费用删除
  3007. /// </summary>
  3008. /// <param name="dto"></param>
  3009. /// <returns></returns>
  3010. [HttpPost]
  3011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3012. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  3013. {
  3014. try
  3015. {
  3016. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  3017. if (!res)
  3018. {
  3019. return Ok(JsonView(false, "删除失败"));
  3020. }
  3021. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
  3022. {
  3023. IsDel = 1,
  3024. DeleteUserId = dto.DeleteUserId,
  3025. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3026. }).ExecuteCommandAsync();
  3027. return Ok(JsonView(true, "删除成功!"));
  3028. }
  3029. catch (Exception ex)
  3030. {
  3031. return Ok(JsonView(false, "程序错误!"));
  3032. throw;
  3033. }
  3034. }
  3035. /// <summary>
  3036. /// 签证费用录入下拉框初始化
  3037. /// </summary>
  3038. /// <returns></returns>
  3039. [HttpPost]
  3040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3041. public async Task<IActionResult> VisaPriceAddSelect()
  3042. {
  3043. try
  3044. {
  3045. //支付方式
  3046. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  3047. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  3048. //币种
  3049. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  3050. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  3051. //乘客类型
  3052. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  3053. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  3054. //卡类型
  3055. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  3056. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  3057. var data = new
  3058. {
  3059. Payment = _Payment,
  3060. CurrencyList = _CurrencyList,
  3061. PassengerType = _PassengerType,
  3062. BankCard = _BankCard
  3063. };
  3064. return Ok(JsonView(true, "查询成功!", data));
  3065. }
  3066. catch (Exception ex)
  3067. {
  3068. return Ok(JsonView(false, "程序错误!"));
  3069. throw;
  3070. }
  3071. }
  3072. /// <summary>
  3073. /// 签证费用录入操作(Status:1.新增,2.修改)
  3074. /// </summary>
  3075. /// <param name="dto"></param>
  3076. /// <returns></returns>
  3077. [HttpPost]
  3078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3079. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  3080. {
  3081. try
  3082. {
  3083. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  3084. if (groupData.Code != 0)
  3085. {
  3086. return Ok(JsonView(false, groupData.Msg));
  3087. }
  3088. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3089. }
  3090. catch (Exception ex)
  3091. {
  3092. return Ok(JsonView(false, ex.Message));
  3093. }
  3094. }
  3095. #endregion
  3096. #region op费用录入
  3097. /// <summary>
  3098. /// 根据diid查询op费用列表
  3099. /// </summary>
  3100. /// <param name="dto"></param>
  3101. /// <returns></returns>
  3102. [HttpPost]
  3103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3104. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  3105. {
  3106. try
  3107. {
  3108. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  3109. if (groupData.Code != 0)
  3110. {
  3111. return Ok(JsonView(false, groupData.Msg));
  3112. }
  3113. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3114. }
  3115. catch (Exception ex)
  3116. {
  3117. return Ok(JsonView(false, ex.Message));
  3118. }
  3119. }
  3120. /// <summary>
  3121. /// 根据op费用Id查询单条数据及c表数据
  3122. /// </summary>
  3123. /// <param name="dto"></param>
  3124. /// <returns></returns>
  3125. [HttpPost]
  3126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3127. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  3128. {
  3129. try
  3130. {
  3131. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  3132. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  3133. var data = new
  3134. {
  3135. CarTouristGuideGround = _groupData,
  3136. CreditCardPayment = _creditCardPayment
  3137. };
  3138. return Ok(JsonView(true, "查询成功!", data));
  3139. }
  3140. catch (Exception ex)
  3141. {
  3142. return Ok(JsonView(false, "程序错误!"));
  3143. }
  3144. }
  3145. /// <summary>
  3146. /// op费用删除
  3147. /// </summary>
  3148. /// <param name="dto"></param>
  3149. /// <returns></returns>
  3150. [HttpPost]
  3151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3152. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  3153. {
  3154. try
  3155. {
  3156. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3157. if (!res)
  3158. {
  3159. return Ok(JsonView(false, "删除失败"));
  3160. }
  3161. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  3162. {
  3163. IsDel = 1,
  3164. DeleteUserId = dto.DeleteUserId,
  3165. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3166. }).ExecuteCommandAsync();
  3167. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  3168. {
  3169. IsDel = 1,
  3170. DeleteUserId = dto.DeleteUserId,
  3171. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3172. }).ExecuteCommandAsync();
  3173. return Ok(JsonView(true, "删除成功!"));
  3174. }
  3175. catch (Exception ex)
  3176. {
  3177. return Ok(JsonView(false, "程序错误!"));
  3178. throw;
  3179. }
  3180. }
  3181. /// <summary>
  3182. /// op费用录入操作(Status:1.新增,2.修改)
  3183. /// </summary>
  3184. /// <param name="dto"></param>
  3185. /// <returns></returns>
  3186. [HttpPost]
  3187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3188. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  3189. {
  3190. try
  3191. {
  3192. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  3193. if (groupData.Code != 0)
  3194. {
  3195. return Ok(JsonView(false, groupData.Msg));
  3196. }
  3197. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3198. }
  3199. catch (Exception ex)
  3200. {
  3201. return Ok(JsonView(false, ex.Message));
  3202. }
  3203. }
  3204. /// <summary>
  3205. /// 填写费用详细页面初始化绑定
  3206. /// </summary>
  3207. /// <param name="dto"></param>
  3208. /// <returns></returns>
  3209. [HttpPost]
  3210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3211. public async Task<IActionResult> CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  3212. {
  3213. try
  3214. {
  3215. Result groupData = await _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  3216. if (groupData.Code != 0)
  3217. {
  3218. return Ok(JsonView(false, groupData.Msg));
  3219. }
  3220. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3221. }
  3222. catch (Exception ex)
  3223. {
  3224. return Ok(JsonView(false, ex.Message));
  3225. }
  3226. }
  3227. /// <summary>
  3228. /// 根据op费用Id查询详细数据
  3229. /// </summary>
  3230. /// <param name="dto"></param>
  3231. /// <returns></returns>
  3232. [HttpPost]
  3233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3234. public async Task<IActionResult> OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  3235. {
  3236. try
  3237. {
  3238. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  3239. if (groupData.Code != 0)
  3240. {
  3241. return Ok(JsonView(false, groupData.Msg));
  3242. }
  3243. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3244. }
  3245. catch (Exception ex)
  3246. {
  3247. return Ok(JsonView(false, ex.Message));
  3248. }
  3249. }
  3250. /// <summary>
  3251. /// OP费用录入填写详情
  3252. /// </summary>
  3253. /// <param name="dto"></param>
  3254. /// <returns></returns>
  3255. [HttpPost]
  3256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3257. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  3258. {
  3259. try
  3260. {
  3261. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  3262. if (groupData.Code != 0)
  3263. {
  3264. return Ok(JsonView(false, groupData.Msg));
  3265. }
  3266. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3267. }
  3268. catch (Exception ex)
  3269. {
  3270. return Ok(JsonView(false, ex.Message));
  3271. }
  3272. }
  3273. #endregion
  3274. #region 团组成本
  3275. /// <summary>
  3276. /// 团组成本数据初始化
  3277. /// </summary>
  3278. /// <param name="dto"></param>
  3279. /// <returns></returns>
  3280. [HttpPost]
  3281. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  3282. {
  3283. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  3284. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  3285. WHEN COUNT(*) >= 0 THEN 'True'
  3286. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  3287. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  3288. ").ToList(); //团组列表
  3289. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  3290. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  3291. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  3292. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  3293. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  3294. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  3295. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  3296. //GroupCostParameter.Add(new
  3297. // Grp_GroupCostParameter());
  3298. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  3299. return Ok(JsonView(new
  3300. {
  3301. groupList,
  3302. groupInfo,
  3303. groupChecks,
  3304. groupCost = groupCostMap,
  3305. hotelNumber,
  3306. GroupCostParameter = GroupCostParameterMap,
  3307. }));
  3308. }
  3309. /// <summary>
  3310. /// 团组成本信息保存
  3311. /// </summary>
  3312. /// <param name="dto"></param>
  3313. /// <returns></returns>
  3314. [HttpPost]
  3315. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  3316. {
  3317. JsonView jw = null;
  3318. bool isTrue = false;
  3319. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  3320. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  3321. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  3322. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  3323. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  3324. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  3325. try
  3326. {
  3327. _sqlSugar.BeginTran();
  3328. isTrue = await _GroupCostRepository.
  3329. SaveGroupCostList(Grp_groups, dto.Diid); //列表
  3330. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  3331. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  3332. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  3333. _sqlSugar.CommitTran();
  3334. jw = JsonView(true, "保存成功!", isTrue);
  3335. }
  3336. catch (Exception)
  3337. {
  3338. _sqlSugar.RollbackTran();
  3339. jw = JsonView(false);
  3340. }
  3341. return Ok(jw);
  3342. }
  3343. /// <summary>
  3344. /// 司兼导数据
  3345. /// </summary>
  3346. /// <param name="dto"></param>
  3347. /// <returns></returns>
  3348. [HttpPost]
  3349. public IActionResult GetCarGuides(CarGuidesDto dto)
  3350. {
  3351. JsonView jw = null;
  3352. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  3353. jw = JsonView(true, "获取成功!", Data);
  3354. return Ok(jw);
  3355. }
  3356. /// <summary>
  3357. /// 导游数据
  3358. /// </summary>
  3359. /// <param name="dto"></param>
  3360. /// <returns></returns>
  3361. [HttpPost]
  3362. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  3363. {
  3364. JsonView jw = null;
  3365. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  3366. // 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
  3367. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  3368. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  3369. jw = JsonView(true, "获取成功!", Data);
  3370. return Ok(jw);
  3371. }
  3372. /// <summary>
  3373. /// 成本车数据
  3374. /// </summary>
  3375. /// <param name="dto"></param>
  3376. /// <returns></returns>
  3377. [HttpPost]
  3378. public IActionResult GetCarInfo(CarGuidesDto dto)
  3379. {
  3380. JsonView jw = null;
  3381. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  3382. jw = JsonView(true, "获取成功!", Data);
  3383. return Ok(jw);
  3384. }
  3385. /// <summary>
  3386. /// 景点数据
  3387. /// </summary>
  3388. /// <param name="dto"></param>
  3389. /// <returns></returns>
  3390. [HttpPost]
  3391. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  3392. {
  3393. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  3394. return Ok(JsonView(true, "获取成功!", Data));
  3395. }
  3396. #endregion
  3397. #region 酒店预定
  3398. /// <summary>
  3399. /// 酒店预订页面初始化绑定
  3400. /// </summary>
  3401. /// <param name="dto"></param>
  3402. /// <returns></returns>
  3403. [HttpPost]
  3404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3405. public async Task<IActionResult> HotelReservationsInitialize(HotelReservationsDto dto)
  3406. {
  3407. try
  3408. {
  3409. Result groupData = await _hotelPriceRep.HotelReservationsInitialize(dto);
  3410. if (groupData.Code != 0)
  3411. {
  3412. return Ok(JsonView(false, groupData.Msg));
  3413. }
  3414. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3415. }
  3416. catch (Exception ex)
  3417. {
  3418. return Ok(JsonView(false, ex.Message));
  3419. }
  3420. }
  3421. /// <summary>
  3422. /// 根据团组Id查询酒店费用列表
  3423. /// </summary>
  3424. /// <param name="dto"></param>
  3425. /// <returns></returns>
  3426. [HttpPost]
  3427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3428. public async Task<IActionResult> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
  3429. {
  3430. try
  3431. {
  3432. Result groupData = await _hotelPriceRep.HotelReservationsByDiId(dto);
  3433. if (groupData.Code != 0)
  3434. {
  3435. return Ok(JsonView(false, groupData.Msg));
  3436. }
  3437. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3438. }
  3439. catch (Exception ex)
  3440. {
  3441. return Ok(JsonView(false, ex.Message));
  3442. }
  3443. }
  3444. /// <summary>
  3445. /// 根据酒店费用Id查询酒店费用详细
  3446. /// </summary>
  3447. /// <param name="dto"></param>
  3448. /// <returns></returns>
  3449. [HttpPost]
  3450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3451. public async Task<IActionResult> HotelReservationsById(HotelReservationsByIdDto dto)
  3452. {
  3453. try
  3454. {
  3455. Result groupData = await _hotelPriceRep.HotelReservationsById(dto);
  3456. if (groupData.Code != 0)
  3457. {
  3458. return Ok(JsonView(false, groupData.Msg));
  3459. }
  3460. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3461. }
  3462. catch (Exception ex)
  3463. {
  3464. return Ok(JsonView(false, ex.Message));
  3465. }
  3466. }
  3467. /// <summary>
  3468. /// 计算酒店付款总金额
  3469. /// </summary>
  3470. /// <param name="dto"></param>
  3471. /// <returns></returns>
  3472. [HttpPost]
  3473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3474. public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
  3475. {
  3476. try
  3477. {
  3478. Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
  3479. if (groupData.Code != 0)
  3480. {
  3481. return Ok(JsonView(false, groupData.Msg));
  3482. }
  3483. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3484. }
  3485. catch (Exception ex)
  3486. {
  3487. return Ok(JsonView(false, ex.Message));
  3488. }
  3489. }
  3490. /// <summary>
  3491. /// 酒店费用操作(Status:1.新增,2.修改)
  3492. /// </summary>
  3493. /// <param name="dto"></param>
  3494. /// <returns></returns>
  3495. [HttpPost]
  3496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3497. public async Task<IActionResult> OpHotelReservations(OpHotelReservationsData dto)
  3498. {
  3499. try
  3500. {
  3501. Result groupData = await _hotelPriceRep.OpHotelReservations(dto);
  3502. if (groupData.Code != 0)
  3503. {
  3504. return Ok(JsonView(false, groupData.Msg));
  3505. }
  3506. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3507. }
  3508. catch (Exception ex)
  3509. {
  3510. return Ok(JsonView(false, ex.Message));
  3511. }
  3512. }
  3513. /// <summary>
  3514. /// 文件上传
  3515. /// </summary>
  3516. /// <param name="file"></param>
  3517. /// <returns></returns>
  3518. [HttpPost]
  3519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3520. public async Task<IActionResult> UploadHotel(IFormFile file)
  3521. {
  3522. try
  3523. {
  3524. if (file != null)
  3525. {
  3526. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3527. //文件名称
  3528. string projectFileName = file.FileName;
  3529. //上传的文件的路径
  3530. string filePath = "";
  3531. if (!Directory.Exists(fileDir))
  3532. {
  3533. Directory.CreateDirectory(fileDir);
  3534. }
  3535. //上传的文件的路径
  3536. filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
  3537. using (FileStream fs = System.IO.File.Create(filePath))
  3538. {
  3539. file.CopyTo(fs);
  3540. fs.Flush();
  3541. }
  3542. return Ok(JsonView(true, "上传成功!", projectFileName));
  3543. }
  3544. else
  3545. {
  3546. return Ok(JsonView(false, "上传失败!"));
  3547. }
  3548. }
  3549. catch (Exception ex)
  3550. {
  3551. return Ok(JsonView(false, "程序错误!"));
  3552. throw;
  3553. }
  3554. }
  3555. /// <summary>
  3556. /// 删除指定文件
  3557. /// </summary>
  3558. /// <param name="dto"></param>
  3559. /// <returns></returns>
  3560. [HttpPost]
  3561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3562. public async Task<IActionResult> DelFileHotel(DelFileDto dto)
  3563. {
  3564. try
  3565. {
  3566. string filePath = "";
  3567. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3568. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3569. //int id = 0;
  3570. filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
  3571. // 删除该文件
  3572. try
  3573. {
  3574. System.IO.File.Delete(filePath);
  3575. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3576. {
  3577. Attachment = "",
  3578. }).ExecuteCommandAsync();
  3579. if (result != 0)
  3580. {
  3581. return Ok(JsonView(true, "成功!"));
  3582. }
  3583. else
  3584. {
  3585. return Ok(JsonView(false, "失败!"));
  3586. }
  3587. }
  3588. catch (Exception)
  3589. {
  3590. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3591. {
  3592. Attachment = "",
  3593. }).ExecuteCommandAsync();
  3594. if (result != 0)
  3595. {
  3596. return Ok(JsonView(true, "成功!"));
  3597. }
  3598. else
  3599. {
  3600. return Ok(JsonView(false, "失败!"));
  3601. }
  3602. throw;
  3603. }
  3604. }
  3605. catch (Exception ex)
  3606. {
  3607. return Ok(JsonView(false, "程序错误!"));
  3608. throw;
  3609. }
  3610. }
  3611. /// <summary>
  3612. /// 生成VOUCHER
  3613. /// </summary>
  3614. /// <param name=""></param>
  3615. /// <returns></returns>
  3616. [HttpPost]
  3617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3618. public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
  3619. {
  3620. Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
  3621. //判断数据是否完整
  3622. if (h != null)
  3623. {
  3624. if (!string.IsNullOrEmpty(h.DetermineNo))
  3625. {
  3626. string strFileName = "HotelStatement/";
  3627. Grp_DelegationInfo dele = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
  3628. if (dele != null)
  3629. strFileName += dele.TourCode;
  3630. //载入模板
  3631. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  3632. Document doc = new Document(sss);
  3633. DocumentBuilder builder = new DocumentBuilder(doc);
  3634. try
  3635. {
  3636. #region 替换Word模板书签内容
  3637. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  3638. //入住卷预定号码
  3639. if (doc.Range.Bookmarks["VNO"] != null)
  3640. {
  3641. Bookmark mark = doc.Range.Bookmarks["VNO"];
  3642. mark.Text = h.CheckNumber;
  3643. }
  3644. //酒店时间
  3645. if (doc.Range.Bookmarks["Date"] != null)
  3646. {
  3647. Bookmark mark = doc.Range.Bookmarks["Date"];
  3648. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3649. }
  3650. //团号
  3651. if (doc.Range.Bookmarks["TNo"] != null)
  3652. {
  3653. Bookmark mark = doc.Range.Bookmarks["TNo"];
  3654. mark.Text = dele.TourCode;
  3655. }
  3656. //预定号码
  3657. if (doc.Range.Bookmarks["BookingId"] != null)
  3658. {
  3659. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  3660. mark.Text = h.ReservationsNo;
  3661. }
  3662. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  3663. {
  3664. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  3665. mark.Text = h.DetermineNo;
  3666. }
  3667. //酒店城市
  3668. if (doc.Range.Bookmarks["City"] != null)
  3669. {
  3670. Bookmark mark = doc.Range.Bookmarks["City"];
  3671. mark.Text = h.City;
  3672. }
  3673. //酒店名称
  3674. if (doc.Range.Bookmarks["HName"] != null)
  3675. {
  3676. Bookmark mark = doc.Range.Bookmarks["HName"];
  3677. mark.Text = h.HotelName;
  3678. }
  3679. //酒店地址
  3680. if (doc.Range.Bookmarks["Address"] != null)
  3681. {
  3682. Bookmark mark = doc.Range.Bookmarks["Address"];
  3683. mark.Text = h.HotelAddress;
  3684. }
  3685. //酒店电话
  3686. if (doc.Range.Bookmarks["Tel"] != null)
  3687. {
  3688. Bookmark mark = doc.Range.Bookmarks["Tel"];
  3689. mark.Text = h.HotelTel;
  3690. }
  3691. //酒店传真
  3692. if (doc.Range.Bookmarks["Fax"] != null)
  3693. {
  3694. Bookmark mark = doc.Range.Bookmarks["Fax"];
  3695. if (!string.IsNullOrWhiteSpace(h.HotelFax))
  3696. {
  3697. mark.Text = h.HotelFax;
  3698. }
  3699. }
  3700. //入住时间
  3701. if (doc.Range.Bookmarks["CIn"] != null)
  3702. {
  3703. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3704. Bookmark mark = doc.Range.Bookmarks["CIn"];
  3705. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  3706. }
  3707. //退房时间
  3708. if (doc.Range.Bookmarks["COut"] != null)
  3709. {
  3710. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3711. Bookmark mark = doc.Range.Bookmarks["COut"];
  3712. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3713. }
  3714. //客户名称
  3715. if (doc.Range.Bookmarks["GName"] != null)
  3716. {
  3717. Bookmark mark = doc.Range.Bookmarks["GName"];
  3718. mark.Text = h.GuestName;
  3719. }
  3720. //房间介绍
  3721. if (doc.Range.Bookmarks["ROOM"] != null)
  3722. {
  3723. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  3724. mark.Text = h.RoomExplanation;
  3725. }
  3726. //报价描述
  3727. if (doc.Range.Bookmarks["NOTE"] != null)
  3728. {
  3729. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  3730. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == h.ReservationsWebsite);
  3731. if (ss != null)
  3732. mark.Text = ss.Name;
  3733. }
  3734. //入住时间
  3735. if (doc.Range.Bookmarks["CheckIn"] != null)
  3736. {
  3737. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3738. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  3739. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  3740. }
  3741. //退房时间
  3742. if (doc.Range.Bookmarks["CheckOut"] != null)
  3743. {
  3744. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3745. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  3746. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3747. }
  3748. //日期
  3749. if (doc.Range.Bookmarks["DT"] != null)
  3750. {
  3751. Bookmark mark = doc.Range.Bookmarks["DT"];
  3752. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3753. }
  3754. //名称
  3755. if (doc.Range.Bookmarks["VName"] != null)
  3756. {
  3757. Bookmark mark = doc.Range.Bookmarks["VName"];
  3758. mark.Text = h.HotelName;
  3759. }
  3760. //号码
  3761. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  3762. {
  3763. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  3764. mark.Text = h.CheckNumber;
  3765. }
  3766. #endregion
  3767. //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  3768. strFileName += "VOUCHER.doc";
  3769. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  3770. doc.Save(fileDir);
  3771. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  3772. return Ok(JsonView(true, "成功!", Url));
  3773. //保存为doc,并打开
  3774. }
  3775. catch (Exception ex)
  3776. {
  3777. throw;
  3778. }
  3779. }
  3780. else
  3781. {
  3782. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3783. }
  3784. }
  3785. else
  3786. {
  3787. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3788. }
  3789. }
  3790. /// <summary>
  3791. /// 导出确认单
  3792. /// </summary>
  3793. /// <param name=""></param>
  3794. /// <returns></returns>
  3795. [HttpPost]
  3796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3797. public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
  3798. {
  3799. //团组信息
  3800. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
  3801. //酒店数据
  3802. List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel == 0).ToList();
  3803. //利datatable存储
  3804. DataTable dt = new DataTable();
  3805. dt.Columns.Add("CheckInDate", typeof(string));
  3806. dt.Columns.Add("City", typeof(string));
  3807. dt.Columns.Add("Hotel", typeof(string));
  3808. dt.Columns.Add("Room", typeof(string));
  3809. for (int i = 0; i < listhoteldata.Count; i++)
  3810. {
  3811. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  3812. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  3813. while (dayStart < dayEnd)
  3814. {
  3815. string temp = "";
  3816. DataRow row = dt.NewRow();
  3817. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  3818. row["City"] = listhoteldata[i].City;
  3819. row["Hotel"] = listhoteldata[i].HotelName;
  3820. if (listhoteldata[i].SingleRoomCount > 0)
  3821. {
  3822. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  3823. }
  3824. if (listhoteldata[i].DoubleRoomCount > 0)
  3825. {
  3826. temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
  3827. }
  3828. if (listhoteldata[i].SuiteRoomCount > 0)
  3829. {
  3830. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  3831. }
  3832. if (listhoteldata[i].OtherRoomCount > 0)
  3833. {
  3834. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  3835. }
  3836. row["Room"] = temp;
  3837. dt.Rows.Add(row);
  3838. dayStart = dayStart.AddDays(1);
  3839. }
  3840. }
  3841. Dictionary<string, string> dic = new Dictionary<string, string>();
  3842. dic.Add("Dele", di.TeamName);
  3843. dic.Add("City", di.VisitCountry);
  3844. //模板路径
  3845. //string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  3846. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  3847. //载入模板
  3848. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  3849. DocumentBuilder builder = new DocumentBuilder(doc);
  3850. foreach (var key in dic.Keys)
  3851. {
  3852. builder.MoveToBookmark(key);
  3853. builder.Write(dic[key]);
  3854. }
  3855. //获取word里所有表格
  3856. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3857. //获取所填表格的序数
  3858. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3859. var rowStart = tableOne.Rows[0]; //获取第1行
  3860. try
  3861. {
  3862. //循环赋值
  3863. for (int i = 0; i < dt.Rows.Count; i++)
  3864. {
  3865. builder.MoveToCell(0, i + 1, 0, 0);
  3866. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  3867. builder.MoveToCell(0, i + 1, 1, 0);
  3868. builder.Write(dt.Rows[i]["City"].ToString());
  3869. builder.MoveToCell(0, i + 1, 2, 0);
  3870. builder.Write(dt.Rows[i]["Hotel"].ToString());
  3871. builder.MoveToCell(0, i + 1, 3, 0);
  3872. builder.Write(dt.Rows[i]["Room"].ToString());
  3873. }
  3874. }
  3875. catch
  3876. {
  3877. }
  3878. //删除多余行
  3879. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  3880. {
  3881. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  3882. }
  3883. string strFileName = di.TeamName + "酒店确认单.doc";
  3884. try
  3885. {
  3886. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  3887. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  3888. return Ok(JsonView(true, "成功", Url));
  3889. }
  3890. catch (Exception)
  3891. {
  3892. return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
  3893. throw;
  3894. }
  3895. //doc.Save(HttpUtility.UrlEncode(strFileName, Encoding.UTF8), Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);
  3896. }
  3897. /// <summary>
  3898. /// 酒店费用删除
  3899. /// </summary>
  3900. /// <param name="dto"></param>
  3901. /// <returns></returns>
  3902. [HttpPost]
  3903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3904. public async Task<IActionResult> DelHotelPrice(DelBaseDto dto)
  3905. {
  3906. try
  3907. {
  3908. var res = await _hotelPriceRep.SoftDeleteByIdAsync<Grp_HotelReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3909. if (!res)
  3910. {
  3911. return Ok(JsonView(false, "删除失败"));
  3912. }
  3913. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment()
  3914. {
  3915. IsDel = 1,
  3916. DeleteUserId = dto.DeleteUserId,
  3917. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3918. }).ExecuteCommandAsync();
  3919. return Ok(JsonView(true, "删除成功!"));
  3920. }
  3921. catch (Exception ex)
  3922. {
  3923. return Ok(JsonView(false, "程序错误!"));
  3924. throw;
  3925. }
  3926. }
  3927. #endregion
  3928. #region 团组状态
  3929. /// <summary>
  3930. /// 团组状态列表 Page
  3931. /// </summary>
  3932. /// <param name="dto">团组列表请求dto</param>
  3933. /// <returns></returns>
  3934. [HttpPost]
  3935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3936. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  3937. {
  3938. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  3939. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  3940. {
  3941. string sqlWhere = string.Empty;
  3942. if (dto.IsSure == 0) //未完成
  3943. {
  3944. sqlWhere += string.Format(@" And IsSure = 0");
  3945. }
  3946. else if (dto.IsSure == 1) //已完成
  3947. {
  3948. sqlWhere += string.Format(@" And IsSure = 1");
  3949. }
  3950. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  3951. {
  3952. string tj = dto.SearchCriteria;
  3953. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  3954. tj, tj, tj, tj, tj);
  3955. }
  3956. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3957. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  3958. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3959. From (
  3960. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  3961. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  3962. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  3963. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3964. From Grp_DelegationInfo gdi
  3965. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3966. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3967. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3968. Where gdi.IsDel = 0 {0}
  3969. ) temp ", sqlWhere);
  3970. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3971. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  3972. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  3973. }
  3974. else
  3975. {
  3976. return Ok(JsonView(false, "查询失败"));
  3977. }
  3978. }
  3979. /// <summary>
  3980. /// 团组状态
  3981. /// 设置操作完成
  3982. /// </summary>
  3983. /// <param name="dto">团组列表请求dto</param>
  3984. /// <returns></returns>
  3985. [HttpPost]
  3986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3987. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  3988. {
  3989. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  3990. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  3991. {
  3992. Id = dto.Id,
  3993. IsSure = 1
  3994. };
  3995. var result = await _sqlSugar.Updateable(_DelegationInfo)
  3996. .UpdateColumns(it => new { it.IsSure })
  3997. .WhereColumns(it => new { it.Id })
  3998. .ExecuteCommandAsync();
  3999. if (result > 0)
  4000. {
  4001. return Ok(JsonView(true, "操作完成!"));
  4002. }
  4003. return Ok(JsonView(false, "操作失败!"));
  4004. }
  4005. #endregion
  4006. #region 保险费用录入
  4007. /// <summary>
  4008. /// 根据团组Id查询保险费用列表
  4009. /// </summary>
  4010. /// <param name="dto"></param>
  4011. /// <returns></returns>
  4012. [HttpPost]
  4013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4014. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  4015. {
  4016. try
  4017. {
  4018. Result groupData = await _customersRep.CustomersByDiId(dto);
  4019. if (groupData.Code != 0)
  4020. {
  4021. return Ok(JsonView(false, groupData.Msg));
  4022. }
  4023. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4024. }
  4025. catch (Exception ex)
  4026. {
  4027. return Ok(JsonView(false, ex.Message));
  4028. }
  4029. }
  4030. /// <summary>
  4031. /// 根据保险费用Id查询保险费用详细
  4032. /// </summary>
  4033. /// <param name="dto"></param>
  4034. /// <returns></returns>
  4035. [HttpPost]
  4036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4037. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  4038. {
  4039. try
  4040. {
  4041. Result groupData = await _customersRep.CustomersById(dto);
  4042. if (groupData.Code != 0)
  4043. {
  4044. return Ok(JsonView(false, groupData.Msg));
  4045. }
  4046. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4047. }
  4048. catch (Exception ex)
  4049. {
  4050. return Ok(JsonView(false, ex.Message));
  4051. }
  4052. }
  4053. /// <summary>
  4054. /// 酒店预订页面初始化绑定
  4055. /// </summary>
  4056. /// <param name="dto"></param>
  4057. /// <returns></returns>
  4058. [HttpPost]
  4059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4060. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  4061. {
  4062. try
  4063. {
  4064. Result groupData = await _customersRep.CustomersInitialize(dto);
  4065. if (groupData.Code != 0)
  4066. {
  4067. return Ok(JsonView(false, groupData.Msg));
  4068. }
  4069. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4070. }
  4071. catch (Exception ex)
  4072. {
  4073. return Ok(JsonView(false, ex.Message));
  4074. }
  4075. }
  4076. /// <summary>
  4077. /// 保险费用操作(Status:1.新增,2.修改)
  4078. /// </summary>
  4079. /// <param name="dto"></param>
  4080. /// <returns></returns>
  4081. [HttpPost]
  4082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4083. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  4084. {
  4085. try
  4086. {
  4087. Result groupData = await _customersRep.OpCustomers(dto);
  4088. if (groupData.Code != 0)
  4089. {
  4090. return Ok(JsonView(false, groupData.Msg));
  4091. }
  4092. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4093. }
  4094. catch (Exception ex)
  4095. {
  4096. return Ok(JsonView(false, ex.Message));
  4097. }
  4098. }
  4099. /// <summary>
  4100. /// 文件上传
  4101. /// </summary>
  4102. /// <param name="file"></param>
  4103. /// <returns></returns>
  4104. [HttpPost]
  4105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4106. public async Task<IActionResult> UploadCus(IFormFile file)
  4107. {
  4108. try
  4109. {
  4110. if (file != null)
  4111. {
  4112. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4113. //文件名称
  4114. string projectFileName = file.FileName;
  4115. //上传的文件的路径
  4116. string filePath = "";
  4117. if (!Directory.Exists(fileDir))
  4118. {
  4119. Directory.CreateDirectory(fileDir);
  4120. }
  4121. //上传的文件的路径
  4122. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  4123. using (FileStream fs = System.IO.File.Create(filePath))
  4124. {
  4125. file.CopyTo(fs);
  4126. fs.Flush();
  4127. }
  4128. return Ok(JsonView(true, "上传成功!", projectFileName));
  4129. }
  4130. else
  4131. {
  4132. return Ok(JsonView(false, "上传失败!"));
  4133. }
  4134. }
  4135. catch (Exception ex)
  4136. {
  4137. return Ok(JsonView(false, "程序错误!"));
  4138. throw;
  4139. }
  4140. }
  4141. /// <summary>
  4142. /// 删除指定文件
  4143. /// </summary>
  4144. /// <param name="dto"></param>
  4145. /// <returns></returns>
  4146. [HttpPost]
  4147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4148. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  4149. {
  4150. try
  4151. {
  4152. string filePath = "";
  4153. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4154. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4155. //int id = 0;
  4156. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  4157. // 删除该文件
  4158. try
  4159. {
  4160. System.IO.File.Delete(filePath);
  4161. var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
  4162. {
  4163. Attachment = "",
  4164. }).ExecuteCommandAsync();
  4165. if (result != 0)
  4166. {
  4167. return Ok(JsonView(true, "成功!"));
  4168. }
  4169. else
  4170. {
  4171. return Ok(JsonView(false, "失败!"));
  4172. }
  4173. }
  4174. catch (Exception)
  4175. {
  4176. var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
  4177. {
  4178. Attachment = "",
  4179. }).ExecuteCommandAsync();
  4180. if (result != 0)
  4181. {
  4182. return Ok(JsonView(true, "成功!"));
  4183. }
  4184. else
  4185. {
  4186. return Ok(JsonView(false, "失败!"));
  4187. }
  4188. }
  4189. }
  4190. catch (Exception ex)
  4191. {
  4192. return Ok(JsonView(false, "程序错误!"));
  4193. throw;
  4194. }
  4195. }
  4196. /// <summary>
  4197. /// 保险费用操作(删除)
  4198. /// </summary>
  4199. /// <param name="dto"></param>
  4200. /// <returns></returns>
  4201. [HttpPost]
  4202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4203. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  4204. {
  4205. try
  4206. {
  4207. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  4208. if (!res)
  4209. {
  4210. return Ok(JsonView(false, "删除失败"));
  4211. }
  4212. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  4213. {
  4214. IsDel = 1,
  4215. DeleteUserId = dto.DeleteUserId,
  4216. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4217. }).ExecuteCommandAsync();
  4218. return Ok(JsonView(true, "删除成功!"));
  4219. }
  4220. catch (Exception ex)
  4221. {
  4222. return Ok(JsonView(false, "程序错误!"));
  4223. throw;
  4224. }
  4225. }
  4226. #endregion
  4227. }
  4228. }