GroupsController.cs 558 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. using System.Collections;
  32. using Org.BouncyCastle.Ocsp;
  33. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. using Microsoft.AspNetCore.Mvc.ViewEngines;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.Entities.Financial;
  41. using NPOI.POIFS.Crypt.Dsig;
  42. using System.Diagnostics.Eventing.Reader;
  43. using System.IO;
  44. using StackExchange.Redis;
  45. using Org.BouncyCastle.Utilities;
  46. using Aspose.Words.Drawing;
  47. using Aspose.Cells.Charts;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using Quartz.Util;
  50. using Google.Protobuf.WellKnownTypes;
  51. using Microsoft.AspNetCore.SignalR;
  52. using OASystem.API.OAMethodLib.Hub.HubClients;
  53. using OASystem.API.OAMethodLib.Hub.Hubs;
  54. using System.Collections.Generic;
  55. using OASystem.API.OAMethodLib.JuHeAPI;
  56. using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
  57. using SixLabors.Fonts.Tables.AdvancedTypographic;
  58. using Microsoft.EntityFrameworkCore;
  59. using System.Security.Cryptography.Xml;
  60. using MathNet.Numerics;
  61. using System.Security.Policy;
  62. using System.Xml;
  63. using OASystem.Domain.Dtos.QiYeWeChat;
  64. using static NPOI.POIFS.Crypt.CryptoFunctions;
  65. using Aspose.Words.Lists;
  66. using OASystem.API.OAMethodLib.YouDaoAPI;
  67. using NPOI.XSSF.Streaming.Values;
  68. using OASystem.API.OAMethodLib.Quartz.Business;
  69. using System.Linq;
  70. using NPOI.POIFS.NIO;
  71. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  72. using OASystem.Domain.ViewModels.Statistics;
  73. using NPOI.XSSF.Model;
  74. using NetTaste;
  75. using Microsoft.AspNetCore.Http;
  76. using EyeSoft.Collections.Generic;
  77. using NPOI.HSSF.Util;
  78. using NPOI.HSSF.UserModel;
  79. using NPOI.SS.UserModel;
  80. using NPOI.XSSF.UserModel;
  81. using MySqlX.XDevAPI.Relational;
  82. using SqlSugar.Extensions;
  83. using Table = Aspose.Words.Tables.Table;
  84. using Aspose.Cells.Tables;
  85. using NPOI.SS.Util;
  86. using RestSharp.Extensions;
  87. using Microsoft.AspNetCore.WebUtilities;
  88. using K4os.Compression.LZ4.Internal;
  89. namespace OASystem.API.Controllers
  90. {
  91. /// <summary>
  92. /// 团组相关
  93. /// </summary>
  94. //[Authorize]
  95. [Route("api/[controller]/[action]")]
  96. public class GroupsController : ControllerBase
  97. {
  98. private readonly GrpScheduleRepository _grpScheduleRep;
  99. private readonly IMapper _mapper;
  100. private readonly DelegationInfoRepository _groupRepository;
  101. private readonly TaskAssignmentRepository _taskAssignmentRep;
  102. private readonly AirTicketResRepository _airTicketResRep;
  103. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  104. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  105. private readonly DelegationEnDataRepository _delegationEnDataRep;
  106. private readonly DelegationVisaRepository _delegationVisaRep;
  107. private readonly VisaPriceRepository _visaPriceRep;
  108. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  109. private readonly HotelPriceRepository _hotelPriceRep;
  110. private readonly CustomersRepository _customersRep;
  111. private readonly MessageRepository _message;
  112. private readonly SqlSugarClient _sqlSugar;
  113. private readonly TourClientListRepository _tourClientListRep;
  114. private readonly TeamRateRepository _teamRateRep;
  115. #region 成本相关
  116. private readonly CheckBoxsRepository _checkBoxs;
  117. private readonly GroupCostRepository _GroupCostRepository;
  118. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  119. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  120. #endregion
  121. private readonly SetDataRepository _setDataRep;
  122. private string url;
  123. private string path;
  124. private readonly EnterExitCostRepository _enterExitCostRep;
  125. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  126. private readonly UsersRepository _usersRep;
  127. private readonly IJuHeApiService _juHeApi;
  128. private readonly InvertedListRepository _invertedListRep;
  129. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  130. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  131. private readonly HotelInquiryRepository _hotelInquiryRep;
  132. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  133. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  134. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  135. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  136. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  137. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  138. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  139. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep)
  140. {
  141. _mapper = mapper;
  142. _grpScheduleRep = grpScheduleRep;
  143. _groupRepository = groupRepository;
  144. _taskAssignmentRep = taskAssignmentRep;
  145. _airTicketResRep = airTicketResRep;
  146. _sqlSugar = sqlSugar;
  147. url = AppSettingsHelper.Get("ExcelBaseUrl");
  148. path = AppSettingsHelper.Get("ExcelBasePath");
  149. if (!System.IO.Directory.Exists(path))
  150. {
  151. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  152. }
  153. _decreasePaymentsRep = decreasePaymentsRep;
  154. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  155. _delegationEnDataRep = delegationEnDataRep;
  156. _enterExitCostRep = enterExitCostRep;
  157. _delegationVisaRep = delegationVisaRep;
  158. _message = message;
  159. _visaPriceRep = visaPriceRep;
  160. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  161. _checkBoxs = checkBoxs;
  162. _GroupCostRepository = GroupCostRepository;
  163. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  164. _GroupCostParameterRepository = GroupCostParameterRepository;
  165. _hotelPriceRep = hotelPriceRep;
  166. _customersRep = customersRep;
  167. _setDataRep = setDataRep;
  168. _tourClientListRep = tourClientListRep;
  169. _teamRateRep = teamRateRep;
  170. _hubContext = hubContext;
  171. _usersRep = usersRep;
  172. _juHeApi = juHeApi;
  173. _invertedListRep = invertedListRep;
  174. _visaFeeInfoRep = visaFeeInfoRep;
  175. _ticketBlackCodeRep = ticketBlackCodeRep;
  176. _hotelInquiryRep = hotelInquiryRep;
  177. }
  178. #region 流程管控
  179. /// <summary>
  180. /// 获取团组流程管控信息
  181. /// </summary>
  182. /// <param name="paras">参数Json字符串</param>
  183. /// <returns></returns>
  184. [HttpPost]
  185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  186. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  187. {
  188. if (string.IsNullOrEmpty(_jsonDto.Paras))
  189. {
  190. return Ok(JsonView(false, "参数为空"));
  191. }
  192. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  193. if (_ScheduleDto != null)
  194. {
  195. if (_ScheduleDto.SearchType == 2)//获取列表
  196. {
  197. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  198. return Ok(JsonView(_grpScheduleViewList));
  199. }
  200. else//获取对象
  201. {
  202. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  203. if (_grpScheduleView != null)
  204. {
  205. return Ok(JsonView(_grpScheduleView));
  206. }
  207. }
  208. }
  209. else
  210. {
  211. return Ok(JsonView(false, "参数反序列化失败"));
  212. }
  213. return Ok(JsonView(false, "暂无数据!"));
  214. }
  215. /// <summary>
  216. /// 修改团组流程管控详细表数据
  217. /// </summary>
  218. /// <param name="paras"></param>
  219. /// <returns></returns>
  220. [HttpPost]
  221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  222. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  223. {
  224. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  225. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  226. .SetColumns(it => it.Duty == _detail.Duty)
  227. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  228. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  229. .SetColumns(it => it.JobContent == _detail.JobContent)
  230. .SetColumns(it => it.Remark == _detail.Remark)
  231. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  232. .Where(s => s.Id == dto.Id)
  233. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  234. .ExecuteCommandAsync();
  235. if (result > 0)
  236. {
  237. return Ok(JsonView(true, "保存成功!"));
  238. }
  239. return Ok(JsonView(false, "保存失败!"));
  240. }
  241. /// <summary>
  242. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  243. /// </summary>
  244. /// <param name="dto"></param>
  245. /// <returns></returns>
  246. [HttpPost]
  247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  248. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  249. {
  250. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  251. _detail.IsDel = 1;
  252. _detail.DeleteUserId = dto.Duty;
  253. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  254. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  255. .SetColumns(it => it.IsDel == _detail.IsDel)
  256. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  257. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  258. .Where(it => it.Id == dto.Id)
  259. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  260. //.WhereColumns(s => s.Id == dto.Id)
  261. .ExecuteCommandAsync();
  262. if (result > 0)
  263. {
  264. return Ok(JsonView(true, "删除成功!"));
  265. }
  266. return Ok(JsonView(false, "删除失败!"));
  267. }
  268. /// <summary>
  269. /// 增加团组流程管控详细表数据
  270. /// </summary>
  271. /// <param name="dto"></param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  275. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  276. {
  277. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  278. if (DateTime.Now < _detail.ExpectBeginDt)
  279. {
  280. _detail.StepStatus = 0;
  281. }
  282. else
  283. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  284. _detail.StepStatus = 1;
  285. }
  286. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  287. if (result > 0)
  288. {
  289. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  290. return Ok(JsonView(true, "添加成功!", _result));
  291. }
  292. return Ok(JsonView(false, "添加失败!"));
  293. }
  294. #endregion
  295. #region 团组基本信息
  296. /// <summary>
  297. /// 接团信息列表
  298. /// </summary>
  299. /// <param name="dto">团组列表请求dto</param>
  300. /// <returns></returns>
  301. [HttpPost]
  302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  303. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  304. {
  305. var groupData = await _groupRepository.GetGroupList(dto);
  306. if (groupData.Code != 0)
  307. {
  308. return Ok(JsonView(false, groupData.Msg));
  309. }
  310. return Ok(JsonView(groupData.Data));
  311. }
  312. /// <summary>
  313. /// 接团信息列表 Page
  314. /// </summary>
  315. /// <param name="dto">团组列表请求dto</param>
  316. /// <returns></returns>
  317. [HttpPost]
  318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  319. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  320. {
  321. #region 参数验证
  322. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  323. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  324. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  325. #region 页面操作权限验证
  326. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  327. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  328. #endregion
  329. #endregion
  330. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  331. {
  332. string sqlWhere = string.Empty;
  333. if (dto.IsSure == 0) //未完成
  334. {
  335. sqlWhere += string.Format(@" And IsSure = 0");
  336. }
  337. else if (dto.IsSure == 1) //已完成
  338. {
  339. sqlWhere += string.Format(@" And IsSure = 1");
  340. }
  341. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  342. {
  343. string tj = dto.SearchCriteria;
  344. 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}%')",
  345. tj, tj, tj, tj, tj);
  346. }
  347. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  348. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  349. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  350. JietuanOperator,IsSure,CreateTime
  351. From (
  352. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  353. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  354. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  355. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  356. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  357. From Grp_DelegationInfo gdi
  358. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  359. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  360. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  361. Where gdi.IsDel = 0 {0}
  362. ) temp", sqlWhere);
  363. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  364. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  365. #region 处理所属部门
  366. /*
  367. * 1.sq 和 gyy 等显示 市场部
  368. * 2.王鸽和主管及张总还有管理员号统一国交部
  369. * 2-1. 4 管理员 ,21 张海麟
  370. */
  371. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  372. List<int> userIds1 = new List<int>() { 4, 21 };
  373. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  374. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  375. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  376. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  377. .ToList();
  378. foreach (var item in _DelegationList)
  379. {
  380. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  381. }
  382. #endregion
  383. var _view = new
  384. {
  385. PageFuncAuth = pageFunAuthView,
  386. Data = _DelegationList
  387. };
  388. return Ok(JsonView(true, "查询成功!", _view, total));
  389. }
  390. else
  391. {
  392. return Ok(JsonView(false, "查询失败"));
  393. }
  394. }
  395. /// <summary>
  396. /// 团组列表
  397. /// </summary>
  398. /// <returns></returns>
  399. [HttpPost]
  400. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  401. {
  402. #region 参数验证
  403. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  404. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  405. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  406. #region 页面操作权限验证
  407. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  408. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  409. #endregion
  410. #endregion
  411. if (dto.PortType != 1 && dto.PortType != 2)
  412. {
  413. return Ok(JsonView(false, "查询失败!"));
  414. }
  415. string orderbyStr = "order by gdi.CreateTime Desc";
  416. string sqlWhere = string.Empty;
  417. if (dto.IsSure == 0) //未完成
  418. {
  419. sqlWhere += string.Format(@" And IsSure = 0");
  420. }
  421. else if (dto.IsSure == 1) //已完成
  422. {
  423. sqlWhere += string.Format(@" And IsSure = 1");
  424. }
  425. //团组类型
  426. if (dto.TeamDid > 0)
  427. {
  428. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  429. }
  430. //团组名称
  431. if (!string.IsNullOrEmpty(dto.TeamName))
  432. {
  433. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  434. }
  435. //客户名称
  436. if (!string.IsNullOrEmpty(dto.ClientName))
  437. {
  438. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  439. }
  440. //客户单位
  441. if (!string.IsNullOrEmpty(dto.ClientUnit))
  442. {
  443. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  444. }
  445. //出访时间
  446. if (!string.IsNullOrEmpty(dto.visitDataTime))
  447. {
  448. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  449. orderbyStr = "order by gdi.VisitDate";
  450. }
  451. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  452. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  453. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  454. JietuanOperator,IsSure,CreateTime
  455. From (
  456. Select row_number() over({0}) as Row_Number,
  457. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  458. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  459. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  460. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  461. From Grp_DelegationInfo gdi
  462. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  463. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  464. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  465. Where gdi.IsDel = 0 {1}
  466. ) temp ", orderbyStr, sqlWhere);
  467. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  468. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  469. #region 处理所属部门
  470. /*
  471. * 1.sq 和 gyy 等显示 市场部
  472. * 2.王鸽和主管及张总还有管理员号统一国交部
  473. * 2-1. 4 管理员 ,21 张海麟
  474. */
  475. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  476. List<int> userIds1 = new List<int>() { 4, 21 };
  477. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  478. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  479. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  480. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  481. .ToList();
  482. foreach (var item in _DelegationList)
  483. {
  484. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  485. }
  486. #endregion
  487. var _view = new
  488. {
  489. PageFuncAuth = pageFunAuthView,
  490. Data = _DelegationList
  491. };
  492. return Ok(JsonView(true, "查询成功!", _view, total));
  493. }
  494. /// <summary>
  495. /// 接团信息详情
  496. /// </summary>
  497. /// <param name="dto">团组info请求dto</param>
  498. /// <returns></returns>
  499. [HttpPost]
  500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  501. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  502. {
  503. var groupData = await _groupRepository.GetGroupInfo(dto);
  504. if (groupData.Code != 0)
  505. {
  506. return Ok(JsonView(false, groupData.Msg));
  507. }
  508. return Ok(JsonView(groupData.Data));
  509. }
  510. /// <summary>
  511. /// 接团信息 编辑添加
  512. /// 基础信息数据源
  513. /// </summary>
  514. /// <param name="dto"></param>
  515. /// <returns></returns>
  516. [HttpPost]
  517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  518. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  519. {
  520. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  521. if (groupData.Code != 0)
  522. {
  523. return Ok(JsonView(false, groupData.Msg));
  524. }
  525. return Ok(JsonView(groupData.Data));
  526. }
  527. /// <summary>
  528. /// 接团信息 操作(增改)
  529. /// </summary>
  530. /// <param name="dto"></param>
  531. /// <returns></returns>
  532. [HttpPost]
  533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  534. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  535. {
  536. try
  537. {
  538. var groupData = await _groupRepository.GroupOperation(dto);
  539. if (groupData.Code != 0)
  540. {
  541. return Ok(JsonView(false, groupData.Msg));
  542. }
  543. int diId = 0;
  544. //添加时 默认加入团组汇率
  545. if (dto.Status == 1) //添加
  546. {
  547. diId = groupData.Data;
  548. //添加默认币种
  549. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  550. //默认分配权限
  551. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  552. //消息提示 王鸽 主管号
  553. List<int> _managerIds = new List<int>() { 22, 32 };
  554. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  555. if (userIds.Count > 0)
  556. {
  557. userIds.Add(208);
  558. //创建团组管控
  559. GroupStepForDelegation.CreateWorkStep(diId);
  560. //发送消息
  561. string groupName = dto.TeamName;
  562. string createGroupUser = string.Empty;
  563. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  564. if (userInfo != null) createGroupUser = userInfo.CnName;
  565. string title = $"系统通知";
  566. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  567. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  568. }
  569. //默认创建倒推表
  570. await _invertedListRep._Create(dto.UserId, diId);
  571. }
  572. else if (dto.Status == 2)
  573. {
  574. diId = dto.Id;
  575. }
  576. return Ok(JsonView(true, "操作成功!", diId));
  577. }
  578. catch (Exception ex)
  579. {
  580. Logs("[response]" + JsonConvert.SerializeObject(dto));
  581. Logs(ex.Message);
  582. return Ok(JsonView(false, ex.Message));
  583. }
  584. }
  585. /// <summary>
  586. /// 接团流程操作(增改)
  587. /// 安卓端使用 建团时添加客户名单
  588. /// </summary>
  589. /// <param name="dto"></param>
  590. /// <returns></returns>
  591. [HttpPost]
  592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  593. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  594. {
  595. try
  596. {
  597. #region 参数验证
  598. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  599. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  600. #region 页面操作权限验证
  601. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  602. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  603. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  604. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  605. #endregion
  606. #endregion
  607. _sqlSugar.BeginTran();
  608. var _dto = new GroupOperationDto();
  609. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  610. var groupData = await _groupRepository.GroupOperation(_dto);
  611. if (groupData.Code != 0)
  612. {
  613. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  614. }
  615. int diId = 0;
  616. //添加时 默认加入团组汇率
  617. if (dto.Status == 1) //添加
  618. {
  619. diId = groupData.Data;
  620. //添加默认币种
  621. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  622. //默认分配权限
  623. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  624. //消息提示 王鸽 主管号
  625. List<int> _managerIds = new List<int>() { 22, 32 };
  626. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  627. if (userIds.Count > 0)
  628. {
  629. userIds.Add(208);
  630. //创建团组管控
  631. GroupStepForDelegation.CreateWorkStep(diId);
  632. //发送消息
  633. string groupName = dto.TeamName;
  634. string createGroupUser = string.Empty;
  635. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  636. if (userInfo != null) createGroupUser = userInfo.CnName;
  637. string title = $"系统通知";
  638. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  639. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  640. }
  641. }
  642. if (dto.Status == 2)
  643. {
  644. diId = dto.Id;
  645. if (diId == 0)
  646. {
  647. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  648. }
  649. }
  650. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  651. if (viewData.Code != 0)
  652. {
  653. _sqlSugar.RollbackTran();
  654. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  655. }
  656. _sqlSugar.CommitTran();
  657. return Ok(JsonView(true, "添加成功"));
  658. }
  659. catch (Exception ex)
  660. {
  661. _sqlSugar.RollbackTran();
  662. return Ok(JsonView(false, ex.Message));
  663. }
  664. }
  665. /// <summary>
  666. /// 接团信息 操作(删除)
  667. /// </summary>
  668. /// <param name="dto"></param>
  669. /// <returns></returns>
  670. [HttpPost]
  671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  672. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  673. {
  674. try
  675. {
  676. var groupData = await _groupRepository.GroupDel(dto);
  677. if (groupData.Code != 0)
  678. {
  679. return Ok(JsonView(false, groupData.Msg));
  680. }
  681. return Ok(JsonView(true));
  682. }
  683. catch (Exception ex)
  684. {
  685. Logs("[response]" + JsonConvert.SerializeObject(dto));
  686. Logs(ex.Message);
  687. return Ok(JsonView(false, ex.Message));
  688. }
  689. }
  690. /// <summary>
  691. /// 获取团组销售报价号
  692. /// 团组添加时 使用
  693. /// </summary>
  694. /// <returns></returns>
  695. [HttpPost]
  696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  697. public async Task<IActionResult> GetGroupSalesQuoteNo()
  698. {
  699. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  700. if (groupData.Code != 0)
  701. {
  702. return Ok(JsonView(false, groupData.Msg));
  703. }
  704. object salesQuoteNo = new
  705. {
  706. SalesQuoteNo = groupData.Data
  707. };
  708. return Ok(JsonView(salesQuoteNo));
  709. }
  710. /// <summary>
  711. /// 设置确认出团
  712. /// </summary>
  713. /// <param name="dto"></param>
  714. /// <returns></returns>
  715. [HttpPost]
  716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  717. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  718. {
  719. var groupData = await _groupRepository.ConfirmationGroup(dto);
  720. if (groupData.Code != 0)
  721. {
  722. return Ok(JsonView(false, groupData.Msg));
  723. }
  724. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  725. #region OA消息推送
  726. try
  727. {
  728. string groupName = groupInfo.TeamName;
  729. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  730. List<int> userIds = new List<int>();
  731. listUser.ForEach(s => userIds.Add(s.Id));
  732. string title = $"系统通知";
  733. string content = $"团组[{groupName}]已确认出团!";
  734. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  735. }
  736. catch (Exception ex)
  737. {
  738. }
  739. #endregion
  740. #region 应用推送
  741. try
  742. {
  743. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  744. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  745. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  746. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  747. {
  748. List<string> userList = new List<string>() { users.QiyeChatUserId };
  749. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  750. }
  751. }
  752. catch (Exception ex)
  753. {
  754. }
  755. #endregion
  756. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  757. return Ok(JsonView(true, "操作成功!", groupData.Data));
  758. }
  759. /// <summary>
  760. /// 获取团组名称data And 签证国别Data
  761. /// </summary>
  762. /// <param name="dto"></param>
  763. /// <returns></returns>
  764. [HttpPost]
  765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  766. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  767. {
  768. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  769. if (groupData.Code != 0)
  770. {
  771. return Ok(JsonView(false, groupData.Msg));
  772. }
  773. return Ok(JsonView(groupData.Data));
  774. }
  775. /// <summary>
  776. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  777. /// </summary>
  778. /// <returns></returns>
  779. [HttpPost]
  780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  781. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  782. {
  783. try
  784. {
  785. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  786. if (groupData.Code != 0)
  787. {
  788. return Ok(JsonView(false, groupData.Msg));
  789. }
  790. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  791. }
  792. catch (Exception ex)
  793. {
  794. return Ok(JsonView(false, "程序错误!"));
  795. throw;
  796. }
  797. }
  798. #endregion
  799. #region 团组&签证
  800. /// <summary>
  801. /// 根据团组Id获取签证客户信息List
  802. /// </summary>
  803. /// <param name="dto">请求dto</param>
  804. /// <returns></returns>
  805. [HttpPost]
  806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  807. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  808. {
  809. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  810. if (groupData.Code != 0)
  811. {
  812. return Ok(JsonView(false, groupData.Msg));
  813. }
  814. return Ok(JsonView(groupData.Data));
  815. }
  816. /// <summary>
  817. /// IOS获取团组签证拍照上传进度01(团组列表)
  818. /// </summary>
  819. /// <param name="dto">请求dto</param>
  820. /// <returns></returns>
  821. [HttpPost]
  822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  823. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  824. {
  825. if (dto == null)
  826. {
  827. return Ok(JsonView(false, "参数为空"));
  828. }
  829. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  830. return Ok(JsonView(visaList));
  831. }
  832. /// <summary>
  833. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  834. /// </summary>
  835. /// <returns></returns>
  836. [HttpPost]
  837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  838. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  839. {
  840. if (dto == null)
  841. {
  842. return Ok(JsonView(false, "请求错误:"));
  843. }
  844. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  845. return Ok(JsonView(list));
  846. }
  847. /// <summary>
  848. /// IOS获取团组签证拍照上传进度03(相册)
  849. /// </summary>
  850. /// <returns></returns>
  851. [HttpPost]
  852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  853. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  854. {
  855. if (dto == null)
  856. {
  857. return Ok(JsonView(false, "请求错误:"));
  858. }
  859. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  860. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  861. list.ForEach(s => s.url = url);
  862. return Ok(JsonView(list));
  863. }
  864. /// <summary>
  865. /// IOS获取团组签证拍照上传进度04(图片上传)
  866. /// </summary>
  867. /// <param name="dto"></param>
  868. /// <returns></returns>
  869. [HttpPost]
  870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  871. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  872. {
  873. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  874. //if (!string.IsNullOrEmpty(result))
  875. //{
  876. //}
  877. //else {
  878. // return Ok(JsonView(false, "上传失败"));
  879. //}
  880. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  881. int sucNum = 0;
  882. try
  883. {
  884. foreach (var item in dto.base64DataList)
  885. {
  886. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  887. string result = decodeBase64ToImage(item, imageName);
  888. if (!string.IsNullOrEmpty(result))
  889. {
  890. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  891. pic.CreateUserId = dto.CreateUserId;
  892. pic.PicName = imageName;
  893. pic.PicPath = result;
  894. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  895. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  896. if (insertResult > 0)
  897. {
  898. sucNum++;
  899. }
  900. }
  901. }
  902. }
  903. catch (Exception ex)
  904. {
  905. return Ok(JsonView(false, ex.Message));
  906. }
  907. string msg = string.Format(@"成功上传{0}张", sucNum);
  908. return Ok(JsonView(true, msg));
  909. }
  910. private string decodeBase64ToImage(string base64DataURL, string imgName)
  911. {
  912. string filename = "";//声明一个string类型的相对路径
  913. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  914. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  915. try//会有异常抛出,try,catch一下
  916. {
  917. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  918. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  919. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  920. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  921. //文件名称
  922. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  923. //上传的文件的路径
  924. string filePath = "";
  925. if (!Directory.Exists(fileDir))
  926. {
  927. Directory.CreateDirectory(fileDir);
  928. }
  929. //上传的文件的路径
  930. filePath = fileDir + filename;
  931. //string url = HttpRuntime.AppDomainAppPath.ToString();
  932. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  933. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  934. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  935. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  936. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  937. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  938. ms.Close();//关闭当前流,并释放所有与之关联的资源
  939. bitmap.Dispose();
  940. }
  941. catch (Exception e)
  942. {
  943. string massage = e.Message;
  944. Logs("IOS图片上传Error:" + massage);
  945. //filename = e.Message;
  946. }
  947. return filename;//返回相对路径
  948. }
  949. /// <summary>
  950. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  951. /// </summary>
  952. /// <param name="dto"></param>
  953. /// <returns></returns>
  954. [HttpPost]
  955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  956. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  957. {
  958. if (dto == null)
  959. {
  960. return Ok(JsonView(false, "请求错误:"));
  961. }
  962. string msg = "参数错误";
  963. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  964. {
  965. try
  966. {
  967. //_delegationVisaRep.BeginTran();
  968. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  969. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  970. .Where(s => s.Id == dto.visaProgressCustomerId)
  971. .ExecuteCommandAsync();
  972. if (updCount > 0 && dto.publishCode == 1)
  973. {
  974. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  975. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  976. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  977. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  978. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  979. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  980. if (groupData == null)
  981. {
  982. _delegationVisaRep.RollbackTran();
  983. }
  984. string title = string.Format(@"[签证进度更新]");
  985. string content = string.Format(@"测试文本");
  986. bool rst = await _message.AddMsg(new MessageDto()
  987. {
  988. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  989. IssuerId = dto.publisher,
  990. Title = title,
  991. Content = content,
  992. ReleaseTime = DateTime.Now,
  993. UIdList = new List<int> {
  994. 234
  995. }
  996. });
  997. if (rst)
  998. {
  999. return Ok(JsonView(true, "发送通知成功"));
  1000. }
  1001. }
  1002. //_delegationVisaRep.CommitTran();
  1003. }
  1004. catch (Exception)
  1005. {
  1006. //_delegationVisaRep.RollbackTran();
  1007. }
  1008. }
  1009. return Ok(JsonView(true, msg));
  1010. }
  1011. #endregion
  1012. #region 团组任务分配
  1013. /// <summary>
  1014. /// 团组任务分配初始化
  1015. /// </summary>
  1016. /// <param name="dto"></param>
  1017. /// <returns></returns>
  1018. [HttpPost]
  1019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1020. public async Task<IActionResult> GetTaskAssignmen()
  1021. {
  1022. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1023. if (groupData.Code != 0)
  1024. {
  1025. return Ok(JsonView(false, groupData.Msg));
  1026. }
  1027. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1028. }
  1029. /// <summary>
  1030. /// 团组任务分配查询
  1031. /// </summary>
  1032. /// <param name="dto"></param>
  1033. /// <returns></returns>
  1034. [HttpPost]
  1035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1036. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1037. {
  1038. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1039. if (groupData.Code != 0)
  1040. {
  1041. return Ok(JsonView(false, groupData.Msg));
  1042. }
  1043. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1044. }
  1045. /// <summary>
  1046. /// 团组任务分配操作
  1047. /// </summary>
  1048. /// <param name="dto"></param>
  1049. /// <returns></returns>
  1050. [HttpPost]
  1051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1052. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1053. {
  1054. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1055. if (groupData.Code != 0)
  1056. {
  1057. return Ok(JsonView(false, groupData.Msg));
  1058. }
  1059. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1060. }
  1061. #endregion
  1062. #region 团组费用审核
  1063. /// <summary>
  1064. /// 费用审核
  1065. /// 团组列表 Page
  1066. /// </summary>
  1067. /// <param name="_dto">团组列表请求dto</param>
  1068. /// <returns></returns>
  1069. [HttpPost]
  1070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1071. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1072. {
  1073. #region 参数验证
  1074. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1075. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1076. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1077. #region 页面操作权限验证
  1078. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1079. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1080. #endregion
  1081. #endregion
  1082. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1083. {
  1084. string sqlWhere = string.Empty;
  1085. if (_dto.IsSure == 0) //未完成
  1086. {
  1087. sqlWhere += string.Format(@" And IsSure = 0");
  1088. }
  1089. else if (_dto.IsSure == 1) //已完成
  1090. {
  1091. sqlWhere += string.Format(@" And IsSure = 1");
  1092. }
  1093. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1094. {
  1095. string tj = _dto.SearchCriteria;
  1096. 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}%')",
  1097. tj, tj, tj, tj, tj);
  1098. }
  1099. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1100. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1101. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1102. From (
  1103. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1104. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1105. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1106. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1107. From Grp_DelegationInfo gdi
  1108. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1109. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1110. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1111. Where gdi.IsDel = 0 {0}
  1112. ) temp ", sqlWhere);
  1113. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1114. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1115. var _view = new
  1116. {
  1117. PageFuncAuth = pageFunAuthView,
  1118. Data = _DelegationList
  1119. };
  1120. return Ok(JsonView(true, "查询成功!", _view, total));
  1121. }
  1122. else
  1123. {
  1124. return Ok(JsonView(false, "查询失败"));
  1125. }
  1126. }
  1127. /// <summary>
  1128. /// 获取团组费用审核
  1129. /// </summary>
  1130. /// <param name="paras">参数Json字符串</param>
  1131. /// <returns></returns>
  1132. [HttpPost]
  1133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1134. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1135. {
  1136. try
  1137. {
  1138. #region 参数验证
  1139. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1140. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1141. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1142. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1143. #region 页面操作权限验证
  1144. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1145. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1146. #endregion
  1147. #endregion
  1148. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1149. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1150. #region 费用清单
  1151. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1152. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1153. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1154. List<Grp_CreditCardPayment> entityList = _groupRepository
  1155. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1156. .Where(exp.ToExpression())
  1157. .ToList();
  1158. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1159. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1160. /*
  1161. * 76://酒店预订
  1162. */
  1163. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1164. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1165. .ToListAsync();
  1166. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1167. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1168. .ToListAsync();
  1169. /*
  1170. * 79://车/导游地接
  1171. */
  1172. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1173. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1174. .ToListAsync();
  1175. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1176. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1177. .ToListAsync();
  1178. /*
  1179. * 80: //签证
  1180. */
  1181. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1182. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1183. .ToListAsync();
  1184. /*
  1185. *81: //邀请/公务活动
  1186. */
  1187. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1188. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1189. .ToListAsync();
  1190. /*
  1191. * 82: //团组客户保险
  1192. */
  1193. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1194. /*
  1195. * Lable = 85 机票预订
  1196. */
  1197. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1198. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1199. .ToListAsync();
  1200. /*
  1201. * 85 机票预定
  1202. */
  1203. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1204. /*
  1205. * 98 其他款项
  1206. */
  1207. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1208. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1209. .ToListAsync();
  1210. /*
  1211. * 285:收款退还
  1212. */
  1213. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1214. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1215. .ToListAsync();
  1216. /*
  1217. * 1015: //超支费用
  1218. */
  1219. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1220. /*
  1221. * 币种信息
  1222. */
  1223. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1224. /*
  1225. * 车/导游地接 费用类型
  1226. */
  1227. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1228. /*
  1229. * 车/导游地接 费用类型
  1230. */
  1231. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1232. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1233. /*
  1234. * 用户信息
  1235. */
  1236. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1237. /*
  1238. * 费用模块
  1239. */
  1240. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1241. string priceModule = string.Empty;
  1242. if (sdPriceName != null)
  1243. {
  1244. priceModule = sdPriceName.Name;
  1245. }
  1246. /*
  1247. * 处理详情数据
  1248. */
  1249. foreach (var entity in entityList)
  1250. {
  1251. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1252. _detail.Id = entity.Id;
  1253. _detail.PriceName = priceModule;
  1254. /*
  1255. * 应付款金额
  1256. */
  1257. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1258. string PaymentCurrency_WaitPay = "Unknown";
  1259. string hotelCurrncyCode = "Unknown";
  1260. string hotelCurrncyName = "Unknown";
  1261. if (sdPaymentCurrency_WaitPay != null)
  1262. {
  1263. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1264. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1265. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1266. if (hotelCurrncyCode.Equals("CNY"))
  1267. {
  1268. entity.DayRate = 1.0000M;
  1269. }
  1270. }
  1271. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1272. /*
  1273. * 此次付款金额
  1274. */
  1275. decimal CurrPayStr = 0;
  1276. if (entity.PayPercentage == 0)
  1277. {
  1278. if (entity.PayThenMoney != 0)
  1279. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1280. }
  1281. else
  1282. {
  1283. if (entity.PayMoney != 0)
  1284. {
  1285. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1286. }
  1287. }
  1288. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1289. /*
  1290. * 剩余尾款
  1291. */
  1292. decimal BalanceStr = 0;
  1293. if (CurrPayStr != 0 )
  1294. {
  1295. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1296. BalanceStr = 0;
  1297. else
  1298. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1299. }
  1300. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1301. /*
  1302. * Bus名称
  1303. */
  1304. _detail.BusName = "待增加";
  1305. /*
  1306. *费用所属
  1307. */
  1308. switch (entity.CTable)
  1309. {
  1310. case 76://酒店预订
  1311. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1312. if (hotelReservations != null)
  1313. {
  1314. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1315. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1316. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1317. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1318. /*
  1319. * 费用类型
  1320. * 1:房费
  1321. * 2:早餐
  1322. * 3:地税
  1323. * 4:城市税
  1324. * </summary>
  1325. */
  1326. //地税
  1327. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1328. if (governmentRentData != null)
  1329. {
  1330. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1331. governmentRentFee = governmentRentData.Price;
  1332. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1333. if (governmentRentCurrData != null)
  1334. {
  1335. governmentRentCode = governmentRentCurrData.Name;
  1336. governmentRentName = $"({governmentRentCurrData.Remark})";
  1337. }
  1338. }
  1339. //城市税
  1340. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1341. if (cityTaxData != null)
  1342. {
  1343. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1344. cityTaxFee = cityTaxData.Price;
  1345. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1346. if (cityTaxCurrData != null)
  1347. {
  1348. cityTaxCode = cityTaxCurrData.Name;
  1349. cityTaxName = $"({cityTaxCurrData.Remark})";
  1350. }
  1351. }
  1352. //酒店早餐
  1353. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1354. if (breakfastData != null)
  1355. {
  1356. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1357. breakfastFee = breakfastData.Price;
  1358. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1359. if (breakfastCurrData != null)
  1360. {
  1361. breakfastCode = breakfastCurrData.Name;
  1362. breakfastName = $"({breakfastCurrData.Remark})";
  1363. }
  1364. }
  1365. //房间费用
  1366. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1367. if (roomData != null)
  1368. {
  1369. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1370. roomFee = roomData.Price;
  1371. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1372. if (roomCurrData != null)
  1373. {
  1374. roomCode = roomCurrData.Name;
  1375. roomName = $"({roomCurrData.Remark})";
  1376. }
  1377. }
  1378. _detail.PriceMsgContent = $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1379. $"房间说明: {hotelReservations.Remark} <br/>" +
  1380. $"房间费用: {roomFee.ToString("#0.00")} {roomCode} {roomName} 当时汇率{roomData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{roomBool}<br/>" +
  1381. $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率{breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/>" +
  1382. $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率{governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/>" +
  1383. $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率{cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1384. _detail.PriceNameContent = hotelReservations.HotelName;
  1385. }
  1386. break;
  1387. case 79://车/导游地接
  1388. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1389. if (touristGuideGroundReservations != null)
  1390. {
  1391. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1392. {
  1393. _detail.BusName = touristGuideGroundReservations.BusName;
  1394. }
  1395. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1396. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1397. //if (isInt)
  1398. //{
  1399. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1400. // if (cityInfo != null)
  1401. // {
  1402. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1403. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1404. // if (carFeeItem != null)
  1405. // {
  1406. // nameContent += $@"({carFeeItem.Name})";
  1407. // }
  1408. // _detail.PriceNameContent = nameContent;
  1409. // }
  1410. //}
  1411. //else
  1412. //{
  1413. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1414. //}
  1415. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  1416. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1417. string priceMsg = string.Empty;
  1418. foreach (var item in touristGuideGroundReservationsContents)
  1419. {
  1420. string typeName = "Unknown";
  1421. string carCurrencyCode = "Unknown";
  1422. string carCurrencyName = "Unknown";
  1423. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1424. if (carTypeData != null) typeName = carTypeData.Name;
  1425. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1426. if (currencyData != null)
  1427. {
  1428. carCurrencyCode = currencyData.Name;
  1429. carCurrencyName = currencyData.Remark;
  1430. }
  1431. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  1432. "明细:" + item.PriceContent + "<br/>" +
  1433. "备注:" + item.Remark + "<br/><br/>";
  1434. }
  1435. _detail.PriceMsgContent = priceMsg;
  1436. }
  1437. break;
  1438. case 80: //签证
  1439. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1440. if (visaInfo != null)
  1441. {
  1442. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1443. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1444. }
  1445. break;
  1446. case 81: //邀请/公务活动
  1447. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1448. if (_ioa != null)
  1449. {
  1450. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1451. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1452. sendCurrName = "Unknown", //快递费用币种 Name
  1453. sendCurrCode = "Unknown", //快递费用币种 Code
  1454. eventsCurrName = "Unknown", //公务活动费币种 Name
  1455. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1456. translateCurrName = "Unknown", //公务翻译费 Name
  1457. translateCurrCode = "Unknown"; //公务翻译费 Code
  1458. #region 处理费用币种
  1459. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1460. if (inviteCurrData != null)
  1461. {
  1462. inviteCurrName = inviteCurrData.Remark;
  1463. inviteCurrCode = inviteCurrData.Name;
  1464. }
  1465. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1466. if (sendCurrData != null)
  1467. {
  1468. sendCurrName = sendCurrData.Remark;
  1469. sendCurrCode = sendCurrData.Name;
  1470. }
  1471. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1472. if (eventsCurrData != null)
  1473. {
  1474. eventsCurrName = eventsCurrData.Remark;
  1475. eventsCurrCode = eventsCurrData.Name;
  1476. }
  1477. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1478. if (translateCurrData != null)
  1479. {
  1480. translateCurrName = translateCurrData.Remark;
  1481. translateCurrCode = translateCurrData.Name;
  1482. }
  1483. #endregion
  1484. _detail.PriceNameContent = _ioa.InviterArea;
  1485. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1486. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1487. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1488. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1489. $@"备注:" + _ioa.Remark + "<br/>";
  1490. }
  1491. break;
  1492. case 82: //团组客户保险
  1493. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1494. if (customers != null)
  1495. {
  1496. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1497. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1498. }
  1499. break;
  1500. case 85: //机票预订
  1501. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1502. if (jpRes != null)
  1503. {
  1504. string FlightsDescription = jpRes.FlightsDescription;
  1505. string PriceDescription = jpRes.PriceDescription;
  1506. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1507. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1508. }
  1509. break;
  1510. case 98://其他款项
  1511. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1512. if (gdpRes != null)
  1513. {
  1514. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1515. _detail.PriceNameContent = gdpRes.PriceName;
  1516. }
  1517. break;
  1518. case 285://收款退还
  1519. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1520. if (refundAndOtherMoney != null)
  1521. {
  1522. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1523. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1524. }
  1525. break;
  1526. case 751://酒店早餐
  1527. break;
  1528. case 1015://超支费用
  1529. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1530. if (groupExtraCost != null)
  1531. {
  1532. _detail.PriceNameContent = groupExtraCost.PriceName;
  1533. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1534. }
  1535. break;
  1536. default:
  1537. break;
  1538. }
  1539. /*
  1540. * 申请人
  1541. */
  1542. string operatorName = " - ";
  1543. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1544. if (_opUser != null)
  1545. {
  1546. operatorName = _opUser.CnName;
  1547. }
  1548. _detail.OperatorName = operatorName;
  1549. /*
  1550. * 审核人
  1551. */
  1552. string auditOperatorName = "Unknown";
  1553. if (entity.AuditGMOperate == 0)
  1554. auditOperatorName = " - ";
  1555. else if (entity.AuditGMOperate == 4)
  1556. auditOperatorName = "自动审核";
  1557. else
  1558. {
  1559. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1560. if (_adUser != null)
  1561. {
  1562. auditOperatorName = _adUser.CnName;
  1563. }
  1564. }
  1565. _detail.AuditOperatorName = auditOperatorName;
  1566. /*
  1567. * 超预算比例
  1568. */
  1569. string overBudgetStr = "";
  1570. if (entity.ExceedBudget == -1)
  1571. overBudgetStr = sdPriceName.Name + "尚无预算";
  1572. else if (entity.ExceedBudget == 0)
  1573. overBudgetStr = "未超预算";
  1574. else
  1575. overBudgetStr = entity.ExceedBudget.ToString("P");
  1576. _detail.OverBudget = overBudgetStr;
  1577. /*
  1578. * 费用总计
  1579. */
  1580. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1581. {
  1582. CurrencyId = entity.PaymentCurrency,
  1583. CurrencyName = PaymentCurrency_WaitPay,
  1584. AmountPayable = entity.PayMoney,
  1585. ThisPayment = CurrPayStr,
  1586. BalancePayment = BalanceStr,
  1587. AuditedFunds = CurrPayStr
  1588. });
  1589. _detail.IsAuditGM = entity.IsAuditGM;
  1590. detailList.Add(_detail);
  1591. }
  1592. #endregion
  1593. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1594. /*
  1595. * 下方描述处理
  1596. */
  1597. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1598. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1599. if (ccpCurrencyPrice != null)
  1600. {
  1601. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1602. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1603. }
  1604. else
  1605. {
  1606. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1607. }
  1608. string amountPayableStr = string.Format(@"应付款总金额: ");
  1609. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1610. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1611. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1612. foreach (var item in nonDuplicat)
  1613. {
  1614. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1615. if (strs.Count > 0)
  1616. {
  1617. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1618. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1619. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1620. //单独处理此次付款金额
  1621. if (item.CurrencyId == 836) //人民币
  1622. {
  1623. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1624. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1625. }
  1626. else
  1627. {
  1628. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1629. }
  1630. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1631. //单独处理已审核费用
  1632. if (item.CurrencyId == 836) //人民币
  1633. {
  1634. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1635. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1636. }
  1637. else
  1638. {
  1639. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1640. }
  1641. }
  1642. }
  1643. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1644. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1645. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1646. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1647. var _view1 = new
  1648. {
  1649. PageFuncAuth = pageFunAuthView,
  1650. Data = _view
  1651. };
  1652. return Ok(JsonView(_view1));
  1653. }
  1654. catch (Exception ex)
  1655. {
  1656. return Ok(JsonView(false, ex.Message));
  1657. }
  1658. }
  1659. /// <summary>
  1660. /// 费用审核
  1661. /// 修改团组费用审核状态
  1662. /// </summary>
  1663. /// <param name="_dto">参数Json字符串</param>
  1664. /// <returns></returns>
  1665. [HttpPost]
  1666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1667. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1668. {
  1669. #region 参数验证
  1670. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1671. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1672. #endregion
  1673. #region 页面操作权限验证
  1674. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1675. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1676. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1677. #endregion
  1678. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1679. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1680. DateTime dtNow = DateTime.Now;
  1681. _groupRepository.BeginTran();
  1682. int rst = 0;
  1683. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1684. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1685. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1686. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1687. List<dynamic> msgDatas = new List<dynamic>();
  1688. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1689. foreach (var item in idList)
  1690. {
  1691. int CreditId = int.Parse(item);
  1692. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1693. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1694. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1695. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1696. .Where(s => s.Id == CreditId)
  1697. .ExecuteCommandAsync();
  1698. if (result < 1)
  1699. {
  1700. rst = -1;
  1701. _groupRepository.RollbackTran();
  1702. return Ok(JsonView(false, "操作失败并回滚!"));
  1703. }
  1704. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1705. if (creditData != null)
  1706. {
  1707. #region 应用通知配置
  1708. try
  1709. {
  1710. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1711. }
  1712. catch (Exception ex)
  1713. {
  1714. }
  1715. #endregion
  1716. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1717. string groupNameStr = string.Empty;
  1718. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1719. if (groupData != null) groupNameStr = groupData.TeamName;
  1720. string creditTypeStr = string.Empty;
  1721. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1722. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1723. string creditCurrency = string.Empty;
  1724. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1725. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1726. if (creditCurrency.Equals("CNY"))
  1727. {
  1728. creditData.DayRate = 1.0000M;
  1729. }
  1730. if (creditData.PayPercentage == 0.00M)
  1731. {
  1732. creditData.PayPercentage = 100M;
  1733. }
  1734. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1735. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1736. string msgContent = "";
  1737. if (creditCurrency.Equals("CNY"))
  1738. {
  1739. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1740. }
  1741. else
  1742. {
  1743. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1744. }
  1745. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1746. }
  1747. }
  1748. if (rst == 0)
  1749. {
  1750. _groupRepository.CommitTran();
  1751. foreach (var item in msgDatas)
  1752. {
  1753. //发送消息
  1754. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1755. }
  1756. #region 应用推送
  1757. try
  1758. {
  1759. foreach (var ccpId in dic_ccp_user.Keys)
  1760. {
  1761. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1762. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1763. }
  1764. }
  1765. catch (Exception)
  1766. {
  1767. }
  1768. #endregion
  1769. return Ok(JsonView(true, "操作成功!"));
  1770. }
  1771. return Ok(JsonView(false, "操作失败!"));
  1772. }
  1773. #endregion
  1774. #region 机票费用录入
  1775. /// <summary>
  1776. /// 机票录入当前登录人可操作团组
  1777. /// </summary>
  1778. /// <param name="dto"></param>
  1779. /// <returns></returns>
  1780. [HttpPost]
  1781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1782. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1783. {
  1784. try
  1785. {
  1786. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1787. if (groupData.Code != 0)
  1788. {
  1789. return Ok(JsonView(false, groupData.Msg));
  1790. }
  1791. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1792. }
  1793. catch (Exception ex)
  1794. {
  1795. return Ok(JsonView(false, "程序错误!"));
  1796. throw;
  1797. }
  1798. }
  1799. /// <summary>
  1800. /// 机票费用录入列表
  1801. /// </summary>
  1802. /// <param name="dto"></param>
  1803. /// <returns></returns>
  1804. [HttpPost]
  1805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1806. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1807. {
  1808. try
  1809. {
  1810. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1811. if (groupData.Code != 0)
  1812. {
  1813. return Ok(JsonView(false, groupData.Msg));
  1814. }
  1815. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1816. }
  1817. catch (Exception ex)
  1818. {
  1819. return Ok(JsonView(false, ex.Message));
  1820. throw;
  1821. }
  1822. }
  1823. /// <summary>
  1824. /// 根据id查询费用录入信息
  1825. /// </summary>
  1826. /// <param name="dto"></param>
  1827. /// <returns></returns>
  1828. [HttpPost]
  1829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1830. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1831. {
  1832. try
  1833. {
  1834. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1835. if (groupData.Code != 0)
  1836. {
  1837. return Ok(JsonView(false, groupData.Msg));
  1838. }
  1839. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1840. }
  1841. catch (Exception ex)
  1842. {
  1843. return Ok(JsonView(false, "程序错误!"));
  1844. throw;
  1845. }
  1846. }
  1847. /// <summary>
  1848. /// 机票费用录入操作(Status:1.新增,2.修改)
  1849. /// </summary>
  1850. /// <param name="dto"></param>
  1851. /// <returns></returns>
  1852. [HttpPost]
  1853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1854. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1855. {
  1856. try
  1857. {
  1858. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1859. if (groupData.Code != 0)
  1860. {
  1861. return Ok(JsonView(false, groupData.Msg));
  1862. }
  1863. #region 应用推送
  1864. try
  1865. {
  1866. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  1867. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  1868. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  1869. }
  1870. catch (Exception ex)
  1871. {
  1872. }
  1873. #endregion
  1874. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1875. }
  1876. catch (Exception ex)
  1877. {
  1878. return Ok(JsonView(false, "程序错误!"));
  1879. throw;
  1880. }
  1881. }
  1882. /// <summary>
  1883. /// 根据舱位类型查询接团客户名单信息
  1884. /// </summary>
  1885. /// <param name="dto"></param>
  1886. /// <returns></returns>
  1887. [HttpPost]
  1888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1889. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1890. {
  1891. try
  1892. {
  1893. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1894. if (crm_Groups.Count != 0)
  1895. {
  1896. List<dynamic> Customer = new List<dynamic>();
  1897. foreach (var item in crm_Groups)
  1898. {
  1899. var data = new
  1900. {
  1901. Id = item.Id,
  1902. Pinyin = item.Pinyin,
  1903. Name = item.LastName + item.FirstName
  1904. };
  1905. Customer.Add(data);
  1906. }
  1907. return Ok(JsonView(true, "查询成功!", Customer));
  1908. }
  1909. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1910. }
  1911. catch (Exception ex)
  1912. {
  1913. return Ok(JsonView(false, "程序错误!"));
  1914. throw;
  1915. }
  1916. }
  1917. /// <summary>
  1918. /// 根据团号获取客户信息
  1919. /// </summary>
  1920. /// <param name="dto"></param>
  1921. /// <returns></returns>
  1922. [HttpPost]
  1923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1924. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  1925. {
  1926. var jw = JsonView(false);
  1927. if (dto.DIID < 1)
  1928. {
  1929. jw.Msg += "请输入正确的diid";
  1930. return Ok(jw);
  1931. }
  1932. var arr = getSimplClientList(dto.DIID);
  1933. jw = JsonView(true, "获取成功!", arr);
  1934. return Ok(jw);
  1935. }
  1936. private List<SimplClientInfo> getSimplClientList(int diId)
  1937. {
  1938. 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);
  1939. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1940. return arr;
  1941. }
  1942. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  1943. {
  1944. string result = origin;
  1945. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  1946. {
  1947. string[] temparr = origin.Split(',');
  1948. string fistrStr = temparr[0];
  1949. int count = temparr.Count();
  1950. int tempId;
  1951. bool success = int.TryParse(fistrStr, out tempId);
  1952. if (success)
  1953. {
  1954. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1955. if (tempInfo != null)
  1956. {
  1957. if (count > 1)
  1958. {
  1959. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1960. }
  1961. else
  1962. {
  1963. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1964. }
  1965. }
  1966. }
  1967. }
  1968. return result;
  1969. }
  1970. /// <summary>
  1971. /// 机票费用录入,删除
  1972. /// </summary>
  1973. /// <param name="dto"></param>
  1974. /// <returns></returns>
  1975. [HttpPost]
  1976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1977. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1978. {
  1979. try
  1980. {
  1981. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1982. if (res)
  1983. {
  1984. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1985. {
  1986. IsDel = 1,
  1987. DeleteUserId = dto.DeleteUserId,
  1988. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1989. }).ExecuteCommandAsync();
  1990. return Ok(JsonView(true, "删除成功!"));
  1991. }
  1992. return Ok(JsonView(false, "删除失败!"));
  1993. }
  1994. catch (Exception ex)
  1995. {
  1996. return Ok(JsonView(false, "程序错误!"));
  1997. throw;
  1998. }
  1999. }
  2000. /// <summary>
  2001. /// 导出机票录入报表
  2002. /// </summary>
  2003. /// <param name="dto"></param>
  2004. /// <returns></returns>
  2005. [HttpPost]
  2006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2007. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2008. {
  2009. try
  2010. {
  2011. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2012. if (groupData.Code != 0)
  2013. {
  2014. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2015. }
  2016. else
  2017. {
  2018. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2019. if (AirTicketReservations.Count != 0)
  2020. {
  2021. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2022. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2023. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2024. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2025. WorkbookDesigner designer = new WorkbookDesigner();
  2026. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2027. decimal countCost = 0;
  2028. foreach (var item in AirTicketReservations)
  2029. {
  2030. #region 处理客人姓名
  2031. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2032. item.ClientName = clientNames;
  2033. #endregion
  2034. if (item.BankType == "其他")
  2035. {
  2036. item.BankNo = "--";
  2037. }
  2038. else
  2039. {
  2040. if (!string.IsNullOrEmpty(item.BankType))
  2041. {
  2042. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2043. }
  2044. }
  2045. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2046. item.Price = System.Decimal.Round(item.Price, 2);
  2047. countCost += Convert.ToDecimal(item.Price);
  2048. }
  2049. designer.SetDataSource("Export", AirTicketReservations);
  2050. designer.SetDataSource("ExportDiCode", diCode);
  2051. designer.SetDataSource("ExportDiName", diName);
  2052. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2053. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2054. designer.Process();
  2055. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2056. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2057. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2058. return Ok(JsonView(true, "成功", url = rst));
  2059. }
  2060. else
  2061. {
  2062. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2063. }
  2064. }
  2065. }
  2066. catch (Exception ex)
  2067. {
  2068. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2069. throw;
  2070. }
  2071. }
  2072. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2073. /// <summary>
  2074. /// 行程单导出
  2075. /// </summary>
  2076. /// <param name="dto"></param>
  2077. /// <returns></returns>
  2078. [HttpPost]
  2079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2080. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2081. {
  2082. try
  2083. {
  2084. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2085. if (groupData.Code != 0)
  2086. {
  2087. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2088. }
  2089. else
  2090. {
  2091. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2092. if (dto.Language == "CN")
  2093. {
  2094. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2095. DocumentBuilder builder = new DocumentBuilder(doc);
  2096. int tableIndex = 0;//表格索引
  2097. //得到文档中的第一个表格
  2098. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2099. foreach (var item in _AirTicketReservations)
  2100. {
  2101. #region 处理固定数据
  2102. string[] FlightsCode = item.FlightsCode.Split('/');
  2103. if (FlightsCode.Length != 0)
  2104. {
  2105. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2106. if (_AirCompany != null)
  2107. {
  2108. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2109. }
  2110. else
  2111. {
  2112. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2113. }
  2114. }
  2115. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2116. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2117. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2118. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2119. string name = "";
  2120. foreach (string clientName in nameArray)
  2121. {
  2122. if (!name.Contains(clientName))
  2123. {
  2124. name += clientName + ",";
  2125. }
  2126. }
  2127. if (!string.IsNullOrWhiteSpace(name))
  2128. {
  2129. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2130. }
  2131. else
  2132. {
  2133. table.Range.Bookmarks["ClientName"].Text = "--";
  2134. }
  2135. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2136. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2137. table.Range.Bookmarks["JointTicket"].Text = "--";
  2138. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2139. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2140. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2141. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2142. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2143. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2144. #endregion
  2145. #region 循环数据处理
  2146. List<AirInfo> airs = new List<AirInfo>();
  2147. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2148. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2149. for (int i = 0; i < FlightsCode.Length; i++)
  2150. {
  2151. AirInfo air = new AirInfo();
  2152. string[] tempstr = DayArray[i]
  2153. .Replace("\r\n", string.Empty)
  2154. .Replace("\\r\\n", string.Empty)
  2155. .TrimStart().TrimEnd()
  2156. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2157. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2158. string starCity = "";
  2159. if (star_Three != null)
  2160. {
  2161. starCity = star_Three.AirPort;
  2162. }
  2163. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2164. string EndCity = "";
  2165. if (End_Three != null)
  2166. {
  2167. EndCity = End_Three.AirPort;
  2168. }
  2169. air.Destination = starCity + "/" + EndCity;
  2170. air.Flight = FlightsCode[i];
  2171. air.SeatingClass = item.CTypeName;
  2172. string dateTime = tempstr[2];
  2173. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2174. air.FlightDate = DateTemp;
  2175. air.DepartureTime = tempstr[5];
  2176. air.LandingTime = tempstr[6];
  2177. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2178. air.TicketStatus = "--";
  2179. air.Luggage = "--";
  2180. air.DepartureTerminal = "--";
  2181. air.LandingTerminal = "--";
  2182. airs.Add(air);
  2183. }
  2184. int row = 13;
  2185. for (int i = 0; i < airs.Count; i++)
  2186. {
  2187. if (airs.Count > 2)
  2188. {
  2189. for (int j = 0; j < airs.Count - 2; j++)
  2190. {
  2191. var CopyRow = table.Rows[12].Clone(true);
  2192. table.Rows.Add(CopyRow);
  2193. }
  2194. }
  2195. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2196. int index = 0;
  2197. foreach (PropertyInfo property in properties)
  2198. {
  2199. string value = property.GetValue(airs[i]).ToString();
  2200. Cell ishcel0 = table.Rows[row].Cells[index];
  2201. Paragraph p = new Paragraph(doc);
  2202. string s = value;
  2203. p.AppendChild(new Run(doc, s));
  2204. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2205. ishcel0.AppendChild(p);
  2206. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2207. index++;
  2208. }
  2209. row++;
  2210. }
  2211. #endregion
  2212. Paragraph lastParagraph = new Paragraph(doc);
  2213. //第一个表格末尾加段落
  2214. table.ParentNode.InsertAfter(lastParagraph, table);
  2215. //复制第一个表格
  2216. Table cloneTable = (Table)table.Clone(true);
  2217. //在文档末尾段落后面加入复制的表格
  2218. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2219. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2220. {
  2221. int rownewsIndex = 13;
  2222. for (int i = 0; i < 2; i++)
  2223. {
  2224. var CopyRow = table.Rows[12].Clone(true);
  2225. table.Rows.RemoveAt(13);
  2226. table.Rows.Add(CopyRow);
  2227. rownewsIndex++;
  2228. }
  2229. }
  2230. else
  2231. {
  2232. table.Rows.RemoveAt(12);
  2233. }
  2234. cloneTable.Rows.RemoveAt(12);
  2235. }
  2236. if (_AirTicketReservations.Count != 0)
  2237. {
  2238. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2239. if (FlightsCode.Length != 0)
  2240. {
  2241. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2242. if (_AirCompany != null)
  2243. {
  2244. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2245. }
  2246. else
  2247. {
  2248. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2249. }
  2250. }
  2251. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2252. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2253. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2254. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2255. string name = "";
  2256. foreach (string clientName in nameArray)
  2257. {
  2258. if (!name.Contains(clientName))
  2259. {
  2260. name += clientName + ",";
  2261. }
  2262. }
  2263. if (!string.IsNullOrWhiteSpace(name))
  2264. {
  2265. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2266. }
  2267. else
  2268. {
  2269. table.Range.Bookmarks["ClientName"].Text = "--";
  2270. }
  2271. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2272. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2273. table.Range.Bookmarks["JointTicket"].Text = "--";
  2274. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2275. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2276. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2277. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2278. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2279. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2280. }
  2281. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2282. //保存合并后的文档
  2283. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2284. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2285. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2286. return Ok(JsonView(true, "成功!", rst));
  2287. }
  2288. else
  2289. {
  2290. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2291. DocumentBuilder builder = new DocumentBuilder(doc);
  2292. int tableIndex = 0;//表格索引
  2293. //得到文档中的第一个表格
  2294. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2295. List<string> texts = new List<string>();
  2296. foreach (var item in _AirTicketReservations)
  2297. {
  2298. string[] FlightsCode = item.FlightsCode.Split('/');
  2299. if (FlightsCode.Length != 0)
  2300. {
  2301. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2302. if (_AirCompany != null)
  2303. {
  2304. if (!transDic.ContainsKey(_AirCompany.CnName))
  2305. {
  2306. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2307. }
  2308. }
  2309. else
  2310. {
  2311. if (!transDic.ContainsKey("--"))
  2312. {
  2313. transDic.Add("--", "--");
  2314. }
  2315. }
  2316. }
  2317. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2318. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2319. string name = "";
  2320. foreach (string clientName in nameArray)
  2321. {
  2322. name += clientName + ",";
  2323. }
  2324. if (!texts.Contains(name))
  2325. {
  2326. texts.Add(name);
  2327. }
  2328. List<AirInfo> airs = new List<AirInfo>();
  2329. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2330. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2331. for (int i = 0; i < FlightsCode.Length; i++)
  2332. {
  2333. AirInfo air = new AirInfo();
  2334. string[] tempstr = DayArray[i]
  2335. .Replace("\r\n", string.Empty)
  2336. .Replace("\\r\\n", string.Empty)
  2337. .TrimStart().TrimEnd()
  2338. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2339. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2340. if (star_Three != null)
  2341. {
  2342. if (!transDic.ContainsKey(star_Three.AirPort))
  2343. {
  2344. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2345. }
  2346. }
  2347. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2348. if (End_Three != null)
  2349. {
  2350. if (!transDic.ContainsKey(End_Three.AirPort))
  2351. {
  2352. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2353. }
  2354. }
  2355. if (!texts.Contains(item.CTypeName))
  2356. {
  2357. texts.Add(item.CTypeName);
  2358. }
  2359. }
  2360. }
  2361. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2362. if (transData.Count > 0)
  2363. {
  2364. foreach (TranslateResult item in transData)
  2365. {
  2366. if (!transDic.ContainsKey(item.Query))
  2367. {
  2368. transDic.Add(item.Query, item.Translation);
  2369. }
  2370. }
  2371. }
  2372. foreach (var item in _AirTicketReservations)
  2373. {
  2374. #region 处理固定数据
  2375. string[] FlightsCode = item.FlightsCode.Split('/');
  2376. if (FlightsCode.Length != 0)
  2377. {
  2378. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2379. if (_AirCompany != null)
  2380. {
  2381. string str = "--";
  2382. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2383. if (!string.IsNullOrEmpty(translateResult))
  2384. {
  2385. str = translateResult;
  2386. str = _airTicketResRep.Processing(str);
  2387. }
  2388. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2389. }
  2390. else
  2391. {
  2392. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2393. }
  2394. }
  2395. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2396. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2397. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2398. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2399. string names = "";
  2400. foreach (string clientName in nameArray)
  2401. {
  2402. names += clientName + ",";
  2403. }
  2404. if (!string.IsNullOrWhiteSpace(names))
  2405. {
  2406. string str = "--";
  2407. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2408. if (!string.IsNullOrEmpty(translateResult))
  2409. {
  2410. str = translateResult;
  2411. str = _airTicketResRep.Processing(str);
  2412. }
  2413. table.Range.Bookmarks["ClientName"].Text = str;
  2414. }
  2415. else
  2416. {
  2417. table.Range.Bookmarks["ClientName"].Text = "--";
  2418. }
  2419. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2420. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2421. table.Range.Bookmarks["JointTicket"].Text = "--";
  2422. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2423. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2424. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2425. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2426. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2427. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2428. #endregion
  2429. #region 循环数据处理
  2430. List<AirInfo> airs = new List<AirInfo>();
  2431. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2432. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2433. for (int i = 0; i < FlightsCode.Length; i++)
  2434. {
  2435. AirInfo air = new AirInfo();
  2436. string[] tempstr = DayArray[i]
  2437. .Replace("\r\n", string.Empty)
  2438. .Replace("\\r\\n", string.Empty)
  2439. .TrimStart().TrimEnd()
  2440. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2441. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2442. string starCity = "";
  2443. if (star_Three != null)
  2444. {
  2445. string str2 = "--";
  2446. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2447. if (!string.IsNullOrEmpty(translateResult2))
  2448. {
  2449. str2 = translateResult2;
  2450. str2 = _airTicketResRep.Processing(str2);
  2451. }
  2452. starCity = str2;
  2453. }
  2454. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2455. string EndCity = "";
  2456. if (End_Three != null)
  2457. {
  2458. string str1 = "--";
  2459. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2460. if (!string.IsNullOrEmpty(translateResult1))
  2461. {
  2462. str1 = translateResult1;
  2463. str1 = _airTicketResRep.Processing(str1);
  2464. }
  2465. EndCity = str1;
  2466. }
  2467. air.Destination = starCity + "/" + EndCity;
  2468. air.Flight = FlightsCode[i];
  2469. string str = "--";
  2470. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2471. if (!string.IsNullOrEmpty(translateResult))
  2472. {
  2473. str = translateResult;
  2474. str = _airTicketResRep.Processing(str);
  2475. }
  2476. air.SeatingClass = str;
  2477. string dateTime = tempstr[2];
  2478. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2479. air.FlightDate = DateTemp;
  2480. air.DepartureTime = tempstr[5];
  2481. air.LandingTime = tempstr[6];
  2482. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2483. air.TicketStatus = "--";
  2484. air.Luggage = "--";
  2485. air.DepartureTerminal = "--";
  2486. air.LandingTerminal = "--";
  2487. airs.Add(air);
  2488. }
  2489. int row = 13;
  2490. for (int i = 0; i < airs.Count; i++)
  2491. {
  2492. if (airs.Count > 2)
  2493. {
  2494. for (int j = 0; j < airs.Count - 2; j++)
  2495. {
  2496. var CopyRow = table.Rows[12].Clone(true);
  2497. table.Rows.Add(CopyRow);
  2498. }
  2499. }
  2500. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2501. int index = 0;
  2502. foreach (PropertyInfo property in properties)
  2503. {
  2504. string value = property.GetValue(airs[i]).ToString();
  2505. Cell ishcel0 = table.Rows[row].Cells[index];
  2506. Paragraph p = new Paragraph(doc);
  2507. string s = value;
  2508. p.AppendChild(new Run(doc, s));
  2509. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2510. ishcel0.AppendChild(p);
  2511. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2512. //ishcel0.CellFormat.VerticalAlignment=
  2513. index++;
  2514. }
  2515. row++;
  2516. }
  2517. #endregion
  2518. Paragraph lastParagraph = new Paragraph(doc);
  2519. //第一个表格末尾加段落
  2520. table.ParentNode.InsertAfter(lastParagraph, table);
  2521. //复制第一个表格
  2522. Table cloneTable = (Table)table.Clone(true);
  2523. //在文档末尾段落后面加入复制的表格
  2524. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2525. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2526. {
  2527. int rownewsIndex = 13;
  2528. for (int i = 0; i < 2; i++)
  2529. {
  2530. var CopyRow = table.Rows[12].Clone(true);
  2531. table.Rows.RemoveAt(13);
  2532. table.Rows.Add(CopyRow);
  2533. rownewsIndex++;
  2534. }
  2535. }
  2536. else
  2537. {
  2538. table.Rows.RemoveAt(12);
  2539. }
  2540. cloneTable.Rows.RemoveAt(12);
  2541. }
  2542. if (_AirTicketReservations.Count != 0)
  2543. {
  2544. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2545. if (FlightsCode.Length != 0)
  2546. {
  2547. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2548. if (_AirCompany != null)
  2549. {
  2550. string str = "--";
  2551. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2552. if (!string.IsNullOrEmpty(translateResult))
  2553. {
  2554. str = translateResult;
  2555. str = _airTicketResRep.Processing(str);
  2556. }
  2557. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2558. }
  2559. else
  2560. {
  2561. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2562. }
  2563. }
  2564. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2565. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2566. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2567. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2568. string names = "";
  2569. foreach (string clientName in nameArray)
  2570. {
  2571. names += clientName + ",";
  2572. }
  2573. if (!string.IsNullOrWhiteSpace(names))
  2574. {
  2575. string str = "--";
  2576. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2577. if (!string.IsNullOrEmpty(translateResult))
  2578. {
  2579. str = translateResult;
  2580. str = _airTicketResRep.Processing(str);
  2581. }
  2582. table.Range.Bookmarks["ClientName"].Text = str;
  2583. }
  2584. else
  2585. {
  2586. table.Range.Bookmarks["ClientName"].Text = "--";
  2587. }
  2588. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2589. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2590. table.Range.Bookmarks["JointTicket"].Text = "--";
  2591. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2592. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2593. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2594. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2595. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2596. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2597. }
  2598. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2599. //保存合并后的文档
  2600. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2601. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2602. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2603. return Ok(JsonView(true, "成功!", rst));
  2604. }
  2605. }
  2606. }
  2607. catch (Exception ex)
  2608. {
  2609. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2610. throw;
  2611. }
  2612. }
  2613. #endregion
  2614. #region 团组增减款项 --> 其他款项
  2615. /// <summary>
  2616. /// 团组增减款项下拉框绑定
  2617. /// </summary>
  2618. /// <param name="dto"></param>
  2619. /// <returns></returns>
  2620. [HttpPost]
  2621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2622. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2623. {
  2624. #region 参数验证
  2625. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2626. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2627. #endregion
  2628. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2629. }
  2630. /// <summary>
  2631. /// 根据团组Id查询团组增减款项
  2632. /// </summary>
  2633. /// <param name="dto"></param>
  2634. /// <returns></returns>
  2635. [HttpPost]
  2636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2637. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2638. {
  2639. #region 参数验证
  2640. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2641. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2642. #endregion
  2643. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2644. }
  2645. /// <summary>
  2646. /// 团组增减款项操作(Status:1.新增,2.修改)
  2647. /// </summary>
  2648. /// <param name="dto"></param>
  2649. /// <returns></returns>
  2650. [HttpPost]
  2651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2652. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2653. {
  2654. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2655. if (groupData.Code != 200)
  2656. {
  2657. return Ok(JsonView(false, groupData.Msg));
  2658. }
  2659. #region 应用推送
  2660. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2661. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2662. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2663. #endregion
  2664. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2665. }
  2666. /// <summary>
  2667. /// 团组增减款项操作 删除
  2668. /// </summary>
  2669. /// <param name="dto"></param>
  2670. /// <returns></returns>
  2671. [HttpPost]
  2672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2673. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2674. {
  2675. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2676. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2677. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2678. if (res.Code == 0)
  2679. {
  2680. return Ok(JsonView(true, "删除成功!"));
  2681. }
  2682. return Ok(JsonView(false, "删除失败!"));
  2683. }
  2684. /// <summary>
  2685. /// 根据团组增减款项Id查询
  2686. /// </summary>
  2687. /// <param name="dto"></param>
  2688. /// <returns></returns>
  2689. [HttpPost]
  2690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2691. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2692. {
  2693. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2694. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2695. }
  2696. /// <summary>
  2697. /// 查询供应商名称
  2698. /// </summary>
  2699. /// <param name="dto"></param>
  2700. /// <returns></returns>
  2701. [HttpPost]
  2702. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2703. {
  2704. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2705. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2706. ?? new List<Grp_DecreasePayments>();
  2707. dbResult = dbResult.Distinct(new
  2708. ProductComparer ()).ToList();
  2709. var jw = JsonView(true, "success", dbResult.OrderByDescending(x=>x. Id ).Select(x => new
  2710. {
  2711. x.Id,
  2712. x.SupplierAddress,
  2713. x.SupplierArea,
  2714. x.SupplierContact,
  2715. x.SupplierContactNumber,
  2716. x.SupplierEmail,
  2717. x.SupplierName,
  2718. x.SupplierSocialAccount,
  2719. x.SupplierTypeId,
  2720. }).ToList());
  2721. return Ok(jw);
  2722. }
  2723. #endregion
  2724. #region 文件上传、删除
  2725. /// <summary>
  2726. /// region 文件上传 可以带参数
  2727. /// </summary>
  2728. /// <param name="file"></param>
  2729. /// <returns></returns>
  2730. [HttpPost]
  2731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2732. public async Task<IActionResult> UploadProject(IFormFile file)
  2733. {
  2734. try
  2735. {
  2736. var TypeName = Request.Headers["TypeName"].ToString();
  2737. if (file != null)
  2738. {
  2739. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2740. //文件名称
  2741. string projectFileName = file.FileName;
  2742. //上传的文件的路径
  2743. string filePath = "";
  2744. if (TypeName == "A")//A代表团组增减款项
  2745. {
  2746. if (!Directory.Exists(fileDir))
  2747. {
  2748. Directory.CreateDirectory(fileDir);
  2749. }
  2750. //上传的文件的路径
  2751. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2752. }
  2753. else if (TypeName == "B")//B代表商邀相关文件
  2754. {
  2755. if (!Directory.Exists(fileDir))
  2756. {
  2757. Directory.CreateDirectory(fileDir);
  2758. }
  2759. //上传的文件的路径
  2760. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2761. }
  2762. using (FileStream fs = System.IO.File.Create(filePath))
  2763. {
  2764. file.CopyTo(fs);
  2765. fs.Flush();
  2766. }
  2767. return Ok(JsonView(true, "上传成功!", projectFileName));
  2768. }
  2769. else
  2770. {
  2771. return Ok(JsonView(false, "上传失败!"));
  2772. }
  2773. }
  2774. catch (Exception ex)
  2775. {
  2776. return Ok(JsonView(false, "程序错误!"));
  2777. throw;
  2778. }
  2779. }
  2780. /// <summary>
  2781. /// 删除指定文件
  2782. /// </summary>
  2783. /// <param name="dto"></param>
  2784. /// <returns></returns>
  2785. [HttpPost]
  2786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2787. public async Task<IActionResult> DelFile(DelFileDto dto)
  2788. {
  2789. try
  2790. {
  2791. var TypeName = Request.Headers["TypeName"].ToString();
  2792. string filePath = "";
  2793. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2794. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2795. int id = 0;
  2796. if (TypeName == "A")
  2797. {
  2798. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2799. // 删除该文件
  2800. System.IO.File.Delete(filePath);
  2801. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2802. }
  2803. else if (TypeName == "B")
  2804. {
  2805. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2806. // 删除该文件
  2807. System.IO.File.Delete(filePath);
  2808. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2809. }
  2810. if (id != 0)
  2811. {
  2812. return Ok(JsonView(true, "成功!"));
  2813. }
  2814. else
  2815. {
  2816. return Ok(JsonView(false, "失败!"));
  2817. }
  2818. }
  2819. catch (Exception ex)
  2820. {
  2821. return Ok(JsonView(false, "程序错误!"));
  2822. throw;
  2823. }
  2824. }
  2825. #endregion
  2826. #region 商邀费用录入
  2827. /// <summary>
  2828. /// 根据团组Id查询商邀费用列表
  2829. /// </summary>
  2830. /// <param name="dto"></param>
  2831. /// <returns></returns>
  2832. [HttpPost]
  2833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2834. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2835. {
  2836. try
  2837. {
  2838. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2839. if (groupData.Code != 0)
  2840. {
  2841. return Ok(JsonView(false, groupData.Msg));
  2842. }
  2843. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2844. }
  2845. catch (Exception ex)
  2846. {
  2847. return Ok(JsonView(false, "程序错误!"));
  2848. throw;
  2849. }
  2850. }
  2851. //
  2852. /// <summary>
  2853. /// 商邀费用 Info Page 基础数据源
  2854. /// </summary>
  2855. /// <param name="dto"></param>
  2856. /// <returns></returns>
  2857. [HttpPost]
  2858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2859. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2860. {
  2861. try
  2862. {
  2863. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2864. if (groupData.Code != 0)
  2865. {
  2866. return Ok(JsonView(false, groupData.Msg));
  2867. }
  2868. return Ok(JsonView(true, "操作成功", groupData.Data));
  2869. }
  2870. catch (Exception ex)
  2871. {
  2872. return Ok(JsonView(false, ex.Message));
  2873. throw;
  2874. }
  2875. }
  2876. /// <summary>
  2877. /// 根据商邀费用ID查询C表和商邀费用数据
  2878. /// </summary>
  2879. /// <param name="dto"></param>
  2880. /// <returns></returns>
  2881. [HttpPost]
  2882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2883. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2884. {
  2885. try
  2886. {
  2887. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2888. if (groupData.Code != 0)
  2889. {
  2890. return Ok(JsonView(false, groupData.Msg));
  2891. }
  2892. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2893. }
  2894. catch (Exception ex)
  2895. {
  2896. return Ok(JsonView(false, ex.Message));
  2897. throw;
  2898. }
  2899. }
  2900. /// <summary>
  2901. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2902. /// </summary>
  2903. /// <param name="dto"></param>
  2904. /// <returns></returns>
  2905. [HttpPost]
  2906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2907. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2908. {
  2909. try
  2910. {
  2911. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  2912. if (groupData.Code != 0)
  2913. {
  2914. return Ok(JsonView(false, groupData.Msg));
  2915. }
  2916. #region 应用推送
  2917. try
  2918. {
  2919. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2920. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2921. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2922. }
  2923. catch (Exception ex)
  2924. {
  2925. }
  2926. #endregion
  2927. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2928. }
  2929. catch (Exception ex)
  2930. {
  2931. return Ok(JsonView(false, "程序错误!"));
  2932. throw;
  2933. }
  2934. }
  2935. /// <summary>
  2936. /// 商邀删除
  2937. /// </summary>
  2938. /// <param name="dto"></param>
  2939. /// <returns></returns>
  2940. [HttpPost]
  2941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2942. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2943. {
  2944. try
  2945. {
  2946. _sqlSugar.BeginTran();
  2947. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  2948. .SetColumns(it => new Grp_InvitationOfficialActivities()
  2949. {
  2950. IsDel = 1,
  2951. DeleteUserId = dto.DeleteUserId,
  2952. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2953. })
  2954. .Where(it => it.Id == dto.Id)
  2955. .ExecuteCommand();
  2956. if (res1 > 0)
  2957. {
  2958. int _diId = 0;
  2959. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  2960. if (_ioaInfo != null)
  2961. {
  2962. _diId = _ioaInfo.DiId;
  2963. }
  2964. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2965. .SetColumns(a => new Grp_CreditCardPayment()
  2966. {
  2967. IsDel = 1,
  2968. DeleteUserId = dto.DeleteUserId,
  2969. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2970. })
  2971. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  2972. .ExecuteCommand();
  2973. if (res2 > 0)
  2974. {
  2975. _sqlSugar.CommitTran();
  2976. return Ok(JsonView(true, "删除成功!"));
  2977. }
  2978. }
  2979. _sqlSugar.RollbackTran();
  2980. return Ok(JsonView(false, "删除失败"));
  2981. }
  2982. catch (Exception ex)
  2983. {
  2984. _sqlSugar.RollbackTran();
  2985. return Ok(JsonView(false, ex.Message));
  2986. }
  2987. }
  2988. #endregion
  2989. #region 团组英文资料
  2990. /// <summary>
  2991. /// 查询团组英文所有资料
  2992. /// </summary>
  2993. /// <param name="dto"></param>
  2994. /// <returns></returns>
  2995. [HttpPost]
  2996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2997. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2998. {
  2999. try
  3000. {
  3001. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3002. if (groupData.Code != 0)
  3003. {
  3004. return Ok(JsonView(false, groupData.Msg));
  3005. }
  3006. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3007. }
  3008. catch (Exception ex)
  3009. {
  3010. return Ok(JsonView(false, "程序错误!"));
  3011. throw;
  3012. }
  3013. }
  3014. /// <summary>
  3015. /// 团组英文资料操作(Status:1.新增,2.修改)
  3016. /// </summary>
  3017. /// <param name="dto"></param>
  3018. /// <returns></returns>
  3019. [HttpPost]
  3020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3021. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3022. {
  3023. try
  3024. {
  3025. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3026. if (groupData.Code != 0)
  3027. {
  3028. return Ok(JsonView(false, groupData.Msg));
  3029. }
  3030. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3031. }
  3032. catch (Exception ex)
  3033. {
  3034. return Ok(JsonView(false, "程序错误!"));
  3035. throw;
  3036. }
  3037. }
  3038. /// <summary>
  3039. /// 团组英文资料Id查询数据
  3040. /// </summary>
  3041. /// <param name="dto"></param>
  3042. /// <returns></returns>
  3043. [HttpPost]
  3044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3045. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3046. {
  3047. try
  3048. {
  3049. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3050. if (_DelegationEnData != null)
  3051. {
  3052. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3053. }
  3054. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3055. }
  3056. catch (Exception ex)
  3057. {
  3058. return Ok(JsonView(false, "程序错误!"));
  3059. throw;
  3060. }
  3061. }
  3062. /// <summary>
  3063. /// 团组英文资料删除
  3064. /// </summary>
  3065. /// <param name="dto"></param>
  3066. /// <returns></returns>
  3067. [HttpPost]
  3068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3069. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3070. {
  3071. try
  3072. {
  3073. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3074. if (!res)
  3075. {
  3076. return Ok(JsonView(false, "删除失败"));
  3077. }
  3078. return Ok(JsonView(true, "删除成功!"));
  3079. }
  3080. catch (Exception ex)
  3081. {
  3082. return Ok(JsonView(false, "程序错误!"));
  3083. throw;
  3084. }
  3085. }
  3086. #endregion
  3087. #region 导出邀请函
  3088. /// <summary>
  3089. /// 导出邀请函页面初始化
  3090. /// </summary>
  3091. /// <param name="dto"></param>
  3092. /// <returns></returns>
  3093. [HttpPost]
  3094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3095. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3096. {
  3097. try
  3098. {
  3099. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3100. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3101. if (dto.DiId == 0)
  3102. {
  3103. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3104. }
  3105. else
  3106. {
  3107. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3108. }
  3109. return Ok(JsonView(true, "查询成功!", new
  3110. {
  3111. deleClient = crm_Deles,
  3112. delegations = grp_Delegations
  3113. }));
  3114. }
  3115. catch (Exception ex)
  3116. {
  3117. return Ok(JsonView(false, "程序错误!"));
  3118. throw;
  3119. }
  3120. }
  3121. /// <summary>
  3122. /// 导出邀请函
  3123. /// </summary>
  3124. /// <param name="dto"></param>
  3125. /// <returns></returns>
  3126. [HttpPost]
  3127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3128. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3129. {
  3130. #region 参数验证
  3131. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3132. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3133. #endregion
  3134. try
  3135. {
  3136. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3137. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3138. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3139. From Grp_TourClientList tcl
  3140. Left Join
  3141. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3142. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3143. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3144. From Crm_DeleClient dc
  3145. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3146. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3147. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3148. Where dc.IsDel = 0) temp
  3149. On temp.DcId =tcl.ClientId
  3150. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3151. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3152. List<string> texts = new List<string>();
  3153. if (datas.Count != 0)
  3154. {
  3155. foreach (TourClientListDetailsView item in datas)
  3156. {
  3157. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3158. {
  3159. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3160. }
  3161. else
  3162. {
  3163. string name = item.LastName + item.FirstName;
  3164. texts.Add(name);
  3165. }
  3166. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3167. {
  3168. if (!transDic.ContainsKey(item.Job))
  3169. {
  3170. texts.Add(item.Job);
  3171. }
  3172. }
  3173. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3174. {
  3175. texts.Add(item.CompanyFullName);
  3176. }
  3177. }
  3178. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3179. if (transData.Count > 0)
  3180. {
  3181. foreach (TranslateResult item in transData)
  3182. {
  3183. if (!transDic.ContainsKey(item.Query))
  3184. {
  3185. transDic.Add(item.Query, item.Translation);
  3186. }
  3187. }
  3188. }
  3189. List<GuestList> list = new List<GuestList>();
  3190. foreach (TourClientListDetailsView dele in datas)
  3191. {
  3192. GuestList guestList = new GuestList();
  3193. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3194. {
  3195. guestList.Name = dele.Pinyin;
  3196. }
  3197. else
  3198. {
  3199. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3200. guestList.Name = Name;
  3201. }
  3202. if (dele.Sex == 0)
  3203. {
  3204. guestList.Sex = "Male";
  3205. }
  3206. else if (dele.Sex == 1)
  3207. {
  3208. guestList.Sex = "Female";
  3209. }
  3210. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3211. if (!string.IsNullOrEmpty(dele.Job))
  3212. {
  3213. guestList.Job = dele.Job;
  3214. }
  3215. list.Add(guestList);
  3216. }
  3217. //载入模板
  3218. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3219. DocumentBuilder builder = new DocumentBuilder(doc);
  3220. //获取word里所有表格
  3221. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3222. //获取所填表格的序数
  3223. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3224. var rowStart = tableOne.Rows[0]; //获取第1行
  3225. //循环赋值
  3226. for (int i = 0; i < list.Count; i++)
  3227. {
  3228. builder.MoveToCell(0, i + 1, 0, 0);
  3229. builder.Write(list[i].Name.ToString());
  3230. builder.MoveToCell(0, i + 1, 1, 0);
  3231. builder.Write(list[i].Sex.ToString());
  3232. builder.MoveToCell(0, i + 1, 2, 0);
  3233. builder.Write(list[i].DOB.ToString());
  3234. builder.MoveToCell(0, i + 1, 3, 0);
  3235. builder.Write(list[i].Job.ToString());
  3236. }
  3237. //删除多余行
  3238. while (tableOne.Rows.Count > list.Count + 1)
  3239. {
  3240. tableOne.Rows.RemoveAt(list.Count + 1);
  3241. }
  3242. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3243. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3244. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3245. doc.Save(filePath);
  3246. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3247. return Ok(JsonView(true, "操作成功!", Url));
  3248. }
  3249. else
  3250. {
  3251. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3252. }
  3253. }
  3254. catch (Exception ex)
  3255. {
  3256. return Ok(JsonView(false, ex.Message));
  3257. throw;
  3258. }
  3259. }
  3260. #endregion
  3261. #region 团组经理模块 出入境费用
  3262. ///// <summary>
  3263. ///// 团组模块 - 出入境费用
  3264. ///// </summary>
  3265. ///// <returns></returns>
  3266. //[HttpPost]
  3267. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3268. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3269. //{
  3270. // try
  3271. // {
  3272. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3273. // if (data.Code != 0)
  3274. // {
  3275. // return Ok(JsonView(false, data.Msg));
  3276. // }
  3277. // return Ok(JsonView(true, "查询成功!"));
  3278. // }
  3279. // catch (Exception ex)
  3280. // {
  3281. // return Ok(JsonView(false, ex.Message));
  3282. // throw;
  3283. // }
  3284. //}
  3285. /// <summary>
  3286. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3287. /// </summary>
  3288. /// <returns></returns>
  3289. [HttpPost]
  3290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3291. public async Task<IActionResult> SetDayAndCostAreaChange()
  3292. {
  3293. try
  3294. {
  3295. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3296. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3297. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3298. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3299. foreach (var item in unite) //处理交集数据
  3300. {
  3301. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3302. }
  3303. foreach (var item in merge) //处理差集数据
  3304. {
  3305. int nationalTravelFeeId = 0;
  3306. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3307. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3308. else
  3309. {
  3310. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3311. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3312. }
  3313. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3314. }
  3315. //只更新dayAndCost 的 nationalTravelFeeId;
  3316. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3317. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3318. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3319. }
  3320. catch (Exception ex)
  3321. {
  3322. return Ok(JsonView(false, ex.Message));
  3323. throw;
  3324. }
  3325. }
  3326. /// <summary>
  3327. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3328. /// </summary>
  3329. /// <returns></returns>
  3330. [HttpPost]
  3331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3332. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3333. {
  3334. try
  3335. {
  3336. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3337. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3338. //SetDataInfoView
  3339. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3340. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3341. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3342. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3343. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3344. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3345. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3346. //默认币种显示
  3347. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3348. {
  3349. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3350. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3351. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3352. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3353. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3354. };
  3355. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3356. if (_currencyRate.Count > 0)
  3357. {
  3358. foreach (var item in _currencyInfos)
  3359. {
  3360. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3361. if (rateInfo != null)
  3362. {
  3363. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3364. rate1 *= 1.03M;
  3365. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3366. }
  3367. }
  3368. }
  3369. return Ok(JsonView(true, "查询成功!", new
  3370. {
  3371. GroupNameData = groupNameData.Data,
  3372. CurrencyData = _CurrencyData,
  3373. WordTypeData = _WordTypeData,
  3374. ExcelTypeData = _ExcelTypeData,
  3375. CurrencyInit = _currencyInfos
  3376. }));
  3377. }
  3378. catch (Exception ex)
  3379. {
  3380. return Ok(JsonView(false, ex.Message));
  3381. throw;
  3382. }
  3383. }
  3384. /// <summary>
  3385. /// 团组模块 - 出入境费用
  3386. /// 实时汇率 tips
  3387. /// 签证费用 tips
  3388. /// </summary>
  3389. /// <returns></returns>
  3390. [HttpPost]
  3391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3392. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3393. {
  3394. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3395. //默认币种显示
  3396. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3397. {
  3398. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3399. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3400. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3401. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3402. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3403. };
  3404. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3405. List<dynamic> reteInfos = new List<dynamic>();
  3406. if (_currencyRate.Count > 0)
  3407. {
  3408. foreach (var item in _currencyInfos)
  3409. {
  3410. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3411. if (rateInfo != null)
  3412. {
  3413. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3414. decimal rate1 = item.Rate;
  3415. rate1 *= 1.03M;
  3416. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3417. reteInfos.Add(new
  3418. {
  3419. currCode = item.CurrencyCode,
  3420. currName = item.CurrencyName,
  3421. rate = rate2,
  3422. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3423. });
  3424. }
  3425. }
  3426. }
  3427. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3428. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3429. return Ok(JsonView(true, "查询成功!", new
  3430. {
  3431. //GroupNameData = groupNameData.Data,
  3432. visaData = visaData.Data,
  3433. airData = airData.Data,
  3434. reteInfos = reteInfos
  3435. }));
  3436. }
  3437. /// <summary>
  3438. /// 团组模块 - 出入境费用 - Info
  3439. /// </summary>
  3440. /// <returns></returns>
  3441. [HttpPost]
  3442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3443. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3444. {
  3445. try
  3446. {
  3447. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3448. if (data.Code != 0)
  3449. {
  3450. return Ok(JsonView(false, data.Msg));
  3451. }
  3452. return Ok(JsonView(true, "查询成功!", data.Data));
  3453. }
  3454. catch (Exception ex)
  3455. {
  3456. return Ok(JsonView(false, ex.Message));
  3457. }
  3458. }
  3459. /// <summary>
  3460. /// 团组模块 - 出入境费用 - Add And Update
  3461. /// </summary>
  3462. /// <returns></returns>
  3463. [HttpPost]
  3464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3465. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3466. {
  3467. try
  3468. {
  3469. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3470. if (data.Code != 0)
  3471. {
  3472. return Ok(JsonView(false, data.Msg));
  3473. }
  3474. return Ok(JsonView(true, data.Msg, data.Data));
  3475. }
  3476. catch (Exception ex)
  3477. {
  3478. return Ok(JsonView(false, ex.Message));
  3479. }
  3480. }
  3481. /// <summary>
  3482. /// 团组模块 - 出入境费用 - File downlaod
  3483. /// </summary>
  3484. /// <param name="dto"></param>
  3485. /// <returns></returns>
  3486. [HttpPost]
  3487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3488. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3489. {
  3490. try
  3491. {
  3492. if (dto.DiId < 1)
  3493. {
  3494. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3495. }
  3496. if (dto.ExportType < 1)
  3497. {
  3498. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3499. }
  3500. if (dto.SubTypeId < 1)
  3501. {
  3502. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3503. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3504. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3505. 3 团组成员名单 1 团组成员名单"));
  3506. }
  3507. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3508. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3509. if (_EnterExitCosts == null)
  3510. {
  3511. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3512. }
  3513. //数据源
  3514. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3515. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3516. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3517. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3518. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3519. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3520. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3521. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3522. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3523. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3524. .Select((tcl, dc, cc) => new
  3525. {
  3526. Name = dc.LastName + dc.FirstName,
  3527. Sex = dc.Sex,
  3528. Birthday = dc.BirthDay,
  3529. Company = cc.CompanyFullName,
  3530. Job = dc.Job
  3531. })
  3532. .ToList();
  3533. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3534. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3535. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3536. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3537. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3538. if (dto.ExportType == 1) //明细表
  3539. {
  3540. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3541. {
  3542. //获取模板
  3543. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3544. //载入模板
  3545. Document doc = new Document(tempPath);
  3546. DocumentBuilder builder = new DocumentBuilder(doc);
  3547. //利用键值对存放数据
  3548. Dictionary<string, string> dic = new Dictionary<string, string>();
  3549. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3550. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3551. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3552. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3553. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3554. string row1_1 = "";
  3555. if (_EnterExitCosts.Visa > 0)
  3556. {
  3557. //insidePayTotal += _EnterExitCosts.Visa;
  3558. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3559. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3560. {
  3561. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3562. }
  3563. }
  3564. string row1_2 = "";
  3565. if (_EnterExitCosts.YiMiao > 0)
  3566. {
  3567. //insidePayTotal += _EnterExitCosts.YiMiao;
  3568. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3569. }
  3570. if (_EnterExitCosts.HeSuan > 0)
  3571. {
  3572. //insidePayTotal += _EnterExitCosts.HeSuan;
  3573. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3574. }
  3575. if (_EnterExitCosts.Service > 0)
  3576. {
  3577. //insidePayTotal += _EnterExitCosts.Service;
  3578. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3579. }
  3580. string row1_3 = "";
  3581. if (_EnterExitCosts.Safe > 0)
  3582. {
  3583. //insidePayTotal += _EnterExitCosts.Safe;
  3584. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3585. }
  3586. if (_EnterExitCosts.Ticket > 0)
  3587. {
  3588. //insidePayTotal += _EnterExitCosts.Ticket;
  3589. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3590. }
  3591. string row1 = "";
  3592. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3593. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3594. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3595. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3596. dic.Add("Row1Str", row1);
  3597. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3598. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3599. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3600. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3601. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3602. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3603. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3604. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3605. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3606. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3607. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3608. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3609. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3610. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3611. #region 填充word模板书签内容
  3612. foreach (var key in dic.Keys)
  3613. {
  3614. builder.MoveToBookmark(key);
  3615. builder.Write(dic[key]);
  3616. }
  3617. #endregion
  3618. #region 填充word表格内容
  3619. ////获读取指定表格方法二
  3620. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3621. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3622. for (int i = 0; i < dac1.Count; i++)
  3623. {
  3624. Grp_DayAndCost dac = dac1[i];
  3625. if (dac == null) continue;
  3626. builder.MoveToCell(0, i, 0, 0);
  3627. builder.Write("第" + dac.Days.ToString() + "晚:");
  3628. builder.MoveToCell(0, i, 1, 0);
  3629. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3630. //builder.Write(dac.Place == null ? "" : dac.Place);
  3631. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3632. builder.MoveToCell(0, i, 2, 0);
  3633. builder.Write("费用标准:");
  3634. string curr = "";
  3635. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3636. if (currData != null)
  3637. {
  3638. curr = currData.Name;
  3639. }
  3640. builder.MoveToCell(0, i, 3, 0);
  3641. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3642. builder.MoveToCell(0, i, 4, 0);
  3643. builder.Write("费用小计:");
  3644. builder.MoveToCell(0, i, 5, 0);
  3645. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3646. }
  3647. //删除多余行
  3648. while (table1.Rows.Count > dac1.Count)
  3649. {
  3650. table1.Rows.RemoveAt(dac1.Count);
  3651. }
  3652. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3653. for (int i = 0; i < dac2.Count; i++)
  3654. {
  3655. Grp_DayAndCost dac = dac2[i];
  3656. if (dac == null) continue;
  3657. builder.MoveToCell(1, i, 0, 0);
  3658. builder.Write("第" + dac.Days.ToString() + "天:");
  3659. builder.MoveToCell(1, i, 1, 0);
  3660. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3661. builder.MoveToCell(1, i, 2, 0);
  3662. builder.Write("费用标准:");
  3663. string curr = "";
  3664. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3665. if (currData != null)
  3666. {
  3667. curr = currData.Name;
  3668. }
  3669. builder.MoveToCell(1, i, 3, 0);
  3670. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3671. builder.MoveToCell(1, i, 4, 0);
  3672. builder.Write("费用小计:");
  3673. builder.MoveToCell(1, i, 5, 0);
  3674. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3675. }
  3676. //删除多余行
  3677. while (table2.Rows.Count > dac2.Count)
  3678. {
  3679. table2.Rows.RemoveAt(dac2.Count);
  3680. }
  3681. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3682. for (int i = 0; i < dac3.Count; i++)
  3683. {
  3684. Grp_DayAndCost dac = dac3[i];
  3685. if (dac == null) continue;
  3686. builder.MoveToCell(2, i, 0, 0);
  3687. builder.Write("第" + dac.Days.ToString() + "天:");
  3688. builder.MoveToCell(2, i, 1, 0);
  3689. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3690. builder.MoveToCell(2, i, 2, 0);
  3691. builder.Write("费用标准:");
  3692. string curr = "";
  3693. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3694. if (currData != null)
  3695. {
  3696. curr = currData.Name;
  3697. }
  3698. builder.MoveToCell(2, i, 3, 0);
  3699. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3700. builder.MoveToCell(2, i, 4, 0);
  3701. builder.Write("费用小计:");
  3702. builder.MoveToCell(2, i, 5, 0);
  3703. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3704. }
  3705. //删除多余行
  3706. while (table3.Rows.Count > dac3.Count)
  3707. {
  3708. table3.Rows.RemoveAt(dac3.Count);
  3709. }
  3710. #endregion
  3711. //文件名
  3712. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3713. AsposeHelper.removewatermark_v2180();
  3714. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3715. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3716. return Ok(JsonView(true, "成功", new { Url = url }));
  3717. }
  3718. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3719. {
  3720. //获取模板
  3721. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3722. //载入模板
  3723. Document doc = new Document(tempPath);
  3724. DocumentBuilder builder = new DocumentBuilder(doc);
  3725. Dictionary<string, string> dic = new Dictionary<string, string>();
  3726. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3727. {
  3728. List<string> list = new List<string>();
  3729. try
  3730. {
  3731. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3732. foreach (var item in spilitArr)
  3733. {
  3734. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3735. var depCode = spDotandEmpty[2].Substring(0, 3);
  3736. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3737. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3738. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3739. list.Add(depName);
  3740. list.Add(arrName);
  3741. }
  3742. list = list.Distinct().ToList();
  3743. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3744. }
  3745. catch (Exception)
  3746. {
  3747. dic.Add("ReturnCode", "行程录入不正确!");
  3748. }
  3749. }
  3750. else
  3751. {
  3752. dic.Add("ReturnCode", "未录入行程!");
  3753. }
  3754. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3755. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3756. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3757. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3758. {
  3759. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3760. dic.Add("Day", sp.Days.ToString());
  3761. }
  3762. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3763. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3764. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3765. //dic.Add("Names", Names);
  3766. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3767. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3768. decimal dac1totalPrice = 0.00M;
  3769. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3770. foreach (var dac in dac1)
  3771. {
  3772. if (dac.SubTotal == 0.00M)
  3773. {
  3774. continue;
  3775. }
  3776. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3777. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3778. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3779. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3780. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3781. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3782. builder.Write(currency);//币种
  3783. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3784. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3785. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3786. builder.Write("");//人数
  3787. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3788. builder.Write("");//天数
  3789. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3790. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3791. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3792. decimal rate = 0.00M;
  3793. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3794. builder.Write(rate.ToString("#0.0000"));//汇率
  3795. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3796. decimal rbmPrice = dac.SubTotal;
  3797. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3798. accommodationStartIndex++;
  3799. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3800. }
  3801. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3802. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3803. {
  3804. table1.Rows.RemoveAt(i - 1);
  3805. foodandotherStartIndex--;
  3806. }
  3807. if (dac2.Count == dac3.Count)//国家 币种 金额
  3808. {
  3809. for (int i = 0; i < dac2.Count; i++)
  3810. {
  3811. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3812. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3813. }
  3814. }
  3815. decimal dac2totalPrice = 0.00M;
  3816. foreach (var dac in dac2)
  3817. {
  3818. if (dac.SubTotal == 0)
  3819. {
  3820. continue;
  3821. }
  3822. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3823. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3824. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3825. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3826. builder.Write(currency);//币种
  3827. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3828. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3829. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3830. builder.Write("");//人数
  3831. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3832. builder.Write("");//天数
  3833. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3834. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3835. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3836. decimal rate = 0.00M;
  3837. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3838. builder.Write(rate.ToString("#0.0000"));//汇率
  3839. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3840. decimal rbmPrice = dac.SubTotal;
  3841. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3842. foodandotherStartIndex++;
  3843. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3844. }
  3845. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3846. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3847. {
  3848. table1.Rows.RemoveAt(i - 1);
  3849. }
  3850. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3851. string otherFeeStr = "";
  3852. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  3853. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  3854. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  3855. if (otherFeeStr.Length > 0)
  3856. {
  3857. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  3858. otherFeeStr = $"({otherFeeStr})";
  3859. dic.Add("OtherFeeStr", otherFeeStr);
  3860. }
  3861. //总计
  3862. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  3863. //国际旅费
  3864. string outsideJJ = "";
  3865. string allPriceJJ = "";
  3866. if (_EnterExitCosts.SumJJC == 1)
  3867. {
  3868. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3869. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  3870. }
  3871. string outsideGW = "";
  3872. string allPriceGW = "";
  3873. if (_EnterExitCosts.SumGWC == 1)
  3874. {
  3875. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  3876. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  3877. }
  3878. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  3879. {
  3880. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  3881. dic.Add("InTravelPrice", InTravelPriceStr);
  3882. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  3883. dic.Add("FinalSumPrice", FinalSumPriceStr);
  3884. }
  3885. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  3886. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  3887. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  3888. foreach (var key in dic.Keys)
  3889. {
  3890. builder.MoveToBookmark(key);
  3891. builder.Write(dic[key]);
  3892. }
  3893. //模板文件名
  3894. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  3895. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3896. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3897. return Ok(JsonView(true, "成功", new { Url = url }));
  3898. }
  3899. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  3900. {
  3901. //获取模板
  3902. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  3903. //载入模板
  3904. WorkbookDesigner designer = new WorkbookDesigner();
  3905. designer.Workbook = new Workbook(tempPath);
  3906. Dictionary<string, string> dic = new Dictionary<string, string>();
  3907. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3908. {
  3909. List<string> list = new List<string>();
  3910. try
  3911. {
  3912. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3913. foreach (var item in spilitArr)
  3914. {
  3915. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3916. var depCode = spDotandEmpty[2].Substring(0, 3);
  3917. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3918. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  3919. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  3920. list.Add(depName);
  3921. list.Add(arrName);
  3922. }
  3923. list = list.Distinct().ToList();
  3924. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3925. }
  3926. catch (Exception)
  3927. {
  3928. dic.Add("ReturnCode", "行程录入不正确!");
  3929. }
  3930. }
  3931. else
  3932. {
  3933. dic.Add("ReturnCode", "未录入行程!");
  3934. }
  3935. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3936. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3937. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3938. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3939. {
  3940. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3941. dic.Add("Day", sp.Days.ToString());
  3942. }
  3943. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3944. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3945. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3946. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  3947. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  3948. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  3949. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  3950. designer.SetDataSource("Name", Names);
  3951. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  3952. designer.SetDataSource("Day", dic["Day"] + "天");
  3953. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  3954. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  3955. int startIndex = 10;
  3956. const int startIndexcopy = 10;
  3957. if (dac2.Count == dac3.Count)//国家 币种 金额
  3958. {
  3959. for (int i = 0; i < dac2.Count; i++)
  3960. {
  3961. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3962. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3963. }
  3964. }
  3965. DataTable dtdac1 = new DataTable();
  3966. List<string> place = new List<string>();
  3967. dtdac1.Columns.AddRange(new DataColumn[] {
  3968. new DataColumn(){ ColumnName = "city"},
  3969. new DataColumn(){ ColumnName = "curr"},
  3970. new DataColumn(){ ColumnName = "criterion"},
  3971. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3972. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3973. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3974. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3975. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  3976. });
  3977. DataTable dtdac2 = new DataTable();
  3978. dtdac2.Columns.AddRange(new DataColumn[] {
  3979. new DataColumn(){ ColumnName = "city"},
  3980. new DataColumn(){ ColumnName = "curr"},
  3981. new DataColumn(){ ColumnName = "criterion"},
  3982. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3983. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3984. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3985. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3986. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  3987. });
  3988. dtdac1.TableName = "tb1";
  3989. dtdac2.TableName = "tb2";
  3990. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  3991. foreach (var item in dac1)
  3992. {
  3993. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  3994. if (place.Contains(item.Place))
  3995. {
  3996. continue;
  3997. }
  3998. DataRow row = dtdac1.NewRow();
  3999. row["city"] = item.Place;
  4000. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4001. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4002. row["curr"] = currency;
  4003. row["rate"] = rate.ToString("#0.0000");
  4004. row["criterion"] = item.Cost.ToString("#0.00");
  4005. row["number"] = 1;
  4006. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4007. //row["costRMB"] = rbmPrice;
  4008. dtdac1.Rows.Add(row);
  4009. place.Add(item.Place);
  4010. }
  4011. place = new List<string>();
  4012. foreach (var item in dac2)
  4013. {
  4014. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4015. if (place.Contains(item.Place))
  4016. {
  4017. continue;
  4018. }
  4019. DataRow row = dtdac2.NewRow();
  4020. row["city"] = item.Place;
  4021. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4022. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4023. row["curr"] = currency;
  4024. row["rate"] = rate.ToString("#0.0000");
  4025. row["criterion"] = item.Cost.ToString("#0.00");
  4026. row["number"] = 1;
  4027. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4028. //row["cost"] = item.SubTotal;
  4029. //row["costRMB"] = rbmPrice;
  4030. dtdac2.Rows.Add(row);
  4031. place.Add(item.Place);
  4032. //dac2totalPrice += rbmPrice;
  4033. }
  4034. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4035. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4036. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4037. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4038. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4039. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4040. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4041. string cellStr = $" 5.其他费用(";
  4042. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4043. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4044. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4045. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4046. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4047. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4048. if (cellStr.Length > 8)
  4049. {
  4050. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4051. }
  4052. cellStr += ")";
  4053. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4054. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4055. decimal pxFee = dac4.Sum(it => it.Cost);
  4056. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4057. string celllastStr1 = "";
  4058. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4059. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4060. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4061. celllastStr1 += $",国际旅费 元";
  4062. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4063. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4064. designer.SetDataSource("cell4Str", cell4Str);
  4065. designer.SetDataSource("cellStr", cellStr);
  4066. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4067. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4068. designer.SetDataSource("celllastStr", celllastStr);
  4069. Workbook wb = designer.Workbook;
  4070. var sheet = wb.Worksheets[0];
  4071. //绑定datatable数据集
  4072. designer.SetDataSource(dtdac1);
  4073. designer.SetDataSource(dtdac2);
  4074. designer.Process();
  4075. var rowStart = dtdac1.Rows.Count;
  4076. while (rowStart > 0)
  4077. {
  4078. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4079. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4080. startIndex++;
  4081. rowStart--;
  4082. }
  4083. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4084. startIndex += 1; //总计行
  4085. rowStart = dtdac2.Rows.Count;
  4086. while (rowStart > 0)
  4087. {
  4088. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4089. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4090. startIndex++;
  4091. rowStart--;
  4092. }
  4093. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4094. wb.CalculateFormula(true);
  4095. //模板文件名
  4096. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  4097. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4098. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4099. return Ok(JsonView(true, "成功", new { Url = url }));
  4100. }
  4101. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4102. {
  4103. //获取模板
  4104. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4105. //载入模板
  4106. Document doc = new Document(tempPath);
  4107. DocumentBuilder builder = new DocumentBuilder(doc);
  4108. Dictionary<string, string> dic = new Dictionary<string, string>();
  4109. dic.Add("GroupName", _DelegationInfo.TeamName);
  4110. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4111. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4112. string missionLeaderJob = "";//负责人job
  4113. int groupNumber = 0; //团人数
  4114. if (DeleClientList.Count > 0)
  4115. {
  4116. missionLeader = DeleClientList[0]?.Name ?? "";
  4117. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4118. }
  4119. dic.Add("MissionLeader", missionLeader); //团负责人
  4120. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4121. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4122. #region MyRegion
  4123. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4124. //{
  4125. // List<string> list = new List<string>();
  4126. // try
  4127. // {
  4128. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4129. // foreach (var item in spilitArr)
  4130. // {
  4131. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4132. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4133. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4134. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4135. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4136. // list.Add(depName);
  4137. // list.Add(arrName);
  4138. // }
  4139. // list = list.Distinct().ToList();
  4140. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4141. // }
  4142. // catch (Exception)
  4143. // {
  4144. // dic.Add("ReturnCode", "行程录入不正确!");
  4145. // }
  4146. //}
  4147. //else
  4148. //{
  4149. // dic.Add("ReturnCode", "未录入行程!");
  4150. //}
  4151. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4152. dic.Add("ReturnCode", string.Join("、", countrys));
  4153. #endregion
  4154. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4155. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4156. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4157. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4158. //{
  4159. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4160. // dic.Add("Day", sp.Days.ToString());
  4161. //}
  4162. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4163. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4164. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4165. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4166. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4167. //培训人员名单
  4168. int cultivateRowIndex = 7;
  4169. foreach (var item in DeleClientList)
  4170. {
  4171. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4172. builder.Write(item.Name);
  4173. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4174. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4175. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4176. string birthDay = "";
  4177. if (item.Birthday != null)
  4178. {
  4179. DateTime dt = Convert.ToDateTime(item.Birthday);
  4180. birthDay = $"{dt.Year}.{dt.Month}";
  4181. }
  4182. builder.Write(birthDay);
  4183. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4184. builder.Write(item.Company);
  4185. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4186. builder.Write(item.Job);
  4187. cultivateRowIndex++;
  4188. }
  4189. //删除多余行
  4190. //cultivateRowIndex -= 2;
  4191. int delRows = 10 + 7 - cultivateRowIndex;
  4192. if (delRows > 0)
  4193. {
  4194. for (int i = 0; i < delRows; i++)
  4195. {
  4196. table1.Rows.RemoveAt(cultivateRowIndex);
  4197. //cultivateRowIndex++;
  4198. }
  4199. }
  4200. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4201. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4202. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4203. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4204. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4205. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4206. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4207. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4208. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4209. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4210. //其他费用
  4211. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4212. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4213. //其他费用合计
  4214. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4215. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4216. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4217. //公务舱合计
  4218. //国际旅费
  4219. string outsideJJ = "";
  4220. string allPriceJJ = "";
  4221. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4222. {
  4223. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4224. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4225. }
  4226. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4227. {
  4228. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4229. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4230. }
  4231. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4232. {
  4233. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4234. dic.Add("AirFeeTotal", airFeeTotalStr);
  4235. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4236. dic.Add("FeeTotal", feeTotalStr);
  4237. }
  4238. foreach (var key in dic.Keys)
  4239. {
  4240. builder.MoveToBookmark(key);
  4241. builder.Write(dic[key]);
  4242. }
  4243. //模板文件名
  4244. string strFileName = $"{_DelegationInfo.TeamName}成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4245. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4246. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4247. return Ok(JsonView(true, "成功", new { Url = url }));
  4248. }
  4249. }
  4250. else if (dto.ExportType == 2) //表格
  4251. {
  4252. //利用键值对存放数据
  4253. Dictionary<string, string> dic = new Dictionary<string, string>();
  4254. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4255. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4256. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4257. dic.Add("Day", sp.Days.ToString());
  4258. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4259. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4260. {
  4261. //获取模板
  4262. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4263. //载入模板
  4264. Document doc = new Document(tempPath);
  4265. DocumentBuilder builder = new DocumentBuilder(doc);
  4266. dic.Add("TeamName", _DelegationInfo.TeamName);
  4267. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4268. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4269. string missionLeaderName = "",
  4270. missionLeaderJob = "";
  4271. if (DeleClientList.Count > 0)
  4272. {
  4273. missionLeaderName = DeleClientList[0].Name;
  4274. missionLeaderJob = DeleClientList[0].Job;
  4275. }
  4276. dic.Add("MissionLeaderName", missionLeaderName);
  4277. dic.Add("MissionLeaderJob", missionLeaderJob);
  4278. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4279. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4280. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4281. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4282. int rowCount = 10;//总人数行
  4283. int startRowIndex = 7; //起始行
  4284. for (int i = 0; i < DeleClientList.Count; i++)
  4285. {
  4286. builder.MoveToCell(0, startRowIndex, 0, 0);
  4287. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4288. builder.MoveToCell(0, startRowIndex, 1, 0);
  4289. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4290. builder.Write(sex);//性别
  4291. builder.MoveToCell(0, startRowIndex, 2, 0);
  4292. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4293. builder.MoveToCell(0, startRowIndex, 3, 0);
  4294. builder.Write(DeleClientList[i].Company);//工作单位
  4295. builder.MoveToCell(0, startRowIndex, 4, 0);
  4296. builder.Write(DeleClientList[i].Job);//职务及级别
  4297. builder.MoveToCell(0, startRowIndex, 5, 0);
  4298. builder.Write("");//人员属性
  4299. builder.MoveToCell(0, startRowIndex, 6, 0);
  4300. builder.Write("");//上次出国时间
  4301. startRowIndex++;
  4302. }
  4303. int nullRow = rowCount - DeleClientList.Count;//空行
  4304. for (int i = 0; i < nullRow; i++)
  4305. {
  4306. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4307. }
  4308. foreach (var key in dic.Keys)
  4309. {
  4310. builder.MoveToBookmark(key);
  4311. builder.Write(dic[key]);
  4312. }
  4313. //模板文件名
  4314. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4315. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4316. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4317. return Ok(JsonView(true, "成功", new { Url = url }));
  4318. }
  4319. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4320. {
  4321. //获取模板
  4322. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4323. //载入模板
  4324. Document doc = new Document(tempPath);
  4325. DocumentBuilder builder = new DocumentBuilder(doc);
  4326. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4327. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4328. dic.Add("Names", Names);
  4329. int accommodationRows = 12, foodandotherRows = 12;
  4330. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4331. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4332. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4333. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4334. int accommodationStartIndex = 6;
  4335. decimal dac1totalPrice = 0.00M;
  4336. foreach (var dac in dac1)
  4337. {
  4338. if (dac.SubTotal == 0)
  4339. {
  4340. continue;
  4341. }
  4342. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4343. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4344. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4345. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4346. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4347. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4348. builder.Write(currency);//币种
  4349. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4350. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4351. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4352. builder.Write("");//人数
  4353. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4354. builder.Write("");//天数
  4355. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4356. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4357. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4358. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4359. builder.Write(rate.ToString("#0.0000"));//汇率
  4360. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4361. decimal rbmPrice = rate * dac.SubTotal;
  4362. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4363. accommodationStartIndex++;
  4364. dac1totalPrice += rbmPrice;
  4365. }
  4366. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4367. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4368. builder.Write("小计");
  4369. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4370. builder.Write(dac1totalPrice.ToString("#0.00"));
  4371. accommodationStartIndex++;
  4372. int nullRow = accommodationRows - dac1.Count;
  4373. //删除空行
  4374. //if (nullRow > 0)
  4375. //{
  4376. // int rowIndex = accommodationStartIndex;
  4377. // for (int i = 0; i < nullRow; i++)
  4378. // {
  4379. // Row row = table1.Rows[rowIndex];
  4380. // row.Remove();
  4381. // rowIndex++;
  4382. // }
  4383. //}
  4384. if (dac2.Count == dac3.Count)//国家 币种 金额
  4385. {
  4386. for (int i = 0; i < dac2.Count; i++)
  4387. {
  4388. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4389. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4390. }
  4391. }
  4392. int foodandotherStartIndex = 19;//
  4393. decimal dac2totalPrice = 0.00M;
  4394. foreach (var dac in dac2)
  4395. {
  4396. if (dac.SubTotal == 0)
  4397. {
  4398. continue;
  4399. }
  4400. //foodandotherStartIndex = 12;
  4401. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4402. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4403. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4404. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4405. builder.Write(currency);//币种
  4406. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4407. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4408. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4409. builder.Write("");//人数
  4410. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4411. builder.Write("");//天数
  4412. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4413. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4414. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4415. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4416. builder.Write(rate.ToString("#0.0000"));//汇率
  4417. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4418. decimal rbmPrice = rate * dac.SubTotal;
  4419. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4420. foodandotherStartIndex++;
  4421. dac2totalPrice += rbmPrice;
  4422. }
  4423. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4424. //删除空行
  4425. if (dac2.Count < foodandotherRows)
  4426. {
  4427. //int nullRow = accommodationRows - dac2.Count;
  4428. //while (table2.Rows.Count > dac2.Count)
  4429. //{
  4430. // table2.Rows.RemoveAt(dac2.Count);
  4431. //}
  4432. }
  4433. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4434. string otherFeeStr = "";
  4435. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4436. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4437. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4438. if (otherFeeStr.Length > 0)
  4439. {
  4440. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4441. otherFeeStr = $"({otherFeeStr})";
  4442. dic.Add("OtherFeeStr", otherFeeStr);
  4443. }
  4444. foreach (var key in dic.Keys)
  4445. {
  4446. builder.MoveToBookmark(key);
  4447. builder.Write(dic[key]);
  4448. }
  4449. //模板文件名
  4450. string strFileName = $"省级单位出(境)经费报销单.docx";
  4451. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4452. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4453. return Ok(JsonView(true, "成功", new { Url = url }));
  4454. }
  4455. }
  4456. else if (dto.ExportType == 3)
  4457. {
  4458. if (dto.SubTypeId == 1) //团组成员名单
  4459. {
  4460. if (DeleClientList.Count < 1)
  4461. {
  4462. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4463. }
  4464. //获取模板
  4465. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4466. //载入模板
  4467. Document doc = new Document(tempPath);
  4468. DocumentBuilder builder = new DocumentBuilder(doc);
  4469. //获取word里所有表格
  4470. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4471. //获取所填表格的序数
  4472. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4473. var rowStart = tableOne.Rows[0]; //获取第1行
  4474. //循环赋值
  4475. for (int i = 0; i < DeleClientList.Count; i++)
  4476. {
  4477. builder.MoveToCell(0, i + 1, 0, 0);
  4478. builder.Write(DeleClientList[i].Name);
  4479. builder.MoveToCell(0, i + 1, 1, 0);
  4480. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4481. builder.Write(sex);
  4482. builder.MoveToCell(0, i + 1, 2, 0);
  4483. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4484. builder.MoveToCell(0, i + 1, 3, 0);
  4485. builder.Write(DeleClientList[i].Company);
  4486. builder.MoveToCell(0, i + 1, 4, 0);
  4487. builder.Write(DeleClientList[i].Job);
  4488. }
  4489. //删除多余行
  4490. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4491. {
  4492. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4493. }
  4494. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4495. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4496. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4497. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4498. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4499. return Ok(JsonView(true, "成功", new { Url = url }));
  4500. }
  4501. }
  4502. return Ok(JsonView(false, "操作失败!"));
  4503. }
  4504. catch (Exception ex)
  4505. {
  4506. return Ok(JsonView(false, ex.Message));
  4507. }
  4508. }
  4509. /// <summary>
  4510. /// 获取三公费用标准city
  4511. /// </summary>
  4512. /// <param name="placeData"></param>
  4513. /// <param name="nationalTravelFeeId"></param>
  4514. /// <returns></returns>
  4515. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4516. {
  4517. string _city = string.Empty;
  4518. if (placeData.Count < 1) return _city;
  4519. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4520. if (data == null) return _city;
  4521. string country = data.Country;
  4522. string city = data.City;
  4523. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4524. else _city = city;
  4525. return _city;
  4526. }
  4527. /// <summary>
  4528. /// 团组模块 - 出入境费用 - 明细表导出
  4529. /// </summary>
  4530. /// <returns></returns>
  4531. [HttpPost]
  4532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4533. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4534. {
  4535. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4536. if (data.Code != 0)
  4537. {
  4538. return Ok(JsonView(false, data.Msg));
  4539. }
  4540. return Ok(JsonView(true, data.Msg, data.Data));
  4541. }
  4542. /// <summary>
  4543. /// 团组模块 - 出入境费用 - 一键清空
  4544. /// </summary>
  4545. /// <returns></returns>
  4546. [HttpPost]
  4547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4548. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4549. {
  4550. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4551. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4552. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4553. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4554. if (_view.Code == 0)
  4555. {
  4556. return Ok(JsonView(true, "操作成功"));
  4557. }
  4558. return Ok(JsonView(false, "操作失败"));
  4559. }
  4560. /// <summary>
  4561. /// 团组模块 - 出入境费用 - 子项删除
  4562. /// </summary>
  4563. /// <returns></returns>
  4564. [HttpPost]
  4565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4566. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4567. {
  4568. try
  4569. {
  4570. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4571. if (data.Code != 0)
  4572. {
  4573. return Ok(JsonView(false, data.Msg));
  4574. }
  4575. return Ok(JsonView(true, "操作成功!", data.Data));
  4576. }
  4577. catch (Exception ex)
  4578. {
  4579. return Ok(JsonView(false, ex.Message));
  4580. }
  4581. }
  4582. /// <summary>
  4583. /// 团组模块 - 出入境国家费用标准 List
  4584. /// </summary>
  4585. /// <returns></returns>
  4586. [HttpPost]
  4587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4588. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4589. {
  4590. try
  4591. {
  4592. Stopwatch sw = new Stopwatch();
  4593. sw.Start();
  4594. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4595. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4596. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4597. Where gntf.Isdel = 0");
  4598. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4599. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4600. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4601. //foreach (var item in nationalTravel)
  4602. //{
  4603. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4604. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4605. // if (otherData != null)
  4606. // {
  4607. // cityData.Remove(otherData);
  4608. // cityData.Add(otherData);
  4609. // }
  4610. // nationalTravelFeeData1.Add(new
  4611. // {
  4612. // Country = item.Country,
  4613. // CityData = cityData
  4614. // });
  4615. //}
  4616. sw.Stop();
  4617. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4618. }
  4619. catch (Exception ex)
  4620. {
  4621. return Ok(JsonView(false, ex.Message));
  4622. throw;
  4623. }
  4624. }
  4625. /// <summary>
  4626. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4627. /// </summary>
  4628. /// <returns></returns>
  4629. [HttpPost]
  4630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4631. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4632. {
  4633. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4634. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4635. List<string> countryData = new List<string>();
  4636. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4637. countryData = countryData.Distinct().ToList();
  4638. List<dynamic> dataSource = new List<dynamic>();
  4639. foreach (var item in countryData)
  4640. {
  4641. List<string> cityData1 = new List<string>();
  4642. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4643. var countryData2 = new
  4644. {
  4645. CountryName = item,
  4646. CityData = cityData1
  4647. };
  4648. dataSource.Add(countryData2);
  4649. }
  4650. return Ok(JsonView(true, "查询成功!", dataSource));
  4651. }
  4652. /// <summary>
  4653. /// 团组模块 - 出入境国家费用标准 Page List
  4654. /// </summary>
  4655. /// <returns></returns>
  4656. [HttpPost]
  4657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4658. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4659. {
  4660. int portId = dto.PortType;
  4661. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4662. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4663. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4664. string whereSql = string.Empty;
  4665. if (!string.IsNullOrEmpty(dto.Country))
  4666. {
  4667. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4668. }
  4669. if (!string.IsNullOrEmpty(dto.City))
  4670. {
  4671. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4672. }
  4673. string pageSql = string.Format(@"Select * From (
  4674. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4675. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4676. From Grp_NationalTravelFee gntf
  4677. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4678. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4679. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4680. RefAsync<int> total = 0;
  4681. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4682. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4683. }
  4684. /// <summary>
  4685. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4686. /// </summary>
  4687. /// <returns></returns>
  4688. [HttpPost]
  4689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4690. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4691. {
  4692. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4693. int portId = dto.PortType;
  4694. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4695. string whereSql = string.Empty;
  4696. if (!string.IsNullOrEmpty(dto.Country))
  4697. {
  4698. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4699. }
  4700. if (!string.IsNullOrEmpty(dto.City))
  4701. {
  4702. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4703. }
  4704. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4705. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4706. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4707. From Grp_NationalTravelFee gntf
  4708. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4709. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4710. Where gntf.Isdel = 0 {0} ", whereSql);
  4711. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4712. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4713. }
  4714. /// <summary>
  4715. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4716. /// </summary>
  4717. /// <returns></returns>
  4718. [HttpPost]
  4719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4720. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4721. {
  4722. try
  4723. {
  4724. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4725. if (data.Code != 0)
  4726. {
  4727. return Ok(JsonView(false, data.Msg));
  4728. }
  4729. return Ok(JsonView(true, "操作成功!", data.Data));
  4730. }
  4731. catch (Exception ex)
  4732. {
  4733. return Ok(JsonView(false, ex.Message));
  4734. }
  4735. }
  4736. /// <summary>
  4737. /// 团组模块 - 出入境国家费用标准 - Del
  4738. /// </summary>
  4739. /// <returns></returns>
  4740. [HttpPost]
  4741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4742. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4743. {
  4744. try
  4745. {
  4746. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4747. {
  4748. Id = dto.Id,
  4749. DeleteUserId = dto.DeleteUserId,
  4750. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4751. IsDel = 1
  4752. };
  4753. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4754. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4755. .WhereColumns(it => new { it.Id })
  4756. .ExecuteCommandAsync();
  4757. if (delStatus <= 0)
  4758. {
  4759. return Ok(JsonView(false, "删除失败!"));
  4760. }
  4761. return Ok(JsonView(true, "操作成功!"));
  4762. }
  4763. catch (Exception ex)
  4764. {
  4765. return Ok(JsonView(false, ex.Message));
  4766. }
  4767. }
  4768. #endregion
  4769. #region 签证费用录入
  4770. /// <summary>
  4771. /// 根据diid查询签证费用列表
  4772. /// </summary>
  4773. /// <param name="dto"></param>
  4774. /// <returns></returns>
  4775. [HttpPost]
  4776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4777. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4778. {
  4779. try
  4780. {
  4781. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4782. if (groupData.Code != 0)
  4783. {
  4784. return Ok(JsonView(false, groupData.Msg));
  4785. }
  4786. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4787. }
  4788. catch (Exception ex)
  4789. {
  4790. return Ok(JsonView(false, ex.Message));
  4791. }
  4792. }
  4793. /// <summary>
  4794. /// 根据签证费用Id查询单条数据及c表数据
  4795. /// </summary>
  4796. /// <param name="dto"></param>
  4797. /// <returns></returns>
  4798. [HttpPost]
  4799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4800. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4801. {
  4802. try
  4803. {
  4804. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4805. if (groupData.Code != 0)
  4806. {
  4807. return Ok(JsonView(false, groupData.Msg));
  4808. }
  4809. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4810. }
  4811. catch (Exception ex)
  4812. {
  4813. return Ok(JsonView(false, ex.Message));
  4814. }
  4815. }
  4816. /// <summary>
  4817. /// 签证费用删除
  4818. /// </summary>
  4819. /// <param name="dto"></param>
  4820. /// <returns></returns>
  4821. [HttpPost]
  4822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4823. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4824. {
  4825. _sqlSugar.BeginTran();
  4826. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4827. if (!res)
  4828. {
  4829. _sqlSugar.RollbackTran();
  4830. return Ok(JsonView(false, "删除失败"));
  4831. }
  4832. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4833. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  4834. .SetColumns(a => new Grp_CreditCardPayment()
  4835. {
  4836. IsDel = 1,
  4837. DeleteUserId = dto.DeleteUserId,
  4838. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4839. }).ExecuteCommand();
  4840. if (resSub < 1)
  4841. {
  4842. _sqlSugar.RollbackTran();
  4843. return Ok(JsonView(false, "删除失败"));
  4844. }
  4845. _sqlSugar.CommitTran();
  4846. return Ok(JsonView(true, "删除成功!"));
  4847. }
  4848. /// <summary>
  4849. /// 签证费用录入下拉框初始化
  4850. /// </summary>
  4851. /// <returns></returns>
  4852. [HttpPost]
  4853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4854. public async Task<IActionResult> VisaPriceAddSelect()
  4855. {
  4856. try
  4857. {
  4858. //支付方式
  4859. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4860. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4861. //币种
  4862. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4863. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4864. //乘客类型
  4865. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4866. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4867. //卡类型
  4868. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4869. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4870. var data = new
  4871. {
  4872. Payment = _Payment,
  4873. CurrencyList = _CurrencyList,
  4874. PassengerType = _PassengerType,
  4875. BankCard = _BankCard
  4876. };
  4877. return Ok(JsonView(true, "查询成功!", data));
  4878. }
  4879. catch (Exception ex)
  4880. {
  4881. return Ok(JsonView(false, "程序错误!"));
  4882. throw;
  4883. }
  4884. }
  4885. /// <summary>
  4886. /// 签证费用录入操作(Status:1.新增,2.修改)
  4887. /// </summary>
  4888. /// <param name="dto"></param>
  4889. /// <returns></returns>
  4890. [HttpPost]
  4891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4892. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  4893. {
  4894. try
  4895. {
  4896. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  4897. if (groupData.Code != 0)
  4898. {
  4899. return Ok(JsonView(false, groupData.Msg));
  4900. }
  4901. #region 应用推送
  4902. try
  4903. {
  4904. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4905. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4906. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4907. }
  4908. catch (Exception ex)
  4909. {
  4910. }
  4911. #endregion
  4912. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4913. }
  4914. catch (Exception ex)
  4915. {
  4916. return Ok(JsonView(false, ex.Message));
  4917. }
  4918. }
  4919. #endregion
  4920. #region op费用录入
  4921. /// <summary>
  4922. /// 根据diid查询op费用列表
  4923. /// </summary>
  4924. /// <param name="dto"></param>
  4925. /// <returns></returns>
  4926. [HttpPost]
  4927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4928. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  4929. {
  4930. try
  4931. {
  4932. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  4933. if (groupData.Code != 0)
  4934. {
  4935. return Ok(JsonView(false, groupData.Msg));
  4936. }
  4937. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4938. }
  4939. catch (Exception ex)
  4940. {
  4941. return Ok(JsonView(false, ex.Message));
  4942. }
  4943. }
  4944. /// <summary>
  4945. /// 根据op费用Id查询单条数据及c表数据
  4946. /// </summary>
  4947. /// <param name="dto"></param>
  4948. /// <returns></returns>
  4949. [HttpPost]
  4950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4951. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  4952. {
  4953. try
  4954. {
  4955. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  4956. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  4957. var data = new
  4958. {
  4959. CarTouristGuideGround = _groupData,
  4960. CreditCardPayment = _creditCardPayment
  4961. };
  4962. return Ok(JsonView(true, "查询成功!", data));
  4963. }
  4964. catch (Exception ex)
  4965. {
  4966. return Ok(JsonView(false, "程序错误!"));
  4967. }
  4968. }
  4969. /// <summary>
  4970. /// op费用删除
  4971. /// </summary>
  4972. /// <param name="dto"></param>
  4973. /// <returns></returns>
  4974. [HttpPost]
  4975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4976. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  4977. {
  4978. try
  4979. {
  4980. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4981. if (!res)
  4982. {
  4983. return Ok(JsonView(false, "删除失败"));
  4984. }
  4985. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  4986. {
  4987. IsDel = 1,
  4988. DeleteUserId = dto.DeleteUserId,
  4989. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4990. }).ExecuteCommandAsync();
  4991. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  4992. {
  4993. IsDel = 1,
  4994. DeleteUserId = dto.DeleteUserId,
  4995. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4996. }).ExecuteCommandAsync();
  4997. return Ok(JsonView(true, "删除成功!"));
  4998. }
  4999. catch (Exception ex)
  5000. {
  5001. return Ok(JsonView(false, "程序错误!"));
  5002. throw;
  5003. }
  5004. }
  5005. /// <summary>
  5006. /// op费用录入操作(Status:1.新增,2.修改)
  5007. /// </summary>
  5008. /// <param name="dto"></param>
  5009. /// <returns></returns>
  5010. [HttpPost]
  5011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5012. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5013. {
  5014. try
  5015. {
  5016. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5017. if (groupData.Code != 0)
  5018. {
  5019. return Ok(JsonView(false, groupData.Msg));
  5020. }
  5021. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5022. }
  5023. catch (Exception ex)
  5024. {
  5025. return Ok(JsonView(false, ex.Message));
  5026. }
  5027. }
  5028. /// <summary>
  5029. /// 填写费用详细页面初始化绑定
  5030. /// </summary>
  5031. /// <param name="dto"></param>
  5032. /// <returns></returns>
  5033. [HttpPost]
  5034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5035. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5036. {
  5037. try
  5038. {
  5039. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5040. if (groupData.Code != 0)
  5041. {
  5042. return Ok(JsonView(false, groupData.Msg));
  5043. }
  5044. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5045. }
  5046. catch (Exception ex)
  5047. {
  5048. return Ok(JsonView(false, ex.Message));
  5049. }
  5050. }
  5051. /// <summary>
  5052. /// 根据op费用Id查询详细数据
  5053. /// </summary>
  5054. /// <param name="dto"></param>
  5055. /// <returns></returns>
  5056. [HttpPost]
  5057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5058. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5059. {
  5060. try
  5061. {
  5062. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5063. if (groupData.Code != 0)
  5064. {
  5065. return Ok(JsonView(false, groupData.Msg));
  5066. }
  5067. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5068. }
  5069. catch (Exception ex)
  5070. {
  5071. return Ok(JsonView(false, ex.Message));
  5072. }
  5073. }
  5074. /// <summary>
  5075. /// OP费用录入填写详情
  5076. /// </summary>
  5077. /// <param name="dto"></param>
  5078. /// <returns></returns>
  5079. [HttpPost]
  5080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5081. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5082. {
  5083. try
  5084. {
  5085. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5086. if (groupData.Code != 0)
  5087. {
  5088. return Ok(JsonView(false, groupData.Msg));
  5089. }
  5090. #region 应用推送
  5091. try
  5092. {
  5093. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5094. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5095. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5096. }
  5097. catch (Exception ex)
  5098. {
  5099. }
  5100. #endregion
  5101. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5102. }
  5103. catch (Exception ex)
  5104. {
  5105. return Ok(JsonView(false, ex.Message));
  5106. }
  5107. }
  5108. /// <summary>
  5109. /// 获取三公详细所有城市
  5110. /// </summary>
  5111. /// <returns></returns>
  5112. [HttpGet]
  5113. public IActionResult OpCarCityResult()
  5114. {
  5115. var jw = JsonView(false);
  5116. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5117. {
  5118. x.Id,
  5119. x.Country,
  5120. x.City,
  5121. }).ToList();
  5122. if (data.Count > 0)
  5123. {
  5124. jw = JsonView(true, "获取成功!", data);
  5125. }
  5126. else
  5127. {
  5128. jw.Msg = "城市数据为空!";
  5129. jw.Data = new string[0];
  5130. }
  5131. return Ok(jw);
  5132. }
  5133. /// <summary>
  5134. /// 导出地接费用明细
  5135. /// </summary>
  5136. /// <param name="dto"></param>
  5137. /// <returns></returns>
  5138. [HttpPost]
  5139. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5140. {
  5141. var jw = JsonView(false);
  5142. if (dto.Diid < 1)
  5143. {
  5144. jw.Msg = "请输入正确的diid!";
  5145. return Ok(jw);
  5146. }
  5147. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x=>x.Id == dto.Diid && x.IsDel == 0);
  5148. if (group == null)
  5149. {
  5150. jw.Msg = "未找到团组信息!";
  5151. return Ok(jw);
  5152. }
  5153. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5154. if (localGuideArr.Count == 0)
  5155. {
  5156. jw.Msg = "该团组暂无地接信息!";
  5157. return Ok(jw);
  5158. }
  5159. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5160. var overspendSoure = new Dictionary<int, int>
  5161. {
  5162. { 91, 982 }, //车
  5163. { 92 , 1059} ,//导游
  5164. { 994 , 1073}, //翻译
  5165. { 988 , 1074 }, //早餐
  5166. { 93 , 1075 }, //午餐
  5167. { 989 , 1076 }, //晚餐
  5168. };
  5169. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5170. foreach (var groupArr in localGroup)
  5171. {
  5172. var keyValue = groupArr.Key;
  5173. if (int.TryParse(keyValue, out int cityid))
  5174. {
  5175. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5176. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5177. }
  5178. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5179. foreach (var item in groupArr)
  5180. {
  5181. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a,b)=> a.SId == b.Id
  5182. ).Where((a,b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a,b)=>
  5183. new Grp_CarTouristGuideGroundReservationsContentExtend
  5184. {
  5185. Count = a.Count,
  5186. CreateTime = a.CreateTime,
  5187. CreateUserId = a.CreateUserId,
  5188. CTGGRId = a.CTGGRId,
  5189. Currency = a.Currency,
  5190. DatePrice = a.DatePrice,
  5191. DeleteTime = a.DeleteTime,
  5192. DeleteUserId = a.DeleteUserId,
  5193. DiId = a.DiId,
  5194. Id = a.Id,
  5195. IsDel = a.IsDel,
  5196. Price = a.Price,
  5197. PriceContent = a.PriceContent,
  5198. Remark = a.Remark,
  5199. SId = a.SId,
  5200. SidName = b.Name,
  5201. Units = a.Units,
  5202. }
  5203. ).ToList();
  5204. if (content.Count > 0)
  5205. {
  5206. contentArr.Add(content);
  5207. }
  5208. }
  5209. //open excel
  5210. //set excel
  5211. //save excel
  5212. try
  5213. {
  5214. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5215. IWorkbook workbook;
  5216. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5217. {
  5218. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5219. }
  5220. else
  5221. {
  5222. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5223. }
  5224. ISheet sheet = workbook.GetSheetAt(0);
  5225. var rowStartIndex = 2;
  5226. var clounmCount = 10;
  5227. var initStyleRow = sheet.GetRow(2);
  5228. var arr = contentArr.SelectMany(x => x).OrderBy(x=>x.SId).ToList();
  5229. //var overspendArrDetail =
  5230. var existsId = new List<CarCompare>();
  5231. var lastElem = arr.Last();
  5232. var thisSid = -1;
  5233. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5234. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5235. {
  5236. Name = "未知币种!",
  5237. Remark = "未知币种!",
  5238. };
  5239. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5240. Action cloneRowFn = () =>
  5241. {
  5242. rowStartIndex++;
  5243. var cloneRow = sheet.CreateRow(rowStartIndex);
  5244. // 复制样式
  5245. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5246. {
  5247. ICell sourceCell = initStyleRow.GetCell(i);
  5248. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5249. // 确保单元格存在样式
  5250. if (sourceCell.CellStyle != null)
  5251. {
  5252. targetCell.CellStyle = sourceCell.CellStyle;
  5253. }
  5254. }
  5255. };
  5256. var mergeRow = () =>
  5257. {
  5258. for (int i = 2; i < sheet.LastRowNum; i++)
  5259. {
  5260. var row = sheet.GetRow(i);
  5261. var cellFirst = row.GetCell(0);
  5262. var thisIndex = i + 1;
  5263. while (thisIndex < sheet.LastRowNum)
  5264. {
  5265. var nextRow = sheet.GetRow(thisIndex);
  5266. var nextCellFirst = nextRow.GetCell(0);
  5267. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5268. {
  5269. thisIndex++;
  5270. }
  5271. else
  5272. {
  5273. break;
  5274. }
  5275. }
  5276. thisIndex--;
  5277. if (thisIndex != i)
  5278. {
  5279. //合并row
  5280. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5281. i, // 起始行索引(0-based)
  5282. thisIndex, // 结束行索引(0-based)
  5283. 0, // 起始列索引(0-based)
  5284. 0 // 结束列索引(0-based)
  5285. );
  5286. sheet.AddMergedRegion(cellRangeAddress);
  5287. i = thisIndex;
  5288. }
  5289. }
  5290. };
  5291. var chaoshiNumber = 0;
  5292. var totalNumber = 0.00M;
  5293. string lastStr = "";
  5294. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5295. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x,b) => new
  5296. {
  5297. b.IsAuditGM,
  5298. x.Id,
  5299. x.Area,
  5300. b.PayPercentage,
  5301. b.PayMoney,
  5302. }).ToList();
  5303. string yesPayment = "", noPayment = "";
  5304. foreach (var item in queryCarArrByCityAndDiid)
  5305. {
  5306. if (item.IsAuditGM == 1)
  5307. {
  5308. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5309. }
  5310. else
  5311. {
  5312. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5313. }
  5314. }
  5315. lastStr = yesPayment + noPayment;
  5316. foreach (var item in arr)
  5317. {
  5318. if (existsId.FirstOrDefault(x=>x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5319. {
  5320. if (thisSid != item.SId)
  5321. {
  5322. if (thisSid == -1)
  5323. {
  5324. thisSid = item.SId;
  5325. }
  5326. else
  5327. {
  5328. //合并小计行
  5329. //创建合并区域的实例
  5330. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5331. rowStartIndex, // 起始行索引(0-based)
  5332. rowStartIndex, // 结束行索引(0-based)
  5333. 0, // 起始列索引(0-based)
  5334. 3 // 结束列索引(0-based)
  5335. );
  5336. sheet.AddMergedRegion(cellRangeAddress);
  5337. var CellStyle = workbook.CreateCellStyle();
  5338. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5339. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5340. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5341. for (int i = 0; i <= clounmCount; i++)
  5342. {
  5343. if (i > 6)
  5344. {
  5345. var CellStyle1 = workbook.CreateCellStyle();
  5346. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5347. IFont Font = workbook.CreateFont(); // 创建字体
  5348. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5349. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5350. CellStyle1.SetFont(Font);
  5351. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5352. }
  5353. else
  5354. {
  5355. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5356. }
  5357. }
  5358. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5359. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x=>x.SId == thisSid).Sum(x=>x.Count * x.Price).ToString("F2"));
  5360. //超时合计
  5361. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5362. //超时数
  5363. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" :chaoshiNumber.ToString());
  5364. //超时合计费用
  5365. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5366. thisSid = item.SId;
  5367. cloneRowFn();
  5368. chaoshiNumber = 0;
  5369. totalNumber = 0;
  5370. }
  5371. }
  5372. IRow row = sheet.GetRow(rowStartIndex);
  5373. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5374. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5375. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null ;
  5376. if (isOpenOverspendSoure)
  5377. {
  5378. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5379. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5380. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5381. }
  5382. for (int i = 0; i <= clounmCount; i++)
  5383. {
  5384. var cell = row.GetCell(i);
  5385. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5386. if (cell == null)
  5387. {
  5388. cell = row.CreateCell(i);
  5389. }
  5390. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5391. fontRed.CloneStyleFrom(cell.CellStyle);
  5392. IFont Font = workbook.CreateFont(); // 创建字体
  5393. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5394. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5395. fontRed.SetFont(Font);
  5396. byte[] rgb = new byte[3] { 255, 242, 204 };
  5397. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5398. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5399. byte[] rgb1 = new byte[3] { 189,215, 238 };
  5400. if (workbook is XSSFWorkbook)
  5401. {
  5402. BackgroundColor255_242_204.FillForegroundColor = 0;
  5403. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5404. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5405. }
  5406. else
  5407. {
  5408. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5409. }
  5410. if (i == 1 || i > 6)
  5411. {
  5412. if (i > 6)
  5413. {
  5414. fontRed.FillForegroundColor = 0;
  5415. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5416. fontRed.FillPattern = FillPattern.SolidForeground;
  5417. }
  5418. cell.CellStyle = fontRed;
  5419. }
  5420. if (i > 2 && i < 7)
  5421. {
  5422. cell.CellStyle = BackgroundColor255_242_204;
  5423. }
  5424. cell.SetCellValue(setCellValue); //写入单元格
  5425. }
  5426. if (overspendSoure.ContainsKey(thisSid)) {
  5427. var overspendId = overspendSoure[thisSid];
  5428. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5429. }
  5430. cloneRowFn();
  5431. existsId.Add(new CarCompare
  5432. {
  5433. DataPrice = item.DatePrice.ObjToDate(),
  5434. Sid = item.SId
  5435. });
  5436. }
  5437. if (item.Equals(lastElem))
  5438. {
  5439. //合并小计行
  5440. //创建合并区域的实例
  5441. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5442. rowStartIndex, // 起始行索引(0-based)
  5443. rowStartIndex, // 结束行索引(0-based)
  5444. 0, // 起始列索引(0-based)
  5445. 3 // 结束列索引(0-based)
  5446. );
  5447. sheet.AddMergedRegion(cellRangeAddress);
  5448. var CellStyle = workbook.CreateCellStyle();
  5449. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5450. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5451. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5452. for (int i = 0; i <= clounmCount; i++)
  5453. {
  5454. if (i > 6)
  5455. {
  5456. var CellStyle1 = workbook.CreateCellStyle();
  5457. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5458. IFont Font = workbook.CreateFont(); // 创建字体
  5459. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5460. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5461. CellStyle1.SetFont(Font);
  5462. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5463. }
  5464. else
  5465. {
  5466. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5467. }
  5468. }
  5469. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5470. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5471. //超时合计
  5472. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5473. //超时数
  5474. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5475. //超时合计费用
  5476. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5477. cloneRowFn();
  5478. // 创建合并区域的实例
  5479. cellRangeAddress = new CellRangeAddress(
  5480. rowStartIndex, // 起始行索引(0-based)
  5481. rowStartIndex, // 结束行索引(0-based)
  5482. 0, // 起始列索引(0-based)
  5483. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5484. );
  5485. // 添加合并区域
  5486. sheet.AddMergedRegion(cellRangeAddress);
  5487. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5488. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5489. }
  5490. }
  5491. mergeRow();
  5492. // 保存修改后的Excel文件到新文件
  5493. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5494. // new FileStream(newFilePath, FileMode.CreateNew)
  5495. using (var stream = new MemoryStream())
  5496. {
  5497. workbook.Write(stream,true);
  5498. stream.Flush();
  5499. stream.Seek(0, SeekOrigin.Begin);
  5500. MemoryStream memoryStream = new MemoryStream();
  5501. stream.CopyTo(memoryStream);
  5502. memoryStream.Seek(0, SeekOrigin.Begin);
  5503. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5504. }
  5505. workbook.Close();
  5506. workbook.Dispose();
  5507. }
  5508. catch (Exception ex)
  5509. {
  5510. jw.Msg = "出现异常!" + ex.Message;
  5511. return Ok(jw);
  5512. }
  5513. }
  5514. if (Zips.Count > 0)
  5515. {
  5516. IOOperatorHelper io = new IOOperatorHelper();
  5517. var byts = io.ConvertZipStream(Zips);
  5518. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5519. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5520. jw = JsonView(true, "success" , new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5521. }
  5522. else
  5523. {
  5524. jw.Msg = "暂无生成文件!";
  5525. }
  5526. return Ok(jw);
  5527. }
  5528. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5529. {
  5530. string outStr = string.Empty;
  5531. switch (i)
  5532. {
  5533. case 0:
  5534. outStr = arr[0].SidName;
  5535. break;
  5536. case 1:
  5537. outStr = arr[0].DataPriceStr;
  5538. break;
  5539. case 2:
  5540. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5541. break;
  5542. case 4:
  5543. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5544. break;
  5545. case 7:
  5546. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5547. {
  5548. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5549. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5550. outStr = arrOverspendSoure.Sum(x=>x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5551. }
  5552. break;
  5553. case 8:
  5554. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5555. {
  5556. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5557. }
  5558. break;
  5559. case 9:
  5560. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5561. {
  5562. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5563. }
  5564. break;
  5565. case 10:
  5566. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5567. {
  5568. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5569. }
  5570. break;
  5571. }
  5572. return outStr;
  5573. }
  5574. #region OP行程单
  5575. /// <summary>
  5576. /// OP行程单初始化
  5577. /// </summary>
  5578. /// <param name="dto"></param>
  5579. /// <returns></returns>
  5580. [HttpPost]
  5581. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5582. {
  5583. var jw = JsonView(false);
  5584. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5585. var group = groupList.First();
  5586. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5587. if (group == null)
  5588. {
  5589. jw.Msg = "暂无团组!";
  5590. return Ok(jw);
  5591. }
  5592. group = groupList.Find(x => x.Id == diid);
  5593. if (group == null)
  5594. {
  5595. jw.Msg = "请输入正确的团组ID!";
  5596. return Ok(jw);
  5597. }
  5598. string city = string.Empty;
  5599. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5600. if (blackCode.Count > 0)
  5601. {
  5602. var black = blackCode.First();
  5603. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5604. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5605. if (blackSp.Length > 0)
  5606. {
  5607. try
  5608. {
  5609. var cityArrCode = new List<string>(20);
  5610. foreach (var item in blackSp)
  5611. {
  5612. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5613. var IndexSelect = itemSp[2];
  5614. var cityArrCodeLength = cityArrCode.Count - 1;
  5615. var startCity = IndexSelect.Substring(0, 3);
  5616. if (cityArrCodeLength > 0)
  5617. {
  5618. var arrEndCity = cityArrCode[cityArrCodeLength];
  5619. if (arrEndCity != startCity)
  5620. {
  5621. cityArrCode.Add(startCity.ToUpper());
  5622. }
  5623. }
  5624. else
  5625. {
  5626. cityArrCode.Add(startCity.ToUpper());
  5627. }
  5628. var endCity = IndexSelect.Substring(3, 3);
  5629. cityArrCode.Add(endCity.ToUpper());
  5630. }
  5631. var cityThree = string.Empty;
  5632. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5633. cityThree = cityThree.TrimEnd(',');
  5634. if (string.IsNullOrWhiteSpace(cityThree))
  5635. {
  5636. throw new
  5637. Exception("error");
  5638. }
  5639. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5640. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5641. foreach (var item in cityArrCode)
  5642. {
  5643. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5644. if (find != null)
  5645. {
  5646. city += find.City + "/";
  5647. }
  5648. else
  5649. {
  5650. city += item + "三字码未收入/";
  5651. }
  5652. }
  5653. city = city.TrimEnd('/');
  5654. }
  5655. catch (Exception e)
  5656. {
  5657. city = "黑屏代码格式不正确!";
  5658. }
  5659. }
  5660. }
  5661. else
  5662. {
  5663. city = "未录入黑屏代码";
  5664. }
  5665. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5666. {
  5667. Date = x.Date,
  5668. Days = x.Days,
  5669. Diffgroup = x.Diffgroup,
  5670. Diid = x.Diid,
  5671. Traffic_First = x.Traffic_First,
  5672. Traffic_Second = x.Traffic_Second,
  5673. Trip = x.Trip,
  5674. WeekDay = x.WeekDay,
  5675. Id = x.Id
  5676. }).ToList();
  5677. jw.Data = new
  5678. {
  5679. groupList = groupList.Select(x => new
  5680. {
  5681. x.Id,
  5682. x.TeamName,
  5683. x.TourCode
  5684. }).ToList(),
  5685. groupInfo = new
  5686. {
  5687. group.VisitDays,
  5688. group.TourCode,
  5689. group.VisitPNumber,
  5690. group.TeamName,
  5691. city
  5692. },
  5693. OpTravelList
  5694. };
  5695. jw.Code = 200;
  5696. jw.Msg = "操作成功!";
  5697. return Ok(jw);
  5698. }
  5699. /// <summary>
  5700. /// 删除团组行程单
  5701. /// </summary>
  5702. /// <returns></returns>
  5703. [HttpPost]
  5704. public IActionResult DelTravel(DelOpTravelDto dto)
  5705. {
  5706. var jw = JsonView(false);
  5707. if (dto.UserId <= 0 || dto.Diid <= 0)
  5708. {
  5709. jw.Msg = "请输入正确的参数!";
  5710. return Ok(jw);
  5711. }
  5712. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5713. .SetColumns(x => new Grp_TravelList
  5714. {
  5715. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5716. DeleteUserId = dto.UserId,
  5717. IsDel = 1,
  5718. }).ExecuteCommand();
  5719. jw = JsonView(true);
  5720. return Ok(jw);
  5721. }
  5722. /// <summary>
  5723. /// 行程单保存
  5724. /// </summary>
  5725. /// <returns></returns>
  5726. [HttpPost]
  5727. public IActionResult TravelSave(TravelSaveDto dto)
  5728. {
  5729. var jw = JsonView(false);
  5730. if (dto.Arr.Count > 0)
  5731. {
  5732. try
  5733. {
  5734. _sqlSugar.BeginTran();
  5735. foreach (var item in dto.Arr)
  5736. {
  5737. if (item.Id == 0)
  5738. {
  5739. throw new Exception("请传入正确的Id");
  5740. }
  5741. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5742. .SetColumns(x => new Grp_TravelList
  5743. {
  5744. Trip = item.Trip
  5745. }).ExecuteCommand();
  5746. }
  5747. _sqlSugar.CommitTran();
  5748. jw = JsonView(true);
  5749. }
  5750. catch (Exception ex)
  5751. {
  5752. _sqlSugar.RollbackTran();
  5753. jw.Msg = "程序异常!" + ex.Message;
  5754. }
  5755. }
  5756. else
  5757. {
  5758. jw.Msg = "请传入正确的参数!";
  5759. }
  5760. return Ok(jw);
  5761. }
  5762. /// <summary>
  5763. /// 导出行程单
  5764. /// </summary>
  5765. /// <param name="dto"></param>
  5766. /// <returns></returns>
  5767. [HttpPost]
  5768. public IActionResult ExportTravel(InitOpTravelDto dto)
  5769. {
  5770. var jw = JsonView(false);
  5771. //数据源
  5772. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5773. int diid = 0;
  5774. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5775. if (Find == null)
  5776. {
  5777. jw.Msg = "请选择正确的团组!";
  5778. return Ok(jw);
  5779. }
  5780. else
  5781. {
  5782. diid = Find.Id;
  5783. }
  5784. DataTable dtBlack = null;
  5785. try
  5786. {
  5787. dtBlack = GetTableByBlackCode(diid);
  5788. }
  5789. catch (Exception)
  5790. {
  5791. jw.Msg = "机票黑屏代码有误!";
  5792. return Ok(jw);
  5793. }
  5794. string CityStr1 = "";
  5795. List<string> countriesList = new List<string>();
  5796. List<string> cityList = new List<string>();
  5797. string countriesIntroduction = "";
  5798. string cityIntroduction = "";
  5799. string timeDifference = "";
  5800. string currExchangeRate = "";
  5801. string txt_itemPrepare = "";
  5802. string txt_specialReminder = "";
  5803. string txt_cGPrecautions = "";
  5804. string txt_yGCG = "";
  5805. string txt_conduct = "";
  5806. string txt_commonEnglish = "";
  5807. if (dtBlack == null && (dtBlack.Rows[0]["Day"] == null || dtBlack.Rows[0]["Day"].ToString() == ""))
  5808. {
  5809. //提示
  5810. //PublicCode.GetAlertMsg(this, GetType(), dt.Rows[dt.Rows.Count - 1]["Error"].ToString());
  5811. }
  5812. else
  5813. {
  5814. //创建三字码示例
  5815. Res_ThreeCode t = new Res_ThreeCode();
  5816. //城市缓存
  5817. string city = "";
  5818. //出访城市
  5819. for (int i = 0; i < dtBlack.Rows.Count; i++)
  5820. {
  5821. if ((i + 1) < dtBlack.Rows.Count && dtBlack.Rows[i]["Three"].ToString() == dtBlack.Rows[i + 1]["Three"].ToString())
  5822. {
  5823. continue;
  5824. }
  5825. if (dtBlack.Rows.Count > 0 && (dtBlack.Rows[i]["Three"].ToString() != null && dtBlack.Rows[i]["Three"].ToString() != ""))
  5826. {
  5827. //出发城市
  5828. string cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(0, 3);
  5829. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5830. if (t != null)
  5831. {
  5832. city = city + "/" + t.City;
  5833. }
  5834. else
  5835. {
  5836. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5837. }
  5838. if (i == dtBlack.Rows.Count - 1)
  5839. {
  5840. //抵达城市
  5841. cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(3, 3);
  5842. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5843. if (t != null)
  5844. {
  5845. city = city + "/" + t.City;
  5846. }
  5847. else
  5848. {
  5849. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5850. }
  5851. }
  5852. }
  5853. }
  5854. if (city != "" && city != null)
  5855. {
  5856. string[] cityStr2 = city.Split('/');
  5857. string[] strs = cityStr2.Distinct().ToArray(); ;
  5858. string str = "";
  5859. foreach (var s in strs)
  5860. {
  5861. str += s + "/";
  5862. }
  5863. str = str.TrimStart('/');
  5864. str = str.TrimEnd('/');
  5865. //lblTourCity.Text = "去重前:" + city.TrimStart('/') + "\n 去重后:" + str;
  5866. CityStr1 = city.TrimStart('/');
  5867. }
  5868. // 行程repeater
  5869. if (GetByDiid(diid).Count > 0)
  5870. {
  5871. _travelList = GetByDiid(diid).Where(x => x.Issel == 1 && x.IsDel == 0).ToList();
  5872. }
  5873. else
  5874. {
  5875. //生成该时间段日期
  5876. List<string> timeList = GetTimeListByDataTable(dtBlack);
  5877. if (timeList != null)
  5878. {
  5879. string[] str = new string[timeList.Count];
  5880. //rpData.DataSource = str;
  5881. //rpData.DataBind();
  5882. }
  5883. }
  5884. }
  5885. //创建数据源Table
  5886. DataTable dtSource = new DataTable();
  5887. dtSource.Columns.Add("Days", typeof(string));
  5888. dtSource.Columns.Add("Date", typeof(string));
  5889. dtSource.Columns.Add("Week", typeof(string));
  5890. dtSource.Columns.Add("Traffic", typeof(string));
  5891. dtSource.Columns.Add("Trip", typeof(string));
  5892. //获取数据,放到datatable
  5893. foreach (var item in _travelList)
  5894. {
  5895. DataRow dr = dtSource.NewRow();
  5896. dr["Days"] = item.Days;
  5897. dr["Date"] = item.Date;
  5898. dr["Week"] = item.WeekDay;
  5899. dr["Traffic"] = item.Traffic_First
  5900. + "\r\n"
  5901. + item.Traffic_Second;
  5902. if (item.Trip.Replace("(此地区为黄热病地区,请注意打疫苗)", "").Length < 15)
  5903. {
  5904. item.Trip += @"
  5905. 08:00 早餐于酒店;
  5906. 09:00 公务活动;
  5907. 10:30 公务活动;
  5908. 12:00 午餐于当地餐厅;
  5909. 14:00 公务活动;
  5910. 16:00 公务活动;
  5911. 18:00 晚餐于当地餐厅;
  5912. 19:00 入住酒店休息;";
  5913. }
  5914. dr["Trip"] = item.Trip;
  5915. dtSource.Rows.Add(dr);
  5916. }
  5917. //lblTeamName.Text = di.TourCode;
  5918. //lblVisitDays.Text = di.VisitDays.ToString();
  5919. //lblVisitDays2.Text = di.VisitDays.ToString();
  5920. //lblPNumber.Text = di.VisitPNumber.ToString();
  5921. //lblGroup.Text = di.TeamName.ToString();
  5922. Dictionary<string, string> dic = new Dictionary<string, string>();
  5923. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  5924. dic.Add("City", CityStr1);
  5925. dic.Add("Days", Find.VisitDays.ToString());
  5926. dic.Add("DeleCode", Find.TourCode);
  5927. dic.Add("Pnum", Find.VisitPNumber.ToString());
  5928. dic.Add("Pnum2", Find.VisitPNumber.ToString());
  5929. List<Crm_DeleClient> leader = GetByDiidClient(Find.Id);
  5930. if (leader != null && leader.Count > 0)
  5931. {
  5932. dic.Add("Leader", GetByDiidClient(Find.Id)[0].LastName + GetByDiidClient(Find.Id)[0].FirstName);
  5933. }
  5934. else
  5935. {
  5936. dic.Add("Leader", "");
  5937. }
  5938. dic.Add("Pnum3", Find.VisitPNumber.ToString());
  5939. int UserId = 253;
  5940. dic.Add("OP", "");
  5941. dic.Add("OPTel", "");
  5942. //dic.Add("OP", "OP姓名");
  5943. //dic.Add("OPTel", "OP手机号码");
  5944. string countriesStr = "";
  5945. countriesList.ForEach(s => countriesStr += s + "、");
  5946. countriesStr = countriesStr.TrimEnd('、');
  5947. string cityStr = "";
  5948. cityList.ForEach(s => cityStr += s + "、");
  5949. cityStr = cityStr.TrimEnd('、');
  5950. //下方数据
  5951. dic.Add("selCountries", countriesStr == null ? "" : countriesStr);
  5952. dic.Add("selCity", cityStr == null ? "" : cityStr);
  5953. dic.Add("countriesIntroduction", countriesIntroduction == null ? "" : countriesIntroduction);
  5954. dic.Add("CityIntroduction", cityIntroduction == null ? "" : cityIntroduction);
  5955. dic.Add("timeDifference", timeDifference == null ? "" : timeDifference);
  5956. dic.Add("currExchangeRate", currExchangeRate == null ? "" : currExchangeRate);
  5957. dic.Add("temperature", "");
  5958. dic.Add("txt_itemPrepare", txt_itemPrepare == null ? "" : txt_itemPrepare);
  5959. dic.Add("txt_specialReminder", txt_specialReminder == null ? "" : txt_specialReminder);
  5960. dic.Add("txt_cGPrecautions", txt_cGPrecautions == null ? "" : txt_cGPrecautions);
  5961. dic.Add("txt_yGCG", txt_yGCG == null ? "" : txt_yGCG);
  5962. dic.Add("txt_conduct", txt_conduct == null ? "" : txt_conduct);
  5963. dic.Add("txt_commonEnglish", txt_commonEnglish == null ? "" : txt_commonEnglish);
  5964. //模板路径
  5965. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  5966. //载入模板
  5967. Document doc = null;
  5968. DocumentBuilder builder = null;
  5969. try
  5970. {
  5971. //载入模板
  5972. doc = new Document(tempPath);
  5973. builder = new DocumentBuilder(doc);
  5974. }
  5975. catch (Exception)
  5976. {
  5977. jw.Msg = "模板位置不存在!";
  5978. return Ok(jw);
  5979. }
  5980. foreach (var key in dic.Keys)
  5981. {
  5982. Bookmark bookmark = doc.Range.Bookmarks[key];
  5983. if (bookmark != null)
  5984. {
  5985. builder.MoveToBookmark(key);
  5986. builder.Write(dic[key]);
  5987. }
  5988. }
  5989. //获取word里所有表格
  5990. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5991. //获取所填表格的序数
  5992. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5993. try
  5994. {
  5995. //循环赋值
  5996. for (int i = 0; i < dtSource.Rows.Count; i++)
  5997. {
  5998. builder.MoveToCell(0, i + 1, 0, 0);
  5999. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6000. builder.MoveToCell(0, i + 1, 1, 0);
  6001. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6002. builder.MoveToCell(0, i + 1, 2, 0);
  6003. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6004. var trip = dtSource.Rows[i]["Trip"].ToString();
  6005. builder.MoveToCell(0, i + 1, 3, 0);
  6006. builder.Write(trip);
  6007. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6008. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6009. // 获取特定索引的段落
  6010. Paragraph paragraph = (Paragraph)paragraphs[0];
  6011. Run run = paragraph.Runs[0];
  6012. Aspose.Words.Font font = run.Font;
  6013. font.Name = "黑体";
  6014. //设置双休红色
  6015. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6016. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6017. paragraph = (Paragraph)paragraphs[1];
  6018. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6019. {
  6020. run = paragraph.Runs[0];
  6021. font = run.Font;
  6022. font.Color = Color.Red;
  6023. }
  6024. }
  6025. }
  6026. catch (Exception ex)
  6027. {
  6028. }
  6029. //删除多余行
  6030. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6031. {
  6032. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6033. }
  6034. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6035. if (!Directory.Exists(savePath))
  6036. {
  6037. try
  6038. {
  6039. Directory.CreateDirectory(savePath);
  6040. }
  6041. catch
  6042. {
  6043. }
  6044. }
  6045. string path = savePath + Find.TeamName + "出访日程.docx";
  6046. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程.docx";
  6047. try
  6048. {
  6049. doc.Save(path, Aspose.Words.SaveFormat.Doc);
  6050. jw = JsonView(true, "导出成功", ftpPath);
  6051. }
  6052. catch (Exception)
  6053. {
  6054. jw = JsonView(false);
  6055. }
  6056. return Ok(jw);
  6057. }
  6058. /// <summary>
  6059. ///根据机票黑屏代码整理DataTable
  6060. /// </summary>
  6061. /// <param name="diid"></param>
  6062. /// <returns></returns>
  6063. DataTable GetTableByBlackCode(int diid)
  6064. {
  6065. //黑屏代码信息
  6066. List<Air_TicketBlackCode> listcode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  6067. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  6068. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  6069. DataTable dt = new DataTable();
  6070. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  6071. dt.Columns.Add("Date", typeof(string));//起飞日期
  6072. dt.Columns.Add("Three", typeof(string));//三字码
  6073. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  6074. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  6075. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  6076. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  6077. dt.Columns.Add("AirModel", typeof(string)); //机型
  6078. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  6079. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  6080. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  6081. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  6082. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  6083. //判断是否录入黑屏代码
  6084. if (listcode.Count() == 0 || listcode == null)
  6085. {
  6086. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  6087. }
  6088. else
  6089. {
  6090. //读取单段黑屏代码
  6091. for (int i = 0; i < listcode.Count; i++)
  6092. {
  6093. //去除序号
  6094. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  6095. //去除多余空格,方法一Linq扩展方法
  6096. CodeList = CodeList.Where(str => str != "").ToArray();
  6097. CodeList = CodeList.Where(str => str != " ").ToArray();
  6098. //年
  6099. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  6100. //读取单条黑屏代码
  6101. for (int j = 0; j < CodeList.Count(); j++)
  6102. {
  6103. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  6104. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  6105. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6106. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6107. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6108. //去除多余空格
  6109. Info = Info.Where(str => str != "").ToArray();
  6110. Info = Info.Where(str => str != " ").ToArray();
  6111. //判断黑屏代码是否正确拆分; 理应拆成9段
  6112. if (Info.Count() < 9)
  6113. {
  6114. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  6115. }
  6116. else
  6117. {
  6118. try
  6119. {
  6120. //月
  6121. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  6122. //日
  6123. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  6124. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  6125. if (j > 0)
  6126. {
  6127. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6128. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6129. Temp = Temp.Where(str => str != "").ToArray();
  6130. Temp = Temp.Where(str => str != " ").ToArray();
  6131. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  6132. // 如果相邻月份之差小于0,则证明次一条年份需+1
  6133. if (month - monthTemp < 0)
  6134. {
  6135. year = year + 1;
  6136. }
  6137. //如果相邻代码三字码不顶真,提醒
  6138. string FootThree = Temp[2].Substring(3, 3);
  6139. string HeadThree = Info[2].Substring(0, 3);
  6140. if (FootThree != HeadThree)
  6141. {
  6142. //DelegationInfoService s = new DelegationInfoService();
  6143. //UsersService us = new UsersService();
  6144. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  6145. //77 行程
  6146. List<Grp_GroupsTaskAssignment> list2 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  6147. foreach (var temp in list2)
  6148. {
  6149. //if (temp.UId != 21)
  6150. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6151. // "黑屏代码提醒",
  6152. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6153. }
  6154. //85 机票预订
  6155. List<Grp_GroupsTaskAssignment> list6 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  6156. foreach (var temp in list6)
  6157. {
  6158. //if (temp.UId != 21)
  6159. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6160. // "黑屏代码提醒",
  6161. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6162. }
  6163. }
  6164. }
  6165. #endregion
  6166. #region 判断到达日期是否需要加1
  6167. if (Info[4].Contains("+"))
  6168. {
  6169. //日期+1
  6170. day = day + 1;
  6171. //判断是否进入下一月
  6172. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  6173. {
  6174. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  6175. month = month + 1;
  6176. //判断是否进入下一年
  6177. if (month > 12)
  6178. {
  6179. month = month - 12;
  6180. year = year + 1;
  6181. }
  6182. }
  6183. //月份整理格式
  6184. string monthTemp = month.ToString();
  6185. if (month < 10)
  6186. {
  6187. monthTemp = "0" + monthTemp;
  6188. }
  6189. //日期整理格式
  6190. string daytemp = day.ToString();
  6191. if (day < 10)
  6192. {
  6193. daytemp = "0" + daytemp;
  6194. }
  6195. string temp = Info[4].Split('+')[0];
  6196. //添加起飞数据
  6197. dt.Rows.Add(Info[0],
  6198. Info[1],
  6199. Info[2],
  6200. Info[3],
  6201. temp,
  6202. Info[5],
  6203. Info[6],
  6204. Info[7],
  6205. Info[8],
  6206. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  6207. year + "-" + monthTemp + "-" + daytemp,
  6208. "",
  6209. "0");
  6210. //加1天,添加到达数据
  6211. dt.Rows.Add(Info[0],
  6212. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  6213. Info[2],
  6214. Info[3],
  6215. temp,
  6216. Info[5],
  6217. Info[6],
  6218. Info[7],
  6219. Info[8],
  6220. year + "-" + monthTemp + "-" + daytemp,
  6221. year + "-" + monthTemp + "-" + daytemp,
  6222. "",
  6223. "1");
  6224. }
  6225. else
  6226. {
  6227. //月份整理格式
  6228. string monthTemp = month.ToString();
  6229. if (month < 10)
  6230. {
  6231. monthTemp = "0" + monthTemp;
  6232. }
  6233. //日期整理格式
  6234. string daytemp = day.ToString();
  6235. if (day < 10)
  6236. {
  6237. daytemp = "0" + daytemp;
  6238. }
  6239. dt.Rows.Add(Info[0],
  6240. Info[1],
  6241. Info[2],
  6242. Info[3],
  6243. Info[4],
  6244. Info[5],
  6245. Info[6],
  6246. Info[7],
  6247. Info[8],
  6248. year + "-" + monthTemp + "-" + daytemp,
  6249. year + "-" + monthTemp + "-" + daytemp,
  6250. "",
  6251. "0");
  6252. }
  6253. #endregion
  6254. }
  6255. catch (Exception ex)
  6256. {
  6257. string exstr = ex.Message.ToString();
  6258. }
  6259. }
  6260. }
  6261. //排序
  6262. dt.DefaultView.Sort = "Day asc";
  6263. dt = dt.DefaultView.ToTable();
  6264. }
  6265. }
  6266. return dt;
  6267. }
  6268. /// <summary>
  6269. /// 根据团组编号查询信息
  6270. /// </summary>
  6271. /// <returns>返回空或者对象信息</returns>
  6272. List<Grp_TravelList> GetByDiid(int Diid)
  6273. {
  6274. //调用获取单个对象的方法
  6275. return _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == Diid && x.IsDel == 0).ToList();
  6276. }
  6277. /// <summary>
  6278. /// 20210816
  6279. /// 根据datatable生成某一时间段的日期
  6280. /// </summary>
  6281. /// <param name="dt">黑屏代码生成的datatable</param>
  6282. /// <returns></returns>
  6283. List<string> GetTimeListByDataTable(DataTable dt)
  6284. {
  6285. if (dt.Rows[0]["Day"].ToString() != "")
  6286. {
  6287. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  6288. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  6289. List<string> timeList = new List<string>();
  6290. while (datestart <= dateend)
  6291. {
  6292. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  6293. datestart = datestart.AddDays(1);
  6294. }
  6295. return timeList;
  6296. }
  6297. return null;
  6298. }
  6299. /// <summary>
  6300. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6301. /// </summary>
  6302. /// <param name="num"></param>
  6303. /// <returns></returns>
  6304. string GetNum(string num)
  6305. {
  6306. string str = "";
  6307. switch (num)
  6308. {
  6309. case "1":
  6310. str = "一";
  6311. break;
  6312. case "2":
  6313. str = "二";
  6314. break;
  6315. case "3":
  6316. str = "三";
  6317. break;
  6318. case "4":
  6319. str = "四";
  6320. break;
  6321. case "5":
  6322. str = "五";
  6323. break;
  6324. case "6":
  6325. str = "六";
  6326. break;
  6327. case "7":
  6328. str = "七";
  6329. break;
  6330. case "8":
  6331. str = "八";
  6332. break;
  6333. case "9":
  6334. str = "九";
  6335. break;
  6336. case "10":
  6337. str = "十";
  6338. break;
  6339. case "11":
  6340. str = "十一";
  6341. break;
  6342. case "12":
  6343. str = "十二";
  6344. break;
  6345. case "一":
  6346. str = "1";
  6347. break;
  6348. case "二":
  6349. str = "2";
  6350. break;
  6351. case "三":
  6352. str = "3";
  6353. break;
  6354. case "四":
  6355. str = "4";
  6356. break;
  6357. case "五":
  6358. str = "5";
  6359. break;
  6360. case "六":
  6361. str = "6";
  6362. break;
  6363. case "七":
  6364. str = "7";
  6365. break;
  6366. case "八":
  6367. str = "8";
  6368. break;
  6369. case "九":
  6370. str = "9";
  6371. break;
  6372. case "十":
  6373. str = "10";
  6374. break;
  6375. case "十一":
  6376. str = "11";
  6377. break;
  6378. case "十二":
  6379. str = "12";
  6380. break;
  6381. }
  6382. return str;
  6383. }
  6384. List<Crm_DeleClient> GetByDiidClient(int DIID)
  6385. {
  6386. return _sqlSugar.Queryable<Crm_DeleClient>().Where(x => x.DiId == DIID && x.IsDel == 0).ToList();
  6387. }
  6388. /// <summary>
  6389. /// 根据星期,月份的缩写,转换成数字或者全称
  6390. /// 根据币种中文名称返回币种代码
  6391. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  6392. /// 20210903贾文滔
  6393. /// </summary>
  6394. /// <param name="startDate"></param>
  6395. /// <param name="endDate"></param>
  6396. /// <returns></returns>
  6397. string GetLonger(string temp)
  6398. {
  6399. string str = "";
  6400. switch (temp.ToUpper())
  6401. {
  6402. case "美元":
  6403. str = "USD";
  6404. break;
  6405. case "日元":
  6406. str = "JPY";
  6407. break;
  6408. case "英镑":
  6409. str = "GBP";
  6410. break;
  6411. case "欧元":
  6412. str = "EUR";
  6413. break;
  6414. case "港币":
  6415. str = "HKD";
  6416. break;
  6417. case "MO":
  6418. str = "星期一";
  6419. break;
  6420. case "TU":
  6421. str = "星期二";
  6422. break;
  6423. case "WE":
  6424. str = "星期三";
  6425. break;
  6426. case "TH":
  6427. str = "星期四";
  6428. break;
  6429. case "FR":
  6430. str = "星期五";
  6431. break;
  6432. case "SA":
  6433. str = "星期六";
  6434. break;
  6435. case "SU":
  6436. str = "星期天";
  6437. break;
  6438. case "JAN":
  6439. str = "01";
  6440. break;
  6441. case "FEB":
  6442. str = "02";
  6443. break;
  6444. case "MAR":
  6445. str = "03";
  6446. break;
  6447. case "APR":
  6448. str = "04";
  6449. break;
  6450. case "MAY":
  6451. str = "05";
  6452. break;
  6453. case "JUN":
  6454. str = "06";
  6455. break;
  6456. case "JUL":
  6457. str = "07";
  6458. break;
  6459. case "AUG":
  6460. str = "08";
  6461. break;
  6462. case "SEP":
  6463. str = "09";
  6464. break;
  6465. case "OCT":
  6466. str = "10";
  6467. break;
  6468. case "NOV":
  6469. str = "11";
  6470. break;
  6471. case "DEC":
  6472. str = "12";
  6473. break;
  6474. case "MONDAY":
  6475. str = "星期一";
  6476. break;
  6477. case "TUESDAY":
  6478. str = "星期二";
  6479. break;
  6480. case "WEDNESDAY":
  6481. str = "星期三";
  6482. break;
  6483. case "THURSDAY":
  6484. str = "星期四";
  6485. break;
  6486. case "FRIDAY":
  6487. str = "星期五";
  6488. break;
  6489. case "SATURDAY":
  6490. str = "星期六";
  6491. break;
  6492. case "SUNDAY":
  6493. str = "星期日";
  6494. break;
  6495. case "01":
  6496. str = "JAN";
  6497. break;
  6498. case "02":
  6499. str = "FEB";
  6500. break;
  6501. case "03":
  6502. str = "MAR";
  6503. break;
  6504. case "04":
  6505. str = "APR";
  6506. break;
  6507. case "05":
  6508. str = "MAY";
  6509. break;
  6510. case "06":
  6511. str = "JUN";
  6512. break;
  6513. case "07":
  6514. str = "JUL";
  6515. break;
  6516. case "08":
  6517. str = "AUG";
  6518. break;
  6519. case "09":
  6520. str = "SEP";
  6521. break;
  6522. case "10":
  6523. str = "OCT";
  6524. break;
  6525. case "11":
  6526. str = "NOV";
  6527. break;
  6528. case "12":
  6529. str = "DEC";
  6530. break;
  6531. case "2":
  6532. str = "空客A";
  6533. break;
  6534. case "3":
  6535. str = "空客A";
  6536. break;
  6537. case "7":
  6538. str = "波音";
  6539. break;
  6540. }
  6541. return str;
  6542. }
  6543. /// <summary>
  6544. /// 根据月份返回天数
  6545. /// </summary>
  6546. /// <param name="temp"></param>
  6547. /// <returns></returns>
  6548. string GetDaysByMonth(string Month, int year)
  6549. {
  6550. string str = "";
  6551. //判断是否是闰年
  6552. if (DateTime.IsLeapYear(year) == false)
  6553. {
  6554. switch (Month.ToUpper())
  6555. {
  6556. case "JAN":
  6557. str = "31";
  6558. break;
  6559. case "FEB":
  6560. str = "28";
  6561. break;
  6562. case "MAR":
  6563. str = "31";
  6564. break;
  6565. case "APR":
  6566. str = "30";
  6567. break;
  6568. case "MAY":
  6569. str = "31";
  6570. break;
  6571. case "JUN":
  6572. str = "30";
  6573. break;
  6574. case "JUL":
  6575. str = "31";
  6576. break;
  6577. case "AUG":
  6578. str = "31";
  6579. break;
  6580. case "SEP":
  6581. str = "30";
  6582. break;
  6583. case "OCT":
  6584. str = "31";
  6585. break;
  6586. case "NOV":
  6587. str = "30";
  6588. break;
  6589. case "DEC":
  6590. str = "31";
  6591. break;
  6592. case "01":
  6593. str = "31";
  6594. break;
  6595. case "02":
  6596. str = "28";
  6597. break;
  6598. case "03":
  6599. str = "31";
  6600. break;
  6601. case "04":
  6602. str = "30";
  6603. break;
  6604. case "05":
  6605. str = "31";
  6606. break;
  6607. case "06":
  6608. str = "30";
  6609. break;
  6610. case "07":
  6611. str = "31";
  6612. break;
  6613. case "08":
  6614. str = "31";
  6615. break;
  6616. case "09":
  6617. str = "30";
  6618. break;
  6619. case "10":
  6620. str = "31";
  6621. break;
  6622. case "11":
  6623. str = "30";
  6624. break;
  6625. case "12":
  6626. str = "31";
  6627. break;
  6628. }
  6629. }
  6630. else
  6631. {
  6632. switch (Month.ToUpper())
  6633. {
  6634. case "JAN":
  6635. str = "31";
  6636. break;
  6637. case "FEB":
  6638. str = "29";
  6639. break;
  6640. case "MAR":
  6641. str = "31";
  6642. break;
  6643. case "APR":
  6644. str = "30";
  6645. break;
  6646. case "MAY":
  6647. str = "31";
  6648. break;
  6649. case "JUN":
  6650. str = "30";
  6651. break;
  6652. case "JUL":
  6653. str = "31";
  6654. break;
  6655. case "AUG":
  6656. str = "31";
  6657. break;
  6658. case "SEP":
  6659. str = "30";
  6660. break;
  6661. case "OCT":
  6662. str = "31";
  6663. break;
  6664. case "NOV":
  6665. str = "30";
  6666. break;
  6667. case "DEC":
  6668. str = "31";
  6669. break;
  6670. case "01":
  6671. str = "31";
  6672. break;
  6673. case "02":
  6674. str = "29";
  6675. break;
  6676. case "03":
  6677. str = "31";
  6678. break;
  6679. case "04":
  6680. str = "30";
  6681. break;
  6682. case "05":
  6683. str = "31";
  6684. break;
  6685. case "06":
  6686. str = "30";
  6687. break;
  6688. case "07":
  6689. str = "31";
  6690. break;
  6691. case "08":
  6692. str = "31";
  6693. break;
  6694. case "09":
  6695. str = "30";
  6696. break;
  6697. case "10":
  6698. str = "31";
  6699. break;
  6700. case "11":
  6701. str = "30";
  6702. break;
  6703. case "12":
  6704. str = "31";
  6705. break;
  6706. }
  6707. }
  6708. return str;
  6709. }
  6710. #endregion
  6711. #endregion
  6712. #region 团组成本
  6713. /// <summary>
  6714. /// 团组成本数据初始化
  6715. /// </summary>
  6716. /// <param name="dto"></param>
  6717. /// <returns></returns>
  6718. [HttpPost]
  6719. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6720. {
  6721. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6722. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6723. WHEN COUNT(*) >= 0 THEN 'True'
  6724. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6725. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6726. ").ToList(); //团组列表
  6727. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6728. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6729. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6730. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6731. if (groupinfoValue != null)
  6732. {
  6733. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6734. var spArr = new string[1] { countryArr };
  6735. if (countryArr.Contains("|"))
  6736. {
  6737. spArr = countryArr.Split("|");
  6738. }
  6739. else if (countryArr.Contains("、"))
  6740. {
  6741. spArr = countryArr.Split("、");
  6742. }
  6743. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6744. {
  6745. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6746. if (dbQueryCountry != null)
  6747. {
  6748. visaCountryInfoArr.Add(dbQueryCountry);
  6749. }
  6750. }
  6751. }
  6752. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6753. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6754. var create = _GroupCostRepository.
  6755. CreateGroupCostByBlackCode(dto.Diid);
  6756. if (groupCost.Count == 0 && create.Code == 0)
  6757. {
  6758. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6759. }
  6760. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6761. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6762. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6763. groupCostMap = groupCostMap.Select(x =>
  6764. {
  6765. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6766. {
  6767. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6768. }
  6769. return x;
  6770. }).ToList();
  6771. //GroupCostParameter.Add(new
  6772. // Grp_GroupCostParameter());
  6773. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6774. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0 ).Count() > 0;
  6775. return Ok(JsonView(new
  6776. {
  6777. groupList,
  6778. groupInfo,
  6779. groupChecks,
  6780. groupCost = groupCostMap,
  6781. hotelNumber,
  6782. GroupCostParameter = GroupCostParameterMap,
  6783. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6784. {
  6785. x.VisaCountry,
  6786. x.VisaPrice,
  6787. x.Id,
  6788. }).ToList(),
  6789. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6790. blackCodeIsTrue = create.Code == 0 ? true : false,
  6791. hotelIsTrue = hotelIsTrue,
  6792. })) ;
  6793. }
  6794. /// <summary>
  6795. /// 团组成本信息保存
  6796. /// </summary>
  6797. /// <param name="dto"></param>
  6798. /// <returns></returns>
  6799. [HttpPost]
  6800. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6801. {
  6802. if (dto.Diid <= 0 || dto.Userid <= 0)
  6803. {
  6804. return Ok(JsonView(false));
  6805. }
  6806. JsonView jw = null;
  6807. bool isTrue = false;
  6808. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6809. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6810. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6811. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6812. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6813. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6814. try
  6815. {
  6816. _sqlSugar.BeginTran();
  6817. isTrue = await _GroupCostRepository.
  6818. SaveGroupCostList(Grp_groups, dto.Diid,dto.Userid); //列表
  6819. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6820. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6821. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6822. _sqlSugar.CommitTran();
  6823. jw = JsonView(true, "保存成功!", isTrue);
  6824. }
  6825. catch (Exception)
  6826. {
  6827. _sqlSugar.RollbackTran();
  6828. jw = JsonView(false);
  6829. }
  6830. return Ok(jw);
  6831. }
  6832. /// <summary>
  6833. /// 司兼导数据
  6834. /// </summary>
  6835. /// <param name="dto"></param>
  6836. /// <returns></returns>
  6837. [HttpPost]
  6838. public IActionResult GetCarGuides(CarGuidesDto dto)
  6839. {
  6840. JsonView jw = null;
  6841. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6842. jw = JsonView(true, "获取成功!", Data);
  6843. return Ok(jw);
  6844. }
  6845. /// <summary>
  6846. /// 导游数据
  6847. /// </summary>
  6848. /// <param name="dto"></param>
  6849. /// <returns></returns>
  6850. [HttpPost]
  6851. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6852. {
  6853. JsonView jw = null;
  6854. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6855. // 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
  6856. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6857. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6858. jw = JsonView(true, "获取成功!", Data);
  6859. return Ok(jw);
  6860. }
  6861. /// <summary>
  6862. /// 成本车数据
  6863. /// </summary>
  6864. /// <param name="dto"></param>
  6865. /// <returns></returns>
  6866. [HttpPost]
  6867. public IActionResult GetCarInfo(CarGuidesDto dto)
  6868. {
  6869. JsonView jw = null;
  6870. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6871. jw = JsonView(true, "获取成功!", Data);
  6872. return Ok(jw);
  6873. }
  6874. /// <summary>
  6875. /// 景点数据
  6876. /// </summary>
  6877. /// <param name="dto"></param>
  6878. /// <returns></returns>
  6879. [HttpPost]
  6880. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6881. {
  6882. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6883. return Ok(JsonView(true, "获取成功!", Data));
  6884. }
  6885. /// <summary>
  6886. /// 成本通知
  6887. /// </summary>
  6888. /// <param name="dto"></param>
  6889. /// <returns></returns>
  6890. [HttpPost]
  6891. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6892. {
  6893. if (dto.Diid < 0)
  6894. {
  6895. return Ok(JsonView(false));
  6896. }
  6897. JsonView jw = null;
  6898. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6899. if (GroupCostParameter != null)
  6900. {
  6901. int IsShare = 0;
  6902. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6903. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6904. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6905. string msg = string.Empty;
  6906. if (isTrue)
  6907. {
  6908. if (IsShare == 0)
  6909. {
  6910. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6911. }
  6912. else
  6913. {
  6914. #region 企微通知对应岗位用户
  6915. try
  6916. {
  6917. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6918. }
  6919. catch (Exception ex)
  6920. {
  6921. }
  6922. #endregion
  6923. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6924. }
  6925. jw = JsonView(isTrue, msg, new { IsShare });
  6926. }
  6927. else
  6928. {
  6929. msg = "修改失败!";
  6930. jw = JsonView(isTrue, msg);
  6931. }
  6932. }
  6933. else
  6934. {
  6935. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6936. }
  6937. return Ok(jw);
  6938. }
  6939. /// <summary>
  6940. /// 导出收款账单
  6941. /// </summary>
  6942. /// <param name="dto"></param>
  6943. /// <returns></returns>
  6944. [HttpPost]
  6945. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6946. {
  6947. if (dto.Diid == 0)
  6948. {
  6949. return Ok(JsonView(false, "请传递团组id"));
  6950. }
  6951. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6952. if (deleInfo.Code != 0)
  6953. {
  6954. return Ok(JsonView(false, "团组信息查询失败!"));
  6955. }
  6956. var di = deleInfo.Data as DelegationInfoWebView;
  6957. if (di != null)
  6958. {
  6959. //文件名
  6960. string strFileName = di.TeamName + "-收款账单.doc";
  6961. //获取模板
  6962. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6963. //载入模板
  6964. Document doc = new Document(tmppath);
  6965. decimal TotalPrice = 0.00M;
  6966. string itemStr = string.Empty;
  6967. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6968. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6969. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6970. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6971. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6972. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6973. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6974. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6975. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6976. foreach (var cost in groupCostType)
  6977. {
  6978. var List = cost.ToList();
  6979. if (cost.Key == "A")
  6980. {
  6981. foreach (var ListItem in List)
  6982. {
  6983. if (ListItem.number > 0)
  6984. {
  6985. if (ListItem.code.Contains("TBR"))
  6986. {
  6987. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6988. }
  6989. else
  6990. {
  6991. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6992. }
  6993. TotalPrice += (ListItem.number * ListItem.price);
  6994. }
  6995. }
  6996. }
  6997. else
  6998. {
  6999. itemStr = itemStr.Insert(0, "A段\r\n");
  7000. itemStr += "B段\r\n";
  7001. foreach (var ListItem in List)
  7002. {
  7003. if (ListItem.number > 0)
  7004. {
  7005. if (ListItem.code.Contains("TBR"))
  7006. {
  7007. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7008. }
  7009. else
  7010. {
  7011. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7012. }
  7013. TotalPrice += (ListItem.number * ListItem.price);
  7014. }
  7015. }
  7016. }
  7017. }
  7018. #region 替换Word模板书签内容
  7019. Dictionary<string, string> marks = new Dictionary<string, string>();
  7020. marks.Add("To", di.ClientUnit);//付款方
  7021. marks.Add("ToTel", di.TellPhone);//付款方电话
  7022. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7023. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7024. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7025. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7026. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7027. marks.Add("WeChat", "WeChat");//微信号 di.WeChat;
  7028. marks.Add("PayItemContent", itemStr);//详细信息
  7029. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7030. #endregion
  7031. ////注
  7032. //if (doc.Range.Bookmarks["Attention"] != null)
  7033. //{
  7034. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7035. // mark.Text = frList[0].Attention;
  7036. //}
  7037. foreach (var item in marks.Keys)
  7038. {
  7039. if (doc.Range.Bookmarks[item] != null)
  7040. {
  7041. Bookmark mark = doc.Range.Bookmarks[item];
  7042. mark.Text = marks[item];
  7043. }
  7044. }
  7045. byte[] bytes = null;
  7046. using (MemoryStream stream = new MemoryStream())
  7047. {
  7048. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7049. bytes = stream.ToArray();
  7050. }
  7051. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7052. return Ok(JsonView(true, "", new
  7053. {
  7054. Data = bytes,
  7055. strFileName,
  7056. }));
  7057. }
  7058. else
  7059. {
  7060. return Ok(JsonView(false, "团组信息不存在!"));
  7061. }
  7062. }
  7063. /// <summary>
  7064. /// 导出团组成本
  7065. /// </summary>
  7066. /// <param name="dto"></param>
  7067. /// <returns></returns>
  7068. [HttpPost]
  7069. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7070. {
  7071. var jw = JsonView(false);
  7072. if (dto.Diid == 0)
  7073. {
  7074. return Ok(JsonView(false, "请传递团组id"));
  7075. }
  7076. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7077. if (deleInfo.Code != 0)
  7078. {
  7079. return Ok(JsonView(false, "团组信息查询失败!"));
  7080. }
  7081. var di = deleInfo.Data as DelegationInfoWebView;
  7082. if (di == null)
  7083. {
  7084. return Ok(JsonView(false, "团组信息查询失败!"));
  7085. }
  7086. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7087. WorkbookDesigner designer = new WorkbookDesigner();
  7088. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7089. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7090. for (int i = 0; i < List_GC.Count; i++)
  7091. {
  7092. GroupCost_Excel gc = new GroupCost_Excel();
  7093. gc.Id = List_GC[i].Id;
  7094. gc.Diid = List_GC[i].Diid.ToString();
  7095. gc.DAY = List_GC[i].DAY;
  7096. string week = "";
  7097. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7098. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7099. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7100. gc.ITIN = List_GC[i].ITIN;
  7101. gc.CarType = List_GC[i].CarType;
  7102. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7103. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7104. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7105. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7106. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7107. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7108. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7109. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7110. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7111. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7112. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7113. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7114. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7115. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7116. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7117. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7118. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7119. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7120. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7121. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7122. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7123. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7124. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7125. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7126. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7127. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7128. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7129. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7130. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7131. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7132. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7133. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7134. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7135. List_GC1.Add(gc);
  7136. }
  7137. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7138. dt.TableName = "TB";
  7139. //报表标题等不用dt的值
  7140. designer.SetDataSource("TeamName", dto.title.TeamName);
  7141. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7142. designer.SetDataSource("Tax", dto.title.Tax);
  7143. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7144. designer.SetDataSource("Currency", dto.title.Currency);
  7145. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7146. designer.SetDataSource("Rate", dto.title.Rate);
  7147. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7148. var Aparams = hotels.Find(x => x.Type == "Default");
  7149. if (Aparams == null)
  7150. {
  7151. return Ok(jw);
  7152. }
  7153. //酒店数量
  7154. var txtSGRNumber = Aparams.SGR.ToString();
  7155. var txtTBRNumber = Aparams.TBR.ToString();
  7156. var txtJSESNumber = Aparams.JSES.ToString();
  7157. var txtSUITENumbe = Aparams.SUITE.ToString();
  7158. if (dto.costType == "B")
  7159. {
  7160. Aparams = hotels.Find(x => x.Type == "A");
  7161. var Bparams = hotels.Find(x => x.Type == "B");
  7162. if (Aparams == null || Bparams == null)
  7163. {
  7164. return Ok(jw);
  7165. }
  7166. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7167. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7168. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7169. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7170. }
  7171. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7172. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7173. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7174. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7175. var ws = designer.Workbook.Worksheets[0];
  7176. int Row = List_GC.Count;
  7177. int startIndex = 11;
  7178. int HideRows = 0;
  7179. List<int> hideRowsList = new List<int>();
  7180. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7181. #region A段left数据
  7182. var left = dto.leftInfo.Find(x => x.Type == "A");
  7183. if (left == null)
  7184. {
  7185. return Ok(jw);
  7186. }
  7187. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7188. if (leftBindData != null)
  7189. {
  7190. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7191. designer.SetDataSource("VisaRS", leftBindData.rs);
  7192. designer.SetDataSource("VisaXS", leftBindData.xs);
  7193. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7194. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7195. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7196. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7197. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7198. }
  7199. else
  7200. {
  7201. hideRowsList.Add(Row + startIndex + HideRows);
  7202. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7203. }
  7204. HideRows += 2;
  7205. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7206. if (leftBindData != null)
  7207. {
  7208. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7209. designer.SetDataSource("BXRS", leftBindData.rs);
  7210. designer.SetDataSource("BXXS", leftBindData.xs);
  7211. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7212. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7213. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7214. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7215. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7216. }
  7217. else
  7218. {
  7219. hideRowsList.Add(Row + startIndex + HideRows);
  7220. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7221. }
  7222. HideRows += 2;
  7223. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7224. if (leftBindData != null)
  7225. {
  7226. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7227. designer.SetDataSource("HSRS", leftBindData.rs);
  7228. designer.SetDataSource("HSXS", leftBindData.xs);
  7229. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7230. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7231. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7232. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7233. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7234. }
  7235. else
  7236. {
  7237. hideRowsList.Add(Row + startIndex + HideRows);
  7238. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7239. }
  7240. HideRows += 2;
  7241. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7242. if (leftBindData != null)
  7243. {
  7244. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7245. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7246. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7247. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7248. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7249. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7250. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7251. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7252. }
  7253. else
  7254. {
  7255. hideRowsList.Add(Row + startIndex + HideRows);
  7256. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7257. }
  7258. HideRows += 2;
  7259. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7260. if (leftBindData != null)
  7261. {
  7262. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7263. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7264. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7265. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7266. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7267. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7268. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7269. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7270. }
  7271. else
  7272. {
  7273. hideRowsList.Add(Row + startIndex + HideRows);
  7274. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7275. }
  7276. HideRows += 2;
  7277. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7278. if (leftBindData != null)
  7279. {
  7280. ////TBR
  7281. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7282. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7283. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7284. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7285. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7286. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7287. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7288. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7289. }
  7290. else
  7291. {
  7292. hideRowsList.Add(Row + startIndex + HideRows);
  7293. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7294. }
  7295. HideRows += 2;
  7296. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7297. if (leftBindData != null)
  7298. {
  7299. ////SGR
  7300. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7301. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7302. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7303. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7304. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7305. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7306. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7307. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7308. }
  7309. else
  7310. {
  7311. hideRowsList.Add(Row + startIndex + HideRows);
  7312. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7313. }
  7314. HideRows += 2;
  7315. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7316. if (leftBindData != null)
  7317. {
  7318. ////JS/ES
  7319. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7320. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7321. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7322. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7323. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7324. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7325. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7326. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7327. }
  7328. else
  7329. {
  7330. hideRowsList.Add(Row + startIndex + HideRows);
  7331. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7332. }
  7333. HideRows += 2;
  7334. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7335. if (leftBindData != null)
  7336. {
  7337. ////SUITE
  7338. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7339. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7340. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7341. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7342. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7343. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7344. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7345. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7346. }
  7347. else
  7348. {
  7349. hideRowsList.Add(Row + startIndex + HideRows);
  7350. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7351. }
  7352. HideRows += 2;
  7353. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7354. if (leftBindData != null)
  7355. {
  7356. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7357. designer.SetDataSource("DJRS", leftBindData.rs);
  7358. designer.SetDataSource("DJXS", leftBindData.xs);
  7359. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7360. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7361. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7362. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7363. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7364. }
  7365. else
  7366. {
  7367. hideRowsList.Add(Row + startIndex + HideRows);
  7368. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7369. }
  7370. HideRows += 2;
  7371. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7372. if (leftBindData != null)
  7373. {
  7374. designer.SetDataSource("HCPCB", leftBindData.cb);
  7375. designer.SetDataSource("HCPRS", leftBindData.rs);
  7376. designer.SetDataSource("HCPXS", leftBindData.xs);
  7377. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7378. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7379. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7380. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7381. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7382. }
  7383. else
  7384. {
  7385. hideRowsList.Add(Row + startIndex + HideRows);
  7386. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7387. }
  7388. HideRows += 2;
  7389. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7390. if (leftBindData != null)
  7391. {
  7392. designer.SetDataSource("CPCB", leftBindData.cb);
  7393. designer.SetDataSource("CPRS", leftBindData.rs);
  7394. designer.SetDataSource("CPXS", leftBindData.xs);
  7395. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7396. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7397. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7398. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7399. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7400. }
  7401. else
  7402. {
  7403. hideRowsList.Add(Row + startIndex + HideRows);
  7404. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7405. }
  7406. HideRows += 2;
  7407. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7408. if (leftBindData != null)
  7409. {
  7410. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7411. designer.SetDataSource("GWRS", leftBindData.rs);
  7412. designer.SetDataSource("GWXS", leftBindData.xs);
  7413. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7414. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7415. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7416. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7417. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7418. }
  7419. else
  7420. {
  7421. hideRowsList.Add(Row + startIndex + HideRows);
  7422. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7423. }
  7424. HideRows += 2;
  7425. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7426. if (leftBindData != null)
  7427. {
  7428. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7429. designer.SetDataSource("LYJRS", leftBindData.rs);
  7430. designer.SetDataSource("LYJXS", leftBindData.xs);
  7431. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7432. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7433. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7434. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7435. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7436. }
  7437. else
  7438. {
  7439. hideRowsList.Add(Row + startIndex + HideRows);
  7440. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7441. }
  7442. #endregion
  7443. #region A段Right信息
  7444. var right = dto.rightInfo.Find(x => x.Type == "A");
  7445. if (right == null)
  7446. {
  7447. return Ok(jw);
  7448. }
  7449. HideRows += 4;
  7450. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7451. if (rightBindData != null)
  7452. {
  7453. //经济舱 + 双人间 TBR
  7454. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7455. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7456. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7457. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7458. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7459. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7460. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7461. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7462. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7463. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7464. }
  7465. else
  7466. {
  7467. hideRowsList.Add(Row + startIndex + HideRows);
  7468. }
  7469. HideRows += 2;
  7470. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7471. if (rightBindData != null)
  7472. {
  7473. //经济舱 + 单人间 SGR
  7474. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7475. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7476. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7477. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7478. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7479. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7480. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7481. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7482. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7483. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7484. }
  7485. else
  7486. {
  7487. hideRowsList.Add(Row + startIndex + HideRows);
  7488. }
  7489. HideRows += 2;
  7490. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7491. if (rightBindData != null)
  7492. {
  7493. //公务舱 + 单人间 SGR
  7494. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7495. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7496. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7497. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7498. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7499. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7500. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7501. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7502. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7503. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7504. }
  7505. else
  7506. {
  7507. hideRowsList.Add(Row + startIndex + HideRows);
  7508. }
  7509. HideRows += 2;
  7510. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7511. if (rightBindData != null)
  7512. {
  7513. //公务舱 + 小套房 JSES
  7514. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7515. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7516. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7517. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7518. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7519. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7520. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7521. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7522. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7523. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7524. }
  7525. else
  7526. {
  7527. hideRowsList.Add(Row + startIndex + HideRows);
  7528. }
  7529. HideRows += 2;
  7530. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7531. if (rightBindData != null)
  7532. {
  7533. //公务舱 + 小套房 JSES
  7534. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7535. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7536. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7537. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7538. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7539. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7540. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7541. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7542. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7543. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7544. }
  7545. else
  7546. {
  7547. hideRowsList.Add(Row + startIndex + HideRows);
  7548. }
  7549. HideRows += 2;
  7550. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7551. if (rightBindData != null)
  7552. {
  7553. //经济舱 + 大套房
  7554. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7555. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7556. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7557. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7558. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7559. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7560. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7561. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7562. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7563. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7564. }
  7565. else
  7566. {
  7567. hideRowsList.Add(Row + startIndex + HideRows);
  7568. }
  7569. #endregion
  7570. #region B段标题清空
  7571. designer.SetDataSource("CostBDRCB", "");
  7572. designer.SetDataSource("CostBRS", "");
  7573. designer.SetDataSource("CostBXS", "");
  7574. designer.SetDataSource("CostBZCB", "");
  7575. designer.SetDataSource("CostBDRBJ", "");
  7576. designer.SetDataSource("CostBZBJ", "");
  7577. designer.SetDataSource("CostBDRLR", "");
  7578. designer.SetDataSource("CostBZLR", "");
  7579. designer.SetDataSource("CostBDRCBOM", "");
  7580. designer.SetDataSource("CostBRSOM", "");
  7581. designer.SetDataSource("CostBZCBOM", "");
  7582. designer.SetDataSource("CostBDRBJOM", "");
  7583. designer.SetDataSource("CostBZBJOM", "");
  7584. designer.SetDataSource("CostBDRLROM", "");
  7585. designer.SetDataSource("CostBZLROM", "");
  7586. #endregion
  7587. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7588. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7589. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7590. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7591. designer.SetDataSource("DJName", "地接(CNY)");
  7592. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7593. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7594. designer.SetDataSource("GWName", "公务(CNY)");
  7595. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7596. designer.SetDataSource("LYJName", "零用金(CNY)");
  7597. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7598. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7599. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7600. designer.SetDataSource("BXName", "保险(CNY)");
  7601. designer.SetDataSource("VisaName", "签证(CNY)");
  7602. #region B段基本数据
  7603. if (dto.costType == "B")
  7604. {
  7605. left = dto.leftInfo.Find(x => x.Type == "B");
  7606. if (left == null)
  7607. {
  7608. return Ok(jw);
  7609. }
  7610. #region B段left数据
  7611. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7612. if (leftBindData != null)
  7613. {
  7614. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7615. designer.SetDataSource("BHSRS", leftBindData.rs);
  7616. designer.SetDataSource("BHSXS", leftBindData.xs);
  7617. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7618. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7619. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7620. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7621. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7622. }
  7623. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7624. if (leftBindData != null)
  7625. {
  7626. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7627. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7628. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7629. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7630. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7631. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7632. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7633. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7634. }
  7635. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7636. if (leftBindData != null)
  7637. {
  7638. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7639. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7640. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7641. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7642. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7643. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7644. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7645. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7646. }
  7647. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7648. if (leftBindData != null)
  7649. {
  7650. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7651. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7652. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7653. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7654. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7655. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7656. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7657. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7658. }
  7659. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7660. if (leftBindData != null)
  7661. {
  7662. designer.SetDataSource("BCPCB", leftBindData.cb);
  7663. designer.SetDataSource("BCPRS", leftBindData.rs);
  7664. designer.SetDataSource("BCPXS", leftBindData.xs);
  7665. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7666. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7667. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7668. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7669. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7670. }
  7671. //TBR
  7672. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7673. if (leftBindData != null)
  7674. {
  7675. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7676. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7677. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7678. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7679. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7680. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7681. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7682. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7683. }
  7684. //SGR
  7685. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7686. if (leftBindData != null)
  7687. {
  7688. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7689. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7690. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7691. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7692. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7693. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7694. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7695. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7696. }
  7697. //JS/ES
  7698. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7699. if (leftBindData != null)
  7700. {
  7701. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7702. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7703. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7704. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7705. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7706. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7707. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7708. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7709. }
  7710. //SUITE
  7711. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7712. if (leftBindData != null)
  7713. {
  7714. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7715. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7716. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7717. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7718. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7719. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7720. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7721. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7722. }
  7723. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7724. if (leftBindData != null)
  7725. {
  7726. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7727. designer.SetDataSource("BDJRS", leftBindData.rs);
  7728. designer.SetDataSource("BDJXS", leftBindData.xs);
  7729. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7730. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7731. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7732. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7733. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7734. }
  7735. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7736. if (leftBindData != null)
  7737. {
  7738. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7739. designer.SetDataSource("BGWRS", leftBindData.rs);
  7740. designer.SetDataSource("BGWXS", leftBindData.xs);
  7741. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7742. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7743. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7744. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7745. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7746. }
  7747. #region 优化方案
  7748. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7749. //excelBind.Add("零用金", new {
  7750. //cb="",
  7751. //rs="",
  7752. //xs ="",
  7753. //zcb = "",
  7754. //});
  7755. #endregion
  7756. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7757. if (leftBindData != null)
  7758. {
  7759. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7760. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7761. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7762. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7763. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7764. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7765. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7766. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7767. }
  7768. #endregion
  7769. #region B段Right信息
  7770. right = dto.rightInfo.Find(x => x.Type == "B");
  7771. if (right == null)
  7772. {
  7773. return Ok(jw);
  7774. }
  7775. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7776. if (rightBindData != null)
  7777. {
  7778. //经济舱 + 双人间 TBR
  7779. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7780. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7781. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7782. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7783. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7784. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7785. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7786. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7787. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7788. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7789. }
  7790. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7791. if (rightBindData != null)
  7792. {
  7793. //经济舱 + 单人间 SGR
  7794. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7795. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7796. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7797. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7798. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7799. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7800. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7801. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7802. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7803. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7804. }
  7805. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7806. if (rightBindData != null)
  7807. {
  7808. //公务舱 + 单人间 SGR
  7809. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7810. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7811. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7812. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7813. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7814. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7815. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7816. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7817. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7818. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7819. }
  7820. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7821. if (rightBindData != null)
  7822. {
  7823. //公务舱 + 小套房 JSES
  7824. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7825. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7826. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7827. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7828. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7829. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7830. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7831. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7832. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7833. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7834. }
  7835. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7836. if (rightBindData != null)
  7837. {
  7838. //公务舱 + 小套房 JSES
  7839. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7840. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7841. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7842. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7843. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7844. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7845. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7846. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7847. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7848. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7849. }
  7850. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7851. if (rightBindData != null)
  7852. {
  7853. //经济舱 + 大套房
  7854. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7855. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7856. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7857. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7858. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7859. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7860. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7861. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7862. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7863. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7864. }
  7865. #endregion
  7866. #region 标题
  7867. designer.SetDataSource("CostBDRCB", "单人成本");
  7868. designer.SetDataSource("CostBRS", "人数");
  7869. designer.SetDataSource("CostBXS", "系数");
  7870. designer.SetDataSource("CostBZCB", "总成本");
  7871. designer.SetDataSource("CostBDRBJ", "单人报价");
  7872. designer.SetDataSource("CostBZBJ", "总报价");
  7873. designer.SetDataSource("CostBDRLR", "单人利润");
  7874. designer.SetDataSource("CostBZLR", "总利润");
  7875. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7876. designer.SetDataSource("CostBRSOM", "人数");
  7877. designer.SetDataSource("CostBZCBOM", "总成本");
  7878. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7879. designer.SetDataSource("CostBZBJOM", "总报价");
  7880. designer.SetDataSource("CostBDRLROM", "单人利润");
  7881. designer.SetDataSource("CostBZLROM", "总利润");
  7882. #endregion
  7883. }
  7884. #endregion
  7885. designer.SetDataSource("TzZCB2", TzZCB2);
  7886. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7887. designer.SetDataSource("TzZLR2", TzZLR2);
  7888. string[] dataSourceKeys = new string[]
  7889. {
  7890. "VF",
  7891. "TGS",
  7892. "TGOF",
  7893. "TGM",
  7894. "TGA",
  7895. "TGTF",
  7896. "TGEF",
  7897. "CFM",
  7898. "CFOF",
  7899. "B",
  7900. "L",
  7901. "D",
  7902. "TBR",
  7903. "SGR",
  7904. "JSES",
  7905. "Suite",
  7906. "TV",
  7907. "1L",
  7908. "IF",
  7909. "EF",
  7910. "BRF",
  7911. "TE",
  7912. "TGT",
  7913. "DRVT",
  7914. "PC",
  7915. "TLF",
  7916. "ECT"
  7917. };
  7918. foreach (var item in dataSourceKeys)
  7919. {
  7920. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7921. if (find != null)
  7922. {
  7923. designer.SetDataSource(item, find.text);
  7924. }
  7925. else
  7926. {
  7927. designer.SetDataSource(item, 0);
  7928. }
  7929. }
  7930. designer.SetDataSource(dt);
  7931. //根据数据源处理生成报表内容
  7932. designer.Process();
  7933. designer.Workbook.Worksheets[0].Name = "清单";
  7934. Worksheet sheet = designer.Workbook.Worksheets[0];
  7935. foreach (var Rowindex in hideRowsList)
  7936. {
  7937. ws.Cells.HideRows(Rowindex, 2);
  7938. }
  7939. byte[] bytes = null;
  7940. string strFileName = di.TeamName + "-团组-成本.xls";
  7941. using (MemoryStream stream = new MemoryStream())
  7942. {
  7943. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7944. bytes = stream.ToArray();
  7945. }
  7946. return Ok(JsonView(true, "", new
  7947. {
  7948. Data = bytes,
  7949. strFileName,
  7950. }));
  7951. }
  7952. /// <summary>
  7953. /// 导出客户报表
  7954. /// </summary>
  7955. /// <returns></returns>
  7956. [HttpPost]
  7957. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7958. {
  7959. var jw = JsonView(false);
  7960. if (dto.Diid == 0)
  7961. {
  7962. return Ok(JsonView(false, "请传递团组id"));
  7963. }
  7964. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7965. if (deleInfo.Code != 0)
  7966. {
  7967. return Ok(JsonView(false, "团组信息查询失败!"));
  7968. }
  7969. var di = deleInfo.Data as DelegationInfoWebView;
  7970. if (di == null)
  7971. {
  7972. return Ok(JsonView(false, "团组信息查询失败!"));
  7973. }
  7974. //文件名
  7975. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  7976. //获取模板
  7977. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  7978. //载入模板
  7979. Document doc = new Document(tmppath);
  7980. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  7981. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  7982. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  7983. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  7984. var AParameter = ParameterList.Find(x => x.CostType == "A");
  7985. var BParameter = ParameterList.Find(x => x.CostType == "B");
  7986. if (AParameter == null)
  7987. {
  7988. return Ok(JsonView(false, "系数不存在!"));
  7989. }
  7990. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  7991. , TzAirDesc, TzZCost;
  7992. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  7993. = TzAirDesc = TzZCost = string.Empty;
  7994. TzNumber = AParameter.CostTypenumber.ToString();
  7995. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  7996. CarGuides1 = dto.CarGuides1;
  7997. Meal = dto.Meal;
  7998. SubsidizedMeals = dto.SubsidizedMeals;
  7999. NightRepair = dto.NightRepair;
  8000. AttractionsTickets = dto.AttractionsTickets;
  8001. MiscellaneousFees = dto.MiscellaneousFees;
  8002. ATip = dto.ATip;
  8003. TzHotelDesc = "";
  8004. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8005. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8006. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8007. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8008. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8009. TzAirDesc = "";
  8010. TzZCost = dto.TzZCost;
  8011. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8012. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8013. var index = 1;
  8014. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8015. foreach (var item in TzHotelDescArr)
  8016. {
  8017. if (AinfoArr != null)
  8018. {
  8019. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8020. if (Ainfo != null)
  8021. {
  8022. if (int.Parse(Ainfo.rs) <= 0)
  8023. {
  8024. continue;
  8025. }
  8026. var hotelText = string.Empty;
  8027. switch (item)
  8028. {
  8029. case "SGR":
  8030. hotelText = "单人间";
  8031. break;
  8032. case "JSES":
  8033. hotelText = "小套房";
  8034. break;
  8035. case "SUITE":
  8036. hotelText = "套房";
  8037. break;
  8038. case "TBR":
  8039. hotelText = "双人间";
  8040. break;
  8041. }
  8042. if (item != "TBR")
  8043. {
  8044. 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";
  8045. }
  8046. else
  8047. {
  8048. 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";
  8049. }
  8050. index++;
  8051. }
  8052. }
  8053. }
  8054. index = 1;
  8055. foreach (var item in TzAirDescArr)
  8056. {
  8057. if (AinfoArr != null)
  8058. {
  8059. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8060. if (Ainfo != null)
  8061. {
  8062. if (int.Parse(Ainfo.rs) <= 0)
  8063. {
  8064. continue;
  8065. }
  8066. 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";
  8067. index++;
  8068. }
  8069. }
  8070. }
  8071. if (dto.costType == "B")
  8072. {
  8073. if (BParameter == null)
  8074. {
  8075. return Ok(JsonView(false, "B段系数不存在!"));
  8076. }
  8077. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8078. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8079. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8080. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8081. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8082. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8083. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8084. foreach (var item in TzHotelDescArr)
  8085. {
  8086. if (AinfoArr != null)
  8087. {
  8088. TzHotelDesc += "B段信息 \r\n";
  8089. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8090. if (Ainfo != null)
  8091. {
  8092. if (int.Parse(Ainfo.rs) <= 0)
  8093. {
  8094. continue;
  8095. }
  8096. var hotelText = string.Empty;
  8097. switch (item)
  8098. {
  8099. case "SGR":
  8100. hotelText = "单人间";
  8101. break;
  8102. case "JSES":
  8103. hotelText = "小套房";
  8104. break;
  8105. case "SUITE":
  8106. hotelText = "套房";
  8107. break;
  8108. case "TBR":
  8109. hotelText = "双人间";
  8110. break;
  8111. }
  8112. if (item != "TBR")
  8113. {
  8114. 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";
  8115. }
  8116. else
  8117. {
  8118. 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";
  8119. }
  8120. index++;
  8121. }
  8122. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8123. }
  8124. }
  8125. index = 1;
  8126. foreach (var item in TzAirDescArr)
  8127. {
  8128. if (AinfoArr != null)
  8129. {
  8130. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8131. if (Ainfo != null)
  8132. {
  8133. if (int.Parse(Ainfo.rs) <= 0)
  8134. {
  8135. continue;
  8136. }
  8137. 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";
  8138. index++;
  8139. }
  8140. }
  8141. }
  8142. }
  8143. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8144. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8145. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8146. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8147. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8148. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8149. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8150. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8151. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8152. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8153. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8154. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8155. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8156. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8157. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8158. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8159. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8160. DickeyValue.Add("TzZCost", TzZCost);
  8161. foreach (var key in DickeyValue.Keys)
  8162. {
  8163. if (doc.Range.Bookmarks[key] != null)
  8164. {
  8165. Bookmark mark = doc.Range.Bookmarks[key];
  8166. mark.Text = DickeyValue[key];
  8167. }
  8168. }
  8169. byte[] bytes = null;
  8170. string strFileName = di.TeamName + "-客户报价.doc";
  8171. using (MemoryStream stream = new MemoryStream())
  8172. {
  8173. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8174. bytes = stream.ToArray();
  8175. }
  8176. return Ok(JsonView(true, "", new
  8177. {
  8178. Data = bytes,
  8179. strFileName,
  8180. }));
  8181. }
  8182. /// <summary>
  8183. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8184. /// </summary>
  8185. /// <param name="dto"></param>
  8186. /// <returns></returns>
  8187. [HttpPost]
  8188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8189. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8190. {
  8191. try
  8192. {
  8193. #region 参数验证
  8194. if (dto.DiId < 0)
  8195. {
  8196. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8197. }
  8198. List<int> cTableIds = new List<int>() {
  8199. 76 ,//酒店预订
  8200. 77 ,//行程
  8201. 79 ,//车/导游地接
  8202. 80 ,//签证
  8203. 81 ,//邀请/公务活
  8204. 82 ,//团组客户保险
  8205. 85 ,//机票预订
  8206. 98 ,//其他款项
  8207. 285 ,//收款退还
  8208. 751 ,//酒店早餐
  8209. 1015 // 超支费用
  8210. };
  8211. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8212. {
  8213. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8214. }
  8215. #endregion
  8216. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8217. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8218. if (_GroupCostParameters.Count <= 0)
  8219. {
  8220. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8221. }
  8222. if (_GroupCostParameters[0].IsShare == 0)
  8223. {
  8224. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8225. }
  8226. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8227. //处理date为空问题
  8228. if (_GroupCosts.Count > 0)
  8229. {
  8230. for (int i = 0; i < _GroupCosts.Count; i++)
  8231. {
  8232. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8233. {
  8234. if (i > 0)
  8235. {
  8236. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8237. }
  8238. }
  8239. }
  8240. }
  8241. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8242. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8243. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8244. string currCode = "";
  8245. #region currCode 验证
  8246. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8247. if (isInt)
  8248. {
  8249. var currData = currDatas.Find(it => it.Id == intCurrency);
  8250. if (currData != null)
  8251. {
  8252. currCode = currData.Name;
  8253. }
  8254. }
  8255. else
  8256. {
  8257. currCode = _GroupCostParameters[0].Currency.Trim();
  8258. }
  8259. #endregion
  8260. //op,酒店单段模式存储
  8261. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8262. {
  8263. CurrencyCode = currCode,
  8264. Rate = _GroupCostParameters[0].Rate,
  8265. CostType = _GroupCostParameters[0].CostType,
  8266. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8267. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8268. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8269. };
  8270. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8271. if (_GroupCostParameters.Count == 2)
  8272. {
  8273. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8274. }
  8275. foreach (var item in _GroupCostParameters)
  8276. {
  8277. decimal _rate = 1;
  8278. decimal _rate1 = item.Rate;
  8279. decimal _scale = 1;
  8280. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8281. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8282. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8283. //if (userInfo != null)
  8284. //{
  8285. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8286. // {
  8287. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8288. // {
  8289. // _scale = 1.00M;
  8290. // }
  8291. // }
  8292. //}
  8293. #endregion
  8294. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8295. {
  8296. CurrencyCode = currCode,
  8297. Rate = _rate1,
  8298. CostType = item.CostType,
  8299. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8300. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8301. CostTypeNumber = item.CostTypenumber
  8302. };
  8303. if (_GroupCostParameters.Count > 1)
  8304. {
  8305. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8306. }
  8307. else
  8308. {
  8309. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8310. }
  8311. if (dto.CTable == 79)//
  8312. {
  8313. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8314. modulePromptInfo.TotalCost = item.DJCB;
  8315. }
  8316. List<string> costTypes = new List<string>() { "A", "B" };
  8317. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8318. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8319. if (_GroupCostsDuplicates.Count() == 1)
  8320. {
  8321. _GroupCostsTypeData = _GroupCosts;
  8322. }
  8323. else
  8324. {
  8325. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8326. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8327. }
  8328. /*
  8329. * 76 酒店预订
  8330. * 77 行程
  8331. * 79 车/导游地接
  8332. * 80 签证
  8333. * 81 邀请/公务活动
  8334. * 82 团组客户保险
  8335. * 85 机票预订
  8336. * 98 其他款项
  8337. * 285 收款退还
  8338. * 751 酒店早餐
  8339. * 1015 超支费用
  8340. */
  8341. switch (dto.CTable)
  8342. {
  8343. case 76: // 酒店预订
  8344. _ModuleSubPromptInfo.AddRange(
  8345. _GroupCostsTypeData.Select(it => new
  8346. {
  8347. it.DAY,
  8348. it.Date,
  8349. it.ACCON,
  8350. it.ITIN,
  8351. it.SGR,
  8352. it.TBR,
  8353. it.JS_ES,
  8354. it.Suite
  8355. })
  8356. );
  8357. break;
  8358. case 79: // 车/导游地接
  8359. _ModuleSubPromptInfo.AddRange(
  8360. _GroupCostsTypeData.Select(it => new
  8361. {
  8362. Date = it.Date, //日期
  8363. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  8364. GuideFee = (it.TGS + it.TGOF + it.TGM + it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  8365. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  8366. TicketFee = it.EF * _rate * _scale, //门票费
  8367. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  8368. AirportTransferFee = 0.00M,
  8369. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8370. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8371. LeadersFee = it.TLF * _rate * _scale, //领队费
  8372. CarFee1 = it.CarCost * _rate * _scale,
  8373. CarType = it.CarType, //车型
  8374. SpentCash = it.PC * _rate * _scale, //零用金
  8375. })
  8376. );
  8377. break;
  8378. case 85: // 机票
  8379. List<dynamic> datas = new List<dynamic>();
  8380. datas.Add(
  8381. new
  8382. {
  8383. AirType = "经济舱",
  8384. AirNum = item.JJCRS,
  8385. AirDRCB = item.JJCCB,
  8386. AirZCB = (item.JJCRS * item.JJCCB)
  8387. }
  8388. );
  8389. datas.Add(
  8390. new
  8391. {
  8392. AirType = "公务舱",
  8393. AirNum = item.GWCRS,
  8394. AirDRCB = item.GWCCB,
  8395. AirZCB = (item.GWCRS * item.GWCCB)
  8396. }
  8397. );
  8398. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8399. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8400. modulePromptInfo.Data = new {
  8401. airFeeData = datas,
  8402. airInitData = initDatas
  8403. };
  8404. _ModulePromptInfos.Add(modulePromptInfo);
  8405. break;
  8406. default:
  8407. break;
  8408. }
  8409. }
  8410. if (dto.CTable != 85)
  8411. {
  8412. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8413. _ModulePromptInfos.Add(_ModulePromptInfo);
  8414. }
  8415. _view.ModulePromptInfos = _ModulePromptInfos;
  8416. return Ok(JsonView(true, "操作成功!", _view));
  8417. }
  8418. catch (Exception ex)
  8419. {
  8420. return Ok(JsonView(false, ex.Message));
  8421. }
  8422. }
  8423. /// <summary>
  8424. /// 根据黑屏代码重新生成行程
  8425. /// </summary>
  8426. /// <param name="dto"></param>
  8427. /// <returns></returns>
  8428. [HttpPost]
  8429. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8430. {
  8431. var jw = JsonView(false);
  8432. var Create =_GroupCostRepository.
  8433. CreateGroupCostByBlackCode(dto.Diid);
  8434. jw.Msg = Create.Msg;
  8435. if (Create.Code == 0)
  8436. {
  8437. jw.Code = 200;
  8438. jw.Data = new
  8439. {
  8440. groupCost = Create.Data,
  8441. blackCodeIsTrue = true
  8442. };
  8443. }
  8444. else
  8445. {
  8446. jw.Code = 400;
  8447. jw.Data = new
  8448. {
  8449. groupCost = Create.Data,
  8450. blackCodeIsTrue = false,
  8451. };
  8452. }
  8453. return Ok(jw);
  8454. }
  8455. /// <summary>
  8456. /// 成本获取OP历史车费用
  8457. /// </summary>
  8458. /// <param name="dto"></param>
  8459. /// <returns></returns>
  8460. [HttpPost]
  8461. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8462. {
  8463. var jw = JsonView(false);
  8464. try
  8465. {
  8466. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8467. //获取现有所有车的数据
  8468. if (!dto.Param.IsNullOrWhiteSpace())
  8469. {
  8470. string sql = $@"
  8471. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8472. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8473. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8474. WHERE gctggr.IsDel = 0 and gctggrc.SId = 91 AND gdi.IsDel = 0 AND gctggrc.Price != 0 AND (ssd.Id in (1061,1069) or ssd.Id is NULL) AND gctggr.ServiceStartTime is not null
  8475. AND gctggr.ServiceEndTime is not NULL
  8476. ORDER by gctggrc.id DESC
  8477. ";
  8478. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8479. var numeberResult = await Task.Run(() =>
  8480. {
  8481. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8482. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8483. return numberArr;
  8484. });
  8485. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8486. foreach (var item in numeberResult)
  8487. {
  8488. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8489. {
  8490. Country = "数据异常!",
  8491. City = string.Empty,
  8492. };
  8493. item.Area = find.Country + " " + find.City;
  8494. }
  8495. dbResult.AddRange(numeberResult);
  8496. if (dto.Param.Contains("、"))
  8497. {
  8498. var sp = dto.Param.Split("、");
  8499. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8500. .Where(x =>
  8501. {
  8502. return System.Array.Exists(sp, e =>
  8503. {
  8504. bool where = false;
  8505. if (x.Area != null)
  8506. {
  8507. where = x.Area.Contains(e);
  8508. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8509. {
  8510. return false;
  8511. }
  8512. }
  8513. if (x.PriceName != null && !where)
  8514. {
  8515. where = x.PriceName.Contains(e);
  8516. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8517. {
  8518. return false;
  8519. }
  8520. }
  8521. return where;
  8522. });
  8523. }).ToList();
  8524. }
  8525. else
  8526. {
  8527. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8528. .Where(x =>
  8529. {
  8530. bool where = false;
  8531. if (x.Area != null)
  8532. {
  8533. where = x.Area.Contains(dto.Param);
  8534. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8535. {
  8536. return false;
  8537. }
  8538. }
  8539. if (x.PriceName != null && !where)
  8540. {
  8541. where = x.PriceName.Contains(dto.Param);
  8542. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8543. {
  8544. return false;
  8545. }
  8546. }
  8547. return where;
  8548. }
  8549. )
  8550. .ToList();
  8551. }
  8552. }
  8553. var view = dbResult.Select(x => {
  8554. decimal dp = 0.00M;
  8555. var startB = DateTime.TryParse(x.Start.ToString(),out DateTime startD);
  8556. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8557. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8558. {
  8559. if (startB && endB)
  8560. {
  8561. var timesp = endD.Subtract(startD);
  8562. if ((timesp.Days + 1) != 0 )
  8563. {
  8564. dp = x.Price / (timesp.Days + 1);
  8565. }
  8566. }
  8567. }
  8568. else
  8569. {
  8570. dp = x.Price;
  8571. }
  8572. return new
  8573. {
  8574. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8575. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8576. x.Area,
  8577. x.id,
  8578. price = x.Price.ToString("F2"),
  8579. x.PriceName,
  8580. x.PriceContent,
  8581. x.TeamName,
  8582. x.DatePrice,
  8583. dayPrice = dp.ToString("F2"),
  8584. };
  8585. }).OrderByDescending(x=>x.id).ToList();
  8586. jw = JsonView(true, "获取成功!", view);
  8587. }
  8588. catch (Exception e)
  8589. {
  8590. jw = JsonView(false,e.Message);
  8591. }
  8592. return Ok(jw);
  8593. }
  8594. #endregion
  8595. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8596. /// <summary>
  8597. /// 酒店预订
  8598. /// 酒店费用列表 根据团组Id查询
  8599. /// </summary>
  8600. /// <param name="_dto"></param>
  8601. /// <returns></returns>
  8602. [HttpPost]
  8603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8604. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8605. {
  8606. #region 参数验证
  8607. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8608. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8609. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8610. #region 团组操作权限验证 76 酒店预定模块
  8611. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8612. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8613. #endregion
  8614. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8615. #region 页面操作权限验证
  8616. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8617. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8618. #endregion
  8619. #endregion
  8620. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8621. }
  8622. /// <summary>
  8623. /// 酒店预订
  8624. /// 基础数据
  8625. /// </summary>
  8626. /// <param name="_dto"></param>
  8627. /// <returns></returns>
  8628. [HttpPost]
  8629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8630. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8631. {
  8632. #region 参数验证
  8633. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8634. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8635. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8636. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8637. #region 页面操作权限验证
  8638. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8639. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8640. #endregion
  8641. #region 团组操作权限验证 76 酒店预定模块
  8642. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8643. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8644. #endregion
  8645. #endregion
  8646. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8647. }
  8648. /// <summary>
  8649. /// 酒店预订
  8650. /// 创建 入住卷号码
  8651. /// </summary>
  8652. /// <param name="_dto"></param>
  8653. /// <returns></returns>
  8654. [HttpPost]
  8655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8656. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8657. {
  8658. try
  8659. {
  8660. #region 参数验证
  8661. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8662. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8663. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8664. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8665. #region 页面操作权限验证
  8666. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8667. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8668. #endregion
  8669. #region 团组操作权限验证 76 酒店预定模块
  8670. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8671. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8672. #endregion
  8673. #endregion
  8674. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8675. if (data.Code != 0)
  8676. {
  8677. return Ok(JsonView(false, data.Msg));
  8678. }
  8679. return Ok(JsonView(true, data.Msg, data.Data));
  8680. }
  8681. catch (Exception ex)
  8682. {
  8683. return Ok(JsonView(false, ex.Message));
  8684. }
  8685. }
  8686. /// <summary>
  8687. /// 酒店预订
  8688. /// 详情
  8689. /// </summary>
  8690. /// <param name="_dto"></param>
  8691. /// <returns></returns>
  8692. [HttpPost]
  8693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8694. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8695. {
  8696. #region 参数验证
  8697. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8698. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8699. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8700. #region 团组操作权限验证 76 酒店预定模块
  8701. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8702. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8703. #endregion
  8704. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8705. #region 页面操作权限验证
  8706. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8707. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8708. #endregion
  8709. #endregion
  8710. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8711. }
  8712. /// <summary>
  8713. /// 酒店预订
  8714. /// Add Or Edit
  8715. /// </summary>
  8716. /// <param name="_dto"></param>
  8717. /// <returns></returns>
  8718. [HttpPost]
  8719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8720. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8721. {
  8722. #region 参数验证
  8723. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8724. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8725. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8726. #region 团组操作权限验证 76 酒店预定模块
  8727. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8728. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8729. #endregion
  8730. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8731. #region 页面操作权限验证
  8732. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8733. if (_dto.Id == 0) // Add
  8734. {
  8735. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8736. }
  8737. else if (_dto.Id > 1) // Edit
  8738. {
  8739. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8740. }else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8741. #endregion
  8742. #endregion
  8743. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8744. if (_view.Code != 200)
  8745. {
  8746. return Ok(_view);
  8747. }
  8748. #region 应用推送
  8749. //TODO:酒店预订费用消息推送 移动端完成后取消注释
  8750. //try
  8751. //{
  8752. // int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8753. // int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8754. // await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8755. //}
  8756. //catch (Exception ex)
  8757. //{
  8758. //}
  8759. #endregion
  8760. return Ok(_view);
  8761. }
  8762. /// <summary>
  8763. /// 酒店预订
  8764. /// Del
  8765. /// </summary>
  8766. /// <param name="_dto"></param>
  8767. /// <returns></returns>
  8768. [HttpPost]
  8769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8770. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8771. {
  8772. #region 参数验证
  8773. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8774. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8775. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8776. #region 团组操作权限验证 76 酒店预定模块
  8777. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8778. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8779. #endregion
  8780. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8781. #region 页面操作权限验证
  8782. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8783. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8784. #endregion
  8785. #endregion
  8786. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8787. }
  8788. /// <summary>
  8789. /// 酒店预订
  8790. /// 生成VOUCHER
  8791. /// 2024.05.06 之前版本
  8792. /// </summary>
  8793. /// <param name="_dto"></param>
  8794. /// <returns></returns>
  8795. [HttpPost]
  8796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8797. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8798. {
  8799. try
  8800. {
  8801. #region 参数验证
  8802. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8803. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8804. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8805. #region 团组操作权限验证 76 酒店预定模块
  8806. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8807. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8808. #endregion
  8809. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8810. #region 页面操作权限验证
  8811. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8812. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8813. #endregion
  8814. #endregion
  8815. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8816. //判断数据是否完整
  8817. if (hr != null)
  8818. {
  8819. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8820. {
  8821. string strFileName = "HotelStatement/";
  8822. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8823. if (dele != null)
  8824. strFileName += dele.TourCode;
  8825. //载入模板
  8826. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8827. Document doc = new Document(sss);
  8828. DocumentBuilder builder = new DocumentBuilder(doc);
  8829. #region 替换Word模板书签内容
  8830. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8831. //入住卷预定号码
  8832. if (doc.Range.Bookmarks["VNO"] != null)
  8833. {
  8834. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8835. mark.Text = hr.CheckNumber;
  8836. }
  8837. //酒店时间
  8838. if (doc.Range.Bookmarks["Date"] != null)
  8839. {
  8840. Bookmark mark = doc.Range.Bookmarks["Date"];
  8841. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8842. }
  8843. //团号
  8844. if (doc.Range.Bookmarks["TNo"] != null)
  8845. {
  8846. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8847. mark.Text = dele.TourCode;
  8848. }
  8849. //预定号码
  8850. if (doc.Range.Bookmarks["BookingId"] != null)
  8851. {
  8852. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8853. mark.Text = hr.ReservationsNo;
  8854. }
  8855. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8856. {
  8857. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8858. mark.Text = hr.DetermineNo;
  8859. }
  8860. //酒店城市
  8861. if (doc.Range.Bookmarks["City"] != null)
  8862. {
  8863. Bookmark mark = doc.Range.Bookmarks["City"];
  8864. mark.Text = hr.City;
  8865. }
  8866. //酒店名称
  8867. if (doc.Range.Bookmarks["HName"] != null)
  8868. {
  8869. Bookmark mark = doc.Range.Bookmarks["HName"];
  8870. mark.Text = hr.HotelName;
  8871. }
  8872. //酒店地址
  8873. if (doc.Range.Bookmarks["Address"] != null)
  8874. {
  8875. Bookmark mark = doc.Range.Bookmarks["Address"];
  8876. mark.Text = hr.HotelAddress;
  8877. }
  8878. //酒店电话
  8879. if (doc.Range.Bookmarks["Tel"] != null)
  8880. {
  8881. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8882. mark.Text = hr.HotelTel;
  8883. }
  8884. //酒店传真
  8885. if (doc.Range.Bookmarks["Fax"] != null)
  8886. {
  8887. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8888. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8889. {
  8890. mark.Text = hr.HotelFax;
  8891. }
  8892. }
  8893. //入住时间
  8894. if (doc.Range.Bookmarks["CIn"] != null)
  8895. {
  8896. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8897. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8898. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8899. }
  8900. //退房时间
  8901. if (doc.Range.Bookmarks["COut"] != null)
  8902. {
  8903. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8904. Bookmark mark = doc.Range.Bookmarks["COut"];
  8905. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8906. }
  8907. //客户名称
  8908. if (doc.Range.Bookmarks["GName"] != null)
  8909. {
  8910. string guestName = "";
  8911. string[] clients = new string[] { };
  8912. if (hr.GuestName.Contains(","))
  8913. {
  8914. clients = hr.GuestName.Split(",");
  8915. }
  8916. else
  8917. {
  8918. clients = new string[] { hr.GuestName };
  8919. }
  8920. List<int> clientIds_int = new List<int>();
  8921. if (clients.Length > 0)
  8922. {
  8923. foreach (var item in clients)
  8924. {
  8925. if (item.IsNumeric())
  8926. {
  8927. clientIds_int.Add(int.Parse(item));
  8928. }
  8929. }
  8930. }
  8931. if (clientIds_int.Count > 0)
  8932. {
  8933. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8934. foreach (var client in _clientDatas)
  8935. {
  8936. //男
  8937. if (client.Sex == 0) guestName += $"Mr.";
  8938. //女
  8939. else if (client.Sex == 1) guestName += $"Ms.";
  8940. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8941. {
  8942. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8943. }
  8944. //guestName += $"{client.Pinyin},";
  8945. }
  8946. if (guestName.Length > 0)
  8947. {
  8948. guestName = guestName.Substring(0, guestName.Length - 1);
  8949. }
  8950. }
  8951. else
  8952. {
  8953. guestName = hr.GuestName;
  8954. }
  8955. Bookmark mark = doc.Range.Bookmarks["GName"];
  8956. mark.Text = guestName;
  8957. }
  8958. //房间介绍
  8959. if (doc.Range.Bookmarks["ROOM"] != null)
  8960. {
  8961. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8962. mark.Text = hr.RoomExplanation;
  8963. }
  8964. //报价描述
  8965. if (doc.Range.Bookmarks["NOTE"] != null)
  8966. {
  8967. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8968. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  8969. if (ss != null)
  8970. mark.Text = ss.Name;
  8971. }
  8972. //入住时间
  8973. if (doc.Range.Bookmarks["CheckIn"] != null)
  8974. {
  8975. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8976. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  8977. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  8978. }
  8979. //退房时间
  8980. if (doc.Range.Bookmarks["CheckOut"] != null)
  8981. {
  8982. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8983. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  8984. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8985. }
  8986. //日期
  8987. if (doc.Range.Bookmarks["DT"] != null)
  8988. {
  8989. Bookmark mark = doc.Range.Bookmarks["DT"];
  8990. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8991. }
  8992. //名称
  8993. if (doc.Range.Bookmarks["VName"] != null)
  8994. {
  8995. Bookmark mark = doc.Range.Bookmarks["VName"];
  8996. mark.Text = hr.HotelName;
  8997. }
  8998. //号码
  8999. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9000. {
  9001. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9002. mark.Text = hr.CheckNumber;
  9003. }
  9004. #endregion
  9005. strFileName += "VOUCHER.doc";
  9006. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9007. doc.Save(fileDir);
  9008. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9009. return Ok(JsonView(true, "操作成功!", Url));
  9010. }
  9011. else
  9012. {
  9013. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9014. }
  9015. }
  9016. else
  9017. {
  9018. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9019. }
  9020. }
  9021. catch (Exception ex)
  9022. {
  9023. return Ok(JsonView(false, ex.Message));
  9024. }
  9025. }
  9026. /// <summary>
  9027. /// 酒店预订
  9028. /// 生成VOUCHER
  9029. /// 2024.05.06 之后版本
  9030. /// </summary>
  9031. /// <param name="_dto"></param>
  9032. /// <returns></returns>
  9033. [HttpPost]
  9034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9035. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9036. {
  9037. #region 参数验证
  9038. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9039. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9040. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9041. #region 团组操作权限验证 76 酒店预定模块
  9042. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9043. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9044. #endregion
  9045. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9046. #region 页面操作权限验证
  9047. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9048. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9049. #endregion
  9050. #endregion
  9051. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9052. //判断数据是否完整
  9053. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9054. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9055. string strFileName = "HotelStatement/";
  9056. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9057. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9058. #region 数据处理
  9059. List<int> guestIds = new List<int>();
  9060. int index = 0;
  9061. foreach (var item in hrDtas)
  9062. {
  9063. if (item.GuestName.Contains(","))
  9064. {
  9065. string[] guestIdArr = item.GuestName.Split(',');
  9066. foreach (var guestIdStr in guestIdArr)
  9067. {
  9068. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9069. if (guestBool)
  9070. {
  9071. guestIds.Add(guestId);
  9072. }
  9073. }
  9074. }
  9075. else guestNames += item.GuestName;
  9076. var voucherInfo = new HotelVoucherInfoView()
  9077. {
  9078. HotelName = item.HotelName,
  9079. CheckInDate = item.CheckInDate,
  9080. CheckOutDate = item.CheckOutDate,
  9081. ConfirmationNumber = item.DetermineNo.Trim(),
  9082. RoomType = item.RoomExplanation
  9083. };
  9084. vouchers.Add(voucherInfo);
  9085. }
  9086. if (guestIds.Count > 0)
  9087. {
  9088. guestIds = guestIds.Distinct().ToList();
  9089. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9090. if (guestDatas.Count > 0)
  9091. {
  9092. guestNames = "";
  9093. foreach (var guest in guestDatas)
  9094. {
  9095. string guestName = "";
  9096. if (guest.Sex == 0) guestName += @"MR.";
  9097. else if (guest.Sex == 1) guestName += @"MS.";
  9098. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9099. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9100. guestNames += @$"{guestName.Trim()}、";
  9101. }
  9102. if (guestNames.Length > 0)
  9103. {
  9104. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9105. }
  9106. }
  9107. }
  9108. #endregion
  9109. //载入模板
  9110. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9111. Document doc = new Document(sss);
  9112. DocumentBuilder builder = new DocumentBuilder(doc);
  9113. if (doc.Range.Bookmarks["GuestName"] != null)
  9114. {
  9115. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9116. mark.Text = guestNames;
  9117. }
  9118. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9119. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9120. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9121. for (int i = 1; i <= vouchers.Count; i++)
  9122. {
  9123. HotelVoucherInfoView hviv = vouchers[i - 1];
  9124. builder.MoveToCell(0, i, 0, 0);
  9125. builder.Write(hviv.HotelName);
  9126. builder.MoveToCell(0, i, 1, 0);
  9127. builder.Write(hviv.CheckInDate);
  9128. builder.MoveToCell(0, i, 2, 0);
  9129. builder.Write(hviv.CheckOutDate);
  9130. builder.MoveToCell(0, i, 3, 0);
  9131. builder.Write(hviv.RoomType);
  9132. builder.MoveToCell(0, i, 4, 0);
  9133. builder.Write(hviv.ConfirmationNumber);
  9134. }
  9135. //删除多余行
  9136. int currRowIndex = vouchers.Count + 1;
  9137. int delRows = 21 - currRowIndex;
  9138. if (delRows > 0)
  9139. {
  9140. for (int i = 0; i < delRows; i++)
  9141. {
  9142. table.Rows.RemoveAt(currRowIndex);
  9143. //cultivateRowIndex++;
  9144. }
  9145. }
  9146. strFileName += "VOUCHER.docx";
  9147. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9148. doc.Save(fileDir);
  9149. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9150. return Ok(JsonView(true, "操作成功!", Url));
  9151. }
  9152. /// <summary>
  9153. /// 酒店预订
  9154. /// 生成 预定成本 Excel
  9155. /// </summary>
  9156. /// <param name="_dto"></param>
  9157. /// <returns></returns>
  9158. [HttpPost]
  9159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9160. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9161. {
  9162. #region 参数验证
  9163. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9164. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9165. if (!vadalitorRes.IsValid)
  9166. {
  9167. var errors = new StringBuilder();
  9168. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9169. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9170. }
  9171. #region 团组操作权限验证 76 酒店预定模块
  9172. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9173. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9174. #endregion
  9175. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9176. #region 页面操作权限验证
  9177. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9178. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9179. #endregion
  9180. #endregion
  9181. decimal _rate = 1.00M;
  9182. string _currency = "";
  9183. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9184. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9185. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9186. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9187. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9188. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9189. {
  9190. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9191. }
  9192. _currency = _GroupCostParameter.Currency;
  9193. bool isIntType = int.TryParse(_currency, out int currId);
  9194. if (isIntType)
  9195. {
  9196. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9197. }
  9198. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9199. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9200. if (currInfo == null)
  9201. {
  9202. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9203. }
  9204. if (!_currency.ToUpper().Equals("CNY"))
  9205. {
  9206. _rate = _GroupCostParameter.Rate;
  9207. }
  9208. _rate = currInfo.Rate;
  9209. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9210. string strFileName = "HotelStatement/";
  9211. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9212. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9213. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  9214. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  9215. #region 数据处理
  9216. foreach (var item in hrDtas)
  9217. {
  9218. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9219. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  9220. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  9221. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  9222. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  9223. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  9224. string singleRoomFeeStr = string.Empty,
  9225. doubleRoomFeeStr = string.Empty,
  9226. suiteRoomFeeStr = string.Empty,
  9227. otherRoomFeeStr = string.Empty,
  9228. payMoneyStr = string.Empty,
  9229. cardPriceStr = string.Empty;
  9230. if (roomCurr.Equals(_currency))
  9231. {
  9232. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9233. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9234. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9235. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9236. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9237. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9238. }
  9239. else
  9240. {
  9241. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9242. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9243. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9244. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9245. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9246. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9247. }
  9248. string breakfastPriceStr = string.Empty,
  9249. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9250. governmentRentStr = string.Empty,
  9251. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9252. cityTaxStrStr = string.Empty,
  9253. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9254. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  9255. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  9256. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  9257. pcfds.Add(new HotelReservations_PCFD_View()
  9258. {
  9259. City = item.City,
  9260. HotelName = item.HotelName,
  9261. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9262. // SingleRoomCount = item.SingleRoomCount,
  9263. SingleRoomPrice = singleRoomFeeStr,
  9264. // DoubleRoomCount = item.DoubleRoomCount,
  9265. DoubleRoomPrice = doubleRoomFeeStr,
  9266. //SuiteRoomCount = item.SuiteRoomCount,
  9267. SuiteRoomPrice = suiteRoomFeeStr,
  9268. OtherRoomPrice = otherRoomFeeStr,
  9269. //OtherRoomCount = item.OtherRoomCount,
  9270. BreakfastPrice = breakfastPriceStr,
  9271. GovernmentRent = governmentRentStr,
  9272. CityTax = cityTaxStrStr,
  9273. RoomExplanation = item.RoomExplanation,
  9274. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  9275. PayTime = roomInfo.ConsumptionDate,
  9276. BankNo = roomInfo.BankNo,
  9277. PayMoney = payMoneyStr,
  9278. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9279. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  9280. CardPrice = cardPriceStr,
  9281. Remark = ccpInfo.Remark
  9282. });
  9283. }
  9284. #endregion
  9285. //载入模板
  9286. WorkbookDesigner designer = new WorkbookDesigner();
  9287. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9288. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9289. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9290. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9291. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9292. designer.SetDataSource("Opertor", userInfo.CnName);
  9293. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9294. dt.TableName = "ViewMyHotelReservations";
  9295. designer.SetDataSource(dt);
  9296. designer.Process();
  9297. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  9298. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9299. designer.Workbook.Save(serverPath);
  9300. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9301. #region 删除指定行
  9302. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true,cpDel=true, remarkDel = true;
  9303. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9304. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9305. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9306. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9307. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9308. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9309. cssIndex = dt.Columns["CityTax"].Ordinal,
  9310. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9311. remarkIndex = dt.Columns["Remark"].Ordinal;
  9312. //删除指定列
  9313. foreach (DataRow item in dt.Rows)
  9314. {
  9315. string singleStr = item["SingleRoomPrice"].ToString();
  9316. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9317. if (containsDigitButNotZero1) singleDel = false;
  9318. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9319. string doubleStr = item["DoubleRoomPrice"].ToString();
  9320. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9321. if (containsDigitButNotZero2) doubleDel = false;
  9322. string suiteStr = item["SuiteRoomPrice"].ToString();
  9323. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9324. if (containsDigitButNotZero3) suiteDel = false;
  9325. string otherStr = item["OtherRoomPrice"].ToString();
  9326. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9327. if (containsDigitButNotZero4) otherDel = false;
  9328. string zcStr = item["BreakfastPrice"].ToString();
  9329. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9330. if (containsDigitButNotZero5) zcDel = false;
  9331. string dsStr = item["GovernmentRent"].ToString();
  9332. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9333. if (containsDigitButNotZero6) dsDel = false;
  9334. string cssStr = item["CityTax"].ToString();
  9335. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9336. if (containsDigitButNotZero7) cssDel = false;
  9337. string cpStr = item["ConsumptionPatterns"].ToString();
  9338. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9339. string remarkStr = item["Remark"].ToString();
  9340. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9341. }
  9342. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9343. DeleteColumn(serverPath, cpIndex, cpDel);
  9344. DeleteColumn(serverPath, dsIndex, dsDel);
  9345. DeleteColumn(serverPath, cssIndex, cssDel);
  9346. DeleteColumn(serverPath, zcIndex, zcDel);
  9347. DeleteColumn(serverPath, otherIndex, otherDel);
  9348. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9349. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9350. DeleteColumn(serverPath, singleIndex, singleDel);
  9351. #endregion
  9352. //只保留第一个表格
  9353. DeleteSheet(serverPath);
  9354. return Ok(JsonView(true, "操作成功", url = rst));
  9355. }
  9356. /// <summary>
  9357. /// 删除指定列
  9358. /// </summary>
  9359. /// <param name="file"></param>
  9360. /// <param name="columnIndex"></param>
  9361. /// <param name="isDel"></param>
  9362. private void DeleteColumn(string file, int columnIndex,bool isDel)
  9363. {
  9364. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9365. //wb.Save(file);
  9366. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9367. if (sheet1 != null)
  9368. {
  9369. if (isDel)
  9370. {
  9371. Cells cells = sheet1.Cells;
  9372. cells.DeleteColumn(columnIndex);
  9373. }
  9374. }
  9375. wb.Save(file);
  9376. }
  9377. /// <summary>
  9378. /// 删除sheet
  9379. /// </summary>
  9380. /// <param name="file"></param>
  9381. /// <param name="sheetName"></param>
  9382. private void DeleteSheet(string file, string sheetName="")
  9383. {
  9384. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9385. //wb.Save(file);
  9386. List<string> sheets = new List<string>();
  9387. foreach (var item in wb.Worksheets)
  9388. {
  9389. sheets.Add(item.Name);
  9390. }
  9391. if (sheets.Count > 0)
  9392. {
  9393. sheets.RemoveAt(0);//不删除第一个sheet
  9394. foreach (var item in sheets)
  9395. {
  9396. wb.Worksheets.RemoveAt(item);
  9397. }
  9398. }
  9399. wb.Save(file);
  9400. }
  9401. /// <summary>
  9402. /// 酒店预订
  9403. /// 确认单
  9404. /// </summary>
  9405. /// <param name="_dto"></param>
  9406. /// <returns></returns>
  9407. [HttpPost]
  9408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9409. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9410. {
  9411. try
  9412. {
  9413. #region 参数验证
  9414. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9415. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9416. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9417. #region 团组操作权限验证 76 酒店预定模块
  9418. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9419. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9420. #endregion
  9421. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9422. #region 页面操作权限验证
  9423. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9424. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9425. #endregion
  9426. #endregion
  9427. //团组信息
  9428. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9429. //酒店数据
  9430. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9431. if (listhoteldata.Count < 0)
  9432. {
  9433. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9434. }
  9435. //利datatable存储
  9436. DataTable dt = new DataTable();
  9437. dt.Columns.Add("CheckInDate", typeof(string));
  9438. dt.Columns.Add("City", typeof(string));
  9439. dt.Columns.Add("Hotel", typeof(string));
  9440. dt.Columns.Add("Room", typeof(string));
  9441. for (int i = 0; i < listhoteldata.Count; i++)
  9442. {
  9443. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9444. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9445. while (dayStart < dayEnd)
  9446. {
  9447. string temp = "";
  9448. DataRow row = dt.NewRow();
  9449. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9450. row["City"] = listhoteldata[i].City;
  9451. row["Hotel"] = listhoteldata[i].HotelName;
  9452. if (listhoteldata[i].SingleRoomCount > 0)
  9453. {
  9454. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9455. }
  9456. if (listhoteldata[i].DoubleRoomCount > 0)
  9457. {
  9458. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9459. }
  9460. if (listhoteldata[i].SuiteRoomCount > 0)
  9461. {
  9462. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9463. }
  9464. if (listhoteldata[i].OtherRoomCount > 0)
  9465. {
  9466. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9467. }
  9468. row["Room"] = temp;
  9469. dt.Rows.Add(row);
  9470. dayStart = dayStart.AddDays(1);
  9471. }
  9472. }
  9473. Dictionary<string, string> dic = new Dictionary<string, string>();
  9474. dic.Add("Dele", di.TeamName);
  9475. dic.Add("City", di.VisitCountry);
  9476. //模板路径
  9477. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9478. //载入模板
  9479. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9480. DocumentBuilder builder = new DocumentBuilder(doc);
  9481. foreach (var key in dic.Keys)
  9482. {
  9483. builder.MoveToBookmark(key);
  9484. builder.Write(dic[key]);
  9485. }
  9486. //获取word里所有表格
  9487. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9488. //获取所填表格的序数
  9489. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9490. var rowStart = tableOne.Rows[0]; //获取第1行
  9491. //循环赋值
  9492. for (int i = 0; i < dt.Rows.Count; i++)
  9493. {
  9494. builder.MoveToCell(0, i + 1, 0, 0);
  9495. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9496. builder.MoveToCell(0, i + 1, 1, 0);
  9497. builder.Write(dt.Rows[i]["City"].ToString());
  9498. builder.MoveToCell(0, i + 1, 2, 0);
  9499. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9500. builder.MoveToCell(0, i + 1, 3, 0);
  9501. builder.Write(dt.Rows[i]["Room"].ToString());
  9502. }
  9503. //删除多余行
  9504. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9505. {
  9506. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9507. }
  9508. string strFileName = di.TeamName + "酒店确认单.doc";
  9509. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9510. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9511. return Ok(JsonView(true, "成功", url));
  9512. }
  9513. catch (Exception ex)
  9514. {
  9515. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9516. }
  9517. }
  9518. #endregion
  9519. #region 团组状态
  9520. /// <summary>
  9521. /// 团组状态列表 Page
  9522. /// </summary>
  9523. /// <param name="dto">团组列表请求dto</param>
  9524. /// <returns></returns>
  9525. [HttpPost]
  9526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9527. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9528. {
  9529. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9530. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9531. {
  9532. string sqlWhere = string.Empty;
  9533. if (dto.IsSure == 0) //未完成
  9534. {
  9535. sqlWhere += string.Format(@" And IsSure = 0");
  9536. }
  9537. else if (dto.IsSure == 1) //已完成
  9538. {
  9539. sqlWhere += string.Format(@" And IsSure = 1");
  9540. }
  9541. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9542. {
  9543. string tj = dto.SearchCriteria;
  9544. 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}%')",
  9545. tj, tj, tj, tj, tj);
  9546. }
  9547. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9548. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9549. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9550. From (
  9551. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9552. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9553. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9554. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9555. From Grp_DelegationInfo gdi
  9556. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9557. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9558. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9559. Where gdi.IsDel = 0 {0}
  9560. ) temp ", sqlWhere);
  9561. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9562. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9563. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9564. }
  9565. else
  9566. {
  9567. return Ok(JsonView(false, "查询失败"));
  9568. }
  9569. }
  9570. /// <summary>
  9571. /// 团组状态
  9572. /// 设置操作完成
  9573. /// </summary>
  9574. /// <param name="dto">团组列表请求dto</param>
  9575. /// <returns></returns>
  9576. [HttpPost]
  9577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9578. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9579. {
  9580. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9581. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9582. {
  9583. Id = dto.Id,
  9584. IsSure = 1
  9585. };
  9586. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9587. .UpdateColumns(it => new { it.IsSure })
  9588. .WhereColumns(it => new { it.Id })
  9589. .ExecuteCommandAsync();
  9590. if (result > 0)
  9591. {
  9592. return Ok(JsonView(true, "操作完成!"));
  9593. }
  9594. return Ok(JsonView(false, "操作失败!"));
  9595. }
  9596. #endregion
  9597. #region 保险费用录入
  9598. /// <summary>
  9599. /// 根据团组Id查询保险费用列表
  9600. /// </summary>
  9601. /// <param name="dto"></param>
  9602. /// <returns></returns>
  9603. [HttpPost]
  9604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9605. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9606. {
  9607. try
  9608. {
  9609. Result groupData = await _customersRep.CustomersByDiId(dto);
  9610. if (groupData.Code != 0)
  9611. {
  9612. return Ok(JsonView(false, groupData.Msg));
  9613. }
  9614. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9615. }
  9616. catch (Exception ex)
  9617. {
  9618. return Ok(JsonView(false, ex.Message));
  9619. }
  9620. }
  9621. /// <summary>
  9622. /// 根据保险费用Id查询保险费用详细
  9623. /// </summary>
  9624. /// <param name="dto"></param>
  9625. /// <returns></returns>
  9626. [HttpPost]
  9627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9628. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9629. {
  9630. try
  9631. {
  9632. Result groupData = await _customersRep.CustomersById(dto);
  9633. if (groupData.Code != 0)
  9634. {
  9635. return Ok(JsonView(false, groupData.Msg));
  9636. }
  9637. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9638. }
  9639. catch (Exception ex)
  9640. {
  9641. return Ok(JsonView(false, ex.Message));
  9642. }
  9643. }
  9644. /// <summary>
  9645. /// 保险费用录入页面初始化绑定
  9646. /// </summary>
  9647. /// <param name="dto"></param>
  9648. /// <returns></returns>
  9649. [HttpPost]
  9650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9651. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9652. {
  9653. try
  9654. {
  9655. Result groupData = await _customersRep.CustomersInitialize(dto);
  9656. if (groupData.Code != 0)
  9657. {
  9658. return Ok(JsonView(false, groupData.Msg));
  9659. }
  9660. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9661. }
  9662. catch (Exception ex)
  9663. {
  9664. return Ok(JsonView(false, ex.Message));
  9665. }
  9666. }
  9667. /// <summary>
  9668. /// 保险费用操作(Status:1.新增,2.修改)
  9669. /// </summary>
  9670. /// <param name="dto"></param>
  9671. /// <returns></returns>
  9672. [HttpPost]
  9673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9674. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9675. {
  9676. try
  9677. {
  9678. Result groupData = await _customersRep.OpCustomers(dto);
  9679. if (groupData.Code != 0)
  9680. {
  9681. return Ok(JsonView(false, groupData.Msg));
  9682. }
  9683. #region 应用推送
  9684. try
  9685. {
  9686. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9687. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9688. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9689. }
  9690. catch (Exception ex)
  9691. {
  9692. }
  9693. #endregion
  9694. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9695. }
  9696. catch (Exception ex)
  9697. {
  9698. return Ok(JsonView(false, ex.Message));
  9699. }
  9700. }
  9701. /// <summary>
  9702. /// 保险文件上传
  9703. /// </summary>
  9704. /// <param name="file"></param>
  9705. /// <returns></returns>
  9706. [HttpPost]
  9707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9708. public async Task<IActionResult> UploadCus(IFormFile file)
  9709. {
  9710. try
  9711. {
  9712. if (file != null)
  9713. {
  9714. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9715. //文件名称
  9716. string projectFileName = file.FileName;
  9717. //上传的文件的路径
  9718. string filePath = "";
  9719. if (!Directory.Exists(fileDir))
  9720. {
  9721. Directory.CreateDirectory(fileDir);
  9722. }
  9723. //上传的文件的路径
  9724. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9725. using (FileStream fs = System.IO.File.Create(filePath))
  9726. {
  9727. file.CopyTo(fs);
  9728. fs.Flush();
  9729. }
  9730. return Ok(JsonView(true, "上传成功!", projectFileName));
  9731. }
  9732. else
  9733. {
  9734. return Ok(JsonView(false, "上传失败!"));
  9735. }
  9736. }
  9737. catch (Exception ex)
  9738. {
  9739. return Ok(JsonView(false, "程序错误!"));
  9740. throw;
  9741. }
  9742. }
  9743. /// <summary>
  9744. /// 保险删除指定文件
  9745. /// </summary>
  9746. /// <param name="dto"></param>
  9747. /// <returns></returns>
  9748. [HttpPost]
  9749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9750. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9751. {
  9752. try
  9753. {
  9754. string filePath = "";
  9755. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9756. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9757. //int id = 0;
  9758. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9759. // 删除该文件
  9760. try
  9761. {
  9762. System.IO.File.Delete(filePath);
  9763. 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()
  9764. {
  9765. Attachment = "",
  9766. }).ExecuteCommandAsync();
  9767. if (result != 0)
  9768. {
  9769. return Ok(JsonView(true, "成功!"));
  9770. }
  9771. else
  9772. {
  9773. return Ok(JsonView(false, "失败!"));
  9774. }
  9775. }
  9776. catch (Exception)
  9777. {
  9778. 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()
  9779. {
  9780. Attachment = "",
  9781. }).ExecuteCommandAsync();
  9782. if (result != 0)
  9783. {
  9784. return Ok(JsonView(true, "成功!"));
  9785. }
  9786. else
  9787. {
  9788. return Ok(JsonView(false, "失败!"));
  9789. }
  9790. }
  9791. }
  9792. catch (Exception ex)
  9793. {
  9794. return Ok(JsonView(false, "程序错误!"));
  9795. throw;
  9796. }
  9797. }
  9798. /// <summary>
  9799. /// 保险费用操作(删除)
  9800. /// </summary>
  9801. /// <param name="dto"></param>
  9802. /// <returns></returns>
  9803. [HttpPost]
  9804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9805. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9806. {
  9807. try
  9808. {
  9809. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9810. if (!res)
  9811. {
  9812. return Ok(JsonView(false, "删除失败"));
  9813. }
  9814. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9815. {
  9816. IsDel = 1,
  9817. DeleteUserId = dto.DeleteUserId,
  9818. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9819. }).ExecuteCommandAsync();
  9820. return Ok(JsonView(true, "删除成功!"));
  9821. }
  9822. catch (Exception ex)
  9823. {
  9824. return Ok(JsonView(false, "程序错误!"));
  9825. throw;
  9826. }
  9827. }
  9828. #endregion
  9829. #region 接团客户名单 PageId 104
  9830. /// <summary>
  9831. /// 接团客户名单
  9832. /// 迁移数据(慎用!)
  9833. /// </summary>
  9834. /// <param name="dto"></param>
  9835. /// <returns></returns>
  9836. [HttpPost]
  9837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9838. public async Task<IActionResult> PostTourClientListChange()
  9839. {
  9840. try
  9841. {
  9842. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9843. //var groupClinetData1
  9844. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9845. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9846. int updateCount = 0;
  9847. if (oldOAClientList.Count > 0)
  9848. {
  9849. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9850. _sqlSugar.BeginTran();
  9851. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9852. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9853. foreach (var item in oldOAClientList)
  9854. {
  9855. int comId = 0;
  9856. string format = "yyyy-MM-dd HH:mm:ss";
  9857. string data11 = "1990-01-01 00:00";
  9858. var data1 = IsValidDate(item.OPdate, format);
  9859. if (data1) data11 = item.OPdate;
  9860. //客户公司验证
  9861. if (!string.IsNullOrEmpty(item.Company))
  9862. {
  9863. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9864. if (clientComInfo == null) // add
  9865. {
  9866. var addInfo = new Crm_CustomerCompany()
  9867. {
  9868. CompanyAbbreviation = "",
  9869. CompanyFullName = item.Company,
  9870. Address = "",
  9871. PostCodes = "",
  9872. LastedOpUserId = item.OPer,
  9873. LastedOpDt = Convert.ToDateTime(data11),
  9874. CreateUserId = item.OPer,
  9875. CreateTime = Convert.ToDateTime(data11),
  9876. IsDel = 0
  9877. };
  9878. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9879. if (comId1 > 0) comId = comId1;
  9880. }
  9881. else comId = clientComInfo.Id;
  9882. }
  9883. //客户人员验证
  9884. int clientId = 0;
  9885. string name = item.LastName + item.Name;
  9886. if (!string.IsNullOrEmpty(name))
  9887. {
  9888. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9889. if (clientInfo == null)
  9890. {
  9891. DateTime? dateTime = null;
  9892. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9893. if (isDt) dateTime = birthDayDt;
  9894. var addInfo1 = new Crm_DeleClient()
  9895. {
  9896. CrmCompanyId = comId,
  9897. DiId = -1,
  9898. LastName = item.LastName,
  9899. FirstName = item.Name,
  9900. OldName = "",
  9901. Pinyin = item.Pinyin,
  9902. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9903. Marriage = 0,
  9904. Phone = item.Phone,
  9905. Job = item.Job,
  9906. BirthDay = dateTime
  9907. };
  9908. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9909. if (clientId1 > 0) clientId = clientId1;
  9910. }
  9911. else clientId = clientInfo.Id;
  9912. }
  9913. if (clientId < 1)
  9914. {
  9915. continue;
  9916. }
  9917. int airType = 0;
  9918. if (item.AirType == "超经舱") airType = 459;
  9919. else if (item.AirType == "公务舱") airType = 458;
  9920. else if (item.AirType == "经济舱") airType = 460;
  9921. else if (item.AirType == "其他") airType = 565;
  9922. else if (item.AirType == "头等舱") airType = 457;
  9923. var _TourClientListEntity = new Grp_TourClientList()
  9924. {
  9925. DiId = item.Diid,
  9926. ClientId = clientId,
  9927. CreateUserId = item.OPer,
  9928. CreateTime = Convert.ToDateTime(data11),
  9929. Remark = item.Remark,
  9930. IsDel = item.Isdel,
  9931. ShippingSpaceTypeId = airType,
  9932. ShippingSpaceSpecialNeeds = item.AirRemark,
  9933. HotelSpecialNeeds = item.RoomType
  9934. };
  9935. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9936. if (_TourClientList > 0)
  9937. {
  9938. updateCount++;
  9939. }
  9940. }
  9941. _sqlSugar.CommitTran();
  9942. }
  9943. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9944. }
  9945. catch (Exception ex)
  9946. {
  9947. _sqlSugar.RollbackTran();
  9948. return Ok(JsonView(false, ex.Message));
  9949. }
  9950. return Ok(JsonView(true));
  9951. }
  9952. private bool IsValidDate(string dateString, string format)
  9953. {
  9954. DateTime dateValue;
  9955. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9956. return valid;
  9957. }
  9958. /// <summary>
  9959. /// 接团客户名单
  9960. /// 根据团组Id查询List
  9961. /// </summary>
  9962. /// <param name="dto"></param>
  9963. /// <returns></returns>
  9964. [HttpPost]
  9965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9966. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  9967. {
  9968. #region 参数验证
  9969. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  9970. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9971. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  9972. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9973. #region 页面操作权限验证
  9974. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9975. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9976. #endregion
  9977. #endregion
  9978. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  9979. if (viewData.Code != 0)
  9980. {
  9981. return Ok(JsonView(false, viewData.Msg));
  9982. }
  9983. return Ok(JsonView(viewData.Data));
  9984. }
  9985. /// <summary>
  9986. /// 接团客户名单
  9987. /// 基础数据 Init
  9988. /// </summary>
  9989. /// <param name="_dto"></param>
  9990. /// <returns></returns>
  9991. [HttpPost]
  9992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9993. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  9994. {
  9995. #region 参数验证
  9996. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9997. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9998. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9999. #region 页面操作权限验证
  10000. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10001. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10002. #endregion
  10003. #endregion
  10004. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10005. if (viewData.Code != 0)
  10006. {
  10007. return Ok(JsonView(false, viewData.Msg));
  10008. }
  10009. return Ok(JsonView(viewData.Data));
  10010. }
  10011. /// <summary>
  10012. /// 接团客户名单
  10013. /// 根据 Id查询 Details
  10014. /// </summary>
  10015. /// <param name="_dto"></param>
  10016. /// <returns></returns>
  10017. [HttpPost]
  10018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10019. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10020. {
  10021. #region 参数验证
  10022. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10023. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10024. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10025. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10026. #region 页面操作权限验证
  10027. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10028. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10029. #endregion
  10030. #endregion
  10031. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10032. if (viewData.Code != 0)
  10033. {
  10034. return Ok(JsonView(false, viewData.Msg));
  10035. }
  10036. return Ok(JsonView(viewData.Data));
  10037. }
  10038. /// <summary>
  10039. /// 接团客户名单
  10040. /// Add Or Edit
  10041. /// </summary>
  10042. /// <param name="_dto"></param>
  10043. /// <returns></returns>
  10044. [HttpPost]
  10045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10046. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10047. {
  10048. #region 参数验证
  10049. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10050. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10051. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10052. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10053. #region 页面操作权限验证
  10054. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10055. if (_dto.Id == 0) //添加
  10056. {
  10057. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10058. }
  10059. else if (_dto.Id >= 0) //修改
  10060. {
  10061. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10062. }
  10063. #endregion
  10064. #endregion
  10065. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10066. if (viewData.Code != 0)
  10067. {
  10068. return Ok(JsonView(false, viewData.Msg));
  10069. }
  10070. return Ok(JsonView(true));
  10071. }
  10072. /// <summary>
  10073. /// 接团客户名单
  10074. /// AddMultiple(添加多个)
  10075. /// </summary>
  10076. /// <param name="_dto"></param>
  10077. /// <returns></returns>
  10078. [HttpPost]
  10079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10080. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10081. {
  10082. #region 参数验证
  10083. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10084. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10085. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10086. #region 页面操作权限验证
  10087. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10088. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10089. #endregion
  10090. #endregion
  10091. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10092. if (viewData.Code != 0)
  10093. {
  10094. return Ok(JsonView(false, viewData.Msg));
  10095. }
  10096. return Ok(JsonView(true));
  10097. }
  10098. /// <summary>
  10099. /// 接团客户名单
  10100. /// Del
  10101. /// </summary>
  10102. /// <param name="_dto"></param>
  10103. /// <returns></returns>
  10104. [HttpPost]
  10105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10106. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10107. {
  10108. #region 参数验证
  10109. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10110. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10111. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10112. #region 页面操作权限验证
  10113. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10114. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10115. #endregion
  10116. #endregion
  10117. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10118. if (viewData.Code != 0)
  10119. {
  10120. return Ok(JsonView(false, viewData.Msg));
  10121. }
  10122. return Ok(JsonView(true));
  10123. }
  10124. /// <summary>
  10125. /// 接团客户名单
  10126. /// 文件下载 客户名单
  10127. /// </summary>
  10128. /// <param name="_dto"></param>
  10129. /// <returns></returns>
  10130. [HttpPost]
  10131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10132. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10133. {
  10134. #region 参数验证
  10135. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10136. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10137. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10138. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10139. #region 页面操作权限验证
  10140. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10141. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10142. #endregion
  10143. #endregion
  10144. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10145. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10146. From Grp_TourClientList tcl
  10147. Left Join
  10148. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10149. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10150. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10151. From Crm_DeleClient dc
  10152. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10153. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10154. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10155. Where dc.IsDel = 0) temp
  10156. On temp.DcId =tcl.ClientId
  10157. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10158. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10159. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10160. //载入模板
  10161. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10162. if (_dto.Language == 1)
  10163. {
  10164. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10165. }
  10166. //载入模板
  10167. var doc = new Document(tempPath);
  10168. DocumentBuilder builder = new DocumentBuilder(doc);
  10169. //获取word里所有表格
  10170. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10171. //获取所填表格的序数
  10172. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10173. var rowStart = tableOne.Rows[0]; //获取第1行
  10174. if (_dto.Language == 0)
  10175. {
  10176. //循环赋值
  10177. for (int i = 0; i < DcList.Count; i++)
  10178. {
  10179. builder.MoveToCell(0, i + 1, 0, 0);
  10180. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10181. builder.MoveToCell(0, i + 1, 1, 0);
  10182. int sex = DcList[i].Sex;
  10183. string sexStr = string.Empty;
  10184. if (sex == 0) sexStr = "男";
  10185. else if (sex == 1) sexStr = "女";
  10186. else sexStr = "未设置";
  10187. builder.Write(sexStr);
  10188. builder.MoveToCell(0, i + 1, 2, 0);
  10189. string birthDay = DcList[i].BirthDay;
  10190. string birthDayStr = string.Empty;
  10191. if (!string.IsNullOrEmpty(birthDay))
  10192. {
  10193. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10194. }
  10195. builder.Write(birthDayStr);
  10196. builder.MoveToCell(0, i + 1, 3, 0);
  10197. string company = "";
  10198. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10199. {
  10200. company = DcList[i].CompanyFullName.ToString();
  10201. }
  10202. builder.Write(company);
  10203. builder.MoveToCell(0, i + 1, 4, 0);
  10204. builder.Write(DcList[i].Job);
  10205. }
  10206. }
  10207. else if (_dto.Language == 1)
  10208. {
  10209. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10210. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10211. //循环赋值
  10212. for (int i = 0; i < DcList.Count; i++)
  10213. {
  10214. string PYName = "";
  10215. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10216. {
  10217. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10218. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10219. PYName = PY_First + " " + PY_Last;
  10220. }
  10221. else
  10222. {
  10223. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10224. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10225. PYName = PY_First + " " + PY_Last;
  10226. }
  10227. builder.MoveToCell(0, i + 1, 0, 0);
  10228. builder.Write(PYName);
  10229. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10230. builder.MoveToCell(0, i + 1, 1, 0);
  10231. builder.Write(sex);
  10232. DateTime birthDt;
  10233. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10234. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  10235. builder.MoveToCell(0, i + 1, 2, 0);
  10236. builder.Write(birthday);
  10237. string company = "";
  10238. try
  10239. {
  10240. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10241. {
  10242. //查询对照表
  10243. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10244. if (tempCec != null)
  10245. {
  10246. company = tempCec.enName;
  10247. }
  10248. //翻译
  10249. else
  10250. {
  10251. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  10252. }
  10253. }
  10254. }
  10255. catch (Exception)
  10256. {
  10257. }
  10258. builder.MoveToCell(0, i + 1, 3, 0);
  10259. builder.Write(company);
  10260. string job = "";
  10261. try
  10262. {
  10263. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10264. {
  10265. //查询对照表
  10266. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10267. if (tempPec != null)
  10268. {
  10269. job = tempPec.enName;
  10270. }
  10271. //翻译
  10272. else
  10273. {
  10274. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  10275. }
  10276. }
  10277. }
  10278. catch (Exception ex)
  10279. {
  10280. }
  10281. builder.MoveToCell(0, i + 1, 4, 0);
  10282. builder.Write(job);
  10283. }
  10284. }
  10285. //删除多余行
  10286. while (tableOne.Rows.Count > DcList.Count + 1)
  10287. {
  10288. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10289. }
  10290. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10291. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10292. doc.Save(fileDir);
  10293. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10294. return Ok(JsonView(true, "操作成功!", Url));
  10295. }
  10296. #endregion
  10297. #region 团组倒推表
  10298. /// <summary>
  10299. /// 倒推表基础数据
  10300. /// Init
  10301. /// </summary>
  10302. /// <param name="dto"></param>
  10303. /// <returns></returns>
  10304. [HttpPost]
  10305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10306. public async Task<IActionResult> PostInvertedListInit()
  10307. {
  10308. var viewData = await _invertedListRep._Init();
  10309. if (viewData.Code != 0)
  10310. {
  10311. return Ok(JsonView(false, viewData.Msg));
  10312. }
  10313. return Ok(JsonView(viewData.Data));
  10314. }
  10315. /// <summary>
  10316. /// 倒推表
  10317. /// Info
  10318. /// </summary>
  10319. /// <param name="dto"></param>
  10320. /// <returns></returns>
  10321. [HttpPost]
  10322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10323. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10324. {
  10325. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10326. if (viewData.Code != 0)
  10327. {
  10328. return Ok(JsonView(false, viewData.Msg));
  10329. }
  10330. return Ok(JsonView(viewData.Data));
  10331. }
  10332. /// <summary>
  10333. /// 倒推表
  10334. /// Create
  10335. /// </summary>
  10336. /// <param name="dto"></param>
  10337. /// <returns></returns>
  10338. [HttpPost]
  10339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10340. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  10341. {
  10342. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  10343. if (viewData.Code != 0)
  10344. {
  10345. return Ok(JsonView(false, viewData.Msg));
  10346. }
  10347. return Ok(JsonView(viewData.Data));
  10348. }
  10349. /// <summary>
  10350. /// 倒推表
  10351. /// Update
  10352. /// </summary>
  10353. /// <param name="dto"></param>
  10354. /// <returns></returns>
  10355. [HttpPost]
  10356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10357. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  10358. {
  10359. var viewData = await _invertedListRep._Update(dto);
  10360. if (viewData.Code != 0)
  10361. {
  10362. return Ok(JsonView(false, viewData.Msg));
  10363. }
  10364. return Ok(JsonView(viewData.Data));
  10365. }
  10366. /// <summary>
  10367. /// 倒推表
  10368. /// File Download
  10369. /// </summary>
  10370. /// <param name="dto"></param>
  10371. /// <returns></returns>
  10372. [HttpPost]
  10373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10374. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  10375. {
  10376. var info2 = await _invertedListRep._Info(1, dto.DiId);
  10377. if (info2.Code != 0)
  10378. {
  10379. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  10380. }
  10381. var info1 = info2.Data as InvertedListInfoView;
  10382. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  10383. string teamName = "";
  10384. if (info != null) teamName = info.TeamName;
  10385. //载入模板
  10386. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10387. DocumentBuilder builder = new DocumentBuilder(doc);
  10388. //利用键值对存放数据
  10389. Dictionary<string, string> dic = new Dictionary<string, string>();
  10390. dic.Add("TeamName", teamName);
  10391. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10392. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10393. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10394. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10395. dic.Add("SQRemark", info1.ApprovalRemark);
  10396. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10397. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10398. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10399. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10400. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10401. dic.Add("QZRemark", info1.VisaInformationRemark);
  10402. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10403. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10404. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10405. dic.Add("CQRemark", info1.IssueVisaRemark);
  10406. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10407. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10408. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10409. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10410. #region 填充word模板书签内容
  10411. foreach (var key in dic.Keys)
  10412. {
  10413. builder.MoveToBookmark(key);
  10414. builder.Write(dic[key]);
  10415. }
  10416. #endregion
  10417. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10418. string fileName = $"{teamName}团出行准备流程表.doc";
  10419. string filePath = fileDir + $@"InvertedList/{fileName}";
  10420. doc.Save(filePath);
  10421. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10422. return Ok(JsonView(true, "操作成功!", Url));
  10423. }
  10424. #endregion
  10425. #region 三公签证费用(签证费、代办费)
  10426. /// <summary>
  10427. /// 三公签证费用(签证费、代办费)
  10428. /// List
  10429. /// </summary>
  10430. /// <returns></returns>
  10431. [HttpPost]
  10432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10433. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10434. {
  10435. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10436. if (_view.Code != 0)
  10437. {
  10438. return Ok(JsonView(false, _view.Msg));
  10439. }
  10440. return Ok(JsonView(true, "操作成功!", _view.Data));
  10441. }
  10442. /// <summary>
  10443. /// 三公签证费用(签证费、代办费)
  10444. /// Add Or Update
  10445. /// </summary>
  10446. /// <returns></returns>
  10447. [HttpPost]
  10448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10449. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10450. {
  10451. var _view = await _visaFeeInfoRep._Update(_dto);
  10452. if (_view.Code != 0)
  10453. {
  10454. return Ok(JsonView(false, _view.Msg));
  10455. }
  10456. return Ok(JsonView(true, _view.Msg));
  10457. }
  10458. #endregion
  10459. #region 酒店询价
  10460. /// <summary>
  10461. /// 酒店询价
  10462. /// Init
  10463. /// </summary>
  10464. /// <param name="dto"></param>
  10465. /// <returns></returns>
  10466. [HttpPost]
  10467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10468. public async Task<IActionResult> PostHotelInquiryInit()
  10469. {
  10470. var res = await _hotelInquiryRep._Init();
  10471. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10472. return Ok(JsonView(true, res.Msg, res.Data));
  10473. }
  10474. /// <summary>
  10475. /// 酒店询价
  10476. /// page Item
  10477. /// </summary>
  10478. /// <param name="_dto"></param>
  10479. /// <returns></returns>
  10480. [HttpPost]
  10481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10482. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10483. {
  10484. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex,_dto.PageSize,_dto.PortType,_dto.DiId);
  10485. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10486. var view = res.Data as PageDataViewBase;
  10487. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10488. }
  10489. /// <summary>
  10490. /// 酒店询价
  10491. /// info
  10492. /// </summary>
  10493. /// <param name="_dto"></param>
  10494. /// <returns></returns>
  10495. [HttpPost]
  10496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10497. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10498. {
  10499. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10500. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10501. return Ok(JsonView(true, res.Msg, res.Data));
  10502. }
  10503. /// <summary>
  10504. /// 酒店询价
  10505. /// Add Or Edit
  10506. /// </summary>
  10507. /// <param name="_dto"></param>
  10508. /// <returns></returns>
  10509. [HttpPost]
  10510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10511. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10512. {
  10513. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10514. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10515. return Ok(JsonView(true, res.Msg, res.Data));
  10516. }
  10517. /// <summary>
  10518. /// 酒店询价
  10519. /// Del
  10520. /// </summary>
  10521. /// <param name="_dto"></param>
  10522. /// <returns></returns>
  10523. [HttpPost]
  10524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10525. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10526. {
  10527. var res = await _hotelInquiryRep._Del(_dto.Id,_dto.DeleteUserId);
  10528. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10529. return Ok(JsonView(true, res.Msg, res.Data));
  10530. }
  10531. #endregion
  10532. // /// <summary>
  10533. // ///
  10534. // /// </summary>
  10535. // /// <param name="_dto"></param>
  10536. // /// <returns></returns>
  10537. // [HttpPost]
  10538. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10539. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  10540. // {
  10541. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  10542. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  10543. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  10544. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  10545. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  10546. // dic_psg.Add("客人", 974);
  10547. // dic_psg.Add("司机", 975);
  10548. // dic_psg.Add("导游", 976);
  10549. // dic_psg.Add("公司内部人员", 977);
  10550. // dic_psg.Add("司机/导游/公司内部人员", 978);
  10551. // foreach (var item in list_visa)
  10552. // {
  10553. // Grp_VisaInfo temp = new Grp_VisaInfo();
  10554. // temp.Id = item.Id;
  10555. // temp.DIId = item.DIId;
  10556. // temp.VisaClient = item.VisaClient;
  10557. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  10558. // temp.VisaCurrency = item.VisaCurrency;
  10559. // temp.IsThird = item.IsThird;
  10560. // if (dic_psg.ContainsKey(item.PassengerType))
  10561. // {
  10562. // temp.PassengerType = dic_psg[item.PassengerType];
  10563. // }
  10564. // else {
  10565. // temp.PassengerType = -1;
  10566. // }
  10567. // temp.VisaNumber = item.VisaNumber;
  10568. // temp.VisaFreeNumber = item.VisaFreeNumber;
  10569. // temp.CreateUserId = item.Operators;
  10570. // DateTime dt_ct;
  10571. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  10572. // if (b_ct)
  10573. // {
  10574. // temp.CreateTime = dt_ct;
  10575. // }
  10576. // else
  10577. // {
  10578. // temp.CreateTime = DateTime.Now;
  10579. // }
  10580. // temp.DeleteTime = "";
  10581. // temp.DeleteUserId = 0;
  10582. // temp.Remark = item.Remark;
  10583. // if (string.IsNullOrEmpty(temp.Remark)) {
  10584. // temp.Remark = "";
  10585. // }
  10586. // temp.IsDel = item.IsDel;
  10587. // temp.VisaDescription = item.VisaAttachment;
  10588. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  10589. //([Id]
  10590. // ,[DIId]
  10591. // ,[VisaClient]
  10592. // ,[VisaPrice]
  10593. // ,[VisaCurrency]
  10594. // ,[IsThird]
  10595. // ,[PassengerType]
  10596. // ,[VisaNumber]
  10597. // ,[VisaFreeNumber]
  10598. // ,[CreateUserId]
  10599. // ,[CreateTime]
  10600. // ,[DeleteTime]
  10601. // ,[DeleteUserId]
  10602. // ,[Remark]
  10603. // ,[IsDel]
  10604. // ,[visaDescription])
  10605. // VALUES
  10606. // ({0},{1},'{2}',{3},{4}
  10607. //,{5},{6},{7},{8},{9}
  10608. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  10609. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  10610. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  10611. //);
  10612. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  10613. // }
  10614. // return Ok(JsonView(true, "操作成功!"));
  10615. // }
  10616. /// <summary>
  10617. /// 123132123
  10618. /// </summary>
  10619. /// <param name="_dto"></param>
  10620. /// <returns></returns>
  10621. [HttpPost]
  10622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10623. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  10624. {
  10625. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  10626. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  10627. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  10628. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  10629. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  10630. dicDetail.Add(789, 1034);
  10631. dicDetail.Add(790, 1035);
  10632. dicDetail.Add(791, 1036);
  10633. dicDetail.Add(792, 1037);
  10634. dicDetail.Add(793, 1038);
  10635. dicDetail.Add(794, 1039);
  10636. dicDetail.Add(795, 1040);
  10637. dicDetail.Add(796, 1041);
  10638. dicDetail.Add(797, 1042);
  10639. dicDetail.Add(798, 1043);
  10640. dicDetail.Add(801, 1044);
  10641. dicDetail.Add(802, 1045);
  10642. dicDetail.Add(803, 1046);
  10643. Dictionary<int, int> dic = new Dictionary<int, int>();
  10644. dic.Add(806, 1027);
  10645. dic.Add(807, 1028);
  10646. dic.Add(808, 1029);
  10647. dic.Add(809, 1030);
  10648. dic.Add(810, 1031);
  10649. dic.Add(811, 1032);
  10650. dic.Add(812, 1033);
  10651. foreach (var item in list_visa)
  10652. {
  10653. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  10654. temp.Coefficient = item.coefficient;
  10655. DateTime dtCrt;
  10656. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  10657. if (b1)
  10658. {
  10659. temp.CreateTime = dtCrt;
  10660. }
  10661. else
  10662. {
  10663. temp.CreateTime = DateTime.Now;
  10664. }
  10665. temp.CreateUserId = item.Operators;
  10666. temp.DeleteTime = "";
  10667. temp.DeleteUserId = 0;
  10668. temp.DiId = int.Parse(item.DIID);
  10669. temp.FilePath = item.FilePath;
  10670. temp.IsDel = item.IsDel;
  10671. temp.Price = item.Price;
  10672. temp.PriceCount = 1;
  10673. temp.PriceCurrency = item.Currency;
  10674. int detailId = 0;
  10675. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  10676. {
  10677. detailId = dicDetail[item.PriceTypeDetail];
  10678. }
  10679. temp.PriceDetailType = detailId;
  10680. temp.PriceDt = DateTime.Now;
  10681. temp.PriceName = item.PriceName;
  10682. temp.PriceSum = item.Price;
  10683. int tid = 0;
  10684. if (dic.ContainsKey(item.PriceType))
  10685. {
  10686. tid = dic[item.PriceType];
  10687. }
  10688. temp.PriceType = tid;
  10689. temp.Remark = item.Remark;
  10690. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  10691. }
  10692. return Ok(JsonView(true, "操作成功!"));
  10693. }
  10694. }
  10695. }