GroupsController.cs 189 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532
  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. decimal auditedFunds = strs.Sum(it => it.AuditedFunds);
  1010. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1011. //单独处理此次付款金额
  1012. if (item.CurrencyId == 836) //人名币
  1013. {
  1014. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1015. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1016. }
  1017. else
  1018. {
  1019. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|","0.00", item.CurrencyName);
  1020. }
  1021. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1022. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1023. }
  1024. }
  1025. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1026. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1027. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1028. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1029. var _view1 = new
  1030. {
  1031. PageFuncAuth = pageFunAuthView,
  1032. Data = _view
  1033. };
  1034. return Ok(JsonView(_view1));
  1035. }
  1036. catch (Exception ex)
  1037. {
  1038. return Ok(JsonView(false, ex.Message));
  1039. }
  1040. }
  1041. /// <summary>
  1042. /// 费用审核
  1043. /// 修改团组费用审核状态
  1044. /// </summary>
  1045. /// <param name="_dto">参数Json字符串</param>
  1046. /// <returns></returns>
  1047. [HttpPost]
  1048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1049. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1050. {
  1051. #region 参数验证
  1052. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1053. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1054. #endregion
  1055. #region 页面操作权限验证
  1056. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1057. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1058. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1059. #endregion
  1060. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1061. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1062. DateTime dtNow = DateTime.Now;
  1063. _groupRepository.BeginTran();
  1064. int rst = 0;
  1065. foreach (var item in idList)
  1066. {
  1067. int CreditId = int.Parse(item);
  1068. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1069. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1070. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1071. .SetColumns(it => it.AuditGMDate == dtNow.ToString())
  1072. .Where(s => s.Id == CreditId)
  1073. .ExecuteCommandAsync();
  1074. if (result < 1)
  1075. {
  1076. rst = -1;
  1077. }
  1078. else
  1079. {
  1080. _groupRepository.RollbackTran();
  1081. return Ok(JsonView(false, "保存失败并回滚!"));
  1082. }
  1083. }
  1084. _groupRepository.CommitTran();
  1085. if (rst == 0)
  1086. {
  1087. return Ok(JsonView(true, "保存成功!"));
  1088. }
  1089. return Ok(JsonView(false, "保存失败!"));
  1090. }
  1091. #endregion
  1092. #region 机票费用录入
  1093. /// <summary>
  1094. /// 机票录入当前登录人可操作团组
  1095. /// </summary>
  1096. /// <param name="dto"></param>
  1097. /// <returns></returns>
  1098. [HttpPost]
  1099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1100. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1101. {
  1102. try
  1103. {
  1104. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1105. if (groupData.Code != 0)
  1106. {
  1107. return Ok(JsonView(false, groupData.Msg));
  1108. }
  1109. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1110. }
  1111. catch (Exception ex)
  1112. {
  1113. return Ok(JsonView(false, "程序错误!"));
  1114. throw;
  1115. }
  1116. }
  1117. /// <summary>
  1118. /// 机票费用录入列表
  1119. /// </summary>
  1120. /// <param name="dto"></param>
  1121. /// <returns></returns>
  1122. [HttpPost]
  1123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1124. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1125. {
  1126. try
  1127. {
  1128. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1129. if (groupData.Code != 0)
  1130. {
  1131. return Ok(JsonView(false, groupData.Msg));
  1132. }
  1133. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1134. }
  1135. catch (Exception ex)
  1136. {
  1137. return Ok(JsonView(false, "程序错误!"));
  1138. throw;
  1139. }
  1140. }
  1141. /// <summary>
  1142. /// 根据id查询费用录入信息
  1143. /// </summary>
  1144. /// <param name="dto"></param>
  1145. /// <returns></returns>
  1146. [HttpPost]
  1147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1148. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1149. {
  1150. try
  1151. {
  1152. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1153. if (groupData.Code != 0)
  1154. {
  1155. return Ok(JsonView(false, groupData.Msg));
  1156. }
  1157. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1158. }
  1159. catch (Exception ex)
  1160. {
  1161. return Ok(JsonView(false, "程序错误!"));
  1162. throw;
  1163. }
  1164. }
  1165. /// <summary>
  1166. /// 机票费用录入操作(Status:1.新增,2.修改)
  1167. /// </summary>
  1168. /// <param name="dto"></param>
  1169. /// <returns></returns>
  1170. [HttpPost]
  1171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1172. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1173. {
  1174. try
  1175. {
  1176. Result groupData = await _airTicketResRep.OpAirTicketRes(dto);
  1177. if (groupData.Code != 0)
  1178. {
  1179. return Ok(JsonView(false, groupData.Msg));
  1180. }
  1181. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1182. }
  1183. catch (Exception ex)
  1184. {
  1185. return Ok(JsonView(false, "程序错误!"));
  1186. throw;
  1187. }
  1188. }
  1189. /// <summary>
  1190. /// 根据舱位类型查询接团客户名单信息
  1191. /// </summary>
  1192. /// <param name="dto"></param>
  1193. /// <returns></returns>
  1194. [HttpPost]
  1195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1196. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1197. {
  1198. try
  1199. {
  1200. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1201. if (crm_Groups.Count != 0)
  1202. {
  1203. List<dynamic> Customer = new List<dynamic>();
  1204. foreach (var item in crm_Groups)
  1205. {
  1206. var data = new
  1207. {
  1208. Id = item.Id,
  1209. Pinyin = item.Pinyin,
  1210. Name = item.LastName + item.FirstName
  1211. };
  1212. Customer.Add(data);
  1213. }
  1214. return Ok(JsonView(true, "查询成功!", Customer));
  1215. }
  1216. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1217. }
  1218. catch (Exception ex)
  1219. {
  1220. return Ok(JsonView(false, "程序错误!"));
  1221. throw;
  1222. }
  1223. }
  1224. /// <summary>
  1225. /// 机票费用录入,删除
  1226. /// </summary>
  1227. /// <param name="dto"></param>
  1228. /// <returns></returns>
  1229. [HttpPost]
  1230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1231. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1232. {
  1233. try
  1234. {
  1235. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1236. if (!res)
  1237. {
  1238. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1239. {
  1240. IsDel = 1,
  1241. DeleteUserId = dto.DeleteUserId,
  1242. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1243. }).ExecuteCommandAsync();
  1244. return Ok(JsonView(false, "删除失败"));
  1245. }
  1246. return Ok(JsonView(true, "删除成功!"));
  1247. }
  1248. catch (Exception ex)
  1249. {
  1250. return Ok(JsonView(false, "程序错误!"));
  1251. throw;
  1252. }
  1253. }
  1254. /// <summary>
  1255. /// 导出机票录入报表
  1256. /// </summary>
  1257. /// <param name="dto"></param>
  1258. /// <returns></returns>
  1259. [HttpPost]
  1260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1261. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  1262. {
  1263. try
  1264. {
  1265. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1266. if (groupData.Code != 0)
  1267. {
  1268. return Ok(JsonView(false, groupData.Msg));
  1269. }
  1270. else
  1271. {
  1272. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1273. if (AirTicketReservations.Count != 0)
  1274. {
  1275. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1276. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1277. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1278. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1279. WorkbookDesigner designer = new WorkbookDesigner();
  1280. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1281. decimal countCost = 0;
  1282. foreach (var item in AirTicketReservations)
  1283. {
  1284. if (item.BankType == "其他")
  1285. {
  1286. item.BankNo = "--";
  1287. }
  1288. else
  1289. {
  1290. item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
  1291. }
  1292. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1293. item.Price = System.Decimal.Round(item.Price, 2);
  1294. countCost += Convert.ToDecimal(item.Price);
  1295. }
  1296. designer.SetDataSource("Export", AirTicketReservations);
  1297. designer.SetDataSource("ExportDiCode", diCode);
  1298. designer.SetDataSource("ExportDiName", diName);
  1299. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1300. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1301. designer.Process();
  1302. string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  1303. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1304. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1305. return Ok(JsonView(true, "成功", url = rst));
  1306. }
  1307. else
  1308. {
  1309. return Ok(JsonView(false, "暂无数据!"));
  1310. }
  1311. }
  1312. }
  1313. catch (Exception ex)
  1314. {
  1315. return Ok(JsonView(false, "程序错误!"));
  1316. throw;
  1317. }
  1318. }
  1319. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1320. /// <summary>
  1321. /// 行程单导出
  1322. /// </summary>
  1323. /// <param name="dto"></param>
  1324. /// <returns></returns>
  1325. [HttpPost]
  1326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1327. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1328. {
  1329. try
  1330. {
  1331. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1332. if (groupData.Code != 0)
  1333. {
  1334. return Ok(JsonView(false, groupData.Msg));
  1335. }
  1336. else
  1337. {
  1338. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1339. if (dto.Language == "CN")
  1340. {
  1341. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1342. DocumentBuilder builder = new DocumentBuilder(doc);
  1343. int tableIndex = 0;//表格索引
  1344. //得到文档中的第一个表格
  1345. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1346. foreach (var item in _AirTicketReservations)
  1347. {
  1348. #region 处理固定数据
  1349. string[] FlightsCode = item.FlightsCode.Split('/');
  1350. if (FlightsCode.Length != 0)
  1351. {
  1352. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1353. if (_AirCompany != null)
  1354. {
  1355. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1356. }
  1357. else
  1358. {
  1359. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1360. }
  1361. }
  1362. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1363. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1364. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1365. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1366. string name = "";
  1367. foreach (string clientName in nameArray)
  1368. {
  1369. if (!name.Contains(clientName))
  1370. {
  1371. name += clientName + ",";
  1372. }
  1373. }
  1374. if (!string.IsNullOrWhiteSpace(name))
  1375. {
  1376. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1377. }
  1378. else
  1379. {
  1380. table.Range.Bookmarks["ClientName"].Text = "--";
  1381. }
  1382. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1383. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1384. table.Range.Bookmarks["JointTicket"].Text = "--";
  1385. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1386. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1387. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1388. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1389. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1390. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1391. #endregion
  1392. #region 循环数据处理
  1393. List<AirInfo> airs = new List<AirInfo>();
  1394. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1395. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1396. for (int i = 0; i < FlightsCode.Length; i++)
  1397. {
  1398. AirInfo air = new AirInfo();
  1399. string[] tempstr = DayArray[i]
  1400. .Replace("\r\n", string.Empty)
  1401. .Replace("\\r\\n", string.Empty)
  1402. .TrimStart().TrimEnd()
  1403. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1404. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1405. string starCity = "";
  1406. if (star_Three != null)
  1407. {
  1408. starCity = star_Three.AirPort;
  1409. }
  1410. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1411. string EndCity = "";
  1412. if (End_Three != null)
  1413. {
  1414. EndCity = End_Three.AirPort;
  1415. }
  1416. air.Destination = starCity + "/" + EndCity;
  1417. air.Flight = FlightsCode[i];
  1418. air.SeatingClass = item.CTypeName;
  1419. string dateTime = tempstr[2];
  1420. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1421. air.FlightDate = DateTemp;
  1422. air.DepartureTime = tempstr[5];
  1423. air.LandingTime = tempstr[6];
  1424. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1425. air.TicketStatus = "--";
  1426. air.Luggage = "--";
  1427. air.DepartureTerminal = "--";
  1428. air.LandingTerminal = "--";
  1429. airs.Add(air);
  1430. }
  1431. int row = 13;
  1432. for (int i = 0; i < airs.Count; i++)
  1433. {
  1434. if (airs.Count > 2)
  1435. {
  1436. for (int j = 0; j < airs.Count - 2; j++)
  1437. {
  1438. var CopyRow = table.Rows[12].Clone(true);
  1439. table.Rows.Add(CopyRow);
  1440. }
  1441. }
  1442. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1443. int index = 0;
  1444. foreach (PropertyInfo property in properties)
  1445. {
  1446. string value = property.GetValue(airs[i]).ToString();
  1447. Cell ishcel0 = table.Rows[row].Cells[index];
  1448. Paragraph p = new Paragraph(doc);
  1449. string s = value;
  1450. p.AppendChild(new Run(doc, s));
  1451. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1452. ishcel0.AppendChild(p);
  1453. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1454. index++;
  1455. }
  1456. row++;
  1457. }
  1458. #endregion
  1459. Paragraph lastParagraph = new Paragraph(doc);
  1460. //第一个表格末尾加段落
  1461. table.ParentNode.InsertAfter(lastParagraph, table);
  1462. //复制第一个表格
  1463. Table cloneTable = (Table)table.Clone(true);
  1464. //在文档末尾段落后面加入复制的表格
  1465. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1466. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1467. {
  1468. int rownewsIndex = 13;
  1469. for (int i = 0; i < 2; i++)
  1470. {
  1471. var CopyRow = table.Rows[12].Clone(true);
  1472. table.Rows.RemoveAt(13);
  1473. table.Rows.Add(CopyRow);
  1474. rownewsIndex++;
  1475. }
  1476. }
  1477. else
  1478. {
  1479. table.Rows.RemoveAt(12);
  1480. }
  1481. cloneTable.Rows.RemoveAt(12);
  1482. }
  1483. if (_AirTicketReservations.Count != 0)
  1484. {
  1485. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1486. if (FlightsCode.Length != 0)
  1487. {
  1488. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1489. if (_AirCompany != null)
  1490. {
  1491. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1492. }
  1493. else
  1494. {
  1495. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1496. }
  1497. }
  1498. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1499. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1500. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1501. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1502. string name = "";
  1503. foreach (string clientName in nameArray)
  1504. {
  1505. if (!name.Contains(clientName))
  1506. {
  1507. name += clientName + ",";
  1508. }
  1509. }
  1510. if (!string.IsNullOrWhiteSpace(name))
  1511. {
  1512. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1513. }
  1514. else
  1515. {
  1516. table.Range.Bookmarks["ClientName"].Text = "--";
  1517. }
  1518. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1519. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1520. table.Range.Bookmarks["JointTicket"].Text = "--";
  1521. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1522. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1523. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1524. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1525. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1526. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1527. }
  1528. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1529. //保存合并后的文档
  1530. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  1531. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1532. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1533. return Ok(JsonView(true, "成功!", rst));
  1534. }
  1535. else
  1536. {
  1537. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  1538. DocumentBuilder builder = new DocumentBuilder(doc);
  1539. int tableIndex = 0;//表格索引
  1540. //得到文档中的第一个表格
  1541. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1542. List<string> texts = new List<string>();
  1543. foreach (var item in _AirTicketReservations)
  1544. {
  1545. string[] FlightsCode = item.FlightsCode.Split('/');
  1546. if (FlightsCode.Length != 0)
  1547. {
  1548. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1549. if (_AirCompany != null)
  1550. {
  1551. if (!transDic.ContainsKey(_AirCompany.CnName))
  1552. {
  1553. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  1554. }
  1555. }
  1556. else
  1557. {
  1558. if (!transDic.ContainsKey("--"))
  1559. {
  1560. transDic.Add("--", "--");
  1561. }
  1562. }
  1563. }
  1564. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1565. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1566. string name = "";
  1567. foreach (string clientName in nameArray)
  1568. {
  1569. name += clientName + ",";
  1570. }
  1571. if (!texts.Contains(name))
  1572. {
  1573. texts.Add(name);
  1574. }
  1575. List<AirInfo> airs = new List<AirInfo>();
  1576. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1577. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1578. for (int i = 0; i < FlightsCode.Length; i++)
  1579. {
  1580. AirInfo air = new AirInfo();
  1581. string[] tempstr = DayArray[i]
  1582. .Replace("\r\n", string.Empty)
  1583. .Replace("\\r\\n", string.Empty)
  1584. .TrimStart().TrimEnd()
  1585. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1586. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1587. if (star_Three != null)
  1588. {
  1589. if (!transDic.ContainsKey(star_Three.AirPort))
  1590. {
  1591. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  1592. }
  1593. }
  1594. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1595. if (End_Three != null)
  1596. {
  1597. if (!transDic.ContainsKey(End_Three.AirPort))
  1598. {
  1599. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  1600. }
  1601. }
  1602. if (!texts.Contains(item.CTypeName))
  1603. {
  1604. texts.Add(item.CTypeName);
  1605. }
  1606. }
  1607. }
  1608. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  1609. if (transData.Count > 0)
  1610. {
  1611. foreach (TranslateResult item in transData)
  1612. {
  1613. if (!transDic.ContainsKey(item.Query))
  1614. {
  1615. transDic.Add(item.Query, item.Translation);
  1616. }
  1617. }
  1618. }
  1619. foreach (var item in _AirTicketReservations)
  1620. {
  1621. #region 处理固定数据
  1622. string[] FlightsCode = item.FlightsCode.Split('/');
  1623. if (FlightsCode.Length != 0)
  1624. {
  1625. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1626. if (_AirCompany != null)
  1627. {
  1628. string str = "--";
  1629. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1630. if (!string.IsNullOrEmpty(translateResult))
  1631. {
  1632. str = translateResult;
  1633. str = _airTicketResRep.Processing(str);
  1634. }
  1635. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1636. }
  1637. else
  1638. {
  1639. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1640. }
  1641. }
  1642. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1643. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1644. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1645. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1646. string names = "";
  1647. foreach (string clientName in nameArray)
  1648. {
  1649. names += clientName + ",";
  1650. }
  1651. if (!string.IsNullOrWhiteSpace(names))
  1652. {
  1653. string str = "--";
  1654. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1655. if (!string.IsNullOrEmpty(translateResult))
  1656. {
  1657. str = translateResult;
  1658. str = _airTicketResRep.Processing(str);
  1659. }
  1660. table.Range.Bookmarks["ClientName"].Text = str;
  1661. }
  1662. else
  1663. {
  1664. table.Range.Bookmarks["ClientName"].Text = "--";
  1665. }
  1666. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1667. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1668. table.Range.Bookmarks["JointTicket"].Text = "--";
  1669. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1670. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1671. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1672. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1673. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1674. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1675. #endregion
  1676. #region 循环数据处理
  1677. List<AirInfo> airs = new List<AirInfo>();
  1678. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1679. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1680. for (int i = 0; i < FlightsCode.Length; i++)
  1681. {
  1682. AirInfo air = new AirInfo();
  1683. string[] tempstr = DayArray[i]
  1684. .Replace("\r\n", string.Empty)
  1685. .Replace("\\r\\n", string.Empty)
  1686. .TrimStart().TrimEnd()
  1687. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1688. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1689. string starCity = "";
  1690. if (star_Three != null)
  1691. {
  1692. string str2 = "--";
  1693. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  1694. if (!string.IsNullOrEmpty(translateResult2))
  1695. {
  1696. str2 = translateResult2;
  1697. str2 = _airTicketResRep.Processing(str2);
  1698. }
  1699. starCity = str2;
  1700. }
  1701. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1702. string EndCity = "";
  1703. if (End_Three != null)
  1704. {
  1705. string str1 = "--";
  1706. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  1707. if (!string.IsNullOrEmpty(translateResult1))
  1708. {
  1709. str1 = translateResult1;
  1710. str1 = _airTicketResRep.Processing(str1);
  1711. }
  1712. EndCity = str1;
  1713. }
  1714. air.Destination = starCity + "/" + EndCity;
  1715. air.Flight = FlightsCode[i];
  1716. string str = "--";
  1717. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  1718. if (!string.IsNullOrEmpty(translateResult))
  1719. {
  1720. str = translateResult;
  1721. str = _airTicketResRep.Processing(str);
  1722. }
  1723. air.SeatingClass = str;
  1724. string dateTime = tempstr[2];
  1725. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1726. air.FlightDate = DateTemp;
  1727. air.DepartureTime = tempstr[5];
  1728. air.LandingTime = tempstr[6];
  1729. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1730. air.TicketStatus = "--";
  1731. air.Luggage = "--";
  1732. air.DepartureTerminal = "--";
  1733. air.LandingTerminal = "--";
  1734. airs.Add(air);
  1735. }
  1736. int row = 13;
  1737. for (int i = 0; i < airs.Count; i++)
  1738. {
  1739. if (airs.Count > 2)
  1740. {
  1741. for (int j = 0; j < airs.Count - 2; j++)
  1742. {
  1743. var CopyRow = table.Rows[12].Clone(true);
  1744. table.Rows.Add(CopyRow);
  1745. }
  1746. }
  1747. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1748. int index = 0;
  1749. foreach (PropertyInfo property in properties)
  1750. {
  1751. string value = property.GetValue(airs[i]).ToString();
  1752. Cell ishcel0 = table.Rows[row].Cells[index];
  1753. Paragraph p = new Paragraph(doc);
  1754. string s = value;
  1755. p.AppendChild(new Run(doc, s));
  1756. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1757. ishcel0.AppendChild(p);
  1758. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1759. //ishcel0.CellFormat.VerticalAlignment=
  1760. index++;
  1761. }
  1762. row++;
  1763. }
  1764. #endregion
  1765. Paragraph lastParagraph = new Paragraph(doc);
  1766. //第一个表格末尾加段落
  1767. table.ParentNode.InsertAfter(lastParagraph, table);
  1768. //复制第一个表格
  1769. Table cloneTable = (Table)table.Clone(true);
  1770. //在文档末尾段落后面加入复制的表格
  1771. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1772. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1773. {
  1774. int rownewsIndex = 13;
  1775. for (int i = 0; i < 2; i++)
  1776. {
  1777. var CopyRow = table.Rows[12].Clone(true);
  1778. table.Rows.RemoveAt(13);
  1779. table.Rows.Add(CopyRow);
  1780. rownewsIndex++;
  1781. }
  1782. }
  1783. else
  1784. {
  1785. table.Rows.RemoveAt(12);
  1786. }
  1787. cloneTable.Rows.RemoveAt(12);
  1788. }
  1789. if (_AirTicketReservations.Count != 0)
  1790. {
  1791. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1792. if (FlightsCode.Length != 0)
  1793. {
  1794. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1795. if (_AirCompany != null)
  1796. {
  1797. string str = "--";
  1798. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1799. if (!string.IsNullOrEmpty(translateResult))
  1800. {
  1801. str = translateResult;
  1802. str = _airTicketResRep.Processing(str);
  1803. }
  1804. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1805. }
  1806. else
  1807. {
  1808. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1809. }
  1810. }
  1811. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1812. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1813. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1814. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1815. string names = "";
  1816. foreach (string clientName in nameArray)
  1817. {
  1818. names += clientName + ",";
  1819. }
  1820. if (!string.IsNullOrWhiteSpace(names))
  1821. {
  1822. string str = "--";
  1823. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1824. if (!string.IsNullOrEmpty(translateResult))
  1825. {
  1826. str = translateResult;
  1827. str = _airTicketResRep.Processing(str);
  1828. }
  1829. table.Range.Bookmarks["ClientName"].Text = str;
  1830. }
  1831. else
  1832. {
  1833. table.Range.Bookmarks["ClientName"].Text = "--";
  1834. }
  1835. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1836. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1837. table.Range.Bookmarks["JointTicket"].Text = "--";
  1838. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1839. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1840. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1841. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1842. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1843. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1844. }
  1845. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1846. //保存合并后的文档
  1847. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  1848. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1849. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1850. return Ok(JsonView(true, "成功!", rst));
  1851. }
  1852. }
  1853. }
  1854. catch (Exception ex)
  1855. {
  1856. return Ok(JsonView(false, "程序错误!"));
  1857. throw;
  1858. }
  1859. }
  1860. #endregion
  1861. #region 团组增减款项
  1862. /// <summary>
  1863. /// 团组增减款项下拉框绑定
  1864. /// </summary>
  1865. /// <param name="dto"></param>
  1866. /// <returns></returns>
  1867. [HttpPost]
  1868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1869. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  1870. {
  1871. try
  1872. {
  1873. Result groupData = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  1874. if (groupData.Code != 0)
  1875. {
  1876. return Ok(JsonView(false, groupData.Msg));
  1877. }
  1878. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1879. }
  1880. catch (Exception ex)
  1881. {
  1882. return Ok(JsonView(false, "程序错误!"));
  1883. throw;
  1884. }
  1885. }
  1886. /// <summary>
  1887. /// 根据团组Id查询团组增减款项
  1888. /// </summary>
  1889. /// <param name="dto"></param>
  1890. /// <returns></returns>
  1891. [HttpPost]
  1892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1893. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  1894. {
  1895. try
  1896. {
  1897. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  1898. if (groupData.Code != 0)
  1899. {
  1900. return Ok(JsonView(false, groupData.Msg));
  1901. }
  1902. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1903. }
  1904. catch (Exception ex)
  1905. {
  1906. return Ok(JsonView(false, "程序错误!"));
  1907. throw;
  1908. }
  1909. }
  1910. /// <summary>
  1911. /// 团组增减款项操作(Status:1.新增,2.修改)
  1912. /// </summary>
  1913. /// <param name="dto"></param>
  1914. /// <returns></returns>
  1915. [HttpPost]
  1916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1917. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  1918. {
  1919. try
  1920. {
  1921. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  1922. if (groupData.Code != 0)
  1923. {
  1924. return Ok(JsonView(false, groupData.Msg));
  1925. }
  1926. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1927. }
  1928. catch (Exception ex)
  1929. {
  1930. return Ok(JsonView(false, "程序错误!"));
  1931. throw;
  1932. }
  1933. }
  1934. /// <summary>
  1935. /// 团组增减款项操作 删除
  1936. /// </summary>
  1937. /// <param name="dto"></param>
  1938. /// <returns></returns>
  1939. [HttpPost]
  1940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1941. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  1942. {
  1943. try
  1944. {
  1945. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  1946. if (!res)
  1947. {
  1948. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  1949. {
  1950. IsDel = 1,
  1951. DeleteUserId = dto.DeleteUserId,
  1952. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1953. }).ExecuteCommandAsync();
  1954. return Ok(JsonView(false, "删除失败"));
  1955. }
  1956. return Ok(JsonView(true, "删除成功!"));
  1957. }
  1958. catch (Exception ex)
  1959. {
  1960. return Ok(JsonView(false, "程序错误!"));
  1961. throw;
  1962. }
  1963. }
  1964. /// <summary>
  1965. /// 根据团组增减款项Id查询
  1966. /// </summary>
  1967. /// <param name="dto"></param>
  1968. /// <returns></returns>
  1969. [HttpPost]
  1970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1971. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  1972. {
  1973. try
  1974. {
  1975. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  1976. if (groupData.Code != 0)
  1977. {
  1978. return Ok(JsonView(false, groupData.Msg));
  1979. }
  1980. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1981. }
  1982. catch (Exception ex)
  1983. {
  1984. return Ok(JsonView(false, "程序错误!"));
  1985. throw;
  1986. }
  1987. }
  1988. #endregion
  1989. #region 文件上传、删除
  1990. /// <summary>
  1991. /// region 文件上传 可以带参数
  1992. /// </summary>
  1993. /// <param name="file"></param>
  1994. /// <returns></returns>
  1995. [HttpPost]
  1996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1997. public async Task<IActionResult> UploadProject(IFormFile file)
  1998. {
  1999. try
  2000. {
  2001. var TypeName = Request.Headers["TypeName"].ToString();
  2002. if (file != null)
  2003. {
  2004. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2005. //文件名称
  2006. string projectFileName = file.FileName;
  2007. //上传的文件的路径
  2008. string filePath = "";
  2009. if (TypeName == "A")//A代表团组增减款项
  2010. {
  2011. if (!Directory.Exists(fileDir))
  2012. {
  2013. Directory.CreateDirectory(fileDir);
  2014. }
  2015. //上传的文件的路径
  2016. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2017. }
  2018. else if (TypeName == "B")//B代表商邀相关文件
  2019. {
  2020. if (!Directory.Exists(fileDir))
  2021. {
  2022. Directory.CreateDirectory(fileDir);
  2023. }
  2024. //上传的文件的路径
  2025. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2026. }
  2027. using (FileStream fs = System.IO.File.Create(filePath))
  2028. {
  2029. file.CopyTo(fs);
  2030. fs.Flush();
  2031. }
  2032. return Ok(JsonView(true, "上传成功!", projectFileName));
  2033. }
  2034. else
  2035. {
  2036. return Ok(JsonView(false, "上传失败!"));
  2037. }
  2038. }
  2039. catch (Exception ex)
  2040. {
  2041. return Ok(JsonView(false, "程序错误!"));
  2042. throw;
  2043. }
  2044. }
  2045. /// <summary>
  2046. /// 删除指定文件
  2047. /// </summary>
  2048. /// <param name="dto"></param>
  2049. /// <returns></returns>
  2050. [HttpPost]
  2051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2052. public async Task<IActionResult> DelFile(DelFileDto dto)
  2053. {
  2054. try
  2055. {
  2056. var TypeName = Request.Headers["TypeName"].ToString();
  2057. string filePath = "";
  2058. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2059. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2060. int id = 0;
  2061. if (TypeName == "A")
  2062. {
  2063. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2064. // 删除该文件
  2065. System.IO.File.Delete(filePath);
  2066. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2067. }
  2068. else if (TypeName == "B")
  2069. {
  2070. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2071. // 删除该文件
  2072. System.IO.File.Delete(filePath);
  2073. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2074. }
  2075. if (id != 0)
  2076. {
  2077. return Ok(JsonView(true, "成功!"));
  2078. }
  2079. else
  2080. {
  2081. return Ok(JsonView(false, "失败!"));
  2082. }
  2083. }
  2084. catch (Exception ex)
  2085. {
  2086. return Ok(JsonView(false, "程序错误!"));
  2087. throw;
  2088. }
  2089. }
  2090. #endregion
  2091. #region 商邀费用录入
  2092. /// <summary>
  2093. /// 根据团组Id查询商邀费用列表
  2094. /// </summary>
  2095. /// <param name="dto"></param>
  2096. /// <returns></returns>
  2097. [HttpPost]
  2098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2099. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2100. {
  2101. try
  2102. {
  2103. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2104. if (groupData.Code != 0)
  2105. {
  2106. return Ok(JsonView(false, groupData.Msg));
  2107. }
  2108. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2109. }
  2110. catch (Exception ex)
  2111. {
  2112. return Ok(JsonView(false, "程序错误!"));
  2113. throw;
  2114. }
  2115. }
  2116. /// <summary>
  2117. /// 根据商邀费用ID查询C表和商邀费用数据
  2118. /// </summary>
  2119. /// <param name="dto"></param>
  2120. /// <returns></returns>
  2121. [HttpPost]
  2122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2123. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2124. {
  2125. try
  2126. {
  2127. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2128. if (groupData.Code != 0)
  2129. {
  2130. return Ok(JsonView(false, groupData.Msg));
  2131. }
  2132. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2133. }
  2134. catch (Exception ex)
  2135. {
  2136. return Ok(JsonView(false, "程序错误!"));
  2137. throw;
  2138. }
  2139. }
  2140. /// <summary>
  2141. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2142. /// </summary>
  2143. /// <param name="dto"></param>
  2144. /// <returns></returns>
  2145. [HttpPost]
  2146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2147. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2148. {
  2149. try
  2150. {
  2151. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto);
  2152. if (groupData.Code != 0)
  2153. {
  2154. return Ok(JsonView(false, groupData.Msg));
  2155. }
  2156. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2157. }
  2158. catch (Exception ex)
  2159. {
  2160. return Ok(JsonView(false, "程序错误!"));
  2161. throw;
  2162. }
  2163. }
  2164. /// <summary>
  2165. /// 商邀删除
  2166. /// </summary>
  2167. /// <param name="dto"></param>
  2168. /// <returns></returns>
  2169. [HttpPost]
  2170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2171. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2172. {
  2173. try
  2174. {
  2175. var res = await _InvitationOfficialActivitiesRep.SoftDeleteByIdAsync<Grp_InvitationOfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  2176. if (!res)
  2177. {
  2178. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 81).SetColumns(a => new Grp_CreditCardPayment()
  2179. {
  2180. IsDel = 1,
  2181. DeleteUserId = dto.DeleteUserId,
  2182. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2183. }).ExecuteCommandAsync();
  2184. return Ok(JsonView(false, "删除失败"));
  2185. }
  2186. return Ok(JsonView(true, "删除成功!"));
  2187. }
  2188. catch (Exception ex)
  2189. {
  2190. return Ok(JsonView(false, "程序错误!"));
  2191. throw;
  2192. }
  2193. }
  2194. #endregion
  2195. #region 团组英文资料
  2196. /// <summary>
  2197. /// 查询团组英文所有资料
  2198. /// </summary>
  2199. /// <param name="dto"></param>
  2200. /// <returns></returns>
  2201. [HttpPost]
  2202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2203. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2204. {
  2205. try
  2206. {
  2207. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  2208. if (groupData.Code != 0)
  2209. {
  2210. return Ok(JsonView(false, groupData.Msg));
  2211. }
  2212. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2213. }
  2214. catch (Exception ex)
  2215. {
  2216. return Ok(JsonView(false, "程序错误!"));
  2217. throw;
  2218. }
  2219. }
  2220. /// <summary>
  2221. /// 团组英文资料操作(Status:1.新增,2.修改)
  2222. /// </summary>
  2223. /// <param name="dto"></param>
  2224. /// <returns></returns>
  2225. [HttpPost]
  2226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2227. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  2228. {
  2229. try
  2230. {
  2231. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  2232. if (groupData.Code != 0)
  2233. {
  2234. return Ok(JsonView(false, groupData.Msg));
  2235. }
  2236. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2237. }
  2238. catch (Exception ex)
  2239. {
  2240. return Ok(JsonView(false, "程序错误!"));
  2241. throw;
  2242. }
  2243. }
  2244. /// <summary>
  2245. /// 团组英文资料Id查询数据
  2246. /// </summary>
  2247. /// <param name="dto"></param>
  2248. /// <returns></returns>
  2249. [HttpPost]
  2250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2251. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  2252. {
  2253. try
  2254. {
  2255. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  2256. if (_DelegationEnData != null)
  2257. {
  2258. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  2259. }
  2260. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  2261. }
  2262. catch (Exception ex)
  2263. {
  2264. return Ok(JsonView(false, "程序错误!"));
  2265. throw;
  2266. }
  2267. }
  2268. /// <summary>
  2269. /// 团组英文资料删除
  2270. /// </summary>
  2271. /// <param name="dto"></param>
  2272. /// <returns></returns>
  2273. [HttpPost]
  2274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2275. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2276. {
  2277. try
  2278. {
  2279. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2280. if (!res)
  2281. {
  2282. return Ok(JsonView(false, "删除失败"));
  2283. }
  2284. return Ok(JsonView(true, "删除成功!"));
  2285. }
  2286. catch (Exception ex)
  2287. {
  2288. return Ok(JsonView(false, "程序错误!"));
  2289. throw;
  2290. }
  2291. }
  2292. #endregion
  2293. #region 导出邀请函
  2294. /// <summary>
  2295. /// 导出邀请函页面初始化
  2296. /// </summary>
  2297. /// <param name="dto"></param>
  2298. /// <returns></returns>
  2299. [HttpPost]
  2300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2301. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2302. {
  2303. try
  2304. {
  2305. List<Grp_DelegationInfo> grp_Delegations = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToListAsync();
  2306. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2307. if (dto.DiId == 0)
  2308. {
  2309. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2310. }
  2311. else
  2312. {
  2313. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2314. }
  2315. return Ok(JsonView(true, "查询成功!", new
  2316. {
  2317. deleClient = crm_Deles,
  2318. delegations = grp_Delegations
  2319. }));
  2320. }
  2321. catch (Exception ex)
  2322. {
  2323. return Ok(JsonView(false, "程序错误!"));
  2324. throw;
  2325. }
  2326. }
  2327. /// <summary>
  2328. /// 导出邀请函
  2329. /// </summary>
  2330. /// <param name="dto"></param>
  2331. /// <returns></returns>
  2332. [HttpPost]
  2333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2334. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2335. {
  2336. try
  2337. {
  2338. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2339. List<Crm_DeleClient> crm_DeleClients = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2340. List<string> texts = new List<string>();
  2341. if (crm_DeleClients.Count != 0)
  2342. {
  2343. foreach (Crm_DeleClient item in crm_DeleClients)
  2344. {
  2345. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2346. {
  2347. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2348. }
  2349. else
  2350. {
  2351. string name = item.LastName + item.FirstName;
  2352. texts.Add(name);
  2353. }
  2354. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  2355. {
  2356. if (!transDic.ContainsKey(item.Job))
  2357. {
  2358. texts.Add(item.Job);
  2359. }
  2360. }
  2361. if (item.CrmCompanyId != 0)
  2362. {
  2363. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == item.CrmCompanyId && a.IsDel == 0);
  2364. if (!transDic.ContainsKey(crm_Customer.CompanyName))
  2365. {
  2366. texts.Add(crm_Customer.CompanyName);
  2367. }
  2368. }
  2369. }
  2370. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2371. if (transData.Count > 0)
  2372. {
  2373. foreach (TranslateResult item in transData)
  2374. {
  2375. if (!transDic.ContainsKey(item.Query))
  2376. {
  2377. transDic.Add(item.Query, item.Translation);
  2378. }
  2379. }
  2380. }
  2381. List<guestList> list = new List<guestList>();
  2382. foreach (Crm_DeleClient dele in crm_DeleClients)
  2383. {
  2384. guestList guestList = new guestList();
  2385. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  2386. {
  2387. guestList.Name = dele.Pinyin;
  2388. }
  2389. else
  2390. {
  2391. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  2392. guestList.Name = Name;
  2393. }
  2394. if (dele.Sex == 0)
  2395. {
  2396. guestList.Sex = "Male";
  2397. }
  2398. else if (dele.Sex == 1)
  2399. {
  2400. guestList.Sex = "Female";
  2401. }
  2402. guestList.DOB = dele.BirthDay.Replace('-', '.');
  2403. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == dele.CrmCompanyId && a.IsDel == 0);
  2404. string jobName = transDic.Where(s => s.Key == crm_Customer.CompanyName).FirstOrDefault().Value + " " + transDic.Where(s => s.Key == dele.Job).FirstOrDefault().Value;
  2405. guestList.Job = jobName;
  2406. list.Add(guestList);
  2407. }
  2408. //载入模板
  2409. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  2410. DocumentBuilder builder = new DocumentBuilder(doc);
  2411. //获取word里所有表格
  2412. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2413. //获取所填表格的序数
  2414. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2415. var rowStart = tableOne.Rows[0]; //获取第1行
  2416. //循环赋值
  2417. for (int i = 0; i < list.Count; i++)
  2418. {
  2419. builder.MoveToCell(0, i + 1, 0, 0);
  2420. builder.Write(list[i].Name.ToString());
  2421. builder.MoveToCell(0, i + 1, 1, 0);
  2422. builder.Write(list[i].Sex.ToString());
  2423. builder.MoveToCell(0, i + 1, 2, 0);
  2424. builder.Write(list[i].DOB.ToString());
  2425. builder.MoveToCell(0, i + 1, 3, 0);
  2426. builder.Write(list[i].Job.ToString());
  2427. }
  2428. //删除多余行
  2429. while (tableOne.Rows.Count > list.Count + 1)
  2430. {
  2431. tableOne.Rows.RemoveAt(list.Count + 1);
  2432. }
  2433. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2434. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  2435. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  2436. doc.Save(filePath);
  2437. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件" + fileName;
  2438. return Ok(JsonView(true, "成功!", Url));
  2439. }
  2440. else
  2441. {
  2442. return Ok(JsonView(false, "失败,该团组没有客户名单!"));
  2443. }
  2444. }
  2445. catch (Exception ex)
  2446. {
  2447. return Ok(JsonView(false, "程序错误!"));
  2448. throw;
  2449. }
  2450. }
  2451. #endregion
  2452. #region 团组经理模块 出入境费用
  2453. ///// <summary>
  2454. ///// 团组模块 - 出入境费用
  2455. ///// </summary>
  2456. ///// <returns></returns>
  2457. //[HttpPost]
  2458. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2459. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  2460. //{
  2461. // try
  2462. // {
  2463. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  2464. // if (data.Code != 0)
  2465. // {
  2466. // return Ok(JsonView(false, data.Msg));
  2467. // }
  2468. // return Ok(JsonView(true, "查询成功!"));
  2469. // }
  2470. // catch (Exception ex)
  2471. // {
  2472. // return Ok(JsonView(false, ex.Message));
  2473. // throw;
  2474. // }
  2475. //}
  2476. /// <summary>
  2477. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  2478. /// </summary>
  2479. /// <returns></returns>
  2480. [HttpPost]
  2481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2482. public async Task<IActionResult> SetDayAndCostAreaChange()
  2483. {
  2484. try
  2485. {
  2486. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  2487. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  2488. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  2489. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  2490. foreach (var item in unite) //处理交集数据
  2491. {
  2492. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  2493. }
  2494. foreach (var item in merge) //处理差集数据
  2495. {
  2496. int nationalTravelFeeId = 0;
  2497. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  2498. if (cityData != null) nationalTravelFeeId = cityData.Id;
  2499. else
  2500. {
  2501. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  2502. if (countryData != null) nationalTravelFeeId = countryData.Id;
  2503. }
  2504. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  2505. }
  2506. //只更新dayAndCost 的 nationalTravelFeeId;
  2507. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  2508. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  2509. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  2510. }
  2511. catch (Exception ex)
  2512. {
  2513. return Ok(JsonView(false, ex.Message));
  2514. throw;
  2515. }
  2516. }
  2517. /// <summary>
  2518. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  2519. /// </summary>
  2520. /// <returns></returns>
  2521. [HttpPost]
  2522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2523. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  2524. {
  2525. try
  2526. {
  2527. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  2528. string currencySql = string.Format("Select * From Sys_SetData Where STid = 66 And IsDel = 0");
  2529. var currencyData = await _sqlSugar.SqlQueryable<SetDataInfoView>(currencySql).ToListAsync();
  2530. //string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2531. // Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2532. // Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2533. // Where gntf.Isdel = 0");
  2534. //var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2535. return Ok(JsonView(true, "查询成功!", new
  2536. {
  2537. GroupNameData = groupNameData.Data,
  2538. CurrencyData = currencyData,
  2539. //NationalTravelFeeData = nationalTravelFeeData
  2540. }));
  2541. }
  2542. catch (Exception ex)
  2543. {
  2544. return Ok(JsonView(false, ex.Message));
  2545. throw;
  2546. }
  2547. }
  2548. /// <summary>
  2549. /// 团组模块 - 出入境费用 - Info
  2550. /// </summary>
  2551. /// <returns></returns>
  2552. [HttpPost]
  2553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2554. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  2555. {
  2556. try
  2557. {
  2558. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  2559. if (data.Code != 0)
  2560. {
  2561. return Ok(JsonView(false, data.Msg));
  2562. }
  2563. return Ok(JsonView(true, "查询成功!", data.Data));
  2564. }
  2565. catch (Exception ex)
  2566. {
  2567. return Ok(JsonView(false, ex.Message));
  2568. }
  2569. }
  2570. /// <summary>
  2571. /// 团组模块 - 出入境费用 - Add And Update
  2572. /// </summary>
  2573. /// <returns></returns>
  2574. [HttpPost]
  2575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2576. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  2577. {
  2578. try
  2579. {
  2580. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2581. if (data.Code != 0)
  2582. {
  2583. return Ok(JsonView(false, data.Msg));
  2584. }
  2585. return Ok(JsonView(true, data.Msg, data.Data));
  2586. }
  2587. catch (Exception ex)
  2588. {
  2589. return Ok(JsonView(false, ex.Message));
  2590. }
  2591. }
  2592. /// <summary>
  2593. /// 团组模块 - 出入境费用 - 明细表导出
  2594. /// </summary>
  2595. /// <returns></returns>
  2596. [HttpPost]
  2597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2598. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  2599. {
  2600. try
  2601. {
  2602. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2603. if (data.Code != 0)
  2604. {
  2605. return Ok(JsonView(false, data.Msg));
  2606. }
  2607. return Ok(JsonView(true, data.Msg, data.Data));
  2608. }
  2609. catch (Exception ex)
  2610. {
  2611. return Ok(JsonView(false, ex.Message));
  2612. }
  2613. }
  2614. /// <summary>
  2615. /// 团组模块 - 出入境费用 - 子项删除
  2616. /// </summary>
  2617. /// <returns></returns>
  2618. [HttpPost]
  2619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2620. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  2621. {
  2622. try
  2623. {
  2624. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  2625. if (data.Code != 0)
  2626. {
  2627. return Ok(JsonView(false, data.Msg));
  2628. }
  2629. return Ok(JsonView(true, "操作成功!", data.Data));
  2630. }
  2631. catch (Exception ex)
  2632. {
  2633. return Ok(JsonView(false, ex.Message));
  2634. }
  2635. }
  2636. /// <summary>
  2637. /// 团组模块 - 出入境国家费用标准 List
  2638. /// </summary>
  2639. /// <returns></returns>
  2640. [HttpPost]
  2641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2642. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  2643. {
  2644. try
  2645. {
  2646. Stopwatch sw = new Stopwatch();
  2647. sw.Start();
  2648. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2649. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2650. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2651. Where gntf.Isdel = 0");
  2652. var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2653. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  2654. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  2655. //foreach (var item in nationalTravel)
  2656. //{
  2657. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  2658. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  2659. // if (otherData != null)
  2660. // {
  2661. // cityData.Remove(otherData);
  2662. // cityData.Add(otherData);
  2663. // }
  2664. // nationalTravelFeeData1.Add(new
  2665. // {
  2666. // Country = item.Country,
  2667. // CityData = cityData
  2668. // });
  2669. //}
  2670. sw.Stop();
  2671. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  2672. }
  2673. catch (Exception ex)
  2674. {
  2675. return Ok(JsonView(false, ex.Message));
  2676. throw;
  2677. }
  2678. }
  2679. /// <summary>
  2680. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  2681. /// </summary>
  2682. /// <returns></returns>
  2683. [HttpPost]
  2684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2685. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  2686. {
  2687. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  2688. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  2689. List<string> countryData = new List<string>();
  2690. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  2691. countryData = countryData.Distinct().ToList();
  2692. List<dynamic> dataSource = new List<dynamic>();
  2693. foreach (var item in countryData)
  2694. {
  2695. List<string> cityData1 = new List<string>();
  2696. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  2697. var countryData2 = new
  2698. {
  2699. CountryName = item,
  2700. CityData = cityData1
  2701. };
  2702. dataSource.Add(countryData2);
  2703. }
  2704. return Ok(JsonView(true, "查询成功!", dataSource));
  2705. }
  2706. /// <summary>
  2707. /// 团组模块 - 出入境国家费用标准 Page List
  2708. /// </summary>
  2709. /// <returns></returns>
  2710. [HttpPost]
  2711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2712. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  2713. {
  2714. int portId = dto.PortType;
  2715. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2716. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  2717. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  2718. string whereSql = string.Empty;
  2719. if (!string.IsNullOrEmpty(dto.Country))
  2720. {
  2721. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  2722. }
  2723. if (!string.IsNullOrEmpty(dto.City))
  2724. {
  2725. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  2726. }
  2727. string pageSql = string.Format(@"Select * From (
  2728. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  2729. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  2730. From Grp_NationalTravelFee gntf
  2731. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2732. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2733. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  2734. RefAsync<int> total = 0;
  2735. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  2736. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  2737. }
  2738. /// <summary>
  2739. /// 团组模块 - 出入境国家费用标准 根据城市查询
  2740. /// </summary>
  2741. /// <returns></returns>
  2742. [HttpPost]
  2743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2744. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  2745. {
  2746. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  2747. int portId = dto.PortType;
  2748. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2749. string whereSql = string.Empty;
  2750. if (!string.IsNullOrEmpty(dto.Country))
  2751. {
  2752. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  2753. }
  2754. if (!string.IsNullOrEmpty(dto.City))
  2755. {
  2756. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  2757. }
  2758. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  2759. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  2760. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  2761. From Grp_NationalTravelFee gntf
  2762. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2763. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2764. Where gntf.Isdel = 0 {0} ", whereSql);
  2765. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  2766. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  2767. }
  2768. /// <summary>
  2769. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  2770. /// </summary>
  2771. /// <returns></returns>
  2772. [HttpPost]
  2773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2774. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  2775. {
  2776. try
  2777. {
  2778. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  2779. if (data.Code != 0)
  2780. {
  2781. return Ok(JsonView(false, data.Msg));
  2782. }
  2783. return Ok(JsonView(true, "操作成功!", data.Data));
  2784. }
  2785. catch (Exception ex)
  2786. {
  2787. return Ok(JsonView(false, ex.Message));
  2788. }
  2789. }
  2790. /// <summary>
  2791. /// 团组模块 - 出入境国家费用标准 - Del
  2792. /// </summary>
  2793. /// <returns></returns>
  2794. [HttpPost]
  2795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2796. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  2797. {
  2798. try
  2799. {
  2800. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  2801. {
  2802. Id = dto.Id,
  2803. DeleteUserId = dto.DeleteUserId,
  2804. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  2805. IsDel = 1
  2806. };
  2807. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  2808. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  2809. .WhereColumns(it => new { it.Id })
  2810. .ExecuteCommandAsync();
  2811. if (delStatus <= 0)
  2812. {
  2813. return Ok(JsonView(false, "删除失败!"));
  2814. }
  2815. return Ok(JsonView(true, "操作成功!"));
  2816. }
  2817. catch (Exception ex)
  2818. {
  2819. return Ok(JsonView(false, ex.Message));
  2820. }
  2821. }
  2822. #endregion
  2823. #region 签证费用录入
  2824. /// <summary>
  2825. /// 根据diid查询签证费用列表
  2826. /// </summary>
  2827. /// <param name="dto"></param>
  2828. /// <returns></returns>
  2829. [HttpPost]
  2830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2831. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  2832. {
  2833. try
  2834. {
  2835. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  2836. if (groupData.Code != 0)
  2837. {
  2838. return Ok(JsonView(false, groupData.Msg));
  2839. }
  2840. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2841. }
  2842. catch (Exception ex)
  2843. {
  2844. return Ok(JsonView(false, ex.Message));
  2845. }
  2846. }
  2847. /// <summary>
  2848. /// 根据签证费用Id查询单条数据及c表数据
  2849. /// </summary>
  2850. /// <param name="dto"></param>
  2851. /// <returns></returns>
  2852. [HttpPost]
  2853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2854. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  2855. {
  2856. try
  2857. {
  2858. Result groupData = await _visaPriceRep.PostVisaById(dto);
  2859. if (groupData.Code != 0)
  2860. {
  2861. return Ok(JsonView(false, groupData.Msg));
  2862. }
  2863. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2864. }
  2865. catch (Exception ex)
  2866. {
  2867. return Ok(JsonView(false, ex.Message));
  2868. }
  2869. }
  2870. /// <summary>
  2871. /// 签证费用删除
  2872. /// </summary>
  2873. /// <param name="dto"></param>
  2874. /// <returns></returns>
  2875. [HttpPost]
  2876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2877. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  2878. {
  2879. try
  2880. {
  2881. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  2882. if (!res)
  2883. {
  2884. return Ok(JsonView(false, "删除失败"));
  2885. }
  2886. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
  2887. {
  2888. IsDel = 1,
  2889. DeleteUserId = dto.DeleteUserId,
  2890. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2891. }).ExecuteCommandAsync();
  2892. return Ok(JsonView(true, "删除成功!"));
  2893. }
  2894. catch (Exception ex)
  2895. {
  2896. return Ok(JsonView(false, "程序错误!"));
  2897. throw;
  2898. }
  2899. }
  2900. /// <summary>
  2901. /// 签证费用录入下拉框初始化
  2902. /// </summary>
  2903. /// <returns></returns>
  2904. [HttpPost]
  2905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2906. public async Task<IActionResult> VisaPriceAddSelect()
  2907. {
  2908. try
  2909. {
  2910. //支付方式
  2911. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  2912. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  2913. //币种
  2914. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  2915. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  2916. //乘客类型
  2917. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  2918. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  2919. //卡类型
  2920. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  2921. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  2922. var data = new
  2923. {
  2924. Payment = _Payment,
  2925. CurrencyList = _CurrencyList,
  2926. PassengerType = _PassengerType,
  2927. BankCard = _BankCard
  2928. };
  2929. return Ok(JsonView(true, "查询成功!", data));
  2930. }
  2931. catch (Exception ex)
  2932. {
  2933. return Ok(JsonView(false, "程序错误!"));
  2934. throw;
  2935. }
  2936. }
  2937. /// <summary>
  2938. /// 签证费用录入操作(Status:1.新增,2.修改)
  2939. /// </summary>
  2940. /// <param name="dto"></param>
  2941. /// <returns></returns>
  2942. [HttpPost]
  2943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2944. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  2945. {
  2946. try
  2947. {
  2948. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  2949. if (groupData.Code != 0)
  2950. {
  2951. return Ok(JsonView(false, groupData.Msg));
  2952. }
  2953. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2954. }
  2955. catch (Exception ex)
  2956. {
  2957. return Ok(JsonView(false, ex.Message));
  2958. }
  2959. }
  2960. #endregion
  2961. #region op费用录入
  2962. /// <summary>
  2963. /// 根据diid查询op费用列表
  2964. /// </summary>
  2965. /// <param name="dto"></param>
  2966. /// <returns></returns>
  2967. [HttpPost]
  2968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2969. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  2970. {
  2971. try
  2972. {
  2973. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  2974. if (groupData.Code != 0)
  2975. {
  2976. return Ok(JsonView(false, groupData.Msg));
  2977. }
  2978. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2979. }
  2980. catch (Exception ex)
  2981. {
  2982. return Ok(JsonView(false, ex.Message));
  2983. }
  2984. }
  2985. /// <summary>
  2986. /// 根据op费用Id查询单条数据及c表数据
  2987. /// </summary>
  2988. /// <param name="dto"></param>
  2989. /// <returns></returns>
  2990. [HttpPost]
  2991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2992. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  2993. {
  2994. try
  2995. {
  2996. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  2997. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  2998. var data = new
  2999. {
  3000. CarTouristGuideGround = _groupData,
  3001. CreditCardPayment = _creditCardPayment
  3002. };
  3003. return Ok(JsonView(true, "查询成功!", data));
  3004. }
  3005. catch (Exception ex)
  3006. {
  3007. return Ok(JsonView(false, "程序错误!"));
  3008. }
  3009. }
  3010. /// <summary>
  3011. /// op费用删除
  3012. /// </summary>
  3013. /// <param name="dto"></param>
  3014. /// <returns></returns>
  3015. [HttpPost]
  3016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3017. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  3018. {
  3019. try
  3020. {
  3021. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3022. if (!res)
  3023. {
  3024. return Ok(JsonView(false, "删除失败"));
  3025. }
  3026. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  3027. {
  3028. IsDel = 1,
  3029. DeleteUserId = dto.DeleteUserId,
  3030. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3031. }).ExecuteCommandAsync();
  3032. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  3033. {
  3034. IsDel = 1,
  3035. DeleteUserId = dto.DeleteUserId,
  3036. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3037. }).ExecuteCommandAsync();
  3038. return Ok(JsonView(true, "删除成功!"));
  3039. }
  3040. catch (Exception ex)
  3041. {
  3042. return Ok(JsonView(false, "程序错误!"));
  3043. throw;
  3044. }
  3045. }
  3046. /// <summary>
  3047. /// op费用录入操作(Status:1.新增,2.修改)
  3048. /// </summary>
  3049. /// <param name="dto"></param>
  3050. /// <returns></returns>
  3051. [HttpPost]
  3052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3053. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  3054. {
  3055. try
  3056. {
  3057. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  3058. if (groupData.Code != 0)
  3059. {
  3060. return Ok(JsonView(false, groupData.Msg));
  3061. }
  3062. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3063. }
  3064. catch (Exception ex)
  3065. {
  3066. return Ok(JsonView(false, ex.Message));
  3067. }
  3068. }
  3069. /// <summary>
  3070. /// 填写费用详细页面初始化绑定
  3071. /// </summary>
  3072. /// <param name="dto"></param>
  3073. /// <returns></returns>
  3074. [HttpPost]
  3075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3076. public async Task<IActionResult> CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  3077. {
  3078. try
  3079. {
  3080. Result groupData = await _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  3081. if (groupData.Code != 0)
  3082. {
  3083. return Ok(JsonView(false, groupData.Msg));
  3084. }
  3085. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3086. }
  3087. catch (Exception ex)
  3088. {
  3089. return Ok(JsonView(false, ex.Message));
  3090. }
  3091. }
  3092. /// <summary>
  3093. /// 根据op费用Id查询详细数据
  3094. /// </summary>
  3095. /// <param name="dto"></param>
  3096. /// <returns></returns>
  3097. [HttpPost]
  3098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3099. public async Task<IActionResult> OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  3100. {
  3101. try
  3102. {
  3103. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  3104. if (groupData.Code != 0)
  3105. {
  3106. return Ok(JsonView(false, groupData.Msg));
  3107. }
  3108. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3109. }
  3110. catch (Exception ex)
  3111. {
  3112. return Ok(JsonView(false, ex.Message));
  3113. }
  3114. }
  3115. /// <summary>
  3116. /// OP费用录入填写详情
  3117. /// </summary>
  3118. /// <param name="dto"></param>
  3119. /// <returns></returns>
  3120. [HttpPost]
  3121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3122. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  3123. {
  3124. try
  3125. {
  3126. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  3127. if (groupData.Code != 0)
  3128. {
  3129. return Ok(JsonView(false, groupData.Msg));
  3130. }
  3131. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3132. }
  3133. catch (Exception ex)
  3134. {
  3135. return Ok(JsonView(false, ex.Message));
  3136. }
  3137. }
  3138. #endregion
  3139. #region 团组成本
  3140. /// <summary>
  3141. /// 团组成本数据初始化
  3142. /// </summary>
  3143. /// <param name="dto"></param>
  3144. /// <returns></returns>
  3145. [HttpPost]
  3146. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  3147. {
  3148. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  3149. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  3150. WHEN COUNT(*) >= 0 THEN 'True'
  3151. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  3152. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  3153. ").ToList(); //团组列表
  3154. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  3155. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  3156. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  3157. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  3158. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  3159. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  3160. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  3161. //GroupCostParameter.Add(new
  3162. // Grp_GroupCostParameter());
  3163. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  3164. return Ok(JsonView(new
  3165. {
  3166. groupList,
  3167. groupInfo,
  3168. groupChecks,
  3169. groupCost = groupCostMap,
  3170. hotelNumber,
  3171. GroupCostParameter = GroupCostParameterMap,
  3172. }));
  3173. }
  3174. /// <summary>
  3175. /// 团组成本信息保存
  3176. /// </summary>
  3177. /// <param name="dto"></param>
  3178. /// <returns></returns>
  3179. [HttpPost]
  3180. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  3181. {
  3182. JsonView jw = null;
  3183. bool isTrue = false;
  3184. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  3185. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  3186. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  3187. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  3188. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  3189. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  3190. try
  3191. {
  3192. _sqlSugar.BeginTran();
  3193. isTrue = await _GroupCostRepository.
  3194. SaveGroupCostList(Grp_groups, dto.Diid); //列表
  3195. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  3196. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  3197. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  3198. _sqlSugar.CommitTran();
  3199. jw = JsonView(true, "保存成功!", isTrue);
  3200. }
  3201. catch (Exception)
  3202. {
  3203. _sqlSugar.RollbackTran();
  3204. jw = JsonView(false);
  3205. }
  3206. return Ok(jw);
  3207. }
  3208. /// <summary>
  3209. /// 司兼导数据
  3210. /// </summary>
  3211. /// <param name="dto"></param>
  3212. /// <returns></returns>
  3213. [HttpPost]
  3214. public IActionResult GetCarGuides(CarGuidesDto dto)
  3215. {
  3216. JsonView jw = null;
  3217. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  3218. jw = JsonView(true, "获取成功!", Data);
  3219. return Ok(jw);
  3220. }
  3221. /// <summary>
  3222. /// 导游数据
  3223. /// </summary>
  3224. /// <param name="dto"></param>
  3225. /// <returns></returns>
  3226. [HttpPost]
  3227. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  3228. {
  3229. JsonView jw = null;
  3230. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  3231. // 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
  3232. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  3233. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  3234. jw = JsonView(true, "获取成功!", Data);
  3235. return Ok(jw);
  3236. }
  3237. /// <summary>
  3238. /// 成本车数据
  3239. /// </summary>
  3240. /// <param name="dto"></param>
  3241. /// <returns></returns>
  3242. [HttpPost]
  3243. public IActionResult GetCarInfo(CarGuidesDto dto)
  3244. {
  3245. JsonView jw = null;
  3246. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  3247. jw = JsonView(true, "获取成功!", Data);
  3248. return Ok(jw);
  3249. }
  3250. /// <summary>
  3251. /// 景点数据
  3252. /// </summary>
  3253. /// <param name="dto"></param>
  3254. /// <returns></returns>
  3255. [HttpPost]
  3256. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  3257. {
  3258. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  3259. return Ok(JsonView(true, "获取成功!", Data));
  3260. }
  3261. #endregion
  3262. #region 酒店预定
  3263. /// <summary>
  3264. /// 酒店预订页面初始化绑定
  3265. /// </summary>
  3266. /// <param name="dto"></param>
  3267. /// <returns></returns>
  3268. [HttpPost]
  3269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3270. public async Task<IActionResult> HotelReservationsInitialize(HotelReservationsDto dto)
  3271. {
  3272. try
  3273. {
  3274. Result groupData = await _hotelPriceRep.HotelReservationsInitialize(dto);
  3275. if (groupData.Code != 0)
  3276. {
  3277. return Ok(JsonView(false, groupData.Msg));
  3278. }
  3279. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3280. }
  3281. catch (Exception ex)
  3282. {
  3283. return Ok(JsonView(false, ex.Message));
  3284. }
  3285. }
  3286. /// <summary>
  3287. /// 根据团组Id查询酒店费用列表
  3288. /// </summary>
  3289. /// <param name="dto"></param>
  3290. /// <returns></returns>
  3291. [HttpPost]
  3292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3293. public async Task<IActionResult> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
  3294. {
  3295. try
  3296. {
  3297. Result groupData = await _hotelPriceRep.HotelReservationsByDiId(dto);
  3298. if (groupData.Code != 0)
  3299. {
  3300. return Ok(JsonView(false, groupData.Msg));
  3301. }
  3302. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3303. }
  3304. catch (Exception ex)
  3305. {
  3306. return Ok(JsonView(false, ex.Message));
  3307. }
  3308. }
  3309. /// <summary>
  3310. /// 根据酒店费用Id查询酒店费用详细
  3311. /// </summary>
  3312. /// <param name="dto"></param>
  3313. /// <returns></returns>
  3314. [HttpPost]
  3315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3316. public async Task<IActionResult> HotelReservationsById(HotelReservationsByIdDto dto)
  3317. {
  3318. try
  3319. {
  3320. Result groupData = await _hotelPriceRep.HotelReservationsById(dto);
  3321. if (groupData.Code != 0)
  3322. {
  3323. return Ok(JsonView(false, groupData.Msg));
  3324. }
  3325. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3326. }
  3327. catch (Exception ex)
  3328. {
  3329. return Ok(JsonView(false, ex.Message));
  3330. }
  3331. }
  3332. /// <summary>
  3333. /// 计算酒店付款总金额
  3334. /// </summary>
  3335. /// <param name="dto"></param>
  3336. /// <returns></returns>
  3337. [HttpPost]
  3338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3339. public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
  3340. {
  3341. try
  3342. {
  3343. Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
  3344. if (groupData.Code != 0)
  3345. {
  3346. return Ok(JsonView(false, groupData.Msg));
  3347. }
  3348. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3349. }
  3350. catch (Exception ex)
  3351. {
  3352. return Ok(JsonView(false, ex.Message));
  3353. }
  3354. }
  3355. /// <summary>
  3356. /// 酒店费用操作(Status:1.新增,2.修改)
  3357. /// </summary>
  3358. /// <param name="dto"></param>
  3359. /// <returns></returns>
  3360. [HttpPost]
  3361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3362. public async Task<IActionResult> OpHotelReservations(OpHotelReservationsData dto)
  3363. {
  3364. try
  3365. {
  3366. Result groupData = await _hotelPriceRep.OpHotelReservations(dto);
  3367. if (groupData.Code != 0)
  3368. {
  3369. return Ok(JsonView(false, groupData.Msg));
  3370. }
  3371. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3372. }
  3373. catch (Exception ex)
  3374. {
  3375. return Ok(JsonView(false, ex.Message));
  3376. }
  3377. }
  3378. /// <summary>
  3379. /// 文件上传
  3380. /// </summary>
  3381. /// <param name="file"></param>
  3382. /// <returns></returns>
  3383. [HttpPost]
  3384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3385. public async Task<IActionResult> UploadHotel(IFormFile file)
  3386. {
  3387. try
  3388. {
  3389. if (file != null)
  3390. {
  3391. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3392. //文件名称
  3393. string projectFileName = file.FileName;
  3394. //上传的文件的路径
  3395. string filePath = "";
  3396. if (!Directory.Exists(fileDir))
  3397. {
  3398. Directory.CreateDirectory(fileDir);
  3399. }
  3400. //上传的文件的路径
  3401. filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
  3402. using (FileStream fs = System.IO.File.Create(filePath))
  3403. {
  3404. file.CopyTo(fs);
  3405. fs.Flush();
  3406. }
  3407. return Ok(JsonView(true, "上传成功!", projectFileName));
  3408. }
  3409. else
  3410. {
  3411. return Ok(JsonView(false, "上传失败!"));
  3412. }
  3413. }
  3414. catch (Exception ex)
  3415. {
  3416. return Ok(JsonView(false, "程序错误!"));
  3417. throw;
  3418. }
  3419. }
  3420. /// <summary>
  3421. /// 删除指定文件
  3422. /// </summary>
  3423. /// <param name="dto"></param>
  3424. /// <returns></returns>
  3425. [HttpPost]
  3426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3427. public async Task<IActionResult> DelFileHotel(DelFileDto dto)
  3428. {
  3429. try
  3430. {
  3431. string filePath = "";
  3432. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3433. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3434. //int id = 0;
  3435. filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
  3436. // 删除该文件
  3437. try
  3438. {
  3439. System.IO.File.Delete(filePath);
  3440. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3441. {
  3442. Attachment = "",
  3443. }).ExecuteCommandAsync();
  3444. if (result != 0)
  3445. {
  3446. return Ok(JsonView(true, "成功!"));
  3447. }
  3448. else
  3449. {
  3450. return Ok(JsonView(false, "失败!"));
  3451. }
  3452. }
  3453. catch (Exception)
  3454. {
  3455. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3456. {
  3457. Attachment = "",
  3458. }).ExecuteCommandAsync();
  3459. if (result != 0)
  3460. {
  3461. return Ok(JsonView(true, "成功!"));
  3462. }
  3463. else
  3464. {
  3465. return Ok(JsonView(false, "失败!"));
  3466. }
  3467. throw;
  3468. }
  3469. }
  3470. catch (Exception ex)
  3471. {
  3472. return Ok(JsonView(false, "程序错误!"));
  3473. throw;
  3474. }
  3475. }
  3476. /// <summary>
  3477. /// 生成VOUCHER
  3478. /// </summary>
  3479. /// <param name=""></param>
  3480. /// <returns></returns>
  3481. [HttpPost]
  3482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3483. public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
  3484. {
  3485. Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
  3486. //判断数据是否完整
  3487. if (h != null)
  3488. {
  3489. if (!string.IsNullOrEmpty(h.DetermineNo))
  3490. {
  3491. string strFileName = "HotelStatement/";
  3492. Grp_DelegationInfo dele = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
  3493. if (dele != null)
  3494. strFileName += dele.TourCode;
  3495. //载入模板
  3496. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  3497. Document doc = new Document(sss);
  3498. DocumentBuilder builder = new DocumentBuilder(doc);
  3499. try
  3500. {
  3501. #region 替换Word模板书签内容
  3502. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  3503. //入住卷预定号码
  3504. if (doc.Range.Bookmarks["VNO"] != null)
  3505. {
  3506. Bookmark mark = doc.Range.Bookmarks["VNO"];
  3507. mark.Text = h.CheckNumber;
  3508. }
  3509. //酒店时间
  3510. if (doc.Range.Bookmarks["Date"] != null)
  3511. {
  3512. Bookmark mark = doc.Range.Bookmarks["Date"];
  3513. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3514. }
  3515. //团号
  3516. if (doc.Range.Bookmarks["TNo"] != null)
  3517. {
  3518. Bookmark mark = doc.Range.Bookmarks["TNo"];
  3519. mark.Text = dele.TourCode;
  3520. }
  3521. //预定号码
  3522. if (doc.Range.Bookmarks["BookingId"] != null)
  3523. {
  3524. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  3525. mark.Text = h.ReservationsNo;
  3526. }
  3527. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  3528. {
  3529. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  3530. mark.Text = h.DetermineNo;
  3531. }
  3532. //酒店城市
  3533. if (doc.Range.Bookmarks["City"] != null)
  3534. {
  3535. Bookmark mark = doc.Range.Bookmarks["City"];
  3536. mark.Text = h.City;
  3537. }
  3538. //酒店名称
  3539. if (doc.Range.Bookmarks["HName"] != null)
  3540. {
  3541. Bookmark mark = doc.Range.Bookmarks["HName"];
  3542. mark.Text = h.HotelName;
  3543. }
  3544. //酒店地址
  3545. if (doc.Range.Bookmarks["Address"] != null)
  3546. {
  3547. Bookmark mark = doc.Range.Bookmarks["Address"];
  3548. mark.Text = h.HotelAddress;
  3549. }
  3550. //酒店电话
  3551. if (doc.Range.Bookmarks["Tel"] != null)
  3552. {
  3553. Bookmark mark = doc.Range.Bookmarks["Tel"];
  3554. mark.Text = h.HotelTel;
  3555. }
  3556. //酒店传真
  3557. if (doc.Range.Bookmarks["Fax"] != null)
  3558. {
  3559. Bookmark mark = doc.Range.Bookmarks["Fax"];
  3560. if (!string.IsNullOrWhiteSpace(h.HotelFax))
  3561. {
  3562. mark.Text = h.HotelFax;
  3563. }
  3564. }
  3565. //入住时间
  3566. if (doc.Range.Bookmarks["CIn"] != null)
  3567. {
  3568. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3569. Bookmark mark = doc.Range.Bookmarks["CIn"];
  3570. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  3571. }
  3572. //退房时间
  3573. if (doc.Range.Bookmarks["COut"] != null)
  3574. {
  3575. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3576. Bookmark mark = doc.Range.Bookmarks["COut"];
  3577. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3578. }
  3579. //客户名称
  3580. if (doc.Range.Bookmarks["GName"] != null)
  3581. {
  3582. Bookmark mark = doc.Range.Bookmarks["GName"];
  3583. mark.Text = h.GuestName;
  3584. }
  3585. //房间介绍
  3586. if (doc.Range.Bookmarks["ROOM"] != null)
  3587. {
  3588. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  3589. mark.Text = h.RoomExplanation;
  3590. }
  3591. //报价描述
  3592. if (doc.Range.Bookmarks["NOTE"] != null)
  3593. {
  3594. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  3595. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == h.ReservationsWebsite);
  3596. if (ss != null)
  3597. mark.Text = ss.Name;
  3598. }
  3599. //入住时间
  3600. if (doc.Range.Bookmarks["CheckIn"] != null)
  3601. {
  3602. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3603. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  3604. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  3605. }
  3606. //退房时间
  3607. if (doc.Range.Bookmarks["CheckOut"] != null)
  3608. {
  3609. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3610. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  3611. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3612. }
  3613. //日期
  3614. if (doc.Range.Bookmarks["DT"] != null)
  3615. {
  3616. Bookmark mark = doc.Range.Bookmarks["DT"];
  3617. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3618. }
  3619. //名称
  3620. if (doc.Range.Bookmarks["VName"] != null)
  3621. {
  3622. Bookmark mark = doc.Range.Bookmarks["VName"];
  3623. mark.Text = h.HotelName;
  3624. }
  3625. //号码
  3626. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  3627. {
  3628. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  3629. mark.Text = h.CheckNumber;
  3630. }
  3631. #endregion
  3632. //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  3633. strFileName += "VOUCHER.doc";
  3634. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  3635. doc.Save(fileDir);
  3636. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  3637. return Ok(JsonView(true, "成功!", Url));
  3638. //保存为doc,并打开
  3639. }
  3640. catch (Exception ex)
  3641. {
  3642. throw;
  3643. }
  3644. }
  3645. else
  3646. {
  3647. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3648. }
  3649. }
  3650. else
  3651. {
  3652. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3653. }
  3654. }
  3655. /// <summary>
  3656. /// 导出确认单
  3657. /// </summary>
  3658. /// <param name=""></param>
  3659. /// <returns></returns>
  3660. [HttpPost]
  3661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3662. public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
  3663. {
  3664. //团组信息
  3665. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
  3666. //酒店数据
  3667. List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel == 0).ToList();
  3668. //利datatable存储
  3669. DataTable dt = new DataTable();
  3670. dt.Columns.Add("CheckInDate", typeof(string));
  3671. dt.Columns.Add("City", typeof(string));
  3672. dt.Columns.Add("Hotel", typeof(string));
  3673. dt.Columns.Add("Room", typeof(string));
  3674. for (int i = 0; i < listhoteldata.Count; i++)
  3675. {
  3676. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  3677. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  3678. while (dayStart < dayEnd)
  3679. {
  3680. string temp = "";
  3681. DataRow row = dt.NewRow();
  3682. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  3683. row["City"] = listhoteldata[i].City;
  3684. row["Hotel"] = listhoteldata[i].HotelName;
  3685. if (listhoteldata[i].SingleRoomCount > 0)
  3686. {
  3687. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  3688. }
  3689. if (listhoteldata[i].DoubleRoomCount > 0)
  3690. {
  3691. temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
  3692. }
  3693. if (listhoteldata[i].SuiteRoomCount > 0)
  3694. {
  3695. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  3696. }
  3697. if (listhoteldata[i].OtherRoomCount > 0)
  3698. {
  3699. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  3700. }
  3701. row["Room"] = temp;
  3702. dt.Rows.Add(row);
  3703. dayStart = dayStart.AddDays(1);
  3704. }
  3705. }
  3706. Dictionary<string, string> dic = new Dictionary<string, string>();
  3707. dic.Add("Dele", di.TeamName);
  3708. dic.Add("City", di.VisitCountry);
  3709. //模板路径
  3710. //string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  3711. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  3712. //载入模板
  3713. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  3714. DocumentBuilder builder = new DocumentBuilder(doc);
  3715. foreach (var key in dic.Keys)
  3716. {
  3717. builder.MoveToBookmark(key);
  3718. builder.Write(dic[key]);
  3719. }
  3720. //获取word里所有表格
  3721. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3722. //获取所填表格的序数
  3723. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3724. var rowStart = tableOne.Rows[0]; //获取第1行
  3725. try
  3726. {
  3727. //循环赋值
  3728. for (int i = 0; i < dt.Rows.Count; i++)
  3729. {
  3730. builder.MoveToCell(0, i + 1, 0, 0);
  3731. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  3732. builder.MoveToCell(0, i + 1, 1, 0);
  3733. builder.Write(dt.Rows[i]["City"].ToString());
  3734. builder.MoveToCell(0, i + 1, 2, 0);
  3735. builder.Write(dt.Rows[i]["Hotel"].ToString());
  3736. builder.MoveToCell(0, i + 1, 3, 0);
  3737. builder.Write(dt.Rows[i]["Room"].ToString());
  3738. }
  3739. }
  3740. catch
  3741. {
  3742. }
  3743. //删除多余行
  3744. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  3745. {
  3746. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  3747. }
  3748. string strFileName = di.TeamName + "酒店确认单.doc";
  3749. try
  3750. {
  3751. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  3752. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  3753. return Ok(JsonView(true, "成功", Url));
  3754. }
  3755. catch (Exception)
  3756. {
  3757. return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
  3758. throw;
  3759. }
  3760. //doc.Save(HttpUtility.UrlEncode(strFileName, Encoding.UTF8), Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);
  3761. }
  3762. /// <summary>
  3763. /// 酒店费用删除
  3764. /// </summary>
  3765. /// <param name="dto"></param>
  3766. /// <returns></returns>
  3767. [HttpPost]
  3768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3769. public async Task<IActionResult> DelHotelPrice(DelBaseDto dto)
  3770. {
  3771. try
  3772. {
  3773. var res = await _hotelPriceRep.SoftDeleteByIdAsync<Grp_HotelReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3774. if (!res)
  3775. {
  3776. return Ok(JsonView(false, "删除失败"));
  3777. }
  3778. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment()
  3779. {
  3780. IsDel = 1,
  3781. DeleteUserId = dto.DeleteUserId,
  3782. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3783. }).ExecuteCommandAsync();
  3784. return Ok(JsonView(true, "删除成功!"));
  3785. }
  3786. catch (Exception ex)
  3787. {
  3788. return Ok(JsonView(false, "程序错误!"));
  3789. throw;
  3790. }
  3791. }
  3792. #endregion
  3793. #region 团组状态
  3794. /// <summary>
  3795. /// 团组状态列表 Page
  3796. /// </summary>
  3797. /// <param name="dto">团组列表请求dto</param>
  3798. /// <returns></returns>
  3799. [HttpPost]
  3800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3801. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  3802. {
  3803. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  3804. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  3805. {
  3806. string sqlWhere = string.Empty;
  3807. if (dto.IsSure == 0) //未完成
  3808. {
  3809. sqlWhere += string.Format(@" And IsSure = 0");
  3810. }
  3811. else if (dto.IsSure == 1) //已完成
  3812. {
  3813. sqlWhere += string.Format(@" And IsSure = 1");
  3814. }
  3815. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  3816. {
  3817. string tj = dto.SearchCriteria;
  3818. 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}%')",
  3819. tj, tj, tj, tj, tj);
  3820. }
  3821. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3822. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  3823. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3824. From (
  3825. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  3826. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  3827. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  3828. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3829. From Grp_DelegationInfo gdi
  3830. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3831. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3832. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3833. Where gdi.IsDel = 0 {0}
  3834. ) temp ", sqlWhere);
  3835. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3836. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  3837. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  3838. }
  3839. else
  3840. {
  3841. return Ok(JsonView(false, "查询失败"));
  3842. }
  3843. }
  3844. /// <summary>
  3845. /// 团组状态
  3846. /// 设置操作完成
  3847. /// </summary>
  3848. /// <param name="dto">团组列表请求dto</param>
  3849. /// <returns></returns>
  3850. [HttpPost]
  3851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3852. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  3853. {
  3854. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  3855. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  3856. {
  3857. Id = dto.Id,
  3858. IsSure = 1
  3859. };
  3860. var result = await _sqlSugar.Updateable(_DelegationInfo)
  3861. .UpdateColumns(it => new { it.IsSure })
  3862. .WhereColumns(it => new { it.Id })
  3863. .ExecuteCommandAsync();
  3864. if (result > 0)
  3865. {
  3866. return Ok(JsonView(true, "操作完成!"));
  3867. }
  3868. return Ok(JsonView(false, "操作失败!"));
  3869. }
  3870. #endregion
  3871. #region 保险费用录入
  3872. /// <summary>
  3873. /// 根据团组Id查询保险费用列表
  3874. /// </summary>
  3875. /// <param name="dto"></param>
  3876. /// <returns></returns>
  3877. [HttpPost]
  3878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3879. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  3880. {
  3881. try
  3882. {
  3883. Result groupData = await _customersRep.CustomersByDiId(dto);
  3884. if (groupData.Code != 0)
  3885. {
  3886. return Ok(JsonView(false, groupData.Msg));
  3887. }
  3888. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3889. }
  3890. catch (Exception ex)
  3891. {
  3892. return Ok(JsonView(false, ex.Message));
  3893. }
  3894. }
  3895. /// <summary>
  3896. /// 根据保险费用Id查询保险费用详细
  3897. /// </summary>
  3898. /// <param name="dto"></param>
  3899. /// <returns></returns>
  3900. [HttpPost]
  3901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3902. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  3903. {
  3904. try
  3905. {
  3906. Result groupData = await _customersRep.CustomersById(dto);
  3907. if (groupData.Code != 0)
  3908. {
  3909. return Ok(JsonView(false, groupData.Msg));
  3910. }
  3911. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3912. }
  3913. catch (Exception ex)
  3914. {
  3915. return Ok(JsonView(false, ex.Message));
  3916. }
  3917. }
  3918. /// <summary>
  3919. /// 酒店预订页面初始化绑定
  3920. /// </summary>
  3921. /// <param name="dto"></param>
  3922. /// <returns></returns>
  3923. [HttpPost]
  3924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3925. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  3926. {
  3927. try
  3928. {
  3929. Result groupData = await _customersRep.CustomersInitialize(dto);
  3930. if (groupData.Code != 0)
  3931. {
  3932. return Ok(JsonView(false, groupData.Msg));
  3933. }
  3934. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3935. }
  3936. catch (Exception ex)
  3937. {
  3938. return Ok(JsonView(false, ex.Message));
  3939. }
  3940. }
  3941. /// <summary>
  3942. /// 保险费用操作(Status:1.新增,2.修改)
  3943. /// </summary>
  3944. /// <param name="dto"></param>
  3945. /// <returns></returns>
  3946. [HttpPost]
  3947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3948. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  3949. {
  3950. try
  3951. {
  3952. Result groupData = await _customersRep.OpCustomers(dto);
  3953. if (groupData.Code != 0)
  3954. {
  3955. return Ok(JsonView(false, groupData.Msg));
  3956. }
  3957. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3958. }
  3959. catch (Exception ex)
  3960. {
  3961. return Ok(JsonView(false, ex.Message));
  3962. }
  3963. }
  3964. /// <summary>
  3965. /// 文件上传
  3966. /// </summary>
  3967. /// <param name="file"></param>
  3968. /// <returns></returns>
  3969. [HttpPost]
  3970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3971. public async Task<IActionResult> UploadCus(IFormFile file)
  3972. {
  3973. try
  3974. {
  3975. if (file != null)
  3976. {
  3977. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3978. //文件名称
  3979. string projectFileName = file.FileName;
  3980. //上传的文件的路径
  3981. string filePath = "";
  3982. if (!Directory.Exists(fileDir))
  3983. {
  3984. Directory.CreateDirectory(fileDir);
  3985. }
  3986. //上传的文件的路径
  3987. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  3988. using (FileStream fs = System.IO.File.Create(filePath))
  3989. {
  3990. file.CopyTo(fs);
  3991. fs.Flush();
  3992. }
  3993. return Ok(JsonView(true, "上传成功!", projectFileName));
  3994. }
  3995. else
  3996. {
  3997. return Ok(JsonView(false, "上传失败!"));
  3998. }
  3999. }
  4000. catch (Exception ex)
  4001. {
  4002. return Ok(JsonView(false, "程序错误!"));
  4003. throw;
  4004. }
  4005. }
  4006. /// <summary>
  4007. /// 删除指定文件
  4008. /// </summary>
  4009. /// <param name="dto"></param>
  4010. /// <returns></returns>
  4011. [HttpPost]
  4012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4013. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  4014. {
  4015. try
  4016. {
  4017. string filePath = "";
  4018. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4019. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4020. //int id = 0;
  4021. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  4022. // 删除该文件
  4023. try
  4024. {
  4025. System.IO.File.Delete(filePath);
  4026. 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()
  4027. {
  4028. Attachment = "",
  4029. }).ExecuteCommandAsync();
  4030. if (result != 0)
  4031. {
  4032. return Ok(JsonView(true, "成功!"));
  4033. }
  4034. else
  4035. {
  4036. return Ok(JsonView(false, "失败!"));
  4037. }
  4038. }
  4039. catch (Exception)
  4040. {
  4041. 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()
  4042. {
  4043. Attachment = "",
  4044. }).ExecuteCommandAsync();
  4045. if (result != 0)
  4046. {
  4047. return Ok(JsonView(true, "成功!"));
  4048. }
  4049. else
  4050. {
  4051. return Ok(JsonView(false, "失败!"));
  4052. }
  4053. }
  4054. }
  4055. catch (Exception ex)
  4056. {
  4057. return Ok(JsonView(false, "程序错误!"));
  4058. throw;
  4059. }
  4060. }
  4061. /// <summary>
  4062. /// 保险费用操作(删除)
  4063. /// </summary>
  4064. /// <param name="dto"></param>
  4065. /// <returns></returns>
  4066. [HttpPost]
  4067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4068. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  4069. {
  4070. try
  4071. {
  4072. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  4073. if (!res)
  4074. {
  4075. return Ok(JsonView(false, "删除失败"));
  4076. }
  4077. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  4078. {
  4079. IsDel = 1,
  4080. DeleteUserId = dto.DeleteUserId,
  4081. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4082. }).ExecuteCommandAsync();
  4083. return Ok(JsonView(true, "删除成功!"));
  4084. }
  4085. catch (Exception ex)
  4086. {
  4087. return Ok(JsonView(false, "程序错误!"));
  4088. throw;
  4089. }
  4090. }
  4091. #endregion
  4092. }
  4093. }