GroupsController.cs 210 KB

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