GroupsController.cs 189 KB

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