GroupsController.cs 611 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. using System.Collections;
  32. using Org.BouncyCastle.Ocsp;
  33. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. using Microsoft.AspNetCore.Mvc.ViewEngines;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.Entities.Financial;
  41. using NPOI.POIFS.Crypt.Dsig;
  42. using System.Diagnostics.Eventing.Reader;
  43. using System.IO;
  44. using StackExchange.Redis;
  45. using Org.BouncyCastle.Utilities;
  46. using Aspose.Words.Drawing;
  47. using Aspose.Cells.Charts;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using Quartz.Util;
  50. using Google.Protobuf.WellKnownTypes;
  51. using Microsoft.AspNetCore.SignalR;
  52. using OASystem.API.OAMethodLib.Hub.HubClients;
  53. using OASystem.API.OAMethodLib.Hub.Hubs;
  54. using System.Collections.Generic;
  55. using OASystem.API.OAMethodLib.JuHeAPI;
  56. using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
  57. using SixLabors.Fonts.Tables.AdvancedTypographic;
  58. using Microsoft.EntityFrameworkCore;
  59. using System.Security.Cryptography.Xml;
  60. using MathNet.Numerics;
  61. using System.Security.Policy;
  62. using System.Xml;
  63. using OASystem.Domain.Dtos.QiYeWeChat;
  64. using static NPOI.POIFS.Crypt.CryptoFunctions;
  65. using Aspose.Words.Lists;
  66. using OASystem.API.OAMethodLib.YouDaoAPI;
  67. using NPOI.XSSF.Streaming.Values;
  68. using OASystem.API.OAMethodLib.Quartz.Business;
  69. using System.Linq;
  70. using NPOI.POIFS.NIO;
  71. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  72. using OASystem.Domain.ViewModels.Statistics;
  73. using NPOI.XSSF.Model;
  74. using NetTaste;
  75. using Microsoft.AspNetCore.Http;
  76. using EyeSoft.Collections.Generic;
  77. using NPOI.HSSF.Util;
  78. using NPOI.HSSF.UserModel;
  79. using NPOI.SS.UserModel;
  80. using NPOI.XSSF.UserModel;
  81. using MySqlX.XDevAPI.Relational;
  82. using SqlSugar.Extensions;
  83. using Table = Aspose.Words.Tables.Table;
  84. using Aspose.Cells.Tables;
  85. using NPOI.SS.Util;
  86. using RestSharp.Extensions;
  87. using Microsoft.AspNetCore.WebUtilities;
  88. using K4os.Compression.LZ4.Internal;
  89. using static Pipelines.Sockets.Unofficial.SocketConnection;
  90. using System.Diagnostics.PerformanceData;
  91. using System.Drawing.Printing;
  92. namespace OASystem.API.Controllers
  93. {
  94. /// <summary>
  95. /// 团组相关
  96. /// </summary>
  97. //[Authorize]
  98. [Route("api/[controller]/[action]")]
  99. public class GroupsController : ControllerBase
  100. {
  101. private readonly GrpScheduleRepository _grpScheduleRep;
  102. private readonly IMapper _mapper;
  103. private readonly DelegationInfoRepository _groupRepository;
  104. private readonly TaskAssignmentRepository _taskAssignmentRep;
  105. private readonly AirTicketResRepository _airTicketResRep;
  106. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  107. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  108. private readonly DelegationEnDataRepository _delegationEnDataRep;
  109. private readonly DelegationVisaRepository _delegationVisaRep;
  110. private readonly VisaPriceRepository _visaPriceRep;
  111. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  112. private readonly HotelPriceRepository _hotelPriceRep;
  113. private readonly CustomersRepository _customersRep;
  114. private readonly MessageRepository _message;
  115. private readonly SqlSugarClient _sqlSugar;
  116. private readonly TourClientListRepository _tourClientListRep;
  117. private readonly TeamRateRepository _teamRateRep;
  118. #region 成本相关
  119. private readonly CheckBoxsRepository _checkBoxs;
  120. private readonly GroupCostRepository _GroupCostRepository;
  121. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  122. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  123. #endregion
  124. private readonly SetDataRepository _setDataRep;
  125. private string url;
  126. private string path;
  127. private readonly EnterExitCostRepository _enterExitCostRep;
  128. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  129. private readonly UsersRepository _usersRep;
  130. private readonly IJuHeApiService _juHeApi;
  131. private readonly InvertedListRepository _invertedListRep;
  132. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  133. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  134. private readonly ThreeCodeRepository _threeCodeRepository;
  135. private readonly HotelInquiryRepository _hotelInquiryRep;
  136. private readonly FeeAuditRepository _feeAuditRep;
  137. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  138. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  139. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  140. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  141. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  142. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  143. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  144. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  145. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep)
  146. {
  147. _mapper = mapper;
  148. _grpScheduleRep = grpScheduleRep;
  149. _groupRepository = groupRepository;
  150. _taskAssignmentRep = taskAssignmentRep;
  151. _airTicketResRep = airTicketResRep;
  152. _sqlSugar = sqlSugar;
  153. url = AppSettingsHelper.Get("ExcelBaseUrl");
  154. path = AppSettingsHelper.Get("ExcelBasePath");
  155. if (!System.IO.Directory.Exists(path))
  156. {
  157. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  158. }
  159. _decreasePaymentsRep = decreasePaymentsRep;
  160. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  161. _delegationEnDataRep = delegationEnDataRep;
  162. _enterExitCostRep = enterExitCostRep;
  163. _delegationVisaRep = delegationVisaRep;
  164. _message = message;
  165. _visaPriceRep = visaPriceRep;
  166. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  167. _checkBoxs = checkBoxs;
  168. _GroupCostRepository = GroupCostRepository;
  169. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  170. _GroupCostParameterRepository = GroupCostParameterRepository;
  171. _hotelPriceRep = hotelPriceRep;
  172. _customersRep = customersRep;
  173. _setDataRep = setDataRep;
  174. _tourClientListRep = tourClientListRep;
  175. _teamRateRep = teamRateRep;
  176. _hubContext = hubContext;
  177. _usersRep = usersRep;
  178. _juHeApi = juHeApi;
  179. _invertedListRep = invertedListRep;
  180. _visaFeeInfoRep = visaFeeInfoRep;
  181. _ticketBlackCodeRep = ticketBlackCodeRep;
  182. _hotelInquiryRep = hotelInquiryRep;
  183. _threeCodeRepository = threeCodeRepository;
  184. _feeAuditRep = feeAuditRep;
  185. }
  186. #region 流程管控
  187. /// <summary>
  188. /// 获取团组流程管控信息
  189. /// </summary>
  190. /// <param name="paras">参数Json字符串</param>
  191. /// <returns></returns>
  192. [HttpPost]
  193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  194. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  195. {
  196. if (string.IsNullOrEmpty(_jsonDto.Paras))
  197. {
  198. return Ok(JsonView(false, "参数为空"));
  199. }
  200. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  201. if (_ScheduleDto != null)
  202. {
  203. if (_ScheduleDto.SearchType == 2)//获取列表
  204. {
  205. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  206. return Ok(JsonView(_grpScheduleViewList));
  207. }
  208. else//获取对象
  209. {
  210. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  211. if (_grpScheduleView != null)
  212. {
  213. return Ok(JsonView(_grpScheduleView));
  214. }
  215. }
  216. }
  217. else
  218. {
  219. return Ok(JsonView(false, "参数反序列化失败"));
  220. }
  221. return Ok(JsonView(false, "暂无数据!"));
  222. }
  223. /// <summary>
  224. /// 修改团组流程管控详细表数据
  225. /// </summary>
  226. /// <param name="paras"></param>
  227. /// <returns></returns>
  228. [HttpPost]
  229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  230. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  231. {
  232. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  233. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  234. .SetColumns(it => it.Duty == _detail.Duty)
  235. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  236. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  237. .SetColumns(it => it.JobContent == _detail.JobContent)
  238. .SetColumns(it => it.Remark == _detail.Remark)
  239. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  240. .Where(s => s.Id == dto.Id)
  241. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  242. .ExecuteCommandAsync();
  243. if (result > 0)
  244. {
  245. return Ok(JsonView(true, "保存成功!"));
  246. }
  247. return Ok(JsonView(false, "保存失败!"));
  248. }
  249. /// <summary>
  250. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  251. /// </summary>
  252. /// <param name="dto"></param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  256. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  257. {
  258. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  259. _detail.IsDel = 1;
  260. _detail.DeleteUserId = dto.Duty;
  261. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  262. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  263. .SetColumns(it => it.IsDel == _detail.IsDel)
  264. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  265. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  266. .Where(it => it.Id == dto.Id)
  267. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  268. //.WhereColumns(s => s.Id == dto.Id)
  269. .ExecuteCommandAsync();
  270. if (result > 0)
  271. {
  272. return Ok(JsonView(true, "删除成功!"));
  273. }
  274. return Ok(JsonView(false, "删除失败!"));
  275. }
  276. /// <summary>
  277. /// 增加团组流程管控详细表数据
  278. /// </summary>
  279. /// <param name="dto"></param>
  280. /// <returns></returns>
  281. [HttpPost]
  282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  283. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  284. {
  285. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  286. if (DateTime.Now < _detail.ExpectBeginDt)
  287. {
  288. _detail.StepStatus = 0;
  289. }
  290. else
  291. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  292. _detail.StepStatus = 1;
  293. }
  294. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  295. if (result > 0)
  296. {
  297. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  298. return Ok(JsonView(true, "添加成功!", _result));
  299. }
  300. return Ok(JsonView(false, "添加失败!"));
  301. }
  302. #endregion
  303. #region 团组基本信息
  304. /// <summary>
  305. /// 接团信息列表
  306. /// </summary>
  307. /// <param name="dto">团组列表请求dto</param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  312. {
  313. var groupData = await _groupRepository.GetGroupList(dto);
  314. if (groupData.Code != 0)
  315. {
  316. return Ok(JsonView(false, groupData.Msg));
  317. }
  318. return Ok(JsonView(groupData.Data));
  319. }
  320. /// <summary>
  321. /// 接团信息列表 Page
  322. /// </summary>
  323. /// <param name="dto">团组列表请求dto</param>
  324. /// <returns></returns>
  325. [HttpPost]
  326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  327. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  328. {
  329. #region 参数验证
  330. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  331. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  332. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  333. #region 页面操作权限验证
  334. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  335. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  336. #endregion
  337. #endregion
  338. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  339. {
  340. string sqlWhere = string.Empty;
  341. if (dto.IsSure == 0) //未完成
  342. {
  343. sqlWhere += string.Format(@" And IsSure = 0");
  344. }
  345. else if (dto.IsSure == 1) //已完成
  346. {
  347. sqlWhere += string.Format(@" And IsSure = 1");
  348. }
  349. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  350. {
  351. string tj = dto.SearchCriteria;
  352. 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}%')",
  353. tj, tj, tj, tj, tj);
  354. }
  355. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  356. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  357. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  358. JietuanOperator,IsSure,CreateTime
  359. From (
  360. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  361. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  362. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  363. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  364. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  365. From Grp_DelegationInfo gdi
  366. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  367. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  368. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  369. Where gdi.IsDel = 0 {0}
  370. ) temp", sqlWhere);
  371. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  372. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  373. #region 处理所属部门
  374. /*
  375. * 1.sq 和 gyy 等显示 市场部
  376. * 2.王鸽和主管及张总还有管理员号统一国交部
  377. * 2-1. 4 管理员 ,21 张海麟
  378. */
  379. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  380. List<int> userIds1 = new List<int>() { 4, 21 };
  381. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  382. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  383. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  384. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  385. .ToList();
  386. foreach (var item in _DelegationList)
  387. {
  388. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  389. }
  390. #endregion
  391. var _view = new
  392. {
  393. PageFuncAuth = pageFunAuthView,
  394. Data = _DelegationList
  395. };
  396. return Ok(JsonView(true, "查询成功!", _view, total));
  397. }
  398. else
  399. {
  400. return Ok(JsonView(false, "查询失败"));
  401. }
  402. }
  403. /// <summary>
  404. /// 团组列表
  405. /// </summary>
  406. /// <returns></returns>
  407. [HttpPost]
  408. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  409. {
  410. #region 参数验证
  411. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  412. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  413. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  414. #region 页面操作权限验证
  415. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  416. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  417. #endregion
  418. #endregion
  419. if (dto.PortType != 1 && dto.PortType != 2)
  420. {
  421. return Ok(JsonView(false, "查询失败!"));
  422. }
  423. string orderbyStr = "order by gdi.CreateTime Desc";
  424. string sqlWhere = string.Empty;
  425. if (dto.IsSure == 0) //未完成
  426. {
  427. sqlWhere += string.Format(@" And IsSure = 0");
  428. }
  429. else if (dto.IsSure == 1) //已完成
  430. {
  431. sqlWhere += string.Format(@" And IsSure = 1");
  432. }
  433. //团组类型
  434. if (dto.TeamDid > 0)
  435. {
  436. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  437. }
  438. //团组名称
  439. if (!string.IsNullOrEmpty(dto.TeamName))
  440. {
  441. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  442. }
  443. //客户名称
  444. if (!string.IsNullOrEmpty(dto.ClientName))
  445. {
  446. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  447. }
  448. //客户单位
  449. if (!string.IsNullOrEmpty(dto.ClientUnit))
  450. {
  451. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  452. }
  453. //出访时间
  454. if (!string.IsNullOrEmpty(dto.visitDataTime))
  455. {
  456. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  457. orderbyStr = "order by gdi.VisitDate";
  458. }
  459. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  460. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  461. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  462. JietuanOperator,IsSure,CreateTime
  463. From (
  464. Select row_number() over({0}) as Row_Number,
  465. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  466. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  467. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  468. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  469. From Grp_DelegationInfo gdi
  470. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  471. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  472. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  473. Where gdi.IsDel = 0 {1}
  474. ) temp ", orderbyStr, sqlWhere);
  475. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  476. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  477. #region 处理所属部门
  478. /*
  479. * 1.sq 和 gyy 等显示 市场部
  480. * 2.王鸽和主管及张总还有管理员号统一国交部
  481. * 2-1. 4 管理员 ,21 张海麟
  482. */
  483. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  484. List<int> userIds1 = new List<int>() { 4, 21 };
  485. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  486. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  487. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  488. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  489. .ToList();
  490. foreach (var item in _DelegationList)
  491. {
  492. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  493. }
  494. #endregion
  495. var _view = new
  496. {
  497. PageFuncAuth = pageFunAuthView,
  498. Data = _DelegationList
  499. };
  500. return Ok(JsonView(true, "查询成功!", _view, total));
  501. }
  502. /// <summary>
  503. /// 接团信息详情
  504. /// </summary>
  505. /// <param name="dto">团组info请求dto</param>
  506. /// <returns></returns>
  507. [HttpPost]
  508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  509. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  510. {
  511. var groupData = await _groupRepository.GetGroupInfo(dto);
  512. if (groupData.Code != 0)
  513. {
  514. return Ok(JsonView(false, groupData.Msg));
  515. }
  516. return Ok(JsonView(groupData.Data));
  517. }
  518. /// <summary>
  519. /// 接团信息 编辑添加
  520. /// 基础信息数据源
  521. /// </summary>
  522. /// <param name="dto"></param>
  523. /// <returns></returns>
  524. [HttpPost]
  525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  526. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  527. {
  528. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  529. if (groupData.Code != 0)
  530. {
  531. return Ok(JsonView(false, groupData.Msg));
  532. }
  533. return Ok(JsonView(groupData.Data));
  534. }
  535. /// <summary>
  536. /// 接团信息 操作(增改)
  537. /// </summary>
  538. /// <param name="dto"></param>
  539. /// <returns></returns>
  540. [HttpPost]
  541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  542. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  543. {
  544. try
  545. {
  546. var groupData = await _groupRepository.GroupOperation(dto);
  547. if (groupData.Code != 0)
  548. {
  549. return Ok(JsonView(false, groupData.Msg));
  550. }
  551. int diId = 0;
  552. //添加时 默认加入团组汇率
  553. if (dto.Status == 1) //添加
  554. {
  555. diId = groupData.Data;
  556. //添加默认币种
  557. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  558. //默认分配权限
  559. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  560. //消息提示 王鸽 主管号
  561. List<int> _managerIds = new List<int>() { 22, 32 };
  562. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  563. if (userIds.Count > 0)
  564. {
  565. userIds.Add(208);
  566. //创建团组管控
  567. GroupStepForDelegation.CreateWorkStep(diId);
  568. //发送消息
  569. string groupName = dto.TeamName;
  570. string createGroupUser = string.Empty;
  571. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  572. if (userInfo != null) createGroupUser = userInfo.CnName;
  573. string title = $"系统通知";
  574. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  575. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  576. }
  577. //默认创建倒推表
  578. await _invertedListRep._Create(dto.UserId, diId);
  579. }
  580. else if (dto.Status == 2)
  581. {
  582. diId = dto.Id;
  583. }
  584. return Ok(JsonView(true, "操作成功!", diId));
  585. }
  586. catch (Exception ex)
  587. {
  588. Logs("[response]" + JsonConvert.SerializeObject(dto));
  589. Logs(ex.Message);
  590. return Ok(JsonView(false, ex.Message));
  591. }
  592. }
  593. /// <summary>
  594. /// 接团流程操作(增改)
  595. /// 安卓端使用 建团时添加客户名单
  596. /// </summary>
  597. /// <param name="dto"></param>
  598. /// <returns></returns>
  599. [HttpPost]
  600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  601. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  602. {
  603. try
  604. {
  605. #region 参数验证
  606. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  607. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  608. #region 页面操作权限验证
  609. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  610. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  611. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  612. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  613. #endregion
  614. #endregion
  615. _sqlSugar.BeginTran();
  616. var _dto = new GroupOperationDto();
  617. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  618. var groupData = await _groupRepository.GroupOperation(_dto);
  619. if (groupData.Code != 0)
  620. {
  621. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  622. }
  623. int diId = 0;
  624. //添加时 默认加入团组汇率
  625. if (dto.Status == 1) //添加
  626. {
  627. diId = groupData.Data;
  628. //添加默认币种
  629. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  630. //默认分配权限
  631. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  632. //消息提示 王鸽 主管号
  633. List<int> _managerIds = new List<int>() { 22, 32 };
  634. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  635. if (userIds.Count > 0)
  636. {
  637. userIds.Add(208);
  638. //创建团组管控
  639. GroupStepForDelegation.CreateWorkStep(diId);
  640. //发送消息
  641. string groupName = dto.TeamName;
  642. string createGroupUser = string.Empty;
  643. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  644. if (userInfo != null) createGroupUser = userInfo.CnName;
  645. string title = $"系统通知";
  646. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  647. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  648. }
  649. }
  650. if (dto.Status == 2)
  651. {
  652. diId = dto.Id;
  653. if (diId == 0)
  654. {
  655. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  656. }
  657. }
  658. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  659. if (viewData.Code != 0)
  660. {
  661. _sqlSugar.RollbackTran();
  662. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  663. }
  664. _sqlSugar.CommitTran();
  665. return Ok(JsonView(true, "添加成功"));
  666. }
  667. catch (Exception ex)
  668. {
  669. _sqlSugar.RollbackTran();
  670. return Ok(JsonView(false, ex.Message));
  671. }
  672. }
  673. /// <summary>
  674. /// 接团信息 操作(删除)
  675. /// </summary>
  676. /// <param name="dto"></param>
  677. /// <returns></returns>
  678. [HttpPost]
  679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  680. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  681. {
  682. try
  683. {
  684. var groupData = await _groupRepository.GroupDel(dto);
  685. if (groupData.Code != 0)
  686. {
  687. return Ok(JsonView(false, groupData.Msg));
  688. }
  689. return Ok(JsonView(true));
  690. }
  691. catch (Exception ex)
  692. {
  693. Logs("[response]" + JsonConvert.SerializeObject(dto));
  694. Logs(ex.Message);
  695. return Ok(JsonView(false, ex.Message));
  696. }
  697. }
  698. /// <summary>
  699. /// 获取团组销售报价号
  700. /// 团组添加时 使用
  701. /// </summary>
  702. /// <returns></returns>
  703. [HttpPost]
  704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  705. public async Task<IActionResult> GetGroupSalesQuoteNo()
  706. {
  707. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  708. if (groupData.Code != 0)
  709. {
  710. return Ok(JsonView(false, groupData.Msg));
  711. }
  712. object salesQuoteNo = new
  713. {
  714. SalesQuoteNo = groupData.Data
  715. };
  716. return Ok(JsonView(salesQuoteNo));
  717. }
  718. /// <summary>
  719. /// 设置确认出团
  720. /// </summary>
  721. /// <param name="dto"></param>
  722. /// <returns></returns>
  723. [HttpPost]
  724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  725. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  726. {
  727. var groupData = await _groupRepository.ConfirmationGroup(dto);
  728. if (groupData.Code != 0)
  729. {
  730. return Ok(JsonView(false, groupData.Msg));
  731. }
  732. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  733. #region OA消息推送
  734. try
  735. {
  736. string groupName = groupInfo.TeamName;
  737. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  738. List<int> userIds = new List<int>();
  739. listUser.ForEach(s => userIds.Add(s.Id));
  740. string title = $"系统通知";
  741. string content = $"团组[{groupName}]已确认出团!";
  742. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  743. }
  744. catch (Exception ex)
  745. {
  746. }
  747. #endregion
  748. #region 应用推送
  749. try
  750. {
  751. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  752. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  753. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  754. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  755. {
  756. List<string> userList = new List<string>() { users.QiyeChatUserId };
  757. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  758. }
  759. }
  760. catch (Exception ex)
  761. {
  762. }
  763. #endregion
  764. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  765. return Ok(JsonView(true, "操作成功!", groupData.Data));
  766. }
  767. /// <summary>
  768. /// 获取团组名称data And 签证国别Data
  769. /// </summary>
  770. /// <param name="dto"></param>
  771. /// <returns></returns>
  772. [HttpPost]
  773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  774. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  775. {
  776. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  777. if (groupData.Code != 0)
  778. {
  779. return Ok(JsonView(false, groupData.Msg));
  780. }
  781. return Ok(JsonView(groupData.Data));
  782. }
  783. /// <summary>
  784. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  785. /// </summary>
  786. /// <returns></returns>
  787. [HttpPost]
  788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  789. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  790. {
  791. try
  792. {
  793. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  794. if (groupData.Code != 0)
  795. {
  796. return Ok(JsonView(false, groupData.Msg));
  797. }
  798. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  799. }
  800. catch (Exception ex)
  801. {
  802. return Ok(JsonView(false, "程序错误!"));
  803. throw;
  804. }
  805. }
  806. #endregion
  807. #region 团组&签证
  808. /// <summary>
  809. /// 根据团组Id获取签证客户信息List
  810. /// </summary>
  811. /// <param name="dto">请求dto</param>
  812. /// <returns></returns>
  813. [HttpPost]
  814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  815. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  816. {
  817. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  818. if (groupData.Code != 0)
  819. {
  820. return Ok(JsonView(false, groupData.Msg));
  821. }
  822. return Ok(JsonView(groupData.Data));
  823. }
  824. /// <summary>
  825. /// IOS获取团组签证拍照上传进度01(团组列表)
  826. /// </summary>
  827. /// <param name="dto">请求dto</param>
  828. /// <returns></returns>
  829. [HttpPost]
  830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  831. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  832. {
  833. if (dto == null)
  834. {
  835. return Ok(JsonView(false, "参数为空"));
  836. }
  837. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  838. return Ok(JsonView(visaList));
  839. }
  840. /// <summary>
  841. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  842. /// </summary>
  843. /// <returns></returns>
  844. [HttpPost]
  845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  846. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  847. {
  848. if (dto == null)
  849. {
  850. return Ok(JsonView(false, "请求错误:"));
  851. }
  852. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  853. return Ok(JsonView(list));
  854. }
  855. /// <summary>
  856. /// IOS获取团组签证拍照上传进度03(相册)
  857. /// </summary>
  858. /// <returns></returns>
  859. [HttpPost]
  860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  861. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  862. {
  863. if (dto == null)
  864. {
  865. return Ok(JsonView(false, "请求错误:"));
  866. }
  867. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  868. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  869. list.ForEach(s => s.url = url);
  870. return Ok(JsonView(list));
  871. }
  872. /// <summary>
  873. /// IOS获取团组签证拍照上传进度04(图片上传)
  874. /// </summary>
  875. /// <param name="dto"></param>
  876. /// <returns></returns>
  877. [HttpPost]
  878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  879. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  880. {
  881. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  882. //if (!string.IsNullOrEmpty(result))
  883. //{
  884. //}
  885. //else {
  886. // return Ok(JsonView(false, "上传失败"));
  887. //}
  888. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  889. int sucNum = 0;
  890. try
  891. {
  892. foreach (var item in dto.base64DataList)
  893. {
  894. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  895. string result = decodeBase64ToImage(item, imageName);
  896. if (!string.IsNullOrEmpty(result))
  897. {
  898. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  899. pic.CreateUserId = dto.CreateUserId;
  900. pic.PicName = imageName;
  901. pic.PicPath = result;
  902. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  903. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  904. if (insertResult > 0)
  905. {
  906. sucNum++;
  907. }
  908. }
  909. }
  910. }
  911. catch (Exception ex)
  912. {
  913. return Ok(JsonView(false, ex.Message));
  914. }
  915. string msg = string.Format(@"成功上传{0}张", sucNum);
  916. return Ok(JsonView(true, msg));
  917. }
  918. private string decodeBase64ToImage(string base64DataURL, string imgName)
  919. {
  920. string filename = "";//声明一个string类型的相对路径
  921. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  922. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  923. try//会有异常抛出,try,catch一下
  924. {
  925. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  926. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  927. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  928. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  929. //文件名称
  930. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  931. //上传的文件的路径
  932. string filePath = "";
  933. if (!Directory.Exists(fileDir))
  934. {
  935. Directory.CreateDirectory(fileDir);
  936. }
  937. //上传的文件的路径
  938. filePath = fileDir + filename;
  939. //string url = HttpRuntime.AppDomainAppPath.ToString();
  940. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  941. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  942. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  943. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  944. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  945. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  946. ms.Close();//关闭当前流,并释放所有与之关联的资源
  947. bitmap.Dispose();
  948. }
  949. catch (Exception e)
  950. {
  951. string massage = e.Message;
  952. Logs("IOS图片上传Error:" + massage);
  953. //filename = e.Message;
  954. }
  955. return filename;//返回相对路径
  956. }
  957. /// <summary>
  958. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  959. /// </summary>
  960. /// <param name="dto"></param>
  961. /// <returns></returns>
  962. [HttpPost]
  963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  964. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  965. {
  966. if (dto == null)
  967. {
  968. return Ok(JsonView(false, "请求错误:"));
  969. }
  970. string msg = "参数错误";
  971. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  972. {
  973. try
  974. {
  975. //_delegationVisaRep.BeginTran();
  976. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  977. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  978. .Where(s => s.Id == dto.visaProgressCustomerId)
  979. .ExecuteCommandAsync();
  980. if (updCount > 0 && dto.publishCode == 1)
  981. {
  982. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  983. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  984. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  985. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  986. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  987. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  988. if (groupData == null)
  989. {
  990. _delegationVisaRep.RollbackTran();
  991. }
  992. string title = string.Format(@"[签证进度更新]");
  993. string content = string.Format(@"测试文本");
  994. bool rst = await _message.AddMsg(new MessageDto()
  995. {
  996. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  997. IssuerId = dto.publisher,
  998. Title = title,
  999. Content = content,
  1000. ReleaseTime = DateTime.Now,
  1001. UIdList = new List<int> {
  1002. 234
  1003. }
  1004. });
  1005. if (rst)
  1006. {
  1007. return Ok(JsonView(true, "发送通知成功"));
  1008. }
  1009. }
  1010. //_delegationVisaRep.CommitTran();
  1011. }
  1012. catch (Exception)
  1013. {
  1014. //_delegationVisaRep.RollbackTran();
  1015. }
  1016. }
  1017. return Ok(JsonView(true, msg));
  1018. }
  1019. #endregion
  1020. #region 团组任务分配
  1021. /// <summary>
  1022. /// 团组任务分配初始化
  1023. /// </summary>
  1024. /// <param name="dto"></param>
  1025. /// <returns></returns>
  1026. [HttpPost]
  1027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1028. public async Task<IActionResult> GetTaskAssignmen()
  1029. {
  1030. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1031. if (groupData.Code != 0)
  1032. {
  1033. return Ok(JsonView(false, groupData.Msg));
  1034. }
  1035. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1036. }
  1037. /// <summary>
  1038. /// 团组任务分配查询
  1039. /// </summary>
  1040. /// <param name="dto"></param>
  1041. /// <returns></returns>
  1042. [HttpPost]
  1043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1044. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1045. {
  1046. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1047. if (groupData.Code != 0)
  1048. {
  1049. return Ok(JsonView(false, groupData.Msg));
  1050. }
  1051. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1052. }
  1053. /// <summary>
  1054. /// 团组任务分配操作
  1055. /// </summary>
  1056. /// <param name="dto"></param>
  1057. /// <returns></returns>
  1058. [HttpPost]
  1059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1060. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1061. {
  1062. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1063. if (groupData.Code != 0)
  1064. {
  1065. return Ok(JsonView(false, groupData.Msg));
  1066. }
  1067. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1068. }
  1069. #endregion
  1070. #region 团组费用审核
  1071. /// <summary>
  1072. /// 费用审核
  1073. /// 团组列表 Page
  1074. /// </summary>
  1075. /// <param name="_dto">团组列表请求dto</param>
  1076. /// <returns></returns>
  1077. [HttpPost]
  1078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1079. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1080. {
  1081. #region 参数验证
  1082. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1083. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1084. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1085. #region 页面操作权限验证
  1086. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1087. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1088. #endregion
  1089. #endregion
  1090. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1091. {
  1092. string sqlWhere = string.Empty;
  1093. if (_dto.IsSure == 0) //未完成
  1094. {
  1095. sqlWhere += string.Format(@" And IsSure = 0");
  1096. }
  1097. else if (_dto.IsSure == 1) //已完成
  1098. {
  1099. sqlWhere += string.Format(@" And IsSure = 1");
  1100. }
  1101. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1102. {
  1103. string tj = _dto.SearchCriteria;
  1104. 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}%')",
  1105. tj, tj, tj, tj, tj);
  1106. }
  1107. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1108. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1109. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1110. From (
  1111. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1112. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1113. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1114. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1115. From Grp_DelegationInfo gdi
  1116. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1117. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1118. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1119. Where gdi.IsDel = 0 {0}
  1120. ) temp ", sqlWhere);
  1121. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1122. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1123. var _view = new
  1124. {
  1125. PageFuncAuth = pageFunAuthView,
  1126. Data = _DelegationList
  1127. };
  1128. return Ok(JsonView(true, "查询成功!", _view, total));
  1129. }
  1130. else
  1131. {
  1132. return Ok(JsonView(false, "查询失败"));
  1133. }
  1134. }
  1135. /// <summary>
  1136. /// 获取团组费用审核
  1137. /// </summary>
  1138. /// <param name="paras">参数Json字符串</param>
  1139. /// <returns></returns>
  1140. [HttpPost]
  1141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1142. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1143. {
  1144. try
  1145. {
  1146. #region 参数验证
  1147. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1148. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1149. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1150. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1151. #region 页面操作权限验证
  1152. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1153. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1154. #endregion
  1155. #endregion
  1156. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1157. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1158. #region 费用清单
  1159. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1160. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1161. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1162. List<Grp_CreditCardPayment> entityList = _groupRepository
  1163. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1164. .Where(exp.ToExpression())
  1165. .ToList();
  1166. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1167. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1168. /*
  1169. * 76://酒店预订
  1170. */
  1171. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1172. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1173. .ToListAsync();
  1174. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1175. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1176. .ToListAsync();
  1177. /*
  1178. * 79://车/导游地接
  1179. */
  1180. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1181. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1182. .ToListAsync();
  1183. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1184. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1185. .ToListAsync();
  1186. /*
  1187. * 80: //签证
  1188. */
  1189. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1190. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1191. .ToListAsync();
  1192. /*
  1193. *81: //邀请/公务活动
  1194. */
  1195. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1196. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1197. .ToListAsync();
  1198. /*
  1199. * 82: //团组客户保险
  1200. */
  1201. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1202. /*
  1203. * Lable = 85 机票预订
  1204. */
  1205. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1206. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1207. .ToListAsync();
  1208. /*
  1209. * 85 机票预定
  1210. */
  1211. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1212. /*
  1213. * 98 其他款项
  1214. */
  1215. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1216. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1217. .ToListAsync();
  1218. /*
  1219. * 285:收款退还
  1220. */
  1221. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1222. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1223. .ToListAsync();
  1224. /*
  1225. * 1015: //超支费用
  1226. */
  1227. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1228. /*
  1229. * 币种信息
  1230. */
  1231. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1232. /*
  1233. * 车/导游地接 费用类型
  1234. */
  1235. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1236. /*
  1237. * 车/导游地接 费用类型
  1238. */
  1239. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1240. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1241. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1242. /*
  1243. * 用户信息
  1244. */
  1245. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1246. /*
  1247. * 费用模块
  1248. */
  1249. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1250. string priceModule = string.Empty;
  1251. if (sdPriceName != null)
  1252. {
  1253. priceModule = sdPriceName.Name;
  1254. }
  1255. /*
  1256. * 成本信息
  1257. */
  1258. var groupCost = _groupRepository.Query<Grp_GroupCostParameter >(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1259. decimal _groupRate = 0.0000M;
  1260. string _groupCurrencyCode = "-";
  1261. if (groupCost != null)
  1262. {
  1263. _groupRate = groupCost.Rate;
  1264. if (int.TryParse(groupCost.Currency, out int _currency))
  1265. {
  1266. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1267. }
  1268. }
  1269. string costContentSql = $"Select * From Grp_GroupCost";
  1270. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1271. //处理日期为空的天数
  1272. for (int i = 0; i < groupCostDetails.Count; i++)
  1273. if (i != 0)
  1274. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1275. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1276. /*
  1277. * 处理详情数据
  1278. */
  1279. foreach (var entity in entityList)
  1280. {
  1281. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1282. _detail.Id = entity.Id;
  1283. _detail.PriceName = priceModule;
  1284. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1285. _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1286. /*
  1287. * 应付款金额
  1288. */
  1289. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1290. string PaymentCurrency_WaitPay = "Unknown";
  1291. string hotelCurrncyCode = "Unknown";
  1292. string hotelCurrncyName = "Unknown";
  1293. if (sdPaymentCurrency_WaitPay != null)
  1294. {
  1295. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1296. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1297. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1298. if (hotelCurrncyCode.Equals("CNY"))
  1299. {
  1300. entity.DayRate = 1.0000M;
  1301. }
  1302. }
  1303. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1304. /*
  1305. * 此次付款金额
  1306. */
  1307. decimal CurrPayStr = 0;
  1308. if (entity.PayPercentage == 0)
  1309. {
  1310. if (entity.PayThenMoney != 0)
  1311. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1312. }
  1313. else
  1314. {
  1315. if (entity.PayMoney != 0)
  1316. {
  1317. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1318. }
  1319. }
  1320. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1321. /*
  1322. * 剩余尾款
  1323. */
  1324. decimal BalanceStr = 0;
  1325. if (CurrPayStr != 0)
  1326. {
  1327. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1328. BalanceStr = 0;
  1329. else
  1330. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1331. }
  1332. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1333. /*
  1334. * Bus名称
  1335. */
  1336. _detail.BusName = "待增加";
  1337. /*
  1338. *费用所属
  1339. */
  1340. switch (entity.CTable)
  1341. {
  1342. case 76://酒店预订
  1343. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1344. if (hotelReservations != null)
  1345. {
  1346. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1347. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1348. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1349. string roomFeeStr = "";
  1350. if (hotelReservations.SingleRoomPrice>0)
  1351. roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}";
  1352. if (hotelReservations.DoubleRoomPrice > 0)
  1353. roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}";
  1354. if (hotelReservations.SuiteRoomPrice > 0)
  1355. roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}";
  1356. if (hotelReservations.OtherRoomPrice > 0)
  1357. roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1358. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1359. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1360. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1361. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1362. /*
  1363. * 费用类型
  1364. * 1:房费
  1365. * 2:早餐
  1366. * 3:地税
  1367. * 4:城市税
  1368. * </summary>
  1369. */
  1370. //地税
  1371. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1372. if (governmentRentData != null)
  1373. {
  1374. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1375. governmentRentFee = governmentRentData.Price;
  1376. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1377. if (governmentRentCurrData != null)
  1378. {
  1379. governmentRentCode = governmentRentCurrData.Name;
  1380. governmentRentName = $"({governmentRentCurrData.Remark})";
  1381. }
  1382. }
  1383. //城市税
  1384. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1385. if (cityTaxData != null)
  1386. {
  1387. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1388. cityTaxFee = cityTaxData.Price;
  1389. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1390. if (cityTaxCurrData != null)
  1391. {
  1392. cityTaxCode = cityTaxCurrData.Name;
  1393. cityTaxName = $"({cityTaxCurrData.Remark})";
  1394. }
  1395. }
  1396. //酒店早餐
  1397. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1398. if (breakfastData != null)
  1399. {
  1400. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1401. breakfastFee = breakfastData.Price;
  1402. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1403. if (breakfastCurrData != null)
  1404. {
  1405. breakfastCode = breakfastCurrData.Name;
  1406. breakfastName = $"({breakfastCurrData.Remark})";
  1407. }
  1408. }
  1409. //房间费用
  1410. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1411. if (roomData != null)
  1412. {
  1413. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1414. _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1415. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1416. roomFee = roomData.Price;
  1417. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1418. if (roomCurrData != null)
  1419. {
  1420. roomCode = roomCurrData.Name;
  1421. roomName = $"({roomCurrData.Remark})";
  1422. }
  1423. }
  1424. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1425. string hotelCostStr = "";
  1426. decimal hotelCsotTotal = 0.00M;
  1427. if (groupCost != null)
  1428. {
  1429. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1430. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1431. }
  1432. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1433. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1434. string hotelCost_day = "";
  1435. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1436. foreach (var item in hotelCostDetails1)
  1437. {
  1438. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1439. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1440. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1441. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1442. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1443. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1444. hotelCost_day += @$"</br>";
  1445. }
  1446. string hotelBreakfastStr = "",hotelGovernmentRentStr = "",hotelCityTaxStr="" ;
  1447. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1448. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1449. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1450. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1451. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>"+
  1452. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1453. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1454. $"房间说明: {hotelReservations.Remark} <br/>" +
  1455. $"房间费用: {roomCode} {roomName} 当时汇率 {roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接代付:{roomBool}<br/><br/>" +
  1456. $"{hotelBreakfastStr}"+
  1457. $"{hotelGovernmentRentStr}"+
  1458. $"{hotelCityTaxStr}";
  1459. _detail.PriceNameContent = hotelReservations.HotelName;
  1460. }
  1461. break;
  1462. case 79://车/导游地接
  1463. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1464. if (touristGuideGroundReservations != null)
  1465. {
  1466. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1467. {
  1468. _detail.BusName = touristGuideGroundReservations.BusName;
  1469. }
  1470. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1471. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1472. //if (isInt)
  1473. //{
  1474. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1475. // if (cityInfo != null)
  1476. // {
  1477. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1478. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1479. // if (carFeeItem != null)
  1480. // {
  1481. // nameContent += $@"({carFeeItem.Name})";
  1482. // }
  1483. // _detail.PriceNameContent = nameContent;
  1484. // }
  1485. //}
  1486. //else
  1487. //{
  1488. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1489. //}
  1490. var touristGuideGroundReservationsContents =
  1491. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1492. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1493. foreach (var item in touristGuideGroundReservationsContents)
  1494. {
  1495. string typeName = "Unknown";
  1496. string carCurrencyCode = "Unknown";
  1497. string carCurrencyName = "Unknown";
  1498. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1499. if (carTypeData != null) typeName = carTypeData.Name;
  1500. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1501. if (currencyData != null)
  1502. {
  1503. carCurrencyCode = currencyData.Name;
  1504. carCurrencyName = currencyData.Remark;
  1505. }
  1506. string opCostStr =string.Empty;
  1507. decimal opCostTypePrice = 0.00M;
  1508. #region 处理成本各项费用
  1509. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1510. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1511. if (opCost.Count > 0)
  1512. {
  1513. switch (item.SId)
  1514. {
  1515. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1516. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1517. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1518. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1519. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1520. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1521. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1522. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1523. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1524. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1525. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1526. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1527. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1528. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1529. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1530. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1531. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1532. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1533. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1534. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1535. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1536. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1537. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1538. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1539. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1540. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1541. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1542. }
  1543. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1544. }
  1545. #endregion
  1546. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1547. $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")}) {opCostStr}<br/>" +
  1548. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1549. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1550. }
  1551. _detail.PriceMsgContent = priceMsg;
  1552. }
  1553. break;
  1554. case 80: //签证
  1555. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1556. if (visaInfo != null)
  1557. {
  1558. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1559. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1560. }
  1561. break;
  1562. case 81: //邀请/公务活动
  1563. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1564. if (_ioa != null)
  1565. {
  1566. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1567. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1568. sendCurrName = "Unknown", //快递费用币种 Name
  1569. sendCurrCode = "Unknown", //快递费用币种 Code
  1570. eventsCurrName = "Unknown", //公务活动费币种 Name
  1571. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1572. translateCurrName = "Unknown", //公务翻译费 Name
  1573. translateCurrCode = "Unknown"; //公务翻译费 Code
  1574. #region 处理费用币种
  1575. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1576. if (inviteCurrData != null)
  1577. {
  1578. inviteCurrName = inviteCurrData.Remark;
  1579. inviteCurrCode = inviteCurrData.Name;
  1580. }
  1581. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1582. if (sendCurrData != null)
  1583. {
  1584. sendCurrName = sendCurrData.Remark;
  1585. sendCurrCode = sendCurrData.Name;
  1586. }
  1587. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1588. if (eventsCurrData != null)
  1589. {
  1590. eventsCurrName = eventsCurrData.Remark;
  1591. eventsCurrCode = eventsCurrData.Name;
  1592. }
  1593. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1594. if (translateCurrData != null)
  1595. {
  1596. translateCurrName = translateCurrData.Remark;
  1597. translateCurrCode = translateCurrData.Name;
  1598. }
  1599. #endregion
  1600. _detail.PriceNameContent = _ioa.InviterArea;
  1601. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1602. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1603. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1604. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1605. $@"备注:" + _ioa.Remark + "<br/>";
  1606. }
  1607. break;
  1608. case 82: //团组客户保险
  1609. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1610. if (customers != null)
  1611. {
  1612. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1613. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1614. }
  1615. break;
  1616. case 85: //机票预订
  1617. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1618. if (jpRes != null)
  1619. {
  1620. string FlightsDescription = jpRes.FlightsDescription;
  1621. string PriceDescription = jpRes.PriceDescription;
  1622. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1623. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1624. }
  1625. break;
  1626. case 98://其他款项
  1627. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1628. if (gdpRes != null)
  1629. {
  1630. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1631. _detail.PriceNameContent = gdpRes.PriceName;
  1632. }
  1633. break;
  1634. case 285://收款退还
  1635. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1636. if (refundAndOtherMoney != null)
  1637. {
  1638. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1639. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1640. }
  1641. break;
  1642. case 751://酒店早餐
  1643. break;
  1644. case 1015://超支费用
  1645. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1646. if (groupExtraCost != null)
  1647. {
  1648. _detail.PriceNameContent = groupExtraCost.PriceName;
  1649. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1650. }
  1651. break;
  1652. default:
  1653. break;
  1654. }
  1655. /*
  1656. * 申请人
  1657. */
  1658. string operatorName = " - ";
  1659. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1660. if (_opUser != null)
  1661. {
  1662. operatorName = _opUser.CnName;
  1663. }
  1664. _detail.OperatorName = operatorName;
  1665. /*
  1666. * 审核人
  1667. */
  1668. string auditOperatorName = "Unknown";
  1669. if (entity.AuditGMOperate == 0)
  1670. auditOperatorName = " - ";
  1671. else if (entity.AuditGMOperate == 4)
  1672. auditOperatorName = "自动审核";
  1673. else
  1674. {
  1675. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1676. if (_adUser != null)
  1677. {
  1678. auditOperatorName = _adUser.CnName;
  1679. }
  1680. }
  1681. _detail.AuditOperatorName = auditOperatorName;
  1682. /*
  1683. * 超预算比例
  1684. */
  1685. string overBudgetStr = "";
  1686. if (entity.ExceedBudget == -1)
  1687. overBudgetStr = sdPriceName.Name + "尚无预算";
  1688. else if (entity.ExceedBudget == 0)
  1689. {
  1690. if (entity.CTable == 76 || entity.CTable == 79)
  1691. {
  1692. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1693. else overBudgetStr = "超预算";
  1694. }
  1695. else
  1696. {
  1697. overBudgetStr = "未超预算";
  1698. }
  1699. }
  1700. else
  1701. overBudgetStr = entity.ExceedBudget.ToString("P");
  1702. _detail.OverBudget = overBudgetStr;
  1703. /*
  1704. * 费用总计
  1705. */
  1706. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1707. {
  1708. CurrencyId = entity.PaymentCurrency,
  1709. CurrencyName = PaymentCurrency_WaitPay,
  1710. AmountPayable = entity.PayMoney,
  1711. ThisPayment = CurrPayStr,
  1712. BalancePayment = BalanceStr,
  1713. AuditedFunds = CurrPayStr
  1714. });
  1715. _detail.IsAuditGM = entity.IsAuditGM;
  1716. detailList.Add(_detail);
  1717. }
  1718. #endregion
  1719. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1720. /*
  1721. * 下方描述处理
  1722. */
  1723. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1724. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1725. if (ccpCurrencyPrice != null)
  1726. {
  1727. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1728. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1729. }
  1730. else
  1731. {
  1732. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1733. }
  1734. string amountPayableStr = string.Format(@"应付款总金额: ");
  1735. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1736. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1737. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1738. foreach (var item in nonDuplicat)
  1739. {
  1740. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1741. if (strs.Count > 0)
  1742. {
  1743. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1744. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1745. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1746. //单独处理此次付款金额
  1747. if (item.CurrencyId == 836) //人民币
  1748. {
  1749. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1750. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1751. }
  1752. else
  1753. {
  1754. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1755. }
  1756. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1757. //单独处理已审核费用
  1758. if (item.CurrencyId == 836) //人民币
  1759. {
  1760. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1761. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1762. }
  1763. else
  1764. {
  1765. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1766. }
  1767. }
  1768. }
  1769. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1770. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1771. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1772. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1773. var _view1 = new
  1774. {
  1775. PageFuncAuth = pageFunAuthView,
  1776. Data = _view
  1777. };
  1778. return Ok(JsonView(_view1));
  1779. }
  1780. catch (Exception ex)
  1781. {
  1782. return Ok(JsonView(false, ex.Message));
  1783. }
  1784. }
  1785. /// <summary>
  1786. /// 费用审核
  1787. /// 修改团组费用审核状态
  1788. /// </summary>
  1789. /// <param name="_dto">参数Json字符串</param>
  1790. /// <returns></returns>
  1791. [HttpPost]
  1792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1793. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1794. {
  1795. #region 参数验证
  1796. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1797. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1798. #endregion
  1799. #region 页面操作权限验证
  1800. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1801. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1802. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1803. #endregion
  1804. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1805. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1806. DateTime dtNow = DateTime.Now;
  1807. _groupRepository.BeginTran();
  1808. int rst = 0;
  1809. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1810. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1811. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1812. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1813. List<dynamic> msgDatas = new List<dynamic>();
  1814. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1815. foreach (var item in idList)
  1816. {
  1817. int CreditId = int.Parse(item);
  1818. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1819. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1820. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1821. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1822. .Where(s => s.Id == CreditId)
  1823. .ExecuteCommandAsync();
  1824. if (result < 1)
  1825. {
  1826. rst = -1;
  1827. _groupRepository.RollbackTran();
  1828. return Ok(JsonView(false, "操作失败并回滚!"));
  1829. }
  1830. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1831. if (creditData != null)
  1832. {
  1833. #region 应用通知配置
  1834. try
  1835. {
  1836. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1837. }
  1838. catch (Exception ex)
  1839. {
  1840. }
  1841. #endregion
  1842. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1843. string groupNameStr = string.Empty;
  1844. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1845. if (groupData != null) groupNameStr = groupData.TeamName;
  1846. string creditTypeStr = string.Empty;
  1847. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1848. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1849. string creditCurrency = string.Empty;
  1850. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1851. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1852. if (creditCurrency.Equals("CNY"))
  1853. {
  1854. creditData.DayRate = 1.0000M;
  1855. }
  1856. if (creditData.PayPercentage == 0.00M)
  1857. {
  1858. creditData.PayPercentage = 100M;
  1859. }
  1860. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1861. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1862. string msgContent = "";
  1863. if (creditCurrency.Equals("CNY"))
  1864. {
  1865. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1866. }
  1867. else
  1868. {
  1869. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1870. }
  1871. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1872. }
  1873. }
  1874. if (rst == 0)
  1875. {
  1876. _groupRepository.CommitTran();
  1877. foreach (var item in msgDatas)
  1878. {
  1879. //发送消息
  1880. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1881. }
  1882. #region 应用推送
  1883. try
  1884. {
  1885. foreach (var ccpId in dic_ccp_user.Keys)
  1886. {
  1887. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1888. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1889. }
  1890. }
  1891. catch (Exception)
  1892. {
  1893. }
  1894. #endregion
  1895. return Ok(JsonView(true, "操作成功!"));
  1896. }
  1897. return Ok(JsonView(false, "操作失败!"));
  1898. }
  1899. #endregion
  1900. #region 机票费用录入
  1901. /// <summary>
  1902. /// 机票录入当前登录人可操作团组
  1903. /// </summary>
  1904. /// <param name="dto"></param>
  1905. /// <returns></returns>
  1906. [HttpPost]
  1907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1908. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1909. {
  1910. try
  1911. {
  1912. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1913. if (groupData.Code != 0)
  1914. {
  1915. return Ok(JsonView(false, groupData.Msg));
  1916. }
  1917. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1918. }
  1919. catch (Exception ex)
  1920. {
  1921. return Ok(JsonView(false, "程序错误!"));
  1922. throw;
  1923. }
  1924. }
  1925. /// <summary>
  1926. /// 机票费用录入列表
  1927. /// </summary>
  1928. /// <param name="dto"></param>
  1929. /// <returns></returns>
  1930. [HttpPost]
  1931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1932. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1933. {
  1934. try
  1935. {
  1936. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1937. if (groupData.Code != 0)
  1938. {
  1939. return Ok(JsonView(false, groupData.Msg));
  1940. }
  1941. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1942. }
  1943. catch (Exception ex)
  1944. {
  1945. return Ok(JsonView(false, ex.Message));
  1946. throw;
  1947. }
  1948. }
  1949. /// <summary>
  1950. /// 根据id查询费用录入信息
  1951. /// </summary>
  1952. /// <param name="dto"></param>
  1953. /// <returns></returns>
  1954. [HttpPost]
  1955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1956. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1957. {
  1958. try
  1959. {
  1960. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1961. if (groupData.Code != 0)
  1962. {
  1963. return Ok(JsonView(false, groupData.Msg));
  1964. }
  1965. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1966. }
  1967. catch (Exception ex)
  1968. {
  1969. return Ok(JsonView(false, "程序错误!"));
  1970. throw;
  1971. }
  1972. }
  1973. /// <summary>
  1974. /// 机票费用录入操作(Status:1.新增,2.修改)
  1975. /// </summary>
  1976. /// <param name="dto"></param>
  1977. /// <returns></returns>
  1978. [HttpPost]
  1979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1980. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1981. {
  1982. try
  1983. {
  1984. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1985. if (groupData.Code != 0)
  1986. {
  1987. return Ok(JsonView(false, groupData.Msg));
  1988. }
  1989. #region 应用推送
  1990. try
  1991. {
  1992. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  1993. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  1994. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  1995. }
  1996. catch (Exception ex)
  1997. {
  1998. }
  1999. #endregion
  2000. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2001. }
  2002. catch (Exception ex)
  2003. {
  2004. return Ok(JsonView(false, "程序错误!"));
  2005. throw;
  2006. }
  2007. }
  2008. /// <summary>
  2009. /// 根据舱位类型查询接团客户名单信息
  2010. /// </summary>
  2011. /// <param name="dto"></param>
  2012. /// <returns></returns>
  2013. [HttpPost]
  2014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2015. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2016. {
  2017. try
  2018. {
  2019. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2020. if (crm_Groups.Count != 0)
  2021. {
  2022. List<dynamic> Customer = new List<dynamic>();
  2023. foreach (var item in crm_Groups)
  2024. {
  2025. var data = new
  2026. {
  2027. Id = item.Id,
  2028. Pinyin = item.Pinyin,
  2029. Name = item.LastName + item.FirstName
  2030. };
  2031. Customer.Add(data);
  2032. }
  2033. return Ok(JsonView(true, "查询成功!", Customer));
  2034. }
  2035. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2036. }
  2037. catch (Exception ex)
  2038. {
  2039. return Ok(JsonView(false, "程序错误!"));
  2040. throw;
  2041. }
  2042. }
  2043. /// <summary>
  2044. /// 根据团号获取客户信息
  2045. /// </summary>
  2046. /// <param name="dto"></param>
  2047. /// <returns></returns>
  2048. [HttpPost]
  2049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2050. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2051. {
  2052. var jw = JsonView(false);
  2053. if (dto.DIID < 1)
  2054. {
  2055. jw.Msg += "请输入正确的diid";
  2056. return Ok(jw);
  2057. }
  2058. var arr = getSimplClientList(dto.DIID);
  2059. jw = JsonView(true, "获取成功!", arr);
  2060. return Ok(jw);
  2061. }
  2062. private List<SimplClientInfo> getSimplClientList(int diId)
  2063. {
  2064. 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);
  2065. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2066. return arr;
  2067. }
  2068. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2069. {
  2070. string result = origin;
  2071. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2072. {
  2073. string[] temparr = origin.Split(',');
  2074. string fistrStr = temparr[0];
  2075. int count = temparr.Count();
  2076. int tempId;
  2077. bool success = int.TryParse(fistrStr, out tempId);
  2078. if (success)
  2079. {
  2080. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2081. if (tempInfo != null)
  2082. {
  2083. if (count > 1)
  2084. {
  2085. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2086. }
  2087. else
  2088. {
  2089. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2090. }
  2091. }
  2092. }
  2093. }
  2094. return result;
  2095. }
  2096. /// <summary>
  2097. /// 机票费用录入,删除
  2098. /// </summary>
  2099. /// <param name="dto"></param>
  2100. /// <returns></returns>
  2101. [HttpPost]
  2102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2103. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2104. {
  2105. try
  2106. {
  2107. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2108. if (res)
  2109. {
  2110. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2111. {
  2112. IsDel = 1,
  2113. DeleteUserId = dto.DeleteUserId,
  2114. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2115. }).ExecuteCommandAsync();
  2116. return Ok(JsonView(true, "删除成功!"));
  2117. }
  2118. return Ok(JsonView(false, "删除失败!"));
  2119. }
  2120. catch (Exception ex)
  2121. {
  2122. return Ok(JsonView(false, "程序错误!"));
  2123. throw;
  2124. }
  2125. }
  2126. /// <summary>
  2127. /// 导出机票录入报表
  2128. /// </summary>
  2129. /// <param name="dto"></param>
  2130. /// <returns></returns>
  2131. [HttpPost]
  2132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2133. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2134. {
  2135. try
  2136. {
  2137. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2138. if (groupData.Code != 0)
  2139. {
  2140. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2141. }
  2142. else
  2143. {
  2144. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2145. if (AirTicketReservations.Count != 0)
  2146. {
  2147. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2148. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2149. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2150. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2151. WorkbookDesigner designer = new WorkbookDesigner();
  2152. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2153. decimal countCost = 0;
  2154. foreach (var item in AirTicketReservations)
  2155. {
  2156. #region 处理客人姓名
  2157. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2158. item.ClientName = clientNames;
  2159. #endregion
  2160. if (item.BankType == "其他")
  2161. {
  2162. item.BankNo = "--";
  2163. }
  2164. else
  2165. {
  2166. if (!string.IsNullOrEmpty(item.BankType))
  2167. {
  2168. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2169. }
  2170. }
  2171. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2172. item.Price = System.Decimal.Round(item.Price, 2);
  2173. countCost += Convert.ToDecimal(item.Price);
  2174. }
  2175. designer.SetDataSource("Export", AirTicketReservations);
  2176. designer.SetDataSource("ExportDiCode", diCode);
  2177. designer.SetDataSource("ExportDiName", diName);
  2178. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2179. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2180. designer.Process();
  2181. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2182. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2183. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2184. return Ok(JsonView(true, "成功", url = rst));
  2185. }
  2186. else
  2187. {
  2188. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2189. }
  2190. }
  2191. }
  2192. catch (Exception ex)
  2193. {
  2194. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2195. throw;
  2196. }
  2197. }
  2198. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2199. /// <summary>
  2200. /// 行程单导出
  2201. /// </summary>
  2202. /// <param name="dto"></param>
  2203. /// <returns></returns>
  2204. [HttpPost]
  2205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2206. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2207. {
  2208. try
  2209. {
  2210. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2211. if (groupData.Code != 0)
  2212. {
  2213. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2214. }
  2215. else
  2216. {
  2217. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2218. if (dto.Language == "CN")
  2219. {
  2220. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2221. DocumentBuilder builder = new DocumentBuilder(doc);
  2222. int tableIndex = 0;//表格索引
  2223. //得到文档中的第一个表格
  2224. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2225. foreach (var item in _AirTicketReservations)
  2226. {
  2227. #region 处理固定数据
  2228. string[] FlightsCode = item.FlightsCode.Split('/');
  2229. if (FlightsCode.Length != 0)
  2230. {
  2231. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2232. if (_AirCompany != null)
  2233. {
  2234. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2235. }
  2236. else
  2237. {
  2238. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2239. }
  2240. }
  2241. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2242. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2243. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2244. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2245. string name = "";
  2246. foreach (string clientName in nameArray)
  2247. {
  2248. if (!name.Contains(clientName))
  2249. {
  2250. name += clientName + ",";
  2251. }
  2252. }
  2253. if (!string.IsNullOrWhiteSpace(name))
  2254. {
  2255. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2256. }
  2257. else
  2258. {
  2259. table.Range.Bookmarks["ClientName"].Text = "--";
  2260. }
  2261. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2262. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2263. table.Range.Bookmarks["JointTicket"].Text = "--";
  2264. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2265. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2266. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2267. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2268. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2269. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2270. #endregion
  2271. #region 循环数据处理
  2272. List<AirInfo> airs = new List<AirInfo>();
  2273. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2274. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2275. for (int i = 0; i < FlightsCode.Length; i++)
  2276. {
  2277. AirInfo air = new AirInfo();
  2278. string[] tempstr = DayArray[i]
  2279. .Replace("\r\n", string.Empty)
  2280. .Replace("\\r\\n", string.Empty)
  2281. .TrimStart().TrimEnd()
  2282. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2283. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2284. string starCity = "";
  2285. if (star_Three != null)
  2286. {
  2287. starCity = star_Three.AirPort;
  2288. }
  2289. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2290. string EndCity = "";
  2291. if (End_Three != null)
  2292. {
  2293. EndCity = End_Three.AirPort;
  2294. }
  2295. air.Destination = starCity + "/" + EndCity;
  2296. air.Flight = FlightsCode[i];
  2297. air.SeatingClass = item.CTypeName;
  2298. string dateTime = tempstr[2];
  2299. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2300. air.FlightDate = DateTemp;
  2301. air.DepartureTime = tempstr[5];
  2302. air.LandingTime = tempstr[6];
  2303. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2304. air.TicketStatus = "--";
  2305. air.Luggage = "--";
  2306. air.DepartureTerminal = "--";
  2307. air.LandingTerminal = "--";
  2308. airs.Add(air);
  2309. }
  2310. int row = 13;
  2311. for (int i = 0; i < airs.Count; i++)
  2312. {
  2313. if (airs.Count > 2)
  2314. {
  2315. for (int j = 0; j < airs.Count - 2; j++)
  2316. {
  2317. var CopyRow = table.Rows[12].Clone(true);
  2318. table.Rows.Add(CopyRow);
  2319. }
  2320. }
  2321. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2322. int index = 0;
  2323. foreach (PropertyInfo property in properties)
  2324. {
  2325. string value = property.GetValue(airs[i]).ToString();
  2326. Cell ishcel0 = table.Rows[row].Cells[index];
  2327. Paragraph p = new Paragraph(doc);
  2328. string s = value;
  2329. p.AppendChild(new Run(doc, s));
  2330. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2331. ishcel0.AppendChild(p);
  2332. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2333. index++;
  2334. }
  2335. row++;
  2336. }
  2337. #endregion
  2338. Paragraph lastParagraph = new Paragraph(doc);
  2339. //第一个表格末尾加段落
  2340. table.ParentNode.InsertAfter(lastParagraph, table);
  2341. //复制第一个表格
  2342. Table cloneTable = (Table)table.Clone(true);
  2343. //在文档末尾段落后面加入复制的表格
  2344. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2345. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2346. {
  2347. int rownewsIndex = 13;
  2348. for (int i = 0; i < 2; i++)
  2349. {
  2350. var CopyRow = table.Rows[12].Clone(true);
  2351. table.Rows.RemoveAt(13);
  2352. table.Rows.Add(CopyRow);
  2353. rownewsIndex++;
  2354. }
  2355. }
  2356. else
  2357. {
  2358. table.Rows.RemoveAt(12);
  2359. }
  2360. cloneTable.Rows.RemoveAt(12);
  2361. }
  2362. if (_AirTicketReservations.Count != 0)
  2363. {
  2364. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2365. if (FlightsCode.Length != 0)
  2366. {
  2367. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2368. if (_AirCompany != null)
  2369. {
  2370. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2371. }
  2372. else
  2373. {
  2374. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2375. }
  2376. }
  2377. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2378. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2379. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2380. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2381. string name = "";
  2382. foreach (string clientName in nameArray)
  2383. {
  2384. if (!name.Contains(clientName))
  2385. {
  2386. name += clientName + ",";
  2387. }
  2388. }
  2389. if (!string.IsNullOrWhiteSpace(name))
  2390. {
  2391. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2392. }
  2393. else
  2394. {
  2395. table.Range.Bookmarks["ClientName"].Text = "--";
  2396. }
  2397. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2398. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2399. table.Range.Bookmarks["JointTicket"].Text = "--";
  2400. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2401. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2402. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2403. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2404. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2405. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2406. }
  2407. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2408. //保存合并后的文档
  2409. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2410. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2411. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2412. return Ok(JsonView(true, "成功!", rst));
  2413. }
  2414. else
  2415. {
  2416. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2417. DocumentBuilder builder = new DocumentBuilder(doc);
  2418. int tableIndex = 0;//表格索引
  2419. //得到文档中的第一个表格
  2420. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2421. List<string> texts = new List<string>();
  2422. foreach (var item in _AirTicketReservations)
  2423. {
  2424. string[] FlightsCode = item.FlightsCode.Split('/');
  2425. if (FlightsCode.Length != 0)
  2426. {
  2427. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2428. if (_AirCompany != null)
  2429. {
  2430. if (!transDic.ContainsKey(_AirCompany.CnName))
  2431. {
  2432. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2433. }
  2434. }
  2435. else
  2436. {
  2437. if (!transDic.ContainsKey("--"))
  2438. {
  2439. transDic.Add("--", "--");
  2440. }
  2441. }
  2442. }
  2443. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2444. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2445. string name = "";
  2446. foreach (string clientName in nameArray)
  2447. {
  2448. name += clientName + ",";
  2449. }
  2450. if (!texts.Contains(name))
  2451. {
  2452. texts.Add(name);
  2453. }
  2454. List<AirInfo> airs = new List<AirInfo>();
  2455. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2456. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2457. for (int i = 0; i < FlightsCode.Length; i++)
  2458. {
  2459. AirInfo air = new AirInfo();
  2460. string[] tempstr = DayArray[i]
  2461. .Replace("\r\n", string.Empty)
  2462. .Replace("\\r\\n", string.Empty)
  2463. .TrimStart().TrimEnd()
  2464. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2465. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2466. if (star_Three != null)
  2467. {
  2468. if (!transDic.ContainsKey(star_Three.AirPort))
  2469. {
  2470. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2471. }
  2472. }
  2473. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2474. if (End_Three != null)
  2475. {
  2476. if (!transDic.ContainsKey(End_Three.AirPort))
  2477. {
  2478. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2479. }
  2480. }
  2481. if (!texts.Contains(item.CTypeName))
  2482. {
  2483. texts.Add(item.CTypeName);
  2484. }
  2485. }
  2486. }
  2487. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2488. if (transData.Count > 0)
  2489. {
  2490. foreach (TranslateResult item in transData)
  2491. {
  2492. if (!transDic.ContainsKey(item.Query))
  2493. {
  2494. transDic.Add(item.Query, item.Translation);
  2495. }
  2496. }
  2497. }
  2498. foreach (var item in _AirTicketReservations)
  2499. {
  2500. #region 处理固定数据
  2501. string[] FlightsCode = item.FlightsCode.Split('/');
  2502. if (FlightsCode.Length != 0)
  2503. {
  2504. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2505. if (_AirCompany != null)
  2506. {
  2507. string str = "--";
  2508. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2509. if (!string.IsNullOrEmpty(translateResult))
  2510. {
  2511. str = translateResult;
  2512. str = _airTicketResRep.Processing(str);
  2513. }
  2514. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2515. }
  2516. else
  2517. {
  2518. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2519. }
  2520. }
  2521. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2522. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2523. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2524. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2525. string names = "";
  2526. foreach (string clientName in nameArray)
  2527. {
  2528. names += clientName + ",";
  2529. }
  2530. if (!string.IsNullOrWhiteSpace(names))
  2531. {
  2532. string str = "--";
  2533. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2534. if (!string.IsNullOrEmpty(translateResult))
  2535. {
  2536. str = translateResult;
  2537. str = _airTicketResRep.Processing(str);
  2538. }
  2539. table.Range.Bookmarks["ClientName"].Text = str;
  2540. }
  2541. else
  2542. {
  2543. table.Range.Bookmarks["ClientName"].Text = "--";
  2544. }
  2545. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2546. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2547. table.Range.Bookmarks["JointTicket"].Text = "--";
  2548. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2549. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2550. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2551. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2552. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2553. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2554. #endregion
  2555. #region 循环数据处理
  2556. List<AirInfo> airs = new List<AirInfo>();
  2557. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2558. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2559. for (int i = 0; i < FlightsCode.Length; i++)
  2560. {
  2561. AirInfo air = new AirInfo();
  2562. string[] tempstr = DayArray[i]
  2563. .Replace("\r\n", string.Empty)
  2564. .Replace("\\r\\n", string.Empty)
  2565. .TrimStart().TrimEnd()
  2566. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2567. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2568. string starCity = "";
  2569. if (star_Three != null)
  2570. {
  2571. string str2 = "--";
  2572. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2573. if (!string.IsNullOrEmpty(translateResult2))
  2574. {
  2575. str2 = translateResult2;
  2576. str2 = _airTicketResRep.Processing(str2);
  2577. }
  2578. starCity = str2;
  2579. }
  2580. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2581. string EndCity = "";
  2582. if (End_Three != null)
  2583. {
  2584. string str1 = "--";
  2585. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2586. if (!string.IsNullOrEmpty(translateResult1))
  2587. {
  2588. str1 = translateResult1;
  2589. str1 = _airTicketResRep.Processing(str1);
  2590. }
  2591. EndCity = str1;
  2592. }
  2593. air.Destination = starCity + "/" + EndCity;
  2594. air.Flight = FlightsCode[i];
  2595. string str = "--";
  2596. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2597. if (!string.IsNullOrEmpty(translateResult))
  2598. {
  2599. str = translateResult;
  2600. str = _airTicketResRep.Processing(str);
  2601. }
  2602. air.SeatingClass = str;
  2603. string dateTime = tempstr[2];
  2604. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2605. air.FlightDate = DateTemp;
  2606. air.DepartureTime = tempstr[5];
  2607. air.LandingTime = tempstr[6];
  2608. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2609. air.TicketStatus = "--";
  2610. air.Luggage = "--";
  2611. air.DepartureTerminal = "--";
  2612. air.LandingTerminal = "--";
  2613. airs.Add(air);
  2614. }
  2615. int row = 13;
  2616. for (int i = 0; i < airs.Count; i++)
  2617. {
  2618. if (airs.Count > 2)
  2619. {
  2620. for (int j = 0; j < airs.Count - 2; j++)
  2621. {
  2622. var CopyRow = table.Rows[12].Clone(true);
  2623. table.Rows.Add(CopyRow);
  2624. }
  2625. }
  2626. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2627. int index = 0;
  2628. foreach (PropertyInfo property in properties)
  2629. {
  2630. string value = property.GetValue(airs[i]).ToString();
  2631. Cell ishcel0 = table.Rows[row].Cells[index];
  2632. Paragraph p = new Paragraph(doc);
  2633. string s = value;
  2634. p.AppendChild(new Run(doc, s));
  2635. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2636. ishcel0.AppendChild(p);
  2637. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2638. //ishcel0.CellFormat.VerticalAlignment=
  2639. index++;
  2640. }
  2641. row++;
  2642. }
  2643. #endregion
  2644. Paragraph lastParagraph = new Paragraph(doc);
  2645. //第一个表格末尾加段落
  2646. table.ParentNode.InsertAfter(lastParagraph, table);
  2647. //复制第一个表格
  2648. Table cloneTable = (Table)table.Clone(true);
  2649. //在文档末尾段落后面加入复制的表格
  2650. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2651. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2652. {
  2653. int rownewsIndex = 13;
  2654. for (int i = 0; i < 2; i++)
  2655. {
  2656. var CopyRow = table.Rows[12].Clone(true);
  2657. table.Rows.RemoveAt(13);
  2658. table.Rows.Add(CopyRow);
  2659. rownewsIndex++;
  2660. }
  2661. }
  2662. else
  2663. {
  2664. table.Rows.RemoveAt(12);
  2665. }
  2666. cloneTable.Rows.RemoveAt(12);
  2667. }
  2668. if (_AirTicketReservations.Count != 0)
  2669. {
  2670. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2671. if (FlightsCode.Length != 0)
  2672. {
  2673. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2674. if (_AirCompany != null)
  2675. {
  2676. string str = "--";
  2677. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2678. if (!string.IsNullOrEmpty(translateResult))
  2679. {
  2680. str = translateResult;
  2681. str = _airTicketResRep.Processing(str);
  2682. }
  2683. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2684. }
  2685. else
  2686. {
  2687. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2688. }
  2689. }
  2690. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2691. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2692. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2693. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2694. string names = "";
  2695. foreach (string clientName in nameArray)
  2696. {
  2697. names += clientName + ",";
  2698. }
  2699. if (!string.IsNullOrWhiteSpace(names))
  2700. {
  2701. string str = "--";
  2702. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2703. if (!string.IsNullOrEmpty(translateResult))
  2704. {
  2705. str = translateResult;
  2706. str = _airTicketResRep.Processing(str);
  2707. }
  2708. table.Range.Bookmarks["ClientName"].Text = str;
  2709. }
  2710. else
  2711. {
  2712. table.Range.Bookmarks["ClientName"].Text = "--";
  2713. }
  2714. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2715. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2716. table.Range.Bookmarks["JointTicket"].Text = "--";
  2717. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2718. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2719. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2720. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2721. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2722. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2723. }
  2724. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2725. //保存合并后的文档
  2726. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2727. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2728. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2729. return Ok(JsonView(true, "成功!", rst));
  2730. }
  2731. }
  2732. }
  2733. catch (Exception ex)
  2734. {
  2735. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2736. throw;
  2737. }
  2738. }
  2739. #endregion
  2740. #region 团组增减款项 --> 其他款项
  2741. /// <summary>
  2742. /// 团组增减款项下拉框绑定
  2743. /// </summary>
  2744. /// <param name="dto"></param>
  2745. /// <returns></returns>
  2746. [HttpPost]
  2747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2748. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2749. {
  2750. #region 参数验证
  2751. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2752. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2753. #endregion
  2754. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2755. }
  2756. /// <summary>
  2757. /// 根据团组Id查询团组增减款项
  2758. /// </summary>
  2759. /// <param name="dto"></param>
  2760. /// <returns></returns>
  2761. [HttpPost]
  2762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2763. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2764. {
  2765. #region 参数验证
  2766. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2767. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2768. #endregion
  2769. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2770. }
  2771. /// <summary>
  2772. /// 团组增减款项操作(Status:1.新增,2.修改)
  2773. /// </summary>
  2774. /// <param name="dto"></param>
  2775. /// <returns></returns>
  2776. [HttpPost]
  2777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2778. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2779. {
  2780. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2781. if (groupData.Code != 200)
  2782. {
  2783. return Ok(JsonView(false, groupData.Msg));
  2784. }
  2785. #region 应用推送
  2786. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2787. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2788. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2789. #endregion
  2790. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2791. }
  2792. /// <summary>
  2793. /// 团组增减款项操作 删除
  2794. /// </summary>
  2795. /// <param name="dto"></param>
  2796. /// <returns></returns>
  2797. [HttpPost]
  2798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2799. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2800. {
  2801. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2802. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2803. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2804. if (res.Code == 0)
  2805. {
  2806. return Ok(JsonView(true, "删除成功!"));
  2807. }
  2808. return Ok(JsonView(false, "删除失败!"));
  2809. }
  2810. /// <summary>
  2811. /// 根据团组增减款项Id查询
  2812. /// </summary>
  2813. /// <param name="dto"></param>
  2814. /// <returns></returns>
  2815. [HttpPost]
  2816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2817. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2818. {
  2819. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2820. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2821. }
  2822. /// <summary>
  2823. /// 查询供应商名称
  2824. /// </summary>
  2825. /// <param name="dto"></param>
  2826. /// <returns></returns>
  2827. [HttpPost]
  2828. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2829. {
  2830. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2831. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2832. ?? new List<Grp_DecreasePayments>();
  2833. dbResult = dbResult.Distinct(new
  2834. ProductComparer()).ToList();
  2835. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2836. {
  2837. x.Id,
  2838. x.SupplierAddress,
  2839. x.SupplierArea,
  2840. x.SupplierContact,
  2841. x.SupplierContactNumber,
  2842. x.SupplierEmail,
  2843. x.SupplierName,
  2844. x.SupplierSocialAccount,
  2845. x.SupplierTypeId,
  2846. }).ToList());
  2847. return Ok(jw);
  2848. }
  2849. #endregion
  2850. #region 文件上传、删除
  2851. /// <summary>
  2852. /// region 文件上传 可以带参数
  2853. /// </summary>
  2854. /// <param name="file"></param>
  2855. /// <returns></returns>
  2856. [HttpPost]
  2857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2858. public async Task<IActionResult> UploadProject(IFormFile file)
  2859. {
  2860. try
  2861. {
  2862. var TypeName = Request.Headers["TypeName"].ToString();
  2863. if (file != null)
  2864. {
  2865. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2866. //文件名称
  2867. string projectFileName = file.FileName;
  2868. //上传的文件的路径
  2869. string filePath = "";
  2870. if (TypeName == "A")//A代表团组增减款项
  2871. {
  2872. if (!Directory.Exists(fileDir))
  2873. {
  2874. Directory.CreateDirectory(fileDir);
  2875. }
  2876. //上传的文件的路径
  2877. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2878. }
  2879. else if (TypeName == "B")//B代表商邀相关文件
  2880. {
  2881. if (!Directory.Exists(fileDir))
  2882. {
  2883. Directory.CreateDirectory(fileDir);
  2884. }
  2885. //上传的文件的路径
  2886. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2887. }
  2888. using (FileStream fs = System.IO.File.Create(filePath))
  2889. {
  2890. file.CopyTo(fs);
  2891. fs.Flush();
  2892. }
  2893. return Ok(JsonView(true, "上传成功!", projectFileName));
  2894. }
  2895. else
  2896. {
  2897. return Ok(JsonView(false, "上传失败!"));
  2898. }
  2899. }
  2900. catch (Exception ex)
  2901. {
  2902. return Ok(JsonView(false, "程序错误!"));
  2903. throw;
  2904. }
  2905. }
  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> DelFile(DelFileDto dto)
  2914. {
  2915. try
  2916. {
  2917. var TypeName = Request.Headers["TypeName"].ToString();
  2918. string filePath = "";
  2919. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2920. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2921. int id = 0;
  2922. if (TypeName == "A")
  2923. {
  2924. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2925. // 删除该文件
  2926. System.IO.File.Delete(filePath);
  2927. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2928. }
  2929. else if (TypeName == "B")
  2930. {
  2931. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2932. // 删除该文件
  2933. System.IO.File.Delete(filePath);
  2934. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2935. }
  2936. if (id != 0)
  2937. {
  2938. return Ok(JsonView(true, "成功!"));
  2939. }
  2940. else
  2941. {
  2942. return Ok(JsonView(false, "失败!"));
  2943. }
  2944. }
  2945. catch (Exception ex)
  2946. {
  2947. return Ok(JsonView(false, "程序错误!"));
  2948. throw;
  2949. }
  2950. }
  2951. #endregion
  2952. #region 商邀费用录入
  2953. /// <summary>
  2954. /// 根据团组Id查询商邀费用列表
  2955. /// </summary>
  2956. /// <param name="dto"></param>
  2957. /// <returns></returns>
  2958. [HttpPost]
  2959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2960. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2961. {
  2962. try
  2963. {
  2964. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2965. if (groupData.Code != 0)
  2966. {
  2967. return Ok(JsonView(false, groupData.Msg));
  2968. }
  2969. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2970. }
  2971. catch (Exception ex)
  2972. {
  2973. return Ok(JsonView(false, "程序错误!"));
  2974. throw;
  2975. }
  2976. }
  2977. //
  2978. /// <summary>
  2979. /// 商邀费用 Info Page 基础数据源
  2980. /// </summary>
  2981. /// <param name="dto"></param>
  2982. /// <returns></returns>
  2983. [HttpPost]
  2984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2985. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2986. {
  2987. try
  2988. {
  2989. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2990. if (groupData.Code != 0)
  2991. {
  2992. return Ok(JsonView(false, groupData.Msg));
  2993. }
  2994. return Ok(JsonView(true, "操作成功", groupData.Data));
  2995. }
  2996. catch (Exception ex)
  2997. {
  2998. return Ok(JsonView(false, ex.Message));
  2999. throw;
  3000. }
  3001. }
  3002. /// <summary>
  3003. /// 根据商邀费用ID查询C表和商邀费用数据
  3004. /// </summary>
  3005. /// <param name="dto"></param>
  3006. /// <returns></returns>
  3007. [HttpPost]
  3008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3009. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3010. {
  3011. try
  3012. {
  3013. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3014. if (groupData.Code != 0)
  3015. {
  3016. return Ok(JsonView(false, groupData.Msg));
  3017. }
  3018. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3019. }
  3020. catch (Exception ex)
  3021. {
  3022. return Ok(JsonView(false, ex.Message));
  3023. throw;
  3024. }
  3025. }
  3026. /// <summary>
  3027. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3028. /// </summary>
  3029. /// <param name="dto"></param>
  3030. /// <returns></returns>
  3031. [HttpPost]
  3032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3033. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3034. {
  3035. try
  3036. {
  3037. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3038. if (groupData.Code != 0)
  3039. {
  3040. return Ok(JsonView(false, groupData.Msg));
  3041. }
  3042. #region 应用推送
  3043. try
  3044. {
  3045. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3046. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3047. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3048. }
  3049. catch (Exception ex)
  3050. {
  3051. }
  3052. #endregion
  3053. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3054. }
  3055. catch (Exception ex)
  3056. {
  3057. return Ok(JsonView(false, "程序错误!"));
  3058. throw;
  3059. }
  3060. }
  3061. /// <summary>
  3062. /// 商邀删除
  3063. /// </summary>
  3064. /// <param name="dto"></param>
  3065. /// <returns></returns>
  3066. [HttpPost]
  3067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3068. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3069. {
  3070. try
  3071. {
  3072. _sqlSugar.BeginTran();
  3073. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3074. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3075. {
  3076. IsDel = 1,
  3077. DeleteUserId = dto.DeleteUserId,
  3078. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3079. })
  3080. .Where(it => it.Id == dto.Id)
  3081. .ExecuteCommand();
  3082. if (res1 > 0)
  3083. {
  3084. int _diId = 0;
  3085. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3086. if (_ioaInfo != null)
  3087. {
  3088. _diId = _ioaInfo.DiId;
  3089. }
  3090. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3091. .SetColumns(a => new Grp_CreditCardPayment()
  3092. {
  3093. IsDel = 1,
  3094. DeleteUserId = dto.DeleteUserId,
  3095. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3096. })
  3097. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3098. .ExecuteCommand();
  3099. if (res2 > 0)
  3100. {
  3101. _sqlSugar.CommitTran();
  3102. return Ok(JsonView(true, "删除成功!"));
  3103. }
  3104. }
  3105. _sqlSugar.RollbackTran();
  3106. return Ok(JsonView(false, "删除失败"));
  3107. }
  3108. catch (Exception ex)
  3109. {
  3110. _sqlSugar.RollbackTran();
  3111. return Ok(JsonView(false, ex.Message));
  3112. }
  3113. }
  3114. #endregion
  3115. #region 团组英文资料
  3116. /// <summary>
  3117. /// 查询团组英文所有资料
  3118. /// </summary>
  3119. /// <param name="dto"></param>
  3120. /// <returns></returns>
  3121. [HttpPost]
  3122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3123. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3124. {
  3125. try
  3126. {
  3127. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3128. if (groupData.Code != 0)
  3129. {
  3130. return Ok(JsonView(false, groupData.Msg));
  3131. }
  3132. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3133. }
  3134. catch (Exception ex)
  3135. {
  3136. return Ok(JsonView(false, "程序错误!"));
  3137. throw;
  3138. }
  3139. }
  3140. /// <summary>
  3141. /// 团组英文资料操作(Status:1.新增,2.修改)
  3142. /// </summary>
  3143. /// <param name="dto"></param>
  3144. /// <returns></returns>
  3145. [HttpPost]
  3146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3147. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3148. {
  3149. try
  3150. {
  3151. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3152. if (groupData.Code != 0)
  3153. {
  3154. return Ok(JsonView(false, groupData.Msg));
  3155. }
  3156. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3157. }
  3158. catch (Exception ex)
  3159. {
  3160. return Ok(JsonView(false, "程序错误!"));
  3161. throw;
  3162. }
  3163. }
  3164. /// <summary>
  3165. /// 团组英文资料Id查询数据
  3166. /// </summary>
  3167. /// <param name="dto"></param>
  3168. /// <returns></returns>
  3169. [HttpPost]
  3170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3171. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3172. {
  3173. try
  3174. {
  3175. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3176. if (_DelegationEnData != null)
  3177. {
  3178. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3179. }
  3180. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3181. }
  3182. catch (Exception ex)
  3183. {
  3184. return Ok(JsonView(false, "程序错误!"));
  3185. throw;
  3186. }
  3187. }
  3188. /// <summary>
  3189. /// 团组英文资料删除
  3190. /// </summary>
  3191. /// <param name="dto"></param>
  3192. /// <returns></returns>
  3193. [HttpPost]
  3194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3195. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3196. {
  3197. try
  3198. {
  3199. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3200. if (!res)
  3201. {
  3202. return Ok(JsonView(false, "删除失败"));
  3203. }
  3204. return Ok(JsonView(true, "删除成功!"));
  3205. }
  3206. catch (Exception ex)
  3207. {
  3208. return Ok(JsonView(false, "程序错误!"));
  3209. throw;
  3210. }
  3211. }
  3212. #endregion
  3213. #region 导出邀请函
  3214. /// <summary>
  3215. /// 导出邀请函页面初始化
  3216. /// </summary>
  3217. /// <param name="dto"></param>
  3218. /// <returns></returns>
  3219. [HttpPost]
  3220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3221. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3222. {
  3223. try
  3224. {
  3225. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3226. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3227. if (dto.DiId == 0)
  3228. {
  3229. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3230. }
  3231. else
  3232. {
  3233. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3234. }
  3235. return Ok(JsonView(true, "查询成功!", new
  3236. {
  3237. deleClient = crm_Deles,
  3238. delegations = grp_Delegations
  3239. }));
  3240. }
  3241. catch (Exception ex)
  3242. {
  3243. return Ok(JsonView(false, "程序错误!"));
  3244. throw;
  3245. }
  3246. }
  3247. /// <summary>
  3248. /// 导出邀请函
  3249. /// </summary>
  3250. /// <param name="dto"></param>
  3251. /// <returns></returns>
  3252. [HttpPost]
  3253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3254. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3255. {
  3256. #region 参数验证
  3257. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3258. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3259. #endregion
  3260. try
  3261. {
  3262. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3263. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3264. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3265. From Grp_TourClientList tcl
  3266. Left Join
  3267. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3268. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3269. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3270. From Crm_DeleClient dc
  3271. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3272. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3273. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3274. Where dc.IsDel = 0) temp
  3275. On temp.DcId =tcl.ClientId
  3276. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3277. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3278. List<string> texts = new List<string>();
  3279. if (datas.Count != 0)
  3280. {
  3281. foreach (TourClientListDetailsView item in datas)
  3282. {
  3283. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3284. {
  3285. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3286. }
  3287. else
  3288. {
  3289. string name = item.LastName + item.FirstName;
  3290. texts.Add(name);
  3291. }
  3292. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3293. {
  3294. if (!transDic.ContainsKey(item.Job))
  3295. {
  3296. texts.Add(item.Job);
  3297. }
  3298. }
  3299. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3300. {
  3301. texts.Add(item.CompanyFullName);
  3302. }
  3303. }
  3304. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3305. if (transData.Count > 0)
  3306. {
  3307. foreach (TranslateResult item in transData)
  3308. {
  3309. if (!transDic.ContainsKey(item.Query))
  3310. {
  3311. transDic.Add(item.Query, item.Translation);
  3312. }
  3313. }
  3314. }
  3315. List<GuestList> list = new List<GuestList>();
  3316. foreach (TourClientListDetailsView dele in datas)
  3317. {
  3318. GuestList guestList = new GuestList();
  3319. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3320. {
  3321. guestList.Name = dele.Pinyin;
  3322. }
  3323. else
  3324. {
  3325. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3326. guestList.Name = Name;
  3327. }
  3328. if (dele.Sex == 0)
  3329. {
  3330. guestList.Sex = "Male";
  3331. }
  3332. else if (dele.Sex == 1)
  3333. {
  3334. guestList.Sex = "Female";
  3335. }
  3336. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3337. if (!string.IsNullOrEmpty(dele.Job))
  3338. {
  3339. guestList.Job = dele.Job;
  3340. }
  3341. list.Add(guestList);
  3342. }
  3343. //载入模板
  3344. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3345. DocumentBuilder builder = new DocumentBuilder(doc);
  3346. //获取word里所有表格
  3347. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3348. //获取所填表格的序数
  3349. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3350. var rowStart = tableOne.Rows[0]; //获取第1行
  3351. //循环赋值
  3352. for (int i = 0; i < list.Count; i++)
  3353. {
  3354. builder.MoveToCell(0, i + 1, 0, 0);
  3355. builder.Write(list[i].Name.ToString());
  3356. builder.MoveToCell(0, i + 1, 1, 0);
  3357. builder.Write(list[i].Sex.ToString());
  3358. builder.MoveToCell(0, i + 1, 2, 0);
  3359. builder.Write(list[i].DOB.ToString());
  3360. builder.MoveToCell(0, i + 1, 3, 0);
  3361. builder.Write(list[i].Job.ToString());
  3362. }
  3363. //删除多余行
  3364. while (tableOne.Rows.Count > list.Count + 1)
  3365. {
  3366. tableOne.Rows.RemoveAt(list.Count + 1);
  3367. }
  3368. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3369. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3370. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3371. doc.Save(filePath);
  3372. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3373. return Ok(JsonView(true, "操作成功!", Url));
  3374. }
  3375. else
  3376. {
  3377. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3378. }
  3379. }
  3380. catch (Exception ex)
  3381. {
  3382. return Ok(JsonView(false, ex.Message));
  3383. throw;
  3384. }
  3385. }
  3386. #endregion
  3387. #region 团组经理模块 出入境费用
  3388. ///// <summary>
  3389. ///// 团组模块 - 出入境费用
  3390. ///// </summary>
  3391. ///// <returns></returns>
  3392. //[HttpPost]
  3393. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3394. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3395. //{
  3396. // try
  3397. // {
  3398. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3399. // if (data.Code != 0)
  3400. // {
  3401. // return Ok(JsonView(false, data.Msg));
  3402. // }
  3403. // return Ok(JsonView(true, "查询成功!"));
  3404. // }
  3405. // catch (Exception ex)
  3406. // {
  3407. // return Ok(JsonView(false, ex.Message));
  3408. // throw;
  3409. // }
  3410. //}
  3411. /// <summary>
  3412. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3413. /// </summary>
  3414. /// <returns></returns>
  3415. [HttpPost]
  3416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3417. public async Task<IActionResult> SetDayAndCostAreaChange()
  3418. {
  3419. try
  3420. {
  3421. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3422. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3423. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3424. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3425. foreach (var item in unite) //处理交集数据
  3426. {
  3427. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3428. }
  3429. foreach (var item in merge) //处理差集数据
  3430. {
  3431. int nationalTravelFeeId = 0;
  3432. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3433. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3434. else
  3435. {
  3436. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3437. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3438. }
  3439. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3440. }
  3441. //只更新dayAndCost 的 nationalTravelFeeId;
  3442. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3443. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3444. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3445. }
  3446. catch (Exception ex)
  3447. {
  3448. return Ok(JsonView(false, ex.Message));
  3449. throw;
  3450. }
  3451. }
  3452. /// <summary>
  3453. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3454. /// </summary>
  3455. /// <returns></returns>
  3456. [HttpPost]
  3457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3458. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3459. {
  3460. try
  3461. {
  3462. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3463. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3464. //SetDataInfoView
  3465. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3466. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3467. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3468. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3469. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3470. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3471. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3472. //默认币种显示
  3473. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3474. {
  3475. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3476. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3477. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3478. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3479. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3480. };
  3481. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3482. if (_currencyRate.Count > 0)
  3483. {
  3484. foreach (var item in _currencyInfos)
  3485. {
  3486. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3487. if (rateInfo != null)
  3488. {
  3489. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3490. rate1 *= 1.035M;
  3491. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3492. }
  3493. }
  3494. }
  3495. return Ok(JsonView(true, "查询成功!", new
  3496. {
  3497. GroupNameData = groupNameData.Data,
  3498. CurrencyData = _CurrencyData,
  3499. WordTypeData = _WordTypeData,
  3500. ExcelTypeData = _ExcelTypeData,
  3501. CurrencyInit = _currencyInfos
  3502. }));
  3503. }
  3504. catch (Exception ex)
  3505. {
  3506. return Ok(JsonView(false, ex.Message));
  3507. throw;
  3508. }
  3509. }
  3510. /// <summary>
  3511. /// 团组模块 - 出入境费用
  3512. /// 实时汇率 tips
  3513. /// 签证费用 tips
  3514. /// </summary>
  3515. /// <returns></returns>
  3516. [HttpPost]
  3517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3518. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3519. {
  3520. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3521. //默认币种显示
  3522. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3523. {
  3524. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3525. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3526. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3527. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3528. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3529. };
  3530. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3531. List<dynamic> reteInfos = new List<dynamic>();
  3532. if (_currencyRate.Count > 0)
  3533. {
  3534. foreach (var item in _currencyInfos)
  3535. {
  3536. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3537. if (rateInfo != null)
  3538. {
  3539. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3540. decimal rate1 = item.Rate;
  3541. rate1 *= 1.03M;
  3542. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3543. reteInfos.Add(new
  3544. {
  3545. currCode = item.CurrencyCode,
  3546. currName = item.CurrencyName,
  3547. rate = rate2,
  3548. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3549. });
  3550. }
  3551. }
  3552. }
  3553. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3554. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3555. return Ok(JsonView(true, "查询成功!", new
  3556. {
  3557. //GroupNameData = groupNameData.Data,
  3558. visaData = visaData.Data,
  3559. airData = airData.Data,
  3560. reteInfos = reteInfos
  3561. }));
  3562. }
  3563. /// <summary>
  3564. /// 团组模块 - 出入境费用 - Info
  3565. /// </summary>
  3566. /// <returns></returns>
  3567. [HttpPost]
  3568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3569. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3570. {
  3571. try
  3572. {
  3573. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3574. if (data.Code != 0)
  3575. {
  3576. return Ok(JsonView(false, data.Msg));
  3577. }
  3578. return Ok(JsonView(true, "查询成功!", data.Data));
  3579. }
  3580. catch (Exception ex)
  3581. {
  3582. return Ok(JsonView(false, ex.Message));
  3583. }
  3584. }
  3585. /// <summary>
  3586. /// 团组模块 - 出入境费用 - Add And Update
  3587. /// </summary>
  3588. /// <returns></returns>
  3589. [HttpPost]
  3590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3591. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3592. {
  3593. try
  3594. {
  3595. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3596. if (data.Code != 0)
  3597. {
  3598. return Ok(JsonView(false, data.Msg));
  3599. }
  3600. return Ok(JsonView(true, data.Msg, data.Data));
  3601. }
  3602. catch (Exception ex)
  3603. {
  3604. return Ok(JsonView(false, ex.Message));
  3605. }
  3606. }
  3607. /// <summary>
  3608. /// 团组模块 - 出入境费用 - File downlaod
  3609. /// </summary>
  3610. /// <param name="dto"></param>
  3611. /// <returns></returns>
  3612. [HttpPost]
  3613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3614. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3615. {
  3616. try
  3617. {
  3618. if (dto.DiId < 1)
  3619. {
  3620. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3621. }
  3622. if (dto.ExportType < 1)
  3623. {
  3624. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3625. }
  3626. if (dto.SubTypeId < 1)
  3627. {
  3628. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3629. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3630. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3631. 3 团组成员名单 1 团组成员名单"));
  3632. }
  3633. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3634. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3635. if (_EnterExitCosts == null)
  3636. {
  3637. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3638. }
  3639. //数据源
  3640. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3641. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3642. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3643. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3644. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3645. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3646. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3647. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3648. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3649. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3650. .Select((tcl, dc, cc) => new
  3651. {
  3652. Name = dc.LastName + dc.FirstName,
  3653. Sex = dc.Sex,
  3654. Birthday = dc.BirthDay,
  3655. Company = cc.CompanyFullName,
  3656. Job = dc.Job
  3657. })
  3658. .ToList();
  3659. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3660. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3661. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3662. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3663. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3664. if (dto.ExportType == 1) //明细表
  3665. {
  3666. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3667. {
  3668. //获取模板
  3669. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3670. //载入模板
  3671. Document doc = new Document(tempPath);
  3672. DocumentBuilder builder = new DocumentBuilder(doc);
  3673. //利用键值对存放数据
  3674. Dictionary<string, string> dic = new Dictionary<string, string>();
  3675. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3676. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3677. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3678. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3679. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3680. string row1_1 = "";
  3681. if (_EnterExitCosts.Visa > 0)
  3682. {
  3683. //insidePayTotal += _EnterExitCosts.Visa;
  3684. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3685. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3686. {
  3687. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3688. }
  3689. }
  3690. string row1_2 = "";
  3691. if (_EnterExitCosts.YiMiao > 0)
  3692. {
  3693. //insidePayTotal += _EnterExitCosts.YiMiao;
  3694. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3695. }
  3696. if (_EnterExitCosts.HeSuan > 0)
  3697. {
  3698. //insidePayTotal += _EnterExitCosts.HeSuan;
  3699. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3700. }
  3701. if (_EnterExitCosts.Service > 0)
  3702. {
  3703. //insidePayTotal += _EnterExitCosts.Service;
  3704. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3705. }
  3706. string row1_3 = "";
  3707. if (_EnterExitCosts.Safe > 0)
  3708. {
  3709. //insidePayTotal += _EnterExitCosts.Safe;
  3710. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3711. }
  3712. if (_EnterExitCosts.Ticket > 0)
  3713. {
  3714. //insidePayTotal += _EnterExitCosts.Ticket;
  3715. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3716. }
  3717. string row1 = "";
  3718. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3719. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3720. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3721. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3722. dic.Add("Row1Str", row1);
  3723. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3724. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3725. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3726. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3727. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3728. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3729. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3730. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3731. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3732. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3733. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3734. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3735. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3736. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3737. #region 填充word模板书签内容
  3738. foreach (var key in dic.Keys)
  3739. {
  3740. builder.MoveToBookmark(key);
  3741. builder.Write(dic[key]);
  3742. }
  3743. #endregion
  3744. #region 填充word表格内容
  3745. ////获读取指定表格方法二
  3746. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3747. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3748. for (int i = 0; i < dac1.Count; i++)
  3749. {
  3750. Grp_DayAndCost dac = dac1[i];
  3751. if (dac == null) continue;
  3752. builder.MoveToCell(0, i, 0, 0);
  3753. builder.Write("第" + dac.Days.ToString() + "晚:");
  3754. builder.MoveToCell(0, i, 1, 0);
  3755. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3756. //builder.Write(dac.Place == null ? "" : dac.Place);
  3757. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3758. builder.MoveToCell(0, i, 2, 0);
  3759. builder.Write("费用标准:");
  3760. string curr = "";
  3761. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3762. if (currData != null)
  3763. {
  3764. curr = currData.Name;
  3765. }
  3766. builder.MoveToCell(0, i, 3, 0);
  3767. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3768. builder.MoveToCell(0, i, 4, 0);
  3769. builder.Write("费用小计:");
  3770. builder.MoveToCell(0, i, 5, 0);
  3771. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3772. }
  3773. //删除多余行
  3774. while (table1.Rows.Count > dac1.Count)
  3775. {
  3776. table1.Rows.RemoveAt(dac1.Count);
  3777. }
  3778. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3779. for (int i = 0; i < dac2.Count; i++)
  3780. {
  3781. Grp_DayAndCost dac = dac2[i];
  3782. if (dac == null) continue;
  3783. builder.MoveToCell(1, i, 0, 0);
  3784. builder.Write("第" + dac.Days.ToString() + "天:");
  3785. builder.MoveToCell(1, i, 1, 0);
  3786. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3787. builder.MoveToCell(1, i, 2, 0);
  3788. builder.Write("费用标准:");
  3789. string curr = "";
  3790. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3791. if (currData != null)
  3792. {
  3793. curr = currData.Name;
  3794. }
  3795. builder.MoveToCell(1, i, 3, 0);
  3796. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3797. builder.MoveToCell(1, i, 4, 0);
  3798. builder.Write("费用小计:");
  3799. builder.MoveToCell(1, i, 5, 0);
  3800. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3801. }
  3802. //删除多余行
  3803. while (table2.Rows.Count > dac2.Count)
  3804. {
  3805. table2.Rows.RemoveAt(dac2.Count);
  3806. }
  3807. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3808. for (int i = 0; i < dac3.Count; i++)
  3809. {
  3810. Grp_DayAndCost dac = dac3[i];
  3811. if (dac == null) continue;
  3812. builder.MoveToCell(2, i, 0, 0);
  3813. builder.Write("第" + dac.Days.ToString() + "天:");
  3814. builder.MoveToCell(2, i, 1, 0);
  3815. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3816. builder.MoveToCell(2, i, 2, 0);
  3817. builder.Write("费用标准:");
  3818. string curr = "";
  3819. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3820. if (currData != null)
  3821. {
  3822. curr = currData.Name;
  3823. }
  3824. builder.MoveToCell(2, i, 3, 0);
  3825. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3826. builder.MoveToCell(2, i, 4, 0);
  3827. builder.Write("费用小计:");
  3828. builder.MoveToCell(2, i, 5, 0);
  3829. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3830. }
  3831. //删除多余行
  3832. while (table3.Rows.Count > dac3.Count)
  3833. {
  3834. table3.Rows.RemoveAt(dac3.Count);
  3835. }
  3836. #endregion
  3837. //文件名
  3838. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3839. AsposeHelper.removewatermark_v2180();
  3840. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3841. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3842. return Ok(JsonView(true, "成功", new { Url = url }));
  3843. }
  3844. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3845. {
  3846. //获取模板
  3847. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3848. //载入模板
  3849. Document doc = new Document(tempPath);
  3850. DocumentBuilder builder = new DocumentBuilder(doc);
  3851. Dictionary<string, string> dic = new Dictionary<string, string>();
  3852. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3853. {
  3854. List<string> list = new List<string>();
  3855. try
  3856. {
  3857. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3858. foreach (var item in spilitArr)
  3859. {
  3860. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3861. var depCode = spDotandEmpty[2].Substring(0, 3);
  3862. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3863. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3864. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3865. list.Add(depName);
  3866. list.Add(arrName);
  3867. }
  3868. list = list.Distinct().ToList();
  3869. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3870. }
  3871. catch (Exception)
  3872. {
  3873. dic.Add("ReturnCode", "行程录入不正确!");
  3874. }
  3875. }
  3876. else
  3877. {
  3878. dic.Add("ReturnCode", "未录入行程!");
  3879. }
  3880. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3881. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3882. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3883. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3884. {
  3885. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3886. dic.Add("Day", sp.Days.ToString());
  3887. }
  3888. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3889. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3890. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3891. //dic.Add("Names", Names);
  3892. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3893. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3894. decimal dac1totalPrice = 0.00M;
  3895. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3896. foreach (var dac in dac1)
  3897. {
  3898. if (dac.SubTotal == 0.00M)
  3899. {
  3900. continue;
  3901. }
  3902. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3903. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3904. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3905. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3906. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3907. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3908. builder.Write(currency);//币种
  3909. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3910. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3911. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3912. builder.Write("");//人数
  3913. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3914. builder.Write("");//天数
  3915. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3916. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3917. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3918. decimal rate = 0.00M;
  3919. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3920. builder.Write(rate.ToString("#0.0000"));//汇率
  3921. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3922. decimal rbmPrice = dac.SubTotal;
  3923. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3924. accommodationStartIndex++;
  3925. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3926. }
  3927. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3928. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3929. {
  3930. table1.Rows.RemoveAt(i - 1);
  3931. foodandotherStartIndex--;
  3932. }
  3933. if (dac2.Count == dac3.Count)//国家 币种 金额
  3934. {
  3935. for (int i = 0; i < dac2.Count; i++)
  3936. {
  3937. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3938. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3939. }
  3940. }
  3941. decimal dac2totalPrice = 0.00M;
  3942. foreach (var dac in dac2)
  3943. {
  3944. if (dac.SubTotal == 0)
  3945. {
  3946. continue;
  3947. }
  3948. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3949. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3950. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3951. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3952. builder.Write(currency);//币种
  3953. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3954. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3955. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3956. builder.Write("");//人数
  3957. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3958. builder.Write("");//天数
  3959. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3960. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3961. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3962. decimal rate = 0.00M;
  3963. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3964. builder.Write(rate.ToString("#0.0000"));//汇率
  3965. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3966. decimal rbmPrice = dac.SubTotal;
  3967. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3968. foodandotherStartIndex++;
  3969. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3970. }
  3971. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3972. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3973. {
  3974. table1.Rows.RemoveAt(i - 1);
  3975. }
  3976. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3977. string otherFeeStr = "";
  3978. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  3979. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  3980. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  3981. if (otherFeeStr.Length > 0)
  3982. {
  3983. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  3984. otherFeeStr = $"({otherFeeStr})";
  3985. dic.Add("OtherFeeStr", otherFeeStr);
  3986. }
  3987. //总计
  3988. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  3989. //国际旅费
  3990. string outsideJJ = "";
  3991. string allPriceJJ = "";
  3992. if (_EnterExitCosts.SumJJC == 1)
  3993. {
  3994. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3995. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  3996. }
  3997. string outsideGW = "";
  3998. string allPriceGW = "";
  3999. if (_EnterExitCosts.SumGWC == 1)
  4000. {
  4001. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  4002. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4003. }
  4004. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  4005. {
  4006. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  4007. dic.Add("InTravelPrice", InTravelPriceStr);
  4008. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  4009. dic.Add("FinalSumPrice", FinalSumPriceStr);
  4010. }
  4011. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4012. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4013. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4014. foreach (var key in dic.Keys)
  4015. {
  4016. builder.MoveToBookmark(key);
  4017. builder.Write(dic[key]);
  4018. }
  4019. //模板文件名
  4020. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  4021. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4022. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4023. return Ok(JsonView(true, "成功", new { Url = url }));
  4024. }
  4025. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4026. {
  4027. //获取模板
  4028. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4029. //载入模板
  4030. WorkbookDesigner designer = new WorkbookDesigner();
  4031. designer.Workbook = new Workbook(tempPath);
  4032. Dictionary<string, string> dic = new Dictionary<string, string>();
  4033. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4034. {
  4035. List<string> list = new List<string>();
  4036. try
  4037. {
  4038. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4039. foreach (var item in spilitArr)
  4040. {
  4041. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4042. var depCode = spDotandEmpty[2].Substring(0, 3);
  4043. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4044. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4045. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4046. list.Add(depName);
  4047. list.Add(arrName);
  4048. }
  4049. list = list.Distinct().ToList();
  4050. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4051. }
  4052. catch (Exception)
  4053. {
  4054. dic.Add("ReturnCode", "行程录入不正确!");
  4055. }
  4056. }
  4057. else
  4058. {
  4059. dic.Add("ReturnCode", "未录入行程!");
  4060. }
  4061. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4062. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4063. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4064. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4065. {
  4066. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4067. dic.Add("Day", sp.Days.ToString());
  4068. }
  4069. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4070. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4071. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4072. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4073. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4074. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4075. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4076. designer.SetDataSource("Name", Names);
  4077. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4078. designer.SetDataSource("Day", dic["Day"] + "天");
  4079. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4080. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4081. int startIndex = 10;
  4082. const int startIndexcopy = 10;
  4083. if (dac2.Count == dac3.Count)//国家 币种 金额
  4084. {
  4085. for (int i = 0; i < dac2.Count; i++)
  4086. {
  4087. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4088. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4089. }
  4090. }
  4091. DataTable dtdac1 = new DataTable();
  4092. List<string> place = new List<string>();
  4093. dtdac1.Columns.AddRange(new DataColumn[] {
  4094. new DataColumn(){ ColumnName = "city"},
  4095. new DataColumn(){ ColumnName = "curr"},
  4096. new DataColumn(){ ColumnName = "criterion"},
  4097. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4098. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4099. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4100. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4101. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4102. });
  4103. DataTable dtdac2 = new DataTable();
  4104. dtdac2.Columns.AddRange(new DataColumn[] {
  4105. new DataColumn(){ ColumnName = "city"},
  4106. new DataColumn(){ ColumnName = "curr"},
  4107. new DataColumn(){ ColumnName = "criterion"},
  4108. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4109. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4110. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4111. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4112. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4113. });
  4114. dtdac1.TableName = "tb1";
  4115. dtdac2.TableName = "tb2";
  4116. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4117. foreach (var item in dac1)
  4118. {
  4119. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4120. if (place.Contains(item.Place))
  4121. {
  4122. continue;
  4123. }
  4124. DataRow row = dtdac1.NewRow();
  4125. row["city"] = item.Place;
  4126. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4127. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4128. row["curr"] = currency;
  4129. row["rate"] = rate.ToString("#0.0000");
  4130. row["criterion"] = item.Cost.ToString("#0.00");
  4131. row["number"] = 1;
  4132. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4133. //row["costRMB"] = rbmPrice;
  4134. dtdac1.Rows.Add(row);
  4135. place.Add(item.Place);
  4136. }
  4137. place = new List<string>();
  4138. foreach (var item in dac2)
  4139. {
  4140. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4141. if (place.Contains(item.Place))
  4142. {
  4143. continue;
  4144. }
  4145. DataRow row = dtdac2.NewRow();
  4146. row["city"] = item.Place;
  4147. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4148. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4149. row["curr"] = currency;
  4150. row["rate"] = rate.ToString("#0.0000");
  4151. row["criterion"] = item.Cost.ToString("#0.00");
  4152. row["number"] = 1;
  4153. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4154. //row["cost"] = item.SubTotal;
  4155. //row["costRMB"] = rbmPrice;
  4156. dtdac2.Rows.Add(row);
  4157. place.Add(item.Place);
  4158. //dac2totalPrice += rbmPrice;
  4159. }
  4160. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4161. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4162. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4163. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4164. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4165. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4166. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4167. string cellStr = $" 5.其他费用(";
  4168. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4169. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4170. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4171. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4172. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4173. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4174. if (cellStr.Length > 8)
  4175. {
  4176. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4177. }
  4178. cellStr += ")";
  4179. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4180. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4181. decimal pxFee = dac4.Sum(it => it.Cost);
  4182. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4183. string celllastStr1 = "";
  4184. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4185. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4186. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4187. celllastStr1 += $",国际旅费 元";
  4188. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4189. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4190. designer.SetDataSource("cell4Str", cell4Str);
  4191. designer.SetDataSource("cellStr", cellStr);
  4192. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4193. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4194. designer.SetDataSource("celllastStr", celllastStr);
  4195. Workbook wb = designer.Workbook;
  4196. var sheet = wb.Worksheets[0];
  4197. //绑定datatable数据集
  4198. designer.SetDataSource(dtdac1);
  4199. designer.SetDataSource(dtdac2);
  4200. designer.Process();
  4201. var rowStart = dtdac1.Rows.Count;
  4202. while (rowStart > 0)
  4203. {
  4204. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4205. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4206. startIndex++;
  4207. rowStart--;
  4208. }
  4209. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4210. startIndex += 1; //总计行
  4211. rowStart = dtdac2.Rows.Count;
  4212. while (rowStart > 0)
  4213. {
  4214. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4215. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4216. startIndex++;
  4217. rowStart--;
  4218. }
  4219. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4220. wb.CalculateFormula(true);
  4221. //模板文件名
  4222. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  4223. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4224. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4225. return Ok(JsonView(true, "成功", new { Url = url }));
  4226. }
  4227. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4228. {
  4229. //获取模板
  4230. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4231. //载入模板
  4232. Document doc = new Document(tempPath);
  4233. DocumentBuilder builder = new DocumentBuilder(doc);
  4234. Dictionary<string, string> dic = new Dictionary<string, string>();
  4235. dic.Add("GroupName", _DelegationInfo.TeamName);
  4236. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4237. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4238. string missionLeaderJob = "";//负责人job
  4239. int groupNumber = 0; //团人数
  4240. if (DeleClientList.Count > 0)
  4241. {
  4242. missionLeader = DeleClientList[0]?.Name ?? "";
  4243. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4244. }
  4245. dic.Add("MissionLeader", missionLeader); //团负责人
  4246. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4247. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4248. #region MyRegion
  4249. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4250. //{
  4251. // List<string> list = new List<string>();
  4252. // try
  4253. // {
  4254. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4255. // foreach (var item in spilitArr)
  4256. // {
  4257. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4258. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4259. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4260. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4261. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4262. // list.Add(depName);
  4263. // list.Add(arrName);
  4264. // }
  4265. // list = list.Distinct().ToList();
  4266. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4267. // }
  4268. // catch (Exception)
  4269. // {
  4270. // dic.Add("ReturnCode", "行程录入不正确!");
  4271. // }
  4272. //}
  4273. //else
  4274. //{
  4275. // dic.Add("ReturnCode", "未录入行程!");
  4276. //}
  4277. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4278. dic.Add("ReturnCode", string.Join("、", countrys));
  4279. #endregion
  4280. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4281. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4282. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4283. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4284. //{
  4285. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4286. // dic.Add("Day", sp.Days.ToString());
  4287. //}
  4288. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4289. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4290. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4291. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4292. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4293. //培训人员名单
  4294. int cultivateRowIndex = 7;
  4295. foreach (var item in DeleClientList)
  4296. {
  4297. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4298. builder.Write(item.Name);
  4299. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4300. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4301. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4302. string birthDay = "";
  4303. if (item.Birthday != null)
  4304. {
  4305. DateTime dt = Convert.ToDateTime(item.Birthday);
  4306. birthDay = $"{dt.Year}.{dt.Month}";
  4307. }
  4308. builder.Write(birthDay);
  4309. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4310. builder.Write(item.Company);
  4311. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4312. builder.Write(item.Job);
  4313. cultivateRowIndex++;
  4314. }
  4315. //删除多余行
  4316. //cultivateRowIndex -= 2;
  4317. int delRows = 10 + 7 - cultivateRowIndex;
  4318. if (delRows > 0)
  4319. {
  4320. for (int i = 0; i < delRows; i++)
  4321. {
  4322. table1.Rows.RemoveAt(cultivateRowIndex);
  4323. //cultivateRowIndex++;
  4324. }
  4325. }
  4326. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4327. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4328. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4329. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4330. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4331. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4332. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4333. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4334. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4335. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4336. //其他费用
  4337. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4338. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4339. //其他费用合计
  4340. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4341. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4342. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4343. //公务舱合计
  4344. //国际旅费
  4345. string outsideJJ = "";
  4346. string allPriceJJ = "";
  4347. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4348. {
  4349. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4350. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4351. }
  4352. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4353. {
  4354. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4355. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4356. }
  4357. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4358. {
  4359. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4360. dic.Add("AirFeeTotal", airFeeTotalStr);
  4361. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4362. dic.Add("FeeTotal", feeTotalStr);
  4363. }
  4364. foreach (var key in dic.Keys)
  4365. {
  4366. builder.MoveToBookmark(key);
  4367. builder.Write(dic[key]);
  4368. }
  4369. //模板文件名
  4370. string strFileName = $"{_DelegationInfo.TeamName}成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4371. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4372. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4373. return Ok(JsonView(true, "成功", new { Url = url }));
  4374. }
  4375. }
  4376. else if (dto.ExportType == 2) //表格
  4377. {
  4378. //利用键值对存放数据
  4379. Dictionary<string, string> dic = new Dictionary<string, string>();
  4380. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4381. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4382. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4383. dic.Add("Day", sp.Days.ToString());
  4384. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4385. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4386. {
  4387. //获取模板
  4388. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4389. //载入模板
  4390. Document doc = new Document(tempPath);
  4391. DocumentBuilder builder = new DocumentBuilder(doc);
  4392. dic.Add("TeamName", _DelegationInfo.TeamName);
  4393. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4394. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4395. string missionLeaderName = "",
  4396. missionLeaderJob = "";
  4397. if (DeleClientList.Count > 0)
  4398. {
  4399. missionLeaderName = DeleClientList[0].Name;
  4400. missionLeaderJob = DeleClientList[0].Job;
  4401. }
  4402. dic.Add("MissionLeaderName", missionLeaderName);
  4403. dic.Add("MissionLeaderJob", missionLeaderJob);
  4404. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4405. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4406. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4407. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4408. int rowCount = 10;//总人数行
  4409. int startRowIndex = 7; //起始行
  4410. for (int i = 0; i < DeleClientList.Count; i++)
  4411. {
  4412. builder.MoveToCell(0, startRowIndex, 0, 0);
  4413. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4414. builder.MoveToCell(0, startRowIndex, 1, 0);
  4415. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4416. builder.Write(sex);//性别
  4417. builder.MoveToCell(0, startRowIndex, 2, 0);
  4418. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4419. builder.MoveToCell(0, startRowIndex, 3, 0);
  4420. builder.Write(DeleClientList[i].Company);//工作单位
  4421. builder.MoveToCell(0, startRowIndex, 4, 0);
  4422. builder.Write(DeleClientList[i].Job);//职务及级别
  4423. builder.MoveToCell(0, startRowIndex, 5, 0);
  4424. builder.Write("");//人员属性
  4425. builder.MoveToCell(0, startRowIndex, 6, 0);
  4426. builder.Write("");//上次出国时间
  4427. startRowIndex++;
  4428. }
  4429. int nullRow = rowCount - DeleClientList.Count;//空行
  4430. for (int i = 0; i < nullRow; i++)
  4431. {
  4432. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4433. }
  4434. foreach (var key in dic.Keys)
  4435. {
  4436. builder.MoveToBookmark(key);
  4437. builder.Write(dic[key]);
  4438. }
  4439. //模板文件名
  4440. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4441. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4442. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4443. return Ok(JsonView(true, "成功", new { Url = url }));
  4444. }
  4445. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4446. {
  4447. //获取模板
  4448. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4449. //载入模板
  4450. Document doc = new Document(tempPath);
  4451. DocumentBuilder builder = new DocumentBuilder(doc);
  4452. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4453. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4454. dic.Add("Names", Names);
  4455. int accommodationRows = 12, foodandotherRows = 12;
  4456. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4457. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4458. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4459. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4460. int accommodationStartIndex = 6;
  4461. decimal dac1totalPrice = 0.00M;
  4462. foreach (var dac in dac1)
  4463. {
  4464. if (dac.SubTotal == 0)
  4465. {
  4466. continue;
  4467. }
  4468. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4469. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4470. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4471. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4472. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4473. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4474. builder.Write(currency);//币种
  4475. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4476. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4477. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4478. builder.Write("");//人数
  4479. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4480. builder.Write("");//天数
  4481. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4482. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4483. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4484. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4485. builder.Write(rate.ToString("#0.0000"));//汇率
  4486. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4487. decimal rbmPrice = rate * dac.SubTotal;
  4488. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4489. accommodationStartIndex++;
  4490. dac1totalPrice += rbmPrice;
  4491. }
  4492. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4493. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4494. builder.Write("小计");
  4495. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4496. builder.Write(dac1totalPrice.ToString("#0.00"));
  4497. accommodationStartIndex++;
  4498. int nullRow = accommodationRows - dac1.Count;
  4499. //删除空行
  4500. //if (nullRow > 0)
  4501. //{
  4502. // int rowIndex = accommodationStartIndex;
  4503. // for (int i = 0; i < nullRow; i++)
  4504. // {
  4505. // Row row = table1.Rows[rowIndex];
  4506. // row.Remove();
  4507. // rowIndex++;
  4508. // }
  4509. //}
  4510. if (dac2.Count == dac3.Count)//国家 币种 金额
  4511. {
  4512. for (int i = 0; i < dac2.Count; i++)
  4513. {
  4514. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4515. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4516. }
  4517. }
  4518. int foodandotherStartIndex = 19;//
  4519. decimal dac2totalPrice = 0.00M;
  4520. foreach (var dac in dac2)
  4521. {
  4522. if (dac.SubTotal == 0)
  4523. {
  4524. continue;
  4525. }
  4526. //foodandotherStartIndex = 12;
  4527. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4528. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4529. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4530. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4531. builder.Write(currency);//币种
  4532. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4533. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4534. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4535. builder.Write("");//人数
  4536. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4537. builder.Write("");//天数
  4538. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4539. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4540. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4541. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4542. builder.Write(rate.ToString("#0.0000"));//汇率
  4543. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4544. decimal rbmPrice = rate * dac.SubTotal;
  4545. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4546. foodandotherStartIndex++;
  4547. dac2totalPrice += rbmPrice;
  4548. }
  4549. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4550. //删除空行
  4551. if (dac2.Count < foodandotherRows)
  4552. {
  4553. //int nullRow = accommodationRows - dac2.Count;
  4554. //while (table2.Rows.Count > dac2.Count)
  4555. //{
  4556. // table2.Rows.RemoveAt(dac2.Count);
  4557. //}
  4558. }
  4559. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4560. string otherFeeStr = "";
  4561. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4562. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4563. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4564. if (otherFeeStr.Length > 0)
  4565. {
  4566. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4567. otherFeeStr = $"({otherFeeStr})";
  4568. dic.Add("OtherFeeStr", otherFeeStr);
  4569. }
  4570. foreach (var key in dic.Keys)
  4571. {
  4572. builder.MoveToBookmark(key);
  4573. builder.Write(dic[key]);
  4574. }
  4575. //模板文件名
  4576. string strFileName = $"省级单位出(境)经费报销单.docx";
  4577. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4578. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4579. return Ok(JsonView(true, "成功", new { Url = url }));
  4580. }
  4581. }
  4582. else if (dto.ExportType == 3)
  4583. {
  4584. if (dto.SubTypeId == 1) //团组成员名单
  4585. {
  4586. if (DeleClientList.Count < 1)
  4587. {
  4588. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4589. }
  4590. //获取模板
  4591. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4592. //载入模板
  4593. Document doc = new Document(tempPath);
  4594. DocumentBuilder builder = new DocumentBuilder(doc);
  4595. //获取word里所有表格
  4596. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4597. //获取所填表格的序数
  4598. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4599. var rowStart = tableOne.Rows[0]; //获取第1行
  4600. //循环赋值
  4601. for (int i = 0; i < DeleClientList.Count; i++)
  4602. {
  4603. builder.MoveToCell(0, i + 1, 0, 0);
  4604. builder.Write(DeleClientList[i].Name);
  4605. builder.MoveToCell(0, i + 1, 1, 0);
  4606. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4607. builder.Write(sex);
  4608. builder.MoveToCell(0, i + 1, 2, 0);
  4609. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4610. builder.MoveToCell(0, i + 1, 3, 0);
  4611. builder.Write(DeleClientList[i].Company);
  4612. builder.MoveToCell(0, i + 1, 4, 0);
  4613. builder.Write(DeleClientList[i].Job);
  4614. }
  4615. //删除多余行
  4616. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4617. {
  4618. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4619. }
  4620. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4621. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4622. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4623. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4624. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4625. return Ok(JsonView(true, "成功", new { Url = url }));
  4626. }
  4627. }
  4628. return Ok(JsonView(false, "操作失败!"));
  4629. }
  4630. catch (Exception ex)
  4631. {
  4632. return Ok(JsonView(false, ex.Message));
  4633. }
  4634. }
  4635. /// <summary>
  4636. /// 获取三公费用标准city
  4637. /// </summary>
  4638. /// <param name="placeData"></param>
  4639. /// <param name="nationalTravelFeeId"></param>
  4640. /// <returns></returns>
  4641. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4642. {
  4643. string _city = string.Empty;
  4644. if (placeData.Count < 1) return _city;
  4645. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4646. if (data == null) return _city;
  4647. string country = data.Country;
  4648. string city = data.City;
  4649. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4650. else _city = city;
  4651. return _city;
  4652. }
  4653. /// <summary>
  4654. /// 团组模块 - 出入境费用 - 明细表导出
  4655. /// </summary>
  4656. /// <returns></returns>
  4657. [HttpPost]
  4658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4659. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4660. {
  4661. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4662. if (data.Code != 0)
  4663. {
  4664. return Ok(JsonView(false, data.Msg));
  4665. }
  4666. return Ok(JsonView(true, data.Msg, data.Data));
  4667. }
  4668. /// <summary>
  4669. /// 团组模块 - 出入境费用 - 一键清空
  4670. /// </summary>
  4671. /// <returns></returns>
  4672. [HttpPost]
  4673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4674. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4675. {
  4676. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4677. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4678. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4679. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4680. if (_view.Code == 0)
  4681. {
  4682. return Ok(JsonView(true, "操作成功"));
  4683. }
  4684. return Ok(JsonView(false, "操作失败"));
  4685. }
  4686. /// <summary>
  4687. /// 团组模块 - 出入境费用 - 子项删除
  4688. /// </summary>
  4689. /// <returns></returns>
  4690. [HttpPost]
  4691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4692. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4693. {
  4694. try
  4695. {
  4696. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4697. if (data.Code != 0)
  4698. {
  4699. return Ok(JsonView(false, data.Msg));
  4700. }
  4701. return Ok(JsonView(true, "操作成功!", data.Data));
  4702. }
  4703. catch (Exception ex)
  4704. {
  4705. return Ok(JsonView(false, ex.Message));
  4706. }
  4707. }
  4708. /// <summary>
  4709. /// 团组模块 - 出入境国家费用标准 List
  4710. /// </summary>
  4711. /// <returns></returns>
  4712. [HttpPost]
  4713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4714. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4715. {
  4716. try
  4717. {
  4718. Stopwatch sw = new Stopwatch();
  4719. sw.Start();
  4720. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4721. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4722. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4723. Where gntf.Isdel = 0");
  4724. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4725. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4726. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4727. //foreach (var item in nationalTravel)
  4728. //{
  4729. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4730. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4731. // if (otherData != null)
  4732. // {
  4733. // cityData.Remove(otherData);
  4734. // cityData.Add(otherData);
  4735. // }
  4736. // nationalTravelFeeData1.Add(new
  4737. // {
  4738. // Country = item.Country,
  4739. // CityData = cityData
  4740. // });
  4741. //}
  4742. sw.Stop();
  4743. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4744. }
  4745. catch (Exception ex)
  4746. {
  4747. return Ok(JsonView(false, ex.Message));
  4748. throw;
  4749. }
  4750. }
  4751. /// <summary>
  4752. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4753. /// </summary>
  4754. /// <returns></returns>
  4755. [HttpPost]
  4756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4757. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4758. {
  4759. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4760. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4761. List<string> countryData = new List<string>();
  4762. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4763. countryData = countryData.Distinct().ToList();
  4764. List<dynamic> dataSource = new List<dynamic>();
  4765. foreach (var item in countryData)
  4766. {
  4767. List<string> cityData1 = new List<string>();
  4768. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4769. var countryData2 = new
  4770. {
  4771. CountryName = item,
  4772. CityData = cityData1
  4773. };
  4774. dataSource.Add(countryData2);
  4775. }
  4776. return Ok(JsonView(true, "查询成功!", dataSource));
  4777. }
  4778. /// <summary>
  4779. /// 团组模块 - 出入境国家费用标准 Page List
  4780. /// </summary>
  4781. /// <returns></returns>
  4782. [HttpPost]
  4783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4784. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4785. {
  4786. int portId = dto.PortType;
  4787. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4788. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4789. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4790. string whereSql = string.Empty;
  4791. if (!string.IsNullOrEmpty(dto.Country))
  4792. {
  4793. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4794. }
  4795. if (!string.IsNullOrEmpty(dto.City))
  4796. {
  4797. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4798. }
  4799. string pageSql = string.Format(@"Select * From (
  4800. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4801. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4802. From Grp_NationalTravelFee gntf
  4803. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4804. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4805. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4806. RefAsync<int> total = 0;
  4807. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4808. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4809. }
  4810. /// <summary>
  4811. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4812. /// </summary>
  4813. /// <returns></returns>
  4814. [HttpPost]
  4815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4816. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4817. {
  4818. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4819. int portId = dto.PortType;
  4820. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4821. string whereSql = string.Empty;
  4822. if (!string.IsNullOrEmpty(dto.Country))
  4823. {
  4824. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4825. }
  4826. if (!string.IsNullOrEmpty(dto.City))
  4827. {
  4828. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4829. }
  4830. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4831. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4832. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4833. From Grp_NationalTravelFee gntf
  4834. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4835. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4836. Where gntf.Isdel = 0 {0} ", whereSql);
  4837. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4838. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4839. }
  4840. /// <summary>
  4841. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4842. /// </summary>
  4843. /// <returns></returns>
  4844. [HttpPost]
  4845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4846. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4847. {
  4848. try
  4849. {
  4850. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4851. if (data.Code != 0)
  4852. {
  4853. return Ok(JsonView(false, data.Msg));
  4854. }
  4855. return Ok(JsonView(true, "操作成功!", data.Data));
  4856. }
  4857. catch (Exception ex)
  4858. {
  4859. return Ok(JsonView(false, ex.Message));
  4860. }
  4861. }
  4862. /// <summary>
  4863. /// 团组模块 - 出入境国家费用标准 - Del
  4864. /// </summary>
  4865. /// <returns></returns>
  4866. [HttpPost]
  4867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4868. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4869. {
  4870. try
  4871. {
  4872. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4873. {
  4874. Id = dto.Id,
  4875. DeleteUserId = dto.DeleteUserId,
  4876. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4877. IsDel = 1
  4878. };
  4879. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4880. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4881. .WhereColumns(it => new { it.Id })
  4882. .ExecuteCommandAsync();
  4883. if (delStatus <= 0)
  4884. {
  4885. return Ok(JsonView(false, "删除失败!"));
  4886. }
  4887. return Ok(JsonView(true, "操作成功!"));
  4888. }
  4889. catch (Exception ex)
  4890. {
  4891. return Ok(JsonView(false, ex.Message));
  4892. }
  4893. }
  4894. #endregion
  4895. #region 签证费用录入
  4896. /// <summary>
  4897. /// 根据diid查询签证费用列表
  4898. /// </summary>
  4899. /// <param name="dto"></param>
  4900. /// <returns></returns>
  4901. [HttpPost]
  4902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4903. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4904. {
  4905. try
  4906. {
  4907. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4908. if (groupData.Code != 0)
  4909. {
  4910. return Ok(JsonView(false, groupData.Msg));
  4911. }
  4912. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4913. }
  4914. catch (Exception ex)
  4915. {
  4916. return Ok(JsonView(false, ex.Message));
  4917. }
  4918. }
  4919. /// <summary>
  4920. /// 根据签证费用Id查询单条数据及c表数据
  4921. /// </summary>
  4922. /// <param name="dto"></param>
  4923. /// <returns></returns>
  4924. [HttpPost]
  4925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4926. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4927. {
  4928. try
  4929. {
  4930. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4931. if (groupData.Code != 0)
  4932. {
  4933. return Ok(JsonView(false, groupData.Msg));
  4934. }
  4935. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4936. }
  4937. catch (Exception ex)
  4938. {
  4939. return Ok(JsonView(false, ex.Message));
  4940. }
  4941. }
  4942. /// <summary>
  4943. /// 签证费用删除
  4944. /// </summary>
  4945. /// <param name="dto"></param>
  4946. /// <returns></returns>
  4947. [HttpPost]
  4948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4949. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4950. {
  4951. _sqlSugar.BeginTran();
  4952. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4953. if (!res)
  4954. {
  4955. _sqlSugar.RollbackTran();
  4956. return Ok(JsonView(false, "删除失败"));
  4957. }
  4958. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4959. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  4960. .SetColumns(a => new Grp_CreditCardPayment()
  4961. {
  4962. IsDel = 1,
  4963. DeleteUserId = dto.DeleteUserId,
  4964. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4965. }).ExecuteCommand();
  4966. if (resSub < 1)
  4967. {
  4968. _sqlSugar.RollbackTran();
  4969. return Ok(JsonView(false, "删除失败"));
  4970. }
  4971. _sqlSugar.CommitTran();
  4972. return Ok(JsonView(true, "删除成功!"));
  4973. }
  4974. /// <summary>
  4975. /// 签证费用录入下拉框初始化
  4976. /// </summary>
  4977. /// <returns></returns>
  4978. [HttpPost]
  4979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4980. public async Task<IActionResult> VisaPriceAddSelect()
  4981. {
  4982. try
  4983. {
  4984. //支付方式
  4985. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4986. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4987. //币种
  4988. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4989. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4990. //乘客类型
  4991. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4992. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4993. //卡类型
  4994. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4995. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4996. var data = new
  4997. {
  4998. Payment = _Payment,
  4999. CurrencyList = _CurrencyList,
  5000. PassengerType = _PassengerType,
  5001. BankCard = _BankCard
  5002. };
  5003. return Ok(JsonView(true, "查询成功!", data));
  5004. }
  5005. catch (Exception ex)
  5006. {
  5007. return Ok(JsonView(false, "程序错误!"));
  5008. throw;
  5009. }
  5010. }
  5011. /// <summary>
  5012. /// 签证费用录入操作(Status:1.新增,2.修改)
  5013. /// </summary>
  5014. /// <param name="dto"></param>
  5015. /// <returns></returns>
  5016. [HttpPost]
  5017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5018. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5019. {
  5020. try
  5021. {
  5022. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5023. if (groupData.Code != 0)
  5024. {
  5025. return Ok(JsonView(false, groupData.Msg));
  5026. }
  5027. #region 应用推送
  5028. try
  5029. {
  5030. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5031. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5032. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5033. }
  5034. catch (Exception ex)
  5035. {
  5036. }
  5037. #endregion
  5038. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5039. }
  5040. catch (Exception ex)
  5041. {
  5042. return Ok(JsonView(false, ex.Message));
  5043. }
  5044. }
  5045. #endregion
  5046. #region op费用录入
  5047. /// <summary>
  5048. /// 根据diid查询op费用列表
  5049. /// </summary>
  5050. /// <param name="dto"></param>
  5051. /// <returns></returns>
  5052. [HttpPost]
  5053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5054. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5055. {
  5056. try
  5057. {
  5058. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5059. if (groupData.Code != 0)
  5060. {
  5061. return Ok(JsonView(false, groupData.Msg));
  5062. }
  5063. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5064. }
  5065. catch (Exception ex)
  5066. {
  5067. return Ok(JsonView(false, ex.Message));
  5068. }
  5069. }
  5070. /// <summary>
  5071. /// 根据op费用Id查询单条数据及c表数据
  5072. /// </summary>
  5073. /// <param name="dto"></param>
  5074. /// <returns></returns>
  5075. [HttpPost]
  5076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5077. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5078. {
  5079. try
  5080. {
  5081. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5082. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5083. var data = new
  5084. {
  5085. CarTouristGuideGround = _groupData,
  5086. CreditCardPayment = _creditCardPayment
  5087. };
  5088. return Ok(JsonView(true, "查询成功!", data));
  5089. }
  5090. catch (Exception ex)
  5091. {
  5092. return Ok(JsonView(false, "程序错误!"));
  5093. }
  5094. }
  5095. /// <summary>
  5096. /// op费用删除
  5097. /// </summary>
  5098. /// <param name="dto"></param>
  5099. /// <returns></returns>
  5100. [HttpPost]
  5101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5102. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5103. {
  5104. try
  5105. {
  5106. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5107. if (!res)
  5108. {
  5109. return Ok(JsonView(false, "删除失败"));
  5110. }
  5111. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5112. {
  5113. IsDel = 1,
  5114. DeleteUserId = dto.DeleteUserId,
  5115. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5116. }).ExecuteCommandAsync();
  5117. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5118. {
  5119. IsDel = 1,
  5120. DeleteUserId = dto.DeleteUserId,
  5121. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5122. }).ExecuteCommandAsync();
  5123. return Ok(JsonView(true, "删除成功!"));
  5124. }
  5125. catch (Exception ex)
  5126. {
  5127. return Ok(JsonView(false, "程序错误!"));
  5128. throw;
  5129. }
  5130. }
  5131. /// <summary>
  5132. /// op费用录入操作(Status:1.新增,2.修改)
  5133. /// </summary>
  5134. /// <param name="dto"></param>
  5135. /// <returns></returns>
  5136. [HttpPost]
  5137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5138. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5139. {
  5140. try
  5141. {
  5142. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5143. if (groupData.Code != 0)
  5144. {
  5145. return Ok(JsonView(false, groupData.Msg));
  5146. }
  5147. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5148. }
  5149. catch (Exception ex)
  5150. {
  5151. return Ok(JsonView(false, ex.Message));
  5152. }
  5153. }
  5154. /// <summary>
  5155. /// 填写费用详细页面初始化绑定
  5156. /// </summary>
  5157. /// <param name="dto"></param>
  5158. /// <returns></returns>
  5159. [HttpPost]
  5160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5161. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5162. {
  5163. try
  5164. {
  5165. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5166. if (groupData.Code != 0)
  5167. {
  5168. return Ok(JsonView(false, groupData.Msg));
  5169. }
  5170. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5171. }
  5172. catch (Exception ex)
  5173. {
  5174. return Ok(JsonView(false, ex.Message));
  5175. }
  5176. }
  5177. /// <summary>
  5178. /// 根据op费用Id查询详细数据
  5179. /// </summary>
  5180. /// <param name="dto"></param>
  5181. /// <returns></returns>
  5182. [HttpPost]
  5183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5184. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5185. {
  5186. try
  5187. {
  5188. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5189. if (groupData.Code != 0)
  5190. {
  5191. return Ok(JsonView(false, groupData.Msg));
  5192. }
  5193. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5194. }
  5195. catch (Exception ex)
  5196. {
  5197. return Ok(JsonView(false, ex.Message));
  5198. }
  5199. }
  5200. /// <summary>
  5201. /// OP费用录入填写详情
  5202. /// </summary>
  5203. /// <param name="dto"></param>
  5204. /// <returns></returns>
  5205. [HttpPost]
  5206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5207. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5208. {
  5209. try
  5210. {
  5211. #region 参数校验
  5212. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5213. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5214. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5215. #endregion
  5216. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5217. if (groupData.Code != 0)
  5218. {
  5219. return Ok(JsonView(false, groupData.Msg));
  5220. }
  5221. //自动审核
  5222. await _feeAuditRep.FeeAutomaticAudit(2,dto.DiId,dto.CTGGRId);
  5223. #region 应用推送
  5224. try
  5225. {
  5226. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5227. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5228. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5229. }
  5230. catch (Exception ex)
  5231. {
  5232. }
  5233. #endregion
  5234. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5235. }
  5236. catch (Exception ex)
  5237. {
  5238. return Ok(JsonView(false, ex.Message));
  5239. }
  5240. }
  5241. /// <summary>
  5242. /// 获取三公详细所有城市
  5243. /// </summary>
  5244. /// <returns></returns>
  5245. [HttpGet]
  5246. public IActionResult OpCarCityResult()
  5247. {
  5248. var jw = JsonView(false);
  5249. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5250. {
  5251. x.Id,
  5252. x.Country,
  5253. x.City,
  5254. }).ToList();
  5255. if (data.Count > 0)
  5256. {
  5257. jw = JsonView(true, "获取成功!", data);
  5258. }
  5259. else
  5260. {
  5261. jw.Msg = "城市数据为空!";
  5262. jw.Data = new string[0];
  5263. }
  5264. return Ok(jw);
  5265. }
  5266. /// <summary>
  5267. /// 导出地接费用明细
  5268. /// </summary>
  5269. /// <param name="dto"></param>
  5270. /// <returns></returns>
  5271. [HttpPost]
  5272. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5273. {
  5274. var jw = JsonView(false);
  5275. if (dto.Diid < 1)
  5276. {
  5277. jw.Msg = "请输入正确的diid!";
  5278. return Ok(jw);
  5279. }
  5280. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5281. if (group == null)
  5282. {
  5283. jw.Msg = "未找到团组信息!";
  5284. return Ok(jw);
  5285. }
  5286. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5287. if (localGuideArr.Count == 0)
  5288. {
  5289. jw.Msg = "该团组暂无地接信息!";
  5290. return Ok(jw);
  5291. }
  5292. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5293. var overspendSoure = new Dictionary<int, int>
  5294. {
  5295. { 91, 982 }, //车
  5296. { 92 , 1059} ,//导游
  5297. { 994 , 1073}, //翻译
  5298. { 988 , 1074 }, //早餐
  5299. { 93 , 1075 }, //午餐
  5300. { 989 , 1076 }, //晚餐
  5301. };
  5302. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5303. foreach (var groupArr in localGroup)
  5304. {
  5305. var keyValue = groupArr.Key;
  5306. if (int.TryParse(keyValue, out int cityid))
  5307. {
  5308. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5309. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5310. }
  5311. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5312. foreach (var item in groupArr)
  5313. {
  5314. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5315. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5316. new Grp_CarTouristGuideGroundReservationsContentExtend
  5317. {
  5318. Count = a.Count,
  5319. CreateTime = a.CreateTime,
  5320. CreateUserId = a.CreateUserId,
  5321. CTGGRId = a.CTGGRId,
  5322. Currency = a.Currency,
  5323. DatePrice = a.DatePrice,
  5324. DeleteTime = a.DeleteTime,
  5325. DeleteUserId = a.DeleteUserId,
  5326. DiId = a.DiId,
  5327. Id = a.Id,
  5328. IsDel = a.IsDel,
  5329. Price = a.Price,
  5330. PriceContent = a.PriceContent,
  5331. Remark = a.Remark,
  5332. SId = a.SId,
  5333. SidName = b.Name,
  5334. Units = a.Units,
  5335. }
  5336. ).ToList();
  5337. if (content.Count > 0)
  5338. {
  5339. contentArr.Add(content);
  5340. }
  5341. }
  5342. //open excel
  5343. //set excel
  5344. //save excel
  5345. try
  5346. {
  5347. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5348. IWorkbook workbook;
  5349. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5350. {
  5351. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5352. }
  5353. else
  5354. {
  5355. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5356. }
  5357. ISheet sheet = workbook.GetSheetAt(0);
  5358. var rowStartIndex = 2;
  5359. var clounmCount = 10;
  5360. var initStyleRow = sheet.GetRow(2);
  5361. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5362. //var overspendArrDetail =
  5363. var existsId = new List<CarCompare>();
  5364. var lastElem = arr.Last();
  5365. var thisSid = -1;
  5366. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5367. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5368. {
  5369. Name = "未知币种!",
  5370. Remark = "未知币种!",
  5371. };
  5372. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5373. Action cloneRowFn = () =>
  5374. {
  5375. rowStartIndex++;
  5376. var cloneRow = sheet.CreateRow(rowStartIndex);
  5377. // 复制样式
  5378. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5379. {
  5380. ICell sourceCell = initStyleRow.GetCell(i);
  5381. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5382. // 确保单元格存在样式
  5383. if (sourceCell.CellStyle != null)
  5384. {
  5385. targetCell.CellStyle = sourceCell.CellStyle;
  5386. }
  5387. }
  5388. };
  5389. var mergeRow = () =>
  5390. {
  5391. for (int i = 2; i < sheet.LastRowNum; i++)
  5392. {
  5393. var row = sheet.GetRow(i);
  5394. var cellFirst = row.GetCell(0);
  5395. var thisIndex = i + 1;
  5396. while (thisIndex < sheet.LastRowNum)
  5397. {
  5398. var nextRow = sheet.GetRow(thisIndex);
  5399. var nextCellFirst = nextRow.GetCell(0);
  5400. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5401. {
  5402. thisIndex++;
  5403. }
  5404. else
  5405. {
  5406. break;
  5407. }
  5408. }
  5409. thisIndex--;
  5410. if (thisIndex != i)
  5411. {
  5412. //合并row
  5413. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5414. i, // 起始行索引(0-based)
  5415. thisIndex, // 结束行索引(0-based)
  5416. 0, // 起始列索引(0-based)
  5417. 0 // 结束列索引(0-based)
  5418. );
  5419. sheet.AddMergedRegion(cellRangeAddress);
  5420. i = thisIndex;
  5421. }
  5422. }
  5423. };
  5424. var chaoshiNumber = 0;
  5425. var totalNumber = 0.00M;
  5426. string lastStr = "";
  5427. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5428. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5429. {
  5430. b.IsAuditGM,
  5431. x.Id,
  5432. x.Area,
  5433. b.PayPercentage,
  5434. b.PayMoney,
  5435. }).ToList();
  5436. string yesPayment = "", noPayment = "";
  5437. foreach (var item in queryCarArrByCityAndDiid)
  5438. {
  5439. if (item.IsAuditGM == 1)
  5440. {
  5441. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5442. }
  5443. else
  5444. {
  5445. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5446. }
  5447. }
  5448. lastStr = yesPayment + noPayment;
  5449. foreach (var item in arr)
  5450. {
  5451. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5452. {
  5453. if (thisSid != item.SId)
  5454. {
  5455. if (thisSid == -1)
  5456. {
  5457. thisSid = item.SId;
  5458. }
  5459. else
  5460. {
  5461. //合并小计行
  5462. //创建合并区域的实例
  5463. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5464. rowStartIndex, // 起始行索引(0-based)
  5465. rowStartIndex, // 结束行索引(0-based)
  5466. 0, // 起始列索引(0-based)
  5467. 3 // 结束列索引(0-based)
  5468. );
  5469. sheet.AddMergedRegion(cellRangeAddress);
  5470. var CellStyle = workbook.CreateCellStyle();
  5471. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5472. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5473. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5474. for (int i = 0; i <= clounmCount; i++)
  5475. {
  5476. if (i > 6)
  5477. {
  5478. var CellStyle1 = workbook.CreateCellStyle();
  5479. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5480. IFont Font = workbook.CreateFont(); // 创建字体
  5481. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5482. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5483. CellStyle1.SetFont(Font);
  5484. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5485. }
  5486. else
  5487. {
  5488. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5489. }
  5490. }
  5491. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5492. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5493. //超时合计
  5494. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5495. //超时数
  5496. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5497. //超时合计费用
  5498. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5499. thisSid = item.SId;
  5500. cloneRowFn();
  5501. chaoshiNumber = 0;
  5502. totalNumber = 0;
  5503. }
  5504. }
  5505. IRow row = sheet.GetRow(rowStartIndex);
  5506. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5507. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5508. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  5509. if (isOpenOverspendSoure)
  5510. {
  5511. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5512. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5513. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5514. }
  5515. for (int i = 0; i <= clounmCount; i++)
  5516. {
  5517. var cell = row.GetCell(i);
  5518. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5519. if (cell == null)
  5520. {
  5521. cell = row.CreateCell(i);
  5522. }
  5523. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5524. fontRed.CloneStyleFrom(cell.CellStyle);
  5525. IFont Font = workbook.CreateFont(); // 创建字体
  5526. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5527. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5528. fontRed.SetFont(Font);
  5529. byte[] rgb = new byte[3] { 255, 242, 204 };
  5530. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5531. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5532. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  5533. if (workbook is XSSFWorkbook)
  5534. {
  5535. BackgroundColor255_242_204.FillForegroundColor = 0;
  5536. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5537. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5538. }
  5539. else
  5540. {
  5541. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5542. }
  5543. if (i == 1 || i > 6)
  5544. {
  5545. if (i > 6)
  5546. {
  5547. fontRed.FillForegroundColor = 0;
  5548. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5549. fontRed.FillPattern = FillPattern.SolidForeground;
  5550. }
  5551. cell.CellStyle = fontRed;
  5552. }
  5553. if (i > 2 && i < 7)
  5554. {
  5555. cell.CellStyle = BackgroundColor255_242_204;
  5556. }
  5557. cell.SetCellValue(setCellValue); //写入单元格
  5558. }
  5559. if (overspendSoure.ContainsKey(thisSid)) {
  5560. var overspendId = overspendSoure[thisSid];
  5561. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5562. }
  5563. cloneRowFn();
  5564. existsId.Add(new CarCompare
  5565. {
  5566. DataPrice = item.DatePrice.ObjToDate(),
  5567. Sid = item.SId
  5568. });
  5569. }
  5570. if (item.Equals(lastElem))
  5571. {
  5572. //合并小计行
  5573. //创建合并区域的实例
  5574. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5575. rowStartIndex, // 起始行索引(0-based)
  5576. rowStartIndex, // 结束行索引(0-based)
  5577. 0, // 起始列索引(0-based)
  5578. 3 // 结束列索引(0-based)
  5579. );
  5580. sheet.AddMergedRegion(cellRangeAddress);
  5581. var CellStyle = workbook.CreateCellStyle();
  5582. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5583. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5584. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5585. for (int i = 0; i <= clounmCount; i++)
  5586. {
  5587. if (i > 6)
  5588. {
  5589. var CellStyle1 = workbook.CreateCellStyle();
  5590. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5591. IFont Font = workbook.CreateFont(); // 创建字体
  5592. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5593. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5594. CellStyle1.SetFont(Font);
  5595. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5596. }
  5597. else
  5598. {
  5599. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5600. }
  5601. }
  5602. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5603. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5604. //超时合计
  5605. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5606. //超时数
  5607. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5608. //超时合计费用
  5609. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5610. cloneRowFn();
  5611. // 创建合并区域的实例
  5612. cellRangeAddress = new CellRangeAddress(
  5613. rowStartIndex, // 起始行索引(0-based)
  5614. rowStartIndex, // 结束行索引(0-based)
  5615. 0, // 起始列索引(0-based)
  5616. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5617. );
  5618. // 添加合并区域
  5619. sheet.AddMergedRegion(cellRangeAddress);
  5620. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5621. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5622. }
  5623. }
  5624. mergeRow();
  5625. // 保存修改后的Excel文件到新文件
  5626. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5627. // new FileStream(newFilePath, FileMode.CreateNew)
  5628. using (var stream = new MemoryStream())
  5629. {
  5630. workbook.Write(stream, true);
  5631. stream.Flush();
  5632. stream.Seek(0, SeekOrigin.Begin);
  5633. MemoryStream memoryStream = new MemoryStream();
  5634. stream.CopyTo(memoryStream);
  5635. memoryStream.Seek(0, SeekOrigin.Begin);
  5636. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5637. }
  5638. workbook.Close();
  5639. workbook.Dispose();
  5640. }
  5641. catch (Exception ex)
  5642. {
  5643. jw.Msg = "出现异常!" + ex.Message;
  5644. return Ok(jw);
  5645. }
  5646. }
  5647. if (Zips.Count > 0)
  5648. {
  5649. IOOperatorHelper io = new IOOperatorHelper();
  5650. var byts = io.ConvertZipStream(Zips);
  5651. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5652. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5653. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5654. }
  5655. else
  5656. {
  5657. jw.Msg = "暂无生成文件!";
  5658. }
  5659. return Ok(jw);
  5660. }
  5661. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5662. {
  5663. string outStr = string.Empty;
  5664. switch (i)
  5665. {
  5666. case 0:
  5667. outStr = arr[0].SidName;
  5668. break;
  5669. case 1:
  5670. outStr = arr[0].DataPriceStr;
  5671. break;
  5672. case 2:
  5673. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5674. break;
  5675. case 4:
  5676. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5677. break;
  5678. case 7:
  5679. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5680. {
  5681. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5682. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5683. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5684. }
  5685. break;
  5686. case 8:
  5687. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5688. {
  5689. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5690. }
  5691. break;
  5692. case 9:
  5693. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5694. {
  5695. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5696. }
  5697. break;
  5698. case 10:
  5699. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5700. {
  5701. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5702. }
  5703. break;
  5704. }
  5705. return outStr;
  5706. }
  5707. #region OP行程单
  5708. /// <summary>
  5709. /// OP行程单初始化
  5710. /// </summary>
  5711. /// <param name="dto"></param>
  5712. /// <returns></returns>
  5713. [HttpPost]
  5714. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5715. {
  5716. var jw = JsonView(false);
  5717. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5718. var group = groupList.First();
  5719. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5720. if (group == null)
  5721. {
  5722. jw.Msg = "暂无团组!";
  5723. return Ok(jw);
  5724. }
  5725. group = groupList.Find(x => x.Id == diid);
  5726. if (group == null)
  5727. {
  5728. jw.Msg = "请输入正确的团组ID!";
  5729. return Ok(jw);
  5730. }
  5731. string city = string.Empty;
  5732. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5733. if (blackCode.Count > 0)
  5734. {
  5735. var black = blackCode.First();
  5736. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5737. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5738. if (blackSp.Length > 0)
  5739. {
  5740. try
  5741. {
  5742. var cityArrCode = new List<string>(20);
  5743. foreach (var item in blackSp)
  5744. {
  5745. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5746. var IndexSelect = itemSp[2];
  5747. var cityArrCodeLength = cityArrCode.Count - 1;
  5748. var startCity = IndexSelect.Substring(0, 3);
  5749. if (cityArrCodeLength > 0)
  5750. {
  5751. var arrEndCity = cityArrCode[cityArrCodeLength];
  5752. if (arrEndCity != startCity)
  5753. {
  5754. cityArrCode.Add(startCity.ToUpper());
  5755. }
  5756. }
  5757. else
  5758. {
  5759. cityArrCode.Add(startCity.ToUpper());
  5760. }
  5761. var endCity = IndexSelect.Substring(3, 3);
  5762. cityArrCode.Add(endCity.ToUpper());
  5763. }
  5764. var cityThree = string.Empty;
  5765. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5766. cityThree = cityThree.TrimEnd(',');
  5767. if (string.IsNullOrWhiteSpace(cityThree))
  5768. {
  5769. throw new
  5770. Exception("error");
  5771. }
  5772. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5773. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5774. foreach (var item in cityArrCode)
  5775. {
  5776. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5777. if (find != null)
  5778. {
  5779. city += find.City + "/";
  5780. }
  5781. else
  5782. {
  5783. city += item + "三字码未收入/";
  5784. }
  5785. }
  5786. city = city.TrimEnd('/');
  5787. }
  5788. catch (Exception e)
  5789. {
  5790. city = "黑屏代码格式不正确!";
  5791. }
  5792. }
  5793. }
  5794. else
  5795. {
  5796. city = "未录入黑屏代码";
  5797. }
  5798. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5799. {
  5800. Date = x.Date,
  5801. Days = x.Days,
  5802. Diffgroup = x.Diffgroup,
  5803. Diid = x.Diid,
  5804. Traffic_First = x.Traffic_First,
  5805. Traffic_Second = x.Traffic_Second,
  5806. Trip = x.Trip,
  5807. WeekDay = x.WeekDay,
  5808. Id = x.Id
  5809. }).ToList();
  5810. jw.Data = new
  5811. {
  5812. groupList = groupList.Select(x => new
  5813. {
  5814. x.Id,
  5815. x.TeamName,
  5816. x.TourCode
  5817. }).ToList(),
  5818. groupInfo = new
  5819. {
  5820. group.VisitDays,
  5821. group.TourCode,
  5822. group.VisitPNumber,
  5823. group.TeamName,
  5824. city
  5825. },
  5826. OpTravelList
  5827. };
  5828. jw.Code = 200;
  5829. jw.Msg = "操作成功!";
  5830. return Ok(jw);
  5831. }
  5832. /// <summary>
  5833. /// 删除团组行程单
  5834. /// </summary>
  5835. /// <returns></returns>
  5836. [HttpPost]
  5837. public IActionResult DelTravel(DelOpTravelDto dto)
  5838. {
  5839. var jw = JsonView(false);
  5840. if (dto.UserId <= 0 || dto.Diid <= 0)
  5841. {
  5842. jw.Msg = "请输入正确的参数!";
  5843. return Ok(jw);
  5844. }
  5845. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5846. .SetColumns(x => new Grp_TravelList
  5847. {
  5848. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5849. DeleteUserId = dto.UserId,
  5850. IsDel = 1,
  5851. }).ExecuteCommand();
  5852. jw = JsonView(true);
  5853. return Ok(jw);
  5854. }
  5855. /// <summary>
  5856. /// 行程单保存
  5857. /// </summary>
  5858. /// <returns></returns>
  5859. [HttpPost]
  5860. public IActionResult TravelSave(TravelSaveDto dto)
  5861. {
  5862. var jw = JsonView(false);
  5863. if (dto.Arr.Count > 0)
  5864. {
  5865. try
  5866. {
  5867. _sqlSugar.BeginTran();
  5868. foreach (var item in dto.Arr)
  5869. {
  5870. if (item.Id == 0)
  5871. {
  5872. throw new Exception("请传入正确的Id");
  5873. }
  5874. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5875. .SetColumns(x => new Grp_TravelList
  5876. {
  5877. Trip = item.Trip
  5878. }).ExecuteCommand();
  5879. }
  5880. _sqlSugar.CommitTran();
  5881. jw = JsonView(true);
  5882. }
  5883. catch (Exception ex)
  5884. {
  5885. _sqlSugar.RollbackTran();
  5886. jw.Msg = "程序异常!" + ex.Message;
  5887. }
  5888. }
  5889. else
  5890. {
  5891. jw.Msg = "请传入正确的参数!";
  5892. }
  5893. return Ok(jw);
  5894. }
  5895. /// <summary>
  5896. /// 导出行程单
  5897. /// </summary>
  5898. /// <param name="dto"></param>
  5899. /// <returns></returns>
  5900. [HttpPost]
  5901. public IActionResult ExportTravel(ExportTravelDto dto)
  5902. {
  5903. var jw = JsonView(false);
  5904. jw.Data = "";
  5905. int diid = 0;
  5906. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5907. if (Find == null)
  5908. {
  5909. jw.Msg = "请选择正确的团组!";
  5910. return Ok(jw);
  5911. }
  5912. else
  5913. {
  5914. diid = Find.Id;
  5915. }
  5916. //数据源
  5917. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5918. DataTable dtBlack = null;
  5919. try
  5920. {
  5921. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  5922. }
  5923. catch (Exception)
  5924. {
  5925. jw.Msg = "机票黑屏代码有误!";
  5926. return Ok(jw);
  5927. }
  5928. string CityStr = string.Empty;
  5929. if (dtBlack.Rows.Count == 0)
  5930. {
  5931. jw.Msg = "机票黑屏代码有误!";
  5932. return Ok(jw);
  5933. }
  5934. else
  5935. {
  5936. foreach (DataRow row in dtBlack.Rows)
  5937. {
  5938. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  5939. {
  5940. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  5941. return Ok(jw);
  5942. }
  5943. }
  5944. CityStr = GeneralMethod.GetGroupCityLine(diid,"/");
  5945. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  5946. }
  5947. //创建数据源Table
  5948. DataTable dtSource = new DataTable();
  5949. dtSource.Columns.Add("Days", typeof(string));
  5950. dtSource.Columns.Add("Date", typeof(string));
  5951. dtSource.Columns.Add("Week", typeof(string));
  5952. dtSource.Columns.Add("Traffic", typeof(string));
  5953. dtSource.Columns.Add("Trip", typeof(string));
  5954. //获取数据,放到datatable
  5955. foreach (var item in _travelList)
  5956. {
  5957. DataRow dr = dtSource.NewRow();
  5958. dr["Days"] = item.Days;
  5959. dr["Date"] = item.Date;
  5960. dr["Week"] = item.WeekDay;
  5961. dr["Traffic"] = item.Traffic_First
  5962. + "\r\n"
  5963. + item.Traffic_Second;
  5964. dr["Trip"] = item.Trip;
  5965. dtSource.Rows.Add(dr);
  5966. }
  5967. Dictionary<string, string> dic = new Dictionary<string, string>();
  5968. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  5969. dic.Add("City", CityStr);
  5970. dic.Add("Days", Find.VisitDays.ToString());
  5971. dic.Add("DeleCode", Find.TourCode);
  5972. dic.Add("Pnum", Find.VisitPNumber.ToString());
  5973. //模板路径
  5974. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  5975. //载入模板
  5976. Document doc = null;
  5977. DocumentBuilder builder = null;
  5978. try
  5979. {
  5980. //载入模板
  5981. doc = new Document(tempPath);
  5982. builder = new DocumentBuilder(doc);
  5983. }
  5984. catch (Exception)
  5985. {
  5986. jw.Msg = "模板位置不存在!";
  5987. return Ok(jw);
  5988. }
  5989. foreach (var key in dic.Keys)
  5990. {
  5991. Bookmark bookmark = doc.Range.Bookmarks[key];
  5992. if (bookmark != null)
  5993. {
  5994. builder.MoveToBookmark(key);
  5995. builder.Write(dic[key]);
  5996. }
  5997. }
  5998. //获取word里所有表格
  5999. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6000. //获取所填表格的序数
  6001. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6002. try
  6003. {
  6004. //循环赋值
  6005. for (int i = 0; i < dtSource.Rows.Count; i++)
  6006. {
  6007. builder.MoveToCell(0, i + 1, 0, 0);
  6008. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6009. builder.MoveToCell(0, i + 1, 1, 0);
  6010. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6011. builder.MoveToCell(0, i + 1, 2, 0);
  6012. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6013. var trip = dtSource.Rows[i]["Trip"].ToString();
  6014. builder.MoveToCell(0, i + 1, 3, 0);
  6015. builder.Write(trip);
  6016. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6017. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6018. // 获取特定索引的段落
  6019. Paragraph paragraph = (Paragraph)paragraphs[0];
  6020. Run run = paragraph.Runs[0];
  6021. Aspose.Words.Font font = run.Font;
  6022. font.Name = "黑体";
  6023. //设置双休红色
  6024. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6025. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6026. paragraph = (Paragraph)paragraphs[1];
  6027. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6028. {
  6029. run = paragraph.Runs[0];
  6030. font = run.Font;
  6031. font.Color = Color.Red;
  6032. }
  6033. }
  6034. }
  6035. catch (Exception ex)
  6036. {
  6037. }
  6038. //删除多余行
  6039. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6040. {
  6041. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6042. }
  6043. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6044. if (!Directory.Exists(savePath))
  6045. {
  6046. try
  6047. {
  6048. Directory.CreateDirectory(savePath);
  6049. }
  6050. catch
  6051. {
  6052. }
  6053. }
  6054. string path = savePath + Find.TeamName + "出访日程";
  6055. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6056. try
  6057. {
  6058. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6059. string postfix = ".docx";
  6060. if (dto.IsPDF == 1)
  6061. {
  6062. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6063. postfix = ".pdf";
  6064. }
  6065. doc.Save(path + postfix, saveFormat);
  6066. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6067. }
  6068. catch (Exception)
  6069. {
  6070. jw = JsonView(false);
  6071. }
  6072. return Ok(jw);
  6073. }
  6074. /// <summary>
  6075. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6076. /// </summary>
  6077. /// <param name="num"></param>
  6078. /// <returns></returns>
  6079. string GetNum(string num)
  6080. {
  6081. string str = "";
  6082. switch (num)
  6083. {
  6084. case "1":
  6085. str = "一";
  6086. break;
  6087. case "2":
  6088. str = "二";
  6089. break;
  6090. case "3":
  6091. str = "三";
  6092. break;
  6093. case "4":
  6094. str = "四";
  6095. break;
  6096. case "5":
  6097. str = "五";
  6098. break;
  6099. case "6":
  6100. str = "六";
  6101. break;
  6102. case "7":
  6103. str = "七";
  6104. break;
  6105. case "8":
  6106. str = "八";
  6107. break;
  6108. case "9":
  6109. str = "九";
  6110. break;
  6111. case "10":
  6112. str = "十";
  6113. break;
  6114. case "11":
  6115. str = "十一";
  6116. break;
  6117. case "12":
  6118. str = "十二";
  6119. break;
  6120. case "一":
  6121. str = "1";
  6122. break;
  6123. case "二":
  6124. str = "2";
  6125. break;
  6126. case "三":
  6127. str = "3";
  6128. break;
  6129. case "四":
  6130. str = "4";
  6131. break;
  6132. case "五":
  6133. str = "5";
  6134. break;
  6135. case "六":
  6136. str = "6";
  6137. break;
  6138. case "七":
  6139. str = "7";
  6140. break;
  6141. case "八":
  6142. str = "8";
  6143. break;
  6144. case "九":
  6145. str = "9";
  6146. break;
  6147. case "十":
  6148. str = "10";
  6149. break;
  6150. case "十一":
  6151. str = "11";
  6152. break;
  6153. case "十二":
  6154. str = "12";
  6155. break;
  6156. }
  6157. return str;
  6158. }
  6159. #endregion
  6160. #endregion
  6161. #region 团组成本
  6162. /// <summary>
  6163. /// 团组成本数据初始化
  6164. /// </summary>
  6165. /// <param name="dto"></param>
  6166. /// <returns></returns>
  6167. [HttpPost]
  6168. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6169. {
  6170. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6171. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6172. WHEN COUNT(*) >= 0 THEN 'True'
  6173. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6174. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6175. ").ToList(); //团组列表
  6176. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6177. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6178. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6179. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6180. if (groupinfoValue != null)
  6181. {
  6182. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6183. var spArr = new string[1] { countryArr };
  6184. if (countryArr.Contains("|"))
  6185. {
  6186. spArr = countryArr.Split("|");
  6187. }
  6188. else if (countryArr.Contains("、"))
  6189. {
  6190. spArr = countryArr.Split("、");
  6191. }
  6192. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6193. {
  6194. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6195. if (dbQueryCountry != null)
  6196. {
  6197. visaCountryInfoArr.Add(dbQueryCountry);
  6198. }
  6199. }
  6200. }
  6201. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6202. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6203. var create = _GroupCostRepository.
  6204. CreateGroupCostByBlackCode(dto.Diid);
  6205. if (groupCost.Count == 0 && create.Code == 0)
  6206. {
  6207. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6208. }
  6209. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6210. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6211. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6212. groupCostMap = groupCostMap.Select(x =>
  6213. {
  6214. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6215. {
  6216. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6217. }
  6218. return x;
  6219. }).ToList();
  6220. //GroupCostParameter.Add(new
  6221. // Grp_GroupCostParameter());
  6222. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6223. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6224. return Ok(JsonView(new
  6225. {
  6226. groupList,
  6227. groupInfo,
  6228. groupChecks,
  6229. groupCost = groupCostMap,
  6230. hotelNumber,
  6231. GroupCostParameter = GroupCostParameterMap,
  6232. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6233. {
  6234. x.VisaCountry,
  6235. x.VisaPrice,
  6236. x.Id,
  6237. }).ToList(),
  6238. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6239. blackCodeIsTrue = create.Code == 0 ? true : false,
  6240. hotelIsTrue = hotelIsTrue,
  6241. }));
  6242. }
  6243. /// <summary>
  6244. /// 团组成本信息保存
  6245. /// </summary>
  6246. /// <param name="dto"></param>
  6247. /// <returns></returns>
  6248. [HttpPost]
  6249. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6250. {
  6251. if (dto.Diid <= 0 || dto.Userid <= 0)
  6252. {
  6253. return Ok(JsonView(false));
  6254. }
  6255. JsonView jw = null;
  6256. bool isTrue = false;
  6257. #region 复制团组成本
  6258. //if (dto.Diid == 2581)
  6259. //{
  6260. // dto.Diid = 2599;
  6261. // dto.CheckBoxs.ForEach(x =>
  6262. // {
  6263. // x.Diid = 2599;
  6264. // });
  6265. // dto.GroupCosts.ForEach(x =>
  6266. // {
  6267. // x.Diid = 2599;
  6268. // });
  6269. // dto.CostTypeHotelNumbers.ForEach(x =>
  6270. // {
  6271. // x.Diid = 2599;
  6272. // });
  6273. // dto.GroupCostParameters.ForEach(x =>
  6274. // {
  6275. // x.DiId = 2599;
  6276. // });
  6277. //}
  6278. #endregion
  6279. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6280. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6281. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6282. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6283. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6284. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6285. try
  6286. {
  6287. _sqlSugar.BeginTran();
  6288. isTrue = await _GroupCostRepository.
  6289. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6290. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6291. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6292. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6293. _sqlSugar.CommitTran();
  6294. jw = JsonView(true, "保存成功!", isTrue);
  6295. }
  6296. catch (Exception)
  6297. {
  6298. _sqlSugar.RollbackTran();
  6299. jw = JsonView(false);
  6300. }
  6301. return Ok(jw);
  6302. }
  6303. /// <summary>
  6304. /// 司兼导数据
  6305. /// </summary>
  6306. /// <param name="dto"></param>
  6307. /// <returns></returns>
  6308. [HttpPost]
  6309. public IActionResult GetCarGuides(CarGuidesDto dto)
  6310. {
  6311. JsonView jw = null;
  6312. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6313. jw = JsonView(true, "获取成功!", Data);
  6314. return Ok(jw);
  6315. }
  6316. /// <summary>
  6317. /// 导游数据
  6318. /// </summary>
  6319. /// <param name="dto"></param>
  6320. /// <returns></returns>
  6321. [HttpPost]
  6322. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6323. {
  6324. JsonView jw = null;
  6325. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6326. // 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
  6327. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6328. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6329. jw = JsonView(true, "获取成功!", Data);
  6330. return Ok(jw);
  6331. }
  6332. /// <summary>
  6333. /// 成本车数据
  6334. /// </summary>
  6335. /// <param name="dto"></param>
  6336. /// <returns></returns>
  6337. [HttpPost]
  6338. public IActionResult GetCarInfo(CarGuidesDto dto)
  6339. {
  6340. JsonView jw = null;
  6341. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6342. jw = JsonView(true, "获取成功!", Data);
  6343. return Ok(jw);
  6344. }
  6345. /// <summary>
  6346. /// 景点数据
  6347. /// </summary>
  6348. /// <param name="dto"></param>
  6349. /// <returns></returns>
  6350. [HttpPost]
  6351. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6352. {
  6353. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6354. return Ok(JsonView(true, "获取成功!", Data));
  6355. }
  6356. /// <summary>
  6357. /// 成本通知
  6358. /// </summary>
  6359. /// <param name="dto"></param>
  6360. /// <returns></returns>
  6361. [HttpPost]
  6362. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6363. {
  6364. if (dto.Diid < 0)
  6365. {
  6366. return Ok(JsonView(false));
  6367. }
  6368. JsonView jw = null;
  6369. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6370. if (GroupCostParameter != null)
  6371. {
  6372. int IsShare = 0;
  6373. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6374. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6375. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6376. string msg = string.Empty;
  6377. if (isTrue)
  6378. {
  6379. if (IsShare == 0)
  6380. {
  6381. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6382. }
  6383. else
  6384. {
  6385. #region 企微通知对应岗位用户
  6386. try
  6387. {
  6388. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6389. }
  6390. catch (Exception ex)
  6391. {
  6392. }
  6393. #endregion
  6394. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6395. }
  6396. jw = JsonView(isTrue, msg, new { IsShare });
  6397. }
  6398. else
  6399. {
  6400. msg = "修改失败!";
  6401. jw = JsonView(isTrue, msg);
  6402. }
  6403. }
  6404. else
  6405. {
  6406. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6407. }
  6408. return Ok(jw);
  6409. }
  6410. /// <summary>
  6411. /// 导出报价单
  6412. /// </summary>
  6413. /// <param name="dto"></param>
  6414. /// <returns></returns>
  6415. [HttpPost]
  6416. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6417. {
  6418. if (dto.Diid == 0)
  6419. {
  6420. return Ok(JsonView(false, "请传递团组id"));
  6421. }
  6422. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6423. if (deleInfo.Code != 0)
  6424. {
  6425. return Ok(JsonView(false, "团组信息查询失败!"));
  6426. }
  6427. var di = deleInfo.Data as DelegationInfoWebView;
  6428. if (di != null)
  6429. {
  6430. //文件名
  6431. string strFileName = di.TeamName + "-收款账单.doc";
  6432. //获取模板
  6433. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6434. //载入模板
  6435. Document doc = new Document(tmppath);
  6436. decimal TotalPrice = 0.00M;
  6437. string itemStr = string.Empty;
  6438. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6439. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6440. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6441. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6442. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6443. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6444. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6445. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6446. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6447. foreach (var cost in groupCostType)
  6448. {
  6449. var List = cost.ToList();
  6450. if (cost.Key == "A")
  6451. {
  6452. foreach (var ListItem in List)
  6453. {
  6454. if (ListItem.number > 0)
  6455. {
  6456. if (ListItem.code.Contains("TBR"))
  6457. {
  6458. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6459. }
  6460. else
  6461. {
  6462. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6463. }
  6464. TotalPrice += (ListItem.number * ListItem.price);
  6465. }
  6466. }
  6467. }
  6468. else
  6469. {
  6470. itemStr = itemStr.Insert(0, "A段\r\n");
  6471. itemStr += "B段\r\n";
  6472. foreach (var ListItem in List)
  6473. {
  6474. if (ListItem.number > 0)
  6475. {
  6476. if (ListItem.code.Contains("TBR"))
  6477. {
  6478. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6479. }
  6480. else
  6481. {
  6482. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6483. }
  6484. TotalPrice += (ListItem.number * ListItem.price);
  6485. }
  6486. }
  6487. }
  6488. }
  6489. #region 替换Word模板书签内容
  6490. Dictionary<string, string> marks = new Dictionary<string, string>();
  6491. marks.Add("To", di.ClientUnit);//付款方
  6492. marks.Add("ToTel", di.TellPhone);//付款方电话
  6493. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  6494. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  6495. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  6496. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  6497. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  6498. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  6499. marks.Add("PayItemContent", itemStr);//详细信息
  6500. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  6501. #endregion
  6502. ////注
  6503. //if (doc.Range.Bookmarks["Attention"] != null)
  6504. //{
  6505. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  6506. // mark.Text = frList[0].Attention;
  6507. //}
  6508. foreach (var item in marks.Keys)
  6509. {
  6510. if (doc.Range.Bookmarks[item] != null)
  6511. {
  6512. Bookmark mark = doc.Range.Bookmarks[item];
  6513. mark.Text = marks[item];
  6514. }
  6515. }
  6516. byte[] bytes = null;
  6517. using (MemoryStream stream = new MemoryStream())
  6518. {
  6519. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  6520. bytes = stream.ToArray();
  6521. }
  6522. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  6523. return Ok(JsonView(true, "", new
  6524. {
  6525. Data = bytes,
  6526. strFileName,
  6527. }));
  6528. }
  6529. else
  6530. {
  6531. return Ok(JsonView(false, "团组信息不存在!"));
  6532. }
  6533. }
  6534. /// <summary>
  6535. /// 导出团组成本
  6536. /// </summary>
  6537. /// <param name="dto"></param>
  6538. /// <returns></returns>
  6539. [HttpPost]
  6540. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  6541. {
  6542. var jw = JsonView(false);
  6543. if (dto.Diid == 0)
  6544. {
  6545. return Ok(JsonView(false, "请传递团组id"));
  6546. }
  6547. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6548. if (deleInfo.Code != 0)
  6549. {
  6550. return Ok(JsonView(false, "团组信息查询失败!"));
  6551. }
  6552. var di = deleInfo.Data as DelegationInfoWebView;
  6553. if (di == null)
  6554. {
  6555. return Ok(JsonView(false, "团组信息查询失败!"));
  6556. }
  6557. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  6558. WorkbookDesigner designer = new WorkbookDesigner();
  6559. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  6560. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  6561. for (int i = 0; i < List_GC.Count; i++)
  6562. {
  6563. GroupCost_Excel gc = new GroupCost_Excel();
  6564. gc.Id = List_GC[i].Id;
  6565. gc.Diid = List_GC[i].Diid.ToString();
  6566. gc.DAY = List_GC[i].DAY;
  6567. string week = "";
  6568. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  6569. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  6570. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  6571. gc.ITIN = List_GC[i].ITIN;
  6572. gc.CarType = List_GC[i].CarType;
  6573. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  6574. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  6575. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  6576. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  6577. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  6578. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  6579. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  6580. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  6581. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  6582. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  6583. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  6584. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  6585. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6586. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6587. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  6588. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  6589. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  6590. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  6591. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  6592. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  6593. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  6594. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  6595. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  6596. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  6597. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  6598. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  6599. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  6600. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  6601. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  6602. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  6603. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  6604. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  6605. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  6606. List_GC1.Add(gc);
  6607. }
  6608. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  6609. dt.TableName = "TB";
  6610. //报表标题等不用dt的值
  6611. designer.SetDataSource("TeamName", dto.title.TeamName);
  6612. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  6613. designer.SetDataSource("Tax", dto.title.Tax);
  6614. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  6615. designer.SetDataSource("Currency", dto.title.Currency);
  6616. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  6617. designer.SetDataSource("Rate", dto.title.Rate);
  6618. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  6619. var Aparams = hotels.Find(x => x.Type == "Default");
  6620. if (Aparams == null)
  6621. {
  6622. return Ok(jw);
  6623. }
  6624. //酒店数量
  6625. var txtSGRNumber = Aparams.SGR.ToString();
  6626. var txtTBRNumber = Aparams.TBR.ToString();
  6627. var txtJSESNumber = Aparams.JSES.ToString();
  6628. var txtSUITENumbe = Aparams.SUITE.ToString();
  6629. if (dto.costType == "B")
  6630. {
  6631. Aparams = hotels.Find(x => x.Type == "A");
  6632. var Bparams = hotels.Find(x => x.Type == "B");
  6633. if (Aparams == null || Bparams == null)
  6634. {
  6635. return Ok(jw);
  6636. }
  6637. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  6638. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  6639. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  6640. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  6641. }
  6642. designer.SetDataSource("SGRNumber", txtSGRNumber);
  6643. designer.SetDataSource("TBRNumber", txtTBRNumber);
  6644. designer.SetDataSource("JSESNumber", txtJSESNumber);
  6645. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  6646. var ws = designer.Workbook.Worksheets[0];
  6647. int Row = List_GC.Count;
  6648. int startIndex = 11;
  6649. int HideRows = 0;
  6650. List<int> hideRowsList = new List<int>();
  6651. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  6652. #region A段left数据
  6653. var left = dto.leftInfo.Find(x => x.Type == "A");
  6654. if (left == null)
  6655. {
  6656. return Ok(jw);
  6657. }
  6658. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  6659. if (leftBindData != null)
  6660. {
  6661. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  6662. designer.SetDataSource("VisaRS", leftBindData.rs);
  6663. designer.SetDataSource("VisaXS", leftBindData.xs);
  6664. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6665. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6666. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6667. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6668. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6669. }
  6670. else
  6671. {
  6672. hideRowsList.Add(Row + startIndex + HideRows);
  6673. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6674. }
  6675. HideRows += 2;
  6676. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  6677. if (leftBindData != null)
  6678. {
  6679. designer.SetDataSource("BXDRCB", leftBindData.cb);
  6680. designer.SetDataSource("BXRS", leftBindData.rs);
  6681. designer.SetDataSource("BXXS", leftBindData.xs);
  6682. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6683. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6684. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6685. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6686. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6687. }
  6688. else
  6689. {
  6690. hideRowsList.Add(Row + startIndex + HideRows);
  6691. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6692. }
  6693. HideRows += 2;
  6694. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  6695. if (leftBindData != null)
  6696. {
  6697. designer.SetDataSource("HSDRCB", leftBindData.cb);
  6698. designer.SetDataSource("HSRS", leftBindData.rs);
  6699. designer.SetDataSource("HSXS", leftBindData.xs);
  6700. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6701. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6702. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6703. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6704. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6705. }
  6706. else
  6707. {
  6708. hideRowsList.Add(Row + startIndex + HideRows);
  6709. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6710. }
  6711. HideRows += 2;
  6712. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  6713. if (leftBindData != null)
  6714. {
  6715. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  6716. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  6717. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  6718. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6719. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6720. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6721. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6722. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6723. }
  6724. else
  6725. {
  6726. hideRowsList.Add(Row + startIndex + HideRows);
  6727. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6728. }
  6729. HideRows += 2;
  6730. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  6731. if (leftBindData != null)
  6732. {
  6733. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  6734. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  6735. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  6736. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6737. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6738. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6739. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6740. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6741. }
  6742. else
  6743. {
  6744. hideRowsList.Add(Row + startIndex + HideRows);
  6745. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6746. }
  6747. HideRows += 2;
  6748. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  6749. if (leftBindData != null)
  6750. {
  6751. ////TBR
  6752. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  6753. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  6754. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  6755. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6756. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6757. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6758. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6759. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6760. }
  6761. else
  6762. {
  6763. hideRowsList.Add(Row + startIndex + HideRows);
  6764. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6765. }
  6766. HideRows += 2;
  6767. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  6768. if (leftBindData != null)
  6769. {
  6770. ////SGR
  6771. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  6772. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  6773. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  6774. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6775. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6776. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6777. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6778. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6779. }
  6780. else
  6781. {
  6782. hideRowsList.Add(Row + startIndex + HideRows);
  6783. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6784. }
  6785. HideRows += 2;
  6786. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  6787. if (leftBindData != null)
  6788. {
  6789. ////JS/ES
  6790. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  6791. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  6792. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  6793. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6794. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6795. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6796. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6797. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6798. }
  6799. else
  6800. {
  6801. hideRowsList.Add(Row + startIndex + HideRows);
  6802. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6803. }
  6804. HideRows += 2;
  6805. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  6806. if (leftBindData != null)
  6807. {
  6808. ////SUITE
  6809. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  6810. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  6811. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  6812. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6813. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6814. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6815. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6816. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6817. }
  6818. else
  6819. {
  6820. hideRowsList.Add(Row + startIndex + HideRows);
  6821. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6822. }
  6823. HideRows += 2;
  6824. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  6825. if (leftBindData != null)
  6826. {
  6827. designer.SetDataSource("DJDRCB", leftBindData.cb);
  6828. designer.SetDataSource("DJRS", leftBindData.rs);
  6829. designer.SetDataSource("DJXS", leftBindData.xs);
  6830. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6831. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6832. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6833. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6834. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6835. }
  6836. else
  6837. {
  6838. hideRowsList.Add(Row + startIndex + HideRows);
  6839. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6840. }
  6841. HideRows += 2;
  6842. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  6843. if (leftBindData != null)
  6844. {
  6845. designer.SetDataSource("HCPCB", leftBindData.cb);
  6846. designer.SetDataSource("HCPRS", leftBindData.rs);
  6847. designer.SetDataSource("HCPXS", leftBindData.xs);
  6848. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6849. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6850. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6851. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6852. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6853. }
  6854. else
  6855. {
  6856. hideRowsList.Add(Row + startIndex + HideRows);
  6857. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6858. }
  6859. HideRows += 2;
  6860. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  6861. if (leftBindData != null)
  6862. {
  6863. designer.SetDataSource("CPCB", leftBindData.cb);
  6864. designer.SetDataSource("CPRS", leftBindData.rs);
  6865. designer.SetDataSource("CPXS", leftBindData.xs);
  6866. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6867. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6868. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6869. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6870. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6871. }
  6872. else
  6873. {
  6874. hideRowsList.Add(Row + startIndex + HideRows);
  6875. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6876. }
  6877. HideRows += 2;
  6878. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  6879. if (leftBindData != null)
  6880. {
  6881. designer.SetDataSource("GWDRCD", leftBindData.cb);
  6882. designer.SetDataSource("GWRS", leftBindData.rs);
  6883. designer.SetDataSource("GWXS", leftBindData.xs);
  6884. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6885. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6886. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6887. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6888. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6889. }
  6890. else
  6891. {
  6892. hideRowsList.Add(Row + startIndex + HideRows);
  6893. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6894. }
  6895. HideRows += 2;
  6896. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  6897. if (leftBindData != null)
  6898. {
  6899. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  6900. designer.SetDataSource("LYJRS", leftBindData.rs);
  6901. designer.SetDataSource("LYJXS", leftBindData.xs);
  6902. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6903. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6904. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6905. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6906. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6907. }
  6908. else
  6909. {
  6910. hideRowsList.Add(Row + startIndex + HideRows);
  6911. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6912. }
  6913. #endregion
  6914. #region A段Right信息
  6915. var right = dto.rightInfo.Find(x => x.Type == "A");
  6916. if (right == null)
  6917. {
  6918. return Ok(jw);
  6919. }
  6920. HideRows += 4;
  6921. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  6922. if (rightBindData != null)
  6923. {
  6924. //经济舱 + 双人间 TBR
  6925. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  6926. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  6927. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6928. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  6929. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6930. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6931. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6932. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6933. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6934. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6935. }
  6936. else
  6937. {
  6938. hideRowsList.Add(Row + startIndex + HideRows);
  6939. }
  6940. HideRows += 2;
  6941. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  6942. if (rightBindData != null)
  6943. {
  6944. //经济舱 + 单人间 SGR
  6945. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  6946. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  6947. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6948. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  6949. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6950. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6951. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6952. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6953. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6954. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6955. }
  6956. else
  6957. {
  6958. hideRowsList.Add(Row + startIndex + HideRows);
  6959. }
  6960. HideRows += 2;
  6961. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  6962. if (rightBindData != null)
  6963. {
  6964. //公务舱 + 单人间 SGR
  6965. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  6966. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  6967. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6968. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  6969. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6970. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6971. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6972. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6973. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6974. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6975. }
  6976. else
  6977. {
  6978. hideRowsList.Add(Row + startIndex + HideRows);
  6979. }
  6980. HideRows += 2;
  6981. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  6982. if (rightBindData != null)
  6983. {
  6984. //公务舱 + 小套房 JSES
  6985. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  6986. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  6987. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6988. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  6989. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6990. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6991. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6992. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6993. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6994. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6995. }
  6996. else
  6997. {
  6998. hideRowsList.Add(Row + startIndex + HideRows);
  6999. }
  7000. HideRows += 2;
  7001. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7002. if (rightBindData != null)
  7003. {
  7004. //公务舱 + 小套房 JSES
  7005. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7006. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7007. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7008. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7009. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7010. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7011. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7012. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7013. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7014. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7015. }
  7016. else
  7017. {
  7018. hideRowsList.Add(Row + startIndex + HideRows);
  7019. }
  7020. HideRows += 2;
  7021. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7022. if (rightBindData != null)
  7023. {
  7024. //经济舱 + 大套房
  7025. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7026. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7027. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7028. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7029. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7030. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7031. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7032. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7033. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7034. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7035. }
  7036. else
  7037. {
  7038. hideRowsList.Add(Row + startIndex + HideRows);
  7039. }
  7040. #endregion
  7041. #region B段标题清空
  7042. designer.SetDataSource("CostBDRCB", "");
  7043. designer.SetDataSource("CostBRS", "");
  7044. designer.SetDataSource("CostBXS", "");
  7045. designer.SetDataSource("CostBZCB", "");
  7046. designer.SetDataSource("CostBDRBJ", "");
  7047. designer.SetDataSource("CostBZBJ", "");
  7048. designer.SetDataSource("CostBDRLR", "");
  7049. designer.SetDataSource("CostBZLR", "");
  7050. designer.SetDataSource("CostBDRCBOM", "");
  7051. designer.SetDataSource("CostBRSOM", "");
  7052. designer.SetDataSource("CostBZCBOM", "");
  7053. designer.SetDataSource("CostBDRBJOM", "");
  7054. designer.SetDataSource("CostBZBJOM", "");
  7055. designer.SetDataSource("CostBDRLROM", "");
  7056. designer.SetDataSource("CostBZLROM", "");
  7057. #endregion
  7058. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7059. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7060. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7061. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7062. designer.SetDataSource("DJName", "地接(CNY)");
  7063. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7064. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7065. designer.SetDataSource("GWName", "公务(CNY)");
  7066. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7067. designer.SetDataSource("LYJName", "零用金(CNY)");
  7068. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7069. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7070. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7071. designer.SetDataSource("BXName", "保险(CNY)");
  7072. designer.SetDataSource("VisaName", "签证(CNY)");
  7073. #region B段基本数据
  7074. if (dto.costType == "B")
  7075. {
  7076. left = dto.leftInfo.Find(x => x.Type == "B");
  7077. if (left == null)
  7078. {
  7079. return Ok(jw);
  7080. }
  7081. #region B段left数据
  7082. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7083. if (leftBindData != null)
  7084. {
  7085. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7086. designer.SetDataSource("BHSRS", leftBindData.rs);
  7087. designer.SetDataSource("BHSXS", leftBindData.xs);
  7088. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7089. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7090. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7091. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7092. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7093. }
  7094. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7095. if (leftBindData != null)
  7096. {
  7097. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7098. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7099. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7100. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7101. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7102. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7103. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7104. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7105. }
  7106. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7107. if (leftBindData != null)
  7108. {
  7109. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7110. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7111. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7112. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7113. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7114. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7115. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7116. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7117. }
  7118. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7119. if (leftBindData != null)
  7120. {
  7121. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7122. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7123. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7124. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7125. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7126. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7127. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7128. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7129. }
  7130. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7131. if (leftBindData != null)
  7132. {
  7133. designer.SetDataSource("BCPCB", leftBindData.cb);
  7134. designer.SetDataSource("BCPRS", leftBindData.rs);
  7135. designer.SetDataSource("BCPXS", leftBindData.xs);
  7136. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7137. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7138. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7139. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7140. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7141. }
  7142. //TBR
  7143. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7144. if (leftBindData != null)
  7145. {
  7146. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7147. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7148. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7149. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7150. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7151. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7152. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7153. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7154. }
  7155. //SGR
  7156. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7157. if (leftBindData != null)
  7158. {
  7159. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7160. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7161. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7162. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7163. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7164. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7165. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7166. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7167. }
  7168. //JS/ES
  7169. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7170. if (leftBindData != null)
  7171. {
  7172. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7173. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7174. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7175. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7176. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7177. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7178. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7179. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7180. }
  7181. //SUITE
  7182. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7183. if (leftBindData != null)
  7184. {
  7185. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7186. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7187. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7188. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7189. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7190. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7191. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7192. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7193. }
  7194. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7195. if (leftBindData != null)
  7196. {
  7197. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7198. designer.SetDataSource("BDJRS", leftBindData.rs);
  7199. designer.SetDataSource("BDJXS", leftBindData.xs);
  7200. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7201. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7202. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7203. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7204. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7205. }
  7206. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7207. if (leftBindData != null)
  7208. {
  7209. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7210. designer.SetDataSource("BGWRS", leftBindData.rs);
  7211. designer.SetDataSource("BGWXS", leftBindData.xs);
  7212. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7213. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7214. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7215. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7216. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7217. }
  7218. #region 优化方案
  7219. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7220. //excelBind.Add("零用金", new {
  7221. //cb="",
  7222. //rs="",
  7223. //xs ="",
  7224. //zcb = "",
  7225. //});
  7226. #endregion
  7227. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7228. if (leftBindData != null)
  7229. {
  7230. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7231. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7232. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7233. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7234. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7235. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7236. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7237. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7238. }
  7239. #endregion
  7240. #region B段Right信息
  7241. right = dto.rightInfo.Find(x => x.Type == "B");
  7242. if (right == null)
  7243. {
  7244. return Ok(jw);
  7245. }
  7246. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7247. if (rightBindData != null)
  7248. {
  7249. //经济舱 + 双人间 TBR
  7250. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7251. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7252. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7253. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7254. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7255. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7256. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7257. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7258. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7259. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7260. }
  7261. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7262. if (rightBindData != null)
  7263. {
  7264. //经济舱 + 单人间 SGR
  7265. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7266. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7267. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7268. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7269. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7270. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7271. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7272. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7273. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7274. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7275. }
  7276. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7277. if (rightBindData != null)
  7278. {
  7279. //公务舱 + 单人间 SGR
  7280. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7281. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7282. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7283. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7284. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7285. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7286. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7287. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7288. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7289. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7290. }
  7291. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7292. if (rightBindData != null)
  7293. {
  7294. //公务舱 + 小套房 JSES
  7295. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7296. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7297. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7298. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7299. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7300. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7301. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7302. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7303. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7304. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7305. }
  7306. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7307. if (rightBindData != null)
  7308. {
  7309. //公务舱 + 小套房 JSES
  7310. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7311. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7312. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7313. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7314. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7315. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7316. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7317. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7318. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7319. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7320. }
  7321. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7322. if (rightBindData != null)
  7323. {
  7324. //经济舱 + 大套房
  7325. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7326. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7327. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7328. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7329. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7330. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7331. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7332. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7333. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7334. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7335. }
  7336. #endregion
  7337. #region 标题
  7338. designer.SetDataSource("CostBDRCB", "单人成本");
  7339. designer.SetDataSource("CostBRS", "人数");
  7340. designer.SetDataSource("CostBXS", "系数");
  7341. designer.SetDataSource("CostBZCB", "总成本");
  7342. designer.SetDataSource("CostBDRBJ", "单人报价");
  7343. designer.SetDataSource("CostBZBJ", "总报价");
  7344. designer.SetDataSource("CostBDRLR", "单人利润");
  7345. designer.SetDataSource("CostBZLR", "总利润");
  7346. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7347. designer.SetDataSource("CostBRSOM", "人数");
  7348. designer.SetDataSource("CostBZCBOM", "总成本");
  7349. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7350. designer.SetDataSource("CostBZBJOM", "总报价");
  7351. designer.SetDataSource("CostBDRLROM", "单人利润");
  7352. designer.SetDataSource("CostBZLROM", "总利润");
  7353. #endregion
  7354. }
  7355. #endregion
  7356. designer.SetDataSource("TzZCB2", TzZCB2);
  7357. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7358. designer.SetDataSource("TzZLR2", TzZLR2);
  7359. string[] dataSourceKeys = new string[]
  7360. {
  7361. "VF",
  7362. "TGS",
  7363. "TGOF",
  7364. "TGM",
  7365. "TGA",
  7366. "TGTF",
  7367. "TGEF",
  7368. "CFM",
  7369. "CFOF",
  7370. "B",
  7371. "L",
  7372. "D",
  7373. "TBR",
  7374. "SGR",
  7375. "JSES",
  7376. "Suite",
  7377. "TV",
  7378. "1L",
  7379. "IF",
  7380. "EF",
  7381. "BRF",
  7382. "TE",
  7383. "TGT",
  7384. "DRVT",
  7385. "PC",
  7386. "TLF",
  7387. "ECT"
  7388. };
  7389. foreach (var item in dataSourceKeys)
  7390. {
  7391. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7392. if (find != null)
  7393. {
  7394. designer.SetDataSource(item, find.text);
  7395. }
  7396. else
  7397. {
  7398. designer.SetDataSource(item, 0);
  7399. }
  7400. }
  7401. designer.SetDataSource(dt);
  7402. //根据数据源处理生成报表内容
  7403. designer.Process();
  7404. designer.Workbook.Worksheets[0].Name = "清单";
  7405. Worksheet sheet = designer.Workbook.Worksheets[0];
  7406. foreach (var Rowindex in hideRowsList)
  7407. {
  7408. ws.Cells.HideRows(Rowindex, 2);
  7409. }
  7410. byte[] bytes = null;
  7411. string strFileName = di.TeamName + "-团组-成本.xls";
  7412. using (MemoryStream stream = new MemoryStream())
  7413. {
  7414. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7415. bytes = stream.ToArray();
  7416. }
  7417. return Ok(JsonView(true, "", new
  7418. {
  7419. Data = bytes,
  7420. strFileName,
  7421. }));
  7422. }
  7423. /// <summary>
  7424. /// 导出客户报表
  7425. /// </summary>
  7426. /// <returns></returns>
  7427. [HttpPost]
  7428. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7429. {
  7430. var jw = JsonView(false);
  7431. if (dto.Diid == 0)
  7432. {
  7433. return Ok(JsonView(false, "请传递团组id"));
  7434. }
  7435. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7436. if (deleInfo.Code != 0)
  7437. {
  7438. return Ok(JsonView(false, "团组信息查询失败!"));
  7439. }
  7440. var di = deleInfo.Data as DelegationInfoWebView;
  7441. if (di == null)
  7442. {
  7443. return Ok(JsonView(false, "团组信息查询失败!"));
  7444. }
  7445. //文件名
  7446. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  7447. //获取模板
  7448. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  7449. //载入模板
  7450. Document doc = new Document(tmppath);
  7451. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  7452. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  7453. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  7454. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  7455. var AParameter = ParameterList.Find(x => x.CostType == "A");
  7456. var BParameter = ParameterList.Find(x => x.CostType == "B");
  7457. if (AParameter == null)
  7458. {
  7459. return Ok(JsonView(false, "系数不存在!"));
  7460. }
  7461. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  7462. , TzAirDesc, TzZCost;
  7463. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  7464. = TzAirDesc = TzZCost = string.Empty;
  7465. TzNumber = AParameter.CostTypenumber.ToString();
  7466. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  7467. CarGuides1 = dto.CarGuides1;
  7468. Meal = dto.Meal;
  7469. SubsidizedMeals = dto.SubsidizedMeals;
  7470. NightRepair = dto.NightRepair;
  7471. AttractionsTickets = dto.AttractionsTickets;
  7472. MiscellaneousFees = dto.MiscellaneousFees;
  7473. ATip = dto.ATip;
  7474. TzHotelDesc = "";
  7475. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  7476. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  7477. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  7478. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  7479. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  7480. TzAirDesc = "";
  7481. TzZCost = dto.TzZCost;
  7482. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  7483. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  7484. var index = 1;
  7485. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  7486. foreach (var item in TzHotelDescArr)
  7487. {
  7488. if (AinfoArr != null)
  7489. {
  7490. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7491. if (Ainfo != null)
  7492. {
  7493. if (int.Parse(Ainfo.rs) <= 0)
  7494. {
  7495. continue;
  7496. }
  7497. var hotelText = string.Empty;
  7498. switch (item)
  7499. {
  7500. case "SGR":
  7501. hotelText = "单人间";
  7502. break;
  7503. case "JSES":
  7504. hotelText = "小套房";
  7505. break;
  7506. case "SUITE":
  7507. hotelText = "套房";
  7508. break;
  7509. case "TBR":
  7510. hotelText = "双人间";
  7511. break;
  7512. }
  7513. if (item != "TBR")
  7514. {
  7515. 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";
  7516. }
  7517. else
  7518. {
  7519. 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";
  7520. }
  7521. index++;
  7522. }
  7523. }
  7524. }
  7525. index = 1;
  7526. foreach (var item in TzAirDescArr)
  7527. {
  7528. if (AinfoArr != null)
  7529. {
  7530. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7531. if (Ainfo != null)
  7532. {
  7533. if (int.Parse(Ainfo.rs) <= 0)
  7534. {
  7535. continue;
  7536. }
  7537. 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";
  7538. index++;
  7539. }
  7540. }
  7541. }
  7542. if (dto.costType == "B")
  7543. {
  7544. if (BParameter == null)
  7545. {
  7546. return Ok(JsonView(false, "B段系数不存在!"));
  7547. }
  7548. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  7549. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  7550. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  7551. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  7552. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  7553. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  7554. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  7555. foreach (var item in TzHotelDescArr)
  7556. {
  7557. if (AinfoArr != null)
  7558. {
  7559. TzHotelDesc += "B段信息 \r\n";
  7560. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7561. if (Ainfo != null)
  7562. {
  7563. if (int.Parse(Ainfo.rs) <= 0)
  7564. {
  7565. continue;
  7566. }
  7567. var hotelText = string.Empty;
  7568. switch (item)
  7569. {
  7570. case "SGR":
  7571. hotelText = "单人间";
  7572. break;
  7573. case "JSES":
  7574. hotelText = "小套房";
  7575. break;
  7576. case "SUITE":
  7577. hotelText = "套房";
  7578. break;
  7579. case "TBR":
  7580. hotelText = "双人间";
  7581. break;
  7582. }
  7583. if (item != "TBR")
  7584. {
  7585. 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";
  7586. }
  7587. else
  7588. {
  7589. 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";
  7590. }
  7591. index++;
  7592. }
  7593. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  7594. }
  7595. }
  7596. index = 1;
  7597. foreach (var item in TzAirDescArr)
  7598. {
  7599. if (AinfoArr != null)
  7600. {
  7601. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7602. if (Ainfo != null)
  7603. {
  7604. if (int.Parse(Ainfo.rs) <= 0)
  7605. {
  7606. continue;
  7607. }
  7608. 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";
  7609. index++;
  7610. }
  7611. }
  7612. }
  7613. }
  7614. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  7615. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  7616. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  7617. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  7618. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  7619. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  7620. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  7621. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  7622. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  7623. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  7624. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  7625. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  7626. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  7627. DickeyValue.Add("Visa", Visa); // 签证单人报价
  7628. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  7629. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  7630. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  7631. DickeyValue.Add("TzZCost", TzZCost);
  7632. foreach (var key in DickeyValue.Keys)
  7633. {
  7634. if (doc.Range.Bookmarks[key] != null)
  7635. {
  7636. Bookmark mark = doc.Range.Bookmarks[key];
  7637. mark.Text = DickeyValue[key];
  7638. }
  7639. }
  7640. byte[] bytes = null;
  7641. string strFileName = di.TeamName + "-客户报价.doc";
  7642. using (MemoryStream stream = new MemoryStream())
  7643. {
  7644. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7645. bytes = stream.ToArray();
  7646. }
  7647. return Ok(JsonView(true, "", new
  7648. {
  7649. Data = bytes,
  7650. strFileName,
  7651. }));
  7652. }
  7653. /// <summary>
  7654. /// 团组成本 各模块(酒店,地接,机票)成本提示
  7655. /// </summary>
  7656. /// <param name="dto"></param>
  7657. /// <returns></returns>
  7658. [HttpPost]
  7659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7660. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  7661. {
  7662. try
  7663. {
  7664. #region 参数验证
  7665. if (dto.DiId < 0)
  7666. {
  7667. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7668. }
  7669. List<int> cTableIds = new List<int>() {
  7670. 76 ,//酒店预订
  7671. 77 ,//行程
  7672. 79 ,//车/导游地接
  7673. 80 ,//签证
  7674. 81 ,//邀请/公务活
  7675. 82 ,//团组客户保险
  7676. 85 ,//机票预订
  7677. 98 ,//其他款项
  7678. 285 ,//收款退还
  7679. 751 ,//酒店早餐
  7680. 1015 // 超支费用
  7681. };
  7682. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  7683. {
  7684. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  7685. }
  7686. #endregion
  7687. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  7688. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7689. if (_GroupCostParameters.Count <= 0)
  7690. {
  7691. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  7692. }
  7693. if (_GroupCostParameters[0].IsShare == 0)
  7694. {
  7695. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  7696. }
  7697. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7698. //处理date为空问题
  7699. if (_GroupCosts.Count > 0)
  7700. {
  7701. for (int i = 0; i < _GroupCosts.Count; i++)
  7702. {
  7703. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  7704. {
  7705. if (i > 0)
  7706. {
  7707. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  7708. }
  7709. }
  7710. }
  7711. }
  7712. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  7713. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  7714. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7715. string currCode = "";
  7716. #region currCode 验证
  7717. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  7718. if (isInt)
  7719. {
  7720. var currData = currDatas.Find(it => it.Id == intCurrency);
  7721. if (currData != null)
  7722. {
  7723. currCode = currData.Name;
  7724. }
  7725. }
  7726. else
  7727. {
  7728. currCode = _GroupCostParameters[0].Currency.Trim();
  7729. }
  7730. #endregion
  7731. //op,酒店单段模式存储
  7732. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  7733. {
  7734. CurrencyCode = currCode,
  7735. Rate = _GroupCostParameters[0].Rate,
  7736. CostType = _GroupCostParameters[0].CostType,
  7737. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  7738. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  7739. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  7740. };
  7741. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  7742. if (_GroupCostParameters.Count == 2)
  7743. {
  7744. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  7745. }
  7746. foreach (var item in _GroupCostParameters)
  7747. {
  7748. decimal _rate = 1;
  7749. decimal _rate1 = item.Rate;
  7750. decimal _scale = 1;
  7751. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  7752. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  7753. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  7754. //if (userInfo != null)
  7755. //{
  7756. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  7757. // {
  7758. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  7759. // {
  7760. // _scale = 1.00M;
  7761. // }
  7762. // }
  7763. //}
  7764. #endregion
  7765. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  7766. {
  7767. CurrencyCode = currCode,
  7768. Rate = _rate1,
  7769. CostType = item.CostType,
  7770. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  7771. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  7772. CostTypeNumber = item.CostTypenumber
  7773. };
  7774. if (_GroupCostParameters.Count > 1)
  7775. {
  7776. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  7777. }
  7778. else
  7779. {
  7780. modulePromptInfo.CostTypeNumber = item.LYJRS;
  7781. }
  7782. if (dto.CTable == 79)//
  7783. {
  7784. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  7785. modulePromptInfo.TotalCost = item.DJCB;
  7786. }
  7787. List<string> costTypes = new List<string>() { "A", "B" };
  7788. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  7789. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  7790. if (_GroupCostsDuplicates.Count() == 1)
  7791. {
  7792. _GroupCostsTypeData = _GroupCosts;
  7793. }
  7794. else
  7795. {
  7796. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  7797. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  7798. }
  7799. /*
  7800. * 76 酒店预订
  7801. * 77 行程
  7802. * 79 车/导游地接
  7803. * 80 签证
  7804. * 81 邀请/公务活动
  7805. * 82 团组客户保险
  7806. * 85 机票预订
  7807. * 98 其他款项
  7808. * 285 收款退还
  7809. * 751 酒店早餐
  7810. * 1015 超支费用
  7811. */
  7812. switch (dto.CTable)
  7813. {
  7814. case 76: // 酒店预订
  7815. _ModuleSubPromptInfo.AddRange(
  7816. _GroupCostsTypeData.Select(it => new
  7817. {
  7818. it.DAY,
  7819. it.Date,
  7820. it.ACCON,
  7821. it.ITIN,
  7822. it.SGR,
  7823. it.TBR,
  7824. it.JS_ES,
  7825. it.Suite
  7826. })
  7827. );
  7828. break;
  7829. case 79: // 车/导游地接
  7830. _ModuleSubPromptInfo.AddRange(
  7831. _GroupCostsTypeData.Select(it => new
  7832. {
  7833. Date = it.Date, //日期
  7834. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  7835. GuideFee = (it.TGS + it.TGOF + it.TGM + it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  7836. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  7837. TicketFee = it.EF * _rate * _scale, //门票费
  7838. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  7839. AirportTransferFee = 0.00M,
  7840. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  7841. TravelSupplies = it.TE * _rate * _scale, //出行物资
  7842. LeadersFee = it.TLF * _rate * _scale, //领队费
  7843. CarFee1 = it.CarCost * _rate * _scale,
  7844. CarType = it.CarType, //车型
  7845. SpentCash = it.PC * _rate * _scale, //零用金
  7846. })
  7847. );
  7848. break;
  7849. case 85: // 机票
  7850. List<dynamic> datas = new List<dynamic>();
  7851. datas.Add(
  7852. new
  7853. {
  7854. AirType = "经济舱",
  7855. AirNum = item.JJCRS,
  7856. AirDRCB = item.JJCCB,
  7857. AirZCB = (item.JJCRS * item.JJCCB)
  7858. }
  7859. );
  7860. datas.Add(
  7861. new
  7862. {
  7863. AirType = "公务舱",
  7864. AirNum = item.GWCRS,
  7865. AirDRCB = item.GWCCB,
  7866. AirZCB = (item.GWCRS * item.GWCCB)
  7867. }
  7868. );
  7869. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7870. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  7871. modulePromptInfo.Data = new {
  7872. airFeeData = datas,
  7873. airInitData = initDatas
  7874. };
  7875. _ModulePromptInfos.Add(modulePromptInfo);
  7876. break;
  7877. default:
  7878. break;
  7879. }
  7880. }
  7881. if (dto.CTable != 85)
  7882. {
  7883. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  7884. _ModulePromptInfos.Add(_ModulePromptInfo);
  7885. }
  7886. _view.ModulePromptInfos = _ModulePromptInfos;
  7887. return Ok(JsonView(true, "操作成功!", _view));
  7888. }
  7889. catch (Exception ex)
  7890. {
  7891. return Ok(JsonView(false, ex.Message));
  7892. }
  7893. }
  7894. /// <summary>
  7895. /// 根据黑屏代码重新生成行程
  7896. /// </summary>
  7897. /// <param name="dto"></param>
  7898. /// <returns></returns>
  7899. [HttpPost]
  7900. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  7901. {
  7902. var jw = JsonView(false);
  7903. var Create = _GroupCostRepository.
  7904. CreateGroupCostByBlackCode(dto.Diid);
  7905. jw.Msg = Create.Msg;
  7906. if (Create.Code == 0)
  7907. {
  7908. jw.Code = 200;
  7909. jw.Data = new
  7910. {
  7911. groupCost = Create.Data,
  7912. blackCodeIsTrue = true
  7913. };
  7914. }
  7915. else
  7916. {
  7917. jw.Code = 400;
  7918. jw.Data = new
  7919. {
  7920. groupCost = Create.Data,
  7921. blackCodeIsTrue = false,
  7922. };
  7923. }
  7924. return Ok(jw);
  7925. }
  7926. /// <summary>
  7927. /// 成本获取OP历史车费用
  7928. /// </summary>
  7929. /// <param name="dto"></param>
  7930. /// <returns></returns>
  7931. [HttpPost]
  7932. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  7933. {
  7934. var jw = JsonView(false);
  7935. try
  7936. {
  7937. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  7938. //获取现有所有车的数据
  7939. if (!dto.Param.IsNullOrWhiteSpace())
  7940. {
  7941. string sql = $@"
  7942. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  7943. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  7944. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  7945. WHERE gctggr.IsDel = 0 and gctggrc.SId = 91 AND gdi.IsDel = 0 AND gctggrc.Price != 0 AND (ssd.Id in (1061,1069) or ssd.Id is NULL) AND gctggr.ServiceStartTime is not null
  7946. AND gctggr.ServiceEndTime is not NULL
  7947. ORDER by gctggrc.id DESC
  7948. ";
  7949. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  7950. var numeberResult = await Task.Run(() =>
  7951. {
  7952. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  7953. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  7954. return numberArr;
  7955. });
  7956. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  7957. foreach (var item in numeberResult)
  7958. {
  7959. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  7960. {
  7961. Country = "数据异常!",
  7962. City = string.Empty,
  7963. };
  7964. item.Area = find.Country + " " + find.City;
  7965. }
  7966. dbResult.AddRange(numeberResult);
  7967. if (dto.Param.Contains("、"))
  7968. {
  7969. var sp = dto.Param.Split("、");
  7970. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  7971. .Where(x =>
  7972. {
  7973. return System.Array.Exists(sp, e =>
  7974. {
  7975. bool where = false;
  7976. if (x.Area != null)
  7977. {
  7978. where = x.Area.Contains(e);
  7979. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  7980. {
  7981. return false;
  7982. }
  7983. }
  7984. if (x.PriceName != null && !where)
  7985. {
  7986. where = x.PriceName.Contains(e);
  7987. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  7988. {
  7989. return false;
  7990. }
  7991. }
  7992. return where;
  7993. });
  7994. }).ToList();
  7995. }
  7996. else
  7997. {
  7998. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  7999. .Where(x =>
  8000. {
  8001. bool where = false;
  8002. if (x.Area != null)
  8003. {
  8004. where = x.Area.Contains(dto.Param);
  8005. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8006. {
  8007. return false;
  8008. }
  8009. }
  8010. if (x.PriceName != null && !where)
  8011. {
  8012. where = x.PriceName.Contains(dto.Param);
  8013. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8014. {
  8015. return false;
  8016. }
  8017. }
  8018. return where;
  8019. }
  8020. )
  8021. .ToList();
  8022. }
  8023. }
  8024. var view = dbResult.Select(x => {
  8025. decimal dp = 0.00M;
  8026. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8027. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8028. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8029. {
  8030. if (startB && endB)
  8031. {
  8032. var timesp = endD.Subtract(startD);
  8033. if ((timesp.Days + 1) != 0)
  8034. {
  8035. dp = x.Price / (timesp.Days + 1);
  8036. }
  8037. }
  8038. }
  8039. else
  8040. {
  8041. dp = x.Price;
  8042. }
  8043. return new
  8044. {
  8045. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8046. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8047. x.Area,
  8048. x.id,
  8049. price = x.Price.ToString("F2"),
  8050. x.PriceName,
  8051. x.PriceContent,
  8052. x.TeamName,
  8053. x.DatePrice,
  8054. dayPrice = dp.ToString("F2"),
  8055. };
  8056. }).OrderByDescending(x => x.id).ToList();
  8057. jw = JsonView(true, "获取成功!", view);
  8058. }
  8059. catch (Exception e)
  8060. {
  8061. jw = JsonView(false, e.Message);
  8062. }
  8063. return Ok(jw);
  8064. }
  8065. #endregion
  8066. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8067. /// <summary>
  8068. /// 酒店预订
  8069. /// 酒店费用列表 根据团组Id查询
  8070. /// </summary>
  8071. /// <param name="_dto"></param>
  8072. /// <returns></returns>
  8073. [HttpPost]
  8074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8075. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8076. {
  8077. #region 参数验证
  8078. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8079. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8080. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8081. #region 团组操作权限验证 76 酒店预定模块
  8082. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8083. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8084. #endregion
  8085. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8086. #region 页面操作权限验证
  8087. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8088. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8089. #endregion
  8090. #endregion
  8091. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8092. }
  8093. /// <summary>
  8094. /// 酒店预订
  8095. /// 基础数据
  8096. /// </summary>
  8097. /// <param name="_dto"></param>
  8098. /// <returns></returns>
  8099. [HttpPost]
  8100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8101. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8102. {
  8103. #region 参数验证
  8104. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8105. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8106. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8107. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8108. #region 页面操作权限验证
  8109. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8110. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8111. #endregion
  8112. #region 团组操作权限验证 76 酒店预定模块
  8113. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8114. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8115. #endregion
  8116. #endregion
  8117. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8118. }
  8119. /// <summary>
  8120. /// 酒店预订
  8121. /// 创建 入住卷号码
  8122. /// </summary>
  8123. /// <param name="_dto"></param>
  8124. /// <returns></returns>
  8125. [HttpPost]
  8126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8127. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8128. {
  8129. try
  8130. {
  8131. #region 参数验证
  8132. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8133. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8134. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8135. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8136. #region 页面操作权限验证
  8137. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8138. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8139. #endregion
  8140. #region 团组操作权限验证 76 酒店预定模块
  8141. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8142. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8143. #endregion
  8144. #endregion
  8145. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8146. if (data.Code != 0)
  8147. {
  8148. return Ok(JsonView(false, data.Msg));
  8149. }
  8150. return Ok(JsonView(true, data.Msg, data.Data));
  8151. }
  8152. catch (Exception ex)
  8153. {
  8154. return Ok(JsonView(false, ex.Message));
  8155. }
  8156. }
  8157. /// <summary>
  8158. /// 酒店预订
  8159. /// 详情
  8160. /// </summary>
  8161. /// <param name="_dto"></param>
  8162. /// <returns></returns>
  8163. [HttpPost]
  8164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8165. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8166. {
  8167. #region 参数验证
  8168. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8169. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8170. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8171. #region 团组操作权限验证 76 酒店预定模块
  8172. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8173. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8174. #endregion
  8175. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8176. #region 页面操作权限验证
  8177. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8178. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8179. #endregion
  8180. #endregion
  8181. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8182. }
  8183. /// <summary>
  8184. /// 酒店预订
  8185. /// Add Or Edit
  8186. /// </summary>
  8187. /// <param name="_dto"></param>
  8188. /// <returns></returns>
  8189. [HttpPost]
  8190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8191. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8192. {
  8193. #region 参数验证
  8194. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8195. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8196. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8197. #region 团组操作权限验证 76 酒店预定模块
  8198. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8199. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8200. #endregion
  8201. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8202. #region 页面操作权限验证
  8203. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8204. if (_dto.Id == 0) // Add
  8205. {
  8206. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8207. }
  8208. else if (_dto.Id > 1) // Edit
  8209. {
  8210. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8211. } else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8212. #endregion
  8213. #endregion
  8214. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8215. if (_view.Code != 200)
  8216. {
  8217. return Ok(_view);
  8218. }
  8219. #region 应用推送
  8220. try
  8221. {
  8222. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8223. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8224. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8225. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8226. //自动审核
  8227. await _feeAuditRep.FeeAutomaticAudit(1,_dto.DiId,hotelId);
  8228. }
  8229. catch (Exception ex)
  8230. {
  8231. }
  8232. #endregion
  8233. return Ok(_view);
  8234. }
  8235. /// <summary>
  8236. /// 酒店预订
  8237. /// Del
  8238. /// </summary>
  8239. /// <param name="_dto"></param>
  8240. /// <returns></returns>
  8241. [HttpPost]
  8242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8243. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8244. {
  8245. #region 参数验证
  8246. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8247. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8248. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8249. #region 团组操作权限验证 76 酒店预定模块
  8250. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8251. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8252. #endregion
  8253. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8254. #region 页面操作权限验证
  8255. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8256. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8257. #endregion
  8258. #endregion
  8259. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8260. }
  8261. /// <summary>
  8262. /// 酒店预订
  8263. /// 生成VOUCHER
  8264. /// 2024.05.06 之前版本
  8265. /// </summary>
  8266. /// <param name="_dto"></param>
  8267. /// <returns></returns>
  8268. [HttpPost]
  8269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8270. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8271. {
  8272. try
  8273. {
  8274. #region 参数验证
  8275. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8276. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8277. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8278. #region 团组操作权限验证 76 酒店预定模块
  8279. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8280. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8281. #endregion
  8282. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8283. #region 页面操作权限验证
  8284. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8285. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8286. #endregion
  8287. #endregion
  8288. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8289. //判断数据是否完整
  8290. if (hr != null)
  8291. {
  8292. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8293. {
  8294. string strFileName = "HotelStatement/";
  8295. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8296. if (dele != null)
  8297. strFileName += dele.TourCode;
  8298. //载入模板
  8299. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8300. Document doc = new Document(sss);
  8301. DocumentBuilder builder = new DocumentBuilder(doc);
  8302. #region 替换Word模板书签内容
  8303. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8304. //入住卷预定号码
  8305. if (doc.Range.Bookmarks["VNO"] != null)
  8306. {
  8307. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8308. mark.Text = hr.CheckNumber;
  8309. }
  8310. //酒店时间
  8311. if (doc.Range.Bookmarks["Date"] != null)
  8312. {
  8313. Bookmark mark = doc.Range.Bookmarks["Date"];
  8314. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8315. }
  8316. //团号
  8317. if (doc.Range.Bookmarks["TNo"] != null)
  8318. {
  8319. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8320. mark.Text = dele.TourCode;
  8321. }
  8322. //预定号码
  8323. if (doc.Range.Bookmarks["BookingId"] != null)
  8324. {
  8325. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8326. mark.Text = hr.ReservationsNo;
  8327. }
  8328. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8329. {
  8330. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8331. mark.Text = hr.DetermineNo;
  8332. }
  8333. //酒店城市
  8334. if (doc.Range.Bookmarks["City"] != null)
  8335. {
  8336. Bookmark mark = doc.Range.Bookmarks["City"];
  8337. mark.Text = hr.City;
  8338. }
  8339. //酒店名称
  8340. if (doc.Range.Bookmarks["HName"] != null)
  8341. {
  8342. Bookmark mark = doc.Range.Bookmarks["HName"];
  8343. mark.Text = hr.HotelName;
  8344. }
  8345. //酒店地址
  8346. if (doc.Range.Bookmarks["Address"] != null)
  8347. {
  8348. Bookmark mark = doc.Range.Bookmarks["Address"];
  8349. mark.Text = hr.HotelAddress;
  8350. }
  8351. //酒店电话
  8352. if (doc.Range.Bookmarks["Tel"] != null)
  8353. {
  8354. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8355. mark.Text = hr.HotelTel;
  8356. }
  8357. //酒店传真
  8358. if (doc.Range.Bookmarks["Fax"] != null)
  8359. {
  8360. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8361. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8362. {
  8363. mark.Text = hr.HotelFax;
  8364. }
  8365. }
  8366. //入住时间
  8367. if (doc.Range.Bookmarks["CIn"] != null)
  8368. {
  8369. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8370. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8371. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8372. }
  8373. //退房时间
  8374. if (doc.Range.Bookmarks["COut"] != null)
  8375. {
  8376. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8377. Bookmark mark = doc.Range.Bookmarks["COut"];
  8378. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8379. }
  8380. //客户名称
  8381. if (doc.Range.Bookmarks["GName"] != null)
  8382. {
  8383. string guestName = "";
  8384. string[] clients = new string[] { };
  8385. if (hr.GuestName.Contains(","))
  8386. {
  8387. clients = hr.GuestName.Split(",");
  8388. }
  8389. else
  8390. {
  8391. clients = new string[] { hr.GuestName };
  8392. }
  8393. List<int> clientIds_int = new List<int>();
  8394. if (clients.Length > 0)
  8395. {
  8396. foreach (var item in clients)
  8397. {
  8398. if (item.IsNumeric())
  8399. {
  8400. clientIds_int.Add(int.Parse(item));
  8401. }
  8402. }
  8403. }
  8404. if (clientIds_int.Count > 0)
  8405. {
  8406. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8407. foreach (var client in _clientDatas)
  8408. {
  8409. //男
  8410. if (client.Sex == 0) guestName += $"Mr.";
  8411. //女
  8412. else if (client.Sex == 1) guestName += $"Ms.";
  8413. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8414. {
  8415. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8416. }
  8417. //guestName += $"{client.Pinyin},";
  8418. }
  8419. if (guestName.Length > 0)
  8420. {
  8421. guestName = guestName.Substring(0, guestName.Length - 1);
  8422. }
  8423. }
  8424. else
  8425. {
  8426. guestName = hr.GuestName;
  8427. }
  8428. Bookmark mark = doc.Range.Bookmarks["GName"];
  8429. mark.Text = guestName;
  8430. }
  8431. //房间介绍
  8432. if (doc.Range.Bookmarks["ROOM"] != null)
  8433. {
  8434. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8435. mark.Text = hr.RoomExplanation;
  8436. }
  8437. //报价描述
  8438. if (doc.Range.Bookmarks["NOTE"] != null)
  8439. {
  8440. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8441. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  8442. if (ss != null)
  8443. mark.Text = ss.Name;
  8444. }
  8445. //入住时间
  8446. if (doc.Range.Bookmarks["CheckIn"] != null)
  8447. {
  8448. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8449. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  8450. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  8451. }
  8452. //退房时间
  8453. if (doc.Range.Bookmarks["CheckOut"] != null)
  8454. {
  8455. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8456. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  8457. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8458. }
  8459. //日期
  8460. if (doc.Range.Bookmarks["DT"] != null)
  8461. {
  8462. Bookmark mark = doc.Range.Bookmarks["DT"];
  8463. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8464. }
  8465. //名称
  8466. if (doc.Range.Bookmarks["VName"] != null)
  8467. {
  8468. Bookmark mark = doc.Range.Bookmarks["VName"];
  8469. mark.Text = hr.HotelName;
  8470. }
  8471. //号码
  8472. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  8473. {
  8474. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  8475. mark.Text = hr.CheckNumber;
  8476. }
  8477. #endregion
  8478. strFileName += "VOUCHER.doc";
  8479. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8480. doc.Save(fileDir);
  8481. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8482. return Ok(JsonView(true, "操作成功!", Url));
  8483. }
  8484. else
  8485. {
  8486. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  8487. }
  8488. }
  8489. else
  8490. {
  8491. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  8492. }
  8493. }
  8494. catch (Exception ex)
  8495. {
  8496. return Ok(JsonView(false, ex.Message));
  8497. }
  8498. }
  8499. /// <summary>
  8500. /// 酒店预订
  8501. /// 生成VOUCHER
  8502. /// 2024.05.06 之后版本
  8503. /// </summary>
  8504. /// <param name="_dto"></param>
  8505. /// <returns></returns>
  8506. [HttpPost]
  8507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8508. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  8509. {
  8510. #region 参数验证
  8511. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8512. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8513. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8514. #region 团组操作权限验证 76 酒店预定模块
  8515. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8516. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8517. #endregion
  8518. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8519. #region 页面操作权限验证
  8520. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8521. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8522. #endregion
  8523. #endregion
  8524. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8525. //判断数据是否完整
  8526. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  8527. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8528. string strFileName = "HotelStatement/";
  8529. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8530. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  8531. #region 数据处理
  8532. List<int> guestIds = new List<int>();
  8533. int index = 0;
  8534. foreach (var item in hrDtas)
  8535. {
  8536. if (item.GuestName.Contains(","))
  8537. {
  8538. string[] guestIdArr = item.GuestName.Split(',');
  8539. foreach (var guestIdStr in guestIdArr)
  8540. {
  8541. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  8542. if (guestBool)
  8543. {
  8544. guestIds.Add(guestId);
  8545. }
  8546. }
  8547. }
  8548. else guestNames += item.GuestName;
  8549. var voucherInfo = new HotelVoucherInfoView()
  8550. {
  8551. HotelName = item.HotelName,
  8552. CheckInDate = item.CheckInDate,
  8553. CheckOutDate = item.CheckOutDate,
  8554. ConfirmationNumber = item.DetermineNo.Trim(),
  8555. RoomType = item.RoomExplanation
  8556. };
  8557. vouchers.Add(voucherInfo);
  8558. }
  8559. if (guestIds.Count > 0)
  8560. {
  8561. guestIds = guestIds.Distinct().ToList();
  8562. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  8563. if (guestDatas.Count > 0)
  8564. {
  8565. guestNames = "";
  8566. foreach (var guest in guestDatas)
  8567. {
  8568. string guestName = "";
  8569. if (guest.Sex == 0) guestName += @"MR.";
  8570. else if (guest.Sex == 1) guestName += @"MS.";
  8571. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  8572. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  8573. guestNames += @$"{guestName.Trim()}、";
  8574. }
  8575. if (guestNames.Length > 0)
  8576. {
  8577. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  8578. }
  8579. }
  8580. }
  8581. #endregion
  8582. //载入模板
  8583. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  8584. Document doc = new Document(sss);
  8585. DocumentBuilder builder = new DocumentBuilder(doc);
  8586. if (doc.Range.Bookmarks["GuestName"] != null)
  8587. {
  8588. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  8589. mark.Text = guestNames;
  8590. }
  8591. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8592. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  8593. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  8594. for (int i = 1; i <= vouchers.Count; i++)
  8595. {
  8596. HotelVoucherInfoView hviv = vouchers[i - 1];
  8597. builder.MoveToCell(0, i, 0, 0);
  8598. builder.Write(hviv.HotelName);
  8599. builder.MoveToCell(0, i, 1, 0);
  8600. builder.Write(hviv.CheckInDate);
  8601. builder.MoveToCell(0, i, 2, 0);
  8602. builder.Write(hviv.CheckOutDate);
  8603. builder.MoveToCell(0, i, 3, 0);
  8604. builder.Write(hviv.RoomType);
  8605. builder.MoveToCell(0, i, 4, 0);
  8606. builder.Write(hviv.ConfirmationNumber);
  8607. }
  8608. //删除多余行
  8609. int currRowIndex = vouchers.Count + 1;
  8610. int delRows = 21 - currRowIndex;
  8611. if (delRows > 0)
  8612. {
  8613. for (int i = 0; i < delRows; i++)
  8614. {
  8615. table.Rows.RemoveAt(currRowIndex);
  8616. //cultivateRowIndex++;
  8617. }
  8618. }
  8619. strFileName += "VOUCHER.docx";
  8620. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8621. doc.Save(fileDir);
  8622. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8623. return Ok(JsonView(true, "操作成功!", Url));
  8624. }
  8625. /// <summary>
  8626. /// 酒店预订
  8627. /// 生成 预定成本 Excel
  8628. /// </summary>
  8629. /// <param name="_dto"></param>
  8630. /// <returns></returns>
  8631. [HttpPost]
  8632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8633. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  8634. {
  8635. #region 参数验证
  8636. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  8637. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  8638. if (!vadalitorRes.IsValid)
  8639. {
  8640. var errors = new StringBuilder();
  8641. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  8642. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  8643. }
  8644. #region 团组操作权限验证 76 酒店预定模块
  8645. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8646. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8647. #endregion
  8648. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8649. #region 页面操作权限验证
  8650. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8651. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8652. #endregion
  8653. #endregion
  8654. decimal _rate = 1.00M;
  8655. string _currency = "";
  8656. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  8657. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8658. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  8659. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  8660. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  8661. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  8662. {
  8663. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  8664. }
  8665. _currency = _GroupCostParameter.Currency;
  8666. bool isIntType = int.TryParse(_currency, out int currId);
  8667. if (isIntType)
  8668. {
  8669. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  8670. }
  8671. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  8672. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  8673. if (currInfo == null)
  8674. {
  8675. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  8676. }
  8677. if (!_currency.ToUpper().Equals("CNY"))
  8678. {
  8679. _rate = _GroupCostParameter.Rate;
  8680. }
  8681. _rate = currInfo.Rate;
  8682. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8683. string strFileName = "HotelStatement/";
  8684. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8685. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  8686. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  8687. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  8688. #region 数据处理
  8689. foreach (var item in hrDtas)
  8690. {
  8691. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  8692. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  8693. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  8694. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  8695. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  8696. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  8697. string singleRoomFeeStr = string.Empty,
  8698. doubleRoomFeeStr = string.Empty,
  8699. suiteRoomFeeStr = string.Empty,
  8700. otherRoomFeeStr = string.Empty,
  8701. payMoneyStr = string.Empty,
  8702. cardPriceStr = string.Empty;
  8703. if (roomCurr.Equals(_currency))
  8704. {
  8705. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  8706. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  8707. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  8708. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  8709. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  8710. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  8711. }
  8712. else
  8713. {
  8714. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  8715. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  8716. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  8717. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  8718. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  8719. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  8720. }
  8721. string breakfastPriceStr = string.Empty,
  8722. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  8723. governmentRentStr = string.Empty,
  8724. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  8725. cityTaxStrStr = string.Empty,
  8726. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  8727. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  8728. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  8729. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  8730. pcfds.Add(new HotelReservations_PCFD_View()
  8731. {
  8732. City = item.City,
  8733. HotelName = item.HotelName,
  8734. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  8735. // SingleRoomCount = item.SingleRoomCount,
  8736. SingleRoomPrice = singleRoomFeeStr,
  8737. // DoubleRoomCount = item.DoubleRoomCount,
  8738. DoubleRoomPrice = doubleRoomFeeStr,
  8739. //SuiteRoomCount = item.SuiteRoomCount,
  8740. SuiteRoomPrice = suiteRoomFeeStr,
  8741. OtherRoomPrice = otherRoomFeeStr,
  8742. //OtherRoomCount = item.OtherRoomCount,
  8743. BreakfastPrice = breakfastPriceStr,
  8744. GovernmentRent = governmentRentStr,
  8745. CityTax = cityTaxStrStr,
  8746. RoomExplanation = item.RoomExplanation,
  8747. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  8748. PayTime = roomInfo.ConsumptionDate,
  8749. BankNo = roomInfo.BankNo,
  8750. PayMoney = payMoneyStr,
  8751. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  8752. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  8753. CardPrice = cardPriceStr,
  8754. Remark = ccpInfo.Remark
  8755. });
  8756. }
  8757. #endregion
  8758. //载入模板
  8759. WorkbookDesigner designer = new WorkbookDesigner();
  8760. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  8761. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  8762. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  8763. designer.SetDataSource("TourNo", groupInfo.TourCode);
  8764. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  8765. designer.SetDataSource("Opertor", userInfo.CnName);
  8766. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  8767. dt.TableName = "ViewMyHotelReservations";
  8768. designer.SetDataSource(dt);
  8769. designer.Process();
  8770. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  8771. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  8772. designer.Workbook.Save(serverPath);
  8773. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  8774. #region 删除指定行
  8775. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  8776. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  8777. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  8778. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  8779. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  8780. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  8781. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  8782. cssIndex = dt.Columns["CityTax"].Ordinal,
  8783. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  8784. remarkIndex = dt.Columns["Remark"].Ordinal;
  8785. //删除指定列
  8786. foreach (DataRow item in dt.Rows)
  8787. {
  8788. string singleStr = item["SingleRoomPrice"].ToString();
  8789. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  8790. if (containsDigitButNotZero1) singleDel = false;
  8791. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  8792. string doubleStr = item["DoubleRoomPrice"].ToString();
  8793. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8794. if (containsDigitButNotZero2) doubleDel = false;
  8795. string suiteStr = item["SuiteRoomPrice"].ToString();
  8796. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8797. if (containsDigitButNotZero3) suiteDel = false;
  8798. string otherStr = item["OtherRoomPrice"].ToString();
  8799. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  8800. if (containsDigitButNotZero4) otherDel = false;
  8801. string zcStr = item["BreakfastPrice"].ToString();
  8802. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  8803. if (containsDigitButNotZero5) zcDel = false;
  8804. string dsStr = item["GovernmentRent"].ToString();
  8805. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  8806. if (containsDigitButNotZero6) dsDel = false;
  8807. string cssStr = item["CityTax"].ToString();
  8808. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  8809. if (containsDigitButNotZero7) cssDel = false;
  8810. string cpStr = item["ConsumptionPatterns"].ToString();
  8811. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  8812. string remarkStr = item["Remark"].ToString();
  8813. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  8814. }
  8815. DeleteColumn(serverPath, remarkIndex, remarkDel);
  8816. DeleteColumn(serverPath, cpIndex, cpDel);
  8817. DeleteColumn(serverPath, dsIndex, dsDel);
  8818. DeleteColumn(serverPath, cssIndex, cssDel);
  8819. DeleteColumn(serverPath, zcIndex, zcDel);
  8820. DeleteColumn(serverPath, otherIndex, otherDel);
  8821. DeleteColumn(serverPath, suiteIndex, suiteDel);
  8822. DeleteColumn(serverPath, doubleIndex, doubleDel);
  8823. DeleteColumn(serverPath, singleIndex, singleDel);
  8824. #endregion
  8825. //只保留第一个表格
  8826. DeleteSheet(serverPath);
  8827. return Ok(JsonView(true, "操作成功", url = rst));
  8828. }
  8829. /// <summary>
  8830. /// 删除指定列
  8831. /// </summary>
  8832. /// <param name="file"></param>
  8833. /// <param name="columnIndex"></param>
  8834. /// <param name="isDel"></param>
  8835. private void DeleteColumn(string file, int columnIndex, bool isDel)
  8836. {
  8837. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  8838. //wb.Save(file);
  8839. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  8840. if (sheet1 != null)
  8841. {
  8842. if (isDel)
  8843. {
  8844. Cells cells = sheet1.Cells;
  8845. cells.DeleteColumn(columnIndex);
  8846. }
  8847. }
  8848. wb.Save(file);
  8849. }
  8850. /// <summary>
  8851. /// 删除sheet
  8852. /// </summary>
  8853. /// <param name="file"></param>
  8854. /// <param name="sheetName"></param>
  8855. private void DeleteSheet(string file, string sheetName = "")
  8856. {
  8857. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  8858. //wb.Save(file);
  8859. List<string> sheets = new List<string>();
  8860. foreach (var item in wb.Worksheets)
  8861. {
  8862. sheets.Add(item.Name);
  8863. }
  8864. if (sheets.Count > 0)
  8865. {
  8866. sheets.RemoveAt(0);//不删除第一个sheet
  8867. foreach (var item in sheets)
  8868. {
  8869. wb.Worksheets.RemoveAt(item);
  8870. }
  8871. }
  8872. wb.Save(file);
  8873. }
  8874. /// <summary>
  8875. /// 酒店预订
  8876. /// 确认单
  8877. /// </summary>
  8878. /// <param name="_dto"></param>
  8879. /// <returns></returns>
  8880. [HttpPost]
  8881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8882. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  8883. {
  8884. try
  8885. {
  8886. #region 参数验证
  8887. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8888. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8889. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8890. #region 团组操作权限验证 76 酒店预定模块
  8891. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8892. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8893. #endregion
  8894. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8895. #region 页面操作权限验证
  8896. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8897. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8898. #endregion
  8899. #endregion
  8900. //团组信息
  8901. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  8902. //酒店数据
  8903. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  8904. if (listhoteldata.Count < 0)
  8905. {
  8906. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  8907. }
  8908. //利datatable存储
  8909. DataTable dt = new DataTable();
  8910. dt.Columns.Add("CheckInDate", typeof(string));
  8911. dt.Columns.Add("City", typeof(string));
  8912. dt.Columns.Add("Hotel", typeof(string));
  8913. dt.Columns.Add("Room", typeof(string));
  8914. for (int i = 0; i < listhoteldata.Count; i++)
  8915. {
  8916. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  8917. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  8918. while (dayStart < dayEnd)
  8919. {
  8920. string temp = "";
  8921. DataRow row = dt.NewRow();
  8922. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  8923. row["City"] = listhoteldata[i].City;
  8924. row["Hotel"] = listhoteldata[i].HotelName;
  8925. if (listhoteldata[i].SingleRoomCount > 0)
  8926. {
  8927. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  8928. }
  8929. if (listhoteldata[i].DoubleRoomCount > 0)
  8930. {
  8931. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  8932. }
  8933. if (listhoteldata[i].SuiteRoomCount > 0)
  8934. {
  8935. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  8936. }
  8937. if (listhoteldata[i].OtherRoomCount > 0)
  8938. {
  8939. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  8940. }
  8941. row["Room"] = temp;
  8942. dt.Rows.Add(row);
  8943. dayStart = dayStart.AddDays(1);
  8944. }
  8945. }
  8946. Dictionary<string, string> dic = new Dictionary<string, string>();
  8947. dic.Add("Dele", di.TeamName);
  8948. dic.Add("City", di.VisitCountry);
  8949. //模板路径
  8950. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  8951. //载入模板
  8952. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  8953. DocumentBuilder builder = new DocumentBuilder(doc);
  8954. foreach (var key in dic.Keys)
  8955. {
  8956. builder.MoveToBookmark(key);
  8957. builder.Write(dic[key]);
  8958. }
  8959. //获取word里所有表格
  8960. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8961. //获取所填表格的序数
  8962. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8963. var rowStart = tableOne.Rows[0]; //获取第1行
  8964. //循环赋值
  8965. for (int i = 0; i < dt.Rows.Count; i++)
  8966. {
  8967. builder.MoveToCell(0, i + 1, 0, 0);
  8968. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  8969. builder.MoveToCell(0, i + 1, 1, 0);
  8970. builder.Write(dt.Rows[i]["City"].ToString());
  8971. builder.MoveToCell(0, i + 1, 2, 0);
  8972. builder.Write(dt.Rows[i]["Hotel"].ToString());
  8973. builder.MoveToCell(0, i + 1, 3, 0);
  8974. builder.Write(dt.Rows[i]["Room"].ToString());
  8975. }
  8976. //删除多余行
  8977. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  8978. {
  8979. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  8980. }
  8981. string strFileName = di.TeamName + "酒店确认单.doc";
  8982. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  8983. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  8984. return Ok(JsonView(true, "成功", url));
  8985. }
  8986. catch (Exception ex)
  8987. {
  8988. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  8989. }
  8990. }
  8991. #endregion
  8992. #region 团组状态
  8993. /// <summary>
  8994. /// 团组状态列表 Page
  8995. /// </summary>
  8996. /// <param name="dto">团组列表请求dto</param>
  8997. /// <returns></returns>
  8998. [HttpPost]
  8999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9000. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9001. {
  9002. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9003. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9004. {
  9005. string sqlWhere = string.Empty;
  9006. if (dto.IsSure == 0) //未完成
  9007. {
  9008. sqlWhere += string.Format(@" And IsSure = 0");
  9009. }
  9010. else if (dto.IsSure == 1) //已完成
  9011. {
  9012. sqlWhere += string.Format(@" And IsSure = 1");
  9013. }
  9014. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9015. {
  9016. string tj = dto.SearchCriteria;
  9017. 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}%')",
  9018. tj, tj, tj, tj, tj);
  9019. }
  9020. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9021. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9022. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9023. From (
  9024. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9025. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9026. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9027. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9028. From Grp_DelegationInfo gdi
  9029. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9030. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9031. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9032. Where gdi.IsDel = 0 {0}
  9033. ) temp ", sqlWhere);
  9034. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9035. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9036. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9037. }
  9038. else
  9039. {
  9040. return Ok(JsonView(false, "查询失败"));
  9041. }
  9042. }
  9043. /// <summary>
  9044. /// 团组状态
  9045. /// 设置操作完成
  9046. /// </summary>
  9047. /// <param name="dto">团组列表请求dto</param>
  9048. /// <returns></returns>
  9049. [HttpPost]
  9050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9051. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9052. {
  9053. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9054. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9055. {
  9056. Id = dto.Id,
  9057. IsSure = 1
  9058. };
  9059. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9060. .UpdateColumns(it => new { it.IsSure })
  9061. .WhereColumns(it => new { it.Id })
  9062. .ExecuteCommandAsync();
  9063. if (result > 0)
  9064. {
  9065. return Ok(JsonView(true, "操作完成!"));
  9066. }
  9067. return Ok(JsonView(false, "操作失败!"));
  9068. }
  9069. #endregion
  9070. #region 保险费用录入
  9071. /// <summary>
  9072. /// 根据团组Id查询保险费用列表
  9073. /// </summary>
  9074. /// <param name="dto"></param>
  9075. /// <returns></returns>
  9076. [HttpPost]
  9077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9078. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9079. {
  9080. try
  9081. {
  9082. Result groupData = await _customersRep.CustomersByDiId(dto);
  9083. if (groupData.Code != 0)
  9084. {
  9085. return Ok(JsonView(false, groupData.Msg));
  9086. }
  9087. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9088. }
  9089. catch (Exception ex)
  9090. {
  9091. return Ok(JsonView(false, ex.Message));
  9092. }
  9093. }
  9094. /// <summary>
  9095. /// 根据保险费用Id查询保险费用详细
  9096. /// </summary>
  9097. /// <param name="dto"></param>
  9098. /// <returns></returns>
  9099. [HttpPost]
  9100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9101. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9102. {
  9103. try
  9104. {
  9105. Result groupData = await _customersRep.CustomersById(dto);
  9106. if (groupData.Code != 0)
  9107. {
  9108. return Ok(JsonView(false, groupData.Msg));
  9109. }
  9110. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9111. }
  9112. catch (Exception ex)
  9113. {
  9114. return Ok(JsonView(false, ex.Message));
  9115. }
  9116. }
  9117. /// <summary>
  9118. /// 保险费用录入页面初始化绑定
  9119. /// </summary>
  9120. /// <param name="dto"></param>
  9121. /// <returns></returns>
  9122. [HttpPost]
  9123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9124. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9125. {
  9126. try
  9127. {
  9128. Result groupData = await _customersRep.CustomersInitialize(dto);
  9129. if (groupData.Code != 0)
  9130. {
  9131. return Ok(JsonView(false, groupData.Msg));
  9132. }
  9133. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9134. }
  9135. catch (Exception ex)
  9136. {
  9137. return Ok(JsonView(false, ex.Message));
  9138. }
  9139. }
  9140. /// <summary>
  9141. /// 保险费用操作(Status:1.新增,2.修改)
  9142. /// </summary>
  9143. /// <param name="dto"></param>
  9144. /// <returns></returns>
  9145. [HttpPost]
  9146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9147. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9148. {
  9149. try
  9150. {
  9151. Result groupData = await _customersRep.OpCustomers(dto);
  9152. if (groupData.Code != 0)
  9153. {
  9154. return Ok(JsonView(false, groupData.Msg));
  9155. }
  9156. #region 应用推送
  9157. try
  9158. {
  9159. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9160. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9161. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9162. }
  9163. catch (Exception ex)
  9164. {
  9165. }
  9166. #endregion
  9167. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9168. }
  9169. catch (Exception ex)
  9170. {
  9171. return Ok(JsonView(false, ex.Message));
  9172. }
  9173. }
  9174. /// <summary>
  9175. /// 保险文件上传
  9176. /// </summary>
  9177. /// <param name="file"></param>
  9178. /// <returns></returns>
  9179. [HttpPost]
  9180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9181. public async Task<IActionResult> UploadCus(IFormFile file)
  9182. {
  9183. try
  9184. {
  9185. if (file != null)
  9186. {
  9187. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9188. //文件名称
  9189. string projectFileName = file.FileName;
  9190. //上传的文件的路径
  9191. string filePath = "";
  9192. if (!Directory.Exists(fileDir))
  9193. {
  9194. Directory.CreateDirectory(fileDir);
  9195. }
  9196. //上传的文件的路径
  9197. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9198. using (FileStream fs = System.IO.File.Create(filePath))
  9199. {
  9200. file.CopyTo(fs);
  9201. fs.Flush();
  9202. }
  9203. return Ok(JsonView(true, "上传成功!", projectFileName));
  9204. }
  9205. else
  9206. {
  9207. return Ok(JsonView(false, "上传失败!"));
  9208. }
  9209. }
  9210. catch (Exception ex)
  9211. {
  9212. return Ok(JsonView(false, "程序错误!"));
  9213. throw;
  9214. }
  9215. }
  9216. /// <summary>
  9217. /// 保险删除指定文件
  9218. /// </summary>
  9219. /// <param name="dto"></param>
  9220. /// <returns></returns>
  9221. [HttpPost]
  9222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9223. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9224. {
  9225. try
  9226. {
  9227. string filePath = "";
  9228. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9229. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9230. //int id = 0;
  9231. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9232. // 删除该文件
  9233. try
  9234. {
  9235. System.IO.File.Delete(filePath);
  9236. 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()
  9237. {
  9238. Attachment = "",
  9239. }).ExecuteCommandAsync();
  9240. if (result != 0)
  9241. {
  9242. return Ok(JsonView(true, "成功!"));
  9243. }
  9244. else
  9245. {
  9246. return Ok(JsonView(false, "失败!"));
  9247. }
  9248. }
  9249. catch (Exception)
  9250. {
  9251. 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()
  9252. {
  9253. Attachment = "",
  9254. }).ExecuteCommandAsync();
  9255. if (result != 0)
  9256. {
  9257. return Ok(JsonView(true, "成功!"));
  9258. }
  9259. else
  9260. {
  9261. return Ok(JsonView(false, "失败!"));
  9262. }
  9263. }
  9264. }
  9265. catch (Exception ex)
  9266. {
  9267. return Ok(JsonView(false, "程序错误!"));
  9268. throw;
  9269. }
  9270. }
  9271. /// <summary>
  9272. /// 保险费用操作(删除)
  9273. /// </summary>
  9274. /// <param name="dto"></param>
  9275. /// <returns></returns>
  9276. [HttpPost]
  9277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9278. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9279. {
  9280. try
  9281. {
  9282. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9283. if (!res)
  9284. {
  9285. return Ok(JsonView(false, "删除失败"));
  9286. }
  9287. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9288. {
  9289. IsDel = 1,
  9290. DeleteUserId = dto.DeleteUserId,
  9291. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9292. }).ExecuteCommandAsync();
  9293. return Ok(JsonView(true, "删除成功!"));
  9294. }
  9295. catch (Exception ex)
  9296. {
  9297. return Ok(JsonView(false, "程序错误!"));
  9298. throw;
  9299. }
  9300. }
  9301. #endregion
  9302. #region 接团客户名单 PageId 104
  9303. /// <summary>
  9304. /// 接团客户名单
  9305. /// 迁移数据(慎用!)
  9306. /// </summary>
  9307. /// <param name="dto"></param>
  9308. /// <returns></returns>
  9309. [HttpPost]
  9310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9311. public async Task<IActionResult> PostTourClientListChange()
  9312. {
  9313. try
  9314. {
  9315. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9316. //var groupClinetData1
  9317. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9318. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9319. int updateCount = 0;
  9320. if (oldOAClientList.Count > 0)
  9321. {
  9322. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9323. _sqlSugar.BeginTran();
  9324. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9325. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9326. foreach (var item in oldOAClientList)
  9327. {
  9328. int comId = 0;
  9329. string format = "yyyy-MM-dd HH:mm:ss";
  9330. string data11 = "1990-01-01 00:00";
  9331. var data1 = IsValidDate(item.OPdate, format);
  9332. if (data1) data11 = item.OPdate;
  9333. //客户公司验证
  9334. if (!string.IsNullOrEmpty(item.Company))
  9335. {
  9336. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9337. if (clientComInfo == null) // add
  9338. {
  9339. var addInfo = new Crm_CustomerCompany()
  9340. {
  9341. CompanyAbbreviation = "",
  9342. CompanyFullName = item.Company,
  9343. Address = "",
  9344. PostCodes = "",
  9345. LastedOpUserId = item.OPer,
  9346. LastedOpDt = Convert.ToDateTime(data11),
  9347. CreateUserId = item.OPer,
  9348. CreateTime = Convert.ToDateTime(data11),
  9349. IsDel = 0
  9350. };
  9351. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9352. if (comId1 > 0) comId = comId1;
  9353. }
  9354. else comId = clientComInfo.Id;
  9355. }
  9356. //客户人员验证
  9357. int clientId = 0;
  9358. string name = item.LastName + item.Name;
  9359. if (!string.IsNullOrEmpty(name))
  9360. {
  9361. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9362. if (clientInfo == null)
  9363. {
  9364. DateTime? dateTime = null;
  9365. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9366. if (isDt) dateTime = birthDayDt;
  9367. var addInfo1 = new Crm_DeleClient()
  9368. {
  9369. CrmCompanyId = comId,
  9370. DiId = -1,
  9371. LastName = item.LastName,
  9372. FirstName = item.Name,
  9373. OldName = "",
  9374. Pinyin = item.Pinyin,
  9375. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9376. Marriage = 0,
  9377. Phone = item.Phone,
  9378. Job = item.Job,
  9379. BirthDay = dateTime
  9380. };
  9381. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9382. if (clientId1 > 0) clientId = clientId1;
  9383. }
  9384. else clientId = clientInfo.Id;
  9385. }
  9386. if (clientId < 1)
  9387. {
  9388. continue;
  9389. }
  9390. int airType = 0;
  9391. if (item.AirType == "超经舱") airType = 459;
  9392. else if (item.AirType == "公务舱") airType = 458;
  9393. else if (item.AirType == "经济舱") airType = 460;
  9394. else if (item.AirType == "其他") airType = 565;
  9395. else if (item.AirType == "头等舱") airType = 457;
  9396. var _TourClientListEntity = new Grp_TourClientList()
  9397. {
  9398. DiId = item.Diid,
  9399. ClientId = clientId,
  9400. CreateUserId = item.OPer,
  9401. CreateTime = Convert.ToDateTime(data11),
  9402. Remark = item.Remark,
  9403. IsDel = item.Isdel,
  9404. ShippingSpaceTypeId = airType,
  9405. ShippingSpaceSpecialNeeds = item.AirRemark,
  9406. HotelSpecialNeeds = item.RoomType
  9407. };
  9408. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9409. if (_TourClientList > 0)
  9410. {
  9411. updateCount++;
  9412. }
  9413. }
  9414. _sqlSugar.CommitTran();
  9415. }
  9416. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9417. }
  9418. catch (Exception ex)
  9419. {
  9420. _sqlSugar.RollbackTran();
  9421. return Ok(JsonView(false, ex.Message));
  9422. }
  9423. return Ok(JsonView(true));
  9424. }
  9425. private bool IsValidDate(string dateString, string format)
  9426. {
  9427. DateTime dateValue;
  9428. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9429. return valid;
  9430. }
  9431. /// <summary>
  9432. /// 接团客户名单
  9433. /// 根据团组Id查询List
  9434. /// </summary>
  9435. /// <param name="dto"></param>
  9436. /// <returns></returns>
  9437. [HttpPost]
  9438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9439. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  9440. {
  9441. #region 参数验证
  9442. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  9443. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9444. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  9445. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9446. #region 页面操作权限验证
  9447. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9448. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9449. #endregion
  9450. #endregion
  9451. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  9452. if (viewData.Code != 0)
  9453. {
  9454. return Ok(JsonView(false, viewData.Msg));
  9455. }
  9456. return Ok(JsonView(viewData.Data));
  9457. }
  9458. /// <summary>
  9459. /// 接团客户名单
  9460. /// 基础数据 Init
  9461. /// </summary>
  9462. /// <param name="_dto"></param>
  9463. /// <returns></returns>
  9464. [HttpPost]
  9465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9466. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  9467. {
  9468. #region 参数验证
  9469. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9470. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9471. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9472. #region 页面操作权限验证
  9473. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9474. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9475. #endregion
  9476. #endregion
  9477. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  9478. if (viewData.Code != 0)
  9479. {
  9480. return Ok(JsonView(false, viewData.Msg));
  9481. }
  9482. return Ok(JsonView(viewData.Data));
  9483. }
  9484. /// <summary>
  9485. /// 接团客户名单
  9486. /// 根据 Id查询 Details
  9487. /// </summary>
  9488. /// <param name="_dto"></param>
  9489. /// <returns></returns>
  9490. [HttpPost]
  9491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9492. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  9493. {
  9494. #region 参数验证
  9495. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9496. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9497. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9498. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9499. #region 页面操作权限验证
  9500. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9501. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9502. #endregion
  9503. #endregion
  9504. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  9505. if (viewData.Code != 0)
  9506. {
  9507. return Ok(JsonView(false, viewData.Msg));
  9508. }
  9509. return Ok(JsonView(viewData.Data));
  9510. }
  9511. /// <summary>
  9512. /// 接团客户名单
  9513. /// Add Or Edit
  9514. /// </summary>
  9515. /// <param name="_dto"></param>
  9516. /// <returns></returns>
  9517. [HttpPost]
  9518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9519. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  9520. {
  9521. #region 参数验证
  9522. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9523. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9524. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9525. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9526. #region 页面操作权限验证
  9527. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9528. if (_dto.Id == 0) //添加
  9529. {
  9530. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9531. }
  9532. else if (_dto.Id >= 0) //修改
  9533. {
  9534. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9535. }
  9536. #endregion
  9537. #endregion
  9538. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  9539. if (viewData.Code != 0)
  9540. {
  9541. return Ok(JsonView(false, viewData.Msg));
  9542. }
  9543. return Ok(JsonView(true));
  9544. }
  9545. /// <summary>
  9546. /// 接团客户名单
  9547. /// AddMultiple(添加多个)
  9548. /// </summary>
  9549. /// <param name="_dto"></param>
  9550. /// <returns></returns>
  9551. [HttpPost]
  9552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9553. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  9554. {
  9555. #region 参数验证
  9556. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9557. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9558. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9559. #region 页面操作权限验证
  9560. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9561. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9562. #endregion
  9563. #endregion
  9564. var viewData = await _tourClientListRep._AddMultiple(_dto);
  9565. if (viewData.Code != 0)
  9566. {
  9567. return Ok(JsonView(false, viewData.Msg));
  9568. }
  9569. return Ok(JsonView(true));
  9570. }
  9571. /// <summary>
  9572. /// 接团客户名单
  9573. /// Del
  9574. /// </summary>
  9575. /// <param name="_dto"></param>
  9576. /// <returns></returns>
  9577. [HttpPost]
  9578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9579. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  9580. {
  9581. #region 参数验证
  9582. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9583. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9584. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9585. #region 页面操作权限验证
  9586. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9587. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9588. #endregion
  9589. #endregion
  9590. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  9591. if (viewData.Code != 0)
  9592. {
  9593. return Ok(JsonView(false, viewData.Msg));
  9594. }
  9595. return Ok(JsonView(true));
  9596. }
  9597. /// <summary>
  9598. /// 接团客户名单
  9599. /// 文件下载 客户名单
  9600. /// </summary>
  9601. /// <param name="_dto"></param>
  9602. /// <returns></returns>
  9603. [HttpPost]
  9604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9605. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  9606. {
  9607. #region 参数验证
  9608. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9609. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9610. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  9611. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9612. #region 页面操作权限验证
  9613. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9614. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9615. #endregion
  9616. #endregion
  9617. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  9618. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  9619. From Grp_TourClientList tcl
  9620. Left Join
  9621. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  9622. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  9623. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  9624. From Crm_DeleClient dc
  9625. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  9626. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  9627. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  9628. Where dc.IsDel = 0) temp
  9629. On temp.DcId =tcl.ClientId
  9630. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  9631. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  9632. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  9633. //载入模板
  9634. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  9635. if (_dto.Language == 1)
  9636. {
  9637. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  9638. }
  9639. //载入模板
  9640. var doc = new Document(tempPath);
  9641. DocumentBuilder builder = new DocumentBuilder(doc);
  9642. //获取word里所有表格
  9643. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9644. //获取所填表格的序数
  9645. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9646. var rowStart = tableOne.Rows[0]; //获取第1行
  9647. if (_dto.Language == 0)
  9648. {
  9649. //循环赋值
  9650. for (int i = 0; i < DcList.Count; i++)
  9651. {
  9652. builder.MoveToCell(0, i + 1, 0, 0);
  9653. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  9654. builder.MoveToCell(0, i + 1, 1, 0);
  9655. int sex = DcList[i].Sex;
  9656. string sexStr = string.Empty;
  9657. if (sex == 0) sexStr = "男";
  9658. else if (sex == 1) sexStr = "女";
  9659. else sexStr = "未设置";
  9660. builder.Write(sexStr);
  9661. builder.MoveToCell(0, i + 1, 2, 0);
  9662. string birthDay = DcList[i].BirthDay;
  9663. string birthDayStr = string.Empty;
  9664. if (!string.IsNullOrEmpty(birthDay))
  9665. {
  9666. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  9667. }
  9668. builder.Write(birthDayStr);
  9669. builder.MoveToCell(0, i + 1, 3, 0);
  9670. string company = "";
  9671. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9672. {
  9673. company = DcList[i].CompanyFullName.ToString();
  9674. }
  9675. builder.Write(company);
  9676. builder.MoveToCell(0, i + 1, 4, 0);
  9677. builder.Write(DcList[i].Job);
  9678. }
  9679. }
  9680. else if (_dto.Language == 1)
  9681. {
  9682. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  9683. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  9684. //循环赋值
  9685. for (int i = 0; i < DcList.Count; i++)
  9686. {
  9687. string PYName = "";
  9688. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  9689. {
  9690. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  9691. string PY_First = DcList[i].Pinyin.Split('/')[1];
  9692. PYName = PY_First + " " + PY_Last;
  9693. }
  9694. else
  9695. {
  9696. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  9697. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  9698. PYName = PY_First + " " + PY_Last;
  9699. }
  9700. builder.MoveToCell(0, i + 1, 0, 0);
  9701. builder.Write(PYName);
  9702. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  9703. builder.MoveToCell(0, i + 1, 1, 0);
  9704. builder.Write(sex);
  9705. DateTime birthDt;
  9706. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  9707. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  9708. builder.MoveToCell(0, i + 1, 2, 0);
  9709. builder.Write(birthday);
  9710. string company = "";
  9711. try
  9712. {
  9713. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9714. {
  9715. //查询对照表
  9716. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  9717. if (tempCec != null)
  9718. {
  9719. company = tempCec.enName;
  9720. }
  9721. //翻译
  9722. else
  9723. {
  9724. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  9725. }
  9726. }
  9727. }
  9728. catch (Exception)
  9729. {
  9730. }
  9731. builder.MoveToCell(0, i + 1, 3, 0);
  9732. builder.Write(company);
  9733. string job = "";
  9734. try
  9735. {
  9736. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  9737. {
  9738. //查询对照表
  9739. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  9740. if (tempPec != null)
  9741. {
  9742. job = tempPec.enName;
  9743. }
  9744. //翻译
  9745. else
  9746. {
  9747. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  9748. }
  9749. }
  9750. }
  9751. catch (Exception ex)
  9752. {
  9753. }
  9754. builder.MoveToCell(0, i + 1, 4, 0);
  9755. builder.Write(job);
  9756. }
  9757. }
  9758. //删除多余行
  9759. while (tableOne.Rows.Count > DcList.Count + 1)
  9760. {
  9761. tableOne.Rows.RemoveAt(DcList.Count + 1);
  9762. }
  9763. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  9764. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  9765. doc.Save(fileDir);
  9766. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  9767. return Ok(JsonView(true, "操作成功!", Url));
  9768. }
  9769. #endregion
  9770. #region 团组倒推表
  9771. /// <summary>
  9772. /// 倒推表基础数据
  9773. /// Init
  9774. /// </summary>
  9775. /// <param name="dto"></param>
  9776. /// <returns></returns>
  9777. [HttpPost]
  9778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9779. public async Task<IActionResult> PostInvertedListInit()
  9780. {
  9781. var viewData = await _invertedListRep._Init();
  9782. if (viewData.Code != 0)
  9783. {
  9784. return Ok(JsonView(false, viewData.Msg));
  9785. }
  9786. return Ok(JsonView(viewData.Data));
  9787. }
  9788. /// <summary>
  9789. /// 倒推表
  9790. /// Info
  9791. /// </summary>
  9792. /// <param name="dto"></param>
  9793. /// <returns></returns>
  9794. [HttpPost]
  9795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9796. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  9797. {
  9798. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  9799. if (viewData.Code != 0)
  9800. {
  9801. return Ok(JsonView(false, viewData.Msg));
  9802. }
  9803. return Ok(JsonView(viewData.Data));
  9804. }
  9805. /// <summary>
  9806. /// 倒推表
  9807. /// Create
  9808. /// </summary>
  9809. /// <param name="dto"></param>
  9810. /// <returns></returns>
  9811. [HttpPost]
  9812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9813. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  9814. {
  9815. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  9816. if (viewData.Code != 0)
  9817. {
  9818. return Ok(JsonView(false, viewData.Msg));
  9819. }
  9820. return Ok(JsonView(viewData.Data));
  9821. }
  9822. /// <summary>
  9823. /// 倒推表
  9824. /// Update
  9825. /// </summary>
  9826. /// <param name="dto"></param>
  9827. /// <returns></returns>
  9828. [HttpPost]
  9829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9830. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  9831. {
  9832. var viewData = await _invertedListRep._Update(dto);
  9833. if (viewData.Code != 0)
  9834. {
  9835. return Ok(JsonView(false, viewData.Msg));
  9836. }
  9837. return Ok(JsonView(viewData.Data));
  9838. }
  9839. /// <summary>
  9840. /// 倒推表
  9841. /// File Download
  9842. /// </summary>
  9843. /// <param name="dto"></param>
  9844. /// <returns></returns>
  9845. [HttpPost]
  9846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9847. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  9848. {
  9849. var info2 = await _invertedListRep._Info(1, dto.DiId);
  9850. if (info2.Code != 0)
  9851. {
  9852. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  9853. }
  9854. var info1 = info2.Data as InvertedListInfoView;
  9855. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  9856. string teamName = "";
  9857. if (info != null) teamName = info.TeamName;
  9858. //载入模板
  9859. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  9860. DocumentBuilder builder = new DocumentBuilder(doc);
  9861. //利用键值对存放数据
  9862. Dictionary<string, string> dic = new Dictionary<string, string>();
  9863. dic.Add("TeamName", teamName);
  9864. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  9865. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  9866. dic.Add("BPRemark", info1.ApprovalDataRemark);
  9867. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  9868. dic.Add("SQRemark", info1.ApprovalRemark);
  9869. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  9870. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  9871. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  9872. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  9873. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  9874. dic.Add("QZRemark", info1.VisaInformationRemark);
  9875. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  9876. dic.Add("SQQZRemark", info1.SendVisaRemark);
  9877. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  9878. dic.Add("CQRemark", info1.IssueVisaRemark);
  9879. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  9880. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  9881. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  9882. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  9883. #region 填充word模板书签内容
  9884. foreach (var key in dic.Keys)
  9885. {
  9886. builder.MoveToBookmark(key);
  9887. builder.Write(dic[key]);
  9888. }
  9889. #endregion
  9890. var fileDir = AppSettingsHelper.Get("WordBasePath");
  9891. string fileName = $"{teamName}团出行准备流程表.doc";
  9892. string filePath = fileDir + $@"InvertedList/{fileName}";
  9893. doc.Save(filePath);
  9894. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  9895. return Ok(JsonView(true, "操作成功!", Url));
  9896. }
  9897. #endregion
  9898. #region 三公签证费用(签证费、代办费)
  9899. /// <summary>
  9900. /// 三公签证费用(签证费、代办费)
  9901. /// List
  9902. /// </summary>
  9903. /// <returns></returns>
  9904. [HttpPost]
  9905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9906. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  9907. {
  9908. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  9909. if (_view.Code != 0)
  9910. {
  9911. return Ok(JsonView(false, _view.Msg));
  9912. }
  9913. return Ok(JsonView(true, "操作成功!", _view.Data));
  9914. }
  9915. /// <summary>
  9916. /// 三公签证费用(签证费、代办费)
  9917. /// Add Or Update
  9918. /// </summary>
  9919. /// <returns></returns>
  9920. [HttpPost]
  9921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9922. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  9923. {
  9924. var _view = await _visaFeeInfoRep._Update(_dto);
  9925. if (_view.Code != 0)
  9926. {
  9927. return Ok(JsonView(false, _view.Msg));
  9928. }
  9929. return Ok(JsonView(true, _view.Msg));
  9930. }
  9931. #endregion
  9932. #region 酒店询价
  9933. /// <summary>
  9934. /// 酒店询价
  9935. /// Init
  9936. /// </summary>
  9937. /// <param name="dto"></param>
  9938. /// <returns></returns>
  9939. [HttpPost]
  9940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9941. public async Task<IActionResult> PostHotelInquiryInit()
  9942. {
  9943. var res = await _hotelInquiryRep._Init();
  9944. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9945. return Ok(JsonView(true, res.Msg, res.Data));
  9946. }
  9947. /// <summary>
  9948. /// 酒店询价
  9949. /// page Item
  9950. /// </summary>
  9951. /// <param name="_dto"></param>
  9952. /// <returns></returns>
  9953. [HttpPost]
  9954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9955. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  9956. {
  9957. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  9958. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9959. var view = res.Data as PageDataViewBase;
  9960. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  9961. }
  9962. /// <summary>
  9963. /// 酒店询价
  9964. /// info
  9965. /// </summary>
  9966. /// <param name="_dto"></param>
  9967. /// <returns></returns>
  9968. [HttpPost]
  9969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9970. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  9971. {
  9972. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  9973. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9974. return Ok(JsonView(true, res.Msg, res.Data));
  9975. }
  9976. /// <summary>
  9977. /// 酒店询价
  9978. /// Add Or Edit
  9979. /// </summary>
  9980. /// <param name="_dto"></param>
  9981. /// <returns></returns>
  9982. [HttpPost]
  9983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9984. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  9985. {
  9986. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  9987. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9988. return Ok(JsonView(true, res.Msg, res.Data));
  9989. }
  9990. /// <summary>
  9991. /// 酒店询价
  9992. /// Del
  9993. /// </summary>
  9994. /// <param name="_dto"></param>
  9995. /// <returns></returns>
  9996. [HttpPost]
  9997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9998. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  9999. {
  10000. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10001. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10002. return Ok(JsonView(true, res.Msg, res.Data));
  10003. }
  10004. #endregion
  10005. #region 下载匹配op行程单
  10006. /// <summary>
  10007. /// 匹配op行程单
  10008. /// Init
  10009. /// </summary>
  10010. /// <param name="dto">团组列表请求dto</param>
  10011. /// <returns></returns>
  10012. [HttpPost]
  10013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10014. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10015. {
  10016. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10017. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10018. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10019. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10020. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  10021. .Where(it => it.IsDel == 0)
  10022. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  10023. .OrderByDescending(it => it.CreateUserId)
  10024. .ToList();
  10025. if (groupInfos.Count < 1) return Ok(JsonView(false,"暂无和你相关的团组信息!"));
  10026. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10027. var diids = groupInfos.Select(it => it.Id).ToList();
  10028. List<string> countrys = new List<string>();
  10029. foreach (var item in country)
  10030. {
  10031. var data = _groupRepository.FormartTeamName(item);
  10032. var dataArray = _groupRepository.GroupSplitCountry(data);
  10033. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10034. }
  10035. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  10036. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10037. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  10038. foreach (var item in areaItem)
  10039. {
  10040. string areaStr = item.Value;
  10041. if (!string.IsNullOrEmpty(areaStr))
  10042. {
  10043. string[] str1 = areaStr.Split("-");
  10044. if (str1.Length > 0)
  10045. {
  10046. areaArray.AddRange(str1);
  10047. }
  10048. }
  10049. }
  10050. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10051. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  10052. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  10053. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  10054. .ToList();
  10055. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  10056. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  10057. .Where(it => countriesIds.Contains(it.Id))
  10058. .Select(it => new { it.Id, Name = it.Name_CN })
  10059. .ToList();
  10060. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName) )
  10061. .Select(it => it.TeamName).ToList();
  10062. stopwatch.Stop();
  10063. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames,countriesDatas, citiesDatas = cityDatas }));
  10064. }
  10065. ///// <summary>
  10066. ///// 匹配op行程单
  10067. ///// Init 查询区域数据
  10068. ///// </summary>
  10069. ///// <param name="dto">团组列表请求dto</param>
  10070. ///// <returns></returns>
  10071. //[HttpPost]
  10072. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10073. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10074. //{
  10075. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10076. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10077. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10078. // if (string.IsNullOrEmpty(countriesDataStr))
  10079. // {
  10080. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10081. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10082. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10083. // }
  10084. // else
  10085. // {
  10086. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10087. // }
  10088. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10089. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10090. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10091. // List<dynamic> childList = new List<dynamic>();
  10092. // int parentId = dto.CountriesId;
  10093. // if (provinceData.Count > 1)
  10094. // {
  10095. // foreach (var item1 in provinceData)
  10096. // {
  10097. // List<dynamic> childList1 = new List<dynamic>();
  10098. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10099. // foreach (var item2 in citiesData1)
  10100. // {
  10101. // List<dynamic> childList2 = new List<dynamic>();
  10102. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10103. // foreach (var item3 in countiesData1)
  10104. // {
  10105. // childList2.Add(new
  10106. // {
  10107. // id = item3.Id,
  10108. // parentId = item2.Id,
  10109. // level = "district",
  10110. // name = item3.Name_CN,
  10111. // });
  10112. // }
  10113. // childList1.Add(new
  10114. // {
  10115. // id = item2.Id,
  10116. // parentId = item1.Id,
  10117. // level = "city",
  10118. // name = item2.Name_CN,
  10119. // childList = childList2
  10120. // });
  10121. // }
  10122. // childList.Add(new
  10123. // {
  10124. // id = item1.Id,
  10125. // parentId = parentId,
  10126. // level = "province",
  10127. // name = item1.Name_CN,
  10128. // childList = childList1
  10129. // });
  10130. // }
  10131. // //城市
  10132. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10133. // foreach (var item2 in citiesData2)
  10134. // {
  10135. // List<dynamic> childList22 = new List<dynamic>();
  10136. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10137. // foreach (var item3 in countiesData1)
  10138. // {
  10139. // childList22.Add(new
  10140. // {
  10141. // id = item3.Id,
  10142. // parentId = item2.Id,
  10143. // level = "district",
  10144. // name = item3.Name_CN,
  10145. // });
  10146. // }
  10147. // childList.Add(new
  10148. // {
  10149. // id = item2.Id,
  10150. // parentId = parentId,
  10151. // level = "city",
  10152. // name = item2.Name_CN,
  10153. // childList = childList22
  10154. // });
  10155. // }
  10156. // }
  10157. // else
  10158. // {
  10159. // foreach (var item2 in citiesData)
  10160. // {
  10161. // string cname = item2.Name_CN;
  10162. // List<dynamic> childList1 = new List<dynamic>();
  10163. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10164. // foreach (var item3 in countiesData1)
  10165. // {
  10166. // childList1.Add(new
  10167. // {
  10168. // Id = item3.Id,
  10169. // parentId = item2.Id,
  10170. // level = "district",
  10171. // name = item3.Name_CN
  10172. // });
  10173. // }
  10174. // childList.Add(new
  10175. // {
  10176. // id = item2.Id,
  10177. // parentId = parentId,
  10178. // level = "city",
  10179. // name = item2.Name_CN,
  10180. // childList = childList1
  10181. // });
  10182. // }
  10183. // }
  10184. // stopwatch.Stop();
  10185. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10186. //}
  10187. /// <summary>
  10188. /// 匹配op行程单
  10189. /// 接团信息列表 Page
  10190. /// </summary>
  10191. /// <param name="dto">团组列表请求dto</param>
  10192. /// <returns></returns>
  10193. [HttpPost]
  10194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10195. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10196. {
  10197. var swatch = new Stopwatch();
  10198. swatch.Start();
  10199. #region 参数验证
  10200. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10201. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10202. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10203. #region 页面操作权限验证
  10204. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10205. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10206. #endregion
  10207. #endregion
  10208. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10209. {
  10210. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10211. string sqlWhere = "";
  10212. if (!string.IsNullOrEmpty(dto.Country))
  10213. {
  10214. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  10215. }
  10216. if (!string.IsNullOrEmpty(dto.Area))
  10217. {
  10218. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  10219. }
  10220. if (!string.IsNullOrEmpty(dto.TeamName))
  10221. {
  10222. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  10223. }
  10224. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  10225. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  10226. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  10227. swatch.Stop();
  10228. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  10229. }
  10230. else
  10231. {
  10232. return Ok(JsonView(false, "查询失败"));
  10233. }
  10234. }
  10235. /// <summary>
  10236. /// 匹配op行程单
  10237. /// 行程单下载
  10238. /// </summary>
  10239. /// <param name="dto">团组列表请求dto</param>
  10240. /// <returns></returns>
  10241. [HttpPost]
  10242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10243. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10244. {
  10245. #region 参数验证
  10246. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10247. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10248. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10249. #region 页面操作权限验证
  10250. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10251. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10252. #endregion
  10253. #endregion
  10254. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10255. {
  10256. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  10257. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10258. }
  10259. else
  10260. {
  10261. return Ok(JsonView(false, "下载失败!"));
  10262. }
  10263. }
  10264. #endregion
  10265. #region 国家信息 数据 注释
  10266. //[HttpPost]
  10267. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10268. //{
  10269. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10270. // foreach (var item in dto)
  10271. // {
  10272. // infos.Add(new Grp_GroupsTaskAssignment()
  10273. // {
  10274. // DIId = item,
  10275. // CTId = 82,
  10276. // UId = 248,
  10277. // IsEnable = 1,
  10278. // CreateUserId = 233,
  10279. // CreateTime = DateTime.Now,
  10280. // IsDel = 0
  10281. // });
  10282. // infos.Add(new Grp_GroupsTaskAssignment()
  10283. // {
  10284. // DIId = item,
  10285. // CTId = 82,
  10286. // UId = 286,
  10287. // IsEnable = 1,
  10288. // CreateUserId = 233,
  10289. // CreateTime = DateTime.Now,
  10290. // IsDel = 0
  10291. // });
  10292. // }
  10293. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10294. // return Ok("操作成功");
  10295. //}
  10296. //public class paramJsonDto
  10297. //{
  10298. // public List<CountriesInfo> str { get; set; }
  10299. //}
  10300. //[HttpPost]
  10301. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  10302. //{
  10303. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  10304. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  10305. // List<Sys_Cities> cities = new List<Sys_Cities>();
  10306. // List<Sys_Cities> districts = new List<Sys_Cities>();
  10307. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10308. // _sqlSugar.BeginTran();
  10309. // int countitiesIndex = 0;
  10310. // foreach (var item in dto.str)
  10311. // {
  10312. // dynamic data = item.c;
  10313. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  10314. // if (data != null)
  10315. // {
  10316. // countitiesIndex++;
  10317. // foreach (var item1 in data)
  10318. // {
  10319. // string cnname = item1.cn;
  10320. // string enname = item1.en;
  10321. // Sys_Cities provinceInfo = new Sys_Cities()
  10322. // {
  10323. // CountriesId = countriesId,
  10324. // Name_CN = cnname,
  10325. // Name_EN = enname,
  10326. // ParentId = 0,
  10327. // IsCapital = 1,
  10328. // CreateUserId = 208,
  10329. // CreateTime = DateTime.Now,
  10330. // IsDel = 0
  10331. // };
  10332. // if (item1.lv == "province") //省份
  10333. // {
  10334. // provinceInfo.Level = 1;
  10335. // int provinceId = 0;
  10336. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  10337. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  10338. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10339. // var data1 = item1.c;
  10340. // foreach (var item2 in data1)
  10341. // {
  10342. // if (item2.lv == "city")
  10343. // {
  10344. // string citycnname = item2.cn;
  10345. // string cityenname = item2.en;
  10346. // Sys_Cities cityInfo = new Sys_Cities()
  10347. // {
  10348. // CountriesId = countriesId,
  10349. // ParentId = provinceId,
  10350. // Level = 2,
  10351. // Name_CN = citycnname,
  10352. // Name_EN = cityenname,
  10353. // IsCapital = 1,
  10354. // CreateUserId = 208,
  10355. // CreateTime = DateTime.Now,
  10356. // IsDel = 0
  10357. // };
  10358. // if (item2.c != null)
  10359. // {
  10360. // int cityId = 0;
  10361. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  10362. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10363. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  10364. // foreach (var item3 in item2.c)
  10365. // {
  10366. // if (item3.lv == "district")
  10367. // {
  10368. // var districtInfo = new Sys_Cities()
  10369. // {
  10370. // CountriesId = countriesId,
  10371. // Name_CN = item3.cn,
  10372. // Name_EN = item3.en,
  10373. // Level = 3,
  10374. // ParentId = cityId,
  10375. // IsCapital = 1,
  10376. // CreateUserId = 208,
  10377. // CreateTime = DateTime.Now,
  10378. // IsDel = 0
  10379. // };
  10380. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10381. // //{
  10382. // districts.Add(districtInfo);
  10383. // //}
  10384. // }
  10385. // }
  10386. // }
  10387. // else
  10388. // {
  10389. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  10390. // //{
  10391. // cities.Add(cityInfo);
  10392. // //}
  10393. // }
  10394. // }
  10395. // }
  10396. // }
  10397. // else if (item1.lv == "city")//城市
  10398. // {
  10399. // provinceInfo.Level = 2;
  10400. // if (item1.c != null)
  10401. // {
  10402. // int cityId = 0;
  10403. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  10404. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10405. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10406. // foreach (var item3 in item1.c)
  10407. // {
  10408. // if (item3.lv == "district")
  10409. // {
  10410. // var districtInfo = new Sys_Cities()
  10411. // {
  10412. // CountriesId = countriesId,
  10413. // Name_CN = item3.cn,
  10414. // Name_EN = item3.en,
  10415. // Level = 3,
  10416. // ParentId = cityId,
  10417. // IsCapital = 1,
  10418. // CreateUserId = 208,
  10419. // CreateTime = DateTime.Now,
  10420. // IsDel = 0
  10421. // };
  10422. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10423. // //{
  10424. // districts.Add(districtInfo);
  10425. // //}
  10426. // }
  10427. // }
  10428. // }
  10429. // else
  10430. // {
  10431. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  10432. // //{
  10433. // cities.Add(provinceInfo);
  10434. // //}
  10435. // }
  10436. // }
  10437. // }
  10438. // }
  10439. // }
  10440. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  10441. // cities = cities.Distinct().ToList();
  10442. // districts = districts.Distinct().ToList();
  10443. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  10444. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  10445. // cities.AddRange(districts);
  10446. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  10447. // //_sqlSugar.RollbackTran();
  10448. // _sqlSugar.CommitTran();
  10449. // return Ok(JsonView(false, "操作成功!"));
  10450. //}
  10451. //[HttpPost]
  10452. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  10453. //{
  10454. // List<CountitiesInfo> infos = dto.MyProperty;
  10455. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  10456. // _sqlSugar.BeginTran();
  10457. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10458. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  10459. // foreach (var item in infos)
  10460. // {
  10461. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  10462. // if (countryInfo != null)
  10463. // {
  10464. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  10465. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  10466. // if (cityInfo1 != null)
  10467. // {
  10468. // cityInfo1.IsCapital = 0;
  10469. // cityInfos.Add(cityInfo1);
  10470. // }
  10471. // }
  10472. // }
  10473. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  10474. // .UpdateColumns(it => it.IsCapital)
  10475. // .WhereColumns(it => it.Id)
  10476. // .ExecuteCommand();
  10477. // //_sqlSugar.RollbackTran();
  10478. // _sqlSugar.CommitTran();
  10479. // return Ok(JsonView(false, "操作成功!"));
  10480. //}
  10481. //public class CounrtiesDto
  10482. //{
  10483. // public List<CountitiesInfo> MyProperty { get; set; }
  10484. //}
  10485. //public class CountitiesInfo
  10486. //{
  10487. // /// <summary>
  10488. // /// 圣约翰
  10489. // /// </summary>
  10490. // public string capital_name_chinese { get; set; }
  10491. // /// <summary>
  10492. // ///
  10493. // /// </summary>
  10494. // public string capital_name { get; set; }
  10495. // /// <summary>
  10496. // ///
  10497. // /// </summary>
  10498. // public string country_type { get; set; }
  10499. // /// <summary>
  10500. // /// 安提瓜和巴布达
  10501. // /// </summary>
  10502. // public string country_name_chinese { get; set; }
  10503. // /// <summary>
  10504. // /// 安提瓜和巴布达
  10505. // /// </summary>
  10506. // public string country_name_chinese_short { get; set; }
  10507. // /// <summary>
  10508. // /// 安提瓜和巴布达
  10509. // /// </summary>
  10510. // public string country_name_chinese_UN { get; set; }
  10511. // /// <summary>
  10512. // ///
  10513. // /// </summary>
  10514. // public string country_name_english_abbreviation { get; set; }
  10515. // /// <summary>
  10516. // ///
  10517. // /// </summary>
  10518. // public string country_name_english_formal { get; set; }
  10519. // /// <summary>
  10520. // ///
  10521. // /// </summary>
  10522. // public string country_name_english_UN { get; set; }
  10523. // /// <summary>
  10524. // ///
  10525. // /// </summary>
  10526. // public string continent_name { get; set; }
  10527. // /// <summary>
  10528. // ///
  10529. // /// </summary>
  10530. // public string subregion_name { get; set; }
  10531. // /// <summary>
  10532. // ///
  10533. // /// </summary>
  10534. // public string country_code2 { get; set; }
  10535. // /// <summary>
  10536. // ///
  10537. // /// </summary>
  10538. // public string country_code3 { get; set; }
  10539. // /// <summary>
  10540. // ///
  10541. // /// </summary>
  10542. // public string phone_code { get; set; }
  10543. //}
  10544. //public class CountriesInfo : BasicInfo
  10545. //{
  10546. // public List<CitiesInfo> c { get; set; }
  10547. //}
  10548. //public class CitiesInfo : BasicInfo
  10549. //{
  10550. // public List<AreaInfo> c { get; set; }
  10551. //}
  10552. //public class AreaInfo : BasicInfo
  10553. //{
  10554. // public List<AreaInfo> c { get; set; }
  10555. //}
  10556. //public class BasicInfo
  10557. //{
  10558. // public string code { get; set; }
  10559. // public string cn { get; set; }
  10560. // public string lv { get; set; }
  10561. // public string en { get; set; }
  10562. //}
  10563. #endregion
  10564. #region 查看邀请方
  10565. /// <summary>
  10566. /// 查看邀请方
  10567. /// 邀请方信息 Init
  10568. /// </summary>
  10569. /// <param name="dto"></param>
  10570. /// <returns></returns>
  10571. [HttpPost]
  10572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10573. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  10574. {
  10575. string sqlWhere = string.Empty;
  10576. if (!string.IsNullOrEmpty(dto.Search))
  10577. {
  10578. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  10579. }
  10580. string sql = string.Format($@"Select
  10581. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  10582. Id,
  10583. UnitName
  10584. From Res_InvitationOfficialActivityData
  10585. Where IsDel = 0
  10586. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  10587. RefAsync<int> total = 0;
  10588. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10589. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  10590. }
  10591. /// <summary>
  10592. /// 查看邀请方
  10593. /// 国家信息 Init
  10594. /// </summary>
  10595. /// <param name="dto"></param>
  10596. /// <returns></returns>
  10597. [HttpPost]
  10598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10599. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  10600. {
  10601. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  10602. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10603. var diids = groupInfos.Select(it => it.Id).ToList();
  10604. List<string> countrys = new List<string>();
  10605. foreach (var item in country)
  10606. {
  10607. var data = _groupRepository.FormartTeamName(item);
  10608. var dataArray = _groupRepository.GroupSplitCountry(data);
  10609. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10610. }
  10611. countrys = countrys.Distinct().ToList();
  10612. for (int i = 0; i < countrys.Count; i++)
  10613. {
  10614. string item = countrys[i];
  10615. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  10616. {
  10617. countrys.Remove(item);
  10618. i--;
  10619. }
  10620. }
  10621. RefAsync<int> total = 0;
  10622. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  10623. .Where(it => countrys.Contains(it.Name_CN))
  10624. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10625. .Select(it => new { id = it.Id, name = it.Name_CN })
  10626. .ToPageListAsync(dto.PageIndex,dto.PageSize, total);
  10627. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10628. }
  10629. /// <summary>
  10630. /// 查看邀请方
  10631. /// 城市信息 Init
  10632. /// </summary>
  10633. /// <param name="dto"></param>
  10634. /// <returns></returns>
  10635. [HttpPost]
  10636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10637. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  10638. {
  10639. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  10640. RefAsync<int> total = 0;
  10641. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  10642. .Where(it => it.CountriesId == dto.CountiesId)
  10643. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10644. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  10645. .Select(it => new { id = it.Id, name = it.Name_CN })
  10646. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10647. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10648. }
  10649. /// <summary>
  10650. /// 查看邀请方
  10651. /// 团组名称 Init
  10652. /// </summary>
  10653. /// <param name="dto"></param>
  10654. /// <returns></returns>
  10655. [HttpPost]
  10656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10657. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  10658. {
  10659. var watch = new Stopwatch();
  10660. watch.Start();
  10661. RefAsync<int> total = 0;
  10662. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  10663. .InnerJoin<Grp_DelegationInfo>((oa,di) => oa.DiId == di.Id)
  10664. .Where((oa, di) => oa.IsDel == 0)
  10665. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  10666. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  10667. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  10668. .Distinct()
  10669. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10670. watch.Stop();
  10671. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  10672. }
  10673. /// <summary>
  10674. /// 查看邀请方
  10675. /// 团组 & 邀请方信息
  10676. /// </summary>
  10677. /// <param name="dto"></param>
  10678. /// <returns></returns>
  10679. [HttpPost]
  10680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10681. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  10682. {
  10683. var watch = new Stopwatch();
  10684. watch.Start();
  10685. RefAsync<int> total = 0;
  10686. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  10687. .AS("Grp_DelegationInfo")
  10688. .Includes(x => x.InvitingInfos)
  10689. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  10690. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  10691. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  10692. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  10693. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  10694. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  10695. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10696. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  10697. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  10698. infos.ForEach(x => {
  10699. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  10700. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  10701. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  10702. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  10703. });
  10704. watch.Stop();
  10705. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  10706. }
  10707. #endregion
  10708. #region 报批行程
  10709. /// <summary>
  10710. /// 报批行程初始化
  10711. /// </summary>
  10712. /// <param name="dto"></param>
  10713. /// <returns></returns>
  10714. [HttpPost]
  10715. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  10716. {
  10717. const int chiNumber = 5;
  10718. var jw = JsonView(false);
  10719. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  10720. var group = groupList.First();
  10721. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  10722. group = groupList.First(x => x.Id == diid);
  10723. if (group == null)
  10724. {
  10725. jw.Msg = "暂无团组!";
  10726. return Ok(jw);
  10727. }
  10728. var data = new
  10729. {
  10730. groupList = groupList.Select(x => new
  10731. {
  10732. x.TeamName,
  10733. x.Id
  10734. }),
  10735. content = new ArrayList(),
  10736. groupInfo = new
  10737. {
  10738. group.VisitDays,
  10739. group.TourCode,
  10740. group.VisitPNumber,
  10741. group.TeamName,
  10742. group.Id,
  10743. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  10744. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  10745. },
  10746. };
  10747. var resultArr = new ArrayList();
  10748. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  10749. if (content.Count == 0)
  10750. {
  10751. var stay = "-";
  10752. var cityPath = "-";
  10753. //添加城市路径以及住宿地
  10754. //黑屏代码数据
  10755. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  10756. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  10757. {
  10758. jw = JsonView(true, "黑屏代码有误!", data);
  10759. return Ok(jw);
  10760. }
  10761. foreach (DataRow row in dtBlack.Rows)
  10762. {
  10763. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  10764. {
  10765. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  10766. return Ok(jw);
  10767. }
  10768. }
  10769. //黑屏代码获取时间区间
  10770. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  10771. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  10772. _sqlSugar.BeginTran();
  10773. for (int i = 0; i < timeArr.Count; i++)
  10774. {
  10775. stay = "-";
  10776. cityPath = "-";
  10777. DateTime NewData = DateTime.Parse(timeArr[i]);
  10778. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  10779. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  10780. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  10781. if (tbSelect.Length > 0)
  10782. {
  10783. List<string> threeCodeStr = new List<string>();
  10784. foreach (var item in tbSelect)
  10785. {
  10786. var threeCode = item["Three"].ToString() ?? "";
  10787. if (threeCode.Length == 6)
  10788. {
  10789. var start = threeCode.Substring(0, 3);
  10790. var end = threeCode.Substring(3, 3);
  10791. if (threeCodeStr.Count == 0)
  10792. {
  10793. threeCodeStr.Add(start);
  10794. threeCodeStr.Add(end);
  10795. }
  10796. else
  10797. {
  10798. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  10799. {
  10800. threeCodeStr.Add(end);
  10801. }
  10802. else {
  10803. threeCodeStr.Add(start);
  10804. threeCodeStr.Add(end);
  10805. }
  10806. }
  10807. }
  10808. }
  10809. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  10810. var last = threeCodeStr.Last();
  10811. foreach (var item in threeCodeStr)
  10812. {
  10813. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  10814. if(item.Equals(last))
  10815. {
  10816. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  10817. }
  10818. }
  10819. cityPath = cityPath.Trim('-');
  10820. }
  10821. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  10822. appro.Diid = diid ?? -1;
  10823. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  10824. appro.Id = thisId;
  10825. appro.CreateUserId = dto.UserId;
  10826. appro.CreateTime = DateTime.Now;
  10827. content.Add(appro);
  10828. }
  10829. _sqlSugar.CommitTran();
  10830. }
  10831. foreach (var x in content)
  10832. {
  10833. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  10834. if (chiList.Count < chiNumber)
  10835. {
  10836. for (int i = chiList.Count; i < chiNumber; i++)
  10837. {
  10838. chiList.Add(new Grp_ApprovalTravelDetails());
  10839. }
  10840. }
  10841. resultArr.Add(new
  10842. {
  10843. x.Id,
  10844. x.Date,
  10845. x.Diid,
  10846. chiList = chiList.Select(x1 => new
  10847. {
  10848. timeInterval = x1.Time == null ? new string [1] : x1.Time.Split('-'),
  10849. x1.Details,
  10850. x1.ParentId,
  10851. x1.Id
  10852. })
  10853. });
  10854. }
  10855. data = data with
  10856. {
  10857. content = resultArr,
  10858. };
  10859. jw = JsonView(true,"获取成功!",data);
  10860. return Ok(jw);
  10861. }
  10862. /// <summary>
  10863. /// 报批行程删除
  10864. /// </summary>
  10865. /// <param name="dto"></param>
  10866. /// <returns></returns>
  10867. [HttpPost]
  10868. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  10869. {
  10870. var jw = JsonView(false);
  10871. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x=>x.Id == dto.Diid && x.IsDel == 0);
  10872. if (group == null)
  10873. {
  10874. jw.Msg = "团组参数有误!";
  10875. return Ok(jw);
  10876. }
  10877. try
  10878. {
  10879. _sqlSugar.BeginTran();
  10880. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x=>x.Id).ToList();
  10881. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  10882. {
  10883. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10884. DeleteUserId = dto.uesrId,
  10885. IsDel = 1
  10886. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  10887. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  10888. {
  10889. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10890. DeleteUserId = dto.uesrId,
  10891. IsDel = 1
  10892. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  10893. _sqlSugar.CommitTran();
  10894. jw = JsonView(true, "删除成功");
  10895. }
  10896. catch (Exception ex)
  10897. {
  10898. jw = JsonView(false, ex.Message);
  10899. }
  10900. return Ok(jw);
  10901. }
  10902. /// <summary>
  10903. /// 报批行程保存
  10904. /// </summary>
  10905. /// <param name="dto"></param>
  10906. /// <returns></returns>
  10907. [HttpPost]
  10908. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  10909. {
  10910. var jw = JsonView(false);
  10911. var Find = dto.Arr.Find(x => x.id == 0);
  10912. if (Find != null)
  10913. {
  10914. jw.Msg = "生成的ID为0!";
  10915. return Ok(jw);
  10916. }
  10917. foreach (var item in dto.Arr)
  10918. {
  10919. foreach (var chi in item.chiList)
  10920. {
  10921. if (chi.parentId == 0)
  10922. {
  10923. chi.parentId = item.id;
  10924. }
  10925. }
  10926. }
  10927. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  10928. _sqlSugar.BeginTran();
  10929. if (chiArr.Where(x=>x.id == 0).Count() == chiArr.Count)
  10930. {
  10931. var parentIds = dto.Arr.Select(x => x.id).ToList();
  10932. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x=>new Grp_ApprovalTravelDetails
  10933. {
  10934. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10935. DeleteUserId = dto.UserId,
  10936. IsDel = 1
  10937. }).ExecuteCommand();
  10938. }
  10939. try
  10940. {
  10941. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  10942. {
  10943. CreateTime = DateTime.Now,
  10944. CreateUserId = dto.UserId,
  10945. Details = x.details,
  10946. ParentId = x.parentId,
  10947. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  10948. Remark = "",
  10949. IsDel = 0
  10950. }).ToList()).ExecuteCommand();
  10951. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  10952. {
  10953. Id = x.id,
  10954. Details = x.details,
  10955. ParentId = x.parentId,
  10956. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  10957. }).ToList()).UpdateColumns(x=> new Grp_ApprovalTravelDetails
  10958. {
  10959. Details = x.Details,
  10960. ParentId = x.ParentId,
  10961. Time = x.Time
  10962. }).ExecuteCommand();
  10963. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  10964. {
  10965. Id = x.id,
  10966. Date = x.date,
  10967. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  10968. {
  10969. Date = x.Date
  10970. }).ExecuteCommand();
  10971. _sqlSugar.CommitTran();
  10972. jw = JsonView(true, "保存成功!");
  10973. }
  10974. catch (Exception ex)
  10975. {
  10976. _sqlSugar.RollbackTran();
  10977. jw = JsonView(false, "保存失败!" + ex.Message);
  10978. }
  10979. return Ok(jw);
  10980. }
  10981. /// <summary>
  10982. /// 报批行程生成
  10983. /// </summary>
  10984. /// <param name="dto"></param>
  10985. /// <returns></returns>
  10986. [HttpPost]
  10987. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  10988. {
  10989. var jw = JsonView(false);
  10990. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10991. if (group == null)
  10992. {
  10993. jw.Msg = "暂无该团组!";
  10994. return Ok(jw);
  10995. }
  10996. //黑屏代码数据
  10997. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  10998. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  10999. {
  11000. jw.Msg = "黑屏代码有误!";
  11001. return Ok(jw);
  11002. }
  11003. foreach (DataRow row in dtBlack.Rows)
  11004. {
  11005. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11006. {
  11007. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  11008. return Ok(jw);
  11009. }
  11010. }
  11011. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11012. var resultArr = new ArrayList();
  11013. if (officialActivitiesArr.Count == 0)
  11014. {
  11015. jw.Msg = "暂无公务出访信息!";
  11016. return Ok(jw);
  11017. }
  11018. try
  11019. {
  11020. _sqlSugar.BeginTran();
  11021. DeleteApprovalJourney(new
  11022. Domain.Dtos.Groups.DeleteApprovalJourney
  11023. {
  11024. Diid = dto.Diid,
  11025. uesrId = dto.Userid
  11026. });
  11027. var stay = "-";
  11028. var cityPath = "-";
  11029. //添加城市路径以及住宿地
  11030. //黑屏代码获取时间区间
  11031. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11032. var empty = "【未收入该三字码!请机票同事录入】";
  11033. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11034. for (int i = 0; i < timeArr.Count; i++)
  11035. {
  11036. stay = "-";
  11037. cityPath = "-";
  11038. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11039. DateTime NewData = DateTime.Parse(timeArr[i]);
  11040. var gwinfo = officialActivitiesArr.Where(x => DateTime.TryParse(x.Date, out DateTime gwData) && gwData.ToString("yyyy-MM-dd") == NewData.ToString("yyyy-MM-dd")).OrderBy(x => x.Time).ToList();
  11041. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11042. if (tbSelect.Length > 0)
  11043. {
  11044. List<string> threeCodeStr = new List<string>();
  11045. bool isTrade = false;
  11046. string trip = string.Empty;
  11047. var rowLast = tbSelect.Last();
  11048. var rowFirst = tbSelect.First();
  11049. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  11050. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  11051. var takeOffTime = DateTime.Parse(timeArr[i]);
  11052. var fallToTime = DateTime.Parse(timeArr[i]);
  11053. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  11054. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  11055. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  11056. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  11057. foreach (var item in tbSelect)
  11058. {
  11059. var start = string.Empty;
  11060. var end = string.Empty;
  11061. var threeCode = item["Three"].ToString() ?? "";
  11062. if (threeCode.Length == 6)
  11063. {
  11064. start = threeCode.Substring(0, 3);
  11065. end = threeCode.Substring(3, 3);
  11066. if (threeCodeStr.Count == 0)
  11067. {
  11068. threeCodeStr.Add(start);
  11069. threeCodeStr.Add(end);
  11070. }
  11071. else
  11072. {
  11073. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11074. {
  11075. threeCodeStr.Add(end);
  11076. }
  11077. else
  11078. {
  11079. threeCodeStr.Add(start);
  11080. threeCodeStr.Add(end);
  11081. }
  11082. }
  11083. }
  11084. //处理机票信息
  11085. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  11086. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  11087. if (start_Object == null)
  11088. {
  11089. start_Object = new Res_ThreeCode()
  11090. {
  11091. AirPort = empty,
  11092. AirPort_En = empty,
  11093. City = empty,
  11094. Country = empty,
  11095. Four = empty,
  11096. Three = empty,
  11097. };
  11098. }
  11099. if (end_Object == null)
  11100. {
  11101. end_Object = new Res_ThreeCode()
  11102. {
  11103. AirPort = empty,
  11104. AirPort_En = empty,
  11105. City = empty,
  11106. Country = empty,
  11107. Four = empty,
  11108. Three = empty,
  11109. };
  11110. }
  11111. //机型判断
  11112. string airModel = item["AirModel"].ToString();
  11113. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  11114. string flightTime = item["FlightTime"].ToString();
  11115. if (flightTime!.Contains(":"))
  11116. {
  11117. flightTime = flightTime.Replace(":", "小时");
  11118. flightTime += "分钟";
  11119. }
  11120. if (flightTime.Contains("H"))
  11121. {
  11122. flightTime = flightTime.Replace("H", "小时");
  11123. }
  11124. if (flightTime.Contains("M"))
  11125. {
  11126. flightTime = flightTime.Replace("M", "分钟");
  11127. }
  11128. //航班号
  11129. string flightcode = item["Fliagtcode"].ToString();
  11130. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  11131. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  11132. if (aircompany == null)
  11133. {
  11134. aircompany = new Res_AirCompany
  11135. {
  11136. CnName = hsEmpty,
  11137. EnName = hsEmpty,
  11138. ShortCode = hsEmpty,
  11139. };
  11140. }
  11141. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  11142. trip += $" 从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n ({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  11143. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  11144. if (isTrade)
  11145. {
  11146. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转时间: 行李直达)";
  11147. }
  11148. else
  11149. {
  11150. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  11151. }
  11152. }
  11153. chiarr.Add(new Grp_ApprovalTravelDetails
  11154. {
  11155. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  11156. CreateTime = DateTime.Now,
  11157. CreateUserId = dto.Userid,
  11158. ParentId = 0,
  11159. Details = trip
  11160. }) ;
  11161. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  11162. var last = threeCodeStr.Last();
  11163. foreach (var item in threeCodeStr)
  11164. {
  11165. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  11166. if (item.Equals(last))
  11167. {
  11168. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  11169. }
  11170. }
  11171. cityPath = cityPath.Trim('-');
  11172. }
  11173. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11174. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11175. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  11176. appro.Diid = dto.Diid;
  11177. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11178. appro.Id = thisId;
  11179. appro.CreateUserId = dto.Userid;
  11180. appro.CreateTime = DateTime.Now;
  11181. foreach (var item in gwinfo)
  11182. {
  11183. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  11184. chi.Details = "拜访" + item.Client;
  11185. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  11186. {
  11187. chi.Details += "," + item.ReqSample;
  11188. }
  11189. chi.ParentId = thisId;
  11190. chi.Time = item.Time;
  11191. chiarr.Add(chi);
  11192. }
  11193. if (chiarr.Count < 5)
  11194. {
  11195. for (int j = chiarr.Count; j < 5; j++)
  11196. {
  11197. chiarr.Add(new
  11198. Grp_ApprovalTravelDetails());
  11199. }
  11200. }
  11201. resultArr.Add(new
  11202. {
  11203. appro.Id,
  11204. appro.Date,
  11205. appro.Diid,
  11206. chiList = chiarr.Select(x1 => new
  11207. {
  11208. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11209. x1.Details,
  11210. x1.ParentId,
  11211. x1.Id
  11212. })
  11213. });
  11214. }
  11215. _sqlSugar.CommitTran();
  11216. jw = JsonView(true, "生成成功!", resultArr);
  11217. }
  11218. catch (Exception ex)
  11219. {
  11220. jw.Code = 400;
  11221. jw.Msg = "生成失败!" + ex.Message;
  11222. }
  11223. return Ok(jw);
  11224. }
  11225. /// <summary>
  11226. /// 报批行程word导出
  11227. /// </summary>
  11228. /// <param name="dto"></param>
  11229. /// <returns></returns>
  11230. [HttpPost]
  11231. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  11232. {
  11233. var jw = JsonView(false);
  11234. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11235. if (group == null)
  11236. {
  11237. jw.Msg = "暂无该团组!";
  11238. return Ok(jw);
  11239. }
  11240. //模板路径
  11241. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx");
  11242. //载入模板
  11243. Document doc = new Document(tempPath);
  11244. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11245. //获取所填表格的序数
  11246. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11247. Aspose.Words.Tables.Row titleRowClone = null;
  11248. Aspose.Words.Tables.Row CenterRowClone = null;
  11249. int index = 0;
  11250. int indexChi = 0;
  11251. int SetIndex = 0;
  11252. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  11253. //获取数据,放到datatable
  11254. foreach (var item in ApprovalTravelArr)
  11255. {
  11256. if (index > 0)
  11257. {
  11258. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  11259. tableOne.AppendChild(titleRowClone);
  11260. }
  11261. var textTime = item.Date;
  11262. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  11263. SetCells(tableOne, doc, SetIndex, 0, textTime);
  11264. SetIndex++;
  11265. if (ChiRep.Count > 0)
  11266. {
  11267. foreach (var itemChi in ChiRep)
  11268. {
  11269. var txtTime = itemChi.Time;
  11270. var txtDetail = itemChi.Details;
  11271. if (indexChi > 0)
  11272. {
  11273. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11274. tableOne.AppendChild(CenterRowClone);
  11275. }
  11276. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  11277. {
  11278. SetCells(tableOne, doc, SetIndex, 0, "");
  11279. SetCells(tableOne, doc, SetIndex, 1, "");
  11280. indexChi++;
  11281. SetIndex++;
  11282. break;
  11283. }
  11284. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  11285. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  11286. indexChi++;
  11287. SetIndex++;
  11288. }
  11289. }
  11290. else
  11291. {
  11292. if (indexChi > 0)
  11293. {
  11294. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11295. tableOne.AppendChild(CenterRowClone);
  11296. }
  11297. SetCells(tableOne, doc, SetIndex, 0, "");
  11298. SetCells(tableOne, doc, SetIndex, 1, "");
  11299. indexChi++;
  11300. SetIndex++;
  11301. }
  11302. index++;
  11303. }
  11304. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  11305. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName);
  11306. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; ;
  11307. jw.Code = 200;
  11308. jw.Msg = "";
  11309. return Ok(jw);
  11310. }
  11311. private string intToString(int numberVal)
  11312. {
  11313. string numberval = numberVal.ToString();
  11314. Dictionary<char, string> Number = new Dictionary<char, string>();
  11315. Number.Add('1', "一");
  11316. Number.Add('2', "二");
  11317. Number.Add('3', "三");
  11318. Number.Add('4', "四");
  11319. Number.Add('5', "五");
  11320. Number.Add('6', "六");
  11321. Number.Add('7', "七");
  11322. Number.Add('8', "八");
  11323. Number.Add('9', "九");
  11324. string stringNumberVal = string.Empty;
  11325. for (int i = 0; i < numberval.Length; i++)
  11326. {
  11327. if (i == 0)
  11328. {
  11329. stringNumberVal += Number[numberval[i]];
  11330. }
  11331. else if (i >= 1)
  11332. {
  11333. if (numberval[i] == '0')
  11334. {
  11335. stringNumberVal = "十";
  11336. }
  11337. else
  11338. {
  11339. stringNumberVal += "十" + Number[numberval[i]];
  11340. }
  11341. }
  11342. }
  11343. return stringNumberVal;
  11344. }
  11345. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  11346. {
  11347. //获取table中的某个单元格,从0开始
  11348. Cell lshCell = table.Rows[rows].Cells[cells];
  11349. //将单元格中的第一个段落移除
  11350. lshCell.FirstParagraph.Remove();
  11351. //新建一个段落
  11352. Paragraph p = new Paragraph(doc);
  11353. var r = new Run(doc, val);
  11354. //把设置的值赋给之前新建的段落
  11355. p.AppendChild(r);
  11356. //将此段落加到单元格内
  11357. lshCell.AppendChild(p);
  11358. }
  11359. [HttpPost]
  11360. public async Task<IActionResult> ServerHttp(string paramStr)
  11361. {
  11362. paramStr = paramStr.TrimEnd('\'');
  11363. paramStr = paramStr.TrimStart('\'');
  11364. JsonView jw = JsonView(false);
  11365. JObject param = JObject.Parse(paramStr);
  11366. if (!param.ContainsKey("url"))
  11367. {
  11368. jw.Msg = "url null";
  11369. return Ok(jw);
  11370. }
  11371. string url = param["url"]!.ToString();
  11372. var methon = "get";
  11373. Dictionary<string, string> bodyValues = null;
  11374. Dictionary<string, string> headValues = null;
  11375. if (param.ContainsKey("methon"))
  11376. {
  11377. methon = param["methon"]!.ToString();
  11378. }
  11379. if (param.ContainsKey("header"))
  11380. {
  11381. var header = param["header"]!.ToString();
  11382. JObject headerJobject = JObject.Parse(header);
  11383. headValues = new Dictionary<string, string>();
  11384. foreach (JProperty item in headerJobject.Properties())
  11385. {
  11386. var value = item.Value.ToString();
  11387. var head = item.Path;
  11388. headValues.Add(head, value);
  11389. }
  11390. }
  11391. if (param.ContainsKey("body"))
  11392. {
  11393. var body = param["body"]!.ToString();
  11394. bodyValues = new Dictionary<string, string>();
  11395. JObject bodyJobject = JObject.Parse(body);
  11396. foreach (JProperty item in bodyJobject.Properties())
  11397. {
  11398. var value = item.Value.ToString();
  11399. var head = item.Path;
  11400. bodyValues.Add(head, value);
  11401. }
  11402. }
  11403. HttpClient client = new HttpClient();
  11404. string responseString = string.Empty;
  11405. if (param.ContainsKey("isJson"))
  11406. {
  11407. }
  11408. if (headValues != null)
  11409. {
  11410. foreach (var item in headValues.Keys)
  11411. {
  11412. client.DefaultRequestHeaders.Add(item, headValues[item]);
  11413. }
  11414. }
  11415. try
  11416. {
  11417. if (methon == "get")
  11418. {
  11419. responseString = await client.GetStringAsync(url);
  11420. }
  11421. else if (methon == "post")
  11422. {
  11423. if (bodyValues == null)
  11424. {
  11425. jw.Msg = "methon post body null";
  11426. return Ok(jw);
  11427. }
  11428. // 数据转化为 key=val 格式
  11429. var content = new FormUrlEncodedContent(bodyValues);
  11430. var response = await client.PostAsync(url, content);
  11431. // 获取数据
  11432. responseString = await response.Content.ReadAsStringAsync();
  11433. }
  11434. else
  11435. {
  11436. jw.Msg = "methon error";
  11437. }
  11438. jw = JsonView(true, "success", responseString);
  11439. }
  11440. catch (Exception ex)
  11441. {
  11442. jw.Msg = "error " + ex.Message;
  11443. jw.Data = ex.StackTrace;
  11444. }
  11445. finally
  11446. {
  11447. client.Dispose();
  11448. }
  11449. return Ok(jw);
  11450. }
  11451. #endregion
  11452. // /// <summary>
  11453. // ///
  11454. // /// </summary>
  11455. // /// <param name="_dto"></param>
  11456. // /// <returns></returns>
  11457. // [HttpPost]
  11458. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11459. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11460. // {
  11461. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11462. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11463. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11464. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11465. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11466. // dic_psg.Add("客人", 974);
  11467. // dic_psg.Add("司机", 975);
  11468. // dic_psg.Add("导游", 976);
  11469. // dic_psg.Add("公司内部人员", 977);
  11470. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11471. // foreach (var item in list_visa)
  11472. // {
  11473. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11474. // temp.Id = item.Id;
  11475. // temp.DIId = item.DIId;
  11476. // temp.VisaClient = item.VisaClient;
  11477. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11478. // temp.VisaCurrency = item.VisaCurrency;
  11479. // temp.IsThird = item.IsThird;
  11480. // if (dic_psg.ContainsKey(item.PassengerType))
  11481. // {
  11482. // temp.PassengerType = dic_psg[item.PassengerType];
  11483. // }
  11484. // else {
  11485. // temp.PassengerType = -1;
  11486. // }
  11487. // temp.VisaNumber = item.VisaNumber;
  11488. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11489. // temp.CreateUserId = item.Operators;
  11490. // DateTime dt_ct;
  11491. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11492. // if (b_ct)
  11493. // {
  11494. // temp.CreateTime = dt_ct;
  11495. // }
  11496. // else
  11497. // {
  11498. // temp.CreateTime = DateTime.Now;
  11499. // }
  11500. // temp.DeleteTime = "";
  11501. // temp.DeleteUserId = 0;
  11502. // temp.Remark = item.Remark;
  11503. // if (string.IsNullOrEmpty(temp.Remark)) {
  11504. // temp.Remark = "";
  11505. // }
  11506. // temp.IsDel = item.IsDel;
  11507. // temp.VisaDescription = item.VisaAttachment;
  11508. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11509. //([Id]
  11510. // ,[DIId]
  11511. // ,[VisaClient]
  11512. // ,[VisaPrice]
  11513. // ,[VisaCurrency]
  11514. // ,[IsThird]
  11515. // ,[PassengerType]
  11516. // ,[VisaNumber]
  11517. // ,[VisaFreeNumber]
  11518. // ,[CreateUserId]
  11519. // ,[CreateTime]
  11520. // ,[DeleteTime]
  11521. // ,[DeleteUserId]
  11522. // ,[Remark]
  11523. // ,[IsDel]
  11524. // ,[visaDescription])
  11525. // VALUES
  11526. // ({0},{1},'{2}',{3},{4}
  11527. //,{5},{6},{7},{8},{9}
  11528. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11529. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11530. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11531. //);
  11532. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11533. // }
  11534. // return Ok(JsonView(true, "操作成功!"));
  11535. // }
  11536. /// <summary>
  11537. /// 123132123
  11538. /// </summary>
  11539. /// <param name="_dto"></param>
  11540. /// <returns></returns>
  11541. [HttpPost]
  11542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11543. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11544. {
  11545. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11546. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11547. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11548. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11549. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11550. dicDetail.Add(789, 1034);
  11551. dicDetail.Add(790, 1035);
  11552. dicDetail.Add(791, 1036);
  11553. dicDetail.Add(792, 1037);
  11554. dicDetail.Add(793, 1038);
  11555. dicDetail.Add(794, 1039);
  11556. dicDetail.Add(795, 1040);
  11557. dicDetail.Add(796, 1041);
  11558. dicDetail.Add(797, 1042);
  11559. dicDetail.Add(798, 1043);
  11560. dicDetail.Add(801, 1044);
  11561. dicDetail.Add(802, 1045);
  11562. dicDetail.Add(803, 1046);
  11563. Dictionary<int, int> dic = new Dictionary<int, int>();
  11564. dic.Add(806, 1027);
  11565. dic.Add(807, 1028);
  11566. dic.Add(808, 1029);
  11567. dic.Add(809, 1030);
  11568. dic.Add(810, 1031);
  11569. dic.Add(811, 1032);
  11570. dic.Add(812, 1033);
  11571. foreach (var item in list_visa)
  11572. {
  11573. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11574. temp.Coefficient = item.coefficient;
  11575. DateTime dtCrt;
  11576. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11577. if (b1)
  11578. {
  11579. temp.CreateTime = dtCrt;
  11580. }
  11581. else
  11582. {
  11583. temp.CreateTime = DateTime.Now;
  11584. }
  11585. temp.CreateUserId = item.Operators;
  11586. temp.DeleteTime = "";
  11587. temp.DeleteUserId = 0;
  11588. temp.DiId = int.Parse(item.DIID);
  11589. temp.FilePath = item.FilePath;
  11590. temp.IsDel = item.IsDel;
  11591. temp.Price = item.Price;
  11592. temp.PriceCount = 1;
  11593. temp.PriceCurrency = item.Currency;
  11594. int detailId = 0;
  11595. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11596. {
  11597. detailId = dicDetail[item.PriceTypeDetail];
  11598. }
  11599. temp.PriceDetailType = detailId;
  11600. temp.PriceDt = DateTime.Now;
  11601. temp.PriceName = item.PriceName;
  11602. temp.PriceSum = item.Price;
  11603. int tid = 0;
  11604. if (dic.ContainsKey(item.PriceType))
  11605. {
  11606. tid = dic[item.PriceType];
  11607. }
  11608. temp.PriceType = tid;
  11609. temp.Remark = item.Remark;
  11610. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11611. }
  11612. return Ok(JsonView(true, "操作成功!"));
  11613. }
  11614. }
  11615. }