GroupsController.cs 199 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714
  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. namespace OASystem.API.Controllers
  42. {
  43. /// <summary>
  44. /// 团组相关
  45. /// </summary>
  46. //[Authorize]
  47. [Route("api/[controller]/[action]")]
  48. public class GroupsController : ControllerBase
  49. {
  50. private readonly GrpScheduleRepository _grpScheduleRep;
  51. private readonly IMapper _mapper;
  52. private readonly DelegationInfoRepository _groupRepository;
  53. private readonly TaskAssignmentRepository _taskAssignmentRep;
  54. private readonly AirTicketResRepository _airTicketResRep;
  55. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  56. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  57. private readonly DelegationEnDataRepository _delegationEnDataRep;
  58. private readonly DelegationVisaRepository _delegationVisaRep;
  59. private readonly VisaPriceRepository _visaPriceRep;
  60. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  61. private readonly HotelPriceRepository _hotelPriceRep;
  62. private readonly CustomersRepository _customersRep;
  63. private readonly MessageRepository _message;
  64. private readonly SqlSugarClient _sqlSugar;
  65. #region 成本相关
  66. private readonly CheckBoxsRepository _checkBoxs;
  67. private readonly GroupCostRepository _GroupCostRepository;
  68. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  69. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  70. #endregion
  71. private readonly SetDataRepository _setDataRep;
  72. private string url;
  73. private string path;
  74. private readonly EnterExitCostRepository _enterExitCostRep;
  75. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  76. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  77. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  78. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  79. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  80. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep)
  81. {
  82. _mapper = mapper;
  83. _grpScheduleRep = grpScheduleRep;
  84. _groupRepository = groupRepository;
  85. _taskAssignmentRep = taskAssignmentRep;
  86. _airTicketResRep = airTicketResRep;
  87. _sqlSugar = sqlSugar;
  88. url = AppSettingsHelper.Get("ExcelBaseUrl");
  89. path = AppSettingsHelper.Get("ExcelBasePath");
  90. if (!System.IO.Directory.Exists(path))
  91. {
  92. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  93. }
  94. _decreasePaymentsRep = decreasePaymentsRep;
  95. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  96. _delegationEnDataRep = delegationEnDataRep;
  97. _enterExitCostRep = enterExitCostRep;
  98. _delegationVisaRep = delegationVisaRep;
  99. _message = message;
  100. _visaPriceRep = visaPriceRep;
  101. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  102. _checkBoxs = checkBoxs;
  103. _GroupCostRepository = GroupCostRepository;
  104. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  105. _GroupCostParameterRepository = GroupCostParameterRepository;
  106. _hotelPriceRep = hotelPriceRep;
  107. _customersRep = customersRep;
  108. _setDataRep = setDataRep;
  109. }
  110. #region 流程管控
  111. /// <summary>
  112. /// 获取团组流程管控信息
  113. /// </summary>
  114. /// <param name="paras">参数Json字符串</param>
  115. /// <returns></returns>
  116. [HttpPost]
  117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  118. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  119. {
  120. if (string.IsNullOrEmpty(_jsonDto.Paras))
  121. {
  122. return Ok(JsonView(false, "参数为空"));
  123. }
  124. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  125. if (_ScheduleDto != null)
  126. {
  127. if (_ScheduleDto.SearchType == 2)//获取列表
  128. {
  129. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  130. return Ok(JsonView(_grpScheduleViewList));
  131. }
  132. else//获取对象
  133. {
  134. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  135. if (_grpScheduleView != null)
  136. {
  137. return Ok(JsonView(_grpScheduleView));
  138. }
  139. }
  140. }
  141. else
  142. {
  143. return Ok(JsonView(false, "参数反序列化失败"));
  144. }
  145. return Ok(JsonView(false, "暂无数据!"));
  146. }
  147. /// <summary>
  148. /// 修改团组流程管控详细表数据
  149. /// </summary>
  150. /// <param name="paras"></param>
  151. /// <returns></returns>
  152. [HttpPost]
  153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  154. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  155. {
  156. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  157. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  158. .SetColumns(it => it.Duty == _detail.Duty)
  159. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  160. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  161. .SetColumns(it => it.JobContent == _detail.JobContent)
  162. .SetColumns(it => it.Remark == _detail.Remark)
  163. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  164. .Where(s => s.Id == dto.Id)
  165. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  166. .ExecuteCommandAsync();
  167. if (result > 0)
  168. {
  169. return Ok(JsonView(true, "保存成功!"));
  170. }
  171. return Ok(JsonView(false, "保存失败!"));
  172. }
  173. /// <summary>
  174. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  175. /// </summary>
  176. /// <param name="dto"></param>
  177. /// <returns></returns>
  178. [HttpPost]
  179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  180. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  181. {
  182. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  183. _detail.IsDel = 1;
  184. _detail.DeleteUserId = dto.Duty;
  185. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  186. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  187. .SetColumns(it => it.IsDel == _detail.IsDel)
  188. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  189. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  190. .Where(it => it.Id == dto.Id)
  191. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  192. //.WhereColumns(s => s.Id == dto.Id)
  193. .ExecuteCommandAsync();
  194. if (result > 0)
  195. {
  196. return Ok(JsonView(true, "删除成功!"));
  197. }
  198. return Ok(JsonView(false, "删除失败!"));
  199. }
  200. /// <summary>
  201. /// 增加团组流程管控详细表数据
  202. /// </summary>
  203. /// <param name="dto"></param>
  204. /// <returns></returns>
  205. [HttpPost]
  206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  207. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  208. {
  209. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  210. if (DateTime.Now < _detail.ExpectBeginDt)
  211. {
  212. _detail.StepStatus = 0;
  213. }
  214. else
  215. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  216. _detail.StepStatus = 1;
  217. }
  218. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  219. if (result > 0)
  220. {
  221. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  222. return Ok(JsonView(true, "添加成功!", _result));
  223. }
  224. return Ok(JsonView(false, "添加失败!"));
  225. }
  226. #endregion
  227. #region 团组基本信息
  228. /// <summary>
  229. /// 接团信息列表
  230. /// </summary>
  231. /// <param name="dto">团组列表请求dto</param>
  232. /// <returns></returns>
  233. [HttpPost]
  234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  235. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  236. {
  237. var groupData = await _groupRepository.GetGroupList(dto);
  238. if (groupData.Code != 0)
  239. {
  240. return Ok(JsonView(false, groupData.Msg));
  241. }
  242. return Ok(JsonView(groupData.Data));
  243. }
  244. /// <summary>
  245. /// 接团信息列表 Page
  246. /// </summary>
  247. /// <param name="dto">团组列表请求dto</param>
  248. /// <returns></returns>
  249. [HttpPost]
  250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  251. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  252. {
  253. #region 参数验证
  254. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  255. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  256. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  257. #region 页面操作权限验证
  258. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  259. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  260. #endregion
  261. #endregion
  262. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  263. {
  264. string sqlWhere = string.Empty;
  265. if (dto.IsSure == 0) //未完成
  266. {
  267. sqlWhere += string.Format(@" And IsSure = 0");
  268. }
  269. else if (dto.IsSure == 1) //已完成
  270. {
  271. sqlWhere += string.Format(@" And IsSure = 1");
  272. }
  273. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  274. {
  275. string tj = dto.SearchCriteria;
  276. 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}%')",
  277. tj, tj, tj, tj, tj);
  278. }
  279. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  280. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  281. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  282. From (
  283. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  284. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  285. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  286. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  287. From Grp_DelegationInfo gdi
  288. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  289. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  290. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  291. Where gdi.IsDel = 0 {0}
  292. ) temp ", sqlWhere);
  293. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  294. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  295. var _view = new
  296. {
  297. PageFuncAuth = pageFunAuthView,
  298. Data = _DelegationList
  299. };
  300. return Ok(JsonView(true, "查询成功!", _view, total));
  301. }
  302. else
  303. {
  304. return Ok(JsonView(false, "查询失败"));
  305. }
  306. }
  307. /// <summary>
  308. /// 接团信息详情
  309. /// </summary>
  310. /// <param name="dto">团组info请求dto</param>
  311. /// <returns></returns>
  312. [HttpPost]
  313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  314. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  315. {
  316. var groupData = await _groupRepository.GetGroupInfo(dto);
  317. if (groupData.Code != 0)
  318. {
  319. return Ok(JsonView(false, groupData.Msg));
  320. }
  321. return Ok(JsonView(groupData.Data));
  322. }
  323. /// <summary>
  324. /// 接团信息 编辑添加
  325. /// 基础信息数据源
  326. /// </summary>
  327. /// <param name="dto"></param>
  328. /// <returns></returns>
  329. [HttpPost]
  330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  331. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  332. {
  333. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  334. if (groupData.Code != 0)
  335. {
  336. return Ok(JsonView(false, groupData.Msg));
  337. }
  338. return Ok(JsonView(groupData.Data));
  339. }
  340. /// <summary>
  341. /// 接团信息 操作(增改)
  342. /// </summary>
  343. /// <param name="dto"></param>
  344. /// <returns></returns>
  345. [HttpPost]
  346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  347. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  348. {
  349. try
  350. {
  351. var groupData = await _groupRepository.GroupOperation(dto);
  352. if (groupData.Code != 0)
  353. {
  354. return Ok(JsonView(false, groupData.Msg));
  355. }
  356. return Ok(JsonView(true));
  357. }
  358. catch (Exception ex)
  359. {
  360. Logs("[response]" + JsonConvert.SerializeObject(dto));
  361. Logs(ex.Message);
  362. return Ok(JsonView(false, ex.Message));
  363. }
  364. }
  365. /// <summary>
  366. /// 接团信息 操作(删除)
  367. /// </summary>
  368. /// <param name="dto"></param>
  369. /// <returns></returns>
  370. [HttpPost]
  371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  372. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  373. {
  374. try
  375. {
  376. var groupData = await _groupRepository.GroupDel(dto);
  377. if (groupData.Code != 0)
  378. {
  379. return Ok(JsonView(false, groupData.Msg));
  380. }
  381. return Ok(JsonView(true));
  382. }
  383. catch (Exception ex)
  384. {
  385. Logs("[response]" + JsonConvert.SerializeObject(dto));
  386. Logs(ex.Message);
  387. return Ok(JsonView(false, ex.Message));
  388. }
  389. }
  390. /// <summary>
  391. /// 获取团组销售报价号
  392. /// 团组添加时 使用
  393. /// </summary>
  394. /// <returns></returns>
  395. [HttpPost]
  396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  397. public async Task<IActionResult> GetGroupSalesQuoteNo()
  398. {
  399. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  400. if (groupData.Code != 0)
  401. {
  402. return Ok(JsonView(false, groupData.Msg));
  403. }
  404. object salesQuoteNo = new
  405. {
  406. SalesQuoteNo = groupData.Data
  407. };
  408. return Ok(JsonView(salesQuoteNo));
  409. }
  410. /// <summary>
  411. /// 设置确认出团
  412. /// </summary>
  413. /// <param name="dto"></param>
  414. /// <returns></returns>
  415. [HttpPost]
  416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  417. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  418. {
  419. var groupData = await _groupRepository.ConfirmationGroup(dto);
  420. if (groupData.Code != 0)
  421. {
  422. return Ok(JsonView(false, groupData.Msg));
  423. }
  424. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  425. return Ok(JsonView(true, "操作成功!", groupData.Data));
  426. }
  427. /// <summary>
  428. /// 获取团组名称data And 签证国别Data
  429. /// </summary>
  430. /// <param name="dto"></param>
  431. /// <returns></returns>
  432. [HttpPost]
  433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  434. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  435. {
  436. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  437. if (groupData.Code != 0)
  438. {
  439. return Ok(JsonView(false, groupData.Msg));
  440. }
  441. return Ok(JsonView(groupData.Data));
  442. }
  443. /// <summary>
  444. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  445. /// </summary>
  446. /// <returns></returns>
  447. [HttpPost]
  448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  449. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  450. {
  451. try
  452. {
  453. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  454. if (groupData.Code != 0)
  455. {
  456. return Ok(JsonView(false, groupData.Msg));
  457. }
  458. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  459. }
  460. catch (Exception ex)
  461. {
  462. return Ok(JsonView(false, "程序错误!"));
  463. throw;
  464. }
  465. }
  466. #endregion
  467. #region 团组&签证
  468. /// <summary>
  469. /// 根据团组Id获取签证客户信息List
  470. /// </summary>
  471. /// <param name="dto">请求dto</param>
  472. /// <returns></returns>
  473. [HttpPost]
  474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  475. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  476. {
  477. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  478. if (groupData.Code != 0)
  479. {
  480. return Ok(JsonView(false, groupData.Msg));
  481. }
  482. return Ok(JsonView(groupData.Data));
  483. }
  484. /// <summary>
  485. /// IOS获取团组签证拍照上传进度01(团组列表)
  486. /// </summary>
  487. /// <param name="dto">请求dto</param>
  488. /// <returns></returns>
  489. [HttpPost]
  490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  491. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  492. {
  493. if (dto == null)
  494. {
  495. return Ok(JsonView(false, "参数为空"));
  496. }
  497. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  498. return Ok(JsonView(visaList));
  499. }
  500. /// <summary>
  501. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  502. /// </summary>
  503. /// <returns></returns>
  504. [HttpPost]
  505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  506. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  507. {
  508. if (dto == null)
  509. {
  510. return Ok(JsonView(false, "请求错误:"));
  511. }
  512. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  513. return Ok(JsonView(list));
  514. }
  515. /// <summary>
  516. /// IOS获取团组签证拍照上传进度03(相册)
  517. /// </summary>
  518. /// <returns></returns>
  519. [HttpPost]
  520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  521. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  522. {
  523. if (dto == null)
  524. {
  525. return Ok(JsonView(false, "请求错误:"));
  526. }
  527. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  528. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  529. list.ForEach(s => s.url = url);
  530. return Ok(JsonView(list));
  531. }
  532. /// <summary>
  533. /// IOS获取团组签证拍照上传进度04(图片上传)
  534. /// </summary>
  535. /// <param name="dto"></param>
  536. /// <returns></returns>
  537. [HttpPost]
  538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  539. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  540. {
  541. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  542. //if (!string.IsNullOrEmpty(result))
  543. //{
  544. //}
  545. //else {
  546. // return Ok(JsonView(false, "上传失败"));
  547. //}
  548. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  549. int sucNum = 0;
  550. try
  551. {
  552. foreach (var item in dto.base64DataList)
  553. {
  554. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  555. string result = decodeBase64ToImage(item, imageName);
  556. if (!string.IsNullOrEmpty(result))
  557. {
  558. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  559. pic.CreateUserId = dto.CreateUserId;
  560. pic.PicName = imageName;
  561. pic.PicPath = result;
  562. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  563. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  564. if (insertResult > 0)
  565. {
  566. sucNum++;
  567. }
  568. }
  569. }
  570. }
  571. catch (Exception ex)
  572. {
  573. return Ok(JsonView(false, ex.Message));
  574. }
  575. string msg = string.Format(@"成功上传{0}张", sucNum);
  576. return Ok(JsonView(true, msg));
  577. }
  578. private string decodeBase64ToImage(string base64DataURL, string imgName)
  579. {
  580. string filename = "";//声明一个string类型的相对路径
  581. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  582. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  583. try//会有异常抛出,try,catch一下
  584. {
  585. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  586. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  587. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  588. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  589. //文件名称
  590. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  591. //上传的文件的路径
  592. string filePath = "";
  593. if (!Directory.Exists(fileDir))
  594. {
  595. Directory.CreateDirectory(fileDir);
  596. }
  597. //上传的文件的路径
  598. filePath = fileDir + filename;
  599. //string url = HttpRuntime.AppDomainAppPath.ToString();
  600. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  601. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  602. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  603. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  604. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  605. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  606. ms.Close();//关闭当前流,并释放所有与之关联的资源
  607. bitmap.Dispose();
  608. }
  609. catch (Exception e)
  610. {
  611. string massage = e.Message;
  612. Logs("IOS图片上传Error:" + massage);
  613. //filename = e.Message;
  614. }
  615. return filename;//返回相对路径
  616. }
  617. /// <summary>
  618. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  619. /// </summary>
  620. /// <param name="dto"></param>
  621. /// <returns></returns>
  622. [HttpPost]
  623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  624. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  625. {
  626. if (dto == null)
  627. {
  628. return Ok(JsonView(false, "请求错误:"));
  629. }
  630. string msg = "参数错误";
  631. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  632. {
  633. try
  634. {
  635. //_delegationVisaRep.BeginTran();
  636. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  637. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  638. .Where(s => s.Id == dto.visaProgressCustomerId)
  639. .ExecuteCommandAsync();
  640. if (updCount > 0 && dto.publishCode == 1)
  641. {
  642. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  643. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  644. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  645. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  646. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  647. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  648. if (groupData == null)
  649. {
  650. _delegationVisaRep.RollbackTran();
  651. }
  652. string title = string.Format(@"[签证进度更新]");
  653. string content = string.Format(@"测试文本");
  654. bool rst = await _message.AddMsg(new MessageDto()
  655. {
  656. Type = 5,
  657. IssuerId = dto.publisher,
  658. Title = title,
  659. Content = content,
  660. ReleaseTime = DateTime.Now,
  661. UIdList = new List<int> {
  662. 234
  663. }
  664. });
  665. if (rst)
  666. {
  667. return Ok(JsonView(true, "发送通知成功"));
  668. }
  669. }
  670. //_delegationVisaRep.CommitTran();
  671. }
  672. catch (Exception)
  673. {
  674. //_delegationVisaRep.RollbackTran();
  675. }
  676. }
  677. return Ok(JsonView(true, msg));
  678. }
  679. #endregion
  680. #region 团组任务分配
  681. /// <summary>
  682. /// 团组任务分配初始化
  683. /// </summary>
  684. /// <param name="dto"></param>
  685. /// <returns></returns>
  686. [HttpPost]
  687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  688. public async Task<IActionResult> GetTaskAssignmen()
  689. {
  690. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  691. if (groupData.Code != 0)
  692. {
  693. return Ok(JsonView(false, groupData.Msg));
  694. }
  695. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  696. }
  697. /// <summary>
  698. /// 团组任务分配查询
  699. /// </summary>
  700. /// <param name="dto"></param>
  701. /// <returns></returns>
  702. [HttpPost]
  703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  704. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  705. {
  706. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  707. if (groupData.Code != 0)
  708. {
  709. return Ok(JsonView(false, groupData.Msg));
  710. }
  711. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  712. }
  713. /// <summary>
  714. /// 团组任务分配操作
  715. /// </summary>
  716. /// <param name="dto"></param>
  717. /// <returns></returns>
  718. [HttpPost]
  719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  720. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  721. {
  722. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  723. if (groupData.Code != 0)
  724. {
  725. return Ok(JsonView(false, groupData.Msg));
  726. }
  727. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  728. }
  729. #endregion
  730. #region 团组费用审核
  731. /// <summary>
  732. /// 费用审核
  733. /// 团组列表 Page
  734. /// </summary>
  735. /// <param name="_dto">团组列表请求dto</param>
  736. /// <returns></returns>
  737. [HttpPost]
  738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  739. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  740. {
  741. #region 参数验证
  742. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  743. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  744. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  745. #region 页面操作权限验证
  746. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  747. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  748. #endregion
  749. #endregion
  750. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  751. {
  752. string sqlWhere = string.Empty;
  753. if (_dto.IsSure == 0) //未完成
  754. {
  755. sqlWhere += string.Format(@" And IsSure = 0");
  756. }
  757. else if (_dto.IsSure == 1) //已完成
  758. {
  759. sqlWhere += string.Format(@" And IsSure = 1");
  760. }
  761. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  762. {
  763. string tj = _dto.SearchCriteria;
  764. 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}%')",
  765. tj, tj, tj, tj, tj);
  766. }
  767. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  768. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  769. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  770. From (
  771. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  772. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  773. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  774. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  775. From Grp_DelegationInfo gdi
  776. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  777. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  778. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  779. Where gdi.IsDel = 0 {0}
  780. ) temp ", sqlWhere);
  781. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  782. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  783. var _view = new
  784. {
  785. PageFuncAuth = pageFunAuthView,
  786. Data = _DelegationList
  787. };
  788. return Ok(JsonView(true, "查询成功!", _view, total));
  789. }
  790. else
  791. {
  792. return Ok(JsonView(false, "查询失败"));
  793. }
  794. }
  795. /// <summary>
  796. /// 获取团组费用审核
  797. /// </summary>
  798. /// <param name="paras">参数Json字符串</param>
  799. /// <returns></returns>
  800. [HttpPost]
  801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  802. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  803. {
  804. try
  805. {
  806. #region 参数验证
  807. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  808. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  809. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  810. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  811. #region 页面操作权限验证
  812. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  813. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  814. #endregion
  815. #endregion
  816. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  817. #region 费用清单
  818. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  819. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  820. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  821. List<Grp_CreditCardPayment> entityList = _groupRepository
  822. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  823. .Where(exp.ToExpression())
  824. .ToList();
  825. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  826. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  827. /*
  828. * 76://酒店预订
  829. */
  830. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  831. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  832. .ToListAsync();
  833. /*
  834. * 79://车/导游地接
  835. */
  836. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  837. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  838. .ToListAsync();
  839. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  840. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  841. .ToListAsync();
  842. /*
  843. * 80: //签证
  844. */
  845. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  846. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  847. .ToListAsync();
  848. /*
  849. *81: //邀请/公务活动
  850. */
  851. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  852. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  853. .ToListAsync();
  854. /*
  855. * 82: //团组客户保险
  856. */
  857. /*
  858. * Label = 98 其他款项
  859. */
  860. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  861. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  862. .ToListAsync();
  863. /*
  864. * Lable = 85 机票预订
  865. */
  866. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  867. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  868. .ToListAsync();
  869. /*
  870. * 98 机票预定
  871. */
  872. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  873. /*
  874. * 285://收款退还
  875. */
  876. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys= await _groupRepository
  877. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  878. .ToListAsync();
  879. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0) .ToListAsync();
  880. /*
  881. * 币种信息
  882. */
  883. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  884. /*
  885. * 车/导游地接 费用类型
  886. */
  887. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  888. /*
  889. * 用户信息
  890. */
  891. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  892. /*
  893. * 费用模块
  894. */
  895. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  896. string priceModule = string.Empty;
  897. if (sdPriceName != null)
  898. {
  899. priceModule = sdPriceName.Name;
  900. }
  901. /*
  902. * 处理详情数据
  903. */
  904. foreach (var entity in entityList)
  905. {
  906. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  907. _detail.Id = entity.Id;
  908. _detail.PriceName = priceModule;
  909. /*
  910. * 应付款金额
  911. */
  912. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  913. string PaymentCurrency_WaitPay = "Unknown";
  914. string hotelCurrncyCode = "Unknown";
  915. string hotelCurrncyName = "Unknown";
  916. if (sdPaymentCurrency_WaitPay != null)
  917. {
  918. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  919. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  920. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  921. }
  922. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1() + " " + PaymentCurrency_WaitPay;
  923. /*
  924. * 此次付款金额
  925. */
  926. decimal CurrPayStr = 0;
  927. if (entity.PayPercentage == 0)
  928. {
  929. if (entity.PayThenMoney != 0)
  930. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  931. }
  932. else
  933. {
  934. CurrPayStr = (entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * entity.DayRate)).ConvertToDecimal1();
  935. }
  936. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  937. /*
  938. * 剩余尾款
  939. */
  940. decimal BalanceStr = 0;
  941. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  942. BalanceStr = 0;
  943. else
  944. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  945. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  946. /*
  947. * Bus名称
  948. */
  949. _detail.BusName = "待增加";
  950. /*
  951. *费用所属
  952. */
  953. switch (entity.CTable)
  954. {
  955. case 76://酒店预订
  956. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  957. if (hotelReservations != null)
  958. {
  959. _detail.PriceMsgContent = "信用卡金额:" + _detail.WaitPay + " " + hotelCurrncyCode + "(" + hotelCurrncyName + ")<br/>" +
  960. "房间说明:" + hotelReservations.Remark;
  961. _detail.PriceNameContent = hotelReservations.HotelName;
  962. }
  963. break;
  964. case 79://车/导游地接
  965. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  966. if (touristGuideGroundReservations != null)
  967. {
  968. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  969. {
  970. _detail.BusName = touristGuideGroundReservations.BusName;
  971. }
  972. _detail.PriceNameContent = touristGuideGroundReservations.Area;
  973. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  974. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  975. string priceMsg = string.Empty;
  976. foreach (var item in touristGuideGroundReservationsContents)
  977. {
  978. string typeName = "Unknown";
  979. string carCurrencyCode = "Unknown";
  980. string carCurrencyName = "Unknown";
  981. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  982. if (carTypeData != null) typeName = carTypeData.Name;
  983. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  984. if (currencyData != null) {
  985. carCurrencyCode = currencyData.Name;
  986. carCurrencyName = currencyData.Remark;
  987. }
  988. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  989. "明细:" + item.PriceContent + "<br/>" +
  990. "备注:" + item.Remark + "<br/><br/>";
  991. }
  992. _detail.PriceMsgContent = priceMsg;
  993. }
  994. break;
  995. case 80: //签证
  996. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  997. if (visaInfo != null)
  998. {
  999. _detail.PriceNameContent = visaInfo.VisaClient;
  1000. _detail.PriceMsgContent = "备注:" + visaInfo.Remark;
  1001. }
  1002. break;
  1003. case 81: //邀请/公务活动
  1004. Grp_InvitationOfficialActivities invitationOfficialActivities = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1005. if (invitationOfficialActivities != null)
  1006. {
  1007. string ioaCurrencyCode = "Unknown";
  1008. string ioaCurrencyName= "Unknown";
  1009. var currencyData = currencyItems.Where(s => s.Id == invitationOfficialActivities.Currency && s.IsDel == 0).FirstOrDefault();
  1010. if (currencyData != null)
  1011. {
  1012. ioaCurrencyCode = currencyData.Name;
  1013. ioaCurrencyName = currencyData.Remark;
  1014. }
  1015. _detail.PriceNameContent = invitationOfficialActivities.InviterArea;
  1016. _detail.PriceMsgContent = "邀请费用:" + invitationOfficialActivities.InviteCosts + " "+ ioaCurrencyCode + "("+ ioaCurrencyName+ ")<br/>" +
  1017. "活动费用:- <br/>" +
  1018. "备注:" + invitationOfficialActivities.Remark + "<br/>";
  1019. }
  1020. break;
  1021. case 82: //团组客户保险
  1022. Grp_Customers customers = _Customers.Where(s => s.Id == entity.Id && s.IsDel == 0).FirstOrDefault();
  1023. if (customers != null)
  1024. {
  1025. _detail.PriceNameContent = customers.ClientName;
  1026. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1027. }
  1028. break;
  1029. case 85: //机票预订
  1030. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1031. if (jpRes != null)
  1032. {
  1033. string FlightsDescription = jpRes.FlightsDescription;
  1034. string PriceDescription = jpRes.PriceDescription;
  1035. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1036. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1037. }
  1038. break;
  1039. case 98://其他款项
  1040. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1041. if (gdpRes != null)
  1042. {
  1043. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1044. _detail.PriceNameContent = gdpRes.PriceName;
  1045. }
  1046. break;
  1047. case 285://收款退还Fin_PaymentRefundAndOtherMoney
  1048. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1049. if (refundAndOtherMoney != null)
  1050. {
  1051. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1052. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1053. }
  1054. break;
  1055. case 751://酒店早餐
  1056. break;
  1057. default:
  1058. break;
  1059. }
  1060. /*
  1061. * 申请人
  1062. */
  1063. string operatorName = " - ";
  1064. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1065. if (_opUser != null)
  1066. {
  1067. operatorName = _opUser.CnName;
  1068. }
  1069. _detail.OperatorName = operatorName;
  1070. /*
  1071. * 审核人
  1072. */
  1073. string auditOperatorName = "Unknown";
  1074. if (entity.AuditGMOperate == 0)
  1075. auditOperatorName = " - ";
  1076. else if (entity.AuditGMOperate == 4)
  1077. auditOperatorName = "自动审核";
  1078. else
  1079. {
  1080. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1081. if (_adUser != null)
  1082. {
  1083. auditOperatorName = _adUser.CnName;
  1084. }
  1085. }
  1086. _detail.AuditOperatorName = auditOperatorName;
  1087. /*
  1088. * 超预算比例
  1089. */
  1090. string overBudgetStr = "";
  1091. if (entity.ExceedBudget == -1)
  1092. overBudgetStr = sdPriceName.Name + "尚无预算";
  1093. else if (entity.ExceedBudget == 0)
  1094. overBudgetStr = "未超预算";
  1095. else
  1096. overBudgetStr = entity.ExceedBudget.ToString("P");
  1097. _detail.OverBudget = overBudgetStr;
  1098. /*
  1099. * 费用总计
  1100. */
  1101. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1102. {
  1103. CurrencyId = entity.PaymentCurrency,
  1104. CurrencyName = PaymentCurrency_WaitPay,
  1105. AmountPayable = entity.PayMoney,
  1106. ThisPayment = CurrPayStr,
  1107. BalancePayment = BalanceStr,
  1108. AuditedFunds = CurrPayStr
  1109. });
  1110. _detail.IsAuditGM = entity.IsAuditGM;
  1111. detailList.Add(_detail);
  1112. }
  1113. #endregion
  1114. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1115. /*
  1116. * 下方描述处理
  1117. */
  1118. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1119. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1120. if (ccpCurrencyPrice != null)
  1121. {
  1122. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1123. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1124. }
  1125. else
  1126. {
  1127. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1128. }
  1129. string amountPayableStr = string.Format(@"应付款总金额: ");
  1130. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1131. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1132. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1133. foreach (var item in nonDuplicat)
  1134. {
  1135. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1136. if (strs.Count > 0)
  1137. {
  1138. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1139. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1140. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1141. //单独处理此次付款金额
  1142. if (item.CurrencyId == 836) //人名币
  1143. {
  1144. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1145. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1146. }
  1147. else
  1148. {
  1149. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|","0.00", item.CurrencyName);
  1150. }
  1151. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1152. //单独处理已审核费用
  1153. if (item.CurrencyId == 836) //人名币
  1154. {
  1155. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1156. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1157. }
  1158. else
  1159. {
  1160. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1161. }
  1162. }
  1163. }
  1164. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1165. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1166. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1167. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1168. var _view1 = new
  1169. {
  1170. PageFuncAuth = pageFunAuthView,
  1171. Data = _view
  1172. };
  1173. return Ok(JsonView(_view1));
  1174. }
  1175. catch (Exception ex)
  1176. {
  1177. return Ok(JsonView(false, ex.Message));
  1178. }
  1179. }
  1180. /// <summary>
  1181. /// 费用审核
  1182. /// 修改团组费用审核状态
  1183. /// </summary>
  1184. /// <param name="_dto">参数Json字符串</param>
  1185. /// <returns></returns>
  1186. [HttpPost]
  1187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1188. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1189. {
  1190. #region 参数验证
  1191. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1192. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1193. #endregion
  1194. #region 页面操作权限验证
  1195. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1196. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1197. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1198. #endregion
  1199. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1200. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1201. DateTime dtNow = DateTime.Now;
  1202. _groupRepository.BeginTran();
  1203. int rst = 0;
  1204. foreach (var item in idList)
  1205. {
  1206. int CreditId = int.Parse(item);
  1207. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1208. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1209. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1210. .SetColumns(it => it.AuditGMDate == dtNow.ToString())
  1211. .Where(s => s.Id == CreditId)
  1212. .ExecuteCommandAsync();
  1213. if (result < 1)
  1214. {
  1215. rst = -1;
  1216. _groupRepository.RollbackTran();
  1217. return Ok(JsonView(false, "保存失败并回滚!"));
  1218. }
  1219. else
  1220. {
  1221. }
  1222. }
  1223. _groupRepository.CommitTran();
  1224. if (rst == 0)
  1225. {
  1226. return Ok(JsonView(true, "保存成功!"));
  1227. }
  1228. return Ok(JsonView(false, "保存失败!"));
  1229. }
  1230. #endregion
  1231. #region 机票费用录入
  1232. /// <summary>
  1233. /// 机票录入当前登录人可操作团组
  1234. /// </summary>
  1235. /// <param name="dto"></param>
  1236. /// <returns></returns>
  1237. [HttpPost]
  1238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1239. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1240. {
  1241. try
  1242. {
  1243. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1244. if (groupData.Code != 0)
  1245. {
  1246. return Ok(JsonView(false, groupData.Msg));
  1247. }
  1248. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1249. }
  1250. catch (Exception ex)
  1251. {
  1252. return Ok(JsonView(false, "程序错误!"));
  1253. throw;
  1254. }
  1255. }
  1256. /// <summary>
  1257. /// 机票费用录入列表
  1258. /// </summary>
  1259. /// <param name="dto"></param>
  1260. /// <returns></returns>
  1261. [HttpPost]
  1262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1263. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1264. {
  1265. try
  1266. {
  1267. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1268. if (groupData.Code != 0)
  1269. {
  1270. return Ok(JsonView(false, groupData.Msg));
  1271. }
  1272. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1273. }
  1274. catch (Exception ex)
  1275. {
  1276. return Ok(JsonView(false, "程序错误!"));
  1277. throw;
  1278. }
  1279. }
  1280. /// <summary>
  1281. /// 根据id查询费用录入信息
  1282. /// </summary>
  1283. /// <param name="dto"></param>
  1284. /// <returns></returns>
  1285. [HttpPost]
  1286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1287. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1288. {
  1289. try
  1290. {
  1291. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1292. if (groupData.Code != 0)
  1293. {
  1294. return Ok(JsonView(false, groupData.Msg));
  1295. }
  1296. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1297. }
  1298. catch (Exception ex)
  1299. {
  1300. return Ok(JsonView(false, "程序错误!"));
  1301. throw;
  1302. }
  1303. }
  1304. /// <summary>
  1305. /// 机票费用录入操作(Status:1.新增,2.修改)
  1306. /// </summary>
  1307. /// <param name="dto"></param>
  1308. /// <returns></returns>
  1309. [HttpPost]
  1310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1311. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1312. {
  1313. try
  1314. {
  1315. Result groupData = await _airTicketResRep.OpAirTicketRes(dto);
  1316. if (groupData.Code != 0)
  1317. {
  1318. return Ok(JsonView(false, groupData.Msg));
  1319. }
  1320. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1321. }
  1322. catch (Exception ex)
  1323. {
  1324. return Ok(JsonView(false, "程序错误!"));
  1325. throw;
  1326. }
  1327. }
  1328. /// <summary>
  1329. /// 根据舱位类型查询接团客户名单信息
  1330. /// </summary>
  1331. /// <param name="dto"></param>
  1332. /// <returns></returns>
  1333. [HttpPost]
  1334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1335. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1336. {
  1337. try
  1338. {
  1339. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1340. if (crm_Groups.Count != 0)
  1341. {
  1342. List<dynamic> Customer = new List<dynamic>();
  1343. foreach (var item in crm_Groups)
  1344. {
  1345. var data = new
  1346. {
  1347. Id = item.Id,
  1348. Pinyin = item.Pinyin,
  1349. Name = item.LastName + item.FirstName
  1350. };
  1351. Customer.Add(data);
  1352. }
  1353. return Ok(JsonView(true, "查询成功!", Customer));
  1354. }
  1355. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1356. }
  1357. catch (Exception ex)
  1358. {
  1359. return Ok(JsonView(false, "程序错误!"));
  1360. throw;
  1361. }
  1362. }
  1363. /// <summary>
  1364. /// 机票费用录入,删除
  1365. /// </summary>
  1366. /// <param name="dto"></param>
  1367. /// <returns></returns>
  1368. [HttpPost]
  1369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1370. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1371. {
  1372. try
  1373. {
  1374. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1375. if (!res)
  1376. {
  1377. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1378. {
  1379. IsDel = 1,
  1380. DeleteUserId = dto.DeleteUserId,
  1381. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1382. }).ExecuteCommandAsync();
  1383. return Ok(JsonView(false, "删除失败"));
  1384. }
  1385. return Ok(JsonView(true, "删除成功!"));
  1386. }
  1387. catch (Exception ex)
  1388. {
  1389. return Ok(JsonView(false, "程序错误!"));
  1390. throw;
  1391. }
  1392. }
  1393. /// <summary>
  1394. /// 导出机票录入报表
  1395. /// </summary>
  1396. /// <param name="dto"></param>
  1397. /// <returns></returns>
  1398. [HttpPost]
  1399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1400. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  1401. {
  1402. try
  1403. {
  1404. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1405. if (groupData.Code != 0)
  1406. {
  1407. return Ok(JsonView(false, groupData.Msg));
  1408. }
  1409. else
  1410. {
  1411. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1412. if (AirTicketReservations.Count != 0)
  1413. {
  1414. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1415. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1416. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1417. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1418. WorkbookDesigner designer = new WorkbookDesigner();
  1419. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1420. decimal countCost = 0;
  1421. foreach (var item in AirTicketReservations)
  1422. {
  1423. if (item.BankType == "其他")
  1424. {
  1425. item.BankNo = "--";
  1426. }
  1427. else
  1428. {
  1429. item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
  1430. }
  1431. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1432. item.Price = System.Decimal.Round(item.Price, 2);
  1433. countCost += Convert.ToDecimal(item.Price);
  1434. }
  1435. designer.SetDataSource("Export", AirTicketReservations);
  1436. designer.SetDataSource("ExportDiCode", diCode);
  1437. designer.SetDataSource("ExportDiName", diName);
  1438. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1439. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1440. designer.Process();
  1441. string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  1442. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1443. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1444. return Ok(JsonView(true, "成功", url = rst));
  1445. }
  1446. else
  1447. {
  1448. return Ok(JsonView(false, "暂无数据!"));
  1449. }
  1450. }
  1451. }
  1452. catch (Exception ex)
  1453. {
  1454. return Ok(JsonView(false, "程序错误!"));
  1455. throw;
  1456. }
  1457. }
  1458. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1459. /// <summary>
  1460. /// 行程单导出
  1461. /// </summary>
  1462. /// <param name="dto"></param>
  1463. /// <returns></returns>
  1464. [HttpPost]
  1465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1466. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1467. {
  1468. try
  1469. {
  1470. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1471. if (groupData.Code != 0)
  1472. {
  1473. return Ok(JsonView(false, groupData.Msg));
  1474. }
  1475. else
  1476. {
  1477. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1478. if (dto.Language == "CN")
  1479. {
  1480. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1481. DocumentBuilder builder = new DocumentBuilder(doc);
  1482. int tableIndex = 0;//表格索引
  1483. //得到文档中的第一个表格
  1484. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1485. foreach (var item in _AirTicketReservations)
  1486. {
  1487. #region 处理固定数据
  1488. string[] FlightsCode = item.FlightsCode.Split('/');
  1489. if (FlightsCode.Length != 0)
  1490. {
  1491. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1492. if (_AirCompany != null)
  1493. {
  1494. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1495. }
  1496. else
  1497. {
  1498. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1499. }
  1500. }
  1501. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1502. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1503. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1504. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1505. string name = "";
  1506. foreach (string clientName in nameArray)
  1507. {
  1508. if (!name.Contains(clientName))
  1509. {
  1510. name += clientName + ",";
  1511. }
  1512. }
  1513. if (!string.IsNullOrWhiteSpace(name))
  1514. {
  1515. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1516. }
  1517. else
  1518. {
  1519. table.Range.Bookmarks["ClientName"].Text = "--";
  1520. }
  1521. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1522. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1523. table.Range.Bookmarks["JointTicket"].Text = "--";
  1524. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1525. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1526. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1527. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1528. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1529. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1530. #endregion
  1531. #region 循环数据处理
  1532. List<AirInfo> airs = new List<AirInfo>();
  1533. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1534. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1535. for (int i = 0; i < FlightsCode.Length; i++)
  1536. {
  1537. AirInfo air = new AirInfo();
  1538. string[] tempstr = DayArray[i]
  1539. .Replace("\r\n", string.Empty)
  1540. .Replace("\\r\\n", string.Empty)
  1541. .TrimStart().TrimEnd()
  1542. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1543. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1544. string starCity = "";
  1545. if (star_Three != null)
  1546. {
  1547. starCity = star_Three.AirPort;
  1548. }
  1549. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1550. string EndCity = "";
  1551. if (End_Three != null)
  1552. {
  1553. EndCity = End_Three.AirPort;
  1554. }
  1555. air.Destination = starCity + "/" + EndCity;
  1556. air.Flight = FlightsCode[i];
  1557. air.SeatingClass = item.CTypeName;
  1558. string dateTime = tempstr[2];
  1559. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1560. air.FlightDate = DateTemp;
  1561. air.DepartureTime = tempstr[5];
  1562. air.LandingTime = tempstr[6];
  1563. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1564. air.TicketStatus = "--";
  1565. air.Luggage = "--";
  1566. air.DepartureTerminal = "--";
  1567. air.LandingTerminal = "--";
  1568. airs.Add(air);
  1569. }
  1570. int row = 13;
  1571. for (int i = 0; i < airs.Count; i++)
  1572. {
  1573. if (airs.Count > 2)
  1574. {
  1575. for (int j = 0; j < airs.Count - 2; j++)
  1576. {
  1577. var CopyRow = table.Rows[12].Clone(true);
  1578. table.Rows.Add(CopyRow);
  1579. }
  1580. }
  1581. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1582. int index = 0;
  1583. foreach (PropertyInfo property in properties)
  1584. {
  1585. string value = property.GetValue(airs[i]).ToString();
  1586. Cell ishcel0 = table.Rows[row].Cells[index];
  1587. Paragraph p = new Paragraph(doc);
  1588. string s = value;
  1589. p.AppendChild(new Run(doc, s));
  1590. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1591. ishcel0.AppendChild(p);
  1592. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1593. index++;
  1594. }
  1595. row++;
  1596. }
  1597. #endregion
  1598. Paragraph lastParagraph = new Paragraph(doc);
  1599. //第一个表格末尾加段落
  1600. table.ParentNode.InsertAfter(lastParagraph, table);
  1601. //复制第一个表格
  1602. Table cloneTable = (Table)table.Clone(true);
  1603. //在文档末尾段落后面加入复制的表格
  1604. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1605. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1606. {
  1607. int rownewsIndex = 13;
  1608. for (int i = 0; i < 2; i++)
  1609. {
  1610. var CopyRow = table.Rows[12].Clone(true);
  1611. table.Rows.RemoveAt(13);
  1612. table.Rows.Add(CopyRow);
  1613. rownewsIndex++;
  1614. }
  1615. }
  1616. else
  1617. {
  1618. table.Rows.RemoveAt(12);
  1619. }
  1620. cloneTable.Rows.RemoveAt(12);
  1621. }
  1622. if (_AirTicketReservations.Count != 0)
  1623. {
  1624. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1625. if (FlightsCode.Length != 0)
  1626. {
  1627. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1628. if (_AirCompany != null)
  1629. {
  1630. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1631. }
  1632. else
  1633. {
  1634. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1635. }
  1636. }
  1637. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1638. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1639. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1640. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1641. string name = "";
  1642. foreach (string clientName in nameArray)
  1643. {
  1644. if (!name.Contains(clientName))
  1645. {
  1646. name += clientName + ",";
  1647. }
  1648. }
  1649. if (!string.IsNullOrWhiteSpace(name))
  1650. {
  1651. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1652. }
  1653. else
  1654. {
  1655. table.Range.Bookmarks["ClientName"].Text = "--";
  1656. }
  1657. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1658. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1659. table.Range.Bookmarks["JointTicket"].Text = "--";
  1660. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1661. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1662. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1663. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1664. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1665. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1666. }
  1667. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1668. //保存合并后的文档
  1669. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  1670. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1671. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1672. return Ok(JsonView(true, "成功!", rst));
  1673. }
  1674. else
  1675. {
  1676. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  1677. DocumentBuilder builder = new DocumentBuilder(doc);
  1678. int tableIndex = 0;//表格索引
  1679. //得到文档中的第一个表格
  1680. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1681. List<string> texts = new List<string>();
  1682. foreach (var item in _AirTicketReservations)
  1683. {
  1684. string[] FlightsCode = item.FlightsCode.Split('/');
  1685. if (FlightsCode.Length != 0)
  1686. {
  1687. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1688. if (_AirCompany != null)
  1689. {
  1690. if (!transDic.ContainsKey(_AirCompany.CnName))
  1691. {
  1692. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  1693. }
  1694. }
  1695. else
  1696. {
  1697. if (!transDic.ContainsKey("--"))
  1698. {
  1699. transDic.Add("--", "--");
  1700. }
  1701. }
  1702. }
  1703. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1704. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1705. string name = "";
  1706. foreach (string clientName in nameArray)
  1707. {
  1708. name += clientName + ",";
  1709. }
  1710. if (!texts.Contains(name))
  1711. {
  1712. texts.Add(name);
  1713. }
  1714. List<AirInfo> airs = new List<AirInfo>();
  1715. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1716. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1717. for (int i = 0; i < FlightsCode.Length; i++)
  1718. {
  1719. AirInfo air = new AirInfo();
  1720. string[] tempstr = DayArray[i]
  1721. .Replace("\r\n", string.Empty)
  1722. .Replace("\\r\\n", string.Empty)
  1723. .TrimStart().TrimEnd()
  1724. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1725. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1726. if (star_Three != null)
  1727. {
  1728. if (!transDic.ContainsKey(star_Three.AirPort))
  1729. {
  1730. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  1731. }
  1732. }
  1733. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1734. if (End_Three != null)
  1735. {
  1736. if (!transDic.ContainsKey(End_Three.AirPort))
  1737. {
  1738. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  1739. }
  1740. }
  1741. if (!texts.Contains(item.CTypeName))
  1742. {
  1743. texts.Add(item.CTypeName);
  1744. }
  1745. }
  1746. }
  1747. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  1748. if (transData.Count > 0)
  1749. {
  1750. foreach (TranslateResult item in transData)
  1751. {
  1752. if (!transDic.ContainsKey(item.Query))
  1753. {
  1754. transDic.Add(item.Query, item.Translation);
  1755. }
  1756. }
  1757. }
  1758. foreach (var item in _AirTicketReservations)
  1759. {
  1760. #region 处理固定数据
  1761. string[] FlightsCode = item.FlightsCode.Split('/');
  1762. if (FlightsCode.Length != 0)
  1763. {
  1764. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1765. if (_AirCompany != null)
  1766. {
  1767. string str = "--";
  1768. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1769. if (!string.IsNullOrEmpty(translateResult))
  1770. {
  1771. str = translateResult;
  1772. str = _airTicketResRep.Processing(str);
  1773. }
  1774. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1775. }
  1776. else
  1777. {
  1778. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1779. }
  1780. }
  1781. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1782. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1783. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1784. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1785. string names = "";
  1786. foreach (string clientName in nameArray)
  1787. {
  1788. names += clientName + ",";
  1789. }
  1790. if (!string.IsNullOrWhiteSpace(names))
  1791. {
  1792. string str = "--";
  1793. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1794. if (!string.IsNullOrEmpty(translateResult))
  1795. {
  1796. str = translateResult;
  1797. str = _airTicketResRep.Processing(str);
  1798. }
  1799. table.Range.Bookmarks["ClientName"].Text = str;
  1800. }
  1801. else
  1802. {
  1803. table.Range.Bookmarks["ClientName"].Text = "--";
  1804. }
  1805. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1806. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1807. table.Range.Bookmarks["JointTicket"].Text = "--";
  1808. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1809. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1810. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1811. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1812. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1813. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1814. #endregion
  1815. #region 循环数据处理
  1816. List<AirInfo> airs = new List<AirInfo>();
  1817. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1818. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1819. for (int i = 0; i < FlightsCode.Length; i++)
  1820. {
  1821. AirInfo air = new AirInfo();
  1822. string[] tempstr = DayArray[i]
  1823. .Replace("\r\n", string.Empty)
  1824. .Replace("\\r\\n", string.Empty)
  1825. .TrimStart().TrimEnd()
  1826. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1827. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1828. string starCity = "";
  1829. if (star_Three != null)
  1830. {
  1831. string str2 = "--";
  1832. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  1833. if (!string.IsNullOrEmpty(translateResult2))
  1834. {
  1835. str2 = translateResult2;
  1836. str2 = _airTicketResRep.Processing(str2);
  1837. }
  1838. starCity = str2;
  1839. }
  1840. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1841. string EndCity = "";
  1842. if (End_Three != null)
  1843. {
  1844. string str1 = "--";
  1845. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  1846. if (!string.IsNullOrEmpty(translateResult1))
  1847. {
  1848. str1 = translateResult1;
  1849. str1 = _airTicketResRep.Processing(str1);
  1850. }
  1851. EndCity = str1;
  1852. }
  1853. air.Destination = starCity + "/" + EndCity;
  1854. air.Flight = FlightsCode[i];
  1855. string str = "--";
  1856. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  1857. if (!string.IsNullOrEmpty(translateResult))
  1858. {
  1859. str = translateResult;
  1860. str = _airTicketResRep.Processing(str);
  1861. }
  1862. air.SeatingClass = str;
  1863. string dateTime = tempstr[2];
  1864. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1865. air.FlightDate = DateTemp;
  1866. air.DepartureTime = tempstr[5];
  1867. air.LandingTime = tempstr[6];
  1868. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1869. air.TicketStatus = "--";
  1870. air.Luggage = "--";
  1871. air.DepartureTerminal = "--";
  1872. air.LandingTerminal = "--";
  1873. airs.Add(air);
  1874. }
  1875. int row = 13;
  1876. for (int i = 0; i < airs.Count; i++)
  1877. {
  1878. if (airs.Count > 2)
  1879. {
  1880. for (int j = 0; j < airs.Count - 2; j++)
  1881. {
  1882. var CopyRow = table.Rows[12].Clone(true);
  1883. table.Rows.Add(CopyRow);
  1884. }
  1885. }
  1886. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1887. int index = 0;
  1888. foreach (PropertyInfo property in properties)
  1889. {
  1890. string value = property.GetValue(airs[i]).ToString();
  1891. Cell ishcel0 = table.Rows[row].Cells[index];
  1892. Paragraph p = new Paragraph(doc);
  1893. string s = value;
  1894. p.AppendChild(new Run(doc, s));
  1895. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1896. ishcel0.AppendChild(p);
  1897. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1898. //ishcel0.CellFormat.VerticalAlignment=
  1899. index++;
  1900. }
  1901. row++;
  1902. }
  1903. #endregion
  1904. Paragraph lastParagraph = new Paragraph(doc);
  1905. //第一个表格末尾加段落
  1906. table.ParentNode.InsertAfter(lastParagraph, table);
  1907. //复制第一个表格
  1908. Table cloneTable = (Table)table.Clone(true);
  1909. //在文档末尾段落后面加入复制的表格
  1910. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1911. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1912. {
  1913. int rownewsIndex = 13;
  1914. for (int i = 0; i < 2; i++)
  1915. {
  1916. var CopyRow = table.Rows[12].Clone(true);
  1917. table.Rows.RemoveAt(13);
  1918. table.Rows.Add(CopyRow);
  1919. rownewsIndex++;
  1920. }
  1921. }
  1922. else
  1923. {
  1924. table.Rows.RemoveAt(12);
  1925. }
  1926. cloneTable.Rows.RemoveAt(12);
  1927. }
  1928. if (_AirTicketReservations.Count != 0)
  1929. {
  1930. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1931. if (FlightsCode.Length != 0)
  1932. {
  1933. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1934. if (_AirCompany != null)
  1935. {
  1936. string str = "--";
  1937. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1938. if (!string.IsNullOrEmpty(translateResult))
  1939. {
  1940. str = translateResult;
  1941. str = _airTicketResRep.Processing(str);
  1942. }
  1943. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1944. }
  1945. else
  1946. {
  1947. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1948. }
  1949. }
  1950. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1951. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1952. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1953. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1954. string names = "";
  1955. foreach (string clientName in nameArray)
  1956. {
  1957. names += clientName + ",";
  1958. }
  1959. if (!string.IsNullOrWhiteSpace(names))
  1960. {
  1961. string str = "--";
  1962. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1963. if (!string.IsNullOrEmpty(translateResult))
  1964. {
  1965. str = translateResult;
  1966. str = _airTicketResRep.Processing(str);
  1967. }
  1968. table.Range.Bookmarks["ClientName"].Text = str;
  1969. }
  1970. else
  1971. {
  1972. table.Range.Bookmarks["ClientName"].Text = "--";
  1973. }
  1974. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1975. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1976. table.Range.Bookmarks["JointTicket"].Text = "--";
  1977. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1978. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1979. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1980. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1981. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1982. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1983. }
  1984. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1985. //保存合并后的文档
  1986. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  1987. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1988. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1989. return Ok(JsonView(true, "成功!", rst));
  1990. }
  1991. }
  1992. }
  1993. catch (Exception ex)
  1994. {
  1995. return Ok(JsonView(false, "程序错误!"));
  1996. throw;
  1997. }
  1998. }
  1999. #endregion
  2000. #region 团组增减款项
  2001. /// <summary>
  2002. /// 团组增减款项下拉框绑定
  2003. /// </summary>
  2004. /// <param name="dto"></param>
  2005. /// <returns></returns>
  2006. [HttpPost]
  2007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2008. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2009. {
  2010. try
  2011. {
  2012. Result groupData = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  2013. if (groupData.Code != 0)
  2014. {
  2015. return Ok(JsonView(false, groupData.Msg));
  2016. }
  2017. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2018. }
  2019. catch (Exception ex)
  2020. {
  2021. return Ok(JsonView(false, "程序错误!"));
  2022. throw;
  2023. }
  2024. }
  2025. /// <summary>
  2026. /// 根据团组Id查询团组增减款项
  2027. /// </summary>
  2028. /// <param name="dto"></param>
  2029. /// <returns></returns>
  2030. [HttpPost]
  2031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2032. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2033. {
  2034. try
  2035. {
  2036. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  2037. if (groupData.Code != 0)
  2038. {
  2039. return Ok(JsonView(false, groupData.Msg));
  2040. }
  2041. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2042. }
  2043. catch (Exception ex)
  2044. {
  2045. return Ok(JsonView(false, "程序错误!"));
  2046. throw;
  2047. }
  2048. }
  2049. /// <summary>
  2050. /// 团组增减款项操作(Status:1.新增,2.修改)
  2051. /// </summary>
  2052. /// <param name="dto"></param>
  2053. /// <returns></returns>
  2054. [HttpPost]
  2055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2056. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2057. {
  2058. try
  2059. {
  2060. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2061. if (groupData.Code != 0)
  2062. {
  2063. return Ok(JsonView(false, groupData.Msg));
  2064. }
  2065. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2066. }
  2067. catch (Exception ex)
  2068. {
  2069. return Ok(JsonView(false, "程序错误!"));
  2070. throw;
  2071. }
  2072. }
  2073. /// <summary>
  2074. /// 团组增减款项操作 删除
  2075. /// </summary>
  2076. /// <param name="dto"></param>
  2077. /// <returns></returns>
  2078. [HttpPost]
  2079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2080. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2081. {
  2082. try
  2083. {
  2084. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  2085. if (!res)
  2086. {
  2087. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  2088. {
  2089. IsDel = 1,
  2090. DeleteUserId = dto.DeleteUserId,
  2091. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2092. }).ExecuteCommandAsync();
  2093. return Ok(JsonView(false, "删除失败"));
  2094. }
  2095. return Ok(JsonView(true, "删除成功!"));
  2096. }
  2097. catch (Exception ex)
  2098. {
  2099. return Ok(JsonView(false, "程序错误!"));
  2100. throw;
  2101. }
  2102. }
  2103. /// <summary>
  2104. /// 根据团组增减款项Id查询
  2105. /// </summary>
  2106. /// <param name="dto"></param>
  2107. /// <returns></returns>
  2108. [HttpPost]
  2109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2110. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2111. {
  2112. try
  2113. {
  2114. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  2115. if (groupData.Code != 0)
  2116. {
  2117. return Ok(JsonView(false, groupData.Msg));
  2118. }
  2119. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2120. }
  2121. catch (Exception ex)
  2122. {
  2123. return Ok(JsonView(false, "程序错误!"));
  2124. throw;
  2125. }
  2126. }
  2127. #endregion
  2128. #region 文件上传、删除
  2129. /// <summary>
  2130. /// region 文件上传 可以带参数
  2131. /// </summary>
  2132. /// <param name="file"></param>
  2133. /// <returns></returns>
  2134. [HttpPost]
  2135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2136. public async Task<IActionResult> UploadProject(IFormFile file)
  2137. {
  2138. try
  2139. {
  2140. var TypeName = Request.Headers["TypeName"].ToString();
  2141. if (file != null)
  2142. {
  2143. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2144. //文件名称
  2145. string projectFileName = file.FileName;
  2146. //上传的文件的路径
  2147. string filePath = "";
  2148. if (TypeName == "A")//A代表团组增减款项
  2149. {
  2150. if (!Directory.Exists(fileDir))
  2151. {
  2152. Directory.CreateDirectory(fileDir);
  2153. }
  2154. //上传的文件的路径
  2155. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2156. }
  2157. else if (TypeName == "B")//B代表商邀相关文件
  2158. {
  2159. if (!Directory.Exists(fileDir))
  2160. {
  2161. Directory.CreateDirectory(fileDir);
  2162. }
  2163. //上传的文件的路径
  2164. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2165. }
  2166. using (FileStream fs = System.IO.File.Create(filePath))
  2167. {
  2168. file.CopyTo(fs);
  2169. fs.Flush();
  2170. }
  2171. return Ok(JsonView(true, "上传成功!", projectFileName));
  2172. }
  2173. else
  2174. {
  2175. return Ok(JsonView(false, "上传失败!"));
  2176. }
  2177. }
  2178. catch (Exception ex)
  2179. {
  2180. return Ok(JsonView(false, "程序错误!"));
  2181. throw;
  2182. }
  2183. }
  2184. /// <summary>
  2185. /// 删除指定文件
  2186. /// </summary>
  2187. /// <param name="dto"></param>
  2188. /// <returns></returns>
  2189. [HttpPost]
  2190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2191. public async Task<IActionResult> DelFile(DelFileDto dto)
  2192. {
  2193. try
  2194. {
  2195. var TypeName = Request.Headers["TypeName"].ToString();
  2196. string filePath = "";
  2197. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2198. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2199. int id = 0;
  2200. if (TypeName == "A")
  2201. {
  2202. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2203. // 删除该文件
  2204. System.IO.File.Delete(filePath);
  2205. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2206. }
  2207. else if (TypeName == "B")
  2208. {
  2209. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2210. // 删除该文件
  2211. System.IO.File.Delete(filePath);
  2212. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2213. }
  2214. if (id != 0)
  2215. {
  2216. return Ok(JsonView(true, "成功!"));
  2217. }
  2218. else
  2219. {
  2220. return Ok(JsonView(false, "失败!"));
  2221. }
  2222. }
  2223. catch (Exception ex)
  2224. {
  2225. return Ok(JsonView(false, "程序错误!"));
  2226. throw;
  2227. }
  2228. }
  2229. #endregion
  2230. #region 商邀费用录入
  2231. /// <summary>
  2232. /// 根据团组Id查询商邀费用列表
  2233. /// </summary>
  2234. /// <param name="dto"></param>
  2235. /// <returns></returns>
  2236. [HttpPost]
  2237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2238. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2239. {
  2240. try
  2241. {
  2242. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2243. if (groupData.Code != 0)
  2244. {
  2245. return Ok(JsonView(false, groupData.Msg));
  2246. }
  2247. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2248. }
  2249. catch (Exception ex)
  2250. {
  2251. return Ok(JsonView(false, "程序错误!"));
  2252. throw;
  2253. }
  2254. }
  2255. /// <summary>
  2256. /// 根据商邀费用ID查询C表和商邀费用数据
  2257. /// </summary>
  2258. /// <param name="dto"></param>
  2259. /// <returns></returns>
  2260. [HttpPost]
  2261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2262. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2263. {
  2264. try
  2265. {
  2266. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2267. if (groupData.Code != 0)
  2268. {
  2269. return Ok(JsonView(false, groupData.Msg));
  2270. }
  2271. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2272. }
  2273. catch (Exception ex)
  2274. {
  2275. return Ok(JsonView(false, "程序错误!"));
  2276. throw;
  2277. }
  2278. }
  2279. /// <summary>
  2280. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2281. /// </summary>
  2282. /// <param name="dto"></param>
  2283. /// <returns></returns>
  2284. [HttpPost]
  2285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2286. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2287. {
  2288. try
  2289. {
  2290. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto);
  2291. if (groupData.Code != 0)
  2292. {
  2293. return Ok(JsonView(false, groupData.Msg));
  2294. }
  2295. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2296. }
  2297. catch (Exception ex)
  2298. {
  2299. return Ok(JsonView(false, "程序错误!"));
  2300. throw;
  2301. }
  2302. }
  2303. /// <summary>
  2304. /// 商邀删除
  2305. /// </summary>
  2306. /// <param name="dto"></param>
  2307. /// <returns></returns>
  2308. [HttpPost]
  2309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2310. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2311. {
  2312. try
  2313. {
  2314. var res = await _InvitationOfficialActivitiesRep.SoftDeleteByIdAsync<Grp_InvitationOfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  2315. if (!res)
  2316. {
  2317. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 81).SetColumns(a => new Grp_CreditCardPayment()
  2318. {
  2319. IsDel = 1,
  2320. DeleteUserId = dto.DeleteUserId,
  2321. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2322. }).ExecuteCommandAsync();
  2323. return Ok(JsonView(false, "删除失败"));
  2324. }
  2325. return Ok(JsonView(true, "删除成功!"));
  2326. }
  2327. catch (Exception ex)
  2328. {
  2329. return Ok(JsonView(false, "程序错误!"));
  2330. throw;
  2331. }
  2332. }
  2333. #endregion
  2334. #region 团组英文资料
  2335. /// <summary>
  2336. /// 查询团组英文所有资料
  2337. /// </summary>
  2338. /// <param name="dto"></param>
  2339. /// <returns></returns>
  2340. [HttpPost]
  2341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2342. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2343. {
  2344. try
  2345. {
  2346. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  2347. if (groupData.Code != 0)
  2348. {
  2349. return Ok(JsonView(false, groupData.Msg));
  2350. }
  2351. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2352. }
  2353. catch (Exception ex)
  2354. {
  2355. return Ok(JsonView(false, "程序错误!"));
  2356. throw;
  2357. }
  2358. }
  2359. /// <summary>
  2360. /// 团组英文资料操作(Status:1.新增,2.修改)
  2361. /// </summary>
  2362. /// <param name="dto"></param>
  2363. /// <returns></returns>
  2364. [HttpPost]
  2365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2366. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  2367. {
  2368. try
  2369. {
  2370. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  2371. if (groupData.Code != 0)
  2372. {
  2373. return Ok(JsonView(false, groupData.Msg));
  2374. }
  2375. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2376. }
  2377. catch (Exception ex)
  2378. {
  2379. return Ok(JsonView(false, "程序错误!"));
  2380. throw;
  2381. }
  2382. }
  2383. /// <summary>
  2384. /// 团组英文资料Id查询数据
  2385. /// </summary>
  2386. /// <param name="dto"></param>
  2387. /// <returns></returns>
  2388. [HttpPost]
  2389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2390. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  2391. {
  2392. try
  2393. {
  2394. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  2395. if (_DelegationEnData != null)
  2396. {
  2397. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  2398. }
  2399. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  2400. }
  2401. catch (Exception ex)
  2402. {
  2403. return Ok(JsonView(false, "程序错误!"));
  2404. throw;
  2405. }
  2406. }
  2407. /// <summary>
  2408. /// 团组英文资料删除
  2409. /// </summary>
  2410. /// <param name="dto"></param>
  2411. /// <returns></returns>
  2412. [HttpPost]
  2413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2414. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2415. {
  2416. try
  2417. {
  2418. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2419. if (!res)
  2420. {
  2421. return Ok(JsonView(false, "删除失败"));
  2422. }
  2423. return Ok(JsonView(true, "删除成功!"));
  2424. }
  2425. catch (Exception ex)
  2426. {
  2427. return Ok(JsonView(false, "程序错误!"));
  2428. throw;
  2429. }
  2430. }
  2431. #endregion
  2432. #region 导出邀请函
  2433. /// <summary>
  2434. /// 导出邀请函页面初始化
  2435. /// </summary>
  2436. /// <param name="dto"></param>
  2437. /// <returns></returns>
  2438. [HttpPost]
  2439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2440. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2441. {
  2442. try
  2443. {
  2444. List<Grp_DelegationInfo> grp_Delegations = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToListAsync();
  2445. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2446. if (dto.DiId == 0)
  2447. {
  2448. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2449. }
  2450. else
  2451. {
  2452. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2453. }
  2454. return Ok(JsonView(true, "查询成功!", new
  2455. {
  2456. deleClient = crm_Deles,
  2457. delegations = grp_Delegations
  2458. }));
  2459. }
  2460. catch (Exception ex)
  2461. {
  2462. return Ok(JsonView(false, "程序错误!"));
  2463. throw;
  2464. }
  2465. }
  2466. /// <summary>
  2467. /// 导出邀请函
  2468. /// </summary>
  2469. /// <param name="dto"></param>
  2470. /// <returns></returns>
  2471. [HttpPost]
  2472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2473. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2474. {
  2475. try
  2476. {
  2477. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2478. List<Crm_DeleClient> crm_DeleClients = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2479. List<string> texts = new List<string>();
  2480. if (crm_DeleClients.Count != 0)
  2481. {
  2482. foreach (Crm_DeleClient item in crm_DeleClients)
  2483. {
  2484. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2485. {
  2486. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2487. }
  2488. else
  2489. {
  2490. string name = item.LastName + item.FirstName;
  2491. texts.Add(name);
  2492. }
  2493. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  2494. {
  2495. if (!transDic.ContainsKey(item.Job))
  2496. {
  2497. texts.Add(item.Job);
  2498. }
  2499. }
  2500. if (item.CrmCompanyId != 0)
  2501. {
  2502. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == item.CrmCompanyId && a.IsDel == 0);
  2503. if (!transDic.ContainsKey(crm_Customer.CompanyName))
  2504. {
  2505. texts.Add(crm_Customer.CompanyName);
  2506. }
  2507. }
  2508. }
  2509. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2510. if (transData.Count > 0)
  2511. {
  2512. foreach (TranslateResult item in transData)
  2513. {
  2514. if (!transDic.ContainsKey(item.Query))
  2515. {
  2516. transDic.Add(item.Query, item.Translation);
  2517. }
  2518. }
  2519. }
  2520. List<guestList> list = new List<guestList>();
  2521. foreach (Crm_DeleClient dele in crm_DeleClients)
  2522. {
  2523. guestList guestList = new guestList();
  2524. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  2525. {
  2526. guestList.Name = dele.Pinyin;
  2527. }
  2528. else
  2529. {
  2530. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  2531. guestList.Name = Name;
  2532. }
  2533. if (dele.Sex == 0)
  2534. {
  2535. guestList.Sex = "Male";
  2536. }
  2537. else if (dele.Sex == 1)
  2538. {
  2539. guestList.Sex = "Female";
  2540. }
  2541. guestList.DOB = dele.BirthDay.Replace('-', '.');
  2542. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == dele.CrmCompanyId && a.IsDel == 0);
  2543. string jobName = transDic.Where(s => s.Key == crm_Customer.CompanyName).FirstOrDefault().Value + " " + transDic.Where(s => s.Key == dele.Job).FirstOrDefault().Value;
  2544. guestList.Job = jobName;
  2545. list.Add(guestList);
  2546. }
  2547. //载入模板
  2548. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  2549. DocumentBuilder builder = new DocumentBuilder(doc);
  2550. //获取word里所有表格
  2551. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2552. //获取所填表格的序数
  2553. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2554. var rowStart = tableOne.Rows[0]; //获取第1行
  2555. //循环赋值
  2556. for (int i = 0; i < list.Count; i++)
  2557. {
  2558. builder.MoveToCell(0, i + 1, 0, 0);
  2559. builder.Write(list[i].Name.ToString());
  2560. builder.MoveToCell(0, i + 1, 1, 0);
  2561. builder.Write(list[i].Sex.ToString());
  2562. builder.MoveToCell(0, i + 1, 2, 0);
  2563. builder.Write(list[i].DOB.ToString());
  2564. builder.MoveToCell(0, i + 1, 3, 0);
  2565. builder.Write(list[i].Job.ToString());
  2566. }
  2567. //删除多余行
  2568. while (tableOne.Rows.Count > list.Count + 1)
  2569. {
  2570. tableOne.Rows.RemoveAt(list.Count + 1);
  2571. }
  2572. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2573. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  2574. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  2575. doc.Save(filePath);
  2576. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件" + fileName;
  2577. return Ok(JsonView(true, "成功!", Url));
  2578. }
  2579. else
  2580. {
  2581. return Ok(JsonView(false, "失败,该团组没有客户名单!"));
  2582. }
  2583. }
  2584. catch (Exception ex)
  2585. {
  2586. return Ok(JsonView(false, "程序错误!"));
  2587. throw;
  2588. }
  2589. }
  2590. #endregion
  2591. #region 团组经理模块 出入境费用
  2592. ///// <summary>
  2593. ///// 团组模块 - 出入境费用
  2594. ///// </summary>
  2595. ///// <returns></returns>
  2596. //[HttpPost]
  2597. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2598. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  2599. //{
  2600. // try
  2601. // {
  2602. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  2603. // if (data.Code != 0)
  2604. // {
  2605. // return Ok(JsonView(false, data.Msg));
  2606. // }
  2607. // return Ok(JsonView(true, "查询成功!"));
  2608. // }
  2609. // catch (Exception ex)
  2610. // {
  2611. // return Ok(JsonView(false, ex.Message));
  2612. // throw;
  2613. // }
  2614. //}
  2615. /// <summary>
  2616. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  2617. /// </summary>
  2618. /// <returns></returns>
  2619. [HttpPost]
  2620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2621. public async Task<IActionResult> SetDayAndCostAreaChange()
  2622. {
  2623. try
  2624. {
  2625. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  2626. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  2627. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  2628. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  2629. foreach (var item in unite) //处理交集数据
  2630. {
  2631. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  2632. }
  2633. foreach (var item in merge) //处理差集数据
  2634. {
  2635. int nationalTravelFeeId = 0;
  2636. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  2637. if (cityData != null) nationalTravelFeeId = cityData.Id;
  2638. else
  2639. {
  2640. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  2641. if (countryData != null) nationalTravelFeeId = countryData.Id;
  2642. }
  2643. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  2644. }
  2645. //只更新dayAndCost 的 nationalTravelFeeId;
  2646. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  2647. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  2648. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  2649. }
  2650. catch (Exception ex)
  2651. {
  2652. return Ok(JsonView(false, ex.Message));
  2653. throw;
  2654. }
  2655. }
  2656. /// <summary>
  2657. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  2658. /// </summary>
  2659. /// <returns></returns>
  2660. [HttpPost]
  2661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2662. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  2663. {
  2664. try
  2665. {
  2666. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  2667. string currencySql = string.Format("Select * From Sys_SetData Where STid = 66 And IsDel = 0");
  2668. var currencyData = await _sqlSugar.SqlQueryable<SetDataInfoView>(currencySql).ToListAsync();
  2669. //string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2670. // Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2671. // Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2672. // Where gntf.Isdel = 0");
  2673. //var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2674. return Ok(JsonView(true, "查询成功!", new
  2675. {
  2676. GroupNameData = groupNameData.Data,
  2677. CurrencyData = currencyData,
  2678. //NationalTravelFeeData = nationalTravelFeeData
  2679. }));
  2680. }
  2681. catch (Exception ex)
  2682. {
  2683. return Ok(JsonView(false, ex.Message));
  2684. throw;
  2685. }
  2686. }
  2687. /// <summary>
  2688. /// 团组模块 - 出入境费用 - Info
  2689. /// </summary>
  2690. /// <returns></returns>
  2691. [HttpPost]
  2692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2693. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  2694. {
  2695. try
  2696. {
  2697. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  2698. if (data.Code != 0)
  2699. {
  2700. return Ok(JsonView(false, data.Msg));
  2701. }
  2702. return Ok(JsonView(true, "查询成功!", data.Data));
  2703. }
  2704. catch (Exception ex)
  2705. {
  2706. return Ok(JsonView(false, ex.Message));
  2707. }
  2708. }
  2709. /// <summary>
  2710. /// 团组模块 - 出入境费用 - Add And Update
  2711. /// </summary>
  2712. /// <returns></returns>
  2713. [HttpPost]
  2714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2715. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  2716. {
  2717. try
  2718. {
  2719. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2720. if (data.Code != 0)
  2721. {
  2722. return Ok(JsonView(false, data.Msg));
  2723. }
  2724. return Ok(JsonView(true, data.Msg, data.Data));
  2725. }
  2726. catch (Exception ex)
  2727. {
  2728. return Ok(JsonView(false, ex.Message));
  2729. }
  2730. }
  2731. /// <summary>
  2732. /// 团组模块 - 出入境费用 - 明细表导出
  2733. /// </summary>
  2734. /// <returns></returns>
  2735. [HttpPost]
  2736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2737. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  2738. {
  2739. try
  2740. {
  2741. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2742. if (data.Code != 0)
  2743. {
  2744. return Ok(JsonView(false, data.Msg));
  2745. }
  2746. return Ok(JsonView(true, data.Msg, data.Data));
  2747. }
  2748. catch (Exception ex)
  2749. {
  2750. return Ok(JsonView(false, ex.Message));
  2751. }
  2752. }
  2753. /// <summary>
  2754. /// 团组模块 - 出入境费用 - 子项删除
  2755. /// </summary>
  2756. /// <returns></returns>
  2757. [HttpPost]
  2758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2759. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  2760. {
  2761. try
  2762. {
  2763. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  2764. if (data.Code != 0)
  2765. {
  2766. return Ok(JsonView(false, data.Msg));
  2767. }
  2768. return Ok(JsonView(true, "操作成功!", data.Data));
  2769. }
  2770. catch (Exception ex)
  2771. {
  2772. return Ok(JsonView(false, ex.Message));
  2773. }
  2774. }
  2775. /// <summary>
  2776. /// 团组模块 - 出入境国家费用标准 List
  2777. /// </summary>
  2778. /// <returns></returns>
  2779. [HttpPost]
  2780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2781. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  2782. {
  2783. try
  2784. {
  2785. Stopwatch sw = new Stopwatch();
  2786. sw.Start();
  2787. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2788. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2789. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2790. Where gntf.Isdel = 0");
  2791. var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2792. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  2793. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  2794. //foreach (var item in nationalTravel)
  2795. //{
  2796. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  2797. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  2798. // if (otherData != null)
  2799. // {
  2800. // cityData.Remove(otherData);
  2801. // cityData.Add(otherData);
  2802. // }
  2803. // nationalTravelFeeData1.Add(new
  2804. // {
  2805. // Country = item.Country,
  2806. // CityData = cityData
  2807. // });
  2808. //}
  2809. sw.Stop();
  2810. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  2811. }
  2812. catch (Exception ex)
  2813. {
  2814. return Ok(JsonView(false, ex.Message));
  2815. throw;
  2816. }
  2817. }
  2818. /// <summary>
  2819. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  2820. /// </summary>
  2821. /// <returns></returns>
  2822. [HttpPost]
  2823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2824. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  2825. {
  2826. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  2827. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  2828. List<string> countryData = new List<string>();
  2829. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  2830. countryData = countryData.Distinct().ToList();
  2831. List<dynamic> dataSource = new List<dynamic>();
  2832. foreach (var item in countryData)
  2833. {
  2834. List<string> cityData1 = new List<string>();
  2835. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  2836. var countryData2 = new
  2837. {
  2838. CountryName = item,
  2839. CityData = cityData1
  2840. };
  2841. dataSource.Add(countryData2);
  2842. }
  2843. return Ok(JsonView(true, "查询成功!", dataSource));
  2844. }
  2845. /// <summary>
  2846. /// 团组模块 - 出入境国家费用标准 Page List
  2847. /// </summary>
  2848. /// <returns></returns>
  2849. [HttpPost]
  2850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2851. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  2852. {
  2853. int portId = dto.PortType;
  2854. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2855. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  2856. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  2857. string whereSql = string.Empty;
  2858. if (!string.IsNullOrEmpty(dto.Country))
  2859. {
  2860. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  2861. }
  2862. if (!string.IsNullOrEmpty(dto.City))
  2863. {
  2864. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  2865. }
  2866. string pageSql = string.Format(@"Select * From (
  2867. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  2868. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  2869. From Grp_NationalTravelFee gntf
  2870. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2871. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2872. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  2873. RefAsync<int> total = 0;
  2874. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  2875. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  2876. }
  2877. /// <summary>
  2878. /// 团组模块 - 出入境国家费用标准 根据城市查询
  2879. /// </summary>
  2880. /// <returns></returns>
  2881. [HttpPost]
  2882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2883. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  2884. {
  2885. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  2886. int portId = dto.PortType;
  2887. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2888. string whereSql = string.Empty;
  2889. if (!string.IsNullOrEmpty(dto.Country))
  2890. {
  2891. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  2892. }
  2893. if (!string.IsNullOrEmpty(dto.City))
  2894. {
  2895. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  2896. }
  2897. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  2898. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  2899. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  2900. From Grp_NationalTravelFee gntf
  2901. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2902. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2903. Where gntf.Isdel = 0 {0} ", whereSql);
  2904. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  2905. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  2906. }
  2907. /// <summary>
  2908. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  2909. /// </summary>
  2910. /// <returns></returns>
  2911. [HttpPost]
  2912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2913. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  2914. {
  2915. try
  2916. {
  2917. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  2918. if (data.Code != 0)
  2919. {
  2920. return Ok(JsonView(false, data.Msg));
  2921. }
  2922. return Ok(JsonView(true, "操作成功!", data.Data));
  2923. }
  2924. catch (Exception ex)
  2925. {
  2926. return Ok(JsonView(false, ex.Message));
  2927. }
  2928. }
  2929. /// <summary>
  2930. /// 团组模块 - 出入境国家费用标准 - Del
  2931. /// </summary>
  2932. /// <returns></returns>
  2933. [HttpPost]
  2934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2935. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  2936. {
  2937. try
  2938. {
  2939. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  2940. {
  2941. Id = dto.Id,
  2942. DeleteUserId = dto.DeleteUserId,
  2943. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  2944. IsDel = 1
  2945. };
  2946. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  2947. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  2948. .WhereColumns(it => new { it.Id })
  2949. .ExecuteCommandAsync();
  2950. if (delStatus <= 0)
  2951. {
  2952. return Ok(JsonView(false, "删除失败!"));
  2953. }
  2954. return Ok(JsonView(true, "操作成功!"));
  2955. }
  2956. catch (Exception ex)
  2957. {
  2958. return Ok(JsonView(false, ex.Message));
  2959. }
  2960. }
  2961. #endregion
  2962. #region 签证费用录入
  2963. /// <summary>
  2964. /// 根据diid查询签证费用列表
  2965. /// </summary>
  2966. /// <param name="dto"></param>
  2967. /// <returns></returns>
  2968. [HttpPost]
  2969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2970. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  2971. {
  2972. try
  2973. {
  2974. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  2975. if (groupData.Code != 0)
  2976. {
  2977. return Ok(JsonView(false, groupData.Msg));
  2978. }
  2979. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2980. }
  2981. catch (Exception ex)
  2982. {
  2983. return Ok(JsonView(false, ex.Message));
  2984. }
  2985. }
  2986. /// <summary>
  2987. /// 根据签证费用Id查询单条数据及c表数据
  2988. /// </summary>
  2989. /// <param name="dto"></param>
  2990. /// <returns></returns>
  2991. [HttpPost]
  2992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2993. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  2994. {
  2995. try
  2996. {
  2997. Result groupData = await _visaPriceRep.PostVisaById(dto);
  2998. if (groupData.Code != 0)
  2999. {
  3000. return Ok(JsonView(false, groupData.Msg));
  3001. }
  3002. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3003. }
  3004. catch (Exception ex)
  3005. {
  3006. return Ok(JsonView(false, ex.Message));
  3007. }
  3008. }
  3009. /// <summary>
  3010. /// 签证费用删除
  3011. /// </summary>
  3012. /// <param name="dto"></param>
  3013. /// <returns></returns>
  3014. [HttpPost]
  3015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3016. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  3017. {
  3018. try
  3019. {
  3020. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  3021. if (!res)
  3022. {
  3023. return Ok(JsonView(false, "删除失败"));
  3024. }
  3025. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
  3026. {
  3027. IsDel = 1,
  3028. DeleteUserId = dto.DeleteUserId,
  3029. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3030. }).ExecuteCommandAsync();
  3031. return Ok(JsonView(true, "删除成功!"));
  3032. }
  3033. catch (Exception ex)
  3034. {
  3035. return Ok(JsonView(false, "程序错误!"));
  3036. throw;
  3037. }
  3038. }
  3039. /// <summary>
  3040. /// 签证费用录入下拉框初始化
  3041. /// </summary>
  3042. /// <returns></returns>
  3043. [HttpPost]
  3044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3045. public async Task<IActionResult> VisaPriceAddSelect()
  3046. {
  3047. try
  3048. {
  3049. //支付方式
  3050. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  3051. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  3052. //币种
  3053. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  3054. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  3055. //乘客类型
  3056. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  3057. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  3058. //卡类型
  3059. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  3060. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  3061. var data = new
  3062. {
  3063. Payment = _Payment,
  3064. CurrencyList = _CurrencyList,
  3065. PassengerType = _PassengerType,
  3066. BankCard = _BankCard
  3067. };
  3068. return Ok(JsonView(true, "查询成功!", data));
  3069. }
  3070. catch (Exception ex)
  3071. {
  3072. return Ok(JsonView(false, "程序错误!"));
  3073. throw;
  3074. }
  3075. }
  3076. /// <summary>
  3077. /// 签证费用录入操作(Status:1.新增,2.修改)
  3078. /// </summary>
  3079. /// <param name="dto"></param>
  3080. /// <returns></returns>
  3081. [HttpPost]
  3082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3083. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  3084. {
  3085. try
  3086. {
  3087. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  3088. if (groupData.Code != 0)
  3089. {
  3090. return Ok(JsonView(false, groupData.Msg));
  3091. }
  3092. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3093. }
  3094. catch (Exception ex)
  3095. {
  3096. return Ok(JsonView(false, ex.Message));
  3097. }
  3098. }
  3099. #endregion
  3100. #region op费用录入
  3101. /// <summary>
  3102. /// 根据diid查询op费用列表
  3103. /// </summary>
  3104. /// <param name="dto"></param>
  3105. /// <returns></returns>
  3106. [HttpPost]
  3107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3108. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  3109. {
  3110. try
  3111. {
  3112. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  3113. if (groupData.Code != 0)
  3114. {
  3115. return Ok(JsonView(false, groupData.Msg));
  3116. }
  3117. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3118. }
  3119. catch (Exception ex)
  3120. {
  3121. return Ok(JsonView(false, ex.Message));
  3122. }
  3123. }
  3124. /// <summary>
  3125. /// 根据op费用Id查询单条数据及c表数据
  3126. /// </summary>
  3127. /// <param name="dto"></param>
  3128. /// <returns></returns>
  3129. [HttpPost]
  3130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3131. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  3132. {
  3133. try
  3134. {
  3135. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  3136. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  3137. var data = new
  3138. {
  3139. CarTouristGuideGround = _groupData,
  3140. CreditCardPayment = _creditCardPayment
  3141. };
  3142. return Ok(JsonView(true, "查询成功!", data));
  3143. }
  3144. catch (Exception ex)
  3145. {
  3146. return Ok(JsonView(false, "程序错误!"));
  3147. }
  3148. }
  3149. /// <summary>
  3150. /// op费用删除
  3151. /// </summary>
  3152. /// <param name="dto"></param>
  3153. /// <returns></returns>
  3154. [HttpPost]
  3155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3156. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  3157. {
  3158. try
  3159. {
  3160. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3161. if (!res)
  3162. {
  3163. return Ok(JsonView(false, "删除失败"));
  3164. }
  3165. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  3166. {
  3167. IsDel = 1,
  3168. DeleteUserId = dto.DeleteUserId,
  3169. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3170. }).ExecuteCommandAsync();
  3171. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  3172. {
  3173. IsDel = 1,
  3174. DeleteUserId = dto.DeleteUserId,
  3175. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3176. }).ExecuteCommandAsync();
  3177. return Ok(JsonView(true, "删除成功!"));
  3178. }
  3179. catch (Exception ex)
  3180. {
  3181. return Ok(JsonView(false, "程序错误!"));
  3182. throw;
  3183. }
  3184. }
  3185. /// <summary>
  3186. /// op费用录入操作(Status:1.新增,2.修改)
  3187. /// </summary>
  3188. /// <param name="dto"></param>
  3189. /// <returns></returns>
  3190. [HttpPost]
  3191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3192. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  3193. {
  3194. try
  3195. {
  3196. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  3197. if (groupData.Code != 0)
  3198. {
  3199. return Ok(JsonView(false, groupData.Msg));
  3200. }
  3201. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3202. }
  3203. catch (Exception ex)
  3204. {
  3205. return Ok(JsonView(false, ex.Message));
  3206. }
  3207. }
  3208. /// <summary>
  3209. /// 填写费用详细页面初始化绑定
  3210. /// </summary>
  3211. /// <param name="dto"></param>
  3212. /// <returns></returns>
  3213. [HttpPost]
  3214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3215. public async Task<IActionResult> CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  3216. {
  3217. try
  3218. {
  3219. Result groupData = await _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  3220. if (groupData.Code != 0)
  3221. {
  3222. return Ok(JsonView(false, groupData.Msg));
  3223. }
  3224. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3225. }
  3226. catch (Exception ex)
  3227. {
  3228. return Ok(JsonView(false, ex.Message));
  3229. }
  3230. }
  3231. /// <summary>
  3232. /// 根据op费用Id查询详细数据
  3233. /// </summary>
  3234. /// <param name="dto"></param>
  3235. /// <returns></returns>
  3236. [HttpPost]
  3237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3238. public async Task<IActionResult> OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  3239. {
  3240. try
  3241. {
  3242. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  3243. if (groupData.Code != 0)
  3244. {
  3245. return Ok(JsonView(false, groupData.Msg));
  3246. }
  3247. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3248. }
  3249. catch (Exception ex)
  3250. {
  3251. return Ok(JsonView(false, ex.Message));
  3252. }
  3253. }
  3254. /// <summary>
  3255. /// OP费用录入填写详情
  3256. /// </summary>
  3257. /// <param name="dto"></param>
  3258. /// <returns></returns>
  3259. [HttpPost]
  3260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3261. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  3262. {
  3263. try
  3264. {
  3265. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  3266. if (groupData.Code != 0)
  3267. {
  3268. return Ok(JsonView(false, groupData.Msg));
  3269. }
  3270. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3271. }
  3272. catch (Exception ex)
  3273. {
  3274. return Ok(JsonView(false, ex.Message));
  3275. }
  3276. }
  3277. #endregion
  3278. #region 团组成本
  3279. /// <summary>
  3280. /// 团组成本数据初始化
  3281. /// </summary>
  3282. /// <param name="dto"></param>
  3283. /// <returns></returns>
  3284. [HttpPost]
  3285. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  3286. {
  3287. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  3288. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  3289. WHEN COUNT(*) >= 0 THEN 'True'
  3290. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  3291. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  3292. ").ToList(); //团组列表
  3293. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  3294. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  3295. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  3296. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  3297. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  3298. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  3299. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  3300. //GroupCostParameter.Add(new
  3301. // Grp_GroupCostParameter());
  3302. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  3303. return Ok(JsonView(new
  3304. {
  3305. groupList,
  3306. groupInfo,
  3307. groupChecks,
  3308. groupCost = groupCostMap,
  3309. hotelNumber,
  3310. GroupCostParameter = GroupCostParameterMap,
  3311. }));
  3312. }
  3313. /// <summary>
  3314. /// 团组成本信息保存
  3315. /// </summary>
  3316. /// <param name="dto"></param>
  3317. /// <returns></returns>
  3318. [HttpPost]
  3319. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  3320. {
  3321. JsonView jw = null;
  3322. bool isTrue = false;
  3323. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  3324. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  3325. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  3326. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  3327. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  3328. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  3329. try
  3330. {
  3331. _sqlSugar.BeginTran();
  3332. isTrue = await _GroupCostRepository.
  3333. SaveGroupCostList(Grp_groups, dto.Diid); //列表
  3334. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  3335. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  3336. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  3337. _sqlSugar.CommitTran();
  3338. jw = JsonView(true, "保存成功!", isTrue);
  3339. }
  3340. catch (Exception)
  3341. {
  3342. _sqlSugar.RollbackTran();
  3343. jw = JsonView(false);
  3344. }
  3345. return Ok(jw);
  3346. }
  3347. /// <summary>
  3348. /// 司兼导数据
  3349. /// </summary>
  3350. /// <param name="dto"></param>
  3351. /// <returns></returns>
  3352. [HttpPost]
  3353. public IActionResult GetCarGuides(CarGuidesDto dto)
  3354. {
  3355. JsonView jw = null;
  3356. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  3357. jw = JsonView(true, "获取成功!", Data);
  3358. return Ok(jw);
  3359. }
  3360. /// <summary>
  3361. /// 导游数据
  3362. /// </summary>
  3363. /// <param name="dto"></param>
  3364. /// <returns></returns>
  3365. [HttpPost]
  3366. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  3367. {
  3368. JsonView jw = null;
  3369. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  3370. // 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
  3371. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  3372. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  3373. jw = JsonView(true, "获取成功!", Data);
  3374. return Ok(jw);
  3375. }
  3376. /// <summary>
  3377. /// 成本车数据
  3378. /// </summary>
  3379. /// <param name="dto"></param>
  3380. /// <returns></returns>
  3381. [HttpPost]
  3382. public IActionResult GetCarInfo(CarGuidesDto dto)
  3383. {
  3384. JsonView jw = null;
  3385. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  3386. jw = JsonView(true, "获取成功!", Data);
  3387. return Ok(jw);
  3388. }
  3389. /// <summary>
  3390. /// 景点数据
  3391. /// </summary>
  3392. /// <param name="dto"></param>
  3393. /// <returns></returns>
  3394. [HttpPost]
  3395. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  3396. {
  3397. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  3398. return Ok(JsonView(true, "获取成功!", Data));
  3399. }
  3400. #endregion
  3401. #region 酒店预定
  3402. /// <summary>
  3403. /// 酒店预订页面初始化绑定
  3404. /// </summary>
  3405. /// <param name="dto"></param>
  3406. /// <returns></returns>
  3407. [HttpPost]
  3408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3409. public async Task<IActionResult> HotelReservationsInitialize(HotelReservationsDto dto)
  3410. {
  3411. try
  3412. {
  3413. Result groupData = await _hotelPriceRep.HotelReservationsInitialize(dto);
  3414. if (groupData.Code != 0)
  3415. {
  3416. return Ok(JsonView(false, groupData.Msg));
  3417. }
  3418. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3419. }
  3420. catch (Exception ex)
  3421. {
  3422. return Ok(JsonView(false, ex.Message));
  3423. }
  3424. }
  3425. /// <summary>
  3426. /// 根据团组Id查询酒店费用列表
  3427. /// </summary>
  3428. /// <param name="dto"></param>
  3429. /// <returns></returns>
  3430. [HttpPost]
  3431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3432. public async Task<IActionResult> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
  3433. {
  3434. try
  3435. {
  3436. Result groupData = await _hotelPriceRep.HotelReservationsByDiId(dto);
  3437. if (groupData.Code != 0)
  3438. {
  3439. return Ok(JsonView(false, groupData.Msg));
  3440. }
  3441. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3442. }
  3443. catch (Exception ex)
  3444. {
  3445. return Ok(JsonView(false, ex.Message));
  3446. }
  3447. }
  3448. /// <summary>
  3449. /// 根据酒店费用Id查询酒店费用详细
  3450. /// </summary>
  3451. /// <param name="dto"></param>
  3452. /// <returns></returns>
  3453. [HttpPost]
  3454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3455. public async Task<IActionResult> HotelReservationsById(HotelReservationsByIdDto dto)
  3456. {
  3457. try
  3458. {
  3459. Result groupData = await _hotelPriceRep.HotelReservationsById(dto);
  3460. if (groupData.Code != 0)
  3461. {
  3462. return Ok(JsonView(false, groupData.Msg));
  3463. }
  3464. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3465. }
  3466. catch (Exception ex)
  3467. {
  3468. return Ok(JsonView(false, ex.Message));
  3469. }
  3470. }
  3471. /// <summary>
  3472. /// 计算酒店付款总金额
  3473. /// </summary>
  3474. /// <param name="dto"></param>
  3475. /// <returns></returns>
  3476. [HttpPost]
  3477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3478. public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
  3479. {
  3480. try
  3481. {
  3482. Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
  3483. if (groupData.Code != 0)
  3484. {
  3485. return Ok(JsonView(false, groupData.Msg));
  3486. }
  3487. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3488. }
  3489. catch (Exception ex)
  3490. {
  3491. return Ok(JsonView(false, ex.Message));
  3492. }
  3493. }
  3494. /// <summary>
  3495. /// 酒店费用操作(Status:1.新增,2.修改)
  3496. /// </summary>
  3497. /// <param name="dto"></param>
  3498. /// <returns></returns>
  3499. [HttpPost]
  3500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3501. public async Task<IActionResult> OpHotelReservations(OpHotelReservationsData dto)
  3502. {
  3503. try
  3504. {
  3505. Result groupData = await _hotelPriceRep.OpHotelReservations(dto);
  3506. if (groupData.Code != 0)
  3507. {
  3508. return Ok(JsonView(false, groupData.Msg));
  3509. }
  3510. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3511. }
  3512. catch (Exception ex)
  3513. {
  3514. return Ok(JsonView(false, ex.Message));
  3515. }
  3516. }
  3517. /// <summary>
  3518. /// 文件上传
  3519. /// </summary>
  3520. /// <param name="file"></param>
  3521. /// <returns></returns>
  3522. [HttpPost]
  3523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3524. public async Task<IActionResult> UploadHotel(IFormFile file)
  3525. {
  3526. try
  3527. {
  3528. if (file != null)
  3529. {
  3530. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3531. //文件名称
  3532. string projectFileName = file.FileName;
  3533. //上传的文件的路径
  3534. string filePath = "";
  3535. if (!Directory.Exists(fileDir))
  3536. {
  3537. Directory.CreateDirectory(fileDir);
  3538. }
  3539. //上传的文件的路径
  3540. filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
  3541. using (FileStream fs = System.IO.File.Create(filePath))
  3542. {
  3543. file.CopyTo(fs);
  3544. fs.Flush();
  3545. }
  3546. return Ok(JsonView(true, "上传成功!", projectFileName));
  3547. }
  3548. else
  3549. {
  3550. return Ok(JsonView(false, "上传失败!"));
  3551. }
  3552. }
  3553. catch (Exception ex)
  3554. {
  3555. return Ok(JsonView(false, "程序错误!"));
  3556. throw;
  3557. }
  3558. }
  3559. /// <summary>
  3560. /// 删除指定文件
  3561. /// </summary>
  3562. /// <param name="dto"></param>
  3563. /// <returns></returns>
  3564. [HttpPost]
  3565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3566. public async Task<IActionResult> DelFileHotel(DelFileDto dto)
  3567. {
  3568. try
  3569. {
  3570. string filePath = "";
  3571. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3572. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3573. //int id = 0;
  3574. filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
  3575. // 删除该文件
  3576. try
  3577. {
  3578. System.IO.File.Delete(filePath);
  3579. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3580. {
  3581. Attachment = "",
  3582. }).ExecuteCommandAsync();
  3583. if (result != 0)
  3584. {
  3585. return Ok(JsonView(true, "成功!"));
  3586. }
  3587. else
  3588. {
  3589. return Ok(JsonView(false, "失败!"));
  3590. }
  3591. }
  3592. catch (Exception)
  3593. {
  3594. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3595. {
  3596. Attachment = "",
  3597. }).ExecuteCommandAsync();
  3598. if (result != 0)
  3599. {
  3600. return Ok(JsonView(true, "成功!"));
  3601. }
  3602. else
  3603. {
  3604. return Ok(JsonView(false, "失败!"));
  3605. }
  3606. throw;
  3607. }
  3608. }
  3609. catch (Exception ex)
  3610. {
  3611. return Ok(JsonView(false, "程序错误!"));
  3612. throw;
  3613. }
  3614. }
  3615. /// <summary>
  3616. /// 生成VOUCHER
  3617. /// </summary>
  3618. /// <param name=""></param>
  3619. /// <returns></returns>
  3620. [HttpPost]
  3621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3622. public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
  3623. {
  3624. Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
  3625. //判断数据是否完整
  3626. if (h != null)
  3627. {
  3628. if (!string.IsNullOrEmpty(h.DetermineNo))
  3629. {
  3630. string strFileName = "HotelStatement/";
  3631. Grp_DelegationInfo dele = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
  3632. if (dele != null)
  3633. strFileName += dele.TourCode;
  3634. //载入模板
  3635. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  3636. Document doc = new Document(sss);
  3637. DocumentBuilder builder = new DocumentBuilder(doc);
  3638. try
  3639. {
  3640. #region 替换Word模板书签内容
  3641. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  3642. //入住卷预定号码
  3643. if (doc.Range.Bookmarks["VNO"] != null)
  3644. {
  3645. Bookmark mark = doc.Range.Bookmarks["VNO"];
  3646. mark.Text = h.CheckNumber;
  3647. }
  3648. //酒店时间
  3649. if (doc.Range.Bookmarks["Date"] != null)
  3650. {
  3651. Bookmark mark = doc.Range.Bookmarks["Date"];
  3652. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3653. }
  3654. //团号
  3655. if (doc.Range.Bookmarks["TNo"] != null)
  3656. {
  3657. Bookmark mark = doc.Range.Bookmarks["TNo"];
  3658. mark.Text = dele.TourCode;
  3659. }
  3660. //预定号码
  3661. if (doc.Range.Bookmarks["BookingId"] != null)
  3662. {
  3663. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  3664. mark.Text = h.ReservationsNo;
  3665. }
  3666. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  3667. {
  3668. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  3669. mark.Text = h.DetermineNo;
  3670. }
  3671. //酒店城市
  3672. if (doc.Range.Bookmarks["City"] != null)
  3673. {
  3674. Bookmark mark = doc.Range.Bookmarks["City"];
  3675. mark.Text = h.City;
  3676. }
  3677. //酒店名称
  3678. if (doc.Range.Bookmarks["HName"] != null)
  3679. {
  3680. Bookmark mark = doc.Range.Bookmarks["HName"];
  3681. mark.Text = h.HotelName;
  3682. }
  3683. //酒店地址
  3684. if (doc.Range.Bookmarks["Address"] != null)
  3685. {
  3686. Bookmark mark = doc.Range.Bookmarks["Address"];
  3687. mark.Text = h.HotelAddress;
  3688. }
  3689. //酒店电话
  3690. if (doc.Range.Bookmarks["Tel"] != null)
  3691. {
  3692. Bookmark mark = doc.Range.Bookmarks["Tel"];
  3693. mark.Text = h.HotelTel;
  3694. }
  3695. //酒店传真
  3696. if (doc.Range.Bookmarks["Fax"] != null)
  3697. {
  3698. Bookmark mark = doc.Range.Bookmarks["Fax"];
  3699. if (!string.IsNullOrWhiteSpace(h.HotelFax))
  3700. {
  3701. mark.Text = h.HotelFax;
  3702. }
  3703. }
  3704. //入住时间
  3705. if (doc.Range.Bookmarks["CIn"] != null)
  3706. {
  3707. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3708. Bookmark mark = doc.Range.Bookmarks["CIn"];
  3709. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  3710. }
  3711. //退房时间
  3712. if (doc.Range.Bookmarks["COut"] != null)
  3713. {
  3714. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3715. Bookmark mark = doc.Range.Bookmarks["COut"];
  3716. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3717. }
  3718. //客户名称
  3719. if (doc.Range.Bookmarks["GName"] != null)
  3720. {
  3721. Bookmark mark = doc.Range.Bookmarks["GName"];
  3722. mark.Text = h.GuestName;
  3723. }
  3724. //房间介绍
  3725. if (doc.Range.Bookmarks["ROOM"] != null)
  3726. {
  3727. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  3728. mark.Text = h.RoomExplanation;
  3729. }
  3730. //报价描述
  3731. if (doc.Range.Bookmarks["NOTE"] != null)
  3732. {
  3733. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  3734. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == h.ReservationsWebsite);
  3735. if (ss != null)
  3736. mark.Text = ss.Name;
  3737. }
  3738. //入住时间
  3739. if (doc.Range.Bookmarks["CheckIn"] != null)
  3740. {
  3741. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3742. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  3743. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  3744. }
  3745. //退房时间
  3746. if (doc.Range.Bookmarks["CheckOut"] != null)
  3747. {
  3748. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3749. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  3750. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3751. }
  3752. //日期
  3753. if (doc.Range.Bookmarks["DT"] != null)
  3754. {
  3755. Bookmark mark = doc.Range.Bookmarks["DT"];
  3756. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3757. }
  3758. //名称
  3759. if (doc.Range.Bookmarks["VName"] != null)
  3760. {
  3761. Bookmark mark = doc.Range.Bookmarks["VName"];
  3762. mark.Text = h.HotelName;
  3763. }
  3764. //号码
  3765. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  3766. {
  3767. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  3768. mark.Text = h.CheckNumber;
  3769. }
  3770. #endregion
  3771. //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  3772. strFileName += "VOUCHER.doc";
  3773. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  3774. doc.Save(fileDir);
  3775. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  3776. return Ok(JsonView(true, "成功!", Url));
  3777. //保存为doc,并打开
  3778. }
  3779. catch (Exception ex)
  3780. {
  3781. throw;
  3782. }
  3783. }
  3784. else
  3785. {
  3786. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3787. }
  3788. }
  3789. else
  3790. {
  3791. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3792. }
  3793. }
  3794. /// <summary>
  3795. /// 导出确认单
  3796. /// </summary>
  3797. /// <param name=""></param>
  3798. /// <returns></returns>
  3799. [HttpPost]
  3800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3801. public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
  3802. {
  3803. //团组信息
  3804. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
  3805. //酒店数据
  3806. List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel == 0).ToList();
  3807. //利datatable存储
  3808. DataTable dt = new DataTable();
  3809. dt.Columns.Add("CheckInDate", typeof(string));
  3810. dt.Columns.Add("City", typeof(string));
  3811. dt.Columns.Add("Hotel", typeof(string));
  3812. dt.Columns.Add("Room", typeof(string));
  3813. for (int i = 0; i < listhoteldata.Count; i++)
  3814. {
  3815. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  3816. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  3817. while (dayStart < dayEnd)
  3818. {
  3819. string temp = "";
  3820. DataRow row = dt.NewRow();
  3821. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  3822. row["City"] = listhoteldata[i].City;
  3823. row["Hotel"] = listhoteldata[i].HotelName;
  3824. if (listhoteldata[i].SingleRoomCount > 0)
  3825. {
  3826. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  3827. }
  3828. if (listhoteldata[i].DoubleRoomCount > 0)
  3829. {
  3830. temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
  3831. }
  3832. if (listhoteldata[i].SuiteRoomCount > 0)
  3833. {
  3834. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  3835. }
  3836. if (listhoteldata[i].OtherRoomCount > 0)
  3837. {
  3838. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  3839. }
  3840. row["Room"] = temp;
  3841. dt.Rows.Add(row);
  3842. dayStart = dayStart.AddDays(1);
  3843. }
  3844. }
  3845. Dictionary<string, string> dic = new Dictionary<string, string>();
  3846. dic.Add("Dele", di.TeamName);
  3847. dic.Add("City", di.VisitCountry);
  3848. //模板路径
  3849. //string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  3850. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  3851. //载入模板
  3852. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  3853. DocumentBuilder builder = new DocumentBuilder(doc);
  3854. foreach (var key in dic.Keys)
  3855. {
  3856. builder.MoveToBookmark(key);
  3857. builder.Write(dic[key]);
  3858. }
  3859. //获取word里所有表格
  3860. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3861. //获取所填表格的序数
  3862. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3863. var rowStart = tableOne.Rows[0]; //获取第1行
  3864. try
  3865. {
  3866. //循环赋值
  3867. for (int i = 0; i < dt.Rows.Count; i++)
  3868. {
  3869. builder.MoveToCell(0, i + 1, 0, 0);
  3870. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  3871. builder.MoveToCell(0, i + 1, 1, 0);
  3872. builder.Write(dt.Rows[i]["City"].ToString());
  3873. builder.MoveToCell(0, i + 1, 2, 0);
  3874. builder.Write(dt.Rows[i]["Hotel"].ToString());
  3875. builder.MoveToCell(0, i + 1, 3, 0);
  3876. builder.Write(dt.Rows[i]["Room"].ToString());
  3877. }
  3878. }
  3879. catch
  3880. {
  3881. }
  3882. //删除多余行
  3883. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  3884. {
  3885. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  3886. }
  3887. string strFileName = di.TeamName + "酒店确认单.doc";
  3888. try
  3889. {
  3890. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  3891. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  3892. return Ok(JsonView(true, "成功", Url));
  3893. }
  3894. catch (Exception)
  3895. {
  3896. return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
  3897. throw;
  3898. }
  3899. //doc.Save(HttpUtility.UrlEncode(strFileName, Encoding.UTF8), Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);
  3900. }
  3901. /// <summary>
  3902. /// 酒店费用删除
  3903. /// </summary>
  3904. /// <param name="dto"></param>
  3905. /// <returns></returns>
  3906. [HttpPost]
  3907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3908. public async Task<IActionResult> DelHotelPrice(DelBaseDto dto)
  3909. {
  3910. try
  3911. {
  3912. var res = await _hotelPriceRep.SoftDeleteByIdAsync<Grp_HotelReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3913. if (!res)
  3914. {
  3915. return Ok(JsonView(false, "删除失败"));
  3916. }
  3917. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment()
  3918. {
  3919. IsDel = 1,
  3920. DeleteUserId = dto.DeleteUserId,
  3921. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3922. }).ExecuteCommandAsync();
  3923. return Ok(JsonView(true, "删除成功!"));
  3924. }
  3925. catch (Exception ex)
  3926. {
  3927. return Ok(JsonView(false, "程序错误!"));
  3928. throw;
  3929. }
  3930. }
  3931. #endregion
  3932. #region 团组状态
  3933. /// <summary>
  3934. /// 团组状态列表 Page
  3935. /// </summary>
  3936. /// <param name="dto">团组列表请求dto</param>
  3937. /// <returns></returns>
  3938. [HttpPost]
  3939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3940. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  3941. {
  3942. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  3943. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  3944. {
  3945. string sqlWhere = string.Empty;
  3946. if (dto.IsSure == 0) //未完成
  3947. {
  3948. sqlWhere += string.Format(@" And IsSure = 0");
  3949. }
  3950. else if (dto.IsSure == 1) //已完成
  3951. {
  3952. sqlWhere += string.Format(@" And IsSure = 1");
  3953. }
  3954. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  3955. {
  3956. string tj = dto.SearchCriteria;
  3957. 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}%')",
  3958. tj, tj, tj, tj, tj);
  3959. }
  3960. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3961. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  3962. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3963. From (
  3964. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  3965. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  3966. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  3967. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3968. From Grp_DelegationInfo gdi
  3969. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3970. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3971. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3972. Where gdi.IsDel = 0 {0}
  3973. ) temp ", sqlWhere);
  3974. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3975. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  3976. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  3977. }
  3978. else
  3979. {
  3980. return Ok(JsonView(false, "查询失败"));
  3981. }
  3982. }
  3983. /// <summary>
  3984. /// 团组状态
  3985. /// 设置操作完成
  3986. /// </summary>
  3987. /// <param name="dto">团组列表请求dto</param>
  3988. /// <returns></returns>
  3989. [HttpPost]
  3990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3991. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  3992. {
  3993. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  3994. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  3995. {
  3996. Id = dto.Id,
  3997. IsSure = 1
  3998. };
  3999. var result = await _sqlSugar.Updateable(_DelegationInfo)
  4000. .UpdateColumns(it => new { it.IsSure })
  4001. .WhereColumns(it => new { it.Id })
  4002. .ExecuteCommandAsync();
  4003. if (result > 0)
  4004. {
  4005. return Ok(JsonView(true, "操作完成!"));
  4006. }
  4007. return Ok(JsonView(false, "操作失败!"));
  4008. }
  4009. #endregion
  4010. #region 保险费用录入
  4011. /// <summary>
  4012. /// 根据团组Id查询保险费用列表
  4013. /// </summary>
  4014. /// <param name="dto"></param>
  4015. /// <returns></returns>
  4016. [HttpPost]
  4017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4018. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  4019. {
  4020. try
  4021. {
  4022. Result groupData = await _customersRep.CustomersByDiId(dto);
  4023. if (groupData.Code != 0)
  4024. {
  4025. return Ok(JsonView(false, groupData.Msg));
  4026. }
  4027. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4028. }
  4029. catch (Exception ex)
  4030. {
  4031. return Ok(JsonView(false, ex.Message));
  4032. }
  4033. }
  4034. /// <summary>
  4035. /// 根据保险费用Id查询保险费用详细
  4036. /// </summary>
  4037. /// <param name="dto"></param>
  4038. /// <returns></returns>
  4039. [HttpPost]
  4040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4041. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  4042. {
  4043. try
  4044. {
  4045. Result groupData = await _customersRep.CustomersById(dto);
  4046. if (groupData.Code != 0)
  4047. {
  4048. return Ok(JsonView(false, groupData.Msg));
  4049. }
  4050. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4051. }
  4052. catch (Exception ex)
  4053. {
  4054. return Ok(JsonView(false, ex.Message));
  4055. }
  4056. }
  4057. /// <summary>
  4058. /// 酒店预订页面初始化绑定
  4059. /// </summary>
  4060. /// <param name="dto"></param>
  4061. /// <returns></returns>
  4062. [HttpPost]
  4063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4064. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  4065. {
  4066. try
  4067. {
  4068. Result groupData = await _customersRep.CustomersInitialize(dto);
  4069. if (groupData.Code != 0)
  4070. {
  4071. return Ok(JsonView(false, groupData.Msg));
  4072. }
  4073. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4074. }
  4075. catch (Exception ex)
  4076. {
  4077. return Ok(JsonView(false, ex.Message));
  4078. }
  4079. }
  4080. /// <summary>
  4081. /// 保险费用操作(Status:1.新增,2.修改)
  4082. /// </summary>
  4083. /// <param name="dto"></param>
  4084. /// <returns></returns>
  4085. [HttpPost]
  4086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4087. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  4088. {
  4089. try
  4090. {
  4091. Result groupData = await _customersRep.OpCustomers(dto);
  4092. if (groupData.Code != 0)
  4093. {
  4094. return Ok(JsonView(false, groupData.Msg));
  4095. }
  4096. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4097. }
  4098. catch (Exception ex)
  4099. {
  4100. return Ok(JsonView(false, ex.Message));
  4101. }
  4102. }
  4103. /// <summary>
  4104. /// 文件上传
  4105. /// </summary>
  4106. /// <param name="file"></param>
  4107. /// <returns></returns>
  4108. [HttpPost]
  4109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4110. public async Task<IActionResult> UploadCus(IFormFile file)
  4111. {
  4112. try
  4113. {
  4114. if (file != null)
  4115. {
  4116. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4117. //文件名称
  4118. string projectFileName = file.FileName;
  4119. //上传的文件的路径
  4120. string filePath = "";
  4121. if (!Directory.Exists(fileDir))
  4122. {
  4123. Directory.CreateDirectory(fileDir);
  4124. }
  4125. //上传的文件的路径
  4126. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  4127. using (FileStream fs = System.IO.File.Create(filePath))
  4128. {
  4129. file.CopyTo(fs);
  4130. fs.Flush();
  4131. }
  4132. return Ok(JsonView(true, "上传成功!", projectFileName));
  4133. }
  4134. else
  4135. {
  4136. return Ok(JsonView(false, "上传失败!"));
  4137. }
  4138. }
  4139. catch (Exception ex)
  4140. {
  4141. return Ok(JsonView(false, "程序错误!"));
  4142. throw;
  4143. }
  4144. }
  4145. /// <summary>
  4146. /// 删除指定文件
  4147. /// </summary>
  4148. /// <param name="dto"></param>
  4149. /// <returns></returns>
  4150. [HttpPost]
  4151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4152. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  4153. {
  4154. try
  4155. {
  4156. string filePath = "";
  4157. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4158. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4159. //int id = 0;
  4160. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  4161. // 删除该文件
  4162. try
  4163. {
  4164. System.IO.File.Delete(filePath);
  4165. 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()
  4166. {
  4167. Attachment = "",
  4168. }).ExecuteCommandAsync();
  4169. if (result != 0)
  4170. {
  4171. return Ok(JsonView(true, "成功!"));
  4172. }
  4173. else
  4174. {
  4175. return Ok(JsonView(false, "失败!"));
  4176. }
  4177. }
  4178. catch (Exception)
  4179. {
  4180. 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()
  4181. {
  4182. Attachment = "",
  4183. }).ExecuteCommandAsync();
  4184. if (result != 0)
  4185. {
  4186. return Ok(JsonView(true, "成功!"));
  4187. }
  4188. else
  4189. {
  4190. return Ok(JsonView(false, "失败!"));
  4191. }
  4192. }
  4193. }
  4194. catch (Exception ex)
  4195. {
  4196. return Ok(JsonView(false, "程序错误!"));
  4197. throw;
  4198. }
  4199. }
  4200. /// <summary>
  4201. /// 保险费用操作(删除)
  4202. /// </summary>
  4203. /// <param name="dto"></param>
  4204. /// <returns></returns>
  4205. [HttpPost]
  4206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4207. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  4208. {
  4209. try
  4210. {
  4211. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  4212. if (!res)
  4213. {
  4214. return Ok(JsonView(false, "删除失败"));
  4215. }
  4216. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  4217. {
  4218. IsDel = 1,
  4219. DeleteUserId = dto.DeleteUserId,
  4220. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4221. }).ExecuteCommandAsync();
  4222. return Ok(JsonView(true, "删除成功!"));
  4223. }
  4224. catch (Exception ex)
  4225. {
  4226. return Ok(JsonView(false, "程序错误!"));
  4227. throw;
  4228. }
  4229. }
  4230. #endregion
  4231. }
  4232. }