GroupsController.cs 415 KB

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