GroupsController.cs 189 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522
  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. * Label = 98 其他款项
  828. */
  829. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  830. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  831. .ToListAsync();
  832. /*
  833. * Lable = 85 机票预订
  834. */
  835. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  836. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  837. .ToListAsync();
  838. /*
  839. * 币种信息
  840. */
  841. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  842. /*
  843. * 用户信息
  844. */
  845. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  846. /*
  847. * 费用模块
  848. */
  849. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  850. string priceModule = string.Empty;
  851. if (sdPriceName != null)
  852. {
  853. priceModule = sdPriceName.Name;
  854. }
  855. /*
  856. * 处理详情数据
  857. */
  858. foreach (var entity in entityList)
  859. {
  860. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  861. _detail.Id = entity.Id;
  862. /*
  863. * Bus名称
  864. */
  865. _detail.BusName = "";
  866. /*
  867. *费用所属
  868. */
  869. switch (entity.CTable)
  870. {
  871. case 85:
  872. Grp_AirTicketReservations jpRes = _groupRepository.Query<Grp_AirTicketReservations>(s => s.Id == entity.CId).First();
  873. if (jpRes != null)
  874. {
  875. string FlightsDescription = jpRes.FlightsDescription;
  876. string PriceDescription = jpRes.PriceDescription;
  877. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  878. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  879. }
  880. break;
  881. case 79:
  882. _detail.BusName = "待增加";
  883. break;
  884. case 98:
  885. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  886. if (gdpRes != null)
  887. {
  888. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  889. _detail.PriceNameContent = gdpRes.PriceName;
  890. }
  891. break;
  892. default:
  893. break;
  894. }
  895. _detail.PriceName = priceModule;
  896. /*
  897. * 应付款金额
  898. */
  899. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  900. string PaymentCurrency_WaitPay = "Unknown";
  901. if (sdPaymentCurrency_WaitPay != null)
  902. {
  903. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  904. }
  905. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1() + " " + PaymentCurrency_WaitPay;
  906. /*
  907. * 此次付款金额
  908. */
  909. decimal CurrPayStr = 0;
  910. if (entity.PayPercentage == 0)
  911. {
  912. if (entity.PayThenMoney != 0)
  913. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  914. }
  915. else
  916. {
  917. CurrPayStr = (entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * entity.DayRate)).ConvertToDecimal1();
  918. }
  919. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  920. /*
  921. * 剩余尾款
  922. */
  923. decimal BalanceStr = 0;
  924. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  925. BalanceStr = 0;
  926. else
  927. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  928. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  929. /*
  930. * 申请人
  931. */
  932. string operatorName = " - ";
  933. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  934. if (_opUser != null)
  935. {
  936. operatorName = _opUser.CnName;
  937. }
  938. _detail.OperatorName = operatorName;
  939. /*
  940. * 审核人
  941. */
  942. string auditOperatorName = "Unknown";
  943. if (entity.AuditGMOperate == 0)
  944. auditOperatorName = " - ";
  945. else if (entity.AuditGMOperate == 4)
  946. auditOperatorName = "自动审核";
  947. else
  948. {
  949. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  950. if (_adUser != null)
  951. {
  952. auditOperatorName = _adUser.CnName;
  953. }
  954. }
  955. _detail.AuditOperatorName = auditOperatorName;
  956. /*
  957. * 超预算比例
  958. */
  959. string overBudgetStr = "";
  960. if (entity.ExceedBudget == -1)
  961. overBudgetStr = sdPriceName.Name + "尚无预算";
  962. else if (entity.ExceedBudget == 0)
  963. overBudgetStr = "未超预算";
  964. else
  965. overBudgetStr = entity.ExceedBudget.ToString("P");
  966. _detail.OverBudget = overBudgetStr;
  967. /*
  968. * 费用总计
  969. */
  970. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  971. {
  972. CurrencyId = entity.PaymentCurrency,
  973. CurrencyName = PaymentCurrency_WaitPay,
  974. AmountPayable = entity.PayMoney,
  975. ThisPayment = CurrPayStr,
  976. BalancePayment = BalanceStr,
  977. AuditedFunds = CurrPayStr
  978. });
  979. _detail.IsAuditGM = entity.IsAuditGM;
  980. detailList.Add(_detail);
  981. }
  982. #endregion
  983. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  984. /*
  985. * 下方描述处理
  986. */
  987. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  988. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  989. if (ccpCurrencyPrice != null)
  990. {
  991. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  992. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  993. }
  994. else
  995. {
  996. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  997. }
  998. string amountPayableStr = string.Format(@"应付款总金额: ");
  999. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1000. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1001. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1002. foreach (var item in nonDuplicat)
  1003. {
  1004. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1005. if (strs.Count > 0)
  1006. {
  1007. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1008. decimal thisPayment = strs.Sum(it => it.ThisPayment);
  1009. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1010. decimal auditedFunds = strs.Sum(it => it.AuditedFunds);
  1011. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1012. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1013. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1014. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1015. }
  1016. }
  1017. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1018. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1019. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1020. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1021. var _view1 = new
  1022. {
  1023. PageFuncAuth = pageFunAuthView,
  1024. Data = _view
  1025. };
  1026. return Ok(JsonView(_view1));
  1027. }
  1028. catch (Exception ex)
  1029. {
  1030. return Ok(JsonView(false, ex.Message));
  1031. }
  1032. }
  1033. /// <summary>
  1034. /// 费用审核
  1035. /// 修改团组费用审核状态
  1036. /// </summary>
  1037. /// <param name="_dto">参数Json字符串</param>
  1038. /// <returns></returns>
  1039. [HttpPost]
  1040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1041. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1042. {
  1043. #region 参数验证
  1044. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1045. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1046. #endregion
  1047. #region 页面操作权限验证
  1048. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1049. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1050. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1051. #endregion
  1052. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1053. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1054. DateTime dtNow = DateTime.Now;
  1055. _groupRepository.BeginTran();
  1056. int rst = 0;
  1057. foreach (var item in idList)
  1058. {
  1059. int CreditId = int.Parse(item);
  1060. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1061. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1062. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1063. .SetColumns(it => it.AuditGMDate == dtNow.ToString())
  1064. .Where(s => s.Id == CreditId)
  1065. .ExecuteCommandAsync();
  1066. if (result < 1)
  1067. {
  1068. rst = -1;
  1069. }
  1070. else
  1071. {
  1072. _groupRepository.RollbackTran();
  1073. return Ok(JsonView(false, "保存失败并回滚!"));
  1074. }
  1075. }
  1076. _groupRepository.CommitTran();
  1077. if (rst == 0)
  1078. {
  1079. return Ok(JsonView(true, "保存成功!"));
  1080. }
  1081. return Ok(JsonView(false, "保存失败!"));
  1082. }
  1083. #endregion
  1084. #region 机票费用录入
  1085. /// <summary>
  1086. /// 机票录入当前登录人可操作团组
  1087. /// </summary>
  1088. /// <param name="dto"></param>
  1089. /// <returns></returns>
  1090. [HttpPost]
  1091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1092. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1093. {
  1094. try
  1095. {
  1096. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1097. if (groupData.Code != 0)
  1098. {
  1099. return Ok(JsonView(false, groupData.Msg));
  1100. }
  1101. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1102. }
  1103. catch (Exception ex)
  1104. {
  1105. return Ok(JsonView(false, "程序错误!"));
  1106. throw;
  1107. }
  1108. }
  1109. /// <summary>
  1110. /// 机票费用录入列表
  1111. /// </summary>
  1112. /// <param name="dto"></param>
  1113. /// <returns></returns>
  1114. [HttpPost]
  1115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1116. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1117. {
  1118. try
  1119. {
  1120. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1121. if (groupData.Code != 0)
  1122. {
  1123. return Ok(JsonView(false, groupData.Msg));
  1124. }
  1125. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1126. }
  1127. catch (Exception ex)
  1128. {
  1129. return Ok(JsonView(false, "程序错误!"));
  1130. throw;
  1131. }
  1132. }
  1133. /// <summary>
  1134. /// 根据id查询费用录入信息
  1135. /// </summary>
  1136. /// <param name="dto"></param>
  1137. /// <returns></returns>
  1138. [HttpPost]
  1139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1140. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1141. {
  1142. try
  1143. {
  1144. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1145. if (groupData.Code != 0)
  1146. {
  1147. return Ok(JsonView(false, groupData.Msg));
  1148. }
  1149. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1150. }
  1151. catch (Exception ex)
  1152. {
  1153. return Ok(JsonView(false, "程序错误!"));
  1154. throw;
  1155. }
  1156. }
  1157. /// <summary>
  1158. /// 机票费用录入操作(Status:1.新增,2.修改)
  1159. /// </summary>
  1160. /// <param name="dto"></param>
  1161. /// <returns></returns>
  1162. [HttpPost]
  1163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1164. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1165. {
  1166. try
  1167. {
  1168. Result groupData = await _airTicketResRep.OpAirTicketRes(dto);
  1169. if (groupData.Code != 0)
  1170. {
  1171. return Ok(JsonView(false, groupData.Msg));
  1172. }
  1173. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1174. }
  1175. catch (Exception ex)
  1176. {
  1177. return Ok(JsonView(false, "程序错误!"));
  1178. throw;
  1179. }
  1180. }
  1181. /// <summary>
  1182. /// 根据舱位类型查询接团客户名单信息
  1183. /// </summary>
  1184. /// <param name="dto"></param>
  1185. /// <returns></returns>
  1186. [HttpPost]
  1187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1188. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1189. {
  1190. try
  1191. {
  1192. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1193. if (crm_Groups.Count != 0)
  1194. {
  1195. List<dynamic> Customer = new List<dynamic>();
  1196. foreach (var item in crm_Groups)
  1197. {
  1198. var data = new
  1199. {
  1200. Id = item.Id,
  1201. Pinyin = item.Pinyin,
  1202. Name = item.LastName + item.FirstName
  1203. };
  1204. Customer.Add(data);
  1205. }
  1206. return Ok(JsonView(true, "查询成功!", Customer));
  1207. }
  1208. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1209. }
  1210. catch (Exception ex)
  1211. {
  1212. return Ok(JsonView(false, "程序错误!"));
  1213. throw;
  1214. }
  1215. }
  1216. /// <summary>
  1217. /// 机票费用录入,删除
  1218. /// </summary>
  1219. /// <param name="dto"></param>
  1220. /// <returns></returns>
  1221. [HttpPost]
  1222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1223. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1224. {
  1225. try
  1226. {
  1227. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1228. if (!res)
  1229. {
  1230. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1231. {
  1232. IsDel = 1,
  1233. DeleteUserId = dto.DeleteUserId,
  1234. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1235. }).ExecuteCommandAsync();
  1236. return Ok(JsonView(false, "删除失败"));
  1237. }
  1238. return Ok(JsonView(true, "删除成功!"));
  1239. }
  1240. catch (Exception ex)
  1241. {
  1242. return Ok(JsonView(false, "程序错误!"));
  1243. throw;
  1244. }
  1245. }
  1246. /// <summary>
  1247. /// 导出机票录入报表
  1248. /// </summary>
  1249. /// <param name="dto"></param>
  1250. /// <returns></returns>
  1251. [HttpPost]
  1252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1253. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  1254. {
  1255. try
  1256. {
  1257. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1258. if (groupData.Code != 0)
  1259. {
  1260. return Ok(JsonView(false, groupData.Msg));
  1261. }
  1262. else
  1263. {
  1264. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1265. if (AirTicketReservations.Count != 0)
  1266. {
  1267. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1268. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1269. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1270. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1271. WorkbookDesigner designer = new WorkbookDesigner();
  1272. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1273. decimal countCost = 0;
  1274. foreach (var item in AirTicketReservations)
  1275. {
  1276. if (item.BankType == "其他")
  1277. {
  1278. item.BankNo = "--";
  1279. }
  1280. else
  1281. {
  1282. item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
  1283. }
  1284. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1285. item.Price = System.Decimal.Round(item.Price, 2);
  1286. countCost += Convert.ToDecimal(item.Price);
  1287. }
  1288. designer.SetDataSource("Export", AirTicketReservations);
  1289. designer.SetDataSource("ExportDiCode", diCode);
  1290. designer.SetDataSource("ExportDiName", diName);
  1291. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1292. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1293. designer.Process();
  1294. string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  1295. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1296. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1297. return Ok(JsonView(true, "成功", url = rst));
  1298. }
  1299. else
  1300. {
  1301. return Ok(JsonView(false, "暂无数据!"));
  1302. }
  1303. }
  1304. }
  1305. catch (Exception ex)
  1306. {
  1307. return Ok(JsonView(false, "程序错误!"));
  1308. throw;
  1309. }
  1310. }
  1311. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1312. /// <summary>
  1313. /// 行程单导出
  1314. /// </summary>
  1315. /// <param name="dto"></param>
  1316. /// <returns></returns>
  1317. [HttpPost]
  1318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1319. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1320. {
  1321. try
  1322. {
  1323. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1324. if (groupData.Code != 0)
  1325. {
  1326. return Ok(JsonView(false, groupData.Msg));
  1327. }
  1328. else
  1329. {
  1330. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1331. if (dto.Language == "CN")
  1332. {
  1333. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1334. DocumentBuilder builder = new DocumentBuilder(doc);
  1335. int tableIndex = 0;//表格索引
  1336. //得到文档中的第一个表格
  1337. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1338. foreach (var item in _AirTicketReservations)
  1339. {
  1340. #region 处理固定数据
  1341. string[] FlightsCode = item.FlightsCode.Split('/');
  1342. if (FlightsCode.Length != 0)
  1343. {
  1344. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1345. if (_AirCompany != null)
  1346. {
  1347. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1348. }
  1349. else
  1350. {
  1351. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1352. }
  1353. }
  1354. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1355. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1356. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1357. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1358. string name = "";
  1359. foreach (string clientName in nameArray)
  1360. {
  1361. if (!name.Contains(clientName))
  1362. {
  1363. name += clientName + ",";
  1364. }
  1365. }
  1366. if (!string.IsNullOrWhiteSpace(name))
  1367. {
  1368. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1369. }
  1370. else
  1371. {
  1372. table.Range.Bookmarks["ClientName"].Text = "--";
  1373. }
  1374. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1375. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1376. table.Range.Bookmarks["JointTicket"].Text = "--";
  1377. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1378. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1379. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1380. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1381. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1382. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1383. #endregion
  1384. #region 循环数据处理
  1385. List<AirInfo> airs = new List<AirInfo>();
  1386. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1387. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1388. for (int i = 0; i < FlightsCode.Length; i++)
  1389. {
  1390. AirInfo air = new AirInfo();
  1391. string[] tempstr = DayArray[i]
  1392. .Replace("\r\n", string.Empty)
  1393. .Replace("\\r\\n", string.Empty)
  1394. .TrimStart().TrimEnd()
  1395. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1396. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1397. string starCity = "";
  1398. if (star_Three != null)
  1399. {
  1400. starCity = star_Three.AirPort;
  1401. }
  1402. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1403. string EndCity = "";
  1404. if (End_Three != null)
  1405. {
  1406. EndCity = End_Three.AirPort;
  1407. }
  1408. air.Destination = starCity + "/" + EndCity;
  1409. air.Flight = FlightsCode[i];
  1410. air.SeatingClass = item.CTypeName;
  1411. string dateTime = tempstr[2];
  1412. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1413. air.FlightDate = DateTemp;
  1414. air.DepartureTime = tempstr[5];
  1415. air.LandingTime = tempstr[6];
  1416. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1417. air.TicketStatus = "--";
  1418. air.Luggage = "--";
  1419. air.DepartureTerminal = "--";
  1420. air.LandingTerminal = "--";
  1421. airs.Add(air);
  1422. }
  1423. int row = 13;
  1424. for (int i = 0; i < airs.Count; i++)
  1425. {
  1426. if (airs.Count > 2)
  1427. {
  1428. for (int j = 0; j < airs.Count - 2; j++)
  1429. {
  1430. var CopyRow = table.Rows[12].Clone(true);
  1431. table.Rows.Add(CopyRow);
  1432. }
  1433. }
  1434. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1435. int index = 0;
  1436. foreach (PropertyInfo property in properties)
  1437. {
  1438. string value = property.GetValue(airs[i]).ToString();
  1439. Cell ishcel0 = table.Rows[row].Cells[index];
  1440. Paragraph p = new Paragraph(doc);
  1441. string s = value;
  1442. p.AppendChild(new Run(doc, s));
  1443. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1444. ishcel0.AppendChild(p);
  1445. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1446. index++;
  1447. }
  1448. row++;
  1449. }
  1450. #endregion
  1451. Paragraph lastParagraph = new Paragraph(doc);
  1452. //第一个表格末尾加段落
  1453. table.ParentNode.InsertAfter(lastParagraph, table);
  1454. //复制第一个表格
  1455. Table cloneTable = (Table)table.Clone(true);
  1456. //在文档末尾段落后面加入复制的表格
  1457. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1458. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1459. {
  1460. int rownewsIndex = 13;
  1461. for (int i = 0; i < 2; i++)
  1462. {
  1463. var CopyRow = table.Rows[12].Clone(true);
  1464. table.Rows.RemoveAt(13);
  1465. table.Rows.Add(CopyRow);
  1466. rownewsIndex++;
  1467. }
  1468. }
  1469. else
  1470. {
  1471. table.Rows.RemoveAt(12);
  1472. }
  1473. cloneTable.Rows.RemoveAt(12);
  1474. }
  1475. if (_AirTicketReservations.Count != 0)
  1476. {
  1477. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1478. if (FlightsCode.Length != 0)
  1479. {
  1480. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1481. if (_AirCompany != null)
  1482. {
  1483. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1484. }
  1485. else
  1486. {
  1487. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1488. }
  1489. }
  1490. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1491. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1492. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1493. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1494. string name = "";
  1495. foreach (string clientName in nameArray)
  1496. {
  1497. if (!name.Contains(clientName))
  1498. {
  1499. name += clientName + ",";
  1500. }
  1501. }
  1502. if (!string.IsNullOrWhiteSpace(name))
  1503. {
  1504. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1505. }
  1506. else
  1507. {
  1508. table.Range.Bookmarks["ClientName"].Text = "--";
  1509. }
  1510. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1511. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1512. table.Range.Bookmarks["JointTicket"].Text = "--";
  1513. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1514. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1515. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1516. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1517. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1518. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1519. }
  1520. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1521. //保存合并后的文档
  1522. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  1523. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1524. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1525. return Ok(JsonView(true, "成功!", rst));
  1526. }
  1527. else
  1528. {
  1529. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  1530. DocumentBuilder builder = new DocumentBuilder(doc);
  1531. int tableIndex = 0;//表格索引
  1532. //得到文档中的第一个表格
  1533. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1534. List<string> texts = new List<string>();
  1535. foreach (var item in _AirTicketReservations)
  1536. {
  1537. string[] FlightsCode = item.FlightsCode.Split('/');
  1538. if (FlightsCode.Length != 0)
  1539. {
  1540. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1541. if (_AirCompany != null)
  1542. {
  1543. if (!transDic.ContainsKey(_AirCompany.CnName))
  1544. {
  1545. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  1546. }
  1547. }
  1548. else
  1549. {
  1550. if (!transDic.ContainsKey("--"))
  1551. {
  1552. transDic.Add("--", "--");
  1553. }
  1554. }
  1555. }
  1556. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1557. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1558. string name = "";
  1559. foreach (string clientName in nameArray)
  1560. {
  1561. name += clientName + ",";
  1562. }
  1563. if (!texts.Contains(name))
  1564. {
  1565. texts.Add(name);
  1566. }
  1567. List<AirInfo> airs = new List<AirInfo>();
  1568. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1569. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1570. for (int i = 0; i < FlightsCode.Length; i++)
  1571. {
  1572. AirInfo air = new AirInfo();
  1573. string[] tempstr = DayArray[i]
  1574. .Replace("\r\n", string.Empty)
  1575. .Replace("\\r\\n", string.Empty)
  1576. .TrimStart().TrimEnd()
  1577. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1578. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1579. if (star_Three != null)
  1580. {
  1581. if (!transDic.ContainsKey(star_Three.AirPort))
  1582. {
  1583. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  1584. }
  1585. }
  1586. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1587. if (End_Three != null)
  1588. {
  1589. if (!transDic.ContainsKey(End_Three.AirPort))
  1590. {
  1591. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  1592. }
  1593. }
  1594. if (!texts.Contains(item.CTypeName))
  1595. {
  1596. texts.Add(item.CTypeName);
  1597. }
  1598. }
  1599. }
  1600. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  1601. if (transData.Count > 0)
  1602. {
  1603. foreach (TranslateResult item in transData)
  1604. {
  1605. if (!transDic.ContainsKey(item.Query))
  1606. {
  1607. transDic.Add(item.Query, item.Translation);
  1608. }
  1609. }
  1610. }
  1611. foreach (var item in _AirTicketReservations)
  1612. {
  1613. #region 处理固定数据
  1614. string[] FlightsCode = item.FlightsCode.Split('/');
  1615. if (FlightsCode.Length != 0)
  1616. {
  1617. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1618. if (_AirCompany != null)
  1619. {
  1620. string str = "--";
  1621. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1622. if (!string.IsNullOrEmpty(translateResult))
  1623. {
  1624. str = translateResult;
  1625. str = _airTicketResRep.Processing(str);
  1626. }
  1627. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1628. }
  1629. else
  1630. {
  1631. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1632. }
  1633. }
  1634. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1635. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1636. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1637. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1638. string names = "";
  1639. foreach (string clientName in nameArray)
  1640. {
  1641. names += clientName + ",";
  1642. }
  1643. if (!string.IsNullOrWhiteSpace(names))
  1644. {
  1645. string str = "--";
  1646. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1647. if (!string.IsNullOrEmpty(translateResult))
  1648. {
  1649. str = translateResult;
  1650. str = _airTicketResRep.Processing(str);
  1651. }
  1652. table.Range.Bookmarks["ClientName"].Text = str;
  1653. }
  1654. else
  1655. {
  1656. table.Range.Bookmarks["ClientName"].Text = "--";
  1657. }
  1658. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1659. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1660. table.Range.Bookmarks["JointTicket"].Text = "--";
  1661. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1662. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1663. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1664. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1665. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1666. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1667. #endregion
  1668. #region 循环数据处理
  1669. List<AirInfo> airs = new List<AirInfo>();
  1670. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1671. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1672. for (int i = 0; i < FlightsCode.Length; i++)
  1673. {
  1674. AirInfo air = new AirInfo();
  1675. string[] tempstr = DayArray[i]
  1676. .Replace("\r\n", string.Empty)
  1677. .Replace("\\r\\n", string.Empty)
  1678. .TrimStart().TrimEnd()
  1679. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1680. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1681. string starCity = "";
  1682. if (star_Three != null)
  1683. {
  1684. string str2 = "--";
  1685. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  1686. if (!string.IsNullOrEmpty(translateResult2))
  1687. {
  1688. str2 = translateResult2;
  1689. str2 = _airTicketResRep.Processing(str2);
  1690. }
  1691. starCity = str2;
  1692. }
  1693. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1694. string EndCity = "";
  1695. if (End_Three != null)
  1696. {
  1697. string str1 = "--";
  1698. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  1699. if (!string.IsNullOrEmpty(translateResult1))
  1700. {
  1701. str1 = translateResult1;
  1702. str1 = _airTicketResRep.Processing(str1);
  1703. }
  1704. EndCity = str1;
  1705. }
  1706. air.Destination = starCity + "/" + EndCity;
  1707. air.Flight = FlightsCode[i];
  1708. string str = "--";
  1709. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  1710. if (!string.IsNullOrEmpty(translateResult))
  1711. {
  1712. str = translateResult;
  1713. str = _airTicketResRep.Processing(str);
  1714. }
  1715. air.SeatingClass = str;
  1716. string dateTime = tempstr[2];
  1717. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1718. air.FlightDate = DateTemp;
  1719. air.DepartureTime = tempstr[5];
  1720. air.LandingTime = tempstr[6];
  1721. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1722. air.TicketStatus = "--";
  1723. air.Luggage = "--";
  1724. air.DepartureTerminal = "--";
  1725. air.LandingTerminal = "--";
  1726. airs.Add(air);
  1727. }
  1728. int row = 13;
  1729. for (int i = 0; i < airs.Count; i++)
  1730. {
  1731. if (airs.Count > 2)
  1732. {
  1733. for (int j = 0; j < airs.Count - 2; j++)
  1734. {
  1735. var CopyRow = table.Rows[12].Clone(true);
  1736. table.Rows.Add(CopyRow);
  1737. }
  1738. }
  1739. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1740. int index = 0;
  1741. foreach (PropertyInfo property in properties)
  1742. {
  1743. string value = property.GetValue(airs[i]).ToString();
  1744. Cell ishcel0 = table.Rows[row].Cells[index];
  1745. Paragraph p = new Paragraph(doc);
  1746. string s = value;
  1747. p.AppendChild(new Run(doc, s));
  1748. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1749. ishcel0.AppendChild(p);
  1750. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1751. //ishcel0.CellFormat.VerticalAlignment=
  1752. index++;
  1753. }
  1754. row++;
  1755. }
  1756. #endregion
  1757. Paragraph lastParagraph = new Paragraph(doc);
  1758. //第一个表格末尾加段落
  1759. table.ParentNode.InsertAfter(lastParagraph, table);
  1760. //复制第一个表格
  1761. Table cloneTable = (Table)table.Clone(true);
  1762. //在文档末尾段落后面加入复制的表格
  1763. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1764. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1765. {
  1766. int rownewsIndex = 13;
  1767. for (int i = 0; i < 2; i++)
  1768. {
  1769. var CopyRow = table.Rows[12].Clone(true);
  1770. table.Rows.RemoveAt(13);
  1771. table.Rows.Add(CopyRow);
  1772. rownewsIndex++;
  1773. }
  1774. }
  1775. else
  1776. {
  1777. table.Rows.RemoveAt(12);
  1778. }
  1779. cloneTable.Rows.RemoveAt(12);
  1780. }
  1781. if (_AirTicketReservations.Count != 0)
  1782. {
  1783. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1784. if (FlightsCode.Length != 0)
  1785. {
  1786. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1787. if (_AirCompany != null)
  1788. {
  1789. string str = "--";
  1790. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1791. if (!string.IsNullOrEmpty(translateResult))
  1792. {
  1793. str = translateResult;
  1794. str = _airTicketResRep.Processing(str);
  1795. }
  1796. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1797. }
  1798. else
  1799. {
  1800. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1801. }
  1802. }
  1803. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1804. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1805. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1806. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1807. string names = "";
  1808. foreach (string clientName in nameArray)
  1809. {
  1810. names += clientName + ",";
  1811. }
  1812. if (!string.IsNullOrWhiteSpace(names))
  1813. {
  1814. string str = "--";
  1815. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1816. if (!string.IsNullOrEmpty(translateResult))
  1817. {
  1818. str = translateResult;
  1819. str = _airTicketResRep.Processing(str);
  1820. }
  1821. table.Range.Bookmarks["ClientName"].Text = str;
  1822. }
  1823. else
  1824. {
  1825. table.Range.Bookmarks["ClientName"].Text = "--";
  1826. }
  1827. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1828. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1829. table.Range.Bookmarks["JointTicket"].Text = "--";
  1830. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1831. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1832. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1833. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1834. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1835. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1836. }
  1837. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1838. //保存合并后的文档
  1839. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  1840. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1841. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1842. return Ok(JsonView(true, "成功!", rst));
  1843. }
  1844. }
  1845. }
  1846. catch (Exception ex)
  1847. {
  1848. return Ok(JsonView(false, "程序错误!"));
  1849. throw;
  1850. }
  1851. }
  1852. #endregion
  1853. #region 团组增减款项
  1854. /// <summary>
  1855. /// 团组增减款项下拉框绑定
  1856. /// </summary>
  1857. /// <param name="dto"></param>
  1858. /// <returns></returns>
  1859. [HttpPost]
  1860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1861. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  1862. {
  1863. try
  1864. {
  1865. Result groupData = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  1866. if (groupData.Code != 0)
  1867. {
  1868. return Ok(JsonView(false, groupData.Msg));
  1869. }
  1870. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1871. }
  1872. catch (Exception ex)
  1873. {
  1874. return Ok(JsonView(false, "程序错误!"));
  1875. throw;
  1876. }
  1877. }
  1878. /// <summary>
  1879. /// 根据团组Id查询团组增减款项
  1880. /// </summary>
  1881. /// <param name="dto"></param>
  1882. /// <returns></returns>
  1883. [HttpPost]
  1884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1885. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  1886. {
  1887. try
  1888. {
  1889. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  1890. if (groupData.Code != 0)
  1891. {
  1892. return Ok(JsonView(false, groupData.Msg));
  1893. }
  1894. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1895. }
  1896. catch (Exception ex)
  1897. {
  1898. return Ok(JsonView(false, "程序错误!"));
  1899. throw;
  1900. }
  1901. }
  1902. /// <summary>
  1903. /// 团组增减款项操作(Status:1.新增,2.修改)
  1904. /// </summary>
  1905. /// <param name="dto"></param>
  1906. /// <returns></returns>
  1907. [HttpPost]
  1908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1909. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  1910. {
  1911. try
  1912. {
  1913. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  1914. if (groupData.Code != 0)
  1915. {
  1916. return Ok(JsonView(false, groupData.Msg));
  1917. }
  1918. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1919. }
  1920. catch (Exception ex)
  1921. {
  1922. return Ok(JsonView(false, "程序错误!"));
  1923. throw;
  1924. }
  1925. }
  1926. /// <summary>
  1927. /// 团组增减款项操作 删除
  1928. /// </summary>
  1929. /// <param name="dto"></param>
  1930. /// <returns></returns>
  1931. [HttpPost]
  1932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1933. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  1934. {
  1935. try
  1936. {
  1937. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  1938. if (!res)
  1939. {
  1940. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  1941. {
  1942. IsDel = 1,
  1943. DeleteUserId = dto.DeleteUserId,
  1944. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1945. }).ExecuteCommandAsync();
  1946. return Ok(JsonView(false, "删除失败"));
  1947. }
  1948. return Ok(JsonView(true, "删除成功!"));
  1949. }
  1950. catch (Exception ex)
  1951. {
  1952. return Ok(JsonView(false, "程序错误!"));
  1953. throw;
  1954. }
  1955. }
  1956. /// <summary>
  1957. /// 根据团组增减款项Id查询
  1958. /// </summary>
  1959. /// <param name="dto"></param>
  1960. /// <returns></returns>
  1961. [HttpPost]
  1962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1963. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  1964. {
  1965. try
  1966. {
  1967. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  1968. if (groupData.Code != 0)
  1969. {
  1970. return Ok(JsonView(false, groupData.Msg));
  1971. }
  1972. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1973. }
  1974. catch (Exception ex)
  1975. {
  1976. return Ok(JsonView(false, "程序错误!"));
  1977. throw;
  1978. }
  1979. }
  1980. #endregion
  1981. #region 文件上传、删除
  1982. /// <summary>
  1983. /// region 文件上传 可以带参数
  1984. /// </summary>
  1985. /// <param name="file"></param>
  1986. /// <returns></returns>
  1987. [HttpPost]
  1988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1989. public async Task<IActionResult> UploadProject(IFormFile file)
  1990. {
  1991. try
  1992. {
  1993. var TypeName = Request.Headers["TypeName"].ToString();
  1994. if (file != null)
  1995. {
  1996. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1997. //文件名称
  1998. string projectFileName = file.FileName;
  1999. //上传的文件的路径
  2000. string filePath = "";
  2001. if (TypeName == "A")//A代表团组增减款项
  2002. {
  2003. if (!Directory.Exists(fileDir))
  2004. {
  2005. Directory.CreateDirectory(fileDir);
  2006. }
  2007. //上传的文件的路径
  2008. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2009. }
  2010. else if (TypeName == "B")//B代表商邀相关文件
  2011. {
  2012. if (!Directory.Exists(fileDir))
  2013. {
  2014. Directory.CreateDirectory(fileDir);
  2015. }
  2016. //上传的文件的路径
  2017. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2018. }
  2019. using (FileStream fs = System.IO.File.Create(filePath))
  2020. {
  2021. file.CopyTo(fs);
  2022. fs.Flush();
  2023. }
  2024. return Ok(JsonView(true, "上传成功!", projectFileName));
  2025. }
  2026. else
  2027. {
  2028. return Ok(JsonView(false, "上传失败!"));
  2029. }
  2030. }
  2031. catch (Exception ex)
  2032. {
  2033. return Ok(JsonView(false, "程序错误!"));
  2034. throw;
  2035. }
  2036. }
  2037. /// <summary>
  2038. /// 删除指定文件
  2039. /// </summary>
  2040. /// <param name="dto"></param>
  2041. /// <returns></returns>
  2042. [HttpPost]
  2043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2044. public async Task<IActionResult> DelFile(DelFileDto dto)
  2045. {
  2046. try
  2047. {
  2048. var TypeName = Request.Headers["TypeName"].ToString();
  2049. string filePath = "";
  2050. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2051. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2052. int id = 0;
  2053. if (TypeName == "A")
  2054. {
  2055. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2056. // 删除该文件
  2057. System.IO.File.Delete(filePath);
  2058. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2059. }
  2060. else if (TypeName == "B")
  2061. {
  2062. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2063. // 删除该文件
  2064. System.IO.File.Delete(filePath);
  2065. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2066. }
  2067. if (id != 0)
  2068. {
  2069. return Ok(JsonView(true, "成功!"));
  2070. }
  2071. else
  2072. {
  2073. return Ok(JsonView(false, "失败!"));
  2074. }
  2075. }
  2076. catch (Exception ex)
  2077. {
  2078. return Ok(JsonView(false, "程序错误!"));
  2079. throw;
  2080. }
  2081. }
  2082. #endregion
  2083. #region 商邀费用录入
  2084. /// <summary>
  2085. /// 根据团组Id查询商邀费用列表
  2086. /// </summary>
  2087. /// <param name="dto"></param>
  2088. /// <returns></returns>
  2089. [HttpPost]
  2090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2091. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2092. {
  2093. try
  2094. {
  2095. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2096. if (groupData.Code != 0)
  2097. {
  2098. return Ok(JsonView(false, groupData.Msg));
  2099. }
  2100. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2101. }
  2102. catch (Exception ex)
  2103. {
  2104. return Ok(JsonView(false, "程序错误!"));
  2105. throw;
  2106. }
  2107. }
  2108. /// <summary>
  2109. /// 根据商邀费用ID查询C表和商邀费用数据
  2110. /// </summary>
  2111. /// <param name="dto"></param>
  2112. /// <returns></returns>
  2113. [HttpPost]
  2114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2115. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2116. {
  2117. try
  2118. {
  2119. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2120. if (groupData.Code != 0)
  2121. {
  2122. return Ok(JsonView(false, groupData.Msg));
  2123. }
  2124. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2125. }
  2126. catch (Exception ex)
  2127. {
  2128. return Ok(JsonView(false, "程序错误!"));
  2129. throw;
  2130. }
  2131. }
  2132. /// <summary>
  2133. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2134. /// </summary>
  2135. /// <param name="dto"></param>
  2136. /// <returns></returns>
  2137. [HttpPost]
  2138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2139. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2140. {
  2141. try
  2142. {
  2143. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto);
  2144. if (groupData.Code != 0)
  2145. {
  2146. return Ok(JsonView(false, groupData.Msg));
  2147. }
  2148. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2149. }
  2150. catch (Exception ex)
  2151. {
  2152. return Ok(JsonView(false, "程序错误!"));
  2153. throw;
  2154. }
  2155. }
  2156. /// <summary>
  2157. /// 商邀删除
  2158. /// </summary>
  2159. /// <param name="dto"></param>
  2160. /// <returns></returns>
  2161. [HttpPost]
  2162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2163. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2164. {
  2165. try
  2166. {
  2167. var res = await _InvitationOfficialActivitiesRep.SoftDeleteByIdAsync<Grp_InvitationOfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  2168. if (!res)
  2169. {
  2170. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 81).SetColumns(a => new Grp_CreditCardPayment()
  2171. {
  2172. IsDel = 1,
  2173. DeleteUserId = dto.DeleteUserId,
  2174. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2175. }).ExecuteCommandAsync();
  2176. return Ok(JsonView(false, "删除失败"));
  2177. }
  2178. return Ok(JsonView(true, "删除成功!"));
  2179. }
  2180. catch (Exception ex)
  2181. {
  2182. return Ok(JsonView(false, "程序错误!"));
  2183. throw;
  2184. }
  2185. }
  2186. #endregion
  2187. #region 团组英文资料
  2188. /// <summary>
  2189. /// 查询团组英文所有资料
  2190. /// </summary>
  2191. /// <param name="dto"></param>
  2192. /// <returns></returns>
  2193. [HttpPost]
  2194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2195. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2196. {
  2197. try
  2198. {
  2199. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  2200. if (groupData.Code != 0)
  2201. {
  2202. return Ok(JsonView(false, groupData.Msg));
  2203. }
  2204. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2205. }
  2206. catch (Exception ex)
  2207. {
  2208. return Ok(JsonView(false, "程序错误!"));
  2209. throw;
  2210. }
  2211. }
  2212. /// <summary>
  2213. /// 团组英文资料操作(Status:1.新增,2.修改)
  2214. /// </summary>
  2215. /// <param name="dto"></param>
  2216. /// <returns></returns>
  2217. [HttpPost]
  2218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2219. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  2220. {
  2221. try
  2222. {
  2223. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  2224. if (groupData.Code != 0)
  2225. {
  2226. return Ok(JsonView(false, groupData.Msg));
  2227. }
  2228. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2229. }
  2230. catch (Exception ex)
  2231. {
  2232. return Ok(JsonView(false, "程序错误!"));
  2233. throw;
  2234. }
  2235. }
  2236. /// <summary>
  2237. /// 团组英文资料Id查询数据
  2238. /// </summary>
  2239. /// <param name="dto"></param>
  2240. /// <returns></returns>
  2241. [HttpPost]
  2242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2243. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  2244. {
  2245. try
  2246. {
  2247. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  2248. if (_DelegationEnData != null)
  2249. {
  2250. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  2251. }
  2252. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  2253. }
  2254. catch (Exception ex)
  2255. {
  2256. return Ok(JsonView(false, "程序错误!"));
  2257. throw;
  2258. }
  2259. }
  2260. /// <summary>
  2261. /// 团组英文资料删除
  2262. /// </summary>
  2263. /// <param name="dto"></param>
  2264. /// <returns></returns>
  2265. [HttpPost]
  2266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2267. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2268. {
  2269. try
  2270. {
  2271. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2272. if (!res)
  2273. {
  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> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2294. {
  2295. try
  2296. {
  2297. List<Grp_DelegationInfo> grp_Delegations = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToListAsync();
  2298. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2299. if (dto.DiId == 0)
  2300. {
  2301. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2302. }
  2303. else
  2304. {
  2305. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2306. }
  2307. return Ok(JsonView(true, "查询成功!", new
  2308. {
  2309. deleClient = crm_Deles,
  2310. delegations = grp_Delegations
  2311. }));
  2312. }
  2313. catch (Exception ex)
  2314. {
  2315. return Ok(JsonView(false, "程序错误!"));
  2316. throw;
  2317. }
  2318. }
  2319. /// <summary>
  2320. /// 导出邀请函
  2321. /// </summary>
  2322. /// <param name="dto"></param>
  2323. /// <returns></returns>
  2324. [HttpPost]
  2325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2326. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2327. {
  2328. try
  2329. {
  2330. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2331. List<Crm_DeleClient> crm_DeleClients = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2332. List<string> texts = new List<string>();
  2333. if (crm_DeleClients.Count != 0)
  2334. {
  2335. foreach (Crm_DeleClient item in crm_DeleClients)
  2336. {
  2337. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2338. {
  2339. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2340. }
  2341. else
  2342. {
  2343. string name = item.LastName + item.FirstName;
  2344. texts.Add(name);
  2345. }
  2346. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  2347. {
  2348. if (!transDic.ContainsKey(item.Job))
  2349. {
  2350. texts.Add(item.Job);
  2351. }
  2352. }
  2353. if (item.CrmCompanyId != 0)
  2354. {
  2355. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == item.CrmCompanyId && a.IsDel == 0);
  2356. if (!transDic.ContainsKey(crm_Customer.CompanyName))
  2357. {
  2358. texts.Add(crm_Customer.CompanyName);
  2359. }
  2360. }
  2361. }
  2362. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2363. if (transData.Count > 0)
  2364. {
  2365. foreach (TranslateResult item in transData)
  2366. {
  2367. if (!transDic.ContainsKey(item.Query))
  2368. {
  2369. transDic.Add(item.Query, item.Translation);
  2370. }
  2371. }
  2372. }
  2373. List<guestList> list = new List<guestList>();
  2374. foreach (Crm_DeleClient dele in crm_DeleClients)
  2375. {
  2376. guestList guestList = new guestList();
  2377. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  2378. {
  2379. guestList.Name = dele.Pinyin;
  2380. }
  2381. else
  2382. {
  2383. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  2384. guestList.Name = Name;
  2385. }
  2386. if (dele.Sex == 0)
  2387. {
  2388. guestList.Sex = "Male";
  2389. }
  2390. else if (dele.Sex == 1)
  2391. {
  2392. guestList.Sex = "Female";
  2393. }
  2394. guestList.DOB = dele.BirthDay.Replace('-', '.');
  2395. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == dele.CrmCompanyId && a.IsDel == 0);
  2396. string jobName = transDic.Where(s => s.Key == crm_Customer.CompanyName).FirstOrDefault().Value + " " + transDic.Where(s => s.Key == dele.Job).FirstOrDefault().Value;
  2397. guestList.Job = jobName;
  2398. list.Add(guestList);
  2399. }
  2400. //载入模板
  2401. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  2402. DocumentBuilder builder = new DocumentBuilder(doc);
  2403. //获取word里所有表格
  2404. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2405. //获取所填表格的序数
  2406. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2407. var rowStart = tableOne.Rows[0]; //获取第1行
  2408. //循环赋值
  2409. for (int i = 0; i < list.Count; i++)
  2410. {
  2411. builder.MoveToCell(0, i + 1, 0, 0);
  2412. builder.Write(list[i].Name.ToString());
  2413. builder.MoveToCell(0, i + 1, 1, 0);
  2414. builder.Write(list[i].Sex.ToString());
  2415. builder.MoveToCell(0, i + 1, 2, 0);
  2416. builder.Write(list[i].DOB.ToString());
  2417. builder.MoveToCell(0, i + 1, 3, 0);
  2418. builder.Write(list[i].Job.ToString());
  2419. }
  2420. //删除多余行
  2421. while (tableOne.Rows.Count > list.Count + 1)
  2422. {
  2423. tableOne.Rows.RemoveAt(list.Count + 1);
  2424. }
  2425. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2426. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  2427. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  2428. doc.Save(filePath);
  2429. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件" + fileName;
  2430. return Ok(JsonView(true, "成功!", Url));
  2431. }
  2432. else
  2433. {
  2434. return Ok(JsonView(false, "失败,该团组没有客户名单!"));
  2435. }
  2436. }
  2437. catch (Exception ex)
  2438. {
  2439. return Ok(JsonView(false, "程序错误!"));
  2440. throw;
  2441. }
  2442. }
  2443. #endregion
  2444. #region 团组经理模块 出入境费用
  2445. ///// <summary>
  2446. ///// 团组模块 - 出入境费用
  2447. ///// </summary>
  2448. ///// <returns></returns>
  2449. //[HttpPost]
  2450. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2451. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  2452. //{
  2453. // try
  2454. // {
  2455. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  2456. // if (data.Code != 0)
  2457. // {
  2458. // return Ok(JsonView(false, data.Msg));
  2459. // }
  2460. // return Ok(JsonView(true, "查询成功!"));
  2461. // }
  2462. // catch (Exception ex)
  2463. // {
  2464. // return Ok(JsonView(false, ex.Message));
  2465. // throw;
  2466. // }
  2467. //}
  2468. /// <summary>
  2469. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  2470. /// </summary>
  2471. /// <returns></returns>
  2472. [HttpPost]
  2473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2474. public async Task<IActionResult> SetDayAndCostAreaChange()
  2475. {
  2476. try
  2477. {
  2478. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  2479. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  2480. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  2481. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  2482. foreach (var item in unite) //处理交集数据
  2483. {
  2484. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  2485. }
  2486. foreach (var item in merge) //处理差集数据
  2487. {
  2488. int nationalTravelFeeId = 0;
  2489. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  2490. if (cityData != null) nationalTravelFeeId = cityData.Id;
  2491. else
  2492. {
  2493. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  2494. if (countryData != null) nationalTravelFeeId = countryData.Id;
  2495. }
  2496. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  2497. }
  2498. //只更新dayAndCost 的 nationalTravelFeeId;
  2499. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  2500. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  2501. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  2502. }
  2503. catch (Exception ex)
  2504. {
  2505. return Ok(JsonView(false, ex.Message));
  2506. throw;
  2507. }
  2508. }
  2509. /// <summary>
  2510. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  2511. /// </summary>
  2512. /// <returns></returns>
  2513. [HttpPost]
  2514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2515. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  2516. {
  2517. try
  2518. {
  2519. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  2520. string currencySql = string.Format("Select * From Sys_SetData Where STid = 66 And IsDel = 0");
  2521. var currencyData = await _sqlSugar.SqlQueryable<SetDataInfoView>(currencySql).ToListAsync();
  2522. //string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2523. // Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2524. // Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2525. // Where gntf.Isdel = 0");
  2526. //var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2527. return Ok(JsonView(true, "查询成功!", new
  2528. {
  2529. GroupNameData = groupNameData.Data,
  2530. CurrencyData = currencyData,
  2531. //NationalTravelFeeData = nationalTravelFeeData
  2532. }));
  2533. }
  2534. catch (Exception ex)
  2535. {
  2536. return Ok(JsonView(false, ex.Message));
  2537. throw;
  2538. }
  2539. }
  2540. /// <summary>
  2541. /// 团组模块 - 出入境费用 - Info
  2542. /// </summary>
  2543. /// <returns></returns>
  2544. [HttpPost]
  2545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2546. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  2547. {
  2548. try
  2549. {
  2550. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  2551. if (data.Code != 0)
  2552. {
  2553. return Ok(JsonView(false, data.Msg));
  2554. }
  2555. return Ok(JsonView(true, "查询成功!", data.Data));
  2556. }
  2557. catch (Exception ex)
  2558. {
  2559. return Ok(JsonView(false, ex.Message));
  2560. }
  2561. }
  2562. /// <summary>
  2563. /// 团组模块 - 出入境费用 - Add And Update
  2564. /// </summary>
  2565. /// <returns></returns>
  2566. [HttpPost]
  2567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2568. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  2569. {
  2570. try
  2571. {
  2572. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2573. if (data.Code != 0)
  2574. {
  2575. return Ok(JsonView(false, data.Msg));
  2576. }
  2577. return Ok(JsonView(true, data.Msg, data.Data));
  2578. }
  2579. catch (Exception ex)
  2580. {
  2581. return Ok(JsonView(false, ex.Message));
  2582. }
  2583. }
  2584. /// <summary>
  2585. /// 团组模块 - 出入境费用 - 明细表导出
  2586. /// </summary>
  2587. /// <returns></returns>
  2588. [HttpPost]
  2589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2590. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  2591. {
  2592. try
  2593. {
  2594. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2595. if (data.Code != 0)
  2596. {
  2597. return Ok(JsonView(false, data.Msg));
  2598. }
  2599. return Ok(JsonView(true, data.Msg, data.Data));
  2600. }
  2601. catch (Exception ex)
  2602. {
  2603. return Ok(JsonView(false, ex.Message));
  2604. }
  2605. }
  2606. /// <summary>
  2607. /// 团组模块 - 出入境费用 - 子项删除
  2608. /// </summary>
  2609. /// <returns></returns>
  2610. [HttpPost]
  2611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2612. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  2613. {
  2614. try
  2615. {
  2616. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  2617. if (data.Code != 0)
  2618. {
  2619. return Ok(JsonView(false, data.Msg));
  2620. }
  2621. return Ok(JsonView(true, "操作成功!", data.Data));
  2622. }
  2623. catch (Exception ex)
  2624. {
  2625. return Ok(JsonView(false, ex.Message));
  2626. }
  2627. }
  2628. /// <summary>
  2629. /// 团组模块 - 出入境国家费用标准 List
  2630. /// </summary>
  2631. /// <returns></returns>
  2632. [HttpPost]
  2633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2634. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  2635. {
  2636. try
  2637. {
  2638. Stopwatch sw = new Stopwatch();
  2639. sw.Start();
  2640. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2641. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2642. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2643. Where gntf.Isdel = 0");
  2644. var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2645. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  2646. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  2647. //foreach (var item in nationalTravel)
  2648. //{
  2649. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  2650. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  2651. // if (otherData != null)
  2652. // {
  2653. // cityData.Remove(otherData);
  2654. // cityData.Add(otherData);
  2655. // }
  2656. // nationalTravelFeeData1.Add(new
  2657. // {
  2658. // Country = item.Country,
  2659. // CityData = cityData
  2660. // });
  2661. //}
  2662. sw.Stop();
  2663. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  2664. }
  2665. catch (Exception ex)
  2666. {
  2667. return Ok(JsonView(false, ex.Message));
  2668. throw;
  2669. }
  2670. }
  2671. /// <summary>
  2672. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  2673. /// </summary>
  2674. /// <returns></returns>
  2675. [HttpPost]
  2676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2677. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  2678. {
  2679. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  2680. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  2681. List<string> countryData = new List<string>();
  2682. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  2683. countryData = countryData.Distinct().ToList();
  2684. List<dynamic> dataSource = new List<dynamic>();
  2685. foreach (var item in countryData)
  2686. {
  2687. List<string> cityData1 = new List<string>();
  2688. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  2689. var countryData2 = new
  2690. {
  2691. CountryName = item,
  2692. CityData = cityData1
  2693. };
  2694. dataSource.Add(countryData2);
  2695. }
  2696. return Ok(JsonView(true, "查询成功!", dataSource));
  2697. }
  2698. /// <summary>
  2699. /// 团组模块 - 出入境国家费用标准 Page List
  2700. /// </summary>
  2701. /// <returns></returns>
  2702. [HttpPost]
  2703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2704. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  2705. {
  2706. int portId = dto.PortType;
  2707. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2708. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  2709. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  2710. string whereSql = string.Empty;
  2711. if (!string.IsNullOrEmpty(dto.Country))
  2712. {
  2713. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  2714. }
  2715. if (!string.IsNullOrEmpty(dto.City))
  2716. {
  2717. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  2718. }
  2719. string pageSql = string.Format(@"Select * From (
  2720. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  2721. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  2722. From Grp_NationalTravelFee gntf
  2723. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2724. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2725. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  2726. RefAsync<int> total = 0;
  2727. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  2728. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  2729. }
  2730. /// <summary>
  2731. /// 团组模块 - 出入境国家费用标准 根据城市查询
  2732. /// </summary>
  2733. /// <returns></returns>
  2734. [HttpPost]
  2735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2736. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  2737. {
  2738. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  2739. int portId = dto.PortType;
  2740. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2741. string whereSql = string.Empty;
  2742. if (!string.IsNullOrEmpty(dto.Country))
  2743. {
  2744. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  2745. }
  2746. if (!string.IsNullOrEmpty(dto.City))
  2747. {
  2748. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  2749. }
  2750. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  2751. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  2752. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  2753. From Grp_NationalTravelFee gntf
  2754. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2755. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2756. Where gntf.Isdel = 0 {0} ", whereSql);
  2757. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  2758. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  2759. }
  2760. /// <summary>
  2761. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  2762. /// </summary>
  2763. /// <returns></returns>
  2764. [HttpPost]
  2765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2766. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  2767. {
  2768. try
  2769. {
  2770. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  2771. if (data.Code != 0)
  2772. {
  2773. return Ok(JsonView(false, data.Msg));
  2774. }
  2775. return Ok(JsonView(true, "操作成功!", data.Data));
  2776. }
  2777. catch (Exception ex)
  2778. {
  2779. return Ok(JsonView(false, ex.Message));
  2780. }
  2781. }
  2782. /// <summary>
  2783. /// 团组模块 - 出入境国家费用标准 - Del
  2784. /// </summary>
  2785. /// <returns></returns>
  2786. [HttpPost]
  2787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2788. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  2789. {
  2790. try
  2791. {
  2792. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  2793. {
  2794. Id = dto.Id,
  2795. DeleteUserId = dto.DeleteUserId,
  2796. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  2797. IsDel = 1
  2798. };
  2799. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  2800. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  2801. .WhereColumns(it => new { it.Id })
  2802. .ExecuteCommandAsync();
  2803. if (delStatus <= 0)
  2804. {
  2805. return Ok(JsonView(false, "删除失败!"));
  2806. }
  2807. return Ok(JsonView(true, "操作成功!"));
  2808. }
  2809. catch (Exception ex)
  2810. {
  2811. return Ok(JsonView(false, ex.Message));
  2812. }
  2813. }
  2814. #endregion
  2815. #region 签证费用录入
  2816. /// <summary>
  2817. /// 根据diid查询签证费用列表
  2818. /// </summary>
  2819. /// <param name="dto"></param>
  2820. /// <returns></returns>
  2821. [HttpPost]
  2822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2823. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  2824. {
  2825. try
  2826. {
  2827. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  2828. if (groupData.Code != 0)
  2829. {
  2830. return Ok(JsonView(false, groupData.Msg));
  2831. }
  2832. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2833. }
  2834. catch (Exception ex)
  2835. {
  2836. return Ok(JsonView(false, ex.Message));
  2837. }
  2838. }
  2839. /// <summary>
  2840. /// 根据签证费用Id查询单条数据及c表数据
  2841. /// </summary>
  2842. /// <param name="dto"></param>
  2843. /// <returns></returns>
  2844. [HttpPost]
  2845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2846. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  2847. {
  2848. try
  2849. {
  2850. Result groupData = await _visaPriceRep.PostVisaById(dto);
  2851. if (groupData.Code != 0)
  2852. {
  2853. return Ok(JsonView(false, groupData.Msg));
  2854. }
  2855. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2856. }
  2857. catch (Exception ex)
  2858. {
  2859. return Ok(JsonView(false, ex.Message));
  2860. }
  2861. }
  2862. /// <summary>
  2863. /// 签证费用删除
  2864. /// </summary>
  2865. /// <param name="dto"></param>
  2866. /// <returns></returns>
  2867. [HttpPost]
  2868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2869. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  2870. {
  2871. try
  2872. {
  2873. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  2874. if (!res)
  2875. {
  2876. return Ok(JsonView(false, "删除失败"));
  2877. }
  2878. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
  2879. {
  2880. IsDel = 1,
  2881. DeleteUserId = dto.DeleteUserId,
  2882. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2883. }).ExecuteCommandAsync();
  2884. return Ok(JsonView(true, "删除成功!"));
  2885. }
  2886. catch (Exception ex)
  2887. {
  2888. return Ok(JsonView(false, "程序错误!"));
  2889. throw;
  2890. }
  2891. }
  2892. /// <summary>
  2893. /// 签证费用录入下拉框初始化
  2894. /// </summary>
  2895. /// <returns></returns>
  2896. [HttpPost]
  2897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2898. public async Task<IActionResult> VisaPriceAddSelect()
  2899. {
  2900. try
  2901. {
  2902. //支付方式
  2903. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  2904. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  2905. //币种
  2906. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  2907. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  2908. //乘客类型
  2909. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  2910. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  2911. //卡类型
  2912. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  2913. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  2914. var data = new
  2915. {
  2916. Payment = _Payment,
  2917. CurrencyList = _CurrencyList,
  2918. PassengerType = _PassengerType,
  2919. BankCard = _BankCard
  2920. };
  2921. return Ok(JsonView(true, "查询成功!", data));
  2922. }
  2923. catch (Exception ex)
  2924. {
  2925. return Ok(JsonView(false, "程序错误!"));
  2926. throw;
  2927. }
  2928. }
  2929. /// <summary>
  2930. /// 签证费用录入操作(Status:1.新增,2.修改)
  2931. /// </summary>
  2932. /// <param name="dto"></param>
  2933. /// <returns></returns>
  2934. [HttpPost]
  2935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2936. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  2937. {
  2938. try
  2939. {
  2940. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  2941. if (groupData.Code != 0)
  2942. {
  2943. return Ok(JsonView(false, groupData.Msg));
  2944. }
  2945. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2946. }
  2947. catch (Exception ex)
  2948. {
  2949. return Ok(JsonView(false, ex.Message));
  2950. }
  2951. }
  2952. #endregion
  2953. #region op费用录入
  2954. /// <summary>
  2955. /// 根据diid查询op费用列表
  2956. /// </summary>
  2957. /// <param name="dto"></param>
  2958. /// <returns></returns>
  2959. [HttpPost]
  2960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2961. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  2962. {
  2963. try
  2964. {
  2965. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  2966. if (groupData.Code != 0)
  2967. {
  2968. return Ok(JsonView(false, groupData.Msg));
  2969. }
  2970. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2971. }
  2972. catch (Exception ex)
  2973. {
  2974. return Ok(JsonView(false, ex.Message));
  2975. }
  2976. }
  2977. /// <summary>
  2978. /// 根据op费用Id查询单条数据及c表数据
  2979. /// </summary>
  2980. /// <param name="dto"></param>
  2981. /// <returns></returns>
  2982. [HttpPost]
  2983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2984. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  2985. {
  2986. try
  2987. {
  2988. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  2989. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  2990. var data = new
  2991. {
  2992. CarTouristGuideGround = _groupData,
  2993. CreditCardPayment = _creditCardPayment
  2994. };
  2995. return Ok(JsonView(true, "查询成功!", data));
  2996. }
  2997. catch (Exception ex)
  2998. {
  2999. return Ok(JsonView(false, "程序错误!"));
  3000. }
  3001. }
  3002. /// <summary>
  3003. /// op费用删除
  3004. /// </summary>
  3005. /// <param name="dto"></param>
  3006. /// <returns></returns>
  3007. [HttpPost]
  3008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3009. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  3010. {
  3011. try
  3012. {
  3013. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3014. if (!res)
  3015. {
  3016. return Ok(JsonView(false, "删除失败"));
  3017. }
  3018. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  3019. {
  3020. IsDel = 1,
  3021. DeleteUserId = dto.DeleteUserId,
  3022. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3023. }).ExecuteCommandAsync();
  3024. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  3025. {
  3026. IsDel = 1,
  3027. DeleteUserId = dto.DeleteUserId,
  3028. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3029. }).ExecuteCommandAsync();
  3030. return Ok(JsonView(true, "删除成功!"));
  3031. }
  3032. catch (Exception ex)
  3033. {
  3034. return Ok(JsonView(false, "程序错误!"));
  3035. throw;
  3036. }
  3037. }
  3038. /// <summary>
  3039. /// op费用录入操作(Status:1.新增,2.修改)
  3040. /// </summary>
  3041. /// <param name="dto"></param>
  3042. /// <returns></returns>
  3043. [HttpPost]
  3044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3045. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  3046. {
  3047. try
  3048. {
  3049. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  3050. if (groupData.Code != 0)
  3051. {
  3052. return Ok(JsonView(false, groupData.Msg));
  3053. }
  3054. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3055. }
  3056. catch (Exception ex)
  3057. {
  3058. return Ok(JsonView(false, ex.Message));
  3059. }
  3060. }
  3061. /// <summary>
  3062. /// 填写费用详细页面初始化绑定
  3063. /// </summary>
  3064. /// <param name="dto"></param>
  3065. /// <returns></returns>
  3066. [HttpPost]
  3067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3068. public async Task<IActionResult> CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  3069. {
  3070. try
  3071. {
  3072. Result groupData = await _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  3073. if (groupData.Code != 0)
  3074. {
  3075. return Ok(JsonView(false, groupData.Msg));
  3076. }
  3077. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3078. }
  3079. catch (Exception ex)
  3080. {
  3081. return Ok(JsonView(false, ex.Message));
  3082. }
  3083. }
  3084. /// <summary>
  3085. /// 根据op费用Id查询详细数据
  3086. /// </summary>
  3087. /// <param name="dto"></param>
  3088. /// <returns></returns>
  3089. [HttpPost]
  3090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3091. public async Task<IActionResult> OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  3092. {
  3093. try
  3094. {
  3095. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  3096. if (groupData.Code != 0)
  3097. {
  3098. return Ok(JsonView(false, groupData.Msg));
  3099. }
  3100. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3101. }
  3102. catch (Exception ex)
  3103. {
  3104. return Ok(JsonView(false, ex.Message));
  3105. }
  3106. }
  3107. /// <summary>
  3108. /// OP费用录入填写详情
  3109. /// </summary>
  3110. /// <param name="dto"></param>
  3111. /// <returns></returns>
  3112. [HttpPost]
  3113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3114. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  3115. {
  3116. try
  3117. {
  3118. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  3119. if (groupData.Code != 0)
  3120. {
  3121. return Ok(JsonView(false, groupData.Msg));
  3122. }
  3123. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3124. }
  3125. catch (Exception ex)
  3126. {
  3127. return Ok(JsonView(false, ex.Message));
  3128. }
  3129. }
  3130. #endregion
  3131. #region 团组成本
  3132. /// <summary>
  3133. /// 团组成本数据初始化
  3134. /// </summary>
  3135. /// <param name="dto"></param>
  3136. /// <returns></returns>
  3137. [HttpPost]
  3138. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  3139. {
  3140. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  3141. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  3142. WHEN COUNT(*) >= 0 THEN 'True'
  3143. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  3144. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  3145. ").ToList(); //团组列表
  3146. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  3147. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  3148. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  3149. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  3150. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  3151. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  3152. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  3153. //GroupCostParameter.Add(new
  3154. // Grp_GroupCostParameter());
  3155. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  3156. return Ok(JsonView(new
  3157. {
  3158. groupList,
  3159. groupInfo,
  3160. groupChecks,
  3161. groupCost = groupCostMap,
  3162. hotelNumber,
  3163. GroupCostParameter = GroupCostParameterMap,
  3164. }));
  3165. }
  3166. /// <summary>
  3167. /// 团组成本信息保存
  3168. /// </summary>
  3169. /// <param name="dto"></param>
  3170. /// <returns></returns>
  3171. [HttpPost]
  3172. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  3173. {
  3174. JsonView jw = null;
  3175. bool isTrue = false;
  3176. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  3177. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  3178. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  3179. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  3180. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  3181. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  3182. try
  3183. {
  3184. _sqlSugar.BeginTran();
  3185. isTrue = await _GroupCostRepository.
  3186. SaveGroupCostList(Grp_groups, dto.Diid); //列表
  3187. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  3188. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  3189. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  3190. _sqlSugar.CommitTran();
  3191. jw = JsonView(true, "保存成功!", isTrue);
  3192. }
  3193. catch (Exception)
  3194. {
  3195. _sqlSugar.RollbackTran();
  3196. jw = JsonView(false);
  3197. }
  3198. return Ok(jw);
  3199. }
  3200. /// <summary>
  3201. /// 司兼导数据
  3202. /// </summary>
  3203. /// <param name="dto"></param>
  3204. /// <returns></returns>
  3205. [HttpPost]
  3206. public IActionResult GetCarGuides(CarGuidesDto dto)
  3207. {
  3208. JsonView jw = null;
  3209. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  3210. jw = JsonView(true, "获取成功!", Data);
  3211. return Ok(jw);
  3212. }
  3213. /// <summary>
  3214. /// 导游数据
  3215. /// </summary>
  3216. /// <param name="dto"></param>
  3217. /// <returns></returns>
  3218. [HttpPost]
  3219. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  3220. {
  3221. JsonView jw = null;
  3222. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  3223. // 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
  3224. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  3225. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  3226. jw = JsonView(true, "获取成功!", Data);
  3227. return Ok(jw);
  3228. }
  3229. /// <summary>
  3230. /// 成本车数据
  3231. /// </summary>
  3232. /// <param name="dto"></param>
  3233. /// <returns></returns>
  3234. [HttpPost]
  3235. public IActionResult GetCarInfo(CarGuidesDto dto)
  3236. {
  3237. JsonView jw = null;
  3238. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  3239. jw = JsonView(true, "获取成功!", Data);
  3240. return Ok(jw);
  3241. }
  3242. /// <summary>
  3243. /// 景点数据
  3244. /// </summary>
  3245. /// <param name="dto"></param>
  3246. /// <returns></returns>
  3247. [HttpPost]
  3248. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  3249. {
  3250. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  3251. return Ok(JsonView(true, "获取成功!", Data));
  3252. }
  3253. #endregion
  3254. #region 酒店预定
  3255. /// <summary>
  3256. /// 酒店预订页面初始化绑定
  3257. /// </summary>
  3258. /// <param name="dto"></param>
  3259. /// <returns></returns>
  3260. [HttpPost]
  3261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3262. public async Task<IActionResult> HotelReservationsInitialize(HotelReservationsDto dto)
  3263. {
  3264. try
  3265. {
  3266. Result groupData = await _hotelPriceRep.HotelReservationsInitialize(dto);
  3267. if (groupData.Code != 0)
  3268. {
  3269. return Ok(JsonView(false, groupData.Msg));
  3270. }
  3271. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3272. }
  3273. catch (Exception ex)
  3274. {
  3275. return Ok(JsonView(false, ex.Message));
  3276. }
  3277. }
  3278. /// <summary>
  3279. /// 根据团组Id查询酒店费用列表
  3280. /// </summary>
  3281. /// <param name="dto"></param>
  3282. /// <returns></returns>
  3283. [HttpPost]
  3284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3285. public async Task<IActionResult> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
  3286. {
  3287. try
  3288. {
  3289. Result groupData = await _hotelPriceRep.HotelReservationsByDiId(dto);
  3290. if (groupData.Code != 0)
  3291. {
  3292. return Ok(JsonView(false, groupData.Msg));
  3293. }
  3294. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3295. }
  3296. catch (Exception ex)
  3297. {
  3298. return Ok(JsonView(false, ex.Message));
  3299. }
  3300. }
  3301. /// <summary>
  3302. /// 根据酒店费用Id查询酒店费用详细
  3303. /// </summary>
  3304. /// <param name="dto"></param>
  3305. /// <returns></returns>
  3306. [HttpPost]
  3307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3308. public async Task<IActionResult> HotelReservationsById(HotelReservationsByIdDto dto)
  3309. {
  3310. try
  3311. {
  3312. Result groupData = await _hotelPriceRep.HotelReservationsById(dto);
  3313. if (groupData.Code != 0)
  3314. {
  3315. return Ok(JsonView(false, groupData.Msg));
  3316. }
  3317. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3318. }
  3319. catch (Exception ex)
  3320. {
  3321. return Ok(JsonView(false, ex.Message));
  3322. }
  3323. }
  3324. /// <summary>
  3325. /// 计算酒店付款总金额
  3326. /// </summary>
  3327. /// <param name="dto"></param>
  3328. /// <returns></returns>
  3329. [HttpPost]
  3330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3331. public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
  3332. {
  3333. try
  3334. {
  3335. Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
  3336. if (groupData.Code != 0)
  3337. {
  3338. return Ok(JsonView(false, groupData.Msg));
  3339. }
  3340. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3341. }
  3342. catch (Exception ex)
  3343. {
  3344. return Ok(JsonView(false, ex.Message));
  3345. }
  3346. }
  3347. /// <summary>
  3348. /// 酒店费用操作(Status:1.新增,2.修改)
  3349. /// </summary>
  3350. /// <param name="dto"></param>
  3351. /// <returns></returns>
  3352. [HttpPost]
  3353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3354. public async Task<IActionResult> OpHotelReservations(OpHotelReservationsData dto)
  3355. {
  3356. try
  3357. {
  3358. Result groupData = await _hotelPriceRep.OpHotelReservations(dto);
  3359. if (groupData.Code != 0)
  3360. {
  3361. return Ok(JsonView(false, groupData.Msg));
  3362. }
  3363. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3364. }
  3365. catch (Exception ex)
  3366. {
  3367. return Ok(JsonView(false, ex.Message));
  3368. }
  3369. }
  3370. /// <summary>
  3371. /// 文件上传
  3372. /// </summary>
  3373. /// <param name="file"></param>
  3374. /// <returns></returns>
  3375. [HttpPost]
  3376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3377. public async Task<IActionResult> UploadHotel(IFormFile file)
  3378. {
  3379. try
  3380. {
  3381. if (file != null)
  3382. {
  3383. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3384. //文件名称
  3385. string projectFileName = file.FileName;
  3386. //上传的文件的路径
  3387. string filePath = "";
  3388. if (!Directory.Exists(fileDir))
  3389. {
  3390. Directory.CreateDirectory(fileDir);
  3391. }
  3392. //上传的文件的路径
  3393. filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
  3394. using (FileStream fs = System.IO.File.Create(filePath))
  3395. {
  3396. file.CopyTo(fs);
  3397. fs.Flush();
  3398. }
  3399. return Ok(JsonView(true, "上传成功!", projectFileName));
  3400. }
  3401. else
  3402. {
  3403. return Ok(JsonView(false, "上传失败!"));
  3404. }
  3405. }
  3406. catch (Exception ex)
  3407. {
  3408. return Ok(JsonView(false, "程序错误!"));
  3409. throw;
  3410. }
  3411. }
  3412. /// <summary>
  3413. /// 删除指定文件
  3414. /// </summary>
  3415. /// <param name="dto"></param>
  3416. /// <returns></returns>
  3417. [HttpPost]
  3418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3419. public async Task<IActionResult> DelFileHotel(DelFileDto dto)
  3420. {
  3421. try
  3422. {
  3423. string filePath = "";
  3424. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3425. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3426. //int id = 0;
  3427. filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
  3428. // 删除该文件
  3429. try
  3430. {
  3431. System.IO.File.Delete(filePath);
  3432. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3433. {
  3434. Attachment = "",
  3435. }).ExecuteCommandAsync();
  3436. if (result != 0)
  3437. {
  3438. return Ok(JsonView(true, "成功!"));
  3439. }
  3440. else
  3441. {
  3442. return Ok(JsonView(false, "失败!"));
  3443. }
  3444. }
  3445. catch (Exception)
  3446. {
  3447. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3448. {
  3449. Attachment = "",
  3450. }).ExecuteCommandAsync();
  3451. if (result != 0)
  3452. {
  3453. return Ok(JsonView(true, "成功!"));
  3454. }
  3455. else
  3456. {
  3457. return Ok(JsonView(false, "失败!"));
  3458. }
  3459. throw;
  3460. }
  3461. }
  3462. catch (Exception ex)
  3463. {
  3464. return Ok(JsonView(false, "程序错误!"));
  3465. throw;
  3466. }
  3467. }
  3468. /// <summary>
  3469. /// 生成VOUCHER
  3470. /// </summary>
  3471. /// <param name=""></param>
  3472. /// <returns></returns>
  3473. [HttpPost]
  3474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3475. public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
  3476. {
  3477. Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
  3478. //判断数据是否完整
  3479. if (h != null)
  3480. {
  3481. if (!string.IsNullOrEmpty(h.DetermineNo))
  3482. {
  3483. string strFileName = "HotelStatement/";
  3484. Grp_DelegationInfo dele = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
  3485. if (dele != null)
  3486. strFileName += dele.TourCode;
  3487. //载入模板
  3488. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  3489. Document doc = new Document(sss);
  3490. DocumentBuilder builder = new DocumentBuilder(doc);
  3491. try
  3492. {
  3493. #region 替换Word模板书签内容
  3494. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  3495. //入住卷预定号码
  3496. if (doc.Range.Bookmarks["VNO"] != null)
  3497. {
  3498. Bookmark mark = doc.Range.Bookmarks["VNO"];
  3499. mark.Text = h.CheckNumber;
  3500. }
  3501. //酒店时间
  3502. if (doc.Range.Bookmarks["Date"] != null)
  3503. {
  3504. Bookmark mark = doc.Range.Bookmarks["Date"];
  3505. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3506. }
  3507. //团号
  3508. if (doc.Range.Bookmarks["TNo"] != null)
  3509. {
  3510. Bookmark mark = doc.Range.Bookmarks["TNo"];
  3511. mark.Text = dele.TourCode;
  3512. }
  3513. //预定号码
  3514. if (doc.Range.Bookmarks["BookingId"] != null)
  3515. {
  3516. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  3517. mark.Text = h.ReservationsNo;
  3518. }
  3519. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  3520. {
  3521. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  3522. mark.Text = h.DetermineNo;
  3523. }
  3524. //酒店城市
  3525. if (doc.Range.Bookmarks["City"] != null)
  3526. {
  3527. Bookmark mark = doc.Range.Bookmarks["City"];
  3528. mark.Text = h.City;
  3529. }
  3530. //酒店名称
  3531. if (doc.Range.Bookmarks["HName"] != null)
  3532. {
  3533. Bookmark mark = doc.Range.Bookmarks["HName"];
  3534. mark.Text = h.HotelName;
  3535. }
  3536. //酒店地址
  3537. if (doc.Range.Bookmarks["Address"] != null)
  3538. {
  3539. Bookmark mark = doc.Range.Bookmarks["Address"];
  3540. mark.Text = h.HotelAddress;
  3541. }
  3542. //酒店电话
  3543. if (doc.Range.Bookmarks["Tel"] != null)
  3544. {
  3545. Bookmark mark = doc.Range.Bookmarks["Tel"];
  3546. mark.Text = h.HotelTel;
  3547. }
  3548. //酒店传真
  3549. if (doc.Range.Bookmarks["Fax"] != null)
  3550. {
  3551. Bookmark mark = doc.Range.Bookmarks["Fax"];
  3552. if (!string.IsNullOrWhiteSpace(h.HotelFax))
  3553. {
  3554. mark.Text = h.HotelFax;
  3555. }
  3556. }
  3557. //入住时间
  3558. if (doc.Range.Bookmarks["CIn"] != null)
  3559. {
  3560. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3561. Bookmark mark = doc.Range.Bookmarks["CIn"];
  3562. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  3563. }
  3564. //退房时间
  3565. if (doc.Range.Bookmarks["COut"] != null)
  3566. {
  3567. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3568. Bookmark mark = doc.Range.Bookmarks["COut"];
  3569. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3570. }
  3571. //客户名称
  3572. if (doc.Range.Bookmarks["GName"] != null)
  3573. {
  3574. Bookmark mark = doc.Range.Bookmarks["GName"];
  3575. mark.Text = h.GuestName;
  3576. }
  3577. //房间介绍
  3578. if (doc.Range.Bookmarks["ROOM"] != null)
  3579. {
  3580. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  3581. mark.Text = h.RoomExplanation;
  3582. }
  3583. //报价描述
  3584. if (doc.Range.Bookmarks["NOTE"] != null)
  3585. {
  3586. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  3587. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == h.ReservationsWebsite);
  3588. if (ss != null)
  3589. mark.Text = ss.Name;
  3590. }
  3591. //入住时间
  3592. if (doc.Range.Bookmarks["CheckIn"] != null)
  3593. {
  3594. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3595. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  3596. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  3597. }
  3598. //退房时间
  3599. if (doc.Range.Bookmarks["CheckOut"] != null)
  3600. {
  3601. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3602. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  3603. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3604. }
  3605. //日期
  3606. if (doc.Range.Bookmarks["DT"] != null)
  3607. {
  3608. Bookmark mark = doc.Range.Bookmarks["DT"];
  3609. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3610. }
  3611. //名称
  3612. if (doc.Range.Bookmarks["VName"] != null)
  3613. {
  3614. Bookmark mark = doc.Range.Bookmarks["VName"];
  3615. mark.Text = h.HotelName;
  3616. }
  3617. //号码
  3618. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  3619. {
  3620. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  3621. mark.Text = h.CheckNumber;
  3622. }
  3623. #endregion
  3624. //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  3625. strFileName += "VOUCHER.doc";
  3626. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  3627. doc.Save(fileDir);
  3628. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  3629. return Ok(JsonView(true, "成功!", Url));
  3630. //保存为doc,并打开
  3631. }
  3632. catch (Exception ex)
  3633. {
  3634. throw;
  3635. }
  3636. }
  3637. else
  3638. {
  3639. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3640. }
  3641. }
  3642. else
  3643. {
  3644. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3645. }
  3646. }
  3647. /// <summary>
  3648. /// 导出确认单
  3649. /// </summary>
  3650. /// <param name=""></param>
  3651. /// <returns></returns>
  3652. [HttpPost]
  3653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3654. public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
  3655. {
  3656. //团组信息
  3657. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
  3658. //酒店数据
  3659. List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel == 0).ToList();
  3660. //利datatable存储
  3661. DataTable dt = new DataTable();
  3662. dt.Columns.Add("CheckInDate", typeof(string));
  3663. dt.Columns.Add("City", typeof(string));
  3664. dt.Columns.Add("Hotel", typeof(string));
  3665. dt.Columns.Add("Room", typeof(string));
  3666. for (int i = 0; i < listhoteldata.Count; i++)
  3667. {
  3668. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  3669. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  3670. while (dayStart < dayEnd)
  3671. {
  3672. string temp = "";
  3673. DataRow row = dt.NewRow();
  3674. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  3675. row["City"] = listhoteldata[i].City;
  3676. row["Hotel"] = listhoteldata[i].HotelName;
  3677. if (listhoteldata[i].SingleRoomCount > 0)
  3678. {
  3679. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  3680. }
  3681. if (listhoteldata[i].DoubleRoomCount > 0)
  3682. {
  3683. temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
  3684. }
  3685. if (listhoteldata[i].SuiteRoomCount > 0)
  3686. {
  3687. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  3688. }
  3689. if (listhoteldata[i].OtherRoomCount > 0)
  3690. {
  3691. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  3692. }
  3693. row["Room"] = temp;
  3694. dt.Rows.Add(row);
  3695. dayStart = dayStart.AddDays(1);
  3696. }
  3697. }
  3698. Dictionary<string, string> dic = new Dictionary<string, string>();
  3699. dic.Add("Dele", di.TeamName);
  3700. dic.Add("City", di.VisitCountry);
  3701. //模板路径
  3702. //string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  3703. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  3704. //载入模板
  3705. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  3706. DocumentBuilder builder = new DocumentBuilder(doc);
  3707. foreach (var key in dic.Keys)
  3708. {
  3709. builder.MoveToBookmark(key);
  3710. builder.Write(dic[key]);
  3711. }
  3712. //获取word里所有表格
  3713. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3714. //获取所填表格的序数
  3715. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3716. var rowStart = tableOne.Rows[0]; //获取第1行
  3717. try
  3718. {
  3719. //循环赋值
  3720. for (int i = 0; i < dt.Rows.Count; i++)
  3721. {
  3722. builder.MoveToCell(0, i + 1, 0, 0);
  3723. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  3724. builder.MoveToCell(0, i + 1, 1, 0);
  3725. builder.Write(dt.Rows[i]["City"].ToString());
  3726. builder.MoveToCell(0, i + 1, 2, 0);
  3727. builder.Write(dt.Rows[i]["Hotel"].ToString());
  3728. builder.MoveToCell(0, i + 1, 3, 0);
  3729. builder.Write(dt.Rows[i]["Room"].ToString());
  3730. }
  3731. }
  3732. catch
  3733. {
  3734. }
  3735. //删除多余行
  3736. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  3737. {
  3738. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  3739. }
  3740. string strFileName = di.TeamName + "酒店确认单.doc";
  3741. try
  3742. {
  3743. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  3744. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  3745. return Ok(JsonView(true, "成功", Url));
  3746. }
  3747. catch (Exception)
  3748. {
  3749. return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
  3750. throw;
  3751. }
  3752. //doc.Save(HttpUtility.UrlEncode(strFileName, Encoding.UTF8), Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);
  3753. }
  3754. /// <summary>
  3755. /// 酒店费用删除
  3756. /// </summary>
  3757. /// <param name="dto"></param>
  3758. /// <returns></returns>
  3759. [HttpPost]
  3760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3761. public async Task<IActionResult> DelHotelPrice(DelBaseDto dto)
  3762. {
  3763. try
  3764. {
  3765. var res = await _hotelPriceRep.SoftDeleteByIdAsync<Grp_HotelReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3766. if (!res)
  3767. {
  3768. return Ok(JsonView(false, "删除失败"));
  3769. }
  3770. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment()
  3771. {
  3772. IsDel = 1,
  3773. DeleteUserId = dto.DeleteUserId,
  3774. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3775. }).ExecuteCommandAsync();
  3776. return Ok(JsonView(true, "删除成功!"));
  3777. }
  3778. catch (Exception ex)
  3779. {
  3780. return Ok(JsonView(false, "程序错误!"));
  3781. throw;
  3782. }
  3783. }
  3784. #endregion
  3785. #region 团组状态
  3786. /// <summary>
  3787. /// 团组状态列表 Page
  3788. /// </summary>
  3789. /// <param name="dto">团组列表请求dto</param>
  3790. /// <returns></returns>
  3791. [HttpPost]
  3792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3793. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  3794. {
  3795. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  3796. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  3797. {
  3798. string sqlWhere = string.Empty;
  3799. if (dto.IsSure == 0) //未完成
  3800. {
  3801. sqlWhere += string.Format(@" And IsSure = 0");
  3802. }
  3803. else if (dto.IsSure == 1) //已完成
  3804. {
  3805. sqlWhere += string.Format(@" And IsSure = 1");
  3806. }
  3807. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  3808. {
  3809. string tj = dto.SearchCriteria;
  3810. 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}%')",
  3811. tj, tj, tj, tj, tj);
  3812. }
  3813. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3814. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  3815. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3816. From (
  3817. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  3818. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  3819. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  3820. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3821. From Grp_DelegationInfo gdi
  3822. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3823. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3824. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3825. Where gdi.IsDel = 0 {0}
  3826. ) temp ", sqlWhere);
  3827. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3828. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  3829. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  3830. }
  3831. else
  3832. {
  3833. return Ok(JsonView(false, "查询失败"));
  3834. }
  3835. }
  3836. /// <summary>
  3837. /// 团组状态
  3838. /// 设置操作完成
  3839. /// </summary>
  3840. /// <param name="dto">团组列表请求dto</param>
  3841. /// <returns></returns>
  3842. [HttpPost]
  3843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3844. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  3845. {
  3846. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  3847. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  3848. {
  3849. Id = dto.Id,
  3850. IsSure = 1
  3851. };
  3852. var result = await _sqlSugar.Updateable(_DelegationInfo)
  3853. .UpdateColumns(it => new { it.IsSure })
  3854. .WhereColumns(it => new { it.Id })
  3855. .ExecuteCommandAsync();
  3856. if (result > 0)
  3857. {
  3858. return Ok(JsonView(true, "操作完成!"));
  3859. }
  3860. return Ok(JsonView(false, "操作失败!"));
  3861. }
  3862. #endregion
  3863. #region 保险费用录入
  3864. /// <summary>
  3865. /// 根据团组Id查询保险费用列表
  3866. /// </summary>
  3867. /// <param name="dto"></param>
  3868. /// <returns></returns>
  3869. [HttpPost]
  3870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3871. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  3872. {
  3873. try
  3874. {
  3875. Result groupData = await _customersRep.CustomersByDiId(dto);
  3876. if (groupData.Code != 0)
  3877. {
  3878. return Ok(JsonView(false, groupData.Msg));
  3879. }
  3880. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3881. }
  3882. catch (Exception ex)
  3883. {
  3884. return Ok(JsonView(false, ex.Message));
  3885. }
  3886. }
  3887. /// <summary>
  3888. /// 根据保险费用Id查询保险费用详细
  3889. /// </summary>
  3890. /// <param name="dto"></param>
  3891. /// <returns></returns>
  3892. [HttpPost]
  3893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3894. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  3895. {
  3896. try
  3897. {
  3898. Result groupData = await _customersRep.CustomersById(dto);
  3899. if (groupData.Code != 0)
  3900. {
  3901. return Ok(JsonView(false, groupData.Msg));
  3902. }
  3903. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3904. }
  3905. catch (Exception ex)
  3906. {
  3907. return Ok(JsonView(false, ex.Message));
  3908. }
  3909. }
  3910. /// <summary>
  3911. /// 酒店预订页面初始化绑定
  3912. /// </summary>
  3913. /// <param name="dto"></param>
  3914. /// <returns></returns>
  3915. [HttpPost]
  3916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3917. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  3918. {
  3919. try
  3920. {
  3921. Result groupData = await _customersRep.CustomersInitialize(dto);
  3922. if (groupData.Code != 0)
  3923. {
  3924. return Ok(JsonView(false, groupData.Msg));
  3925. }
  3926. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3927. }
  3928. catch (Exception ex)
  3929. {
  3930. return Ok(JsonView(false, ex.Message));
  3931. }
  3932. }
  3933. /// <summary>
  3934. /// 保险费用操作(Status:1.新增,2.修改)
  3935. /// </summary>
  3936. /// <param name="dto"></param>
  3937. /// <returns></returns>
  3938. [HttpPost]
  3939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3940. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  3941. {
  3942. try
  3943. {
  3944. Result groupData = await _customersRep.OpCustomers(dto);
  3945. if (groupData.Code != 0)
  3946. {
  3947. return Ok(JsonView(false, groupData.Msg));
  3948. }
  3949. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3950. }
  3951. catch (Exception ex)
  3952. {
  3953. return Ok(JsonView(false, ex.Message));
  3954. }
  3955. }
  3956. /// <summary>
  3957. /// 文件上传
  3958. /// </summary>
  3959. /// <param name="file"></param>
  3960. /// <returns></returns>
  3961. [HttpPost]
  3962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3963. public async Task<IActionResult> UploadCus(IFormFile file)
  3964. {
  3965. try
  3966. {
  3967. if (file != null)
  3968. {
  3969. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3970. //文件名称
  3971. string projectFileName = file.FileName;
  3972. //上传的文件的路径
  3973. string filePath = "";
  3974. if (!Directory.Exists(fileDir))
  3975. {
  3976. Directory.CreateDirectory(fileDir);
  3977. }
  3978. //上传的文件的路径
  3979. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  3980. using (FileStream fs = System.IO.File.Create(filePath))
  3981. {
  3982. file.CopyTo(fs);
  3983. fs.Flush();
  3984. }
  3985. return Ok(JsonView(true, "上传成功!", projectFileName));
  3986. }
  3987. else
  3988. {
  3989. return Ok(JsonView(false, "上传失败!"));
  3990. }
  3991. }
  3992. catch (Exception ex)
  3993. {
  3994. return Ok(JsonView(false, "程序错误!"));
  3995. throw;
  3996. }
  3997. }
  3998. /// <summary>
  3999. /// 删除指定文件
  4000. /// </summary>
  4001. /// <param name="dto"></param>
  4002. /// <returns></returns>
  4003. [HttpPost]
  4004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4005. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  4006. {
  4007. try
  4008. {
  4009. string filePath = "";
  4010. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4011. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4012. //int id = 0;
  4013. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  4014. // 删除该文件
  4015. try
  4016. {
  4017. System.IO.File.Delete(filePath);
  4018. 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()
  4019. {
  4020. Attachment = "",
  4021. }).ExecuteCommandAsync();
  4022. if (result != 0)
  4023. {
  4024. return Ok(JsonView(true, "成功!"));
  4025. }
  4026. else
  4027. {
  4028. return Ok(JsonView(false, "失败!"));
  4029. }
  4030. }
  4031. catch (Exception)
  4032. {
  4033. 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()
  4034. {
  4035. Attachment = "",
  4036. }).ExecuteCommandAsync();
  4037. if (result != 0)
  4038. {
  4039. return Ok(JsonView(true, "成功!"));
  4040. }
  4041. else
  4042. {
  4043. return Ok(JsonView(false, "失败!"));
  4044. }
  4045. }
  4046. }
  4047. catch (Exception ex)
  4048. {
  4049. return Ok(JsonView(false, "程序错误!"));
  4050. throw;
  4051. }
  4052. }
  4053. /// <summary>
  4054. /// 保险费用操作(删除)
  4055. /// </summary>
  4056. /// <param name="dto"></param>
  4057. /// <returns></returns>
  4058. [HttpPost]
  4059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4060. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  4061. {
  4062. try
  4063. {
  4064. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  4065. if (!res)
  4066. {
  4067. return Ok(JsonView(false, "删除失败"));
  4068. }
  4069. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  4070. {
  4071. IsDel = 1,
  4072. DeleteUserId = dto.DeleteUserId,
  4073. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4074. }).ExecuteCommandAsync();
  4075. return Ok(JsonView(true, "删除成功!"));
  4076. }
  4077. catch (Exception ex)
  4078. {
  4079. return Ok(JsonView(false, "程序错误!"));
  4080. throw;
  4081. }
  4082. }
  4083. #endregion
  4084. }
  4085. }