GroupsController.cs 428 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268
  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. using System.IO;
  44. using StackExchange.Redis;
  45. using Org.BouncyCastle.Utilities;
  46. using Aspose.Words.Drawing;
  47. using Aspose.Cells.Charts;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using Quartz.Util;
  50. using Google.Protobuf.WellKnownTypes;
  51. using Microsoft.AspNetCore.SignalR;
  52. using OASystem.API.OAMethodLib.Hub.HubClients;
  53. using OASystem.API.OAMethodLib.Hub.Hubs;
  54. using System.Collections.Generic;
  55. using OASystem.API.OAMethodLib.JuHeAPI;
  56. using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
  57. using SixLabors.Fonts.Tables.AdvancedTypographic;
  58. using Microsoft.EntityFrameworkCore;
  59. using System.Security.Cryptography.Xml;
  60. using MathNet.Numerics;
  61. using System.Security.Policy;
  62. using System.Xml;
  63. using OASystem.Domain.Dtos.QiYeWeChat;
  64. using static NPOI.POIFS.Crypt.CryptoFunctions;
  65. using Aspose.Words.Lists;
  66. namespace OASystem.API.Controllers
  67. {
  68. /// <summary>
  69. /// 团组相关
  70. /// </summary>
  71. //[Authorize]
  72. [Route("api/[controller]/[action]")]
  73. public class GroupsController : ControllerBase
  74. {
  75. private readonly GrpScheduleRepository _grpScheduleRep;
  76. private readonly IMapper _mapper;
  77. private readonly DelegationInfoRepository _groupRepository;
  78. private readonly TaskAssignmentRepository _taskAssignmentRep;
  79. private readonly AirTicketResRepository _airTicketResRep;
  80. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  81. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  82. private readonly DelegationEnDataRepository _delegationEnDataRep;
  83. private readonly DelegationVisaRepository _delegationVisaRep;
  84. private readonly VisaPriceRepository _visaPriceRep;
  85. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  86. private readonly HotelPriceRepository _hotelPriceRep;
  87. private readonly CustomersRepository _customersRep;
  88. private readonly MessageRepository _message;
  89. private readonly SqlSugarClient _sqlSugar;
  90. private readonly TourClientListRepository _tourClientListRep;
  91. private readonly TeamRateRepository _teamRateRep;
  92. #region 成本相关
  93. private readonly CheckBoxsRepository _checkBoxs;
  94. private readonly GroupCostRepository _GroupCostRepository;
  95. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  96. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  97. #endregion
  98. private readonly SetDataRepository _setDataRep;
  99. private string url;
  100. private string path;
  101. private readonly EnterExitCostRepository _enterExitCostRep;
  102. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  103. private readonly UsersRepository _usersRep;
  104. private readonly IJuHeApiService _juHeApi;
  105. private readonly InvertedListRepository _invertedListRep;
  106. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  107. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  108. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  109. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  110. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  111. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  112. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  113. InvertedListRepository invertedListRep)
  114. {
  115. _mapper = mapper;
  116. _grpScheduleRep = grpScheduleRep;
  117. _groupRepository = groupRepository;
  118. _taskAssignmentRep = taskAssignmentRep;
  119. _airTicketResRep = airTicketResRep;
  120. _sqlSugar = sqlSugar;
  121. url = AppSettingsHelper.Get("ExcelBaseUrl");
  122. path = AppSettingsHelper.Get("ExcelBasePath");
  123. if (!System.IO.Directory.Exists(path))
  124. {
  125. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  126. }
  127. _decreasePaymentsRep = decreasePaymentsRep;
  128. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  129. _delegationEnDataRep = delegationEnDataRep;
  130. _enterExitCostRep = enterExitCostRep;
  131. _delegationVisaRep = delegationVisaRep;
  132. _message = message;
  133. _visaPriceRep = visaPriceRep;
  134. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  135. _checkBoxs = checkBoxs;
  136. _GroupCostRepository = GroupCostRepository;
  137. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  138. _GroupCostParameterRepository = GroupCostParameterRepository;
  139. _hotelPriceRep = hotelPriceRep;
  140. _customersRep = customersRep;
  141. _setDataRep = setDataRep;
  142. _tourClientListRep = tourClientListRep;
  143. _teamRateRep = teamRateRep;
  144. _hubContext = hubContext;
  145. _usersRep = usersRep;
  146. _juHeApi = juHeApi;
  147. _invertedListRep = invertedListRep;
  148. }
  149. #region 流程管控
  150. /// <summary>
  151. /// 获取团组流程管控信息
  152. /// </summary>
  153. /// <param name="paras">参数Json字符串</param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  157. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  158. {
  159. if (string.IsNullOrEmpty(_jsonDto.Paras))
  160. {
  161. return Ok(JsonView(false, "参数为空"));
  162. }
  163. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  164. if (_ScheduleDto != null)
  165. {
  166. if (_ScheduleDto.SearchType == 2)//获取列表
  167. {
  168. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  169. return Ok(JsonView(_grpScheduleViewList));
  170. }
  171. else//获取对象
  172. {
  173. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  174. if (_grpScheduleView != null)
  175. {
  176. return Ok(JsonView(_grpScheduleView));
  177. }
  178. }
  179. }
  180. else
  181. {
  182. return Ok(JsonView(false, "参数反序列化失败"));
  183. }
  184. return Ok(JsonView(false, "暂无数据!"));
  185. }
  186. /// <summary>
  187. /// 修改团组流程管控详细表数据
  188. /// </summary>
  189. /// <param name="paras"></param>
  190. /// <returns></returns>
  191. [HttpPost]
  192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  193. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  194. {
  195. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  196. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  197. .SetColumns(it => it.Duty == _detail.Duty)
  198. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  199. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  200. .SetColumns(it => it.JobContent == _detail.JobContent)
  201. .SetColumns(it => it.Remark == _detail.Remark)
  202. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  203. .Where(s => s.Id == dto.Id)
  204. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  205. .ExecuteCommandAsync();
  206. if (result > 0)
  207. {
  208. return Ok(JsonView(true, "保存成功!"));
  209. }
  210. return Ok(JsonView(false, "保存失败!"));
  211. }
  212. /// <summary>
  213. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  214. /// </summary>
  215. /// <param name="dto"></param>
  216. /// <returns></returns>
  217. [HttpPost]
  218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  219. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  220. {
  221. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  222. _detail.IsDel = 1;
  223. _detail.DeleteUserId = dto.Duty;
  224. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  225. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  226. .SetColumns(it => it.IsDel == _detail.IsDel)
  227. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  228. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  229. .Where(it => it.Id == dto.Id)
  230. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  231. //.WhereColumns(s => s.Id == dto.Id)
  232. .ExecuteCommandAsync();
  233. if (result > 0)
  234. {
  235. return Ok(JsonView(true, "删除成功!"));
  236. }
  237. return Ok(JsonView(false, "删除失败!"));
  238. }
  239. /// <summary>
  240. /// 增加团组流程管控详细表数据
  241. /// </summary>
  242. /// <param name="dto"></param>
  243. /// <returns></returns>
  244. [HttpPost]
  245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  246. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  247. {
  248. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  249. if (DateTime.Now < _detail.ExpectBeginDt)
  250. {
  251. _detail.StepStatus = 0;
  252. }
  253. else
  254. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  255. _detail.StepStatus = 1;
  256. }
  257. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  258. if (result > 0)
  259. {
  260. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  261. return Ok(JsonView(true, "添加成功!", _result));
  262. }
  263. return Ok(JsonView(false, "添加失败!"));
  264. }
  265. #endregion
  266. #region 团组基本信息
  267. /// <summary>
  268. /// 接团信息列表
  269. /// </summary>
  270. /// <param name="dto">团组列表请求dto</param>
  271. /// <returns></returns>
  272. [HttpPost]
  273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  274. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  275. {
  276. var groupData = await _groupRepository.GetGroupList(dto);
  277. if (groupData.Code != 0)
  278. {
  279. return Ok(JsonView(false, groupData.Msg));
  280. }
  281. return Ok(JsonView(groupData.Data));
  282. }
  283. /// <summary>
  284. /// 接团信息列表 Page
  285. /// </summary>
  286. /// <param name="dto">团组列表请求dto</param>
  287. /// <returns></returns>
  288. [HttpPost]
  289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  290. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  291. {
  292. #region 参数验证
  293. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  294. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  295. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  296. #region 页面操作权限验证
  297. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  298. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  299. #endregion
  300. #endregion
  301. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  302. {
  303. string sqlWhere = string.Empty;
  304. if (dto.IsSure == 0) //未完成
  305. {
  306. sqlWhere += string.Format(@" And IsSure = 0");
  307. }
  308. else if (dto.IsSure == 1) //已完成
  309. {
  310. sqlWhere += string.Format(@" And IsSure = 1");
  311. }
  312. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  313. {
  314. string tj = dto.SearchCriteria;
  315. 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}%')",
  316. tj, tj, tj, tj, tj);
  317. }
  318. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  319. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  320. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  321. JietuanOperator,IsSure,CreateTime
  322. From (
  323. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  324. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  325. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  326. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  327. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  328. From Grp_DelegationInfo gdi
  329. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  330. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  331. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  332. Where gdi.IsDel = 0 {0}
  333. ) temp", sqlWhere);
  334. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  335. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  336. #region 处理所属部门
  337. /*
  338. * 1.sq 和 gyy 等显示 市场部
  339. * 2.王鸽和主管及张总还有管理员号统一国交部
  340. * 2-1. 4 管理员 ,21 张海麟
  341. */
  342. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  343. List<int> userIds1 = new List<int>() { 4, 21 };
  344. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  345. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  346. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  347. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  348. .ToList();
  349. foreach (var item in _DelegationList)
  350. {
  351. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  352. }
  353. #endregion
  354. var _view = new
  355. {
  356. PageFuncAuth = pageFunAuthView,
  357. Data = _DelegationList
  358. };
  359. return Ok(JsonView(true, "查询成功!", _view, total));
  360. }
  361. else
  362. {
  363. return Ok(JsonView(false, "查询失败"));
  364. }
  365. }
  366. /// <summary>
  367. /// 团组列表
  368. /// </summary>
  369. /// <returns></returns>
  370. [HttpPost]
  371. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  372. {
  373. #region 参数验证
  374. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  375. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  376. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  377. #region 页面操作权限验证
  378. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  379. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  380. #endregion
  381. #endregion
  382. if (dto.PortType != 1 && dto.PortType != 2)
  383. {
  384. return Ok(JsonView(false, "查询失败!"));
  385. }
  386. string orderbyStr = "order by gdi.CreateTime Desc";
  387. string sqlWhere = string.Empty;
  388. if (dto.IsSure == 0) //未完成
  389. {
  390. sqlWhere += string.Format(@" And IsSure = 0");
  391. }
  392. else if (dto.IsSure == 1) //已完成
  393. {
  394. sqlWhere += string.Format(@" And IsSure = 1");
  395. }
  396. //团组类型
  397. if (dto.TeamDid > 0)
  398. {
  399. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  400. }
  401. //团组名称
  402. if (!string.IsNullOrEmpty(dto.TeamName))
  403. {
  404. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  405. }
  406. //客户名称
  407. if (!string.IsNullOrEmpty(dto.ClientName))
  408. {
  409. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  410. }
  411. //客户单位
  412. if (!string.IsNullOrEmpty(dto.ClientUnit))
  413. {
  414. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  415. }
  416. //出访时间
  417. if (!string.IsNullOrEmpty(dto.visitDataTime))
  418. {
  419. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  420. orderbyStr = "order by gdi.VisitDate";
  421. }
  422. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  423. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  424. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  425. JietuanOperator,IsSure,CreateTime
  426. From (
  427. Select row_number() over({0}) as Row_Number,
  428. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  429. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  430. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  431. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  432. From Grp_DelegationInfo gdi
  433. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  434. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  435. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  436. Where gdi.IsDel = 0 {1}
  437. ) temp ", orderbyStr, sqlWhere);
  438. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  439. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  440. #region 处理所属部门
  441. /*
  442. * 1.sq 和 gyy 等显示 市场部
  443. * 2.王鸽和主管及张总还有管理员号统一国交部
  444. * 2-1. 4 管理员 ,21 张海麟
  445. */
  446. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  447. List<int> userIds1 = new List<int>() { 4, 21 };
  448. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  449. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  450. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  451. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  452. .ToList();
  453. foreach (var item in _DelegationList)
  454. {
  455. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  456. }
  457. #endregion
  458. var _view = new
  459. {
  460. PageFuncAuth = pageFunAuthView,
  461. Data = _DelegationList
  462. };
  463. return Ok(JsonView(true, "查询成功!", _view, total));
  464. }
  465. /// <summary>
  466. /// 接团信息详情
  467. /// </summary>
  468. /// <param name="dto">团组info请求dto</param>
  469. /// <returns></returns>
  470. [HttpPost]
  471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  472. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  473. {
  474. var groupData = await _groupRepository.GetGroupInfo(dto);
  475. if (groupData.Code != 0)
  476. {
  477. return Ok(JsonView(false, groupData.Msg));
  478. }
  479. return Ok(JsonView(groupData.Data));
  480. }
  481. /// <summary>
  482. /// 接团信息 编辑添加
  483. /// 基础信息数据源
  484. /// </summary>
  485. /// <param name="dto"></param>
  486. /// <returns></returns>
  487. [HttpPost]
  488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  489. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  490. {
  491. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  492. if (groupData.Code != 0)
  493. {
  494. return Ok(JsonView(false, groupData.Msg));
  495. }
  496. return Ok(JsonView(groupData.Data));
  497. }
  498. /// <summary>
  499. /// 接团信息 操作(增改)
  500. /// </summary>
  501. /// <param name="dto"></param>
  502. /// <returns></returns>
  503. [HttpPost]
  504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  505. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  506. {
  507. try
  508. {
  509. var groupData = await _groupRepository.GroupOperation(dto);
  510. if (groupData.Code != 0)
  511. {
  512. return Ok(JsonView(false, groupData.Msg));
  513. }
  514. int diId = 0;
  515. //添加时 默认加入团组汇率
  516. if (dto.Status == 1) //添加
  517. {
  518. diId = groupData.Data;
  519. //添加默认币种
  520. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  521. //默认分配权限
  522. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  523. //消息提示 王鸽 主管号
  524. List<int> _managerIds = new List<int>() { 22, 32 };
  525. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  526. if (userIds.Count > 0)
  527. {
  528. userIds.Add(208);
  529. //创建团组管控
  530. GroupStepForDelegation.CreateWorkStep(diId);
  531. //发送消息
  532. string groupName = dto.TeamName;
  533. string createGroupUser = string.Empty;
  534. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  535. if (userInfo != null) createGroupUser = userInfo.CnName;
  536. string title = $"系统通知";
  537. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  538. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  539. }
  540. //默认创建倒推表
  541. await _invertedListRep._Create(dto.UserId, diId);
  542. }
  543. else if (dto.Status == 2)
  544. {
  545. diId = dto.Id;
  546. }
  547. return Ok(JsonView(true, "操作成功!", diId));
  548. }
  549. catch (Exception ex)
  550. {
  551. Logs("[response]" + JsonConvert.SerializeObject(dto));
  552. Logs(ex.Message);
  553. return Ok(JsonView(false, ex.Message));
  554. }
  555. }
  556. /// <summary>
  557. /// 接团流程操作(增改)
  558. /// 安卓端使用 建团时添加客户名单
  559. /// </summary>
  560. /// <param name="dto"></param>
  561. /// <returns></returns>
  562. [HttpPost]
  563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  564. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  565. {
  566. try
  567. {
  568. #region 参数验证
  569. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  570. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  571. #region 页面操作权限验证
  572. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  573. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  574. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  575. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  576. #endregion
  577. #endregion
  578. _sqlSugar.BeginTran();
  579. var _dto = new GroupOperationDto();
  580. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  581. var groupData = await _groupRepository.GroupOperation(_dto);
  582. if (groupData.Code != 0)
  583. {
  584. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  585. }
  586. int diId = 0;
  587. //添加时 默认加入团组汇率
  588. if (dto.Status == 1) //添加
  589. {
  590. diId = groupData.Data;
  591. //添加默认币种
  592. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  593. //默认分配权限
  594. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  595. //消息提示 王鸽 主管号
  596. List<int> _managerIds = new List<int>() { 22, 32 };
  597. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  598. if (userIds.Count > 0)
  599. {
  600. userIds.Add(208);
  601. //创建团组管控
  602. GroupStepForDelegation.CreateWorkStep(diId);
  603. //发送消息
  604. string groupName = dto.TeamName;
  605. string createGroupUser = string.Empty;
  606. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  607. if (userInfo != null) createGroupUser = userInfo.CnName;
  608. string title = $"系统通知";
  609. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  610. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  611. }
  612. }
  613. if (dto.Status == 2)
  614. {
  615. diId = dto.Id;
  616. if (diId == 0)
  617. {
  618. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  619. }
  620. }
  621. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  622. if (viewData.Code != 0)
  623. {
  624. _sqlSugar.RollbackTran();
  625. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  626. }
  627. _sqlSugar.CommitTran();
  628. return Ok(JsonView(true, "添加成功"));
  629. }
  630. catch (Exception ex)
  631. {
  632. _sqlSugar.RollbackTran();
  633. return Ok(JsonView(false, ex.Message));
  634. }
  635. }
  636. /// <summary>
  637. /// 接团信息 操作(删除)
  638. /// </summary>
  639. /// <param name="dto"></param>
  640. /// <returns></returns>
  641. [HttpPost]
  642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  643. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  644. {
  645. try
  646. {
  647. var groupData = await _groupRepository.GroupDel(dto);
  648. if (groupData.Code != 0)
  649. {
  650. return Ok(JsonView(false, groupData.Msg));
  651. }
  652. return Ok(JsonView(true));
  653. }
  654. catch (Exception ex)
  655. {
  656. Logs("[response]" + JsonConvert.SerializeObject(dto));
  657. Logs(ex.Message);
  658. return Ok(JsonView(false, ex.Message));
  659. }
  660. }
  661. /// <summary>
  662. /// 获取团组销售报价号
  663. /// 团组添加时 使用
  664. /// </summary>
  665. /// <returns></returns>
  666. [HttpPost]
  667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  668. public async Task<IActionResult> GetGroupSalesQuoteNo()
  669. {
  670. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  671. if (groupData.Code != 0)
  672. {
  673. return Ok(JsonView(false, groupData.Msg));
  674. }
  675. object salesQuoteNo = new
  676. {
  677. SalesQuoteNo = groupData.Data
  678. };
  679. return Ok(JsonView(salesQuoteNo));
  680. }
  681. /// <summary>
  682. /// 设置确认出团
  683. /// </summary>
  684. /// <param name="dto"></param>
  685. /// <returns></returns>
  686. [HttpPost]
  687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  688. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  689. {
  690. var groupData = await _groupRepository.ConfirmationGroup(dto);
  691. if (groupData.Code != 0)
  692. {
  693. return Ok(JsonView(false, groupData.Msg));
  694. }
  695. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  696. return Ok(JsonView(true, "操作成功!", groupData.Data));
  697. }
  698. /// <summary>
  699. /// 获取团组名称data And 签证国别Data
  700. /// </summary>
  701. /// <param name="dto"></param>
  702. /// <returns></returns>
  703. [HttpPost]
  704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  705. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  706. {
  707. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  708. if (groupData.Code != 0)
  709. {
  710. return Ok(JsonView(false, groupData.Msg));
  711. }
  712. return Ok(JsonView(groupData.Data));
  713. }
  714. /// <summary>
  715. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  716. /// </summary>
  717. /// <returns></returns>
  718. [HttpPost]
  719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  720. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  721. {
  722. try
  723. {
  724. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(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. catch (Exception ex)
  732. {
  733. return Ok(JsonView(false, "程序错误!"));
  734. throw;
  735. }
  736. }
  737. #endregion
  738. #region 团组&签证
  739. /// <summary>
  740. /// 根据团组Id获取签证客户信息List
  741. /// </summary>
  742. /// <param name="dto">请求dto</param>
  743. /// <returns></returns>
  744. [HttpPost]
  745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  746. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  747. {
  748. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  749. if (groupData.Code != 0)
  750. {
  751. return Ok(JsonView(false, groupData.Msg));
  752. }
  753. return Ok(JsonView(groupData.Data));
  754. }
  755. /// <summary>
  756. /// IOS获取团组签证拍照上传进度01(团组列表)
  757. /// </summary>
  758. /// <param name="dto">请求dto</param>
  759. /// <returns></returns>
  760. [HttpPost]
  761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  762. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  763. {
  764. if (dto == null)
  765. {
  766. return Ok(JsonView(false, "参数为空"));
  767. }
  768. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  769. return Ok(JsonView(visaList));
  770. }
  771. /// <summary>
  772. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  773. /// </summary>
  774. /// <returns></returns>
  775. [HttpPost]
  776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  777. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  778. {
  779. if (dto == null)
  780. {
  781. return Ok(JsonView(false, "请求错误:"));
  782. }
  783. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  784. return Ok(JsonView(list));
  785. }
  786. /// <summary>
  787. /// IOS获取团组签证拍照上传进度03(相册)
  788. /// </summary>
  789. /// <returns></returns>
  790. [HttpPost]
  791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  792. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  793. {
  794. if (dto == null)
  795. {
  796. return Ok(JsonView(false, "请求错误:"));
  797. }
  798. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  799. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  800. list.ForEach(s => s.url = url);
  801. return Ok(JsonView(list));
  802. }
  803. /// <summary>
  804. /// IOS获取团组签证拍照上传进度04(图片上传)
  805. /// </summary>
  806. /// <param name="dto"></param>
  807. /// <returns></returns>
  808. [HttpPost]
  809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  810. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  811. {
  812. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  813. //if (!string.IsNullOrEmpty(result))
  814. //{
  815. //}
  816. //else {
  817. // return Ok(JsonView(false, "上传失败"));
  818. //}
  819. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  820. int sucNum = 0;
  821. try
  822. {
  823. foreach (var item in dto.base64DataList)
  824. {
  825. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  826. string result = decodeBase64ToImage(item, imageName);
  827. if (!string.IsNullOrEmpty(result))
  828. {
  829. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  830. pic.CreateUserId = dto.CreateUserId;
  831. pic.PicName = imageName;
  832. pic.PicPath = result;
  833. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  834. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  835. if (insertResult > 0)
  836. {
  837. sucNum++;
  838. }
  839. }
  840. }
  841. }
  842. catch (Exception ex)
  843. {
  844. return Ok(JsonView(false, ex.Message));
  845. }
  846. string msg = string.Format(@"成功上传{0}张", sucNum);
  847. return Ok(JsonView(true, msg));
  848. }
  849. private string decodeBase64ToImage(string base64DataURL, string imgName)
  850. {
  851. string filename = "";//声明一个string类型的相对路径
  852. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  853. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  854. try//会有异常抛出,try,catch一下
  855. {
  856. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  857. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  858. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  859. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  860. //文件名称
  861. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  862. //上传的文件的路径
  863. string filePath = "";
  864. if (!Directory.Exists(fileDir))
  865. {
  866. Directory.CreateDirectory(fileDir);
  867. }
  868. //上传的文件的路径
  869. filePath = fileDir + filename;
  870. //string url = HttpRuntime.AppDomainAppPath.ToString();
  871. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  872. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  873. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  874. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  875. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  876. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  877. ms.Close();//关闭当前流,并释放所有与之关联的资源
  878. bitmap.Dispose();
  879. }
  880. catch (Exception e)
  881. {
  882. string massage = e.Message;
  883. Logs("IOS图片上传Error:" + massage);
  884. //filename = e.Message;
  885. }
  886. return filename;//返回相对路径
  887. }
  888. /// <summary>
  889. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  890. /// </summary>
  891. /// <param name="dto"></param>
  892. /// <returns></returns>
  893. [HttpPost]
  894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  895. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  896. {
  897. if (dto == null)
  898. {
  899. return Ok(JsonView(false, "请求错误:"));
  900. }
  901. string msg = "参数错误";
  902. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  903. {
  904. try
  905. {
  906. //_delegationVisaRep.BeginTran();
  907. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  908. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  909. .Where(s => s.Id == dto.visaProgressCustomerId)
  910. .ExecuteCommandAsync();
  911. if (updCount > 0 && dto.publishCode == 1)
  912. {
  913. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  914. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  915. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  916. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  917. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  918. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  919. if (groupData == null)
  920. {
  921. _delegationVisaRep.RollbackTran();
  922. }
  923. string title = string.Format(@"[签证进度更新]");
  924. string content = string.Format(@"测试文本");
  925. bool rst = await _message.AddMsg(new MessageDto()
  926. {
  927. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  928. IssuerId = dto.publisher,
  929. Title = title,
  930. Content = content,
  931. ReleaseTime = DateTime.Now,
  932. UIdList = new List<int> {
  933. 234
  934. }
  935. });
  936. if (rst)
  937. {
  938. return Ok(JsonView(true, "发送通知成功"));
  939. }
  940. }
  941. //_delegationVisaRep.CommitTran();
  942. }
  943. catch (Exception)
  944. {
  945. //_delegationVisaRep.RollbackTran();
  946. }
  947. }
  948. return Ok(JsonView(true, msg));
  949. }
  950. #endregion
  951. #region 团组任务分配
  952. /// <summary>
  953. /// 团组任务分配初始化
  954. /// </summary>
  955. /// <param name="dto"></param>
  956. /// <returns></returns>
  957. [HttpPost]
  958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  959. public async Task<IActionResult> GetTaskAssignmen()
  960. {
  961. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  962. if (groupData.Code != 0)
  963. {
  964. return Ok(JsonView(false, groupData.Msg));
  965. }
  966. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  967. }
  968. /// <summary>
  969. /// 团组任务分配查询
  970. /// </summary>
  971. /// <param name="dto"></param>
  972. /// <returns></returns>
  973. [HttpPost]
  974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  975. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  976. {
  977. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  978. if (groupData.Code != 0)
  979. {
  980. return Ok(JsonView(false, groupData.Msg));
  981. }
  982. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  983. }
  984. /// <summary>
  985. /// 团组任务分配操作
  986. /// </summary>
  987. /// <param name="dto"></param>
  988. /// <returns></returns>
  989. [HttpPost]
  990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  991. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  992. {
  993. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  994. if (groupData.Code != 0)
  995. {
  996. return Ok(JsonView(false, groupData.Msg));
  997. }
  998. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  999. }
  1000. #endregion
  1001. #region 团组费用审核
  1002. /// <summary>
  1003. /// 费用审核
  1004. /// 团组列表 Page
  1005. /// </summary>
  1006. /// <param name="_dto">团组列表请求dto</param>
  1007. /// <returns></returns>
  1008. [HttpPost]
  1009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1010. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1011. {
  1012. #region 参数验证
  1013. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1014. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1015. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1016. #region 页面操作权限验证
  1017. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1018. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1019. #endregion
  1020. #endregion
  1021. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1022. {
  1023. string sqlWhere = string.Empty;
  1024. if (_dto.IsSure == 0) //未完成
  1025. {
  1026. sqlWhere += string.Format(@" And IsSure = 0");
  1027. }
  1028. else if (_dto.IsSure == 1) //已完成
  1029. {
  1030. sqlWhere += string.Format(@" And IsSure = 1");
  1031. }
  1032. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1033. {
  1034. string tj = _dto.SearchCriteria;
  1035. 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}%')",
  1036. tj, tj, tj, tj, tj);
  1037. }
  1038. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1039. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1040. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1041. From (
  1042. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1043. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1044. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1045. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1046. From Grp_DelegationInfo gdi
  1047. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1048. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1049. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1050. Where gdi.IsDel = 0 {0}
  1051. ) temp ", sqlWhere);
  1052. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1053. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1054. var _view = new
  1055. {
  1056. PageFuncAuth = pageFunAuthView,
  1057. Data = _DelegationList
  1058. };
  1059. return Ok(JsonView(true, "查询成功!", _view, total));
  1060. }
  1061. else
  1062. {
  1063. return Ok(JsonView(false, "查询失败"));
  1064. }
  1065. }
  1066. /// <summary>
  1067. /// 获取团组费用审核
  1068. /// </summary>
  1069. /// <param name="paras">参数Json字符串</param>
  1070. /// <returns></returns>
  1071. [HttpPost]
  1072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1073. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1074. {
  1075. try
  1076. {
  1077. #region 参数验证
  1078. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1079. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1080. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1081. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1082. #region 页面操作权限验证
  1083. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1084. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1085. #endregion
  1086. #endregion
  1087. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1088. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1089. #region 费用清单
  1090. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1091. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1092. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1093. List<Grp_CreditCardPayment> entityList = _groupRepository
  1094. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1095. .Where(exp.ToExpression())
  1096. .ToList();
  1097. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1098. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1099. /*
  1100. * 76://酒店预订
  1101. */
  1102. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1103. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1104. .ToListAsync();
  1105. /*
  1106. * 79://车/导游地接
  1107. */
  1108. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1109. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1110. .ToListAsync();
  1111. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1112. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1113. .ToListAsync();
  1114. /*
  1115. * 80: //签证
  1116. */
  1117. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1118. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1119. .ToListAsync();
  1120. /*
  1121. *81: //邀请/公务活动
  1122. */
  1123. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1124. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1125. .ToListAsync();
  1126. /*
  1127. * 82: //团组客户保险
  1128. */
  1129. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1130. /*
  1131. * Lable = 85 机票预订
  1132. */
  1133. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1134. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1135. .ToListAsync();
  1136. /*
  1137. * 85 机票预定
  1138. */
  1139. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1140. /*
  1141. * 98 其他款项
  1142. */
  1143. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1144. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1145. .ToListAsync();
  1146. /*
  1147. * 285:收款退还
  1148. */
  1149. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1150. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1151. .ToListAsync();
  1152. /*
  1153. * 1015: //超支费用
  1154. */
  1155. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1156. /*
  1157. * 币种信息
  1158. */
  1159. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1160. /*
  1161. * 车/导游地接 费用类型
  1162. */
  1163. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1164. /*
  1165. * 用户信息
  1166. */
  1167. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1168. /*
  1169. * 费用模块
  1170. */
  1171. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1172. string priceModule = string.Empty;
  1173. if (sdPriceName != null)
  1174. {
  1175. priceModule = sdPriceName.Name;
  1176. }
  1177. /*
  1178. * 处理详情数据
  1179. */
  1180. foreach (var entity in entityList)
  1181. {
  1182. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1183. _detail.Id = entity.Id;
  1184. _detail.PriceName = priceModule;
  1185. /*
  1186. * 应付款金额
  1187. */
  1188. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1189. string PaymentCurrency_WaitPay = "Unknown";
  1190. string hotelCurrncyCode = "Unknown";
  1191. string hotelCurrncyName = "Unknown";
  1192. if (sdPaymentCurrency_WaitPay != null)
  1193. {
  1194. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1195. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1196. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1197. if (hotelCurrncyCode.Equals("CNY"))
  1198. {
  1199. entity.DayRate = 1.0000M;
  1200. }
  1201. }
  1202. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1203. /*
  1204. * 此次付款金额
  1205. */
  1206. decimal CurrPayStr = 0;
  1207. if (entity.PayPercentage == 0)
  1208. {
  1209. if (entity.PayThenMoney != 0)
  1210. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1211. }
  1212. else
  1213. {
  1214. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1215. }
  1216. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1217. /*
  1218. * 剩余尾款
  1219. */
  1220. decimal BalanceStr = 0;
  1221. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1222. BalanceStr = 0;
  1223. else
  1224. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1225. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1226. /*
  1227. * Bus名称
  1228. */
  1229. _detail.BusName = "待增加";
  1230. /*
  1231. *费用所属
  1232. */
  1233. switch (entity.CTable)
  1234. {
  1235. case 76://酒店预订
  1236. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1237. if (hotelReservations != null)
  1238. {
  1239. string GovernmentRentCode = "", GovernmentRentName = "", CityTaxCode = "", CityTaxName = "", BreakfastCode = "", BreakfastName = "";
  1240. Sys_SetData sdPaymentCurrency_GovernmentRent = currencyItems.Where(s => s.Id == hotelReservations.GovernmentRentCurrency).FirstOrDefault();
  1241. if (sdPaymentCurrency_GovernmentRent != null)
  1242. {
  1243. GovernmentRentCode = sdPaymentCurrency_GovernmentRent.Name;
  1244. GovernmentRentName = sdPaymentCurrency_GovernmentRent.Remark;
  1245. }
  1246. Sys_SetData sdPaymentCurrency_CityTax = currencyItems.Where(s => s.Id == hotelReservations.CityTaxCurrency).FirstOrDefault();
  1247. if (sdPaymentCurrency_CityTax != null)
  1248. {
  1249. CityTaxCode = sdPaymentCurrency_CityTax.Name;
  1250. CityTaxName = sdPaymentCurrency_CityTax.Remark;
  1251. }
  1252. Sys_SetData sdPaymentCurrency_Breakfast = currencyItems.Where(s => s.Id == hotelReservations.BreakfastCurrency).FirstOrDefault();
  1253. if (sdPaymentCurrency_Breakfast != null)
  1254. {
  1255. BreakfastCode = sdPaymentCurrency_Breakfast.Name;
  1256. BreakfastName = sdPaymentCurrency_Breakfast.Remark;
  1257. }
  1258. string isoppayStr = hotelReservations.Isoppay == 0 ? "是" : "否";
  1259. _detail.PriceMsgContent = $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1260. $"房间说明: {hotelReservations.Remark} <br/>" +
  1261. $"地税: {hotelReservations.GovernmentRent.ToString("#0.00")} {GovernmentRentCode} ({GovernmentRentName})<br/>" +
  1262. $"城市税: {hotelReservations.CityTax.ToString("#0.00")} {CityTaxCode} ({CityTaxName})<br/>" +
  1263. $"酒店早餐: {hotelReservations.BreakfastPrice.ToString("#0.00")} {BreakfastCode} ({BreakfastName})<br/>" +
  1264. $"酒店早餐是否由地接代付: {isoppayStr}";
  1265. _detail.PriceNameContent = hotelReservations.HotelName;
  1266. }
  1267. break;
  1268. case 79://车/导游地接
  1269. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1270. if (touristGuideGroundReservations != null)
  1271. {
  1272. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1273. {
  1274. _detail.BusName = touristGuideGroundReservations.BusName;
  1275. }
  1276. _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1277. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  1278. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1279. string priceMsg = string.Empty;
  1280. foreach (var item in touristGuideGroundReservationsContents)
  1281. {
  1282. string typeName = "Unknown";
  1283. string carCurrencyCode = "Unknown";
  1284. string carCurrencyName = "Unknown";
  1285. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1286. if (carTypeData != null) typeName = carTypeData.Name;
  1287. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1288. if (currencyData != null) {
  1289. carCurrencyCode = currencyData.Name;
  1290. carCurrencyName = currencyData.Remark;
  1291. }
  1292. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  1293. "明细:" + item.PriceContent + "<br/>" +
  1294. "备注:" + item.Remark + "<br/><br/>";
  1295. }
  1296. _detail.PriceMsgContent = priceMsg;
  1297. }
  1298. break;
  1299. case 80: //签证
  1300. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1301. if (visaInfo != null)
  1302. {
  1303. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1304. _detail.PriceMsgContent = "备注:" + visaInfo.Remark;
  1305. }
  1306. break;
  1307. case 81: //邀请/公务活动
  1308. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1309. if (_ioa != null)
  1310. {
  1311. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1312. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1313. sendCurrName = "Unknown", //快递费用币种 Name
  1314. sendCurrCode = "Unknown", //快递费用币种 Code
  1315. eventsCurrName = "Unknown", //公务活动费币种 Name
  1316. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1317. translateCurrName = "Unknown", //公务翻译费 Name
  1318. translateCurrCode = "Unknown"; //公务翻译费 Code
  1319. #region 处理费用币种
  1320. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1321. if (inviteCurrData != null)
  1322. {
  1323. inviteCurrName = inviteCurrData.Remark;
  1324. inviteCurrCode = inviteCurrData.Name;
  1325. }
  1326. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1327. if (sendCurrData != null)
  1328. {
  1329. sendCurrName = sendCurrData.Remark;
  1330. sendCurrCode = sendCurrData.Name;
  1331. }
  1332. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1333. if (eventsCurrData != null)
  1334. {
  1335. eventsCurrName = eventsCurrData.Remark;
  1336. eventsCurrCode = eventsCurrData.Name;
  1337. }
  1338. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1339. if (translateCurrData != null)
  1340. {
  1341. translateCurrName = translateCurrData.Remark;
  1342. translateCurrCode = translateCurrData.Name;
  1343. }
  1344. #endregion
  1345. _detail.PriceNameContent = _ioa.InviterArea;
  1346. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1347. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1348. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1349. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1350. $@"备注:" + _ioa.Remark + "<br/>";
  1351. }
  1352. break;
  1353. case 82: //团组客户保险
  1354. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1355. if (customers != null)
  1356. {
  1357. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1358. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1359. }
  1360. break;
  1361. case 85: //机票预订
  1362. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1363. if (jpRes != null)
  1364. {
  1365. string FlightsDescription = jpRes.FlightsDescription;
  1366. string PriceDescription = jpRes.PriceDescription;
  1367. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1368. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1369. }
  1370. break;
  1371. case 98://其他款项
  1372. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1373. if (gdpRes != null)
  1374. {
  1375. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1376. _detail.PriceNameContent = gdpRes.PriceName;
  1377. }
  1378. break;
  1379. case 285://收款退还
  1380. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1381. if (refundAndOtherMoney != null)
  1382. {
  1383. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1384. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1385. }
  1386. break;
  1387. case 751://酒店早餐
  1388. break;
  1389. case 1015://超支费用
  1390. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1391. if (groupExtraCost != null) {
  1392. _detail.PriceNameContent = groupExtraCost.PriceName;
  1393. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1394. }
  1395. break;
  1396. default:
  1397. break;
  1398. }
  1399. /*
  1400. * 申请人
  1401. */
  1402. string operatorName = " - ";
  1403. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1404. if (_opUser != null)
  1405. {
  1406. operatorName = _opUser.CnName;
  1407. }
  1408. _detail.OperatorName = operatorName;
  1409. /*
  1410. * 审核人
  1411. */
  1412. string auditOperatorName = "Unknown";
  1413. if (entity.AuditGMOperate == 0)
  1414. auditOperatorName = " - ";
  1415. else if (entity.AuditGMOperate == 4)
  1416. auditOperatorName = "自动审核";
  1417. else
  1418. {
  1419. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1420. if (_adUser != null)
  1421. {
  1422. auditOperatorName = _adUser.CnName;
  1423. }
  1424. }
  1425. _detail.AuditOperatorName = auditOperatorName;
  1426. /*
  1427. * 超预算比例
  1428. */
  1429. string overBudgetStr = "";
  1430. if (entity.ExceedBudget == -1)
  1431. overBudgetStr = sdPriceName.Name + "尚无预算";
  1432. else if (entity.ExceedBudget == 0)
  1433. overBudgetStr = "未超预算";
  1434. else
  1435. overBudgetStr = entity.ExceedBudget.ToString("P");
  1436. _detail.OverBudget = overBudgetStr;
  1437. /*
  1438. * 费用总计
  1439. */
  1440. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1441. {
  1442. CurrencyId = entity.PaymentCurrency,
  1443. CurrencyName = PaymentCurrency_WaitPay,
  1444. AmountPayable = entity.PayMoney,
  1445. ThisPayment = CurrPayStr,
  1446. BalancePayment = BalanceStr,
  1447. AuditedFunds = CurrPayStr
  1448. });
  1449. _detail.IsAuditGM = entity.IsAuditGM;
  1450. detailList.Add(_detail);
  1451. }
  1452. #endregion
  1453. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1454. /*
  1455. * 下方描述处理
  1456. */
  1457. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1458. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1459. if (ccpCurrencyPrice != null)
  1460. {
  1461. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1462. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1463. }
  1464. else
  1465. {
  1466. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1467. }
  1468. string amountPayableStr = string.Format(@"应付款总金额: ");
  1469. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1470. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1471. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1472. foreach (var item in nonDuplicat)
  1473. {
  1474. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1475. if (strs.Count > 0)
  1476. {
  1477. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1478. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1479. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1480. //单独处理此次付款金额
  1481. if (item.CurrencyId == 836) //人民币
  1482. {
  1483. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1484. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1485. }
  1486. else
  1487. {
  1488. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1489. }
  1490. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1491. //单独处理已审核费用
  1492. if (item.CurrencyId == 836) //人民币
  1493. {
  1494. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1495. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1496. }
  1497. else
  1498. {
  1499. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1500. }
  1501. }
  1502. }
  1503. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1504. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1505. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1506. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1507. var _view1 = new
  1508. {
  1509. PageFuncAuth = pageFunAuthView,
  1510. Data = _view
  1511. };
  1512. return Ok(JsonView(_view1));
  1513. }
  1514. catch (Exception ex)
  1515. {
  1516. return Ok(JsonView(false, ex.Message));
  1517. }
  1518. }
  1519. /// <summary>
  1520. /// 费用审核
  1521. /// 修改团组费用审核状态
  1522. /// </summary>
  1523. /// <param name="_dto">参数Json字符串</param>
  1524. /// <returns></returns>
  1525. [HttpPost]
  1526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1527. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1528. {
  1529. #region 参数验证
  1530. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1531. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1532. #endregion
  1533. #region 页面操作权限验证
  1534. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1535. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1536. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1537. #endregion
  1538. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1539. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1540. DateTime dtNow = DateTime.Now;
  1541. _groupRepository.BeginTran();
  1542. int rst = 0;
  1543. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1544. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1545. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1546. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1547. List<dynamic> msgDatas = new List<dynamic>();
  1548. foreach (var item in idList)
  1549. {
  1550. int CreditId = int.Parse(item);
  1551. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1552. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1553. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1554. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1555. .Where(s => s.Id == CreditId)
  1556. .ExecuteCommandAsync();
  1557. if (result < 1)
  1558. {
  1559. rst = -1;
  1560. _groupRepository.RollbackTran();
  1561. return Ok(JsonView(false, "操作失败并回滚!"));
  1562. }
  1563. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1564. if (creditData != null)
  1565. {
  1566. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1567. string groupNameStr = string.Empty;
  1568. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1569. if (groupData != null) groupNameStr = groupData.TeamName;
  1570. string creditTypeStr = string.Empty;
  1571. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1572. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1573. string creditCurrency = string.Empty;
  1574. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1575. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1576. if (creditCurrency.Equals("CNY"))
  1577. {
  1578. creditData.DayRate = 1.0000M;
  1579. }
  1580. if (creditData.PayPercentage == 0.00M)
  1581. {
  1582. creditData.PayPercentage = 100M;
  1583. }
  1584. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1585. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1586. string msgContent = "";
  1587. if (creditCurrency.Equals("CNY"))
  1588. {
  1589. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1590. }
  1591. else
  1592. {
  1593. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1594. }
  1595. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1596. }
  1597. }
  1598. if (rst == 0)
  1599. {
  1600. _groupRepository.CommitTran();
  1601. foreach (var item in msgDatas)
  1602. {
  1603. //发送消息
  1604. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1605. }
  1606. return Ok(JsonView(true, "操作成功!"));
  1607. }
  1608. return Ok(JsonView(false, "操作失败!"));
  1609. }
  1610. #endregion
  1611. #region 机票费用录入
  1612. /// <summary>
  1613. /// 机票录入当前登录人可操作团组
  1614. /// </summary>
  1615. /// <param name="dto"></param>
  1616. /// <returns></returns>
  1617. [HttpPost]
  1618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1619. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1620. {
  1621. try
  1622. {
  1623. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1624. if (groupData.Code != 0)
  1625. {
  1626. return Ok(JsonView(false, groupData.Msg));
  1627. }
  1628. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1629. }
  1630. catch (Exception ex)
  1631. {
  1632. return Ok(JsonView(false, "程序错误!"));
  1633. throw;
  1634. }
  1635. }
  1636. /// <summary>
  1637. /// 机票费用录入列表
  1638. /// </summary>
  1639. /// <param name="dto"></param>
  1640. /// <returns></returns>
  1641. [HttpPost]
  1642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1643. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1644. {
  1645. try
  1646. {
  1647. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1648. if (groupData.Code != 0)
  1649. {
  1650. return Ok(JsonView(false, groupData.Msg));
  1651. }
  1652. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1653. }
  1654. catch (Exception ex)
  1655. {
  1656. return Ok(JsonView(false, "程序错误!"));
  1657. throw;
  1658. }
  1659. }
  1660. /// <summary>
  1661. /// 根据id查询费用录入信息
  1662. /// </summary>
  1663. /// <param name="dto"></param>
  1664. /// <returns></returns>
  1665. [HttpPost]
  1666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1667. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1668. {
  1669. try
  1670. {
  1671. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1672. if (groupData.Code != 0)
  1673. {
  1674. return Ok(JsonView(false, groupData.Msg));
  1675. }
  1676. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1677. }
  1678. catch (Exception ex)
  1679. {
  1680. return Ok(JsonView(false, "程序错误!"));
  1681. throw;
  1682. }
  1683. }
  1684. /// <summary>
  1685. /// 机票费用录入操作(Status:1.新增,2.修改)
  1686. /// </summary>
  1687. /// <param name="dto"></param>
  1688. /// <returns></returns>
  1689. [HttpPost]
  1690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1691. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1692. {
  1693. try
  1694. {
  1695. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1696. if (groupData.Code != 0)
  1697. {
  1698. return Ok(JsonView(false, groupData.Msg));
  1699. }
  1700. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1701. }
  1702. catch (Exception ex)
  1703. {
  1704. return Ok(JsonView(false, "程序错误!"));
  1705. throw;
  1706. }
  1707. }
  1708. /// <summary>
  1709. /// 根据舱位类型查询接团客户名单信息
  1710. /// </summary>
  1711. /// <param name="dto"></param>
  1712. /// <returns></returns>
  1713. [HttpPost]
  1714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1715. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1716. {
  1717. try
  1718. {
  1719. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1720. if (crm_Groups.Count != 0)
  1721. {
  1722. List<dynamic> Customer = new List<dynamic>();
  1723. foreach (var item in crm_Groups)
  1724. {
  1725. var data = new
  1726. {
  1727. Id = item.Id,
  1728. Pinyin = item.Pinyin,
  1729. Name = item.LastName + item.FirstName
  1730. };
  1731. Customer.Add(data);
  1732. }
  1733. return Ok(JsonView(true, "查询成功!", Customer));
  1734. }
  1735. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1736. }
  1737. catch (Exception ex)
  1738. {
  1739. return Ok(JsonView(false, "程序错误!"));
  1740. throw;
  1741. }
  1742. }
  1743. /// <summary>
  1744. /// 根据团号获取客户信息
  1745. /// </summary>
  1746. /// <param name="dto"></param>
  1747. /// <returns></returns>
  1748. [HttpPost]
  1749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1750. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  1751. {
  1752. var jw = JsonView(false);
  1753. if (dto.DIID < 1)
  1754. {
  1755. jw.Msg += "请输入正确的diid";
  1756. return Ok(jw);
  1757. }
  1758. var arr = getSimplClientList(dto.DIID);
  1759. jw = JsonView(true, "获取成功!", arr);
  1760. return Ok(jw);
  1761. }
  1762. private List<SimplClientInfo> getSimplClientList(int diId) {
  1763. string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", diId);
  1764. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1765. return arr;
  1766. }
  1767. private string getClientNameStr(List<SimplClientInfo> list, string origin) {
  1768. string result = origin;
  1769. if (Regex.Match(origin, @"\d+,?").Value.Length > 0) {
  1770. string[] temparr = origin.Split(',');
  1771. string fistrStr = temparr[0];
  1772. int count = temparr.Count();
  1773. int tempId;
  1774. bool success = int.TryParse(fistrStr, out tempId);
  1775. if (success) {
  1776. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1777. if (tempInfo != null) {
  1778. if (count > 1)
  1779. {
  1780. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1781. }
  1782. else {
  1783. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1784. }
  1785. }
  1786. }
  1787. }
  1788. return result;
  1789. }
  1790. /// <summary>
  1791. /// 机票费用录入,删除
  1792. /// </summary>
  1793. /// <param name="dto"></param>
  1794. /// <returns></returns>
  1795. [HttpPost]
  1796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1797. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1798. {
  1799. try
  1800. {
  1801. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1802. if (res)
  1803. {
  1804. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1805. {
  1806. IsDel = 1,
  1807. DeleteUserId = dto.DeleteUserId,
  1808. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1809. }).ExecuteCommandAsync();
  1810. return Ok(JsonView(true, "删除成功!"));
  1811. }
  1812. return Ok(JsonView(false, "删除失败!"));
  1813. }
  1814. catch (Exception ex)
  1815. {
  1816. return Ok(JsonView(false, "程序错误!"));
  1817. throw;
  1818. }
  1819. }
  1820. /// <summary>
  1821. /// 导出机票录入报表
  1822. /// </summary>
  1823. /// <param name="dto"></param>
  1824. /// <returns></returns>
  1825. [HttpPost]
  1826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1827. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  1828. {
  1829. try
  1830. {
  1831. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1832. if (groupData.Code != 0)
  1833. {
  1834. return Ok(JsonView(false, groupData.Msg));
  1835. }
  1836. else
  1837. {
  1838. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1839. if (AirTicketReservations.Count != 0)
  1840. {
  1841. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1842. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1843. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1844. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1845. WorkbookDesigner designer = new WorkbookDesigner();
  1846. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1847. decimal countCost = 0;
  1848. foreach (var item in AirTicketReservations)
  1849. {
  1850. if (item.BankType == "其他")
  1851. {
  1852. item.BankNo = "--";
  1853. }
  1854. else
  1855. {
  1856. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  1857. }
  1858. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1859. item.Price = System.Decimal.Round(item.Price, 2);
  1860. countCost += Convert.ToDecimal(item.Price);
  1861. }
  1862. designer.SetDataSource("Export", AirTicketReservations);
  1863. designer.SetDataSource("ExportDiCode", diCode);
  1864. designer.SetDataSource("ExportDiName", diName);
  1865. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1866. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1867. designer.Process();
  1868. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  1869. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1870. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1871. return Ok(JsonView(true, "成功", url = rst));
  1872. }
  1873. else
  1874. {
  1875. return Ok(JsonView(false, "暂无数据!"));
  1876. }
  1877. }
  1878. }
  1879. catch (Exception ex)
  1880. {
  1881. return Ok(JsonView(false, "程序错误!"));
  1882. throw;
  1883. }
  1884. }
  1885. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1886. /// <summary>
  1887. /// 行程单导出
  1888. /// </summary>
  1889. /// <param name="dto"></param>
  1890. /// <returns></returns>
  1891. [HttpPost]
  1892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1893. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1894. {
  1895. try
  1896. {
  1897. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1898. if (groupData.Code != 0)
  1899. {
  1900. return Ok(JsonView(false, groupData.Msg));
  1901. }
  1902. else
  1903. {
  1904. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1905. if (dto.Language == "CN")
  1906. {
  1907. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1908. DocumentBuilder builder = new DocumentBuilder(doc);
  1909. int tableIndex = 0;//表格索引
  1910. //得到文档中的第一个表格
  1911. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1912. foreach (var item in _AirTicketReservations)
  1913. {
  1914. #region 处理固定数据
  1915. string[] FlightsCode = item.FlightsCode.Split('/');
  1916. if (FlightsCode.Length != 0)
  1917. {
  1918. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1919. if (_AirCompany != null)
  1920. {
  1921. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1922. }
  1923. else
  1924. {
  1925. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1926. }
  1927. }
  1928. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1929. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1930. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1931. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1932. string name = "";
  1933. foreach (string clientName in nameArray)
  1934. {
  1935. if (!name.Contains(clientName))
  1936. {
  1937. name += clientName + ",";
  1938. }
  1939. }
  1940. if (!string.IsNullOrWhiteSpace(name))
  1941. {
  1942. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1943. }
  1944. else
  1945. {
  1946. table.Range.Bookmarks["ClientName"].Text = "--";
  1947. }
  1948. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1949. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1950. table.Range.Bookmarks["JointTicket"].Text = "--";
  1951. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1952. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1953. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1954. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1955. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1956. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1957. #endregion
  1958. #region 循环数据处理
  1959. List<AirInfo> airs = new List<AirInfo>();
  1960. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1961. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1962. for (int i = 0; i < FlightsCode.Length; i++)
  1963. {
  1964. AirInfo air = new AirInfo();
  1965. string[] tempstr = DayArray[i]
  1966. .Replace("\r\n", string.Empty)
  1967. .Replace("\\r\\n", string.Empty)
  1968. .TrimStart().TrimEnd()
  1969. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1970. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1971. string starCity = "";
  1972. if (star_Three != null)
  1973. {
  1974. starCity = star_Three.AirPort;
  1975. }
  1976. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1977. string EndCity = "";
  1978. if (End_Three != null)
  1979. {
  1980. EndCity = End_Three.AirPort;
  1981. }
  1982. air.Destination = starCity + "/" + EndCity;
  1983. air.Flight = FlightsCode[i];
  1984. air.SeatingClass = item.CTypeName;
  1985. string dateTime = tempstr[2];
  1986. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1987. air.FlightDate = DateTemp;
  1988. air.DepartureTime = tempstr[5];
  1989. air.LandingTime = tempstr[6];
  1990. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1991. air.TicketStatus = "--";
  1992. air.Luggage = "--";
  1993. air.DepartureTerminal = "--";
  1994. air.LandingTerminal = "--";
  1995. airs.Add(air);
  1996. }
  1997. int row = 13;
  1998. for (int i = 0; i < airs.Count; i++)
  1999. {
  2000. if (airs.Count > 2)
  2001. {
  2002. for (int j = 0; j < airs.Count - 2; j++)
  2003. {
  2004. var CopyRow = table.Rows[12].Clone(true);
  2005. table.Rows.Add(CopyRow);
  2006. }
  2007. }
  2008. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2009. int index = 0;
  2010. foreach (PropertyInfo property in properties)
  2011. {
  2012. string value = property.GetValue(airs[i]).ToString();
  2013. Cell ishcel0 = table.Rows[row].Cells[index];
  2014. Paragraph p = new Paragraph(doc);
  2015. string s = value;
  2016. p.AppendChild(new Run(doc, s));
  2017. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2018. ishcel0.AppendChild(p);
  2019. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2020. index++;
  2021. }
  2022. row++;
  2023. }
  2024. #endregion
  2025. Paragraph lastParagraph = new Paragraph(doc);
  2026. //第一个表格末尾加段落
  2027. table.ParentNode.InsertAfter(lastParagraph, table);
  2028. //复制第一个表格
  2029. Table cloneTable = (Table)table.Clone(true);
  2030. //在文档末尾段落后面加入复制的表格
  2031. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2032. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2033. {
  2034. int rownewsIndex = 13;
  2035. for (int i = 0; i < 2; i++)
  2036. {
  2037. var CopyRow = table.Rows[12].Clone(true);
  2038. table.Rows.RemoveAt(13);
  2039. table.Rows.Add(CopyRow);
  2040. rownewsIndex++;
  2041. }
  2042. }
  2043. else
  2044. {
  2045. table.Rows.RemoveAt(12);
  2046. }
  2047. cloneTable.Rows.RemoveAt(12);
  2048. }
  2049. if (_AirTicketReservations.Count != 0)
  2050. {
  2051. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2052. if (FlightsCode.Length != 0)
  2053. {
  2054. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2055. if (_AirCompany != null)
  2056. {
  2057. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2058. }
  2059. else
  2060. {
  2061. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2062. }
  2063. }
  2064. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2065. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2066. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2067. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2068. string name = "";
  2069. foreach (string clientName in nameArray)
  2070. {
  2071. if (!name.Contains(clientName))
  2072. {
  2073. name += clientName + ",";
  2074. }
  2075. }
  2076. if (!string.IsNullOrWhiteSpace(name))
  2077. {
  2078. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2079. }
  2080. else
  2081. {
  2082. table.Range.Bookmarks["ClientName"].Text = "--";
  2083. }
  2084. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2085. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2086. table.Range.Bookmarks["JointTicket"].Text = "--";
  2087. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2088. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2089. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2090. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2091. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2092. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2093. }
  2094. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2095. //保存合并后的文档
  2096. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2097. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2098. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2099. return Ok(JsonView(true, "成功!", rst));
  2100. }
  2101. else
  2102. {
  2103. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2104. DocumentBuilder builder = new DocumentBuilder(doc);
  2105. int tableIndex = 0;//表格索引
  2106. //得到文档中的第一个表格
  2107. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2108. List<string> texts = new List<string>();
  2109. foreach (var item in _AirTicketReservations)
  2110. {
  2111. string[] FlightsCode = item.FlightsCode.Split('/');
  2112. if (FlightsCode.Length != 0)
  2113. {
  2114. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2115. if (_AirCompany != null)
  2116. {
  2117. if (!transDic.ContainsKey(_AirCompany.CnName))
  2118. {
  2119. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2120. }
  2121. }
  2122. else
  2123. {
  2124. if (!transDic.ContainsKey("--"))
  2125. {
  2126. transDic.Add("--", "--");
  2127. }
  2128. }
  2129. }
  2130. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2131. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2132. string name = "";
  2133. foreach (string clientName in nameArray)
  2134. {
  2135. name += clientName + ",";
  2136. }
  2137. if (!texts.Contains(name))
  2138. {
  2139. texts.Add(name);
  2140. }
  2141. List<AirInfo> airs = new List<AirInfo>();
  2142. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2143. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2144. for (int i = 0; i < FlightsCode.Length; i++)
  2145. {
  2146. AirInfo air = new AirInfo();
  2147. string[] tempstr = DayArray[i]
  2148. .Replace("\r\n", string.Empty)
  2149. .Replace("\\r\\n", string.Empty)
  2150. .TrimStart().TrimEnd()
  2151. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2152. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2153. if (star_Three != null)
  2154. {
  2155. if (!transDic.ContainsKey(star_Three.AirPort))
  2156. {
  2157. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2158. }
  2159. }
  2160. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2161. if (End_Three != null)
  2162. {
  2163. if (!transDic.ContainsKey(End_Three.AirPort))
  2164. {
  2165. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2166. }
  2167. }
  2168. if (!texts.Contains(item.CTypeName))
  2169. {
  2170. texts.Add(item.CTypeName);
  2171. }
  2172. }
  2173. }
  2174. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2175. if (transData.Count > 0)
  2176. {
  2177. foreach (TranslateResult item in transData)
  2178. {
  2179. if (!transDic.ContainsKey(item.Query))
  2180. {
  2181. transDic.Add(item.Query, item.Translation);
  2182. }
  2183. }
  2184. }
  2185. foreach (var item in _AirTicketReservations)
  2186. {
  2187. #region 处理固定数据
  2188. string[] FlightsCode = item.FlightsCode.Split('/');
  2189. if (FlightsCode.Length != 0)
  2190. {
  2191. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2192. if (_AirCompany != null)
  2193. {
  2194. string str = "--";
  2195. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2196. if (!string.IsNullOrEmpty(translateResult))
  2197. {
  2198. str = translateResult;
  2199. str = _airTicketResRep.Processing(str);
  2200. }
  2201. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2202. }
  2203. else
  2204. {
  2205. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2206. }
  2207. }
  2208. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2209. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2210. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2211. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2212. string names = "";
  2213. foreach (string clientName in nameArray)
  2214. {
  2215. names += clientName + ",";
  2216. }
  2217. if (!string.IsNullOrWhiteSpace(names))
  2218. {
  2219. string str = "--";
  2220. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2221. if (!string.IsNullOrEmpty(translateResult))
  2222. {
  2223. str = translateResult;
  2224. str = _airTicketResRep.Processing(str);
  2225. }
  2226. table.Range.Bookmarks["ClientName"].Text = str;
  2227. }
  2228. else
  2229. {
  2230. table.Range.Bookmarks["ClientName"].Text = "--";
  2231. }
  2232. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2233. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2234. table.Range.Bookmarks["JointTicket"].Text = "--";
  2235. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2236. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2237. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2238. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2239. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2240. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2241. #endregion
  2242. #region 循环数据处理
  2243. List<AirInfo> airs = new List<AirInfo>();
  2244. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2245. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2246. for (int i = 0; i < FlightsCode.Length; i++)
  2247. {
  2248. AirInfo air = new AirInfo();
  2249. string[] tempstr = DayArray[i]
  2250. .Replace("\r\n", string.Empty)
  2251. .Replace("\\r\\n", string.Empty)
  2252. .TrimStart().TrimEnd()
  2253. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2254. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2255. string starCity = "";
  2256. if (star_Three != null)
  2257. {
  2258. string str2 = "--";
  2259. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2260. if (!string.IsNullOrEmpty(translateResult2))
  2261. {
  2262. str2 = translateResult2;
  2263. str2 = _airTicketResRep.Processing(str2);
  2264. }
  2265. starCity = str2;
  2266. }
  2267. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2268. string EndCity = "";
  2269. if (End_Three != null)
  2270. {
  2271. string str1 = "--";
  2272. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2273. if (!string.IsNullOrEmpty(translateResult1))
  2274. {
  2275. str1 = translateResult1;
  2276. str1 = _airTicketResRep.Processing(str1);
  2277. }
  2278. EndCity = str1;
  2279. }
  2280. air.Destination = starCity + "/" + EndCity;
  2281. air.Flight = FlightsCode[i];
  2282. string str = "--";
  2283. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2284. if (!string.IsNullOrEmpty(translateResult))
  2285. {
  2286. str = translateResult;
  2287. str = _airTicketResRep.Processing(str);
  2288. }
  2289. air.SeatingClass = str;
  2290. string dateTime = tempstr[2];
  2291. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2292. air.FlightDate = DateTemp;
  2293. air.DepartureTime = tempstr[5];
  2294. air.LandingTime = tempstr[6];
  2295. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2296. air.TicketStatus = "--";
  2297. air.Luggage = "--";
  2298. air.DepartureTerminal = "--";
  2299. air.LandingTerminal = "--";
  2300. airs.Add(air);
  2301. }
  2302. int row = 13;
  2303. for (int i = 0; i < airs.Count; i++)
  2304. {
  2305. if (airs.Count > 2)
  2306. {
  2307. for (int j = 0; j < airs.Count - 2; j++)
  2308. {
  2309. var CopyRow = table.Rows[12].Clone(true);
  2310. table.Rows.Add(CopyRow);
  2311. }
  2312. }
  2313. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2314. int index = 0;
  2315. foreach (PropertyInfo property in properties)
  2316. {
  2317. string value = property.GetValue(airs[i]).ToString();
  2318. Cell ishcel0 = table.Rows[row].Cells[index];
  2319. Paragraph p = new Paragraph(doc);
  2320. string s = value;
  2321. p.AppendChild(new Run(doc, s));
  2322. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2323. ishcel0.AppendChild(p);
  2324. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2325. //ishcel0.CellFormat.VerticalAlignment=
  2326. index++;
  2327. }
  2328. row++;
  2329. }
  2330. #endregion
  2331. Paragraph lastParagraph = new Paragraph(doc);
  2332. //第一个表格末尾加段落
  2333. table.ParentNode.InsertAfter(lastParagraph, table);
  2334. //复制第一个表格
  2335. Table cloneTable = (Table)table.Clone(true);
  2336. //在文档末尾段落后面加入复制的表格
  2337. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2338. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2339. {
  2340. int rownewsIndex = 13;
  2341. for (int i = 0; i < 2; i++)
  2342. {
  2343. var CopyRow = table.Rows[12].Clone(true);
  2344. table.Rows.RemoveAt(13);
  2345. table.Rows.Add(CopyRow);
  2346. rownewsIndex++;
  2347. }
  2348. }
  2349. else
  2350. {
  2351. table.Rows.RemoveAt(12);
  2352. }
  2353. cloneTable.Rows.RemoveAt(12);
  2354. }
  2355. if (_AirTicketReservations.Count != 0)
  2356. {
  2357. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2358. if (FlightsCode.Length != 0)
  2359. {
  2360. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2361. if (_AirCompany != null)
  2362. {
  2363. string str = "--";
  2364. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2365. if (!string.IsNullOrEmpty(translateResult))
  2366. {
  2367. str = translateResult;
  2368. str = _airTicketResRep.Processing(str);
  2369. }
  2370. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2371. }
  2372. else
  2373. {
  2374. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2375. }
  2376. }
  2377. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2378. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2379. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2380. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2381. string names = "";
  2382. foreach (string clientName in nameArray)
  2383. {
  2384. names += clientName + ",";
  2385. }
  2386. if (!string.IsNullOrWhiteSpace(names))
  2387. {
  2388. string str = "--";
  2389. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2390. if (!string.IsNullOrEmpty(translateResult))
  2391. {
  2392. str = translateResult;
  2393. str = _airTicketResRep.Processing(str);
  2394. }
  2395. table.Range.Bookmarks["ClientName"].Text = str;
  2396. }
  2397. else
  2398. {
  2399. table.Range.Bookmarks["ClientName"].Text = "--";
  2400. }
  2401. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2402. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2403. table.Range.Bookmarks["JointTicket"].Text = "--";
  2404. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2405. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2406. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2407. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2408. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2409. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2410. }
  2411. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2412. //保存合并后的文档
  2413. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2414. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2415. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2416. return Ok(JsonView(true, "成功!", rst));
  2417. }
  2418. }
  2419. }
  2420. catch (Exception ex)
  2421. {
  2422. return Ok(JsonView(false, "程序错误!"));
  2423. throw;
  2424. }
  2425. }
  2426. #endregion
  2427. #region 团组增减款项 --> 其他款项
  2428. /// <summary>
  2429. /// 团组增减款项下拉框绑定
  2430. /// </summary>
  2431. /// <param name="dto"></param>
  2432. /// <returns></returns>
  2433. [HttpPost]
  2434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2435. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2436. {
  2437. try
  2438. {
  2439. #region 参数验证
  2440. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2441. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2442. #endregion
  2443. //var groupData = await GeneralMethod.PostOperationAuthReturnGroupInfosAsync(dto.UserId, dto.CTId);
  2444. ////支付方式
  2445. //List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  2446. //List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  2447. //var data = new
  2448. //{
  2449. // Payment = _Payment,
  2450. // GroupName = groupData,
  2451. //};
  2452. var res = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  2453. if (res.Code != 0)
  2454. {
  2455. return Ok(JsonView(false, res.Msg));
  2456. }
  2457. return Ok(JsonView(true, "操作成功!", res.Data));
  2458. }
  2459. catch (Exception ex)
  2460. {
  2461. return Ok(JsonView(false, ex.Message));
  2462. }
  2463. }
  2464. /// <summary>
  2465. /// 根据团组Id查询团组增减款项
  2466. /// </summary>
  2467. /// <param name="dto"></param>
  2468. /// <returns></returns>
  2469. [HttpPost]
  2470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2471. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2472. {
  2473. try
  2474. {
  2475. #region 参数验证
  2476. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2477. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2478. #endregion
  2479. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  2480. if (groupData.Code != 0)
  2481. {
  2482. return Ok(JsonView(false, groupData.Msg));
  2483. }
  2484. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2485. }
  2486. catch (Exception ex)
  2487. {
  2488. return Ok(JsonView(false, "程序错误!"));
  2489. }
  2490. }
  2491. /// <summary>
  2492. /// 团组增减款项操作(Status:1.新增,2.修改)
  2493. /// </summary>
  2494. /// <param name="dto"></param>
  2495. /// <returns></returns>
  2496. [HttpPost]
  2497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2498. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2499. {
  2500. try
  2501. {
  2502. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2503. if (groupData.Code != 0)
  2504. {
  2505. return Ok(JsonView(false, groupData.Msg));
  2506. }
  2507. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2508. }
  2509. catch (Exception ex)
  2510. {
  2511. return Ok(JsonView(false, "程序错误!"));
  2512. throw;
  2513. }
  2514. }
  2515. /// <summary>
  2516. /// 团组增减款项操作 删除
  2517. /// </summary>
  2518. /// <param name="dto"></param>
  2519. /// <returns></returns>
  2520. [HttpPost]
  2521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2522. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2523. {
  2524. try
  2525. {
  2526. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  2527. if (!res)
  2528. {
  2529. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  2530. {
  2531. IsDel = 1,
  2532. DeleteUserId = dto.DeleteUserId,
  2533. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2534. }).ExecuteCommandAsync();
  2535. return Ok(JsonView(false, "删除失败"));
  2536. }
  2537. return Ok(JsonView(true, "删除成功!"));
  2538. }
  2539. catch (Exception ex)
  2540. {
  2541. return Ok(JsonView(false, "程序错误!"));
  2542. throw;
  2543. }
  2544. }
  2545. /// <summary>
  2546. /// 根据团组增减款项Id查询
  2547. /// </summary>
  2548. /// <param name="dto"></param>
  2549. /// <returns></returns>
  2550. [HttpPost]
  2551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2552. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2553. {
  2554. try
  2555. {
  2556. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  2557. if (groupData.Code != 0)
  2558. {
  2559. return Ok(JsonView(false, groupData.Msg));
  2560. }
  2561. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2562. }
  2563. catch (Exception ex)
  2564. {
  2565. return Ok(JsonView(false, "程序错误!"));
  2566. throw;
  2567. }
  2568. }
  2569. #endregion
  2570. #region 文件上传、删除
  2571. /// <summary>
  2572. /// region 文件上传 可以带参数
  2573. /// </summary>
  2574. /// <param name="file"></param>
  2575. /// <returns></returns>
  2576. [HttpPost]
  2577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2578. public async Task<IActionResult> UploadProject(IFormFile file)
  2579. {
  2580. try
  2581. {
  2582. var TypeName = Request.Headers["TypeName"].ToString();
  2583. if (file != null)
  2584. {
  2585. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2586. //文件名称
  2587. string projectFileName = file.FileName;
  2588. //上传的文件的路径
  2589. string filePath = "";
  2590. if (TypeName == "A")//A代表团组增减款项
  2591. {
  2592. if (!Directory.Exists(fileDir))
  2593. {
  2594. Directory.CreateDirectory(fileDir);
  2595. }
  2596. //上传的文件的路径
  2597. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2598. }
  2599. else if (TypeName == "B")//B代表商邀相关文件
  2600. {
  2601. if (!Directory.Exists(fileDir))
  2602. {
  2603. Directory.CreateDirectory(fileDir);
  2604. }
  2605. //上传的文件的路径
  2606. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2607. }
  2608. using (FileStream fs = System.IO.File.Create(filePath))
  2609. {
  2610. file.CopyTo(fs);
  2611. fs.Flush();
  2612. }
  2613. return Ok(JsonView(true, "上传成功!", projectFileName));
  2614. }
  2615. else
  2616. {
  2617. return Ok(JsonView(false, "上传失败!"));
  2618. }
  2619. }
  2620. catch (Exception ex)
  2621. {
  2622. return Ok(JsonView(false, "程序错误!"));
  2623. throw;
  2624. }
  2625. }
  2626. /// <summary>
  2627. /// 删除指定文件
  2628. /// </summary>
  2629. /// <param name="dto"></param>
  2630. /// <returns></returns>
  2631. [HttpPost]
  2632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2633. public async Task<IActionResult> DelFile(DelFileDto dto)
  2634. {
  2635. try
  2636. {
  2637. var TypeName = Request.Headers["TypeName"].ToString();
  2638. string filePath = "";
  2639. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2640. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2641. int id = 0;
  2642. if (TypeName == "A")
  2643. {
  2644. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2645. // 删除该文件
  2646. System.IO.File.Delete(filePath);
  2647. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2648. }
  2649. else if (TypeName == "B")
  2650. {
  2651. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2652. // 删除该文件
  2653. System.IO.File.Delete(filePath);
  2654. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2655. }
  2656. if (id != 0)
  2657. {
  2658. return Ok(JsonView(true, "成功!"));
  2659. }
  2660. else
  2661. {
  2662. return Ok(JsonView(false, "失败!"));
  2663. }
  2664. }
  2665. catch (Exception ex)
  2666. {
  2667. return Ok(JsonView(false, "程序错误!"));
  2668. throw;
  2669. }
  2670. }
  2671. #endregion
  2672. #region 商邀费用录入
  2673. /// <summary>
  2674. /// 根据团组Id查询商邀费用列表
  2675. /// </summary>
  2676. /// <param name="dto"></param>
  2677. /// <returns></returns>
  2678. [HttpPost]
  2679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2680. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2681. {
  2682. try
  2683. {
  2684. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2685. if (groupData.Code != 0)
  2686. {
  2687. return Ok(JsonView(false, groupData.Msg));
  2688. }
  2689. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2690. }
  2691. catch (Exception ex)
  2692. {
  2693. return Ok(JsonView(false, "程序错误!"));
  2694. throw;
  2695. }
  2696. }
  2697. //
  2698. /// <summary>
  2699. /// 商邀费用 Info Page 基础数据源
  2700. /// </summary>
  2701. /// <param name="dto"></param>
  2702. /// <returns></returns>
  2703. [HttpPost]
  2704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2705. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2706. {
  2707. try
  2708. {
  2709. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2710. if (groupData.Code != 0)
  2711. {
  2712. return Ok(JsonView(false, groupData.Msg));
  2713. }
  2714. return Ok(JsonView(true, "操作成功", groupData.Data));
  2715. }
  2716. catch (Exception ex)
  2717. {
  2718. return Ok(JsonView(false, ex.Message));
  2719. throw;
  2720. }
  2721. }
  2722. /// <summary>
  2723. /// 根据商邀费用ID查询C表和商邀费用数据
  2724. /// </summary>
  2725. /// <param name="dto"></param>
  2726. /// <returns></returns>
  2727. [HttpPost]
  2728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2729. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2730. {
  2731. try
  2732. {
  2733. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2734. if (groupData.Code != 0)
  2735. {
  2736. return Ok(JsonView(false, groupData.Msg));
  2737. }
  2738. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2739. }
  2740. catch (Exception ex)
  2741. {
  2742. return Ok(JsonView(false, ex.Message));
  2743. throw;
  2744. }
  2745. }
  2746. /// <summary>
  2747. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2748. /// </summary>
  2749. /// <param name="dto"></param>
  2750. /// <returns></returns>
  2751. [HttpPost]
  2752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2753. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2754. {
  2755. try
  2756. {
  2757. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto,_setDataRep.PostCurrencyByDiid);
  2758. if (groupData.Code != 0)
  2759. {
  2760. return Ok(JsonView(false, groupData.Msg));
  2761. }
  2762. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2763. }
  2764. catch (Exception ex)
  2765. {
  2766. return Ok(JsonView(false, "程序错误!"));
  2767. throw;
  2768. }
  2769. }
  2770. /// <summary>
  2771. /// 商邀删除
  2772. /// </summary>
  2773. /// <param name="dto"></param>
  2774. /// <returns></returns>
  2775. [HttpPost]
  2776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2777. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2778. {
  2779. try
  2780. {
  2781. _sqlSugar.BeginTran();
  2782. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  2783. .SetColumns(it => new Grp_InvitationOfficialActivities()
  2784. {
  2785. IsDel = 1,
  2786. DeleteUserId = dto.DeleteUserId,
  2787. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2788. })
  2789. .Where(it => it.Id == dto.Id)
  2790. .ExecuteCommand();
  2791. if (res1 > 0)
  2792. {
  2793. int _diId = 0;
  2794. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  2795. if (_ioaInfo!=null)
  2796. {
  2797. _diId = _ioaInfo.DiId;
  2798. }
  2799. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2800. .SetColumns(a => new Grp_CreditCardPayment()
  2801. {
  2802. IsDel = 1,
  2803. DeleteUserId = dto.DeleteUserId,
  2804. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2805. })
  2806. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81 )
  2807. .ExecuteCommand();
  2808. if (res2 > 0)
  2809. {
  2810. _sqlSugar.CommitTran();
  2811. return Ok(JsonView(true, "删除成功!"));
  2812. }
  2813. }
  2814. _sqlSugar.RollbackTran();
  2815. return Ok(JsonView(false, "删除失败"));
  2816. }
  2817. catch (Exception ex)
  2818. {
  2819. _sqlSugar.RollbackTran();
  2820. return Ok(JsonView(false, ex.Message));
  2821. }
  2822. }
  2823. #endregion
  2824. #region 团组英文资料
  2825. /// <summary>
  2826. /// 查询团组英文所有资料
  2827. /// </summary>
  2828. /// <param name="dto"></param>
  2829. /// <returns></returns>
  2830. [HttpPost]
  2831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2832. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2833. {
  2834. try
  2835. {
  2836. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  2837. if (groupData.Code != 0)
  2838. {
  2839. return Ok(JsonView(false, groupData.Msg));
  2840. }
  2841. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2842. }
  2843. catch (Exception ex)
  2844. {
  2845. return Ok(JsonView(false, "程序错误!"));
  2846. throw;
  2847. }
  2848. }
  2849. /// <summary>
  2850. /// 团组英文资料操作(Status:1.新增,2.修改)
  2851. /// </summary>
  2852. /// <param name="dto"></param>
  2853. /// <returns></returns>
  2854. [HttpPost]
  2855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2856. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  2857. {
  2858. try
  2859. {
  2860. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  2861. if (groupData.Code != 0)
  2862. {
  2863. return Ok(JsonView(false, groupData.Msg));
  2864. }
  2865. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2866. }
  2867. catch (Exception ex)
  2868. {
  2869. return Ok(JsonView(false, "程序错误!"));
  2870. throw;
  2871. }
  2872. }
  2873. /// <summary>
  2874. /// 团组英文资料Id查询数据
  2875. /// </summary>
  2876. /// <param name="dto"></param>
  2877. /// <returns></returns>
  2878. [HttpPost]
  2879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2880. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  2881. {
  2882. try
  2883. {
  2884. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  2885. if (_DelegationEnData != null)
  2886. {
  2887. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  2888. }
  2889. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  2890. }
  2891. catch (Exception ex)
  2892. {
  2893. return Ok(JsonView(false, "程序错误!"));
  2894. throw;
  2895. }
  2896. }
  2897. /// <summary>
  2898. /// 团组英文资料删除
  2899. /// </summary>
  2900. /// <param name="dto"></param>
  2901. /// <returns></returns>
  2902. [HttpPost]
  2903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2904. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2905. {
  2906. try
  2907. {
  2908. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2909. if (!res)
  2910. {
  2911. return Ok(JsonView(false, "删除失败"));
  2912. }
  2913. return Ok(JsonView(true, "删除成功!"));
  2914. }
  2915. catch (Exception ex)
  2916. {
  2917. return Ok(JsonView(false, "程序错误!"));
  2918. throw;
  2919. }
  2920. }
  2921. #endregion
  2922. #region 导出邀请函
  2923. /// <summary>
  2924. /// 导出邀请函页面初始化
  2925. /// </summary>
  2926. /// <param name="dto"></param>
  2927. /// <returns></returns>
  2928. [HttpPost]
  2929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2930. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2931. {
  2932. try
  2933. {
  2934. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  2935. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2936. if (dto.DiId == 0)
  2937. {
  2938. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2939. }
  2940. else
  2941. {
  2942. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2943. }
  2944. return Ok(JsonView(true, "查询成功!", new
  2945. {
  2946. deleClient = crm_Deles,
  2947. delegations = grp_Delegations
  2948. }));
  2949. }
  2950. catch (Exception ex)
  2951. {
  2952. return Ok(JsonView(false, "程序错误!"));
  2953. throw;
  2954. }
  2955. }
  2956. /// <summary>
  2957. /// 导出邀请函
  2958. /// </summary>
  2959. /// <param name="dto"></param>
  2960. /// <returns></returns>
  2961. [HttpPost]
  2962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2963. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2964. {
  2965. #region 参数验证
  2966. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2967. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2968. #endregion
  2969. try
  2970. {
  2971. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2972. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  2973. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  2974. From Grp_TourClientList tcl
  2975. Left Join
  2976. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  2977. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  2978. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  2979. From Crm_DeleClient dc
  2980. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  2981. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  2982. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  2983. Where dc.IsDel = 0) temp
  2984. On temp.DcId =tcl.ClientId
  2985. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  2986. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  2987. List<string> texts = new List<string>();
  2988. if (datas.Count != 0)
  2989. {
  2990. foreach (TourClientListDetailsView item in datas)
  2991. {
  2992. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2993. {
  2994. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2995. }
  2996. else
  2997. {
  2998. string name = item.LastName + item.FirstName;
  2999. texts.Add(name);
  3000. }
  3001. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3002. {
  3003. if (!transDic.ContainsKey(item.Job))
  3004. {
  3005. texts.Add(item.Job);
  3006. }
  3007. }
  3008. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3009. {
  3010. texts.Add(item.CompanyFullName);
  3011. }
  3012. }
  3013. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3014. if (transData.Count > 0)
  3015. {
  3016. foreach (TranslateResult item in transData)
  3017. {
  3018. if (!transDic.ContainsKey(item.Query))
  3019. {
  3020. transDic.Add(item.Query, item.Translation);
  3021. }
  3022. }
  3023. }
  3024. List<GuestList> list = new List<GuestList>();
  3025. foreach (TourClientListDetailsView dele in datas)
  3026. {
  3027. GuestList guestList = new GuestList();
  3028. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3029. {
  3030. guestList.Name = dele.Pinyin;
  3031. }
  3032. else
  3033. {
  3034. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3035. guestList.Name = Name;
  3036. }
  3037. if (dele.Sex == 0)
  3038. {
  3039. guestList.Sex = "Male";
  3040. }
  3041. else if (dele.Sex == 1)
  3042. {
  3043. guestList.Sex = "Female";
  3044. }
  3045. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3046. if (!string.IsNullOrEmpty(dele.Job))
  3047. {
  3048. guestList.Job = dele.Job;
  3049. }
  3050. list.Add(guestList);
  3051. }
  3052. //载入模板
  3053. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3054. DocumentBuilder builder = new DocumentBuilder(doc);
  3055. //获取word里所有表格
  3056. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3057. //获取所填表格的序数
  3058. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3059. var rowStart = tableOne.Rows[0]; //获取第1行
  3060. //循环赋值
  3061. for (int i = 0; i < list.Count; i++)
  3062. {
  3063. builder.MoveToCell(0, i + 1, 0, 0);
  3064. builder.Write(list[i].Name.ToString());
  3065. builder.MoveToCell(0, i + 1, 1, 0);
  3066. builder.Write(list[i].Sex.ToString());
  3067. builder.MoveToCell(0, i + 1, 2, 0);
  3068. builder.Write(list[i].DOB.ToString());
  3069. builder.MoveToCell(0, i + 1, 3, 0);
  3070. builder.Write(list[i].Job.ToString());
  3071. }
  3072. //删除多余行
  3073. while (tableOne.Rows.Count > list.Count + 1)
  3074. {
  3075. tableOne.Rows.RemoveAt(list.Count + 1);
  3076. }
  3077. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3078. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3079. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3080. doc.Save(filePath);
  3081. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3082. return Ok(JsonView(true, "操作成功!", Url));
  3083. }
  3084. else
  3085. {
  3086. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3087. }
  3088. }
  3089. catch (Exception ex)
  3090. {
  3091. return Ok(JsonView(false, ex.Message));
  3092. throw;
  3093. }
  3094. }
  3095. #endregion
  3096. #region 团组经理模块 出入境费用
  3097. ///// <summary>
  3098. ///// 团组模块 - 出入境费用
  3099. ///// </summary>
  3100. ///// <returns></returns>
  3101. //[HttpPost]
  3102. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3103. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3104. //{
  3105. // try
  3106. // {
  3107. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3108. // if (data.Code != 0)
  3109. // {
  3110. // return Ok(JsonView(false, data.Msg));
  3111. // }
  3112. // return Ok(JsonView(true, "查询成功!"));
  3113. // }
  3114. // catch (Exception ex)
  3115. // {
  3116. // return Ok(JsonView(false, ex.Message));
  3117. // throw;
  3118. // }
  3119. //}
  3120. /// <summary>
  3121. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3122. /// </summary>
  3123. /// <returns></returns>
  3124. [HttpPost]
  3125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3126. public async Task<IActionResult> SetDayAndCostAreaChange()
  3127. {
  3128. try
  3129. {
  3130. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3131. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3132. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3133. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3134. foreach (var item in unite) //处理交集数据
  3135. {
  3136. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3137. }
  3138. foreach (var item in merge) //处理差集数据
  3139. {
  3140. int nationalTravelFeeId = 0;
  3141. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3142. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3143. else
  3144. {
  3145. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3146. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3147. }
  3148. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3149. }
  3150. //只更新dayAndCost 的 nationalTravelFeeId;
  3151. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3152. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3153. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3154. }
  3155. catch (Exception ex)
  3156. {
  3157. return Ok(JsonView(false, ex.Message));
  3158. throw;
  3159. }
  3160. }
  3161. /// <summary>
  3162. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3163. /// </summary>
  3164. /// <returns></returns>
  3165. [HttpPost]
  3166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3167. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3168. {
  3169. try
  3170. {
  3171. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3172. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3173. //SetDataInfoView
  3174. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3175. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3176. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3177. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3178. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3179. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3180. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3181. //默认币种显示
  3182. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3183. {
  3184. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 0.0000M },
  3185. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 0.0000M },
  3186. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 0.0000M },
  3187. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0000M },
  3188. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.0000M },
  3189. };
  3190. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3191. if (_currencyRate.Count > 0)
  3192. {
  3193. foreach (var item in _currencyInfos)
  3194. {
  3195. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3196. if (rateInfo != null)
  3197. {
  3198. item.Rate = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3199. }
  3200. }
  3201. }
  3202. return Ok(JsonView(true, "查询成功!", new
  3203. {
  3204. GroupNameData = groupNameData.Data,
  3205. CurrencyData = _CurrencyData,
  3206. WordTypeData = _WordTypeData,
  3207. ExcelTypeData = _ExcelTypeData,
  3208. CurrencyInit = _currencyInfos
  3209. }));
  3210. }
  3211. catch (Exception ex)
  3212. {
  3213. return Ok(JsonView(false, ex.Message));
  3214. throw;
  3215. }
  3216. }
  3217. /// <summary>
  3218. /// 团组模块 - 出入境费用 - Info
  3219. /// </summary>
  3220. /// <returns></returns>
  3221. [HttpPost]
  3222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3223. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3224. {
  3225. try
  3226. {
  3227. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3228. if (data.Code != 0)
  3229. {
  3230. return Ok(JsonView(false, data.Msg));
  3231. }
  3232. return Ok(JsonView(true, "查询成功!", data.Data));
  3233. }
  3234. catch (Exception ex)
  3235. {
  3236. return Ok(JsonView(false, ex.Message));
  3237. }
  3238. }
  3239. /// <summary>
  3240. /// 团组模块 - 出入境费用 - Add And Update
  3241. /// </summary>
  3242. /// <returns></returns>
  3243. [HttpPost]
  3244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3245. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3246. {
  3247. try
  3248. {
  3249. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3250. if (data.Code != 0)
  3251. {
  3252. return Ok(JsonView(false, data.Msg));
  3253. }
  3254. return Ok(JsonView(true, data.Msg, data.Data));
  3255. }
  3256. catch (Exception ex)
  3257. {
  3258. return Ok(JsonView(false, ex.Message));
  3259. }
  3260. }
  3261. /// <summary>
  3262. /// 团组模块 - 出入境费用 - File downlaod
  3263. /// </summary>
  3264. /// <param name="dto"></param>
  3265. /// <returns></returns>
  3266. [HttpPost]
  3267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3268. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3269. {
  3270. try
  3271. {
  3272. if (dto.DiId < 1)
  3273. {
  3274. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3275. }
  3276. if (dto.ExportType <1)
  3277. {
  3278. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3279. }
  3280. if (dto.SubTypeId < 1)
  3281. {
  3282. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3283. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3284. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3285. 3 团组成员名单 1 团组成员名单"));
  3286. }
  3287. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3288. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3289. if (_EnterExitCosts == null)
  3290. {
  3291. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3292. }
  3293. //数据源
  3294. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3295. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3296. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3297. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3298. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3299. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3300. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3301. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3302. .LeftJoin<Crm_CustomerCompany>((tcl, dc,cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3303. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3304. .Select((tcl, dc, cc) => new
  3305. {
  3306. Name = dc.LastName + dc.FirstName,
  3307. Sex = dc.Sex,
  3308. Birthday = dc.BirthDay,
  3309. Company = cc.CompanyFullName,
  3310. Job = dc.Job
  3311. })
  3312. .ToList();
  3313. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3314. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3315. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3316. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3317. if (dto.ExportType == 1) //明细表
  3318. {
  3319. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3320. {
  3321. //获取模板
  3322. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3323. //载入模板
  3324. Document doc = new Document(tempPath);
  3325. DocumentBuilder builder = new DocumentBuilder(doc);
  3326. //利用键值对存放数据
  3327. Dictionary<string, string> dic = new Dictionary<string, string>();
  3328. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3329. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3330. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3331. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3332. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3333. string row1_1 = "";
  3334. if (_EnterExitCosts.Visa > 0)
  3335. {
  3336. //insidePayTotal += _EnterExitCosts.Visa;
  3337. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3338. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3339. {
  3340. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3341. }
  3342. }
  3343. string row1_2 = "";
  3344. if (_EnterExitCosts.YiMiao > 0)
  3345. {
  3346. //insidePayTotal += _EnterExitCosts.YiMiao;
  3347. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3348. }
  3349. if (_EnterExitCosts.HeSuan > 0)
  3350. {
  3351. //insidePayTotal += _EnterExitCosts.HeSuan;
  3352. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3353. }
  3354. if (_EnterExitCosts.Service > 0)
  3355. {
  3356. //insidePayTotal += _EnterExitCosts.Service;
  3357. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3358. }
  3359. string row1_3 = "";
  3360. if (_EnterExitCosts.Safe > 0)
  3361. {
  3362. //insidePayTotal += _EnterExitCosts.Safe;
  3363. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3364. }
  3365. if (_EnterExitCosts.Ticket > 0)
  3366. {
  3367. //insidePayTotal += _EnterExitCosts.Ticket;
  3368. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3369. }
  3370. string row1 = "";
  3371. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3372. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3373. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3374. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3375. dic.Add("Row1Str", row1);
  3376. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3377. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3378. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3379. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3380. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3381. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3382. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3383. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3384. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3385. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3386. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3387. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3388. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3389. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3390. #region 填充word模板书签内容
  3391. foreach (var key in dic.Keys)
  3392. {
  3393. builder.MoveToBookmark(key);
  3394. builder.Write(dic[key]);
  3395. }
  3396. #endregion
  3397. #region 填充word表格内容
  3398. ////获读取指定表格方法二
  3399. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3400. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3401. for (int i = 0; i < dac1.Count; i++)
  3402. {
  3403. Grp_DayAndCost dac = dac1[i];
  3404. if (dac == null) continue;
  3405. builder.MoveToCell(0, i, 0, 0);
  3406. builder.Write("第" + dac.Days.ToString() + "晚:");
  3407. builder.MoveToCell(0, i, 1, 0);
  3408. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3409. builder.Write(dac.Place == null ? "" : dac.Place);
  3410. builder.MoveToCell(0, i, 2, 0);
  3411. builder.Write("费用标准:");
  3412. string curr = "";
  3413. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3414. if (currData != null)
  3415. {
  3416. curr = currData.Name;
  3417. }
  3418. builder.MoveToCell(0, i, 3, 0);
  3419. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3420. builder.MoveToCell(0, i, 4, 0);
  3421. builder.Write("费用小计:");
  3422. builder.MoveToCell(0, i, 5, 0);
  3423. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3424. }
  3425. //删除多余行
  3426. while (table1.Rows.Count > dac1.Count)
  3427. {
  3428. table1.Rows.RemoveAt(dac1.Count);
  3429. }
  3430. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3431. for (int i = 0; i < dac2.Count; i++)
  3432. {
  3433. Grp_DayAndCost dac = dac2[i];
  3434. if (dac == null) continue;
  3435. builder.MoveToCell(1, i, 0, 0);
  3436. builder.Write("第" + dac.Days.ToString() + "天:");
  3437. builder.MoveToCell(1, i, 1, 0);
  3438. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3439. builder.MoveToCell(1, i, 2, 0);
  3440. builder.Write("费用标准:");
  3441. string curr = "";
  3442. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3443. if (currData != null)
  3444. {
  3445. curr = currData.Name;
  3446. }
  3447. builder.MoveToCell(1, i, 3, 0);
  3448. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3449. builder.MoveToCell(1, i, 4, 0);
  3450. builder.Write("费用小计:");
  3451. builder.MoveToCell(1, i, 5, 0);
  3452. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3453. }
  3454. //删除多余行
  3455. while (table2.Rows.Count > dac2.Count)
  3456. {
  3457. table2.Rows.RemoveAt(dac2.Count);
  3458. }
  3459. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3460. for (int i = 0; i < dac3.Count; i++)
  3461. {
  3462. Grp_DayAndCost dac = dac3[i];
  3463. if (dac == null) continue;
  3464. builder.MoveToCell(2, i, 0, 0);
  3465. builder.Write("第" + dac.Days.ToString() + "天:");
  3466. builder.MoveToCell(2, i, 1, 0);
  3467. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3468. builder.MoveToCell(2, i, 2, 0);
  3469. builder.Write("费用标准:");
  3470. string curr = "";
  3471. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3472. if (currData != null)
  3473. {
  3474. curr = currData.Name;
  3475. }
  3476. builder.MoveToCell(2, i, 3, 0);
  3477. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3478. builder.MoveToCell(2, i, 4, 0);
  3479. builder.Write("费用小计:");
  3480. builder.MoveToCell(2, i, 5, 0);
  3481. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3482. }
  3483. //删除多余行
  3484. while (table3.Rows.Count > dac3.Count)
  3485. {
  3486. table3.Rows.RemoveAt(dac3.Count);
  3487. }
  3488. #endregion
  3489. //文件名
  3490. string strFileName = _DelegationInfo.TeamName + "出入境费用.docx";
  3491. //文件流下载
  3492. //byte[] bytes = null;
  3493. //using (MemoryStream stream = new MemoryStream())
  3494. //{
  3495. // doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  3496. // bytes = stream.ToArray();
  3497. //}
  3498. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3499. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3500. return Ok(JsonView(true, "成功", new { Url = url }));
  3501. }
  3502. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3503. {
  3504. //获取模板
  3505. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3506. //载入模板
  3507. Document doc = new Document(tempPath);
  3508. DocumentBuilder builder = new DocumentBuilder(doc);
  3509. Dictionary<string, string> dic = new Dictionary<string, string>();
  3510. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3511. {
  3512. List<string> list = new List<string>();
  3513. try
  3514. {
  3515. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3516. foreach (var item in spilitArr)
  3517. {
  3518. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3519. var depCode = spDotandEmpty[2].Substring(0, 3);
  3520. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3521. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3522. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3523. list.Add(depName);
  3524. list.Add(arrName);
  3525. }
  3526. list = list.Distinct().ToList();
  3527. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3528. }
  3529. catch (Exception)
  3530. {
  3531. dic.Add("ReturnCode", "行程录入不正确!");
  3532. }
  3533. }
  3534. else
  3535. {
  3536. dic.Add("ReturnCode", "未录入行程!");
  3537. }
  3538. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3539. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3540. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3541. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3542. {
  3543. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3544. dic.Add("Day", sp.Days.ToString());
  3545. }
  3546. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3547. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3548. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3549. dic.Add("Names", Names);
  3550. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3551. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3552. decimal dac1totalPrice = 0.00M;
  3553. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3554. foreach (var dac in dac1)
  3555. {
  3556. if (dac.SubTotal == 0.00M)
  3557. {
  3558. continue;
  3559. }
  3560. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3561. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3562. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3563. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3564. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3565. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknown";
  3566. builder.Write(currency);//币种
  3567. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3568. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3569. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3570. builder.Write("");//人数
  3571. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3572. builder.Write("");//天数
  3573. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3574. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3575. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3576. decimal rate = 0.00M;
  3577. rate = rateDatas.Find(it => it.CurrencyCode.Equals(currency))?.Rate ?? 0.00M;
  3578. builder.Write(rate.ToString("#0.0000"));//汇率
  3579. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3580. decimal rbmPrice = rate * dac.SubTotal;
  3581. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3582. accommodationStartIndex++;
  3583. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3584. }
  3585. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3586. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3587. {
  3588. table1.Rows.RemoveAt(i - 1);
  3589. foodandotherStartIndex--;
  3590. }
  3591. if (dac2.Count == dac3.Count)//国家 币种 金额
  3592. {
  3593. for (int i = 0; i < dac2.Count; i++)
  3594. {
  3595. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3596. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3597. }
  3598. }
  3599. decimal dac2totalPrice = 0.00M;
  3600. foreach (var dac in dac2)
  3601. {
  3602. if (dac.SubTotal == 0)
  3603. {
  3604. continue;
  3605. }
  3606. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3607. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3608. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3609. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknown" ;
  3610. builder.Write(currency);//币种
  3611. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3612. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3613. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3614. builder.Write("");//人数
  3615. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3616. builder.Write("");//天数
  3617. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3618. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3619. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3620. decimal rate = 0.00M;
  3621. rate = rateDatas.Find(it => it.CurrencyCode.Equals(currency))?.Rate ?? 0.00M;
  3622. builder.Write(rate.ToString("#0.0000"));//汇率
  3623. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3624. decimal rbmPrice = rate * dac.SubTotal;
  3625. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3626. foodandotherStartIndex++;
  3627. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3628. }
  3629. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3630. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3631. {
  3632. table1.Rows.RemoveAt(i - 1);
  3633. }
  3634. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3635. dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  3636. dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  3637. dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  3638. foreach (var key in dic.Keys)
  3639. {
  3640. builder.MoveToBookmark(key);
  3641. builder.Write(dic[key]);
  3642. }
  3643. //模板文件名
  3644. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  3645. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3646. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3647. return Ok(JsonView(true, "成功", new { Url = url }));
  3648. }
  3649. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  3650. {
  3651. //获取模板
  3652. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  3653. //载入模板
  3654. WorkbookDesigner designer = new WorkbookDesigner();
  3655. designer.Workbook = new Workbook(tempPath);
  3656. Dictionary<string, string> dic = new Dictionary<string, string>();
  3657. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3658. {
  3659. List<string> list = new List<string>();
  3660. try
  3661. {
  3662. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3663. foreach (var item in spilitArr)
  3664. {
  3665. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3666. var depCode = spDotandEmpty[2].Substring(0, 3);
  3667. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3668. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  3669. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  3670. list.Add(depName);
  3671. list.Add(arrName);
  3672. }
  3673. list = list.Distinct().ToList();
  3674. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3675. }
  3676. catch (Exception)
  3677. {
  3678. dic.Add("ReturnCode", "行程录入不正确!");
  3679. }
  3680. }
  3681. else
  3682. {
  3683. dic.Add("ReturnCode", "未录入行程!");
  3684. }
  3685. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3686. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3687. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3688. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3689. {
  3690. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3691. dic.Add("Day", sp.Days.ToString());
  3692. }
  3693. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3694. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3695. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3696. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  3697. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  3698. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  3699. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  3700. designer.SetDataSource("Name", Names);
  3701. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  3702. designer.SetDataSource("Day", dic["Day"] + "天");
  3703. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  3704. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  3705. int startIndex = 10;
  3706. const int startIndexcopy = 10;
  3707. if (dac2.Count == dac3.Count)//国家 币种 金额
  3708. {
  3709. for (int i = 0; i < dac2.Count; i++)
  3710. {
  3711. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3712. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3713. }
  3714. }
  3715. DataTable dtdac1 = new DataTable();
  3716. List<string> place = new List<string>();
  3717. dtdac1.Columns.AddRange(new DataColumn[] {
  3718. new DataColumn(){ ColumnName = "city"},
  3719. new DataColumn(){ ColumnName = "curr"},
  3720. new DataColumn(){ ColumnName = "criterion"},
  3721. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3722. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3723. new DataColumn(){ ColumnName = "cost", DataType = typeof(float)},
  3724. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3725. new DataColumn(){ ColumnName = "costRMB"},
  3726. });
  3727. DataTable dtdac2 = new DataTable();
  3728. dtdac2.Columns.AddRange(new DataColumn[] {
  3729. new DataColumn(){ ColumnName = "city"},
  3730. new DataColumn(){ ColumnName = "curr"},
  3731. new DataColumn(){ ColumnName = "criterion"},
  3732. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3733. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3734. new DataColumn(){ ColumnName = "cost", DataType = typeof(float)},
  3735. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3736. new DataColumn(){ ColumnName = "costRMB"},
  3737. });
  3738. dtdac1.TableName = "tb1";
  3739. dtdac2.TableName = "tb2";
  3740. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  3741. foreach (var item in dac1)
  3742. {
  3743. item.Place = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
  3744. if (place.Contains(item.Place))
  3745. {
  3746. continue;
  3747. }
  3748. DataRow row = dtdac1.NewRow();
  3749. row["city"] = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
  3750. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Name ?? "Unknwon";
  3751. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3752. row["curr"] = currency;
  3753. row["rate"] = rate;
  3754. row["criterion"] = item.Cost;
  3755. row["number"] = 1;
  3756. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  3757. //row["costRMB"] = rbmPrice;
  3758. dtdac1.Rows.Add(row);
  3759. place.Add(item.Place);
  3760. }
  3761. place = new List<string>();
  3762. foreach (var item in dac2)
  3763. {
  3764. item.Place = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
  3765. if (place.Contains(item.Place))
  3766. {
  3767. continue;
  3768. }
  3769. DataRow row = dtdac2.NewRow();
  3770. row["city"] = item.Place;
  3771. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Name ?? "Unknwon";
  3772. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3773. row["curr"] = currency;
  3774. row["rate"] = rate;
  3775. row["criterion"] = item.Cost;
  3776. row["number"] = 1;
  3777. row["day"] = dac2.FindAll(x => x.Place == item.Place).Count;
  3778. //row["cost"] = item.SubTotal;
  3779. //row["costRMB"] = rbmPrice;
  3780. dtdac2.Rows.Add(row);
  3781. place.Add(item.Place);
  3782. //dac2totalPrice += rbmPrice;
  3783. }
  3784. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  3785. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  3786. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3787. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  3788. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元,公务舱:{_EnterExitCosts.OutsaideGWPay.ToString("#0.00")}元";
  3789. string cellStr = $" 5.其他费用(签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,保险费 :{_EnterExitCosts.Safe.ToString("#0.00")}元)";
  3790. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + _EnterExitCosts.Visa + _EnterExitCosts.Safe;
  3791. string celllastStr = $" 经审核,住宿费 {dac1totalPrice.ToString("#0.00")} 元,伙食费和公杂费 {dac2totalPrice.ToString(".00")} 元,培训费 元,国际旅费 {(_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00")} 元,其他费用 {(_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00")} 元,本次出国经费预算合计为 {s.ToString("#0.00")} 元。其中:市本级安排 。";
  3792. designer.SetDataSource("cell4Str", cell4Str);
  3793. designer.SetDataSource("cellStr", cellStr);
  3794. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  3795. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  3796. designer.SetDataSource("celllastStr", celllastStr);
  3797. Workbook wb = designer.Workbook;
  3798. var sheet = wb.Worksheets[0];
  3799. //绑定datatable数据集
  3800. designer.SetDataSource(dtdac1);
  3801. designer.SetDataSource(dtdac2);
  3802. designer.Process();
  3803. var rowStart = dtdac1.Rows.Count;
  3804. while (rowStart > 0)
  3805. {
  3806. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  3807. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  3808. startIndex++;
  3809. rowStart--;
  3810. }
  3811. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  3812. startIndex += 1; //总计行
  3813. rowStart = dtdac2.Rows.Count;
  3814. while (rowStart > 0)
  3815. {
  3816. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  3817. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  3818. startIndex++;
  3819. rowStart--;
  3820. }
  3821. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  3822. wb.CalculateFormula(true);
  3823. //模板文件名
  3824. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  3825. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3826. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3827. return Ok(JsonView(true, "成功", new { Url = url }));
  3828. }
  3829. }
  3830. else if (dto.ExportType == 2) //表格
  3831. {
  3832. //利用键值对存放数据
  3833. Dictionary<string, string> dic = new Dictionary<string, string>();
  3834. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3835. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3836. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3837. dic.Add("Day", sp.Days.ToString());
  3838. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3839. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  3840. {
  3841. //获取模板
  3842. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  3843. //载入模板
  3844. Document doc = new Document(tempPath);
  3845. DocumentBuilder builder = new DocumentBuilder(doc);
  3846. dic.Add("TeamName", _DelegationInfo.TeamName);
  3847. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3848. dic.Add("TellPhone", _DelegationInfo.TellPhone);
  3849. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  3850. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  3851. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3852. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3853. int rowCount = 10;//总人数行
  3854. int startRowIndex = 7; //起始行
  3855. for (int i = 0; i < DeleClientList.Count; i++)
  3856. {
  3857. builder.MoveToCell(0, startRowIndex, 0, 0);
  3858. builder.Write(DeleClientList[i].Name); //出国人员姓名
  3859. builder.MoveToCell(0, startRowIndex, 1, 0);
  3860. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  3861. builder.Write(sex);//性别
  3862. builder.MoveToCell(0, startRowIndex, 2, 0);
  3863. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  3864. builder.MoveToCell(0, startRowIndex, 3, 0);
  3865. builder.Write(DeleClientList[i].Company);//工作单位
  3866. builder.MoveToCell(0, startRowIndex, 4, 0);
  3867. builder.Write(DeleClientList[i].Job);//职务及级别
  3868. builder.MoveToCell(0, startRowIndex, 5, 0);
  3869. builder.Write("");//人员属性
  3870. builder.MoveToCell(0, startRowIndex, 6, 0);
  3871. builder.Write("");//上次出国时间
  3872. startRowIndex++;
  3873. }
  3874. int nullRow = rowCount - DeleClientList.Count;//空行
  3875. for (int i = 0; i < nullRow; i++)
  3876. {
  3877. table1.Rows.Remove(table1.Rows[startRowIndex]);
  3878. }
  3879. foreach (var key in dic.Keys)
  3880. {
  3881. builder.MoveToBookmark(key);
  3882. builder.Write(dic[key]);
  3883. }
  3884. //模板文件名
  3885. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  3886. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3887. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3888. return Ok(JsonView(true, "成功", new { Url = url }));
  3889. }
  3890. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  3891. {
  3892. //获取模板
  3893. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  3894. //载入模板
  3895. Document doc = new Document(tempPath);
  3896. DocumentBuilder builder = new DocumentBuilder(doc);
  3897. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  3898. dic.Add("Names", Names);
  3899. int accommodationStartIndex = 6;
  3900. int foodandotherStartIndex = 19;//
  3901. int accommodationRows = 12, foodandotherRows = 12;
  3902. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  3903. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  3904. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3905. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3906. decimal dac1totalPrice = 0.00M;
  3907. foreach (var dac in dac1)
  3908. {
  3909. if (dac.SubTotal == 0)
  3910. {
  3911. continue;
  3912. }
  3913. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3914. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3915. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3916. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3917. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3918. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknwon";
  3919. builder.Write(currency);//币种
  3920. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3921. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3922. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3923. builder.Write("");//人数
  3924. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3925. builder.Write("");//天数
  3926. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3927. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3928. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3929. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3930. builder.Write(rate.ToString("#0.0000"));//汇率
  3931. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3932. decimal rbmPrice = rate * dac.SubTotal;
  3933. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3934. accommodationStartIndex++;
  3935. dac1totalPrice += rbmPrice;
  3936. }
  3937. dic.Add("dac1totalPrice", dac1totalPrice.ToString());
  3938. if (dac2.Count == dac3.Count)//国家 币种 金额
  3939. {
  3940. for (int i = 0; i < dac2.Count; i++)
  3941. {
  3942. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3943. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3944. }
  3945. }
  3946. decimal dac2totalPrice = 0.00M;
  3947. foreach (var dac in dac2)
  3948. {
  3949. if (dac.SubTotal == 0)
  3950. {
  3951. continue;
  3952. }
  3953. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3954. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3955. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3956. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknwon";
  3957. builder.Write(currency);//币种
  3958. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3959. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3960. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3961. builder.Write("");//人数
  3962. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3963. builder.Write("");//天数
  3964. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3965. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3966. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3967. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3968. builder.Write(rate.ToString());//汇率
  3969. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3970. decimal rbmPrice = rate * dac.SubTotal;
  3971. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3972. foodandotherStartIndex++;
  3973. dac2totalPrice += rbmPrice;
  3974. }
  3975. dic.Add("dac2totalPrice", dac2totalPrice.ToString());
  3976. //删除空行
  3977. if (dac1.Count < accommodationRows)
  3978. {
  3979. int nullRow = accommodationRows - dac1.Count;
  3980. }
  3981. foreach (var key in dic.Keys)
  3982. {
  3983. builder.MoveToBookmark(key);
  3984. builder.Write(dic[key]);
  3985. }
  3986. //模板文件名
  3987. string strFileName = $"省级单位出(境)经费报销单.docx";
  3988. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3989. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3990. return Ok(JsonView(true, "成功", new { Url = url }));
  3991. }
  3992. }
  3993. else if (dto.ExportType == 3)
  3994. {
  3995. if (dto.SubTypeId == 1) //团组成员名单
  3996. {
  3997. if (DeleClientList.Count < 1)
  3998. {
  3999. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4000. }
  4001. //获取模板
  4002. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4003. //载入模板
  4004. Document doc = new Document(tempPath);
  4005. DocumentBuilder builder = new DocumentBuilder(doc);
  4006. //获取word里所有表格
  4007. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4008. //获取所填表格的序数
  4009. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4010. var rowStart = tableOne.Rows[0]; //获取第1行
  4011. //循环赋值
  4012. for (int i = 0; i < DeleClientList.Count; i++)
  4013. {
  4014. builder.MoveToCell(0, i + 1, 0, 0);
  4015. builder.Write(DeleClientList[i].Name);
  4016. builder.MoveToCell(0, i + 1, 1, 0);
  4017. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4018. builder.Write(sex);
  4019. builder.MoveToCell(0, i + 1, 2, 0);
  4020. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4021. builder.MoveToCell(0, i + 1, 3, 0);
  4022. builder.Write(DeleClientList[i].Company);
  4023. builder.MoveToCell(0, i + 1, 4, 0);
  4024. builder.Write(DeleClientList[i].Job);
  4025. }
  4026. //删除多余行
  4027. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4028. {
  4029. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4030. }
  4031. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4032. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4033. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4034. return Ok(JsonView(true, "成功", new { Url = url }));
  4035. }
  4036. }
  4037. return Ok(JsonView(false,"操作失败!"));
  4038. }
  4039. catch (Exception ex)
  4040. {
  4041. return Ok(JsonView(false, ex.Message));
  4042. }
  4043. }
  4044. /// <summary>
  4045. /// 团组模块 - 出入境费用 - 明细表导出
  4046. /// </summary>
  4047. /// <returns></returns>
  4048. [HttpPost]
  4049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4050. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4051. {
  4052. try
  4053. {
  4054. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4055. if (data.Code != 0)
  4056. {
  4057. return Ok(JsonView(false, data.Msg));
  4058. }
  4059. return Ok(JsonView(true, data.Msg, data.Data));
  4060. }
  4061. catch (Exception ex)
  4062. {
  4063. return Ok(JsonView(false, ex.Message));
  4064. }
  4065. }
  4066. /// <summary>
  4067. /// 团组模块 - 出入境费用 - 子项删除
  4068. /// </summary>
  4069. /// <returns></returns>
  4070. [HttpPost]
  4071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4072. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4073. {
  4074. try
  4075. {
  4076. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4077. if (data.Code != 0)
  4078. {
  4079. return Ok(JsonView(false, data.Msg));
  4080. }
  4081. return Ok(JsonView(true, "操作成功!", data.Data));
  4082. }
  4083. catch (Exception ex)
  4084. {
  4085. return Ok(JsonView(false, ex.Message));
  4086. }
  4087. }
  4088. /// <summary>
  4089. /// 团组模块 - 出入境国家费用标准 List
  4090. /// </summary>
  4091. /// <returns></returns>
  4092. [HttpPost]
  4093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4094. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4095. {
  4096. try
  4097. {
  4098. Stopwatch sw = new Stopwatch();
  4099. sw.Start();
  4100. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4101. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4102. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4103. Where gntf.Isdel = 0");
  4104. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4105. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4106. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4107. //foreach (var item in nationalTravel)
  4108. //{
  4109. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4110. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4111. // if (otherData != null)
  4112. // {
  4113. // cityData.Remove(otherData);
  4114. // cityData.Add(otherData);
  4115. // }
  4116. // nationalTravelFeeData1.Add(new
  4117. // {
  4118. // Country = item.Country,
  4119. // CityData = cityData
  4120. // });
  4121. //}
  4122. sw.Stop();
  4123. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4124. }
  4125. catch (Exception ex)
  4126. {
  4127. return Ok(JsonView(false, ex.Message));
  4128. throw;
  4129. }
  4130. }
  4131. /// <summary>
  4132. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4133. /// </summary>
  4134. /// <returns></returns>
  4135. [HttpPost]
  4136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4137. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4138. {
  4139. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4140. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4141. List<string> countryData = new List<string>();
  4142. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4143. countryData = countryData.Distinct().ToList();
  4144. List<dynamic> dataSource = new List<dynamic>();
  4145. foreach (var item in countryData)
  4146. {
  4147. List<string> cityData1 = new List<string>();
  4148. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4149. var countryData2 = new
  4150. {
  4151. CountryName = item,
  4152. CityData = cityData1
  4153. };
  4154. dataSource.Add(countryData2);
  4155. }
  4156. return Ok(JsonView(true, "查询成功!", dataSource));
  4157. }
  4158. /// <summary>
  4159. /// 团组模块 - 出入境国家费用标准 Page List
  4160. /// </summary>
  4161. /// <returns></returns>
  4162. [HttpPost]
  4163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4164. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4165. {
  4166. int portId = dto.PortType;
  4167. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4168. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4169. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4170. string whereSql = string.Empty;
  4171. if (!string.IsNullOrEmpty(dto.Country))
  4172. {
  4173. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4174. }
  4175. if (!string.IsNullOrEmpty(dto.City))
  4176. {
  4177. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4178. }
  4179. string pageSql = string.Format(@"Select * From (
  4180. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4181. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4182. From Grp_NationalTravelFee gntf
  4183. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4184. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4185. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4186. RefAsync<int> total = 0;
  4187. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4188. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4189. }
  4190. /// <summary>
  4191. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4192. /// </summary>
  4193. /// <returns></returns>
  4194. [HttpPost]
  4195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4196. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4197. {
  4198. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4199. int portId = dto.PortType;
  4200. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4201. string whereSql = string.Empty;
  4202. if (!string.IsNullOrEmpty(dto.Country))
  4203. {
  4204. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4205. }
  4206. if (!string.IsNullOrEmpty(dto.City))
  4207. {
  4208. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4209. }
  4210. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4211. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4212. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4213. From Grp_NationalTravelFee gntf
  4214. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4215. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4216. Where gntf.Isdel = 0 {0} ", whereSql);
  4217. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4218. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4219. }
  4220. /// <summary>
  4221. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4222. /// </summary>
  4223. /// <returns></returns>
  4224. [HttpPost]
  4225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4226. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4227. {
  4228. try
  4229. {
  4230. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4231. if (data.Code != 0)
  4232. {
  4233. return Ok(JsonView(false, data.Msg));
  4234. }
  4235. return Ok(JsonView(true, "操作成功!", data.Data));
  4236. }
  4237. catch (Exception ex)
  4238. {
  4239. return Ok(JsonView(false, ex.Message));
  4240. }
  4241. }
  4242. /// <summary>
  4243. /// 团组模块 - 出入境国家费用标准 - Del
  4244. /// </summary>
  4245. /// <returns></returns>
  4246. [HttpPost]
  4247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4248. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4249. {
  4250. try
  4251. {
  4252. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4253. {
  4254. Id = dto.Id,
  4255. DeleteUserId = dto.DeleteUserId,
  4256. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4257. IsDel = 1
  4258. };
  4259. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4260. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4261. .WhereColumns(it => new { it.Id })
  4262. .ExecuteCommandAsync();
  4263. if (delStatus <= 0)
  4264. {
  4265. return Ok(JsonView(false, "删除失败!"));
  4266. }
  4267. return Ok(JsonView(true, "操作成功!"));
  4268. }
  4269. catch (Exception ex)
  4270. {
  4271. return Ok(JsonView(false, ex.Message));
  4272. }
  4273. }
  4274. #endregion
  4275. #region 签证费用录入
  4276. /// <summary>
  4277. /// 根据diid查询签证费用列表
  4278. /// </summary>
  4279. /// <param name="dto"></param>
  4280. /// <returns></returns>
  4281. [HttpPost]
  4282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4283. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4284. {
  4285. try
  4286. {
  4287. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4288. if (groupData.Code != 0)
  4289. {
  4290. return Ok(JsonView(false, groupData.Msg));
  4291. }
  4292. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4293. }
  4294. catch (Exception ex)
  4295. {
  4296. return Ok(JsonView(false, ex.Message));
  4297. }
  4298. }
  4299. /// <summary>
  4300. /// 根据签证费用Id查询单条数据及c表数据
  4301. /// </summary>
  4302. /// <param name="dto"></param>
  4303. /// <returns></returns>
  4304. [HttpPost]
  4305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4306. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4307. {
  4308. try
  4309. {
  4310. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4311. if (groupData.Code != 0)
  4312. {
  4313. return Ok(JsonView(false, groupData.Msg));
  4314. }
  4315. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4316. }
  4317. catch (Exception ex)
  4318. {
  4319. return Ok(JsonView(false, ex.Message));
  4320. }
  4321. }
  4322. /// <summary>
  4323. /// 签证费用删除
  4324. /// </summary>
  4325. /// <param name="dto"></param>
  4326. /// <returns></returns>
  4327. [HttpPost]
  4328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4329. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4330. {
  4331. try
  4332. {
  4333. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4334. if (!res)
  4335. {
  4336. return Ok(JsonView(false, "删除失败"));
  4337. }
  4338. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
  4339. {
  4340. IsDel = 1,
  4341. DeleteUserId = dto.DeleteUserId,
  4342. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4343. }).ExecuteCommandAsync();
  4344. return Ok(JsonView(true, "删除成功!"));
  4345. }
  4346. catch (Exception ex)
  4347. {
  4348. return Ok(JsonView(false, "程序错误!"));
  4349. throw;
  4350. }
  4351. }
  4352. /// <summary>
  4353. /// 签证费用录入下拉框初始化
  4354. /// </summary>
  4355. /// <returns></returns>
  4356. [HttpPost]
  4357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4358. public async Task<IActionResult> VisaPriceAddSelect()
  4359. {
  4360. try
  4361. {
  4362. //支付方式
  4363. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4364. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4365. //币种
  4366. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4367. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4368. //乘客类型
  4369. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4370. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4371. //卡类型
  4372. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4373. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4374. var data = new
  4375. {
  4376. Payment = _Payment,
  4377. CurrencyList = _CurrencyList,
  4378. PassengerType = _PassengerType,
  4379. BankCard = _BankCard
  4380. };
  4381. return Ok(JsonView(true, "查询成功!", data));
  4382. }
  4383. catch (Exception ex)
  4384. {
  4385. return Ok(JsonView(false, "程序错误!"));
  4386. throw;
  4387. }
  4388. }
  4389. /// <summary>
  4390. /// 签证费用录入操作(Status:1.新增,2.修改)
  4391. /// </summary>
  4392. /// <param name="dto"></param>
  4393. /// <returns></returns>
  4394. [HttpPost]
  4395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4396. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  4397. {
  4398. try
  4399. {
  4400. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  4401. if (groupData.Code != 0)
  4402. {
  4403. return Ok(JsonView(false, groupData.Msg));
  4404. }
  4405. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4406. }
  4407. catch (Exception ex)
  4408. {
  4409. return Ok(JsonView(false, ex.Message));
  4410. }
  4411. }
  4412. #endregion
  4413. #region op费用录入
  4414. /// <summary>
  4415. /// 根据diid查询op费用列表
  4416. /// </summary>
  4417. /// <param name="dto"></param>
  4418. /// <returns></returns>
  4419. [HttpPost]
  4420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4421. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  4422. {
  4423. try
  4424. {
  4425. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  4426. if (groupData.Code != 0)
  4427. {
  4428. return Ok(JsonView(false, groupData.Msg));
  4429. }
  4430. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4431. }
  4432. catch (Exception ex)
  4433. {
  4434. return Ok(JsonView(false, ex.Message));
  4435. }
  4436. }
  4437. /// <summary>
  4438. /// 根据op费用Id查询单条数据及c表数据
  4439. /// </summary>
  4440. /// <param name="dto"></param>
  4441. /// <returns></returns>
  4442. [HttpPost]
  4443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4444. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  4445. {
  4446. try
  4447. {
  4448. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  4449. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  4450. var data = new
  4451. {
  4452. CarTouristGuideGround = _groupData,
  4453. CreditCardPayment = _creditCardPayment
  4454. };
  4455. return Ok(JsonView(true, "查询成功!", data));
  4456. }
  4457. catch (Exception ex)
  4458. {
  4459. return Ok(JsonView(false, "程序错误!"));
  4460. }
  4461. }
  4462. /// <summary>
  4463. /// op费用删除
  4464. /// </summary>
  4465. /// <param name="dto"></param>
  4466. /// <returns></returns>
  4467. [HttpPost]
  4468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4469. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  4470. {
  4471. try
  4472. {
  4473. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4474. if (!res)
  4475. {
  4476. return Ok(JsonView(false, "删除失败"));
  4477. }
  4478. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  4479. {
  4480. IsDel = 1,
  4481. DeleteUserId = dto.DeleteUserId,
  4482. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4483. }).ExecuteCommandAsync();
  4484. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  4485. {
  4486. IsDel = 1,
  4487. DeleteUserId = dto.DeleteUserId,
  4488. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4489. }).ExecuteCommandAsync();
  4490. return Ok(JsonView(true, "删除成功!"));
  4491. }
  4492. catch (Exception ex)
  4493. {
  4494. return Ok(JsonView(false, "程序错误!"));
  4495. throw;
  4496. }
  4497. }
  4498. /// <summary>
  4499. /// op费用录入操作(Status:1.新增,2.修改)
  4500. /// </summary>
  4501. /// <param name="dto"></param>
  4502. /// <returns></returns>
  4503. [HttpPost]
  4504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4505. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  4506. {
  4507. try
  4508. {
  4509. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  4510. if (groupData.Code != 0)
  4511. {
  4512. return Ok(JsonView(false, groupData.Msg));
  4513. }
  4514. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4515. }
  4516. catch (Exception ex)
  4517. {
  4518. return Ok(JsonView(false, ex.Message));
  4519. }
  4520. }
  4521. /// <summary>
  4522. /// 填写费用详细页面初始化绑定
  4523. /// </summary>
  4524. /// <param name="dto"></param>
  4525. /// <returns></returns>
  4526. [HttpPost]
  4527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4528. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  4529. {
  4530. try
  4531. {
  4532. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  4533. if (groupData.Code != 0)
  4534. {
  4535. return Ok(JsonView(false, groupData.Msg));
  4536. }
  4537. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4538. }
  4539. catch (Exception ex)
  4540. {
  4541. return Ok(JsonView(false, ex.Message));
  4542. }
  4543. }
  4544. /// <summary>
  4545. /// 根据op费用Id查询详细数据
  4546. /// </summary>
  4547. /// <param name="dto"></param>
  4548. /// <returns></returns>
  4549. [HttpPost]
  4550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4551. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  4552. {
  4553. try
  4554. {
  4555. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  4556. if (groupData.Code != 0)
  4557. {
  4558. return Ok(JsonView(false, groupData.Msg));
  4559. }
  4560. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4561. }
  4562. catch (Exception ex)
  4563. {
  4564. return Ok(JsonView(false, ex.Message));
  4565. }
  4566. }
  4567. /// <summary>
  4568. /// OP费用录入填写详情
  4569. /// </summary>
  4570. /// <param name="dto"></param>
  4571. /// <returns></returns>
  4572. [HttpPost]
  4573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4574. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  4575. {
  4576. try
  4577. {
  4578. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  4579. if (groupData.Code != 0)
  4580. {
  4581. return Ok(JsonView(false, groupData.Msg));
  4582. }
  4583. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4584. }
  4585. catch (Exception ex)
  4586. {
  4587. return Ok(JsonView(false, ex.Message));
  4588. }
  4589. }
  4590. /// <summary>
  4591. /// 获取三公详细所有城市
  4592. /// </summary>
  4593. /// <returns></returns>
  4594. [HttpGet]
  4595. public IActionResult OpCarCityResult()
  4596. {
  4597. var jw = JsonView(false);
  4598. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x=>x.IsDel == 0).Select(x => new
  4599. {
  4600. x.Id,
  4601. x.Country,
  4602. x.City,
  4603. }).ToList();
  4604. if (data.Count > 0)
  4605. {
  4606. jw = JsonView(true, "获取成功!", data);
  4607. }
  4608. else
  4609. {
  4610. jw.Msg = "城市数据未空!";
  4611. jw.Data = new string[0];
  4612. }
  4613. return Ok(jw);
  4614. }
  4615. #region OP行程单
  4616. /// <summary>
  4617. /// OP行程单初始化
  4618. /// </summary>
  4619. /// <param name="dto"></param>
  4620. /// <returns></returns>
  4621. [HttpPost]
  4622. public IActionResult InitOpTravel(InitOpTravelDto dto)
  4623. {
  4624. var jw = JsonView(false);
  4625. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  4626. var group = groupList.First();
  4627. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  4628. if (group == null)
  4629. {
  4630. jw.Msg = "暂无团组!";
  4631. return Ok(jw);
  4632. }
  4633. if (groupList.Find(x=>x.Id == diid) == null)
  4634. {
  4635. jw.Msg = "请输入正确的团组ID!";
  4636. return Ok(jw);
  4637. }
  4638. string city = string.Empty;
  4639. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  4640. if (blackCode.Count > 0)
  4641. {
  4642. var black = blackCode.First();
  4643. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  4644. var blackSp = Regex.Split(black.BlackCode,"\r\n");
  4645. if (blackSp.Length > 0)
  4646. {
  4647. try
  4648. {
  4649. var cityArrCode = new List<string>(20);
  4650. foreach (var item in blackSp)
  4651. {
  4652. var itemSp = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  4653. var IndexSelect = itemSp[2];
  4654. var startCity = IndexSelect.Substring(0, 3);
  4655. var endCity = IndexSelect.Substring(3, 3);
  4656. cityArrCode.Add(startCity.ToUpper());
  4657. cityArrCode.Add(startCity.ToUpper());
  4658. }
  4659. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({string.Join(",", cityArrCode)}) ";
  4660. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  4661. foreach (var item in cityArrCode)
  4662. {
  4663. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  4664. if (find != null)
  4665. {
  4666. city += find.City + "/";
  4667. }
  4668. else
  4669. {
  4670. city += item + "三字码未收入/";
  4671. }
  4672. }
  4673. }
  4674. catch (Exception e)
  4675. {
  4676. city = "黑屏代码格式不正确!";
  4677. }
  4678. }
  4679. }
  4680. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x=>x.Diid == diid && x.IsDel == 0).OrderBy(x=>x.Date).Select(x=> new TravelArrView
  4681. {
  4682. Date = x.Date,
  4683. Days = x.Days,
  4684. Diffgroup = x.Diffgroup,
  4685. Diid = x.Diid,
  4686. Traffic_First = x.Traffic_First,
  4687. Traffic_Second = x.Traffic_Second,
  4688. Trip = x.Trip,
  4689. WeekDay = x.WeekDay
  4690. }).ToList();
  4691. jw.Data = new
  4692. {
  4693. groupList = groupList.Select(x => new
  4694. {
  4695. x.Id,
  4696. x.TeamName,
  4697. x.TourCode
  4698. }).ToList(),
  4699. groupInfo = new
  4700. {
  4701. group.VisitDays,
  4702. group.TourCode,
  4703. group.VisitPNumber,
  4704. group.TeamName,
  4705. city
  4706. },
  4707. OpTravelList
  4708. };
  4709. jw.Code = 200;
  4710. jw.Msg = "操作成功!";
  4711. return Ok(jw);
  4712. }
  4713. #endregion
  4714. #endregion
  4715. #region 团组成本
  4716. /// <summary>
  4717. /// 团组成本数据初始化
  4718. /// </summary>
  4719. /// <param name="dto"></param>
  4720. /// <returns></returns>
  4721. [HttpPost]
  4722. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  4723. {
  4724. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  4725. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  4726. WHEN COUNT(*) >= 0 THEN 'True'
  4727. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  4728. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  4729. ").ToList(); //团组列表
  4730. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  4731. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  4732. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  4733. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  4734. if (groupinfoValue != null)
  4735. {
  4736. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  4737. var spArr = new string[1] { countryArr };
  4738. if (countryArr.Contains("|"))
  4739. {
  4740. spArr = countryArr.Split("|");
  4741. }
  4742. else if (countryArr.Contains("、"))
  4743. {
  4744. spArr = countryArr.Split("、");
  4745. }
  4746. foreach (var item in spArr.Where(x=>!string.IsNullOrWhiteSpace(x)).ToList())
  4747. {
  4748. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  4749. if (dbQueryCountry != null)
  4750. {
  4751. visaCountryInfoArr.Add(dbQueryCountry);
  4752. }
  4753. }
  4754. }
  4755. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  4756. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  4757. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  4758. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  4759. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  4760. //GroupCostParameter.Add(new
  4761. // Grp_GroupCostParameter());
  4762. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  4763. return Ok(JsonView(new
  4764. {
  4765. groupList,
  4766. groupInfo,
  4767. groupChecks,
  4768. groupCost = groupCostMap,
  4769. hotelNumber,
  4770. GroupCostParameter = GroupCostParameterMap,
  4771. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  4772. {
  4773. x.VisaCountry,
  4774. x.VisaPrice,
  4775. x.Id,
  4776. }).ToList(),
  4777. baoPi = _GroupCostParameterRepository.GetBaoPi(diid)
  4778. }));
  4779. }
  4780. /// <summary>
  4781. /// 团组成本信息保存
  4782. /// </summary>
  4783. /// <param name="dto"></param>
  4784. /// <returns></returns>
  4785. [HttpPost]
  4786. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  4787. {
  4788. if (dto.Diid <= 0 || dto.Userid <= 0)
  4789. {
  4790. return Ok(JsonView(false));
  4791. }
  4792. JsonView jw = null;
  4793. bool isTrue = false;
  4794. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  4795. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  4796. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  4797. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  4798. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  4799. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  4800. try
  4801. {
  4802. _sqlSugar.BeginTran();
  4803. isTrue = await _GroupCostRepository.
  4804. SaveGroupCostList(Grp_groups, dto.Diid); //列表
  4805. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  4806. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  4807. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  4808. _sqlSugar.CommitTran();
  4809. jw = JsonView(true, "保存成功!", isTrue);
  4810. }
  4811. catch (Exception)
  4812. {
  4813. _sqlSugar.RollbackTran();
  4814. jw = JsonView(false);
  4815. }
  4816. return Ok(jw);
  4817. }
  4818. /// <summary>
  4819. /// 司兼导数据
  4820. /// </summary>
  4821. /// <param name="dto"></param>
  4822. /// <returns></returns>
  4823. [HttpPost]
  4824. public IActionResult GetCarGuides(CarGuidesDto dto)
  4825. {
  4826. JsonView jw = null;
  4827. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  4828. jw = JsonView(true, "获取成功!", Data);
  4829. return Ok(jw);
  4830. }
  4831. /// <summary>
  4832. /// 导游数据
  4833. /// </summary>
  4834. /// <param name="dto"></param>
  4835. /// <returns></returns>
  4836. [HttpPost]
  4837. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  4838. {
  4839. JsonView jw = null;
  4840. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  4841. // 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
  4842. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  4843. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  4844. jw = JsonView(true, "获取成功!", Data);
  4845. return Ok(jw);
  4846. }
  4847. /// <summary>
  4848. /// 成本车数据
  4849. /// </summary>
  4850. /// <param name="dto"></param>
  4851. /// <returns></returns>
  4852. [HttpPost]
  4853. public IActionResult GetCarInfo(CarGuidesDto dto)
  4854. {
  4855. JsonView jw = null;
  4856. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  4857. jw = JsonView(true, "获取成功!", Data);
  4858. return Ok(jw);
  4859. }
  4860. /// <summary>
  4861. /// 景点数据
  4862. /// </summary>
  4863. /// <param name="dto"></param>
  4864. /// <returns></returns>
  4865. [HttpPost]
  4866. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  4867. {
  4868. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  4869. return Ok(JsonView(true, "获取成功!", Data));
  4870. }
  4871. /// <summary>
  4872. /// 成本通知
  4873. /// </summary>
  4874. /// <param name="dto"></param>
  4875. /// <returns></returns>
  4876. [HttpPost]
  4877. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  4878. {
  4879. if (dto.Diid < 0)
  4880. {
  4881. return Ok(JsonView(false));
  4882. }
  4883. JsonView jw = null;
  4884. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  4885. if (GroupCostParameter != null)
  4886. {
  4887. int IsShare = 0;
  4888. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  4889. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  4890. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id,IsShare);
  4891. string msg = string.Empty;
  4892. if (isTrue)
  4893. {
  4894. if (IsShare == 0)
  4895. {
  4896. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  4897. }
  4898. else
  4899. {
  4900. msg = "通知成功,其他模块操作人员可见此成本信息!";
  4901. }
  4902. jw = JsonView(isTrue, msg);
  4903. }
  4904. else
  4905. {
  4906. msg = "修改失败!";
  4907. jw = JsonView(isTrue, msg);
  4908. }
  4909. }
  4910. else
  4911. {
  4912. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  4913. }
  4914. return Ok(jw);
  4915. }
  4916. /// <summary>
  4917. /// 导出收款账单
  4918. /// </summary>
  4919. /// <param name="dto"></param>
  4920. /// <returns></returns>
  4921. [HttpPost]
  4922. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  4923. {
  4924. if (dto.Diid == 0)
  4925. {
  4926. return Ok(JsonView(false, "请传递团组id"));
  4927. }
  4928. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  4929. if (deleInfo.Code != 0)
  4930. {
  4931. return Ok(JsonView(false, "团组信息查询失败!"));
  4932. }
  4933. var di = deleInfo.Data as DelegationInfoWebView;
  4934. if (di != null)
  4935. {
  4936. //文件名
  4937. string strFileName = di.TeamName + "-收款账单.doc";
  4938. //获取模板
  4939. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  4940. //载入模板
  4941. Document doc = new Document(tmppath);
  4942. decimal TotalPrice = 0.00M;
  4943. string itemStr = string.Empty;
  4944. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  4945. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  4946. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  4947. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  4948. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  4949. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  4950. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  4951. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  4952. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x=>x.Key);
  4953. foreach(var cost in groupCostType)
  4954. {
  4955. var List = cost.ToList();
  4956. if (cost.Key == "A")
  4957. {
  4958. foreach (var ListItem in List)
  4959. {
  4960. if (ListItem.number > 0)
  4961. {
  4962. if (ListItem.code.Contains("TBR"))
  4963. {
  4964. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4965. }
  4966. else
  4967. {
  4968. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4969. }
  4970. TotalPrice += (ListItem.number * ListItem.price);
  4971. }
  4972. }
  4973. }
  4974. else
  4975. {
  4976. itemStr = itemStr.Insert(0, "A段\r\n");
  4977. itemStr += "B段\r\n";
  4978. foreach (var ListItem in List)
  4979. {
  4980. if (ListItem.number > 0)
  4981. {
  4982. if (ListItem.code.Contains("TBR"))
  4983. {
  4984. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4985. }
  4986. else
  4987. {
  4988. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4989. }
  4990. TotalPrice += (ListItem.number * ListItem.price);
  4991. }
  4992. }
  4993. }
  4994. }
  4995. #region 替换Word模板书签内容
  4996. Dictionary<string, string> marks = new Dictionary<string, string>();
  4997. marks.Add("To", di.ClientUnit);//付款方
  4998. marks.Add("ToTel", di.TellPhone);//付款方电话
  4999. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  5000. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  5001. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  5002. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  5003. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  5004. marks.Add("WeChat", "WeChat");//微信号 di.WeChat;
  5005. marks.Add("PayItemContent", itemStr);//详细信息
  5006. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  5007. #endregion
  5008. ////注
  5009. //if (doc.Range.Bookmarks["Attention"] != null)
  5010. //{
  5011. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  5012. // mark.Text = frList[0].Attention;
  5013. //}
  5014. foreach (var item in marks.Keys)
  5015. {
  5016. if (doc.Range.Bookmarks[item] != null)
  5017. {
  5018. Bookmark mark = doc.Range.Bookmarks[item];
  5019. mark.Text = marks[item];
  5020. }
  5021. }
  5022. byte[] bytes = null;
  5023. using (MemoryStream stream = new MemoryStream())
  5024. {
  5025. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  5026. bytes = stream.ToArray();
  5027. }
  5028. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  5029. return Ok(JsonView(true,"",new
  5030. {
  5031. Data = bytes,
  5032. strFileName,
  5033. }));
  5034. }
  5035. else
  5036. {
  5037. return Ok(JsonView(false,"团组信息不存在!"));
  5038. }
  5039. }
  5040. /// <summary>
  5041. /// 导出团组成本
  5042. /// </summary>
  5043. /// <param name="dto"></param>
  5044. /// <returns></returns>
  5045. [HttpPost]
  5046. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  5047. {
  5048. var jw = JsonView(false);
  5049. if (dto.Diid == 0)
  5050. {
  5051. return Ok(JsonView(false, "请传递团组id"));
  5052. }
  5053. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  5054. if (deleInfo.Code != 0)
  5055. {
  5056. return Ok(JsonView(false, "团组信息查询失败!"));
  5057. }
  5058. var di = deleInfo.Data as DelegationInfoWebView;
  5059. if (di == null)
  5060. {
  5061. return Ok(JsonView(false, "团组信息查询失败!"));
  5062. }
  5063. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  5064. WorkbookDesigner designer = new WorkbookDesigner();
  5065. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  5066. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  5067. for (int i = 0; i < List_GC.Count; i++)
  5068. {
  5069. GroupCost_Excel gc = new GroupCost_Excel();
  5070. gc.Id = List_GC[i].Id;
  5071. gc.Diid = List_GC[i].Diid.ToString();
  5072. gc.DAY = List_GC[i].DAY;
  5073. string week = "";
  5074. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  5075. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  5076. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  5077. gc.ITIN = List_GC[i].ITIN;
  5078. gc.CarType = List_GC[i].CarType;
  5079. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  5080. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  5081. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  5082. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  5083. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  5084. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  5085. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  5086. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  5087. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  5088. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  5089. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  5090. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  5091. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  5092. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  5093. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  5094. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  5095. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  5096. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  5097. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  5098. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  5099. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  5100. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  5101. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  5102. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  5103. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  5104. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  5105. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  5106. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  5107. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  5108. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  5109. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  5110. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  5111. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  5112. List_GC1.Add(gc);
  5113. }
  5114. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  5115. dt.TableName = "TB";
  5116. //报表标题等不用dt的值
  5117. designer.SetDataSource("TeamName", dto.title.TeamName);
  5118. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  5119. designer.SetDataSource("Tax", dto.title.Tax);
  5120. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  5121. designer.SetDataSource("Currency", dto.title.Currency);
  5122. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  5123. designer.SetDataSource("Rate", dto.title.Rate);
  5124. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  5125. var Aparams = hotels.Find(x => x.Type == "Default");
  5126. if (Aparams == null)
  5127. {
  5128. return Ok(jw);
  5129. }
  5130. //酒店数量
  5131. var txtSGRNumber = Aparams.SGR.ToString();
  5132. var txtTBRNumber = Aparams.TBR.ToString();
  5133. var txtJSESNumber = Aparams.JSES.ToString();
  5134. var txtSUITENumbe = Aparams.SUITE.ToString();
  5135. if (dto.costType == "B")
  5136. {
  5137. Aparams = hotels.Find(x => x.Type == "A");
  5138. var Bparams = hotels.Find(x => x.Type == "B");
  5139. if (Aparams == null || Bparams == null)
  5140. {
  5141. return Ok(jw);
  5142. }
  5143. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  5144. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  5145. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  5146. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  5147. }
  5148. designer.SetDataSource("SGRNumber", txtSGRNumber);
  5149. designer.SetDataSource("TBRNumber", txtTBRNumber);
  5150. designer.SetDataSource("JSESNumber", txtJSESNumber);
  5151. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  5152. var ws = designer.Workbook.Worksheets[0];
  5153. int Row = List_GC.Count;
  5154. int startIndex = 11;
  5155. int HideRows = 0;
  5156. List<int> hideRowsList = new List<int>();
  5157. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  5158. #region A段left数据
  5159. var left = dto.leftInfo.Find(x => x.Type == "A");
  5160. if (left == null)
  5161. {
  5162. return Ok(jw);
  5163. }
  5164. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  5165. if (leftBindData != null)
  5166. {
  5167. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  5168. designer.SetDataSource("VisaRS", leftBindData.rs);
  5169. designer.SetDataSource("VisaXS", leftBindData.xs);
  5170. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5171. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5172. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5173. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5174. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5175. }
  5176. else {
  5177. hideRowsList.Add(Row + startIndex + HideRows);
  5178. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5179. }
  5180. HideRows += 2;
  5181. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  5182. if (leftBindData != null)
  5183. {
  5184. designer.SetDataSource("BXDRCB", leftBindData.cb);
  5185. designer.SetDataSource("BXRS", leftBindData.rs);
  5186. designer.SetDataSource("BXXS", leftBindData.xs);
  5187. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5188. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5189. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5190. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5191. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5192. }
  5193. else
  5194. {
  5195. hideRowsList.Add(Row + startIndex + HideRows);
  5196. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5197. }
  5198. HideRows += 2;
  5199. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  5200. if (leftBindData != null)
  5201. {
  5202. designer.SetDataSource("HSDRCB", leftBindData.cb);
  5203. designer.SetDataSource("HSRS", leftBindData.rs);
  5204. designer.SetDataSource("HSXS", leftBindData.xs);
  5205. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5206. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5207. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5208. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5209. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5210. }
  5211. else
  5212. {
  5213. hideRowsList.Add(Row + startIndex + HideRows);
  5214. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5215. }
  5216. HideRows += 2;
  5217. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  5218. if (leftBindData != null)
  5219. {
  5220. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  5221. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  5222. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  5223. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5224. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5225. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5226. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5227. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5228. }
  5229. else
  5230. {
  5231. hideRowsList.Add(Row + startIndex + HideRows);
  5232. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5233. }
  5234. HideRows += 2;
  5235. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  5236. if (leftBindData != null)
  5237. {
  5238. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  5239. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  5240. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  5241. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5242. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5243. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5244. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5245. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5246. }
  5247. else
  5248. {
  5249. hideRowsList.Add(Row + startIndex + HideRows);
  5250. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5251. }
  5252. HideRows += 2;
  5253. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  5254. if (leftBindData != null)
  5255. {
  5256. ////TBR
  5257. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  5258. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  5259. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  5260. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5261. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5262. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5263. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5264. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5265. }
  5266. else
  5267. {
  5268. hideRowsList.Add(Row + startIndex + HideRows);
  5269. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5270. }
  5271. HideRows += 2;
  5272. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  5273. if (leftBindData != null)
  5274. {
  5275. ////SGR
  5276. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  5277. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  5278. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  5279. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5280. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5281. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5282. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5283. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5284. }
  5285. else
  5286. {
  5287. hideRowsList.Add(Row + startIndex + HideRows);
  5288. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5289. }
  5290. HideRows += 2;
  5291. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  5292. if (leftBindData != null)
  5293. {
  5294. ////JS/ES
  5295. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  5296. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  5297. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  5298. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5299. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5300. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5301. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5302. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5303. }
  5304. else
  5305. {
  5306. hideRowsList.Add(Row + startIndex + HideRows);
  5307. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5308. }
  5309. HideRows += 2;
  5310. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  5311. if (leftBindData != null)
  5312. {
  5313. ////SUITE
  5314. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  5315. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  5316. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  5317. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5318. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5319. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5320. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5321. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5322. }
  5323. else
  5324. {
  5325. hideRowsList.Add(Row + startIndex + HideRows);
  5326. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5327. }
  5328. HideRows += 2;
  5329. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  5330. if (leftBindData != null)
  5331. {
  5332. designer.SetDataSource("DJDRCB", leftBindData.cb);
  5333. designer.SetDataSource("DJRS", leftBindData.rs);
  5334. designer.SetDataSource("DJXS", leftBindData.xs);
  5335. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5336. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5337. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5338. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5339. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5340. }
  5341. else
  5342. {
  5343. hideRowsList.Add(Row + startIndex + HideRows);
  5344. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5345. }
  5346. HideRows += 2;
  5347. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  5348. if (leftBindData != null)
  5349. {
  5350. designer.SetDataSource("HCPCB", leftBindData.cb);
  5351. designer.SetDataSource("HCPRS", leftBindData.rs);
  5352. designer.SetDataSource("HCPXS", leftBindData.xs);
  5353. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5354. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5355. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5356. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5357. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5358. }
  5359. else
  5360. {
  5361. hideRowsList.Add(Row + startIndex + HideRows);
  5362. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5363. }
  5364. HideRows += 2;
  5365. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  5366. if (leftBindData != null)
  5367. {
  5368. designer.SetDataSource("CPCB", leftBindData.cb);
  5369. designer.SetDataSource("CPRS", leftBindData.rs);
  5370. designer.SetDataSource("CPXS", leftBindData.xs);
  5371. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5372. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5373. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5374. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5375. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5376. }
  5377. else
  5378. {
  5379. hideRowsList.Add(Row + startIndex + HideRows);
  5380. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5381. }
  5382. HideRows += 2;
  5383. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  5384. if (leftBindData != null)
  5385. {
  5386. designer.SetDataSource("GWDRCD", leftBindData.cb);
  5387. designer.SetDataSource("GWRS", leftBindData.rs);
  5388. designer.SetDataSource("GWXS", leftBindData.xs);
  5389. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5390. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5391. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5392. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5393. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5394. }
  5395. else
  5396. {
  5397. hideRowsList.Add(Row + startIndex + HideRows);
  5398. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5399. }
  5400. HideRows += 2;
  5401. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  5402. if (leftBindData != null)
  5403. {
  5404. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  5405. designer.SetDataSource("LYJRS", leftBindData.rs);
  5406. designer.SetDataSource("LYJXS", leftBindData.xs);
  5407. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5408. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5409. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5410. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5411. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5412. }
  5413. else
  5414. {
  5415. hideRowsList.Add(Row + startIndex + HideRows);
  5416. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5417. }
  5418. #endregion
  5419. #region A段Right信息
  5420. var right = dto.rightInfo.Find(x => x.Type == "A");
  5421. if (right == null)
  5422. {
  5423. return Ok(jw);
  5424. }
  5425. HideRows += 4;
  5426. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  5427. if (rightBindData!= null)
  5428. {
  5429. //经济舱 + 双人间 TBR
  5430. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  5431. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  5432. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5433. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  5434. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5435. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5436. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5437. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5438. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5439. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5440. }
  5441. else
  5442. {
  5443. hideRowsList.Add(Row + startIndex + HideRows);
  5444. }
  5445. HideRows += 2;
  5446. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  5447. if (rightBindData != null)
  5448. {
  5449. //经济舱 + 单人间 SGR
  5450. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  5451. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  5452. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5453. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  5454. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5455. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5456. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5457. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5458. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5459. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5460. }
  5461. else
  5462. {
  5463. hideRowsList.Add(Row + startIndex + HideRows);
  5464. }
  5465. HideRows += 2;
  5466. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  5467. if (rightBindData != null)
  5468. {
  5469. //公务舱 + 单人间 SGR
  5470. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  5471. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  5472. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5473. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  5474. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5475. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5476. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5477. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5478. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5479. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5480. }
  5481. else
  5482. {
  5483. hideRowsList.Add(Row + startIndex + HideRows);
  5484. }
  5485. HideRows += 2;
  5486. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  5487. if (rightBindData != null)
  5488. {
  5489. //公务舱 + 小套房 JSES
  5490. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  5491. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  5492. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5493. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  5494. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5495. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5496. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5497. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5498. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5499. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5500. }
  5501. else
  5502. {
  5503. hideRowsList.Add(Row + startIndex + HideRows);
  5504. }
  5505. HideRows += 2;
  5506. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  5507. if (rightBindData != null)
  5508. {
  5509. //公务舱 + 小套房 JSES
  5510. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  5511. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  5512. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5513. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  5514. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5515. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5516. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5517. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5518. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5519. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5520. }
  5521. else
  5522. {
  5523. hideRowsList.Add(Row + startIndex + HideRows);
  5524. }
  5525. HideRows += 2;
  5526. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  5527. if (rightBindData != null)
  5528. {
  5529. //经济舱 + 大套房
  5530. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  5531. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  5532. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5533. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  5534. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5535. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5536. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5537. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5538. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5539. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5540. }
  5541. else
  5542. {
  5543. hideRowsList.Add(Row + startIndex + HideRows);
  5544. }
  5545. #endregion
  5546. #region B段标题清空
  5547. designer.SetDataSource("CostBDRCB", "");
  5548. designer.SetDataSource("CostBRS", "");
  5549. designer.SetDataSource("CostBXS", "");
  5550. designer.SetDataSource("CostBZCB", "");
  5551. designer.SetDataSource("CostBDRBJ", "");
  5552. designer.SetDataSource("CostBZBJ", "");
  5553. designer.SetDataSource("CostBDRLR", "");
  5554. designer.SetDataSource("CostBZLR", "");
  5555. designer.SetDataSource("CostBDRCBOM", "");
  5556. designer.SetDataSource("CostBRSOM", "");
  5557. designer.SetDataSource("CostBZCBOM", "");
  5558. designer.SetDataSource("CostBDRBJOM", "");
  5559. designer.SetDataSource("CostBZBJOM", "");
  5560. designer.SetDataSource("CostBDRLROM", "");
  5561. designer.SetDataSource("CostBZLROM", "");
  5562. #endregion
  5563. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  5564. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  5565. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  5566. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  5567. designer.SetDataSource("DJName", "地接(CNY)");
  5568. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  5569. designer.SetDataSource("CPName", "地接-船票(CNY)");
  5570. designer.SetDataSource("GWName", "公务(CNY)");
  5571. designer.SetDataSource("YQHName", "邀请函(CNY)");
  5572. designer.SetDataSource("LYJName", "零用金(CNY)");
  5573. designer.SetDataSource("HSName", "核酸检测(CNY)");
  5574. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  5575. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  5576. designer.SetDataSource("BXName", "保险(CNY)");
  5577. designer.SetDataSource("VisaName", "签证(CNY)");
  5578. #region B段基本数据
  5579. if (dto.costType == "B")
  5580. {
  5581. left = dto.leftInfo.Find(x => x.Type == "B");
  5582. if (left == null)
  5583. {
  5584. return Ok(jw);
  5585. }
  5586. #region B段left数据
  5587. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  5588. if (leftBindData != null)
  5589. {
  5590. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  5591. designer.SetDataSource("BHSRS", leftBindData.rs);
  5592. designer.SetDataSource("BHSXS", leftBindData.xs);
  5593. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5594. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5595. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5596. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5597. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5598. }
  5599. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  5600. if (leftBindData != null)
  5601. {
  5602. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  5603. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  5604. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  5605. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5606. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5607. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5608. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5609. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5610. }
  5611. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  5612. if (leftBindData != null)
  5613. {
  5614. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  5615. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  5616. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  5617. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5618. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5619. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5620. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5621. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5622. }
  5623. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  5624. if (leftBindData != null)
  5625. {
  5626. designer.SetDataSource("BHCPCB", leftBindData.cb);
  5627. designer.SetDataSource("BHCPRS", leftBindData.rs);
  5628. designer.SetDataSource("BHCPXS", leftBindData.xs);
  5629. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5630. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5631. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5632. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5633. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5634. }
  5635. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  5636. if (leftBindData != null)
  5637. {
  5638. designer.SetDataSource("BCPCB", leftBindData.cb);
  5639. designer.SetDataSource("BCPRS", leftBindData.rs);
  5640. designer.SetDataSource("BCPXS", leftBindData.xs);
  5641. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5642. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5643. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5644. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5645. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5646. }
  5647. //TBR
  5648. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  5649. if (leftBindData != null)
  5650. {
  5651. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  5652. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  5653. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  5654. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5655. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5656. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5657. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5658. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5659. }
  5660. //SGR
  5661. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  5662. if (leftBindData != null)
  5663. {
  5664. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  5665. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  5666. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  5667. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5668. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5669. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5670. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5671. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5672. }
  5673. //JS/ES
  5674. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  5675. if (leftBindData != null)
  5676. {
  5677. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  5678. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  5679. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  5680. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5681. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5682. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5683. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5684. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5685. }
  5686. //SUITE
  5687. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  5688. if (leftBindData != null)
  5689. {
  5690. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  5691. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  5692. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  5693. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5694. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5695. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5696. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5697. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5698. }
  5699. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  5700. if (leftBindData != null)
  5701. {
  5702. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  5703. designer.SetDataSource("BDJRS", leftBindData.rs);
  5704. designer.SetDataSource("BDJXS", leftBindData.xs);
  5705. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5706. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5707. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5708. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5709. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5710. }
  5711. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  5712. if (leftBindData != null)
  5713. {
  5714. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  5715. designer.SetDataSource("BGWRS", leftBindData.rs);
  5716. designer.SetDataSource("BGWXS", leftBindData.xs);
  5717. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5718. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5719. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5720. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5721. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5722. }
  5723. #region 优化方案
  5724. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  5725. //excelBind.Add("零用金", new {
  5726. //cb="",
  5727. //rs="",
  5728. //xs ="",
  5729. //zcb = "",
  5730. //});
  5731. #endregion
  5732. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  5733. if (leftBindData != null)
  5734. {
  5735. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  5736. designer.SetDataSource("BLYJRS", leftBindData.rs);
  5737. designer.SetDataSource("BLYJXS", leftBindData.xs);
  5738. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5739. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5740. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5741. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5742. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5743. }
  5744. #endregion
  5745. #region B段Right信息
  5746. right = dto.rightInfo.Find(x => x.Type == "B");
  5747. if (right == null)
  5748. {
  5749. return Ok(jw);
  5750. }
  5751. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  5752. if (rightBindData!= null)
  5753. {
  5754. //经济舱 + 双人间 TBR
  5755. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  5756. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  5757. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5758. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  5759. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5760. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5761. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5762. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5763. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5764. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5765. }
  5766. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  5767. if (rightBindData != null)
  5768. {
  5769. //经济舱 + 单人间 SGR
  5770. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  5771. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  5772. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5773. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  5774. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5775. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5776. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5777. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5778. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5779. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5780. }
  5781. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  5782. if (rightBindData != null)
  5783. {
  5784. //公务舱 + 单人间 SGR
  5785. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  5786. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  5787. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5788. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  5789. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5790. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5791. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5792. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5793. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5794. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5795. }
  5796. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  5797. if (rightBindData != null)
  5798. {
  5799. //公务舱 + 小套房 JSES
  5800. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  5801. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  5802. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5803. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  5804. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5805. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5806. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5807. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5808. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5809. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5810. }
  5811. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  5812. if (rightBindData != null)
  5813. {
  5814. //公务舱 + 小套房 JSES
  5815. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  5816. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  5817. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5818. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  5819. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5820. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5821. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5822. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5823. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5824. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5825. }
  5826. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  5827. if (rightBindData != null)
  5828. {
  5829. //经济舱 + 大套房
  5830. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  5831. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  5832. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5833. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  5834. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5835. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5836. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5837. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5838. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5839. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5840. }
  5841. #endregion
  5842. #region 标题
  5843. designer.SetDataSource("CostBDRCB", "单人成本");
  5844. designer.SetDataSource("CostBRS", "人数");
  5845. designer.SetDataSource("CostBXS", "系数");
  5846. designer.SetDataSource("CostBZCB", "总成本");
  5847. designer.SetDataSource("CostBDRBJ", "单人报价");
  5848. designer.SetDataSource("CostBZBJ", "总报价");
  5849. designer.SetDataSource("CostBDRLR", "单人利润");
  5850. designer.SetDataSource("CostBZLR", "总利润");
  5851. designer.SetDataSource("CostBDRCBOM", "单人成本");
  5852. designer.SetDataSource("CostBRSOM", "人数");
  5853. designer.SetDataSource("CostBZCBOM", "总成本");
  5854. designer.SetDataSource("CostBDRBJOM", "单人报价");
  5855. designer.SetDataSource("CostBZBJOM", "总报价");
  5856. designer.SetDataSource("CostBDRLROM", "单人利润");
  5857. designer.SetDataSource("CostBZLROM", "总利润");
  5858. #endregion
  5859. }
  5860. #endregion
  5861. designer.SetDataSource("TzZCB2", TzZCB2);
  5862. designer.SetDataSource("TzZBJ2", TzZBJ2);
  5863. designer.SetDataSource("TzZLR2", TzZLR2);
  5864. string[] dataSourceKeys = new string[]
  5865. {
  5866. "VF",
  5867. "TGS",
  5868. "TGOF",
  5869. "TGM",
  5870. "TGA",
  5871. "TGTF",
  5872. "TGEF",
  5873. "CFM",
  5874. "CFOF",
  5875. "B",
  5876. "L",
  5877. "D",
  5878. "TBR",
  5879. "SGR",
  5880. "JSES",
  5881. "Suite",
  5882. "TV",
  5883. "1L",
  5884. "IF",
  5885. "EF",
  5886. "BRF",
  5887. "TE",
  5888. "TGT",
  5889. "DRVT",
  5890. "PC",
  5891. "TLF",
  5892. "ECT"
  5893. };
  5894. foreach (var item in dataSourceKeys)
  5895. {
  5896. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  5897. if (find != null)
  5898. {
  5899. designer.SetDataSource(item, find.text);
  5900. }
  5901. else
  5902. {
  5903. designer.SetDataSource(item, 0);
  5904. }
  5905. }
  5906. designer.SetDataSource(dt);
  5907. //根据数据源处理生成报表内容
  5908. designer.Process();
  5909. designer.Workbook.Worksheets[0].Name = "清单";
  5910. Worksheet sheet = designer.Workbook.Worksheets[0];
  5911. foreach (var Rowindex in hideRowsList)
  5912. {
  5913. ws.Cells.HideRows(Rowindex, 2);
  5914. }
  5915. byte[] bytes = null;
  5916. string strFileName = di.TeamName + "-团组-成本.xls";
  5917. using (MemoryStream stream = new MemoryStream())
  5918. {
  5919. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5920. bytes = stream.ToArray();
  5921. }
  5922. return Ok(JsonView(true, "", new
  5923. {
  5924. Data = bytes,
  5925. strFileName,
  5926. }));
  5927. }
  5928. /// <summary>
  5929. /// 导出客户报表
  5930. /// </summary>
  5931. /// <returns></returns>
  5932. [HttpPost]
  5933. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  5934. {
  5935. var jw = JsonView(false);
  5936. if (dto.Diid == 0)
  5937. {
  5938. return Ok(JsonView(false, "请传递团组id"));
  5939. }
  5940. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  5941. if (deleInfo.Code != 0)
  5942. {
  5943. return Ok(JsonView(false, "团组信息查询失败!"));
  5944. }
  5945. var di = deleInfo.Data as DelegationInfoWebView;
  5946. if (di == null)
  5947. {
  5948. return Ok(JsonView(false, "团组信息查询失败!"));
  5949. }
  5950. //文件名
  5951. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  5952. //获取模板
  5953. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  5954. //载入模板
  5955. Document doc = new Document(tmppath);
  5956. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  5957. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  5958. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  5959. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  5960. var AParameter = ParameterList.Find(x => x.CostType == "A");
  5961. var BParameter = ParameterList.Find(x => x.CostType == "B");
  5962. if (AParameter == null)
  5963. {
  5964. return Ok(JsonView(false, "系数不存在!"));
  5965. }
  5966. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  5967. , TzAirDesc, TzZCost;
  5968. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  5969. = TzAirDesc = TzZCost = string.Empty;
  5970. TzNumber = AParameter.CostTypenumber.ToString();
  5971. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  5972. CarGuides1 = dto.CarGuides1;
  5973. Meal = dto.Meal;
  5974. SubsidizedMeals = dto.SubsidizedMeals;
  5975. NightRepair = dto.NightRepair;
  5976. AttractionsTickets = dto.AttractionsTickets;
  5977. MiscellaneousFees = dto.MiscellaneousFees;
  5978. ATip = dto.ATip;
  5979. TzHotelDesc = "";
  5980. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  5981. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  5982. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  5983. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  5984. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  5985. TzAirDesc = "";
  5986. TzZCost = dto.TzZCost;
  5987. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  5988. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  5989. var index = 1;
  5990. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  5991. foreach (var item in TzHotelDescArr)
  5992. {
  5993. if (AinfoArr != null)
  5994. {
  5995. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  5996. if (Ainfo != null)
  5997. {
  5998. if (int.Parse(Ainfo.rs) <= 0)
  5999. {
  6000. continue;
  6001. }
  6002. var hotelText = string.Empty;
  6003. switch (item)
  6004. {
  6005. case "SGR":
  6006. hotelText = "单人间";
  6007. break;
  6008. case "JSES":
  6009. hotelText = "小套房";
  6010. break;
  6011. case "SUITE":
  6012. hotelText = "套房";
  6013. break;
  6014. case "TBR":
  6015. hotelText = "双人间";
  6016. break;
  6017. }
  6018. if (item != "TBR")
  6019. {
  6020. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  6021. }
  6022. else
  6023. {
  6024. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  6025. }
  6026. index++;
  6027. }
  6028. }
  6029. }
  6030. index = 1;
  6031. foreach (var item in TzAirDescArr)
  6032. {
  6033. if (AinfoArr != null)
  6034. {
  6035. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  6036. if (Ainfo != null)
  6037. {
  6038. if (int.Parse(Ainfo.rs) <= 0)
  6039. {
  6040. continue;
  6041. }
  6042. TzAirDesc += "(" + index + ".) "+item+" " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  6043. index++;
  6044. }
  6045. }
  6046. }
  6047. if (dto.costType == "B")
  6048. {
  6049. if (BParameter == null)
  6050. {
  6051. return Ok(JsonView(false, "B段系数不存在!"));
  6052. }
  6053. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  6054. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  6055. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  6056. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  6057. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  6058. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  6059. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  6060. foreach (var item in TzHotelDescArr)
  6061. {
  6062. if (AinfoArr != null)
  6063. {
  6064. TzHotelDesc += "B段信息 \r\n";
  6065. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  6066. if (Ainfo != null)
  6067. {
  6068. if (int.Parse(Ainfo.rs) <= 0)
  6069. {
  6070. continue;
  6071. }
  6072. var hotelText = string.Empty;
  6073. switch (item)
  6074. {
  6075. case "SGR":
  6076. hotelText = "单人间";
  6077. break;
  6078. case "JSES":
  6079. hotelText = "小套房";
  6080. break;
  6081. case "SUITE":
  6082. hotelText = "套房";
  6083. break;
  6084. case "TBR":
  6085. hotelText = "双人间";
  6086. break;
  6087. }
  6088. if (item != "TBR")
  6089. {
  6090. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  6091. }
  6092. else
  6093. {
  6094. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  6095. }
  6096. index++;
  6097. }
  6098. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  6099. }
  6100. }
  6101. index = 1;
  6102. foreach (var item in TzAirDescArr)
  6103. {
  6104. if (AinfoArr != null)
  6105. {
  6106. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  6107. if (Ainfo != null)
  6108. {
  6109. if (int.Parse(Ainfo.rs) <= 0)
  6110. {
  6111. continue;
  6112. }
  6113. TzAirDesc += "(" + index + ".) " + item + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  6114. index++;
  6115. }
  6116. }
  6117. }
  6118. }
  6119. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  6120. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  6121. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  6122. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  6123. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  6124. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  6125. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  6126. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  6127. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  6128. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  6129. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  6130. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  6131. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  6132. DickeyValue.Add("Visa", Visa); // 签证单人报价
  6133. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  6134. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  6135. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  6136. DickeyValue.Add("TzZCost", TzZCost);
  6137. foreach (var key in DickeyValue.Keys)
  6138. {
  6139. if (doc.Range.Bookmarks[key] != null)
  6140. {
  6141. Bookmark mark = doc.Range.Bookmarks[key];
  6142. mark.Text = DickeyValue[key];
  6143. }
  6144. }
  6145. byte[] bytes = null;
  6146. string strFileName = di.TeamName + "-客户报价.doc";
  6147. using (MemoryStream stream = new MemoryStream())
  6148. {
  6149. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  6150. bytes = stream.ToArray();
  6151. }
  6152. return Ok(JsonView(true, "", new
  6153. {
  6154. Data = bytes,
  6155. strFileName,
  6156. }));
  6157. }
  6158. /// <summary>
  6159. /// 团组成本 各模块(酒店,地接,机票)成本提示
  6160. /// </summary>
  6161. /// <param name="dto"></param>
  6162. /// <returns></returns>
  6163. [HttpPost]
  6164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6165. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  6166. {
  6167. try
  6168. {
  6169. #region 参数验证
  6170. if (dto.DiId < 0)
  6171. {
  6172. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6173. }
  6174. List<int> cTableIds = new List<int>() {
  6175. 76 ,//酒店预订
  6176. 77 ,//行程
  6177. 79 ,//车/导游地接
  6178. 80 ,//签证
  6179. 81 ,//邀请/公务活
  6180. 82 ,//团组客户保险
  6181. 85 ,//机票预订
  6182. 98 ,//其他款项
  6183. 285 ,//收款退还
  6184. 751 ,//酒店早餐
  6185. 1015 // 超支费用
  6186. };
  6187. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  6188. {
  6189. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  6190. }
  6191. #endregion
  6192. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  6193. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6194. if (_GroupCostParameters.Count <= 0)
  6195. {
  6196. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  6197. }
  6198. if (_GroupCostParameters[0].IsShare == 0)
  6199. {
  6200. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  6201. }
  6202. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  6203. //处理date为空问题
  6204. if (_GroupCosts.Count > 0)
  6205. {
  6206. for (int i = 0; i < _GroupCosts.Count; i++)
  6207. {
  6208. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  6209. {
  6210. if (i > 0)
  6211. {
  6212. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  6213. }
  6214. }
  6215. }
  6216. }
  6217. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  6218. ;
  6219. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  6220. //op,酒店单段模式存储
  6221. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  6222. {
  6223. CurrencyCode = _GroupCostParameters[0].Currency,
  6224. Rate = _GroupCostParameters[0].Rate,
  6225. CostType = _GroupCostParameters[0].CostType,
  6226. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  6227. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  6228. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  6229. };
  6230. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  6231. if (_GroupCostParameters.Count == 2)
  6232. {
  6233. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  6234. }
  6235. foreach (var item in _GroupCostParameters)
  6236. {
  6237. decimal _rate = item.Rate;
  6238. decimal _scale = 0.95M;
  6239. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  6240. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  6241. if (userInfo != null)
  6242. {
  6243. if (userInfo.DepId == 1 || userInfo.DepId == 7)
  6244. {
  6245. if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  6246. {
  6247. _scale = 1.00M;
  6248. }
  6249. }
  6250. }
  6251. #endregion
  6252. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  6253. {
  6254. CurrencyCode = item.Currency,
  6255. Rate = _rate,
  6256. CostType = item.CostType,
  6257. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  6258. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  6259. CostTypeNumber = item.CostTypenumber
  6260. };
  6261. if (_GroupCostParameters.Count > 1)
  6262. {
  6263. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  6264. }
  6265. else
  6266. {
  6267. modulePromptInfo.CostTypeNumber = item.LYJRS;
  6268. }
  6269. if (dto.CTable == 79)//
  6270. {
  6271. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  6272. modulePromptInfo.TotalCost = item.DJCB;
  6273. }
  6274. List<string> costTypes = new List<string>() { "A","B" };
  6275. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  6276. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  6277. if (_GroupCostsDuplicates.Count() == 1)
  6278. {
  6279. _GroupCostsTypeData = _GroupCosts;
  6280. }
  6281. else
  6282. {
  6283. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  6284. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  6285. }
  6286. /*
  6287. * 76 酒店预订
  6288. * 77 行程
  6289. * 79 车/导游地接
  6290. * 80 签证
  6291. * 81 邀请/公务活动
  6292. * 82 团组客户保险
  6293. * 85 机票预订
  6294. * 98 其他款项
  6295. * 285 收款退还
  6296. * 751 酒店早餐
  6297. * 1015 超支费用
  6298. */
  6299. switch (dto.CTable)
  6300. {
  6301. case 76: // 酒店预订
  6302. _ModuleSubPromptInfo.AddRange(
  6303. _GroupCostsTypeData.Select(it => new
  6304. {
  6305. it.DAY,
  6306. it.Date,
  6307. it.ACCON,
  6308. it.ITIN,
  6309. it.SGR,
  6310. it.TBR,
  6311. it.JS_ES,
  6312. it.Suite
  6313. })
  6314. );
  6315. break;
  6316. case 79: // 车/导游地接
  6317. _ModuleSubPromptInfo.AddRange(
  6318. _GroupCostsTypeData.Select(it => new
  6319. {
  6320. Date = it.Date, //日期
  6321. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  6322. GuideFee = (it.TGS + it.TGOF + it.TGM+ it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  6323. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  6324. TicketFee = it.EF * _rate * _scale, //门票费
  6325. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  6326. AirportTransferFee = 0.00M,
  6327. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  6328. TravelSupplies = it.TE * _rate * _scale, //出行物资
  6329. LeadersFee = it.TLF * _rate * _scale, //领队费
  6330. CarFee1 = it.CarCost * _rate * _scale,
  6331. CarType = it.CarType, //车型
  6332. SpentCash = it.PC * _rate * _scale, //零用金
  6333. })
  6334. );
  6335. break;
  6336. case 85: // 机票
  6337. List<dynamic> datas = new List<dynamic>();
  6338. datas.Add(
  6339. new
  6340. {
  6341. AirType = "经济舱",
  6342. AirNum = item.JJCRS,
  6343. AirDRCB = item.JJCCB,
  6344. AirZCB = (item.JJCRS * item.JJCCB)
  6345. }
  6346. );
  6347. datas.Add(
  6348. new
  6349. {
  6350. AirType = "公务舱",
  6351. AirNum = item.GWCRS,
  6352. AirDRCB = item.GWCCB,
  6353. AirZCB = (item.GWCRS * item.GWCCB)
  6354. }
  6355. );
  6356. modulePromptInfo.Data = datas;
  6357. _ModulePromptInfos.Add(modulePromptInfo);
  6358. break;
  6359. default:
  6360. break;
  6361. }
  6362. }
  6363. if (dto.CTable != 85)
  6364. {
  6365. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  6366. _ModulePromptInfos.Add(_ModulePromptInfo);
  6367. }
  6368. _view.ModulePromptInfos = _ModulePromptInfos;
  6369. return Ok(JsonView(true,"操作成功!", _view));
  6370. }
  6371. catch (Exception ex)
  6372. {
  6373. return Ok(JsonView(false, ex.Message));
  6374. }
  6375. }
  6376. #endregion
  6377. #region 酒店预定 保留
  6378. /// <summary>
  6379. /// 酒店预订页面初始化绑定
  6380. /// </summary>
  6381. /// <param name="dto"></param>
  6382. /// <returns></returns>
  6383. [HttpPost]
  6384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6385. public async Task<IActionResult> HotelReservationsInitialize(HotelReservationsDto dto)
  6386. {
  6387. try
  6388. {
  6389. Result groupData = await _hotelPriceRep.HotelReservationsInitialize(dto);
  6390. if (groupData.Code != 0)
  6391. {
  6392. return Ok(JsonView(false, groupData.Msg));
  6393. }
  6394. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6395. }
  6396. catch (Exception ex)
  6397. {
  6398. return Ok(JsonView(false, ex.Message));
  6399. }
  6400. }
  6401. /// <summary>
  6402. /// 根据团组Id查询酒店费用列表
  6403. /// </summary>
  6404. /// <param name="dto"></param>
  6405. /// <returns></returns>
  6406. [HttpPost]
  6407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6408. public async Task<IActionResult> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
  6409. {
  6410. try
  6411. {
  6412. Result groupData = await _hotelPriceRep.HotelReservationsByDiId(dto);
  6413. if (groupData.Code != 0)
  6414. {
  6415. return Ok(JsonView(false, groupData.Msg));
  6416. }
  6417. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6418. }
  6419. catch (Exception ex)
  6420. {
  6421. return Ok(JsonView(false, ex.Message));
  6422. }
  6423. }
  6424. /// <summary>
  6425. /// 根据酒店费用Id查询酒店费用详细
  6426. /// </summary>
  6427. /// <param name="dto"></param>
  6428. /// <returns></returns>
  6429. [HttpPost]
  6430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6431. public async Task<IActionResult> HotelReservationsById(HotelReservationsByIdDto dto)
  6432. {
  6433. try
  6434. {
  6435. Result groupData = await _hotelPriceRep.HotelReservationsById(dto);
  6436. if (groupData.Code != 0)
  6437. {
  6438. return Ok(JsonView(false, groupData.Msg));
  6439. }
  6440. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6441. }
  6442. catch (Exception ex)
  6443. {
  6444. return Ok(JsonView(false, ex.Message));
  6445. }
  6446. }
  6447. /// <summary>
  6448. /// 计算酒店付款总金额
  6449. /// </summary>
  6450. /// <param name="dto"></param>
  6451. /// <returns></returns>
  6452. [HttpPost]
  6453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6454. public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
  6455. {
  6456. try
  6457. {
  6458. Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
  6459. if (groupData.Code != 0)
  6460. {
  6461. return Ok(JsonView(false, groupData.Msg));
  6462. }
  6463. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6464. }
  6465. catch (Exception ex)
  6466. {
  6467. return Ok(JsonView(false, ex.Message));
  6468. }
  6469. }
  6470. /// <summary>
  6471. /// 酒店费用操作(Status:1.新增,2.修改)
  6472. /// </summary>
  6473. /// <param name="dto"></param>
  6474. /// <returns></returns>
  6475. [HttpPost]
  6476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6477. public async Task<IActionResult> OpHotelReservations(OpHotelReservationsData dto)
  6478. {
  6479. try
  6480. {
  6481. Result groupData = await _hotelPriceRep.OpHotelReservations(dto);
  6482. if (groupData.Code != 0)
  6483. {
  6484. return Ok(JsonView(false, groupData.Msg));
  6485. }
  6486. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6487. }
  6488. catch (Exception ex)
  6489. {
  6490. return Ok(JsonView(false, ex.Message));
  6491. }
  6492. }
  6493. /// <summary>
  6494. /// 文件上传
  6495. /// </summary>
  6496. /// <param name="file"></param>
  6497. /// <returns></returns>
  6498. [HttpPost]
  6499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6500. public async Task<IActionResult> UploadHotel(IFormFile file)
  6501. {
  6502. try
  6503. {
  6504. if (file != null)
  6505. {
  6506. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6507. //文件名称
  6508. string projectFileName = file.FileName;
  6509. //上传的文件的路径
  6510. string filePath = "";
  6511. if (!Directory.Exists(fileDir))
  6512. {
  6513. Directory.CreateDirectory(fileDir);
  6514. }
  6515. //上传的文件的路径
  6516. filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
  6517. using (FileStream fs = System.IO.File.Create(filePath))
  6518. {
  6519. file.CopyTo(fs);
  6520. fs.Flush();
  6521. }
  6522. return Ok(JsonView(true, "上传成功!", projectFileName));
  6523. }
  6524. else
  6525. {
  6526. return Ok(JsonView(false, "上传失败!"));
  6527. }
  6528. }
  6529. catch (Exception ex)
  6530. {
  6531. return Ok(JsonView(false, "程序错误!"));
  6532. throw;
  6533. }
  6534. }
  6535. /// <summary>
  6536. /// 删除指定文件
  6537. /// </summary>
  6538. /// <param name="dto"></param>
  6539. /// <returns></returns>
  6540. [HttpPost]
  6541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6542. public async Task<IActionResult> DelFileHotel(DelFileDto dto)
  6543. {
  6544. try
  6545. {
  6546. string filePath = "";
  6547. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6548. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  6549. //int id = 0;
  6550. filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
  6551. // 删除该文件
  6552. try
  6553. {
  6554. System.IO.File.Delete(filePath);
  6555. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  6556. {
  6557. Attachment = "",
  6558. }).ExecuteCommandAsync();
  6559. if (result != 0)
  6560. {
  6561. return Ok(JsonView(true, "成功!"));
  6562. }
  6563. else
  6564. {
  6565. return Ok(JsonView(false, "失败!"));
  6566. }
  6567. }
  6568. catch (Exception)
  6569. {
  6570. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  6571. {
  6572. Attachment = "",
  6573. }).ExecuteCommandAsync();
  6574. if (result != 0)
  6575. {
  6576. return Ok(JsonView(true, "成功!"));
  6577. }
  6578. else
  6579. {
  6580. return Ok(JsonView(false, "失败!"));
  6581. }
  6582. throw;
  6583. }
  6584. }
  6585. catch (Exception ex)
  6586. {
  6587. return Ok(JsonView(false, "程序错误!"));
  6588. throw;
  6589. }
  6590. }
  6591. /// <summary>
  6592. /// 生成VOUCHER
  6593. /// </summary>
  6594. /// <param name=""></param>
  6595. /// <returns></returns>
  6596. [HttpPost]
  6597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6598. public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
  6599. {
  6600. Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
  6601. //判断数据是否完整
  6602. if (h != null)
  6603. {
  6604. if (!string.IsNullOrEmpty(h.DetermineNo))
  6605. {
  6606. string strFileName = "HotelStatement/";
  6607. Grp_DelegationInfo dele = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
  6608. if (dele != null)
  6609. strFileName += dele.TourCode;
  6610. //载入模板
  6611. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  6612. Document doc = new Document(sss);
  6613. DocumentBuilder builder = new DocumentBuilder(doc);
  6614. try
  6615. {
  6616. #region 替换Word模板书签内容
  6617. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  6618. //入住卷预定号码
  6619. if (doc.Range.Bookmarks["VNO"] != null)
  6620. {
  6621. Bookmark mark = doc.Range.Bookmarks["VNO"];
  6622. mark.Text = h.CheckNumber;
  6623. }
  6624. //酒店时间
  6625. if (doc.Range.Bookmarks["Date"] != null)
  6626. {
  6627. Bookmark mark = doc.Range.Bookmarks["Date"];
  6628. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  6629. }
  6630. //团号
  6631. if (doc.Range.Bookmarks["TNo"] != null)
  6632. {
  6633. Bookmark mark = doc.Range.Bookmarks["TNo"];
  6634. mark.Text = dele.TourCode;
  6635. }
  6636. //预定号码
  6637. if (doc.Range.Bookmarks["BookingId"] != null)
  6638. {
  6639. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  6640. mark.Text = h.ReservationsNo;
  6641. }
  6642. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  6643. {
  6644. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  6645. mark.Text = h.DetermineNo;
  6646. }
  6647. //酒店城市
  6648. if (doc.Range.Bookmarks["City"] != null)
  6649. {
  6650. Bookmark mark = doc.Range.Bookmarks["City"];
  6651. mark.Text = h.City;
  6652. }
  6653. //酒店名称
  6654. if (doc.Range.Bookmarks["HName"] != null)
  6655. {
  6656. Bookmark mark = doc.Range.Bookmarks["HName"];
  6657. mark.Text = h.HotelName;
  6658. }
  6659. //酒店地址
  6660. if (doc.Range.Bookmarks["Address"] != null)
  6661. {
  6662. Bookmark mark = doc.Range.Bookmarks["Address"];
  6663. mark.Text = h.HotelAddress;
  6664. }
  6665. //酒店电话
  6666. if (doc.Range.Bookmarks["Tel"] != null)
  6667. {
  6668. Bookmark mark = doc.Range.Bookmarks["Tel"];
  6669. mark.Text = h.HotelTel;
  6670. }
  6671. //酒店传真
  6672. if (doc.Range.Bookmarks["Fax"] != null)
  6673. {
  6674. Bookmark mark = doc.Range.Bookmarks["Fax"];
  6675. if (!string.IsNullOrWhiteSpace(h.HotelFax))
  6676. {
  6677. mark.Text = h.HotelFax;
  6678. }
  6679. }
  6680. //入住时间
  6681. if (doc.Range.Bookmarks["CIn"] != null)
  6682. {
  6683. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  6684. Bookmark mark = doc.Range.Bookmarks["CIn"];
  6685. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  6686. }
  6687. //退房时间
  6688. if (doc.Range.Bookmarks["COut"] != null)
  6689. {
  6690. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  6691. Bookmark mark = doc.Range.Bookmarks["COut"];
  6692. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  6693. }
  6694. //客户名称
  6695. if (doc.Range.Bookmarks["GName"] != null)
  6696. {
  6697. Bookmark mark = doc.Range.Bookmarks["GName"];
  6698. mark.Text = h.GuestName;
  6699. }
  6700. //房间介绍
  6701. if (doc.Range.Bookmarks["ROOM"] != null)
  6702. {
  6703. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  6704. mark.Text = h.RoomExplanation;
  6705. }
  6706. //报价描述
  6707. if (doc.Range.Bookmarks["NOTE"] != null)
  6708. {
  6709. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  6710. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == h.ReservationsWebsite);
  6711. if (ss != null)
  6712. mark.Text = ss.Name;
  6713. }
  6714. //入住时间
  6715. if (doc.Range.Bookmarks["CheckIn"] != null)
  6716. {
  6717. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  6718. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  6719. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  6720. }
  6721. //退房时间
  6722. if (doc.Range.Bookmarks["CheckOut"] != null)
  6723. {
  6724. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  6725. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  6726. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  6727. }
  6728. //日期
  6729. if (doc.Range.Bookmarks["DT"] != null)
  6730. {
  6731. Bookmark mark = doc.Range.Bookmarks["DT"];
  6732. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  6733. }
  6734. //名称
  6735. if (doc.Range.Bookmarks["VName"] != null)
  6736. {
  6737. Bookmark mark = doc.Range.Bookmarks["VName"];
  6738. mark.Text = h.HotelName;
  6739. }
  6740. //号码
  6741. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  6742. {
  6743. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  6744. mark.Text = h.CheckNumber;
  6745. }
  6746. #endregion
  6747. //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  6748. strFileName += "VOUCHER.doc";
  6749. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  6750. doc.Save(fileDir);
  6751. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  6752. return Ok(JsonView(true, "成功!", Url));
  6753. }
  6754. catch (Exception ex)
  6755. {
  6756. throw;
  6757. }
  6758. }
  6759. else
  6760. {
  6761. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  6762. }
  6763. }
  6764. else
  6765. {
  6766. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  6767. }
  6768. }
  6769. /// <summary>
  6770. /// 导出确认单
  6771. /// </summary>
  6772. /// <param name=""></param>
  6773. /// <returns></returns>
  6774. [HttpPost]
  6775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6776. public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
  6777. {
  6778. //团组信息
  6779. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
  6780. //酒店数据
  6781. List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel == 0).ToList();
  6782. //利datatable存储
  6783. DataTable dt = new DataTable();
  6784. dt.Columns.Add("CheckInDate", typeof(string));
  6785. dt.Columns.Add("City", typeof(string));
  6786. dt.Columns.Add("Hotel", typeof(string));
  6787. dt.Columns.Add("Room", typeof(string));
  6788. for (int i = 0; i < listhoteldata.Count; i++)
  6789. {
  6790. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  6791. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  6792. while (dayStart < dayEnd)
  6793. {
  6794. string temp = "";
  6795. DataRow row = dt.NewRow();
  6796. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  6797. row["City"] = listhoteldata[i].City;
  6798. row["Hotel"] = listhoteldata[i].HotelName;
  6799. if (listhoteldata[i].SingleRoomCount > 0)
  6800. {
  6801. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  6802. }
  6803. if (listhoteldata[i].DoubleRoomCount > 0)
  6804. {
  6805. temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
  6806. }
  6807. if (listhoteldata[i].SuiteRoomCount > 0)
  6808. {
  6809. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  6810. }
  6811. if (listhoteldata[i].OtherRoomCount > 0)
  6812. {
  6813. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  6814. }
  6815. row["Room"] = temp;
  6816. dt.Rows.Add(row);
  6817. dayStart = dayStart.AddDays(1);
  6818. }
  6819. }
  6820. Dictionary<string, string> dic = new Dictionary<string, string>();
  6821. dic.Add("Dele", di.TeamName);
  6822. dic.Add("City", di.VisitCountry);
  6823. //模板路径
  6824. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  6825. //载入模板
  6826. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  6827. DocumentBuilder builder = new DocumentBuilder(doc);
  6828. foreach (var key in dic.Keys)
  6829. {
  6830. builder.MoveToBookmark(key);
  6831. builder.Write(dic[key]);
  6832. }
  6833. //获取word里所有表格
  6834. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6835. //获取所填表格的序数
  6836. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6837. var rowStart = tableOne.Rows[0]; //获取第1行
  6838. try
  6839. {
  6840. //循环赋值
  6841. for (int i = 0; i < dt.Rows.Count; i++)
  6842. {
  6843. builder.MoveToCell(0, i + 1, 0, 0);
  6844. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  6845. builder.MoveToCell(0, i + 1, 1, 0);
  6846. builder.Write(dt.Rows[i]["City"].ToString());
  6847. builder.MoveToCell(0, i + 1, 2, 0);
  6848. builder.Write(dt.Rows[i]["Hotel"].ToString());
  6849. builder.MoveToCell(0, i + 1, 3, 0);
  6850. builder.Write(dt.Rows[i]["Room"].ToString());
  6851. }
  6852. }
  6853. catch
  6854. {
  6855. }
  6856. //删除多余行
  6857. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  6858. {
  6859. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  6860. }
  6861. string strFileName = di.TeamName + "酒店确认单.doc";
  6862. try
  6863. {
  6864. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  6865. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  6866. return Ok(JsonView(true, "成功", Url));
  6867. }
  6868. catch (Exception)
  6869. {
  6870. return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
  6871. throw;
  6872. }
  6873. }
  6874. /// <summary>
  6875. /// 酒店费用删除
  6876. /// </summary>
  6877. /// <param name="dto"></param>
  6878. /// <returns></returns>
  6879. [HttpPost]
  6880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6881. public async Task<IActionResult> DelHotelPrice(DelBaseDto dto)
  6882. {
  6883. try
  6884. {
  6885. var res = await _hotelPriceRep.SoftDeleteByIdAsync<Grp_HotelReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6886. if (!res)
  6887. {
  6888. return Ok(JsonView(false, "删除失败"));
  6889. }
  6890. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment()
  6891. {
  6892. IsDel = 1,
  6893. DeleteUserId = dto.DeleteUserId,
  6894. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6895. }).ExecuteCommandAsync();
  6896. return Ok(JsonView(true, "删除成功!"));
  6897. }
  6898. catch (Exception ex)
  6899. {
  6900. return Ok(JsonView(false, "程序错误!"));
  6901. throw;
  6902. }
  6903. }
  6904. #endregion
  6905. #region 酒店预订 新 雷怡 2023-12-28 17:45
  6906. /// <summary>
  6907. /// 酒店预订
  6908. /// 酒店费用列表 根据团组Id查询
  6909. /// </summary>
  6910. /// <param name="_dto"></param>
  6911. /// <returns></returns>
  6912. [HttpPost]
  6913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6914. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  6915. {
  6916. try
  6917. {
  6918. #region 参数验证
  6919. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6920. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6921. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6922. #region 团组操作权限验证 76 酒店预定模块
  6923. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6924. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6925. #endregion
  6926. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6927. #region 页面操作权限验证
  6928. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6929. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  6930. #endregion
  6931. #endregion
  6932. Result _view = await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId);
  6933. if (_view.Code != 0)
  6934. {
  6935. return Ok(JsonView(false, _view.Msg));
  6936. }
  6937. return Ok(JsonView(true, _view.Msg, _view.Data));
  6938. }
  6939. catch (Exception ex)
  6940. {
  6941. return Ok(JsonView(false, ex.Message));
  6942. }
  6943. }
  6944. /// <summary>
  6945. /// 酒店预订
  6946. /// 基础数据
  6947. /// </summary>
  6948. /// <param name="_dto"></param>
  6949. /// <returns></returns>
  6950. [HttpPost]
  6951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6952. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  6953. {
  6954. try
  6955. {
  6956. #region 参数验证
  6957. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6958. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6959. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6960. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6961. #region 页面操作权限验证
  6962. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6963. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  6964. #endregion
  6965. #region 团组操作权限验证 76 酒店预定模块
  6966. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6967. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6968. #endregion
  6969. #endregion
  6970. Result data = await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId);
  6971. if (data.Code != 0)
  6972. {
  6973. return Ok(JsonView(false, data.Msg));
  6974. }
  6975. return Ok(JsonView(true, data.Msg, data.Data));
  6976. }
  6977. catch (Exception ex)
  6978. {
  6979. return Ok(JsonView(false, "Catch:"+ex.Message));
  6980. }
  6981. }
  6982. /// <summary>
  6983. /// 酒店预订
  6984. /// 创建 入住卷号码
  6985. /// </summary>
  6986. /// <param name="_dto"></param>
  6987. /// <returns></returns>
  6988. [HttpPost]
  6989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6990. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  6991. {
  6992. try
  6993. {
  6994. #region 参数验证
  6995. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6996. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6997. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6998. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6999. #region 页面操作权限验证
  7000. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7001. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7002. #endregion
  7003. #region 团组操作权限验证 76 酒店预定模块
  7004. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7005. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7006. #endregion
  7007. #endregion
  7008. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  7009. if (data.Code != 0)
  7010. {
  7011. return Ok(JsonView(false, data.Msg));
  7012. }
  7013. return Ok(JsonView(true, data.Msg, data.Data));
  7014. }
  7015. catch (Exception ex)
  7016. {
  7017. return Ok(JsonView(false, ex.Message));
  7018. }
  7019. }
  7020. /// <summary>
  7021. /// 酒店预订
  7022. /// 详情
  7023. /// </summary>
  7024. /// <param name="_dto"></param>
  7025. /// <returns></returns>
  7026. [HttpPost]
  7027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7028. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  7029. {
  7030. try
  7031. {
  7032. #region 参数验证
  7033. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7034. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7035. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7036. #region 团组操作权限验证 76 酒店预定模块
  7037. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7038. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7039. #endregion
  7040. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7041. #region 页面操作权限验证
  7042. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7043. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7044. #endregion
  7045. #endregion
  7046. Result data = await _hotelPriceRep._Details(_dto.PortType,_dto.Id);
  7047. if (data.Code != 0)
  7048. {
  7049. return Ok(JsonView(false, data.Msg));
  7050. }
  7051. return Ok(JsonView(true, data.Msg, data.Data));
  7052. }
  7053. catch (Exception ex)
  7054. {
  7055. return Ok(JsonView(false, ex.Message));
  7056. }
  7057. }
  7058. /// <summary>
  7059. /// 酒店预订
  7060. /// Add Or Edit
  7061. /// </summary>
  7062. /// <param name="_dto"></param>
  7063. /// <returns></returns>
  7064. [HttpPost]
  7065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7066. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  7067. {
  7068. try
  7069. {
  7070. #region 参数验证
  7071. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7072. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7073. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7074. #region 团组操作权限验证 76 酒店预定模块
  7075. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7076. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7077. #endregion
  7078. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7079. #region 页面操作权限验证
  7080. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7081. if (_dto.Id == 0) // Add
  7082. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  7083. else if (_dto.Id > 0) // Edit
  7084. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  7085. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  7086. #endregion
  7087. #endregion
  7088. Result data = await _hotelPriceRep._AddOrEdit(_dto);
  7089. if (data.Code != 0)
  7090. {
  7091. return Ok(JsonView(false, data.Msg));
  7092. }
  7093. return Ok(JsonView(true, data.Msg, data.Data));
  7094. }
  7095. catch (Exception ex)
  7096. {
  7097. return Ok(JsonView(false, ex.Message));
  7098. }
  7099. }
  7100. /// <summary>
  7101. /// 酒店预订
  7102. /// Del
  7103. /// </summary>
  7104. /// <param name="_dto"></param>
  7105. /// <returns></returns>
  7106. [HttpPost]
  7107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7108. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  7109. {
  7110. try
  7111. {
  7112. #region 参数验证
  7113. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7114. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7115. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7116. #region 团组操作权限验证 76 酒店预定模块
  7117. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7118. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7119. #endregion
  7120. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7121. #region 页面操作权限验证
  7122. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7123. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  7124. #endregion
  7125. #endregion
  7126. Result data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  7127. if (data.Code != 0)
  7128. {
  7129. return Ok(JsonView(false, data.Msg));
  7130. }
  7131. return Ok(JsonView(true, data.Msg, data.Data));
  7132. }
  7133. catch (Exception ex)
  7134. {
  7135. return Ok(JsonView(false, ex.Message));
  7136. }
  7137. }
  7138. /// <summary>
  7139. /// 酒店预订
  7140. /// 生成VOUCHER
  7141. /// </summary>
  7142. /// <param name="_dto"></param>
  7143. /// <returns></returns>
  7144. [HttpPost]
  7145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7146. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  7147. {
  7148. try
  7149. {
  7150. #region 参数验证
  7151. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7152. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7153. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7154. #region 团组操作权限验证 76 酒店预定模块
  7155. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7156. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7157. #endregion
  7158. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7159. #region 页面操作权限验证
  7160. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7161. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  7162. #endregion
  7163. #endregion
  7164. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  7165. //判断数据是否完整
  7166. if (hr != null)
  7167. {
  7168. if (!string.IsNullOrEmpty(hr.DetermineNo))
  7169. {
  7170. string strFileName = "HotelStatement/";
  7171. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  7172. if (dele != null)
  7173. strFileName += dele.TourCode;
  7174. //载入模板
  7175. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  7176. Document doc = new Document(sss);
  7177. DocumentBuilder builder = new DocumentBuilder(doc);
  7178. #region 替换Word模板书签内容
  7179. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  7180. //入住卷预定号码
  7181. if (doc.Range.Bookmarks["VNO"] != null)
  7182. {
  7183. Bookmark mark = doc.Range.Bookmarks["VNO"];
  7184. mark.Text = hr.CheckNumber;
  7185. }
  7186. //酒店时间
  7187. if (doc.Range.Bookmarks["Date"] != null)
  7188. {
  7189. Bookmark mark = doc.Range.Bookmarks["Date"];
  7190. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  7191. }
  7192. //团号
  7193. if (doc.Range.Bookmarks["TNo"] != null)
  7194. {
  7195. Bookmark mark = doc.Range.Bookmarks["TNo"];
  7196. mark.Text = dele.TourCode;
  7197. }
  7198. //预定号码
  7199. if (doc.Range.Bookmarks["BookingId"] != null)
  7200. {
  7201. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  7202. mark.Text = hr.ReservationsNo;
  7203. }
  7204. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  7205. {
  7206. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  7207. mark.Text = hr.DetermineNo;
  7208. }
  7209. //酒店城市
  7210. if (doc.Range.Bookmarks["City"] != null)
  7211. {
  7212. Bookmark mark = doc.Range.Bookmarks["City"];
  7213. mark.Text = hr.City;
  7214. }
  7215. //酒店名称
  7216. if (doc.Range.Bookmarks["HName"] != null)
  7217. {
  7218. Bookmark mark = doc.Range.Bookmarks["HName"];
  7219. mark.Text = hr.HotelName;
  7220. }
  7221. //酒店地址
  7222. if (doc.Range.Bookmarks["Address"] != null)
  7223. {
  7224. Bookmark mark = doc.Range.Bookmarks["Address"];
  7225. mark.Text = hr.HotelAddress;
  7226. }
  7227. //酒店电话
  7228. if (doc.Range.Bookmarks["Tel"] != null)
  7229. {
  7230. Bookmark mark = doc.Range.Bookmarks["Tel"];
  7231. mark.Text = hr.HotelTel;
  7232. }
  7233. //酒店传真
  7234. if (doc.Range.Bookmarks["Fax"] != null)
  7235. {
  7236. Bookmark mark = doc.Range.Bookmarks["Fax"];
  7237. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  7238. {
  7239. mark.Text = hr.HotelFax;
  7240. }
  7241. }
  7242. //入住时间
  7243. if (doc.Range.Bookmarks["CIn"] != null)
  7244. {
  7245. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  7246. Bookmark mark = doc.Range.Bookmarks["CIn"];
  7247. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  7248. }
  7249. //退房时间
  7250. if (doc.Range.Bookmarks["COut"] != null)
  7251. {
  7252. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  7253. Bookmark mark = doc.Range.Bookmarks["COut"];
  7254. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  7255. }
  7256. //客户名称
  7257. if (doc.Range.Bookmarks["GName"] != null)
  7258. {
  7259. string guestName = "";
  7260. string[] clients = new string[] { };
  7261. if (hr.GuestName.Contains(","))
  7262. {
  7263. clients = hr.GuestName.Split(",");
  7264. }
  7265. else
  7266. {
  7267. clients = new string[] { hr.GuestName };
  7268. }
  7269. List<int> clientIds_int = new List<int>();
  7270. if (clients.Length > 0)
  7271. {
  7272. foreach (var item in clients)
  7273. {
  7274. if (item.IsNumeric())
  7275. {
  7276. clientIds_int.Add(int.Parse(item));
  7277. }
  7278. }
  7279. }
  7280. if (clientIds_int.Count > 0)
  7281. {
  7282. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  7283. foreach (var client in _clientDatas)
  7284. {
  7285. //男
  7286. if (client.Sex == 0) guestName += $"Mr.";
  7287. //女
  7288. else if (client.Sex == 1) guestName += $"Ms.";
  7289. if (!String.IsNullOrEmpty(client.FirstName+ client.LastName))
  7290. {
  7291. guestName += $"{string.Join("",client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  7292. }
  7293. //guestName += $"{client.Pinyin},";
  7294. }
  7295. if (guestName.Length > 0)
  7296. {
  7297. guestName = guestName.Substring(0, guestName.Length - 1);
  7298. }
  7299. }
  7300. else
  7301. {
  7302. guestName = hr.GuestName;
  7303. }
  7304. Bookmark mark = doc.Range.Bookmarks["GName"];
  7305. mark.Text = guestName;
  7306. }
  7307. //房间介绍
  7308. if (doc.Range.Bookmarks["ROOM"] != null)
  7309. {
  7310. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  7311. mark.Text = hr.RoomExplanation;
  7312. }
  7313. //报价描述
  7314. if (doc.Range.Bookmarks["NOTE"] != null)
  7315. {
  7316. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  7317. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  7318. if (ss != null)
  7319. mark.Text = ss.Name;
  7320. }
  7321. //入住时间
  7322. if (doc.Range.Bookmarks["CheckIn"] != null)
  7323. {
  7324. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  7325. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  7326. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  7327. }
  7328. //退房时间
  7329. if (doc.Range.Bookmarks["CheckOut"] != null)
  7330. {
  7331. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  7332. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  7333. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  7334. }
  7335. //日期
  7336. if (doc.Range.Bookmarks["DT"] != null)
  7337. {
  7338. Bookmark mark = doc.Range.Bookmarks["DT"];
  7339. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  7340. }
  7341. //名称
  7342. if (doc.Range.Bookmarks["VName"] != null)
  7343. {
  7344. Bookmark mark = doc.Range.Bookmarks["VName"];
  7345. mark.Text = hr.HotelName;
  7346. }
  7347. //号码
  7348. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  7349. {
  7350. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  7351. mark.Text = hr.CheckNumber;
  7352. }
  7353. #endregion
  7354. strFileName += "VOUCHER.doc";
  7355. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  7356. doc.Save(fileDir);
  7357. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  7358. return Ok(JsonView(true, "操作成功!", Url));
  7359. }
  7360. else
  7361. {
  7362. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  7363. }
  7364. }
  7365. else
  7366. {
  7367. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  7368. }
  7369. }
  7370. catch (Exception ex)
  7371. {
  7372. return Ok(JsonView(false, ex.Message));
  7373. }
  7374. }
  7375. /// <summary>
  7376. /// 酒店预订
  7377. /// 确认单
  7378. /// </summary>
  7379. /// <param name="_dto"></param>
  7380. /// <returns></returns>
  7381. [HttpPost]
  7382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7383. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  7384. {
  7385. try
  7386. {
  7387. #region 参数验证
  7388. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7389. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7390. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7391. #region 团组操作权限验证 76 酒店预定模块
  7392. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7393. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7394. #endregion
  7395. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7396. #region 页面操作权限验证
  7397. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7398. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  7399. #endregion
  7400. #endregion
  7401. //团组信息
  7402. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  7403. //酒店数据
  7404. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  7405. if (listhoteldata.Count < 0)
  7406. {
  7407. return Ok(JsonView(false, "当前团组暂无酒店预订信息!"));
  7408. }
  7409. //利datatable存储
  7410. DataTable dt = new DataTable();
  7411. dt.Columns.Add("CheckInDate", typeof(string));
  7412. dt.Columns.Add("City", typeof(string));
  7413. dt.Columns.Add("Hotel", typeof(string));
  7414. dt.Columns.Add("Room", typeof(string));
  7415. for (int i = 0; i < listhoteldata.Count; i++)
  7416. {
  7417. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  7418. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  7419. while (dayStart < dayEnd)
  7420. {
  7421. string temp = "";
  7422. DataRow row = dt.NewRow();
  7423. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  7424. row["City"] = listhoteldata[i].City;
  7425. row["Hotel"] = listhoteldata[i].HotelName;
  7426. if (listhoteldata[i].SingleRoomCount > 0)
  7427. {
  7428. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  7429. }
  7430. if (listhoteldata[i].DoubleRoomCount > 0)
  7431. {
  7432. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  7433. }
  7434. if (listhoteldata[i].SuiteRoomCount > 0)
  7435. {
  7436. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  7437. }
  7438. if (listhoteldata[i].OtherRoomCount > 0)
  7439. {
  7440. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  7441. }
  7442. row["Room"] = temp;
  7443. dt.Rows.Add(row);
  7444. dayStart = dayStart.AddDays(1);
  7445. }
  7446. }
  7447. Dictionary<string, string> dic = new Dictionary<string, string>();
  7448. dic.Add("Dele", di.TeamName);
  7449. dic.Add("City", di.VisitCountry);
  7450. //模板路径
  7451. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  7452. //载入模板
  7453. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  7454. DocumentBuilder builder = new DocumentBuilder(doc);
  7455. foreach (var key in dic.Keys)
  7456. {
  7457. builder.MoveToBookmark(key);
  7458. builder.Write(dic[key]);
  7459. }
  7460. //获取word里所有表格
  7461. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7462. //获取所填表格的序数
  7463. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7464. var rowStart = tableOne.Rows[0]; //获取第1行
  7465. //循环赋值
  7466. for (int i = 0; i < dt.Rows.Count; i++)
  7467. {
  7468. builder.MoveToCell(0, i + 1, 0, 0);
  7469. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  7470. builder.MoveToCell(0, i + 1, 1, 0);
  7471. builder.Write(dt.Rows[i]["City"].ToString());
  7472. builder.MoveToCell(0, i + 1, 2, 0);
  7473. builder.Write(dt.Rows[i]["Hotel"].ToString());
  7474. builder.MoveToCell(0, i + 1, 3, 0);
  7475. builder.Write(dt.Rows[i]["Room"].ToString());
  7476. }
  7477. //删除多余行
  7478. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  7479. {
  7480. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  7481. }
  7482. string strFileName = di.TeamName + "酒店确认单.doc";
  7483. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  7484. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  7485. return Ok(JsonView(true, "成功", url));
  7486. }
  7487. catch (Exception ex)
  7488. {
  7489. return Ok(JsonView(false, ex.Message));
  7490. }
  7491. }
  7492. #endregion
  7493. #region 团组状态
  7494. /// <summary>
  7495. /// 团组状态列表 Page
  7496. /// </summary>
  7497. /// <param name="dto">团组列表请求dto</param>
  7498. /// <returns></returns>
  7499. [HttpPost]
  7500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7501. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  7502. {
  7503. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  7504. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  7505. {
  7506. string sqlWhere = string.Empty;
  7507. if (dto.IsSure == 0) //未完成
  7508. {
  7509. sqlWhere += string.Format(@" And IsSure = 0");
  7510. }
  7511. else if (dto.IsSure == 1) //已完成
  7512. {
  7513. sqlWhere += string.Format(@" And IsSure = 1");
  7514. }
  7515. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  7516. {
  7517. string tj = dto.SearchCriteria;
  7518. 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}%')",
  7519. tj, tj, tj, tj, tj);
  7520. }
  7521. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  7522. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  7523. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  7524. From (
  7525. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  7526. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  7527. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  7528. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  7529. From Grp_DelegationInfo gdi
  7530. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  7531. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  7532. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  7533. Where gdi.IsDel = 0 {0}
  7534. ) temp ", sqlWhere);
  7535. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  7536. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  7537. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  7538. }
  7539. else
  7540. {
  7541. return Ok(JsonView(false, "查询失败"));
  7542. }
  7543. }
  7544. /// <summary>
  7545. /// 团组状态
  7546. /// 设置操作完成
  7547. /// </summary>
  7548. /// <param name="dto">团组列表请求dto</param>
  7549. /// <returns></returns>
  7550. [HttpPost]
  7551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7552. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  7553. {
  7554. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  7555. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  7556. {
  7557. Id = dto.Id,
  7558. IsSure = 1
  7559. };
  7560. var result = await _sqlSugar.Updateable(_DelegationInfo)
  7561. .UpdateColumns(it => new { it.IsSure })
  7562. .WhereColumns(it => new { it.Id })
  7563. .ExecuteCommandAsync();
  7564. if (result > 0)
  7565. {
  7566. return Ok(JsonView(true, "操作完成!"));
  7567. }
  7568. return Ok(JsonView(false, "操作失败!"));
  7569. }
  7570. #endregion
  7571. #region 保险费用录入
  7572. /// <summary>
  7573. /// 根据团组Id查询保险费用列表
  7574. /// </summary>
  7575. /// <param name="dto"></param>
  7576. /// <returns></returns>
  7577. [HttpPost]
  7578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7579. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  7580. {
  7581. try
  7582. {
  7583. Result groupData = await _customersRep.CustomersByDiId(dto);
  7584. if (groupData.Code != 0)
  7585. {
  7586. return Ok(JsonView(false, groupData.Msg));
  7587. }
  7588. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7589. }
  7590. catch (Exception ex)
  7591. {
  7592. return Ok(JsonView(false, ex.Message));
  7593. }
  7594. }
  7595. /// <summary>
  7596. /// 根据保险费用Id查询保险费用详细
  7597. /// </summary>
  7598. /// <param name="dto"></param>
  7599. /// <returns></returns>
  7600. [HttpPost]
  7601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7602. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  7603. {
  7604. try
  7605. {
  7606. Result groupData = await _customersRep.CustomersById(dto);
  7607. if (groupData.Code != 0)
  7608. {
  7609. return Ok(JsonView(false, groupData.Msg));
  7610. }
  7611. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7612. }
  7613. catch (Exception ex)
  7614. {
  7615. return Ok(JsonView(false, ex.Message));
  7616. }
  7617. }
  7618. /// <summary>
  7619. /// 保险费用录入页面初始化绑定
  7620. /// </summary>
  7621. /// <param name="dto"></param>
  7622. /// <returns></returns>
  7623. [HttpPost]
  7624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7625. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  7626. {
  7627. try
  7628. {
  7629. Result groupData = await _customersRep.CustomersInitialize(dto);
  7630. if (groupData.Code != 0)
  7631. {
  7632. return Ok(JsonView(false, groupData.Msg));
  7633. }
  7634. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7635. }
  7636. catch (Exception ex)
  7637. {
  7638. return Ok(JsonView(false, ex.Message));
  7639. }
  7640. }
  7641. /// <summary>
  7642. /// 保险费用操作(Status:1.新增,2.修改)
  7643. /// </summary>
  7644. /// <param name="dto"></param>
  7645. /// <returns></returns>
  7646. [HttpPost]
  7647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7648. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  7649. {
  7650. try
  7651. {
  7652. Result groupData = await _customersRep.OpCustomers(dto);
  7653. if (groupData.Code != 0)
  7654. {
  7655. return Ok(JsonView(false, groupData.Msg));
  7656. }
  7657. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7658. }
  7659. catch (Exception ex)
  7660. {
  7661. return Ok(JsonView(false, ex.Message));
  7662. }
  7663. }
  7664. /// <summary>
  7665. /// 保险文件上传
  7666. /// </summary>
  7667. /// <param name="file"></param>
  7668. /// <returns></returns>
  7669. [HttpPost]
  7670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7671. public async Task<IActionResult> UploadCus(IFormFile file)
  7672. {
  7673. try
  7674. {
  7675. if (file != null)
  7676. {
  7677. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7678. //文件名称
  7679. string projectFileName = file.FileName;
  7680. //上传的文件的路径
  7681. string filePath = "";
  7682. if (!Directory.Exists(fileDir))
  7683. {
  7684. Directory.CreateDirectory(fileDir);
  7685. }
  7686. //上传的文件的路径
  7687. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  7688. using (FileStream fs = System.IO.File.Create(filePath))
  7689. {
  7690. file.CopyTo(fs);
  7691. fs.Flush();
  7692. }
  7693. return Ok(JsonView(true, "上传成功!", projectFileName));
  7694. }
  7695. else
  7696. {
  7697. return Ok(JsonView(false, "上传失败!"));
  7698. }
  7699. }
  7700. catch (Exception ex)
  7701. {
  7702. return Ok(JsonView(false, "程序错误!"));
  7703. throw;
  7704. }
  7705. }
  7706. /// <summary>
  7707. /// 保险删除指定文件
  7708. /// </summary>
  7709. /// <param name="dto"></param>
  7710. /// <returns></returns>
  7711. [HttpPost]
  7712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7713. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  7714. {
  7715. try
  7716. {
  7717. string filePath = "";
  7718. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7719. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  7720. //int id = 0;
  7721. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  7722. // 删除该文件
  7723. try
  7724. {
  7725. System.IO.File.Delete(filePath);
  7726. 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()
  7727. {
  7728. Attachment = "",
  7729. }).ExecuteCommandAsync();
  7730. if (result != 0)
  7731. {
  7732. return Ok(JsonView(true, "成功!"));
  7733. }
  7734. else
  7735. {
  7736. return Ok(JsonView(false, "失败!"));
  7737. }
  7738. }
  7739. catch (Exception)
  7740. {
  7741. 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()
  7742. {
  7743. Attachment = "",
  7744. }).ExecuteCommandAsync();
  7745. if (result != 0)
  7746. {
  7747. return Ok(JsonView(true, "成功!"));
  7748. }
  7749. else
  7750. {
  7751. return Ok(JsonView(false, "失败!"));
  7752. }
  7753. }
  7754. }
  7755. catch (Exception ex)
  7756. {
  7757. return Ok(JsonView(false, "程序错误!"));
  7758. throw;
  7759. }
  7760. }
  7761. /// <summary>
  7762. /// 保险费用操作(删除)
  7763. /// </summary>
  7764. /// <param name="dto"></param>
  7765. /// <returns></returns>
  7766. [HttpPost]
  7767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7768. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  7769. {
  7770. try
  7771. {
  7772. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  7773. if (!res)
  7774. {
  7775. return Ok(JsonView(false, "删除失败"));
  7776. }
  7777. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  7778. {
  7779. IsDel = 1,
  7780. DeleteUserId = dto.DeleteUserId,
  7781. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7782. }).ExecuteCommandAsync();
  7783. return Ok(JsonView(true, "删除成功!"));
  7784. }
  7785. catch (Exception ex)
  7786. {
  7787. return Ok(JsonView(false, "程序错误!"));
  7788. throw;
  7789. }
  7790. }
  7791. #endregion
  7792. #region 接团客户名单 PageId 104
  7793. /// <summary>
  7794. /// 接团客户名单
  7795. /// 根据团组Id查询List
  7796. /// </summary>
  7797. /// <param name="dto"></param>
  7798. /// <returns></returns>
  7799. [HttpPost]
  7800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7801. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  7802. {
  7803. #region 参数验证
  7804. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  7805. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7806. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  7807. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7808. #region 页面操作权限验证
  7809. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7810. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7811. #endregion
  7812. #endregion
  7813. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType,_dto.DiId);
  7814. if (viewData.Code != 0)
  7815. {
  7816. return Ok(JsonView(false, viewData.Msg));
  7817. }
  7818. return Ok(JsonView(viewData.Data));
  7819. }
  7820. /// <summary>
  7821. /// 接团客户名单
  7822. /// 基础数据 Init
  7823. /// </summary>
  7824. /// <param name="_dto"></param>
  7825. /// <returns></returns>
  7826. [HttpPost]
  7827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7828. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  7829. {
  7830. #region 参数验证
  7831. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7832. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7833. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7834. #region 页面操作权限验证
  7835. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7836. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7837. #endregion
  7838. #endregion
  7839. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  7840. if (viewData.Code != 0)
  7841. {
  7842. return Ok(JsonView(false, viewData.Msg));
  7843. }
  7844. return Ok(JsonView(viewData.Data));
  7845. }
  7846. /// <summary>
  7847. /// 接团客户名单
  7848. /// 根据 Id查询 Details
  7849. /// </summary>
  7850. /// <param name="_dto"></param>
  7851. /// <returns></returns>
  7852. [HttpPost]
  7853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7854. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  7855. {
  7856. #region 参数验证
  7857. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7858. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7859. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  7860. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7861. #region 页面操作权限验证
  7862. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7863. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7864. #endregion
  7865. #endregion
  7866. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  7867. if (viewData.Code != 0)
  7868. {
  7869. return Ok(JsonView(false, viewData.Msg));
  7870. }
  7871. return Ok(JsonView(viewData.Data));
  7872. }
  7873. /// <summary>
  7874. /// 接团客户名单
  7875. /// Add Or Edit
  7876. /// </summary>
  7877. /// <param name="_dto"></param>
  7878. /// <returns></returns>
  7879. [HttpPost]
  7880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7881. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  7882. {
  7883. #region 参数验证
  7884. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7885. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7886. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  7887. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7888. #region 页面操作权限验证
  7889. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7890. if (_dto.Id == 0) //添加
  7891. {
  7892. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  7893. }else if (_dto.Id >= 0) //修改
  7894. {
  7895. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  7896. }
  7897. #endregion
  7898. #endregion
  7899. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  7900. if (viewData.Code != 0)
  7901. {
  7902. return Ok(JsonView(false, viewData.Msg));
  7903. }
  7904. return Ok(JsonView(true));
  7905. }
  7906. /// <summary>
  7907. /// 接团客户名单
  7908. /// AddMultiple(添加多个)
  7909. /// </summary>
  7910. /// <param name="_dto"></param>
  7911. /// <returns></returns>
  7912. [HttpPost]
  7913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7914. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  7915. {
  7916. #region 参数验证
  7917. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7918. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7919. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7920. #region 页面操作权限验证
  7921. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7922. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  7923. #endregion
  7924. #endregion
  7925. var viewData = await _tourClientListRep._AddMultiple(_dto);
  7926. if (viewData.Code != 0)
  7927. {
  7928. return Ok(JsonView(false, viewData.Msg));
  7929. }
  7930. return Ok(JsonView(true));
  7931. }
  7932. /// <summary>
  7933. /// 接团客户名单
  7934. /// Del
  7935. /// </summary>
  7936. /// <param name="_dto"></param>
  7937. /// <returns></returns>
  7938. [HttpPost]
  7939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7940. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  7941. {
  7942. #region 参数验证
  7943. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7944. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7945. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7946. #region 页面操作权限验证
  7947. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7948. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  7949. #endregion
  7950. #endregion
  7951. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  7952. if (viewData.Code != 0)
  7953. {
  7954. return Ok(JsonView(false, viewData.Msg));
  7955. }
  7956. return Ok(JsonView(true));
  7957. }
  7958. /// <summary>
  7959. /// 接团客户名单
  7960. /// 文件下载 客户名单
  7961. /// </summary>
  7962. /// <param name="_dto"></param>
  7963. /// <returns></returns>
  7964. [HttpPost]
  7965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7966. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  7967. {
  7968. #region 参数验证
  7969. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7970. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7971. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  7972. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7973. #region 页面操作权限验证
  7974. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7975. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  7976. #endregion
  7977. #endregion
  7978. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  7979. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  7980. From Grp_TourClientList tcl
  7981. Left Join
  7982. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  7983. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  7984. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  7985. From Crm_DeleClient dc
  7986. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  7987. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  7988. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  7989. Where dc.IsDel = 0) temp
  7990. On temp.DcId =tcl.ClientId
  7991. Where tcl.IsDel = 0 And tcl.DiId = {0}",_dto.DiId);
  7992. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  7993. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  7994. //载入模板
  7995. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  7996. //载入模板
  7997. var doc = new Document(tempPath);
  7998. DocumentBuilder builder = new DocumentBuilder(doc);
  7999. //获取word里所有表格
  8000. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8001. //获取所填表格的序数
  8002. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8003. var rowStart = tableOne.Rows[0]; //获取第1行
  8004. //循环赋值
  8005. for (int i = 0; i < DcList.Count; i++)
  8006. {
  8007. builder.MoveToCell(0, i + 1, 0, 0);
  8008. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  8009. builder.MoveToCell(0, i + 1, 1, 0);
  8010. int sex = DcList[i].Sex;
  8011. string sexStr = string.Empty;
  8012. if (sex == 0) sexStr = "男";
  8013. else if (sex == 1) sexStr = "女";
  8014. else sexStr = "未设置";
  8015. builder.Write(sexStr);
  8016. builder.MoveToCell(0, i + 1, 2, 0);
  8017. string birthDay = DcList[i].BirthDay;
  8018. string birthDayStr = string.Empty;
  8019. if (!string.IsNullOrEmpty(birthDay))
  8020. {
  8021. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  8022. }
  8023. builder.Write(birthDayStr);
  8024. builder.MoveToCell(0, i + 1, 3, 0);
  8025. builder.Write(DcList[i].CompanyFullName);
  8026. builder.MoveToCell(0, i + 1, 4, 0);
  8027. builder.Write(DcList[i].Job);
  8028. }
  8029. //删除多余行
  8030. while (tableOne.Rows.Count > DcList.Count + 1)
  8031. {
  8032. tableOne.Rows.RemoveAt(DcList.Count + 1);
  8033. }
  8034. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  8035. var fileDir = AppSettingsHelper.Get("WordBasePath") + fileName;
  8036. doc.Save(fileDir);
  8037. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + fileName;
  8038. return Ok(JsonView(true, "操作成功!", Url));
  8039. }
  8040. #endregion
  8041. #region 团组倒推表
  8042. /// <summary>
  8043. /// 倒推表基础数据
  8044. /// Init
  8045. /// </summary>
  8046. /// <param name="dto"></param>
  8047. /// <returns></returns>
  8048. [HttpPost]
  8049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8050. public async Task<IActionResult> PostInvertedListInit()
  8051. {
  8052. var viewData = await _invertedListRep._Init();
  8053. if (viewData.Code != 0)
  8054. {
  8055. return Ok(JsonView(false, viewData.Msg));
  8056. }
  8057. return Ok(JsonView(viewData.Data));
  8058. }
  8059. /// <summary>
  8060. /// 倒推表
  8061. /// Info
  8062. /// </summary>
  8063. /// <param name="dto"></param>
  8064. /// <returns></returns>
  8065. [HttpPost]
  8066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8067. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  8068. {
  8069. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  8070. if (viewData.Code != 0)
  8071. {
  8072. return Ok(JsonView(false, viewData.Msg));
  8073. }
  8074. return Ok(JsonView(viewData.Data));
  8075. }
  8076. /// <summary>
  8077. /// 倒推表
  8078. /// Create
  8079. /// </summary>
  8080. /// <param name="dto"></param>
  8081. /// <returns></returns>
  8082. [HttpPost]
  8083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8084. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  8085. {
  8086. var viewData = await _invertedListRep._Create(dto.PortType,dto.DiId);
  8087. if (viewData.Code != 0)
  8088. {
  8089. return Ok(JsonView(false, viewData.Msg));
  8090. }
  8091. return Ok(JsonView(viewData.Data));
  8092. }
  8093. /// <summary>
  8094. /// 倒推表
  8095. /// Update
  8096. /// </summary>
  8097. /// <param name="dto"></param>
  8098. /// <returns></returns>
  8099. [HttpPost]
  8100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8101. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  8102. {
  8103. var viewData = await _invertedListRep._Update(dto);
  8104. if (viewData.Code != 0)
  8105. {
  8106. return Ok(JsonView(false, viewData.Msg));
  8107. }
  8108. return Ok(JsonView(viewData.Data));
  8109. }
  8110. /// <summary>
  8111. /// 倒推表
  8112. /// File Download
  8113. /// </summary>
  8114. /// <param name="dto"></param>
  8115. /// <returns></returns>
  8116. [HttpPost]
  8117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8118. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  8119. {
  8120. var info1 = await _invertedListRep._sqlSugar.Queryable<Grp_InvertedList>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).FirstAsync();
  8121. if (info1 == null)
  8122. {
  8123. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  8124. }
  8125. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  8126. string teamName = "";
  8127. if (info != null) teamName = info.TeamName;
  8128. //载入模板
  8129. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  8130. DocumentBuilder builder = new DocumentBuilder(doc);
  8131. //利用键值对存放数据
  8132. Dictionary<string, string> dic = new Dictionary<string, string>();
  8133. dic.Add("TeamName", teamName);
  8134. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime());
  8135. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  8136. dic.Add("BPRemark", info1.ApprovalDataRemark);
  8137. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  8138. dic.Add("SQRemark", info1.ApprovalRemark);
  8139. dic.Add("CPJtime", info1.ApprovalDt.ConvertToDatetime());
  8140. dic.Add("CPJRemark", info1.ApprovalRemark);
  8141. dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  8142. dic.Add("HZRemark", info1.ApplyPassportRemark);
  8143. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  8144. dic.Add("QZRemark", info1.VisaInformationRemark);
  8145. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  8146. dic.Add("SQQZRemark", info1.SendVisaRemark);
  8147. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  8148. dic.Add("CQRemark", info1.IssueVisaRemark);
  8149. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  8150. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  8151. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  8152. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  8153. #region 填充word模板书签内容
  8154. foreach (var key in dic.Keys)
  8155. {
  8156. builder.MoveToBookmark(key);
  8157. builder.Write(dic[key]);
  8158. }
  8159. #endregion
  8160. var fileDir = AppSettingsHelper.Get("WordBasePath");
  8161. string fileName = $"{teamName}团出行准备流程表.doc";
  8162. string filePath = fileDir + $@"InvertedList/{fileName}";
  8163. doc.Save(filePath);
  8164. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  8165. return Ok(JsonView(true, "操作成功!", Url));
  8166. }
  8167. #endregion
  8168. }
  8169. }