GroupsController.cs 418 KB

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