GroupsController.cs 195 KB

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