FinancialController.cs 160 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610
  1. using Aspose.Cells;
  2. using Microsoft.AspNetCore.Http;
  3. using Microsoft.AspNetCore.Mvc;
  4. using OASystem.API.OAMethodLib;
  5. using OASystem.API.OAMethodLib.File;
  6. using OASystem.Domain;
  7. using OASystem.Domain.Dtos.Financial;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Financial;
  10. using OASystem.Domain.Entities.Groups;
  11. using OASystem.Domain.ViewModels.Financial;
  12. using OASystem.Domain.ViewModels.Groups;
  13. using OASystem.Domain.ViewModels.SmallFun;
  14. using OASystem.Infrastructure.Repositories.Financial;
  15. using OASystem.Infrastructure.Repositories.Groups;
  16. using SqlSugar;
  17. using StackExchange.Redis;
  18. using System.Data;
  19. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  20. using System.Web;
  21. using Aspose.Words;
  22. using NPOI.HSSF.Util;
  23. using OASystem.Domain.Entities.Customer;
  24. using System.IO.Compression;
  25. using NPOI.SS.UserModel;
  26. using System.Net.Http;
  27. using Google.Protobuf;
  28. using NPOI.SS.Formula.Functions;
  29. using System.Globalization;
  30. using NPOI.POIFS.Properties;
  31. using SixLabors.ImageSharp.ColorSpaces;
  32. using OASystem.Domain.ViewModels.QiYeWeChat;
  33. using System.Diagnostics;
  34. using System.Security.Cryptography;
  35. using NPOI.POIFS.Crypt.Dsig;
  36. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  37. using Org.BouncyCastle.Asn1.Ocsp;
  38. namespace OASystem.API.Controllers
  39. {
  40. /// <summary>
  41. /// 财务模块
  42. /// </summary>
  43. [Route("api/[controller]/[action]")]
  44. [ApiController]
  45. public class FinancialController : ControllerBase
  46. {
  47. private readonly IMapper _mapper;
  48. private readonly IConfiguration _config;
  49. private readonly SqlSugarClient _sqlSugar;
  50. private readonly HttpClient _httpClient;
  51. private readonly SetDataTypeRepository _setDataTypeRep;
  52. private readonly SetDataRepository _setDataRep;
  53. private readonly DailyFeePaymentRepository _daiRep; //日付申请仓库
  54. private readonly TeamRateRepository _teamRateRep; //团组汇率仓库
  55. private readonly ForeignReceivablesRepository _ForForeignReceivablesRep; //对外收款账单仓库
  56. private readonly ProceedsReceivedRepository _proceedsReceivedRep; //已收款项仓库
  57. private readonly PaymentRefundAndOtherMoneyRepository _paymentRefundAndOtherMoneyRep; //收款退还与其他款项 仓库
  58. private readonly DelegationInfoRepository _delegationInfoRep; //团组信息 仓库
  59. /// <summary>
  60. /// 初始化
  61. /// </summary>
  62. public FinancialController(IMapper mapper, IConfiguration configuration, DailyFeePaymentRepository daiRep, SqlSugarClient sqlSugar, SetDataTypeRepository setDataTypeRep,
  63. TeamRateRepository teamRateRep, ForeignReceivablesRepository ForForeignReceivablesRep, ProceedsReceivedRepository proceedsReceivedRep,
  64. PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep, HttpClient httpClient, DelegationInfoRepository delegationInfoRep)
  65. {
  66. _mapper = mapper;
  67. _config = configuration;
  68. _daiRep = daiRep;
  69. _sqlSugar = sqlSugar;
  70. _setDataTypeRep = setDataTypeRep;
  71. _teamRateRep = teamRateRep;
  72. _ForForeignReceivablesRep = ForForeignReceivablesRep;
  73. _proceedsReceivedRep = proceedsReceivedRep;
  74. _paymentRefundAndOtherMoneyRep = paymentRefundAndOtherMoneyRep;
  75. _httpClient = httpClient;
  76. _delegationInfoRep = delegationInfoRep;
  77. }
  78. #region 日付申请
  79. /// <summary>
  80. /// 获取日付申请 基础数据源
  81. /// </summary>
  82. /// <param name="dto"> 日付申请 分页 dto</param>
  83. /// <returns></returns>
  84. [HttpPost]
  85. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  86. public async Task<IActionResult> PostPageSearchDailyPaymentPriceTypeData(PortDtoBase dto)
  87. {
  88. var result = await _daiRep.GetPagePriceTypeData(dto);
  89. if (result == null || result.Code != 0)
  90. {
  91. return Ok(JsonView(false, result.Msg));
  92. }
  93. var data = result.Data;
  94. return Ok(JsonView(data));
  95. }
  96. /// <summary>
  97. /// 获取日付申请 基础数据源 - 转账表识
  98. /// </summary>
  99. /// <param name="dto"> 日付申请 分页 dto</param>
  100. /// <returns></returns>
  101. [HttpPost]
  102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  103. public async Task<IActionResult> GetSearchDailyPaymentPriceTypeAddData(PortDtoBase dto)
  104. {
  105. var result = await _daiRep.GetPriceTypeAddData(dto);
  106. if (result == null || result.Code != 0)
  107. {
  108. return Ok(JsonView(false, result.Msg));
  109. }
  110. var data = result.Data;
  111. return Ok(JsonView(data));
  112. }
  113. /// <summary>
  114. /// 日付申请 Page Search
  115. /// </summary>
  116. /// <param name="dto"> 日付申请 分页 dto</param>
  117. /// <returns></returns>
  118. [HttpPost]
  119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  120. public async Task<IActionResult> PostPageSearchDailyPaymentList(PageDailyFeePaymentDto dto)
  121. {
  122. var result = await _daiRep.GetPageSearchAll(dto);
  123. if (result == null || result.Code != 0)
  124. {
  125. return Ok(JsonView(false, result.Msg));
  126. }
  127. var data = result.Data;
  128. if (data == null)
  129. {
  130. return Ok(JsonView(false, result.Msg));
  131. }
  132. return Ok(JsonView(data));
  133. }
  134. /// <summary>
  135. /// 日付申请 Single Search By Id
  136. /// </summary>
  137. /// <param name="dto"></param>
  138. /// <returns></returns>
  139. [HttpPost]
  140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  141. public async Task<IActionResult> PostSearchDailyPaymentInfo(SearchDailyFeePaymentDto dto)
  142. {
  143. var result = await _daiRep.GetSearchById(dto);
  144. if (result == null || result.Code != 0)
  145. {
  146. return Ok(JsonView(false, result.Msg));
  147. }
  148. return Ok(JsonView(result.Data));
  149. }
  150. /// <summary>
  151. /// 日付申请 添加
  152. /// </summary>
  153. /// <param name="dto"> 日付申请 添加 dto</param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  157. public async Task<IActionResult> PostAddDailyPayment(AddDailyFeePaymentDto dto)
  158. {
  159. var result = await _daiRep.Add(dto);
  160. if (result == null || result.Code != 0)
  161. {
  162. return Ok(JsonView(false, result.Msg));
  163. }
  164. #region 应用推送
  165. try
  166. {
  167. int dailyId = result.Data.GetType().GetProperty("dailyId").GetValue(result.Data, null);
  168. int sign = result.Data.GetType().GetProperty("sign").GetValue(result.Data, null);
  169. await AppNoticeLibrary.DailyPayReminders_Create_ToCaiwuChat(dailyId, sign, QiyeWeChatEnum.CaiWuChat);
  170. }
  171. catch (Exception ex)
  172. {
  173. }
  174. #endregion
  175. return Ok(JsonView(true));
  176. }
  177. /// <summary>
  178. /// 日付申请 Update
  179. /// </summary>
  180. /// <param name="dto"> 日付申请 修改 dto</param>
  181. /// <returns></returns>
  182. [HttpPost]
  183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  184. public async Task<IActionResult> PostEditDailyPayment(EditDailyFeePaymentDto dto)
  185. {
  186. var result = await _daiRep.Edit(dto);
  187. if (result == null || result.Code != 0)
  188. {
  189. return Ok(JsonView(false, result.Msg));
  190. }
  191. #region 应用推送
  192. try
  193. {
  194. int dailyId = result.Data.GetType().GetProperty("dailyId").GetValue(result.Data, null);
  195. int sign = result.Data.GetType().GetProperty("sign").GetValue(result.Data, null);
  196. await AppNoticeLibrary.DailyPayReminders_Create_ToCaiwuChat(dailyId, sign, QiyeWeChatEnum.CaiWuChat);
  197. }
  198. catch (Exception ex)
  199. {
  200. }
  201. #endregion
  202. return Ok(JsonView(true));
  203. }
  204. /// <summary>
  205. /// 日付申请 Del
  206. /// </summary>
  207. /// <param name="dto"> 日付申请 删除 dto</param>
  208. /// <returns></returns>
  209. [HttpPost]
  210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  211. public async Task<IActionResult> PostDelDailyPayment(DelDailyFeePaymentDto dto)
  212. {
  213. var result = await _daiRep.Del(dto);
  214. if (result == null || result.Code != 0)
  215. {
  216. return Ok(JsonView(false, result.Msg));
  217. }
  218. return Ok(JsonView(true));
  219. }
  220. /// <summary>
  221. /// 日付申请 财务审核
  222. /// </summary>
  223. /// <param name="dto"> dto </param>
  224. /// <returns></returns>
  225. [HttpPost]
  226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  227. public async Task<IActionResult> PostDelDailyPaymentAudit(DP_AuditStatusDto dto)
  228. {
  229. var result = await _daiRep.DailyPaymentAudit(dto);
  230. if (result == null || result.Code != 0)
  231. {
  232. return Ok(JsonView(false, result.Msg));
  233. }
  234. return Ok(JsonView(true));
  235. }
  236. /// <summary>
  237. /// 日付申请 Single Excel Download
  238. /// </summary>
  239. /// <param name="dto"> dto </param>
  240. /// <returns></returns>
  241. [HttpPost]
  242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  243. public async Task<IActionResult> PostExcelDailyPaymentDownload(SearchDailyFeePaymentDto dto)
  244. {
  245. if (dto.PortType == 1 || dto.PortType == 2)
  246. {
  247. Fin_DailyFeePaymentInfolView feeData = new Fin_DailyFeePaymentInfolView();
  248. string feeSql = string.Format(@"Select * From Fin_DailyFeePayment
  249. Where IsDel=0 And Id = {0} ", dto.Id);
  250. feeData = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentInfolView>(feeSql).FirstAsync();
  251. if (feeData == null)
  252. {
  253. return Ok(JsonView(false, "暂无数据!"));
  254. }
  255. string feeContentSql = string.Format(@"Select * From Fin_DailyFeePaymentContent
  256. Where IsDel=0 And DFPId = {0} ", dto.Id);
  257. feeData.FeeContents = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentContentInfolView>(feeContentSql).ToListAsync();
  258. if (feeData != null)
  259. {
  260. string userName = string.Empty;
  261. string userSql = string.Format("Select * From Sys_Users Where Id={0} And Isdel = {1}", feeData.CreateUserId, 0);
  262. Sys_Users user = await _sqlSugar.SqlQueryable<Sys_Users>(userSql).FirstAsync();
  263. if (user != null) { userName = user.CnName; }
  264. var setData = _setDataTypeRep.QueryDto<Sys_SetData, Fin_DailyFeePaymentPagePriceSubTypeView>().ToList();
  265. //48人员费用 49办公费用 50 销售费用 51 其他费用 55 大运会
  266. var priceSubTypeData = setData.Where(s => s.STid == 55).ToList();
  267. Dictionary<string, object> pairs = new Dictionary<string, object>();
  268. List<DataTable> datas = new List<DataTable>();
  269. //if (priceSubTypeData.Where(s => s.Id == feeData.PriceTypeId).ToList().Count() > 0)//大运会专属模板
  270. //{
  271. // //AsposeHelper.ExpertExcelToModel("日常费用付款申请模板-大运会数据.xls", "DailyPayment", "大运会所有日常费用付款申请.xls",
  272. // // pairs, datas);
  273. //}
  274. //else //日付常规模板
  275. //{
  276. pairs.Clear();
  277. pairs.Add("Opertor", userName);
  278. pairs.Add("DateTime", feeData.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  279. pairs.Add("FAuditStatus", feeData.FAuditDesc);
  280. pairs.Add("MAuditStatus", feeData.MAuditDesc);
  281. pairs.Add("SumPrice", feeData.SumPrice);
  282. DataTable data = AsposeHelper.ListToDataTable("DailyFeePayment", feeData.FeeContents);
  283. datas.Clear();
  284. datas.Add(data);
  285. string fileName = string.Format("{0}-日常费用付款申请.xlsx", feeData.Instructions);
  286. string msg = AsposeHelper.ExpertExcelToModel("日常费用付款申请模板.xlsx", "DailyPayment", fileName, pairs, datas);
  287. return Ok(JsonView(true, msg));
  288. //}
  289. }
  290. else
  291. {
  292. return Ok(JsonView(false, "暂无数据!"));
  293. }
  294. }
  295. return Ok(JsonView(true));
  296. }
  297. #endregion
  298. #region 团组提成
  299. /// <summary>
  300. /// 提成 Page Search
  301. /// </summary>
  302. /// <param name="dto"> 提成 分页 dto</param>
  303. /// <returns></returns>
  304. [HttpPost]
  305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  306. public async Task<IActionResult> PostPageSearchCommissionList(GroupCommissionDto dto)
  307. {
  308. var data = await GroupCommission.GetCommissionPageList(dto);
  309. return Ok(JsonView(data.Data));
  310. }
  311. #endregion
  312. #region 团组汇率
  313. /// <summary>
  314. /// 团组汇率 Select数据源(团组列,汇率列)
  315. /// </summary>
  316. /// <param name="dto"></param>
  317. /// <returns></returns>
  318. [HttpPost]
  319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  320. public async Task<IActionResult> GetGroupRateDataSources(TeamRateDto dto)
  321. {
  322. try
  323. {
  324. //迁移数据更新团组汇率
  325. //Result teamRateData1 = await _teamRateRep.GetGroupRateChangeData();
  326. //var data = await _teamRateRep.PostGroupTeamRateHot();
  327. Stopwatch stopwatch = Stopwatch.StartNew();
  328. GroupNameDto groupNameDto = new GroupNameDto() { PortType = dto.PortType };
  329. var groups = await _delegationInfoRep.GetGroupNameList(groupNameDto);
  330. List<CurrencyHot> _currData = new List<CurrencyHot>();
  331. string currData = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("GroupTeamCurrencyData");//string 取
  332. if (!string.IsNullOrEmpty(currData))
  333. {
  334. _currData = JsonConvert.DeserializeObject<List<CurrencyHot>>(currData);
  335. }
  336. else
  337. {
  338. _currData = await _teamRateRep.PostGroupTeamRateHot();
  339. //过期时间 25 Hours
  340. TimeSpan ts = DateTime.Now.AddHours(25).TimeOfDay;
  341. await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync("GroupTeamCurrencyData", JsonConvert.SerializeObject(_currData), ts);
  342. }
  343. var _data = new { GroupData = groups.Data, TeamRateData = _currData };
  344. stopwatch.Stop();
  345. return Ok(JsonView(true, $"查询成功!耗时:{stopwatch.ElapsedMilliseconds / 1000}s", _data));
  346. }
  347. catch (Exception ex)
  348. {
  349. return Ok(JsonView(false, ex.Message));
  350. }
  351. }
  352. ///// <summary>
  353. ///// 团组汇率 changge
  354. ///// </summary>
  355. ///// <returns></returns>
  356. //[HttpPost]
  357. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  358. //public async Task<IActionResult> ChangeGroupRateInfo()
  359. //{
  360. // try
  361. // {
  362. // Result teamRateData = await _teamRateRep.GetGroupRateChangeData();
  363. // if (teamRateData.Code != 0)
  364. // {
  365. // return Ok(JsonView(false, teamRateData.Msg));
  366. // }
  367. // return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  368. // }
  369. // catch (Exception ex)
  370. // {
  371. // return Ok(JsonView(false, ex.Message));
  372. // throw;
  373. // }
  374. //}
  375. /// <summary>
  376. /// 团组汇率 Select汇率详情
  377. /// </summary>
  378. /// <param name="dto"></param>
  379. /// <returns></returns>
  380. [HttpPost]
  381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  382. public async Task<IActionResult> GetGroupRateInfo(TeamRateInfoDto dto)
  383. {
  384. try
  385. {
  386. Result teamRateData = await _teamRateRep.GetGroupRateInfoByDiid(dto);
  387. if (teamRateData.Code != 0)
  388. {
  389. return Ok(JsonView(false, teamRateData.Msg));
  390. }
  391. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  392. }
  393. catch (Exception ex)
  394. {
  395. return Ok(JsonView(false, ex.Message));
  396. throw;
  397. }
  398. }
  399. /// <summary>
  400. /// 团组汇率 添加 or 更新
  401. /// </summary>
  402. /// <param name="dto"></param>
  403. /// <returns></returns>
  404. [HttpPost]
  405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  406. public async Task<IActionResult> PostGroupRateUpdate(TeamRateUpdateDto dto)
  407. {
  408. try
  409. {
  410. Result teamRateData = await _teamRateRep.PostGroupRateUpdate(dto);
  411. if (teamRateData.Code != 0)
  412. {
  413. return Ok(JsonView(false, teamRateData.Msg));
  414. }
  415. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  416. }
  417. catch (Exception ex)
  418. {
  419. return Ok(JsonView(false, ex.Message));
  420. throw;
  421. }
  422. }
  423. #endregion
  424. #region 对外收款账单 关联已收款项
  425. /// <summary>
  426. /// 对外收款账单 Select数据源(团组名,币种,汇款方式)
  427. /// 关联已收款项
  428. /// </summary>
  429. /// <param name="dto"></param>
  430. /// <returns></returns>
  431. [HttpPost]
  432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  433. public async Task<IActionResult> GetForeignReceivablesDataSources()
  434. {
  435. try
  436. {
  437. Result ffrData = await _ForForeignReceivablesRep.GetDataSource();
  438. if (ffrData.Code != 0)
  439. {
  440. return Ok(JsonView(false, ffrData.Msg));
  441. }
  442. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  443. }
  444. catch (Exception ex)
  445. {
  446. return Ok(JsonView(false, ex.Message));
  447. throw;
  448. }
  449. }
  450. /// <summary>
  451. /// 对外收款账单
  452. /// 账单详情
  453. /// 关联已收款项
  454. /// </summary>
  455. /// <param name="dto"></param>
  456. /// <returns></returns>
  457. [HttpPost]
  458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  459. public async Task<IActionResult> GetGroupReceivablesInfoByDiId(ForForeignReceivablesInfoDto dto)
  460. {
  461. try
  462. {
  463. Result ffrData = await _ForForeignReceivablesRep.GetGroupReceivablesInfoByDiId(dto);
  464. if (ffrData.Code != 0)
  465. {
  466. return Ok(JsonView(false, ffrData.Msg));
  467. }
  468. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  469. }
  470. catch (Exception ex)
  471. {
  472. return Ok(JsonView(false, ex.Message));
  473. throw;
  474. }
  475. }
  476. /// <summary>
  477. /// 对外收款账单
  478. /// 账单 删除
  479. /// 关联已收款项
  480. /// </summary>
  481. /// <param name="dto"></param>
  482. /// <returns></returns>
  483. [HttpPost]
  484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  485. public async Task<IActionResult> PostGroupReceivablesDel(DelForForeignReceivablesInfoDto dto)
  486. {
  487. try
  488. {
  489. Result ffrData = await _ForForeignReceivablesRep._Del(dto);
  490. if (ffrData.Code != 0)
  491. {
  492. return Ok(JsonView(false, ffrData.Msg));
  493. }
  494. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  495. }
  496. catch (Exception ex)
  497. {
  498. return Ok(JsonView(false, ex.Message));
  499. throw;
  500. }
  501. }
  502. /// <summary>
  503. /// 对外收款账单
  504. /// 添加 And 更新
  505. /// 关联已收款项
  506. /// </summary>
  507. /// <param name="dto"></param>
  508. /// <returns></returns>
  509. [HttpPost]
  510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  511. public async Task<IActionResult> PostReceivablesOperate(ForeignReceivablesAddAndUpdateDto dto)
  512. {
  513. try
  514. {
  515. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesOperate(dto);
  516. if (ffrData.Code != 0)
  517. {
  518. return Ok(JsonView(false, ffrData.Msg));
  519. }
  520. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  521. }
  522. catch (Exception ex)
  523. {
  524. return Ok(JsonView(false, ex.Message));
  525. throw;
  526. }
  527. }
  528. /// <summary>
  529. /// 已收款项
  530. /// 账单 删除
  531. /// 关联已收款项
  532. /// </summary>
  533. /// <param name="dto"></param>
  534. /// <returns></returns>
  535. [HttpPost]
  536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  537. public async Task<IActionResult> PostAmountReceivedDel(ProceedsReceivedDelDto dto)
  538. {
  539. try
  540. {
  541. Result ffrData = await _proceedsReceivedRep._Del(dto);
  542. if (ffrData.Code != 0)
  543. {
  544. return Ok(JsonView(false, ffrData.Msg));
  545. }
  546. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  547. }
  548. catch (Exception ex)
  549. {
  550. return Ok(JsonView(false, ex.Message));
  551. throw;
  552. }
  553. }
  554. /// <summary>
  555. /// 已收款项
  556. /// 添加 And 更新
  557. /// 关联已收款项
  558. /// </summary>
  559. /// <param name="dto"></param>
  560. /// <returns></returns>
  561. [HttpPost]
  562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  563. public async Task<IActionResult> PostAmountReceivedOperate(ProceedsReceivedDto dto)
  564. {
  565. try
  566. {
  567. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedOperate(dto);
  568. if (ffrData.Code != 0)
  569. {
  570. return Ok(JsonView(false, ffrData.Msg));
  571. }
  572. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  573. }
  574. catch (Exception ex)
  575. {
  576. return Ok(JsonView(false, ex.Message));
  577. throw;
  578. }
  579. }
  580. /// <summary>
  581. /// 财务 已收款项
  582. /// 分配已收款项至 应收项下
  583. /// 关联已收款项
  584. /// </summary>
  585. /// <param name="dto"></param>
  586. /// <returns></returns>
  587. [HttpPost]
  588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  589. public async Task<IActionResult> PostAllocateAmountReceived(AllocateAmountReceivedDto dto)
  590. {
  591. try
  592. {
  593. Result ffrData = await _proceedsReceivedRep.PostAllocateAmountReceived(dto);
  594. if (ffrData.Code != 0)
  595. {
  596. return Ok(JsonView(false, ffrData.Msg));
  597. }
  598. return Ok(JsonView(true));
  599. }
  600. catch (Exception ex)
  601. {
  602. return Ok(JsonView(false, ex.Message));
  603. throw;
  604. }
  605. }
  606. ///// <summary>
  607. ///// 财务 收款账单
  608. ///// 导出Word(北京,四川)
  609. ///// </summary>
  610. ///// <param name="dto"></param>
  611. ///// <returns></returns>
  612. //[HttpPost]
  613. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  614. //public async Task<IActionResult> PostAccountReceivableWordExport(AccountReceivableWordExportDto dto)
  615. //{
  616. // try
  617. // {
  618. // //模板处理
  619. // string typeName = string.Empty;
  620. // if (dto.TemplateType == 1) //四川
  621. // {
  622. // typeName = "四川";
  623. // }
  624. // else if (dto.TemplateType == 2) //北京
  625. // {
  626. // typeName = "北京";
  627. // }
  628. // else return Ok(JsonView(false,"请选择正确的模板类型!"));
  629. // string wordTempName = string.Format("收款账单({0})模板.doc", typeName);
  630. // }
  631. // catch (Exception ex)
  632. // {
  633. // return Ok(JsonView(false, ex.Message));
  634. // }
  635. //}
  636. #endregion
  637. #region 对外收款账单
  638. /// <summary>
  639. /// 对外收款账单
  640. /// 数据源
  641. /// </summary>
  642. /// <param name="dto"></param>
  643. /// <returns></returns>
  644. [HttpPost]
  645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  646. public async Task<IActionResult> PostGroupReceivablesDataSource()
  647. {
  648. try
  649. {
  650. Result ffrData = await _ForForeignReceivablesRep.PostDataSource();
  651. if (ffrData.Code != 0)
  652. {
  653. return Ok(JsonView(false, ffrData.Msg));
  654. }
  655. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  656. }
  657. catch (Exception ex)
  658. {
  659. return Ok(JsonView(false, ex.Message));
  660. }
  661. }
  662. /// <summary>
  663. /// 对外收款账单
  664. /// 账单详情
  665. /// </summary>
  666. /// <param name="dto"></param>
  667. /// <returns></returns>
  668. [HttpPost]
  669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  670. public async Task<IActionResult> PostGroupReceivablesInfoByDiId(ForForeignReceivablesNewDto dto)
  671. {
  672. try
  673. {
  674. Result ffrData = await _ForForeignReceivablesRep.PostGroupReceivablesInfoByDiId(dto);
  675. if (ffrData.Code != 0)
  676. {
  677. return Ok(JsonView(false, ffrData.Msg));
  678. }
  679. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  680. }
  681. catch (Exception ex)
  682. {
  683. return Ok(JsonView(false, ex.Message));
  684. }
  685. }
  686. /// <summary>
  687. /// 对外收款账单
  688. /// 添加 And 更新
  689. /// </summary>
  690. /// <param name="dto"></param>
  691. /// <returns></returns>
  692. [HttpPost]
  693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  694. public async Task<IActionResult> PostReceivablesSave(ForeignReceivablesSaveDto dto)
  695. {
  696. try
  697. {
  698. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesSave(dto);
  699. if (ffrData.Code != 0)
  700. {
  701. return Ok(JsonView(false, ffrData.Msg));
  702. }
  703. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  704. }
  705. catch (Exception ex)
  706. {
  707. return Ok(JsonView(false, ex.Message));
  708. throw;
  709. }
  710. }
  711. /// <summary>
  712. /// 已收账单
  713. /// 删除
  714. /// </summary>
  715. /// <param name="dto"></param>
  716. /// <returns></returns>
  717. [HttpPost]
  718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  719. public async Task<IActionResult> PostReceivablesDel(ForeignReceivablesDelDto dto)
  720. {
  721. try
  722. {
  723. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesDel(dto);
  724. if (ffrData.Code != 0)
  725. {
  726. return Ok(JsonView(false, ffrData.Msg));
  727. }
  728. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  729. }
  730. catch (Exception ex)
  731. {
  732. return Ok(JsonView(false, ex.Message));
  733. throw;
  734. }
  735. }
  736. /// <summary>
  737. /// 已收账单
  738. /// File Downloasd
  739. /// Init
  740. /// </summary>
  741. /// <param name="dto"></param>
  742. /// <returns></returns>
  743. [HttpPost]
  744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  745. public async Task<IActionResult> PostReceivablesFeilDownloadInit()
  746. {
  747. return Ok(JsonView(true, "操作成功!", new List<dynamic> {
  748. new { Id = 1, Name = "生成收款单(四川)" },
  749. new { Id = 2, Name = "生成收款单(北京)" },
  750. new { Id = 3, Name = "汇款账单" }
  751. }
  752. ));
  753. }
  754. /// <summary>
  755. /// 已收账单
  756. /// File Downloasd
  757. /// </summary>
  758. /// <param name="dto"></param>
  759. /// <returns></returns>
  760. [HttpPost]
  761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  762. public async Task<IActionResult> PostReceivablesFeilDownload(ForeignReceivablesFeilDownloadDto dto)
  763. {
  764. try
  765. {
  766. if (dto.DiId < 1)
  767. {
  768. return Ok(JsonView(false, "请传入有效DiId参数!"));
  769. }
  770. if (dto.FileType < 1 || dto.FileType > 3)
  771. {
  772. return Ok(JsonView(false, "请传入有效FileType参数! 1 生成收款单(四川) 2 生成收款单(北京) 3 汇款账单"));
  773. }
  774. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  775. if (_DelegationInfo == null)
  776. {
  777. return Ok(JsonView(false, "暂无团组信息!!"));
  778. }
  779. if (dto.FileType == 1 || dto.FileType == 2)
  780. {
  781. var _ForeignReceivables = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  782. if (_ForeignReceivables.Count < 1)
  783. {
  784. return Ok(JsonView(false, "暂无收款信息!!"));
  785. }
  786. string tempName = "";
  787. if (dto.FileType == 1) tempName = $"收款账单(四川)模板.docx";
  788. else if (dto.FileType == 2) tempName = $"收款账单(北京)模板.docx";
  789. string tempPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/Temp/{tempName}";
  790. //载入模板
  791. Document doc = new Document(tempPath);
  792. DocumentBuilder builder = new DocumentBuilder(doc);
  793. #region 替换Word模板书签内容
  794. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  795. //付款方
  796. if (doc.Range.Bookmarks["To"] != null)
  797. {
  798. Bookmark mark = doc.Range.Bookmarks["To"];
  799. mark.Text = _ForeignReceivables[0].To == null ? "" : _ForeignReceivables[0].To.ToString();
  800. }
  801. //付款方电话
  802. if (doc.Range.Bookmarks["ToTel"] != null)
  803. {
  804. Bookmark mark = doc.Range.Bookmarks["ToTel"];
  805. mark.Text = _ForeignReceivables[0].ToTel == null ? "" : _ForeignReceivables[0].ToTel.ToString();
  806. }
  807. //导出时间
  808. if (doc.Range.Bookmarks["Date"] != null)
  809. {
  810. Bookmark mark = doc.Range.Bookmarks["Date"];
  811. mark.Text = DateTime.Now.ToString("yyyy-MM-dd");
  812. }
  813. //注
  814. if (doc.Range.Bookmarks["Attention"] != null)
  815. {
  816. Bookmark mark = doc.Range.Bookmarks["Attention"];
  817. mark.Text = _ForeignReceivables[0].Attention == null ? "" : _ForeignReceivables[0].Attention.ToString();
  818. }
  819. //团队名称
  820. if (doc.Range.Bookmarks["Team"] != null)
  821. {
  822. Bookmark mark = doc.Range.Bookmarks["Team"];
  823. mark.Text = _DelegationInfo.VisitCountry == null ? "" : _DelegationInfo.VisitCountry.Replace("|", "、").ToString();
  824. }
  825. //付款日期
  826. if (doc.Range.Bookmarks["PayDate"] != null)
  827. {
  828. Bookmark mark = doc.Range.Bookmarks["PayDate"];
  829. mark.Text = _ForeignReceivables[0].PayDate == null ? "" : Convert.ToDateTime(_ForeignReceivables[0].PayDate).ToString("yyyy年MM月dd日");
  830. }
  831. decimal sumPrice = 0;
  832. //各项费用
  833. if (doc.Range.Bookmarks["PayItemContent"] != null)
  834. {
  835. string items = "";
  836. foreach (var fr in _ForeignReceivables)
  837. {
  838. items += fr.PriceName + " " + fr.Currency + " " + fr.Price.ToString("#0.00") + " * " + fr.Count + " " + fr.Unit + " * " + fr.Rate + ".................. RMB " + fr.ItemSumPrice.ToString("#0.00") + "\n";
  839. sumPrice += fr.ItemSumPrice;
  840. }
  841. Bookmark mark = doc.Range.Bookmarks["PayItemContent"];
  842. mark.Text = items;
  843. }
  844. //合计
  845. if (doc.Range.Bookmarks["Total"] != null)
  846. {
  847. Bookmark mark = doc.Range.Bookmarks["Total"];
  848. mark.Text = sumPrice.ToString("#0.00");
  849. }
  850. #endregion
  851. //文件名
  852. string strFileName = _DelegationInfo.TeamName + "-收款账单.docx";
  853. //去水印
  854. new Aspose.Words.License().SetLicense(new MemoryStream(Convert.FromBase64String(AsposeHelper.asposeKey)));
  855. doc.Save(AppSettingsHelper.Get("WordBasePath") + "ForeignReceivables/File/" + strFileName);
  856. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/ForeignReceivables/File/" + strFileName;
  857. return Ok(JsonView(true, "成功", new { Url = url }));
  858. }
  859. else if (dto.FileType == 3) //汇款通知
  860. {
  861. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  862. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.NationalTravelFeeId > 0).ToList();
  863. if (_EnterExitCosts == null)
  864. {
  865. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  866. }
  867. var _cityFee = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  868. foreach (var item in _DayAndCosts)
  869. {
  870. var cityInfo = _cityFee.Where(it => it.Id == item.NationalTravelFeeId).FirstOrDefault();
  871. if (cityInfo != null)
  872. {
  873. if (cityInfo.City.Contains("全部城市") || cityInfo.City.Contains("其他城市"))
  874. {
  875. item.Place = cityInfo.Country;
  876. }
  877. else item.Place = cityInfo.City;
  878. }
  879. }
  880. //数据源
  881. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  882. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  883. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  884. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  885. //币种Data
  886. var currData = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  887. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  888. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  889. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  890. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  891. .Select((tcl, dc, cc) => new
  892. {
  893. Name = dc.LastName + dc.FirstName,
  894. Sex = dc.Sex,
  895. Birthday = dc.BirthDay,
  896. Company = cc.CompanyFullName,
  897. Job = dc.Job,
  898. AirType = tcl.ShippingSpaceTypeId
  899. })
  900. .ToList();
  901. if (DeleClientList.Count < 1)
  902. {
  903. return Ok(JsonView(false, "暂无团组成员,请先填写团组成员!!!"));
  904. }
  905. var _ClientNames = DeleClientList.Select(x => x.Name).ToList();
  906. var _GroupClient = DeleClientList.GroupBy(x => x.Company).ToList();
  907. Dictionary<string, string> bookmarkArr = null;
  908. string tempPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/Temp/汇款通知.docx";
  909. //载入模板
  910. Document doc = new Document(tempPath);
  911. DocumentBuilder builder = null;
  912. List<string> filesToZip = new List<string>();
  913. foreach (var ClientItem in _GroupClient) //遍历单位
  914. {
  915. doc = new Document(tempPath);
  916. builder = new DocumentBuilder(doc);
  917. Paragraph paragraph = new Paragraph(doc);
  918. bookmarkArr = new Dictionary<string, string>();
  919. bookmarkArr.Add("titleClientUnit", ClientItem.Key); //title单位
  920. bookmarkArr.Add("ClientUnit", ClientItem.Key); //单位
  921. bookmarkArr.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));//出发日期
  922. bookmarkArr.Add("name", string.Join(",", ClientItem.Select(x => x.Name).ToArray()).TrimEnd(','));//全部人员信息
  923. bookmarkArr.Add("VisitCountry", _DelegationInfo.VisitCountry.Replace("|", "、"));//出访国家
  924. bookmarkArr.Add("dayTime", DateTime.Now.ToString("yyyy年MM月dd日"));//今天日期
  925. var ClientItemList = ClientItem.ToList();
  926. string UsersTop = string.Empty;//word中人员以及金额
  927. decimal WordAllPrice = 0.00M;
  928. //int[] infoColumn = new int[5] {dac1.Select(x=>x.Place.Length).ToList().Max(),2, dac1.Select(x => x.Cost.Length).Max() + dac1.Select(x => x.Currency.Length).Max(),
  929. // 6, 3 + dac1.Where(x=>!string.IsNullOrWhiteSpace(x.Place)).Select(x=>(Convert.ToDecimal(x.SubTotal) / Convert.ToDecimal(x.Cost)).ToString().Length).Max() };
  930. //遍历人员
  931. for (int i = 0; i < ClientItemList.Count(); i++)
  932. {
  933. Dictionary<string, string> TeableBookmarkArr = new Dictionary<string, string>();
  934. var client = ClientItemList[i]; //每个人员
  935. var firstName = ClientItemList[i].Name;
  936. //计算费用总和
  937. decimal airPrice = client.AirType == 460 ? _EnterExitCosts.AirJJ : _EnterExitCosts.AirGW;
  938. decimal AllPrice = airPrice + _EnterExitCosts.CityTranffic + dac1.Sum(x => x.SubTotal) + dac2.Sum(x => x.SubTotal) +
  939. dac3.Sum(x => x.SubTotal) + dac4.Sum(x => x.SubTotal) + _EnterExitCosts.Visa + _EnterExitCosts.Safe +
  940. +_EnterExitCosts.YiMiao + _EnterExitCosts.YiMiao + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  941. WordAllPrice += AllPrice;
  942. UsersTop += firstName + "出访费用为¥" + AllPrice.ToString("#0.00") + "元、";
  943. TeableBookmarkArr.Add("jp", (client.AirType == 460 ? _EnterExitCosts.AirJJ : _EnterExitCosts.AirGW).ToString("#0.00") + " 元"); //机票金额
  944. TeableBookmarkArr.Add("cs", _EnterExitCosts.CityTranffic.ToString("#0.00") + " 元"); //城市交通费用
  945. TeableBookmarkArr.Add("zs", dac1.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //住宿费
  946. string zsinfo = string.Empty;
  947. string hsinfo = string.Empty;
  948. string gzinfo = string.Empty;
  949. List<string> placeArr = new List<string>();
  950. Aspose.Words.Tables.Table FirstTable = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
  951. Aspose.Words.Tables.Table ChildTable = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 0, true);
  952. Aspose.Words.Tables.Table ChildTable1 = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 1, true);
  953. Aspose.Words.Tables.Table ChildTable2 = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 2, true);
  954. int rowIndex = 0;
  955. foreach (var item in dac1)
  956. {
  957. if (string.IsNullOrWhiteSpace(item.Place))
  958. {
  959. continue;
  960. }
  961. if (placeArr.Contains(item.Place))
  962. {
  963. continue;
  964. }
  965. else
  966. {
  967. placeArr.Add(item.Place);
  968. }
  969. if (!string.IsNullOrWhiteSpace(item.Place))
  970. {
  971. if (rowIndex > ChildTable.Rows.Count - 1)
  972. {
  973. var chitableRow = ChildTable.LastRow.Clone(true);
  974. ChildTable.AppendChild(chitableRow);
  975. }
  976. int days = dac1.FindAll(x => x.Place == item.Place).Count();
  977. SetCells(ChildTable, doc, rowIndex, 0, item.Place);
  978. SetCells(ChildTable, doc, rowIndex, 1, days + "晚");
  979. string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
  980. SetCells(ChildTable, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/晚");
  981. SetCells(ChildTable, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
  982. SetCells(ChildTable, doc, rowIndex, 4, "CNY" + item.SubTotal + "\r\n");
  983. rowIndex++;
  984. zsinfo += item.Place + " " + days + "晚 " + item.Cost.ToString("#0.00") + currencyCode + "/晚" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.0000") + " CNY" + item.SubTotal * days + "\r\n";
  985. }
  986. }
  987. placeArr.Clear();
  988. rowIndex = 0;
  989. foreach (var item in dac2)
  990. {
  991. if (string.IsNullOrWhiteSpace(item.Place))
  992. {
  993. continue;
  994. }
  995. if (placeArr.Contains(item.Place))
  996. {
  997. continue;
  998. }
  999. else
  1000. {
  1001. placeArr.Add(item.Place);
  1002. }
  1003. if (!string.IsNullOrWhiteSpace(item.Place))
  1004. {
  1005. if (rowIndex > ChildTable1.Rows.Count - 1)
  1006. {
  1007. var chitableRow = ChildTable1.LastRow.Clone(true);
  1008. ChildTable1.AppendChild(chitableRow);
  1009. }
  1010. int days = dac2.FindAll(x => x.Place == item.Place).Count();
  1011. SetCells(ChildTable1, doc, rowIndex, 0, item.Place);
  1012. SetCells(ChildTable1, doc, rowIndex, 1, days + "天");
  1013. string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
  1014. SetCells(ChildTable1, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/天");
  1015. SetCells(ChildTable1, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
  1016. SetCells(ChildTable1, doc, rowIndex, 4, "CNY" + item.SubTotal);
  1017. rowIndex++;
  1018. hsinfo += item.Place + " " + days + "天 " + item.Cost.ToString("#0.00") + currencyCode + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.0000") + " CNY" + item.SubTotal * days + "\r\n";
  1019. }
  1020. }
  1021. placeArr.Clear();
  1022. rowIndex = 0;
  1023. foreach (var item in dac3)
  1024. {
  1025. if (string.IsNullOrWhiteSpace(item.Place))
  1026. {
  1027. continue;
  1028. }
  1029. if (placeArr.Contains(item.Place))
  1030. {
  1031. continue;
  1032. }
  1033. else
  1034. {
  1035. placeArr.Add(item.Place);
  1036. }
  1037. if (!string.IsNullOrWhiteSpace(item.Place))
  1038. {
  1039. if (rowIndex > ChildTable2.Rows.Count - 1)
  1040. {
  1041. var chitableRow = ChildTable2.LastRow.Clone(true);
  1042. ChildTable2.AppendChild(chitableRow);
  1043. }
  1044. int days = dac3.FindAll(x => x.Place == item.Place).Count();
  1045. SetCells(ChildTable2, doc, rowIndex, 0, item.Place);
  1046. SetCells(ChildTable2, doc, rowIndex, 1, days + "天");
  1047. string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
  1048. SetCells(ChildTable2, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/天");
  1049. SetCells(ChildTable2, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
  1050. SetCells(ChildTable2, doc, rowIndex, 4, "CNY" + item.SubTotal + "\r\n");
  1051. rowIndex++;
  1052. gzinfo += item.Place + " " + days + "天 " + item.Cost.ToString("#0.00") + currencyCode + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00") + " CNY" + item.SubTotal * days + "\r\n";
  1053. }
  1054. }
  1055. placeArr.Clear();
  1056. TeableBookmarkArr.Add("zsinfo", zsinfo); //住宿费详情
  1057. TeableBookmarkArr.Add("hs", dac2.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //伙食费
  1058. TeableBookmarkArr.Add("hsinfo", hsinfo); //伙食费详情
  1059. TeableBookmarkArr.Add("gz", dac3.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //公杂费
  1060. TeableBookmarkArr.Add("gzinfo", gzinfo); //公杂费详情
  1061. string otherFeestr = "";
  1062. decimal otherFee = 0.00M;
  1063. if (_EnterExitCosts.Visa > 0.00M)
  1064. {
  1065. otherFee += _EnterExitCosts.Visa;
  1066. otherFeestr += $"签证费{_EnterExitCosts.Visa.ToString("#0.00")}元、";
  1067. }
  1068. if (_EnterExitCosts.YiMiao > 0.00M)
  1069. {
  1070. otherFee += _EnterExitCosts.YiMiao;
  1071. otherFeestr += $"疫苗费{_EnterExitCosts.YiMiao.ToString("#0.00")}元、";
  1072. }
  1073. if (_EnterExitCosts.HeSuan > 0.00M)
  1074. {
  1075. otherFee += _EnterExitCosts.HeSuan;
  1076. otherFeestr += $"核酸检测费{_EnterExitCosts.HeSuan.ToString("#0.00")}元、";
  1077. }
  1078. if (_EnterExitCosts.Safe > 0.00M)
  1079. {
  1080. otherFee += _EnterExitCosts.Safe;
  1081. otherFeestr += $"保险费{_EnterExitCosts.Safe.ToString("#0.00")}元、";
  1082. }
  1083. if (_EnterExitCosts.Ticket > 0.00M)
  1084. {
  1085. otherFee += _EnterExitCosts.Ticket;
  1086. otherFeestr += $"参展门票费{_EnterExitCosts.Ticket.ToString("#0.00")}元、";
  1087. }
  1088. if (otherFeestr.Length > 0)
  1089. {
  1090. otherFeestr = otherFeestr.Substring(0, otherFeestr.Length - 1);
  1091. otherFeestr += "等费用";
  1092. }
  1093. TeableBookmarkArr.Add("qt", otherFee.ToString("#0.00") + " 元");//其他费用
  1094. TeableBookmarkArr.Add("qtinfo", otherFeestr);//其他费用第二列
  1095. TeableBookmarkArr.Add("fw", _EnterExitCosts.Service.ToString("#0.00") + "元/人");//服务费
  1096. TeableBookmarkArr.Add("AllPrice", AllPrice.ToString("#0.00") + "元/人");//表格合计费用
  1097. string airStr = client.AirType == 460 ? "经济舱" : client.AirType == 458 ? "公务舱" : "";
  1098. TeableBookmarkArr.Add("title", $"费用清单-{airStr}({firstName})");
  1099. foreach (var book in TeableBookmarkArr.Keys)
  1100. {
  1101. if (doc.Range.Bookmarks[book] != null)
  1102. {
  1103. Bookmark mark = doc.Range.Bookmarks[book];
  1104. mark.Text = TeableBookmarkArr[book];
  1105. }
  1106. }
  1107. if (i != ClientItemList.Count - 1)
  1108. {
  1109. builder.PageSetup.Orientation = Aspose.Words.Orientation.Portrait;
  1110. Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
  1111. table.ParentNode.InsertAfter(paragraph, table);
  1112. var CloneTable = (Aspose.Words.Tables.Table)table.Clone(true);
  1113. table.ParentNode.InsertAfter(CloneTable, paragraph);
  1114. }
  1115. TeableBookmarkArr.Clear();
  1116. }
  1117. bookmarkArr.Add("VisitPrice", WordAllPrice.ToString());//出访费用总额
  1118. bookmarkArr.Add("CnAllPrice", WordAllPrice.ConvertCNYUpper());//出访费用总额中文
  1119. bookmarkArr.Add("namesPrice", UsersTop.TrimEnd('、'));//各人员出访费用 付辰同志出访费用为¥73,604.8元
  1120. foreach (var book in bookmarkArr.Keys)
  1121. {
  1122. if (doc.Range.Bookmarks[book] != null)
  1123. {
  1124. Bookmark mark = doc.Range.Bookmarks[book];
  1125. mark.Text = bookmarkArr[book];
  1126. }
  1127. }
  1128. //MemoryStream outSteam = new MemoryStream();
  1129. string filsPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/File/{ClientItem.Key.Replace("\n", "")}.docx";
  1130. //去水印
  1131. new Aspose.Words.License().SetLicense(new MemoryStream(Convert.FromBase64String(AsposeHelper.asposeKey)));
  1132. doc.Save(filsPath);
  1133. filesToZip.Add(filsPath);
  1134. //streams.Add(ClientItem.Key + ".docx", outSteam.ToArray());
  1135. }
  1136. //文件名
  1137. string zipFileName = _DelegationInfo.TeamName + "-收款账单.zip";
  1138. string zipPath = $"ForeignReceivables/File/{_DelegationInfo.TeamName}-收款账单{DateTime.Now.ToString("yyyyMMddHHmmss")}.zip";
  1139. try
  1140. {
  1141. using (var zip = ZipFile.Open(AppSettingsHelper.Get("WordBasePath") + zipPath, ZipArchiveMode.Create))
  1142. {
  1143. foreach (var file in filesToZip)
  1144. {
  1145. zip.CreateEntryFromFile(file, Path.GetFileName(file));
  1146. }
  1147. }
  1148. }
  1149. catch (Exception ex)
  1150. {
  1151. return Ok(JsonView(false, ex.Message));
  1152. }
  1153. string url = AppSettingsHelper.Get("WordBaseUrl") + $"Office/Word/{zipPath}";
  1154. return Ok(JsonView(true, "成功", new { Url = url }));
  1155. }
  1156. return Ok(JsonView(false, "操作失败!"));
  1157. }
  1158. catch (Exception ex)
  1159. {
  1160. return Ok(JsonView(false, ex.Message));
  1161. }
  1162. }
  1163. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  1164. {
  1165. //获取table中的某个单元格,从0开始
  1166. Aspose.Words.Tables.Cell lshCell = table.Rows[rows].Cells[cells];
  1167. //将单元格中的第一个段落移除
  1168. lshCell.FirstParagraph.Remove();
  1169. //新建一个段落
  1170. Paragraph p = new Paragraph(doc);
  1171. var r = new Run(doc, val);
  1172. r.Font.Size = 8;
  1173. //把设置的值赋给之前新建的段落
  1174. p.AppendChild(r);
  1175. //将此段落加到单元格内
  1176. lshCell.AppendChild(p);
  1177. }
  1178. #endregion
  1179. #region 已收款项
  1180. /// <summary>
  1181. /// 已收款项
  1182. /// 查询
  1183. /// </summary>
  1184. /// <param name="dto"></param>
  1185. /// <returns></returns>
  1186. [HttpPost]
  1187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1188. public async Task<IActionResult> PostAmountReceived(AmountReceivedDto dto)
  1189. {
  1190. try
  1191. {
  1192. if (dto == null)
  1193. {
  1194. return Ok(JsonView(false, "参数不能为空!"));
  1195. }
  1196. Result ffrData = await _proceedsReceivedRep.PostAmountReceived(dto.DiId);
  1197. dynamic data = null;
  1198. if (dto.PortType == 1)
  1199. {
  1200. if (ffrData.Code != 0)
  1201. {
  1202. return Ok(JsonView(false, ffrData.Msg));
  1203. }
  1204. data = ffrData.Data;
  1205. }
  1206. else if (dto.PortType == 2)
  1207. {
  1208. if (ffrData.Code != 0)
  1209. {
  1210. return Ok(JsonView(false, ffrData.Msg));
  1211. }
  1212. data = ffrData.Data;
  1213. }
  1214. else if (dto.PortType == 2)
  1215. {
  1216. if (ffrData.Code != 0)
  1217. {
  1218. return Ok(JsonView(false, ffrData.Msg));
  1219. }
  1220. data = ffrData.Data;
  1221. }
  1222. else
  1223. {
  1224. return Ok(JsonView(false, "请选择正确的端口号!"));
  1225. }
  1226. return Ok(JsonView(true, "操作成功!", data));
  1227. }
  1228. catch (Exception ex)
  1229. {
  1230. return Ok(JsonView(false, ex.Message));
  1231. }
  1232. }
  1233. /// <summary>
  1234. /// 已收款项
  1235. /// Add Or Edit
  1236. /// </summary>
  1237. /// <param name="dto"></param>
  1238. /// <returns></returns>
  1239. [HttpPost]
  1240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1241. public async Task<IActionResult> PostAmountReceivedAddOrEdit(AmountReceivedAddOrEditDto dto)
  1242. {
  1243. try
  1244. {
  1245. if (dto == null)
  1246. {
  1247. return Ok(JsonView(false, "参数不能为空!"));
  1248. }
  1249. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedAddOrEditDto(dto);
  1250. if (dto.PortType == 1)
  1251. {
  1252. if (ffrData.Code != 0)
  1253. {
  1254. return Ok(JsonView(false, ffrData.Msg));
  1255. }
  1256. }
  1257. else if (dto.PortType == 2)
  1258. {
  1259. if (ffrData.Code != 0)
  1260. {
  1261. return Ok(JsonView(false, ffrData.Msg));
  1262. }
  1263. }
  1264. else if (dto.PortType == 2)
  1265. {
  1266. if (ffrData.Code != 0)
  1267. {
  1268. return Ok(JsonView(false, ffrData.Msg));
  1269. }
  1270. }
  1271. else
  1272. {
  1273. return Ok(JsonView(false, "请选择正确的端口号!"));
  1274. }
  1275. return Ok(JsonView(true, "操作成功!"));
  1276. }
  1277. catch (Exception ex)
  1278. {
  1279. return Ok(JsonView(false, ex.Message));
  1280. }
  1281. }
  1282. /// <summary>
  1283. /// 已收款项
  1284. /// Del
  1285. /// </summary>
  1286. /// <param name="dto"></param>
  1287. /// <returns></returns>
  1288. [HttpPost]
  1289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1290. public async Task<IActionResult> PostAmountReceived_Del(AmountReceivedDelDto dto)
  1291. {
  1292. try
  1293. {
  1294. if (dto == null)
  1295. {
  1296. return Ok(JsonView(false, "参数不能为空!"));
  1297. }
  1298. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedDel(dto);
  1299. if (ffrData.Code != 0)
  1300. {
  1301. return Ok(JsonView(false, ffrData.Msg));
  1302. }
  1303. return Ok(JsonView(true, "操作成功!"));
  1304. }
  1305. catch (Exception ex)
  1306. {
  1307. return Ok(JsonView(false, ex.Message));
  1308. }
  1309. }
  1310. #endregion
  1311. #region 收款退还与其他款项 --> 收款退还
  1312. /// <summary>
  1313. /// 收款退还与其他款项
  1314. /// 查询 根据团组Id
  1315. /// </summary>
  1316. /// <param name="dto"></param>
  1317. /// <returns></returns>
  1318. [HttpPost]
  1319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1320. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyItemByDiId(PaymentRefundAndOtherMoneyItemByDiIdDto dto)
  1321. {
  1322. try
  1323. {
  1324. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  1325. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  1326. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  1327. #region 页面功能权限处理
  1328. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  1329. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1330. if (pageFunAuth.CheckAuth == 0)
  1331. {
  1332. return Ok(JsonView(false, "您没有当前页面查询权限!"));
  1333. }
  1334. #endregion
  1335. Result _result = await _paymentRefundAndOtherMoneyRep._ItemByDiId(dto.DiId);
  1336. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //1 Web 2 Android 3 Ios
  1337. {
  1338. if (_result.Code != 0)
  1339. {
  1340. return Ok(JsonView(false, _result.Msg));
  1341. }
  1342. var data = new
  1343. {
  1344. PageFuncAuth = pageFunAuth,
  1345. Data = _result.Data
  1346. };
  1347. return Ok(JsonView(true, "操作成功!", data));
  1348. }
  1349. else
  1350. {
  1351. return Ok(JsonView(false, "请输入正确的端口号! 1 Web 2 Android 3 Ios;"));
  1352. }
  1353. }
  1354. catch (Exception ex)
  1355. {
  1356. return Ok(JsonView(false, ex.Message));
  1357. }
  1358. }
  1359. /// <summary>
  1360. /// 收款退还与其他款项
  1361. /// 删除
  1362. /// </summary>
  1363. /// <param name="dto"></param>
  1364. /// <returns></returns>
  1365. [HttpPost]
  1366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1367. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyDel(PaymentRefundAndOtherMoneyDelDto dto)
  1368. {
  1369. try
  1370. {
  1371. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  1372. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  1373. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  1374. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  1375. #region 页面功能权限处理
  1376. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1377. #endregion
  1378. if (pageFunAuth.DeleteAuth == 0)
  1379. {
  1380. return Ok(JsonView(false, "您没有当前页面删除权限!"));
  1381. }
  1382. Result _result = await _paymentRefundAndOtherMoneyRep._Del(dto);
  1383. if (_result.Code != 0)
  1384. {
  1385. return Ok(JsonView(false, _result.Msg));
  1386. }
  1387. return Ok(JsonView(true, "操作成功!"));
  1388. }
  1389. catch (Exception ex)
  1390. {
  1391. return Ok(JsonView(false, ex.Message));
  1392. }
  1393. }
  1394. /// <summary>
  1395. /// 收款退还与其他款项
  1396. /// Info Data Source
  1397. /// </summary>
  1398. /// <param name="dto"></param>
  1399. /// <returns></returns>
  1400. [HttpPost]
  1401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1402. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyInfoDataSource(PortDtoBase dto)
  1403. {
  1404. try
  1405. {
  1406. Result _result = await _paymentRefundAndOtherMoneyRep._InfoDataSource(dto);
  1407. if (_result.Code != 0)
  1408. {
  1409. return Ok(JsonView(false, _result.Msg));
  1410. }
  1411. return Ok(JsonView(true, "查询成功!", _result.Data));
  1412. }
  1413. catch (Exception ex)
  1414. {
  1415. return Ok(JsonView(false, ex.Message));
  1416. }
  1417. }
  1418. /// <summary>
  1419. /// 收款退还与其他款项
  1420. /// Info
  1421. /// </summary>
  1422. /// <param name="dto"></param>
  1423. /// <returns></returns>
  1424. [HttpPost]
  1425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1426. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyInfo(PaymentRefundAndOtherMoneyInfoDto dto)
  1427. {
  1428. try
  1429. {
  1430. if (dto == null)
  1431. {
  1432. return Ok(JsonView(false, "参数不能为空!"));
  1433. }
  1434. Result _result = await _paymentRefundAndOtherMoneyRep._Info(dto);
  1435. if (_result.Code != 0)
  1436. {
  1437. return Ok(JsonView(false, _result.Msg));
  1438. }
  1439. return Ok(JsonView(true, "查询成功!", _result.Data));
  1440. }
  1441. catch (Exception ex)
  1442. {
  1443. return Ok(JsonView(false, ex.Message));
  1444. }
  1445. }
  1446. /// <summary>
  1447. /// 收款退还与其他款项 --> 收款退还(只保留人名币)
  1448. /// 操作(Add Or Edit)
  1449. /// </summary>
  1450. /// <param name="dto"></param>
  1451. /// <returns></returns>
  1452. [HttpPost]
  1453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1454. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyAddOrEdit(PaymentRefundAndOtherMoneyAddOrEditDto dto)
  1455. {
  1456. try
  1457. {
  1458. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  1459. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  1460. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  1461. #region 页面功能权限处理
  1462. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  1463. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1464. #endregion
  1465. if (dto.Status == 1) //add
  1466. {
  1467. if (pageFunAuth.AddAuth == 0)
  1468. {
  1469. return Ok(JsonView(false, "您没有当前页面添加权限!"));
  1470. }
  1471. }
  1472. else if (dto.Status == 2) //edit
  1473. {
  1474. if (pageFunAuth.EditAuth == 0)
  1475. {
  1476. return Ok(JsonView(false, "您没有当前页面编辑权限!"));
  1477. }
  1478. }
  1479. else
  1480. {
  1481. return Ok(JsonView(false, "请输入正确的操作状态! 1 添加 2 修改!"));
  1482. }
  1483. Result _result = await _paymentRefundAndOtherMoneyRep._AddOrEdit(dto);
  1484. if (_result.Code != 0)
  1485. {
  1486. return Ok(JsonView(false, _result.Msg));
  1487. }
  1488. return Ok(JsonView(true, "操作成功!"));
  1489. }
  1490. catch (Exception ex)
  1491. {
  1492. return Ok(JsonView(false, ex.Message));
  1493. }
  1494. }
  1495. #endregion
  1496. #region 应收报表
  1497. /// <summary>
  1498. /// 应收报表
  1499. /// 查询 根据日期范围
  1500. /// </summary>
  1501. /// <param name="dto"></param>
  1502. /// <returns></returns>
  1503. [HttpPost]
  1504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1505. public async Task<IActionResult> PostSyntheticalReceivableByDateRange(PostSyntheticalReceivableByDateRangeDto dto)
  1506. {
  1507. string sqlWhere = " Where di.IsDel=0 ";
  1508. #region 验证
  1509. if (string.IsNullOrEmpty(dto.beginDt) && string.IsNullOrEmpty(dto.endDt))
  1510. {
  1511. return Ok(JsonView(false, "日期参数至少填写一个!"));
  1512. }
  1513. if (!string.IsNullOrEmpty(dto.beginDt))
  1514. {
  1515. if (Regex.Match(dto.beginDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
  1516. {
  1517. return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
  1518. }
  1519. else
  1520. {
  1521. sqlWhere += string.Format(@" And di.VisitDate >= '{0} 00:00:00' ", dto.beginDt);
  1522. }
  1523. }
  1524. if (!string.IsNullOrEmpty(dto.endDt))
  1525. {
  1526. if (Regex.Match(dto.endDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
  1527. {
  1528. return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
  1529. }
  1530. else
  1531. {
  1532. sqlWhere += string.Format(@" And di.VisitDate <= '{0} 23:59:59' ", dto.endDt);
  1533. }
  1534. }
  1535. #endregion
  1536. //排序倒序
  1537. string sql = string.Format(@" select distinct fr.diid,di.TeamName,di.ClientUnit,di.VisitDate,di.CreateTime from Fin_ForeignReceivables fr join Grp_DelegationInfo di on fr.DIID = di.id {0} Order By di.CreateTime Desc", sqlWhere);
  1538. List<PostSyntheticalReceivableByDateRangeView> list_rst = _sqlSugar.SqlQueryable<PostSyntheticalReceivableByDateRangeView>(sql).ToList();
  1539. var setData = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToList();
  1540. decimal sumAll_fr = 0M; //应收
  1541. decimal sumAll_pr = 0M; //已收
  1542. decimal sumAll_balance = 0M; //尾款
  1543. if (list_rst.Count > 0)
  1544. {
  1545. int rowNumber = 1;
  1546. foreach (var item_rst in list_rst)
  1547. {
  1548. DateTime dtTemp;
  1549. bool b = DateTime.TryParse(item_rst.visitDate, out dtTemp);
  1550. if (b)
  1551. {
  1552. item_rst.visitDate = dtTemp.ToString("yyyy-MM-dd");
  1553. }
  1554. item_rst.No = rowNumber;
  1555. rowNumber++;
  1556. int diId = item_rst.diid;
  1557. decimal sum_fr = 0M;
  1558. decimal sum_pr = 0M;
  1559. string str_client = string.Empty;
  1560. decimal sum_refund = 0M; //收款退还
  1561. decimal sum_extra = 0M; //超支费用
  1562. decimal balance = 0M;
  1563. string str_schedule = string.Empty;
  1564. //1.应收
  1565. string sql_fr = string.Format(@" Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0} ", diId);
  1566. List<Fin_ForeignReceivables> list_fr = _sqlSugar.SqlQueryable<Fin_ForeignReceivables>(sql_fr).ToList();
  1567. sum_fr = list_fr.Sum(s => s.ItemSumPrice);
  1568. //2.已收
  1569. string sql_pr = string.Format(@" Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0} ", diId);
  1570. List<Fin_ProceedsReceived> list_pr = _sqlSugar.SqlQueryable<Fin_ProceedsReceived>(sql_pr).ToList();
  1571. foreach (var item_pr in list_pr)
  1572. {
  1573. sum_pr += item_pr.Price;
  1574. str_client += string.Format(@"{0};", item_pr.Client);
  1575. str_schedule += string.Format(@"{0};", item_pr.Remark);
  1576. }
  1577. if (str_schedule.Length > 0)
  1578. {
  1579. str_schedule = str_schedule.TrimEnd(';');
  1580. }
  1581. if (str_client.Length > 0)
  1582. {
  1583. str_client = str_client.TrimEnd(';');
  1584. }
  1585. //3.收款退还
  1586. string sql_other = string.Format(@"Select * From Fin_PaymentRefundAndOtherMoney prao
  1587. Inner Join Grp_CreditCardPayment ccp On prao.Id = ccp.CId
  1588. Where ccp.CTable = 285 And ccp.IsPay = 1 And prao.IsDel = 0 And ccp.IsDel = 0 And prao.DiId = {0}", diId);
  1589. List<Grp_CreditCardPayment> list_other = _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql_other).ToList();
  1590. sum_refund = list_other.Sum(s => s.RMBPrice);
  1591. //4.超支
  1592. string sql_extra = string.Format(@" Select c.* From Fin_GroupExtraCost f
  1593. Inner join Grp_CreditCardPayment c On f.Id = c.CId
  1594. Where c.CTable = 1015 And c.IsPay = 1 And f.IsDel = 0 And c.IsDel = 0 And f.DiId = {0} ", diId);
  1595. List<Grp_CreditCardPayment> list_extra = _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql_extra).ToList();
  1596. sum_extra = list_extra.Sum(s => s.RMBPrice);
  1597. item_rst.frPrice = sum_fr.ToString("#0.00");
  1598. item_rst.extraPrice = sum_extra.ToString("#0.00");
  1599. item_rst.receivableTotal = (sum_fr + sum_extra).ToString("#0.00");
  1600. item_rst.prPrice = sum_pr.ToString("#0.00");
  1601. item_rst.refundAmount = sum_refund.ToString("#0.00");
  1602. item_rst.receivedTotal = (sum_pr - sum_refund).ToString("#0.00");
  1603. item_rst.balPrice = ((sum_fr + sum_extra) - (sum_pr - sum_refund)).ToString("#0.00");
  1604. item_rst.prClient = str_client;
  1605. item_rst.schedule = str_schedule;
  1606. string tempVisitDate = Convert.ToDateTime(item_rst.visitDate).ToString("yyyy-MM-dd");
  1607. sumAll_fr += (sum_fr + sum_extra);
  1608. sumAll_pr += (sum_pr - sum_refund);
  1609. sumAll_balance += ((sum_fr + sum_extra) - (sum_pr - sum_refund));
  1610. #region 单位应收已收细项(以应收费用名称为主去(已收费用)匹配) 新增 雷怡 2024-35-08 16:35:28
  1611. List<ClientFeeInfoView> feeDatas = new List<ClientFeeInfoView>();
  1612. //匹配上的数据
  1613. foreach (var item in list_fr)
  1614. {
  1615. var prInfo = list_pr.Find(it => item.PriceName.Contains(it.Client) || item.PriceName.Equals(it.Client));
  1616. decimal _balancePayment = 0.00M;
  1617. if (item.Currency == prInfo?.Currency)
  1618. {
  1619. _balancePayment = item.ItemSumPrice - prInfo?.Price ?? 0.00M;
  1620. }
  1621. feeDatas.Add(new ClientFeeInfoView
  1622. {
  1623. client = item.PriceName,
  1624. frMoney = item.ItemSumPrice.ToString("#0.00"),
  1625. frCurrency = setData.Find(it => it.Id == item.Currency)?.Name ?? "-",
  1626. frRate = item.Rate.ToString("#0.0000"),
  1627. prReceivablesType = setData.Find(it => it.Id == prInfo?.ReceivablesType)?.Name ?? "",
  1628. prTime = prInfo?.SectionTime ?? "-",
  1629. prMoney = prInfo?.Price.ToString("#0.00") ?? "-",
  1630. prCurrency = setData.Find(it => it.Id == prInfo?.Currency)?.Name ?? "",
  1631. balPayment = _balancePayment.ToString("#0.00")
  1632. });
  1633. }
  1634. //未匹配上的数据
  1635. foreach (var item in list_pr)
  1636. {
  1637. var frInfo = list_fr.Find(it => it.PriceName.Contains(item.Client) || it.PriceName.Equals(item.Client));
  1638. if (frInfo == null)
  1639. {
  1640. feeDatas.Add(new ClientFeeInfoView
  1641. {
  1642. client = item.Client + "[未匹配上的已收数据(应收已收公司名称不一致)]",
  1643. frMoney = "0.00",
  1644. frCurrency = "-",
  1645. frRate = "0.0000",
  1646. prReceivablesType = setData.Find(it => it.Id == item?.ReceivablesType)?.Name ?? "",
  1647. prTime = item?.SectionTime ?? "-",
  1648. prMoney = item?.Price.ToString("#0.00") ?? "0.00",
  1649. prCurrency = setData.Find(it => it.Id == item?.Currency)?.Name ?? "",
  1650. balPayment = "0.00"
  1651. });
  1652. }
  1653. }
  1654. item_rst.feeItem = feeDatas;
  1655. #endregion
  1656. }
  1657. PostSyntheticalReceivableByDateRangeResultView result = new PostSyntheticalReceivableByDateRangeResultView();
  1658. result.total_fr = sumAll_fr.ToString("#0.00");
  1659. result.total_pr = sumAll_pr.ToString("#0.00");
  1660. result.total_balance = sumAll_balance.ToString("#0.00");
  1661. result.dataList = new List<PostSyntheticalReceivableByDateRangeView>(list_rst);
  1662. if (dto.requestType == 1)
  1663. {
  1664. return Ok(JsonView(true, "请求成功", result, list_rst.Count));
  1665. }
  1666. else
  1667. {
  1668. //----------------------------
  1669. List<Excel_SyntheticalReceivableByDateRange> list_Ex = new List<Excel_SyntheticalReceivableByDateRange>();
  1670. WorkbookDesigner designer = new WorkbookDesigner();
  1671. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/应收款项模板 - 副本.xls");
  1672. int excNo = 1;
  1673. foreach (var item in list_rst)
  1674. {
  1675. Excel_SyntheticalReceivableByDateRange exc = new Excel_SyntheticalReceivableByDateRange();
  1676. exc.No = excNo.ToString();
  1677. excNo++;
  1678. exc.TeamName = item.teamName;
  1679. exc.ClientUnit = item.clientUnit;
  1680. exc.VisitDate = item.visitDate;
  1681. exc.Accounts = item.frPrice;
  1682. exc.Extra = item.extraPrice;
  1683. exc.ReceivableTotal = item.receivableTotal;
  1684. exc.Received = item.prPrice;
  1685. exc.RefundAmount = item.refundAmount;
  1686. exc.ReceivedTotal = item.receivedTotal;
  1687. exc.Balance = item.balPrice;
  1688. exc.Collection = item.schedule;
  1689. DateTime time = Convert.ToDateTime(item.visitDate);
  1690. TimeSpan ts = DateTime.Now - time;
  1691. float SY = float.Parse(item.balPrice);
  1692. if (ts.Days >= 365 && SY > 0)
  1693. {
  1694. exc.Sign = "需收款";
  1695. }
  1696. else
  1697. {
  1698. exc.Sign = "";
  1699. }
  1700. list_Ex.Add(exc);
  1701. }
  1702. var dt = CommonFun.GetDataTableFromIList(list_Ex);
  1703. dt.TableName = "Excel_SyntheticalReceivableByDateRange";
  1704. if (dt != null)
  1705. {
  1706. designer.SetDataSource("SumPrice", "应收合计:" + result.total_fr + "RMB 已收合计:" + result.total_pr + "RMB 余款合计:" + result.total_balance + "RMB");
  1707. //数据源
  1708. designer.SetDataSource(dt);
  1709. //根据数据源处理生成报表内容
  1710. designer.Process();
  1711. string fileName = ("Receivable/应收款项(" + dto.beginDt + "~" + dto.endDt + ").xlsx");
  1712. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1713. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1714. return Ok(JsonView(true, "成功", new { url = rst }));
  1715. }
  1716. }
  1717. }
  1718. return Ok(JsonView(true, "获取成功", "", list_rst.Count));
  1719. }
  1720. #endregion
  1721. #region 付款申请
  1722. /// <summary>
  1723. /// 付款申请
  1724. /// 基础数据
  1725. /// </summary>
  1726. /// <param name="dto"></param>
  1727. /// <returns></returns>
  1728. [HttpPost]
  1729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1730. public async Task<IActionResult> PostPayRequestInit()
  1731. {
  1732. try
  1733. {
  1734. var conpanyDatas = _sqlSugar.Queryable<Sys_Company>()
  1735. .Where(it => it.IsDel == 0)
  1736. .Select(it => new
  1737. {
  1738. Id = it.Id,
  1739. ConpamyName = it.CompanyName
  1740. }).ToList();
  1741. return Ok(JsonView(true, "操作成功!", new { ConpanyData = conpanyDatas }));
  1742. }
  1743. catch (Exception ex)
  1744. {
  1745. return Ok(JsonView(false, ex.Message));
  1746. }
  1747. }
  1748. /// <summary>
  1749. /// 付款申请 (PageId=51)
  1750. /// 查询 根据日期范围
  1751. /// </summary>
  1752. /// <param name="dto"></param>
  1753. /// <returns></returns>
  1754. [HttpPost]
  1755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1756. public async Task<IActionResult> PostPayRequest_Center(PostPayRequestByDateRangeDto dto)
  1757. {
  1758. Stopwatch stopwatch = Stopwatch.StartNew();
  1759. #region 验证
  1760. DateTime beginDt, endDt;
  1761. string format = "yyyy-MM-dd";
  1762. if (!DateTime.TryParseExact(dto.beginDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out beginDt))
  1763. {
  1764. return Ok(JsonView(false, "开始日期格式不正确!正确格式:yyyy-MM-dd"));
  1765. }
  1766. if (!DateTime.TryParseExact(dto.endDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out endDt))
  1767. {
  1768. return Ok(JsonView(false, "结束日期格式不正确!正确格式:yyyy-MM-dd"));
  1769. }
  1770. #region 页面操作权限验证
  1771. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1772. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1773. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  1774. #endregion
  1775. #endregion
  1776. try
  1777. {
  1778. PaymentRequestCheckedView checkedView = new PaymentRequestCheckedView();
  1779. var checkedStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("paymentRequestCheckedData");
  1780. if (checkedStr != null)
  1781. {
  1782. checkedView = JsonConvert.DeserializeObject<PaymentRequestCheckedView>(checkedStr.ToString());
  1783. }
  1784. tree_Fin_DailyFeePaymentResult dailyResult = PayRequest_DailyByDateRange(dto.Status, checkedView.DailyPaymentIds, dto.beginDt, dto.endDt);
  1785. tree_Group_DailyFeePaymentResult groupResult = PayRequest_GroupPaymentByDateRange(dto.Status, checkedView.GroupIds, dto.beginDt, dto.endDt);
  1786. stopwatch.Stop();
  1787. return Ok(JsonView(true, $"查询成功!耗时{stopwatch.ElapsedMilliseconds / 1000}s", new { daily = dailyResult, group = groupResult }));
  1788. }
  1789. catch (Exception ex)
  1790. {
  1791. return Ok(JsonView(false, ex.Message));
  1792. }
  1793. }
  1794. /// <summary>
  1795. /// 根据团组类型类型处理团组费用所属公司
  1796. /// </summary>
  1797. /// <param name="teamId"></param>
  1798. /// <returns></returns>
  1799. private CompanyInfo ExpenseCompanyByTeamId(int teamId)
  1800. {
  1801. CompanyInfo _companyInfo = new CompanyInfo();
  1802. List<int> _SiChuan = new List<int>() {
  1803. 38 , // 政府团
  1804. 39 , // 企业团
  1805. 40 , // 散客团
  1806. 102, // 未知
  1807. 248, // 非团组
  1808. 691, // 四川-会务活动
  1809. 762, // 四川-赛事项目收入
  1810. };
  1811. List<int> _ChengDu = new List<int>() {
  1812. 302, // 成都-会务活动
  1813. 1047, // 成都-赛事项目收入
  1814. };
  1815. if (_SiChuan.Contains(teamId))
  1816. {
  1817. _companyInfo.Id = 2;
  1818. _companyInfo.ConpanyName = "四川泛美交流有限公司";
  1819. }
  1820. if (_ChengDu.Contains(teamId))
  1821. {
  1822. _companyInfo.Id = 1;
  1823. _companyInfo.ConpanyName = "成都泛美商务有限公司";
  1824. }
  1825. return _companyInfo;
  1826. }
  1827. /// <summary>
  1828. /// 付款申请(团组费用申请相关)
  1829. /// 查询 根据日期范围
  1830. /// </summary>
  1831. /// <param name="_groupIds"></param>
  1832. /// <param name="beginDt"></param>
  1833. /// <param name="endDt"></param>
  1834. /// <returns></returns>
  1835. private tree_Group_DailyFeePaymentResult PayRequest_GroupPaymentByDateRange(int status, List<int> _groupIds, string beginDt, string endDt)
  1836. {
  1837. tree_Group_DailyFeePaymentResult _DailyFeePaymentResult = new tree_Group_DailyFeePaymentResult();
  1838. List<tree_Group_DailyFeePaymentPageListView> dataList = new List<tree_Group_DailyFeePaymentPageListView>();
  1839. #region sql条件处理
  1840. string sqlWhere = string.Format(@" And (AuditGMDate Between '{0} 00:00:00' And '{1} 23:59:59') ", beginDt, endDt);
  1841. if (status == 2)
  1842. {
  1843. if (_groupIds.Count < 1)
  1844. {
  1845. _DailyFeePaymentResult.dataList = new List<tree_Group_DailyFeePaymentPageListView>();
  1846. return _DailyFeePaymentResult;
  1847. }
  1848. sqlWhere += string.Format(@" And Id In ({0})", string.Join(",", _groupIds));
  1849. }
  1850. string sql_1 = string.Format(@"Select * From Grp_CreditCardPayment Where IsDel = 0 And IsPay = 0 And IsAuditGM = 1 {0}", sqlWhere);
  1851. #endregion
  1852. var _paymentDatas = _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql_1).ToList();//付款信息
  1853. _DailyFeePaymentResult.gz = _paymentDatas.Where(it => it.OrbitalPrivateTransfer == 0).Sum(it => ((it.PayMoney * it.DayRate) / 100) * it.PayPercentage); //公转
  1854. _DailyFeePaymentResult.sz = _paymentDatas.Where(it => it.OrbitalPrivateTransfer == 1).Sum(it => ((it.PayMoney * it.DayRate) / 100) * it.PayPercentage); ; //私转
  1855. List<int> groupIds = _paymentDatas.Select(it => it.DIId).Distinct().ToList();
  1856. var _groupDatas = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && groupIds.Contains(it.Id)).ToList();
  1857. //_groupDatas = (List<Grp_DelegationInfo>)_groupDatas.GroupBy(it => it.TeamDid);
  1858. #region 相关基础数据源
  1859. var userDatas = _sqlSugar.Queryable<Sys_Users>().ToList();
  1860. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToList();
  1861. var countryFeeDatas = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  1862. var hotelDatas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1863. var opDatas = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1864. var visaDatas = _sqlSugar.Queryable<Grp_VisaInfo>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DIId)).ToList();
  1865. var ioaDatas = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1866. var insureDatas = _sqlSugar.Queryable<Grp_Customers>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1867. var airDatas = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DIId)).ToList();
  1868. //var otherMoneyDatas = _sqlSugar.Queryable<Fin_OtherPrice>().Where(it => it.IsDel == 0 && groupIds.Contains(it.Diid)).ToList();
  1869. var otherMoneyDatas = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1870. var refundPaymentDatas = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1871. var ExtraCostDatas = _sqlSugar.Queryable<Fin_GroupExtraCost>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1872. #endregion
  1873. //Expense company
  1874. foreach (var groupInfo in _groupDatas)
  1875. {
  1876. List<Group_DailyFeePaymentContentInfolView> childList = new List<Group_DailyFeePaymentContentInfolView>();
  1877. var groupPaymentDatas = _paymentDatas.Where(it => groupInfo.Id == it.DIId).ToList();
  1878. int rouNumber = 1;
  1879. foreach (var payInfo in groupPaymentDatas)
  1880. {
  1881. string priName = "-";
  1882. string orbitalPrivateTransfer = payInfo.OrbitalPrivateTransfer == 0 ? "公转" : payInfo.OrbitalPrivateTransfer == 1 ? "私转" : "-";
  1883. switch (payInfo.CTable)
  1884. {
  1885. case 76: //76 酒店预订
  1886. priName = $"[费用名称:{hotelDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.HotelName ?? ""}]";
  1887. break;
  1888. case 79: //79 车/导游地接
  1889. var opData = opDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id);
  1890. if (opData != null)
  1891. {
  1892. string area = "";
  1893. bool b = int.TryParse(opData.Area, out int areaId);
  1894. if (b)
  1895. {
  1896. string area1 = countryFeeDatas.Find(it => it.Id == areaId)?.Country ?? "-";
  1897. area = $"{area1}({setDatas.Find(it => it.Id == opData.PriceType)?.Name ?? "-"})";
  1898. }
  1899. else area = opData.Area;
  1900. string opPriName = "-";
  1901. if (!string.IsNullOrEmpty(opData.PriceName)) opPriName = opData.PriceName;
  1902. area += $"({opPriName})";
  1903. if (payInfo.OrbitalPrivateTransfer == 0) //公转
  1904. {
  1905. priName = $"【{orbitalPrivateTransfer}】【导游: {opData.ServiceGuide} 】[费用名称:{area}]";
  1906. }
  1907. else if (payInfo.OrbitalPrivateTransfer == 1) //私转
  1908. {
  1909. priName = $"【{orbitalPrivateTransfer}】【导游:{opData.ServiceGuide}】[费用名称:{area}]";
  1910. }
  1911. }
  1912. break;
  1913. case 80: // 80 签证
  1914. string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", groupInfo.Id);
  1915. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1916. string visaClientName = visaDatas.Find(it => payInfo.DIId == it.DIId && payInfo.CId == it.Id)?.VisaClient ?? "";
  1917. string clientName = "-";
  1918. if (Regex.Match(visaClientName, @"\d+,?").Value.Length > 0)
  1919. {
  1920. string[] temparr = visaClientName.Split(',');
  1921. string fistrStr = temparr[0];
  1922. int count = temparr.Count();
  1923. int tempId;
  1924. bool success = int.TryParse(fistrStr, out tempId);
  1925. if (success)
  1926. {
  1927. SimplClientInfo tempInfo = arr.FirstOrDefault(s => s.Id == tempId);
  1928. if (tempInfo != null)
  1929. {
  1930. if (count > 1)
  1931. {
  1932. clientName = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1933. }
  1934. else
  1935. {
  1936. clientName = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1937. }
  1938. }
  1939. }
  1940. else
  1941. {
  1942. clientName = fistrStr;
  1943. }
  1944. }
  1945. priName = $"[费用名称:{clientName}]";
  1946. break;
  1947. case 81: // 81 邀请/公务活动
  1948. priName = $"[费用名称:{ioaDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.Inviter ?? " -"}]";
  1949. break;
  1950. case 82: // 82 团组客户保险
  1951. priName = $"[费用名称:{insureDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.ClientName ?? " -"}]";
  1952. break;
  1953. case 85: // 85 机票预订
  1954. string flightsCode = airDatas.Find(it => payInfo.DIId == it.DIId && payInfo.CId == it.Id)?.FlightsCode ?? "-";
  1955. string airPayType = setDatas.Find(it => it.Id == payInfo.PayDId)?.Name ?? "-";
  1956. priName = $"{flightsCode}【{airPayType}】";
  1957. break;
  1958. case 98: // 98 其他款项
  1959. priName = $"[费用名称:{otherMoneyDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
  1960. break;
  1961. case 285: // 285 收款退还
  1962. priName = $"[费用名称:{refundPaymentDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
  1963. break;
  1964. case 1015: // 1015 超支费用
  1965. priName = $"[费用名称:{ExtraCostDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
  1966. break;
  1967. default:
  1968. priName = "";
  1969. break;
  1970. }
  1971. //
  1972. bool status1 = false;
  1973. if (_groupIds != null)
  1974. {
  1975. status1 = _groupIds.Contains(payInfo.Id);
  1976. }
  1977. string payeeStr = string.Format(@" {0},开户行:{1},银行卡号:{2} ", string.IsNullOrEmpty(payInfo.Payee) ? "-" : payInfo.Payee,
  1978. string.IsNullOrEmpty(payInfo.OtherBankName) ? "-" : payInfo.OtherBankName,
  1979. string.IsNullOrEmpty(payInfo.OtherSideNo) ? "-" : payInfo.OtherSideNo);
  1980. decimal _PaymentAmount = (payInfo.PayMoney / 100) * payInfo.PayPercentage;//此次付款金额
  1981. decimal _CNYSubTotalAmount = _PaymentAmount * payInfo.DayRate;//此次付款金额
  1982. _CNYSubTotalAmount = Convert.ToDecimal(_CNYSubTotalAmount.ToString("#0.00"));
  1983. var childInfo = new Group_DailyFeePaymentContentInfolView()
  1984. {
  1985. IsChecked = status1,
  1986. Id = payInfo.Id,
  1987. Payee = payeeStr,
  1988. RowNumber = rouNumber,
  1989. Applicant = userDatas.Find(it => it.Id == payInfo.CreateUserId)?.CnName ?? "",
  1990. ApplicantDt = payInfo.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
  1991. PayType = setDatas.Find(it => it.Id == payInfo.PayDId)?.Name ?? "",
  1992. TransferMark = orbitalPrivateTransfer,
  1993. PriceName = priName,
  1994. ModuleName = setDatas.Find(it => it.Id == payInfo.CTable)?.Name ?? "",
  1995. PayCurrCode = setDatas.Find(it => it.Id == payInfo.PaymentCurrency)?.Name ?? "",
  1996. PaymentAmount = _PaymentAmount,
  1997. PayRate = payInfo.DayRate,
  1998. CNYSubTotalAmount = _CNYSubTotalAmount
  1999. };
  2000. //string remaksDescription = $"【{childInfo.PayType}】【{childInfo.ModuleName}】{rouNumber}、[申请人:{childInfo.Applicant}][收款方:{childInfo.Payee}]{priName},{payInfo.OtherBankName},{payInfo.OtherSideNo}[{payInfo.ConsumptionPatterns}] {childInfo.PayCurrCode} {payInfo.PayMoney.ToString("#0.00")}、CNY:{childInfo.CNYSubTotalAmount.ToString("#0.00")}(团组:{groupInfo.TeamName})";
  2001. string remaksDescription = $"【{childInfo.PayType}】【{childInfo.ModuleName}】{rouNumber}、[申请人:{childInfo.Applicant}]{priName}[收款方:{childInfo.Payee}] {childInfo.PayCurrCode} {_PaymentAmount.ToString("#0.00")}、CNY:{childInfo.CNYSubTotalAmount.ToString("#0.00")}(团组:{groupInfo.TeamName})";
  2002. childInfo.RemaksDescription = remaksDescription;
  2003. childList.Add(childInfo);
  2004. rouNumber++;
  2005. }
  2006. CompanyInfo companyInfo = new CompanyInfo();
  2007. companyInfo = ExpenseCompanyByTeamId(groupInfo.TeamDid);
  2008. dataList.Add(new tree_Group_DailyFeePaymentPageListView()
  2009. {
  2010. Id = Guid.NewGuid().ToString("N"),
  2011. GroupName = groupInfo.TeamName,
  2012. CompanyId = companyInfo.Id,
  2013. ConpanyName = companyInfo.ConpanyName,
  2014. CNYTotalAmount = childList.Sum(it => it.CNYSubTotalAmount),
  2015. ChildList = childList,
  2016. });
  2017. }
  2018. _DailyFeePaymentResult.dataList = dataList;
  2019. return _DailyFeePaymentResult;
  2020. }
  2021. /// <summary>
  2022. /// 付款申请(日付申请相关)
  2023. /// 查询 根据日期范围
  2024. /// </summary>
  2025. /// <param name="_dailyIds"></param>
  2026. /// <param name="beginDt"></param>
  2027. /// <param name="endDt"></param>
  2028. /// <returns></returns>
  2029. private tree_Fin_DailyFeePaymentResult PayRequest_DailyByDateRange(int status, List<int> _dailyIds, string beginDt, string endDt)
  2030. {
  2031. #region sql条件处理
  2032. string sqlWhere = string.Format(@" And dfp.CreateTime between '{0} 00:00:00' And '{1} 23:59:59' ", beginDt, endDt);
  2033. if (status == 2)
  2034. {
  2035. if (_dailyIds.Count < 1)
  2036. {
  2037. return new tree_Fin_DailyFeePaymentResult() { childList = new List<Fin_DailyFeePaymentContentInfolView>() };
  2038. }
  2039. sqlWhere += string.Format(@" And dfp.Id In({0}) ", string.Join(",", _dailyIds));
  2040. }
  2041. string sql_1 = string.Format(@"Select * From (
  2042. Select row_number() over (order by dfp.Id Desc) as RowNumber,
  2043. dfp.Id,dfp.CompanyId,c.CompanyName,dfp.Instructions,dfp.SumPrice,
  2044. dfp.CreateUserId,u.CnName CreateUser,dfp.CreateTime,dfp.FAudit,dfp.MAudit,
  2045. dfp.PriceTypeId,dfp.TransferTypeId
  2046. From Fin_DailyFeePayment dfp
  2047. Inner Join Sys_Company c On dfp.CompanyId = c.Id
  2048. Left Join Sys_Users u On dfp.CreateUserId = u.Id
  2049. Where dfp.IsDel=0 {0} And dfp.FAudit = 1 And dfp.MAudit = 1 And dfp.IsPay = 0
  2050. ) temp ", sqlWhere);
  2051. #endregion
  2052. List<tree_Fin_DailyFeePaymentPageListView> DailyFeePaymentData = _sqlSugar.SqlQueryable<tree_Fin_DailyFeePaymentPageListView>(sql_1).ToList();
  2053. Dictionary<int, string> dic_setData = new Dictionary<int, string>();
  2054. Sys_SetDataType stGZ = _daiRep.Query<Sys_SetDataType>(s => s.Name == "公转").First();
  2055. Sys_SetDataType stSZ = _daiRep.Query<Sys_SetDataType>(s => s.Name == "私转").First();
  2056. foreach (var item in DailyFeePaymentData)
  2057. {
  2058. if (_dailyIds != null)
  2059. {
  2060. item.IsChecked = _dailyIds.Contains(item.Id);
  2061. }
  2062. if (dic_setData.ContainsKey(item.PriceTypeId))
  2063. {
  2064. item.priceTypeStr = dic_setData[item.PriceTypeId];
  2065. }
  2066. else
  2067. {
  2068. Sys_SetData sd_priceType = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceTypeId).First();
  2069. if (sd_priceType != null)
  2070. {
  2071. item.priceTypeStr = sd_priceType.Name;
  2072. dic_setData.Add(item.PriceTypeId, sd_priceType.Name);
  2073. }
  2074. }
  2075. if (dic_setData.ContainsKey(item.transferTypeId))
  2076. {
  2077. item.transferTypeIdStr = dic_setData[item.transferTypeId];
  2078. Sys_SetData sd_transfer = _daiRep.Query<Sys_SetData>(s => s.Id == item.transferTypeId).First();
  2079. if (sd_transfer != null)
  2080. {
  2081. item.transferParentId = sd_transfer.STid;
  2082. item.transferParentIdStr = sd_transfer.STid == stGZ.Id ? "公转" : sd_transfer.STid == stSZ.Id ? "私转" : "";
  2083. }
  2084. }
  2085. else
  2086. {
  2087. Sys_SetData sd_transfer = _daiRep.Query<Sys_SetData>(s => s.Id == item.transferTypeId).First();
  2088. if (sd_transfer != null)
  2089. {
  2090. item.transferTypeIdStr = sd_transfer.Name;
  2091. item.transferParentId = sd_transfer.STid;
  2092. item.transferParentIdStr = sd_transfer.STid == stGZ.Id ? "公转" : sd_transfer.STid == stSZ.Id ? "私转" : "";
  2093. dic_setData.Add(item.transferTypeId, sd_transfer.Name);
  2094. }
  2095. }
  2096. string feeContentSql = string.Format(@"Select * From Fin_DailyFeePaymentContent
  2097. Where IsDel=0 And DFPId = {0} ", item.Id);
  2098. item.childList = _sqlSugar.SqlQueryable<Fin_DailyFeePaymentContentInfolView>(feeContentSql).ToList();
  2099. int rowNumber = 1;
  2100. foreach (var subItem in item.childList)
  2101. {
  2102. string remaksDescription = $"{rowNumber}、【{item.priceTypeStr}】{item.Instructions}({subItem.PriceName}) CNY:{subItem.ItemTotal.ToString("#0.00")}(单价:{subItem.Price.ToString("#0.00")} * {subItem.Quantity})";
  2103. subItem.RemaksDescription = remaksDescription;
  2104. string excelRemaksDescription = $"【{item.priceTypeStr}】{item.Instructions}({subItem.PriceName}) CNY:{subItem.ItemTotal.ToString("#0.00")}(单价:{subItem.Price.ToString("#0.00")} * {subItem.Quantity})【申请人:{item.CreateUser} 申请时间:{item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")}】";
  2105. subItem.ExcelRemaksDescription = excelRemaksDescription;
  2106. rowNumber++;
  2107. }
  2108. }
  2109. decimal total_gz = DailyFeePaymentData.Where(s => s.transferParentId == stGZ.Id).Sum(d => d.SumPrice ?? 0M);
  2110. decimal total_sz = DailyFeePaymentData.Where(s => s.transferParentId == stSZ.Id).Sum(d => d.SumPrice ?? 0M);
  2111. var result = new tree_Fin_DailyFeePaymentResult() { gz = total_gz, sz = total_sz, dataList = DailyFeePaymentData };
  2112. return result;
  2113. }
  2114. /// <summary>
  2115. /// 付款申请 (PageId=51)
  2116. /// 团组,日付相关费用 选中状态变更
  2117. /// </summary>
  2118. /// <param name="dto"></param>
  2119. /// <returns></returns>
  2120. [HttpPost]
  2121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2122. public async Task<IActionResult> PostPayRequestCheckedChange(PayRequestCheckedChangeDto dto)
  2123. {
  2124. #region 验证
  2125. if (dto.Type < 1 || dto.Type > 2)
  2126. {
  2127. return Ok(JsonView(false, "请传入有效的Type参数! 1 checked 2 清除上次勾选"));
  2128. }
  2129. #endregion
  2130. try
  2131. {
  2132. PaymentRequestCheckedView requestCheckedView = new PaymentRequestCheckedView();
  2133. List<int> groupIds = new List<int>();
  2134. List<int> dailyPaymentIds = new List<int>();
  2135. #region 参数处理
  2136. if (!string.IsNullOrEmpty(dto.GroupIds))
  2137. {
  2138. if (dto.GroupIds.Contains(","))
  2139. {
  2140. groupIds = dto.GroupIds.Split(',').Select(int.Parse).ToList();
  2141. }
  2142. else
  2143. {
  2144. groupIds.Add(int.Parse(dto.GroupIds));
  2145. }
  2146. }
  2147. if (!string.IsNullOrEmpty(dto.DailyPaymentIds))
  2148. {
  2149. if (dto.DailyPaymentIds.Contains(","))
  2150. {
  2151. dailyPaymentIds = dto.DailyPaymentIds.Split(',').Select(int.Parse).ToList();
  2152. }
  2153. else
  2154. {
  2155. dailyPaymentIds.Add(int.Parse(dto.DailyPaymentIds));
  2156. }
  2157. }
  2158. #endregion
  2159. requestCheckedView.GroupIds = groupIds;
  2160. requestCheckedView.DailyPaymentIds = dailyPaymentIds;
  2161. if (dto.Type == 1)
  2162. {
  2163. TimeSpan ts = DateTime.Now.AddDays(180) - DateTime.Now; //设置redis 过期时间 半年(180)
  2164. var status = await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("paymentRequestCheckedData", JsonConvert.SerializeObject(requestCheckedView), ts);
  2165. if (status)
  2166. {
  2167. return Ok(JsonView(true, "操作成功!"));
  2168. }
  2169. }
  2170. else if (dto.Type == 2)
  2171. {
  2172. var status = await RedisRepository.RedisFactory.CreateRedisRepository().KeyDeleteAsync("paymentRequestCheckedData");
  2173. if (status)
  2174. {
  2175. return Ok(JsonView(true, "操作成功!"));
  2176. }
  2177. }
  2178. return Ok(JsonView(false, "操作失败!"));
  2179. }
  2180. catch (Exception ex)
  2181. {
  2182. return Ok(JsonView(false, ex.Message));
  2183. }
  2184. }
  2185. /// <summary>
  2186. /// 付款申请 (PageId=51)
  2187. /// 团组,日付相关费用 汇率变更
  2188. /// </summary>
  2189. /// <param name="dto"></param>
  2190. /// <returns></returns>
  2191. [HttpPost]
  2192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2193. public async Task<IActionResult> PostPayRequestRateChange(PayRequestRateChangeDto dto)
  2194. {
  2195. #region 验证
  2196. DateTime beginDt, endDt;
  2197. string format = "yyyy-MM-dd";
  2198. if (!DateTime.TryParseExact(dto.beginDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out beginDt))
  2199. {
  2200. return Ok(JsonView(false, "开始日期格式不正确!正确格式:yyyy-MM-dd"));
  2201. }
  2202. if (!DateTime.TryParseExact(dto.endDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out endDt))
  2203. {
  2204. return Ok(JsonView(false, "结束日期格式不正确!正确格式:yyyy-MM-dd"));
  2205. }
  2206. if (dto.UserId < 1)
  2207. {
  2208. return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2209. }
  2210. if (dto.Id < 1)
  2211. {
  2212. return Ok(JsonView(false, "请传入有效的Id参数!"));
  2213. }
  2214. if (dto.Rate <= 0)
  2215. {
  2216. return Ok(JsonView(false, "请传入有效的Rate参数!"));
  2217. }
  2218. #endregion
  2219. try
  2220. {
  2221. var status = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2222. .SetColumns(it => it.DayRate == dto.Rate)
  2223. .Where(it => it.Id == dto.Id)
  2224. .ExecuteCommand();
  2225. if (status > 0)
  2226. {
  2227. PaymentRequestCheckedView checkedView = new PaymentRequestCheckedView();
  2228. var checkedStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("paymentRequestCheckedData");
  2229. if (checkedStr != null)
  2230. {
  2231. checkedView = JsonConvert.DeserializeObject<PaymentRequestCheckedView>(checkedStr.ToString());
  2232. }
  2233. tree_Fin_DailyFeePaymentResult dailyResult = PayRequest_DailyByDateRange(1, checkedView.DailyPaymentIds, dto.beginDt, dto.endDt);
  2234. tree_Group_DailyFeePaymentResult groupResult = PayRequest_GroupPaymentByDateRange(1, checkedView.GroupIds, dto.beginDt, dto.endDt);
  2235. decimal _gz = dailyResult.gz + groupResult.gz;
  2236. decimal _sz = dailyResult.sz + groupResult.sz;
  2237. return Ok(JsonView(true, "操作成功!", new { gz = dailyResult, sz = groupResult }));
  2238. }
  2239. return Ok(JsonView(false, "该项汇率修改失败!"));
  2240. }
  2241. catch (Exception ex)
  2242. {
  2243. return Ok(JsonView(false, ex.Message));
  2244. }
  2245. }
  2246. /// <summary>
  2247. /// 付款申请 (PageId=51)
  2248. /// 团组,日付相关费用 付款状态变更
  2249. /// </summary>
  2250. /// <param name="dto"></param>
  2251. /// <returns></returns>
  2252. [HttpPost]
  2253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2254. public async Task<IActionResult> PostPayRequestPayChange(PayRequestPayChangeDto dto)
  2255. {
  2256. if (dto.UserId < 1)
  2257. {
  2258. return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2259. }
  2260. //if (string.IsNullOrEmpty(dto.GroupIds))
  2261. //{
  2262. // return Ok(JsonView(false, "请传入有效的GroupIds参数!"));
  2263. //}
  2264. //if (string.IsNullOrEmpty(dto.DailyPaymentIds))
  2265. //{
  2266. // return Ok(JsonView(false, "请传入有效的DailyPaymentIds参数!"));
  2267. //}
  2268. try
  2269. {
  2270. List<int> groupIds = new List<int>();
  2271. List<int> dailyPaymentIds = new List<int>();
  2272. #region 参数处理
  2273. if (!string.IsNullOrEmpty(dto.GroupIds))
  2274. {
  2275. if (dto.GroupIds.Contains(","))
  2276. {
  2277. groupIds = dto.GroupIds.Split(',').Select(int.Parse).ToList();
  2278. }
  2279. else
  2280. {
  2281. groupIds.Add(int.Parse(dto.GroupIds));
  2282. }
  2283. }
  2284. if (!string.IsNullOrEmpty(dto.DailyPaymentIds))
  2285. {
  2286. if (dto.DailyPaymentIds.Contains(","))
  2287. {
  2288. dailyPaymentIds = dto.DailyPaymentIds.Split(',').Select(int.Parse).ToList();
  2289. }
  2290. else
  2291. {
  2292. dailyPaymentIds.Add(int.Parse(dto.DailyPaymentIds));
  2293. }
  2294. }
  2295. #endregion
  2296. bool changeStatus = false;
  2297. _sqlSugar.BeginTran();
  2298. if (groupIds.Count > 0)
  2299. {
  2300. var groupStatus = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2301. .SetColumns(it => it.IsPay == 1)
  2302. .Where(it => groupIds.Contains(it.Id))
  2303. .ExecuteCommand();
  2304. if (groupStatus > 0)
  2305. {
  2306. changeStatus = true;
  2307. }
  2308. }
  2309. if (dailyPaymentIds.Count > 0)
  2310. {
  2311. var dailyPaymentStatus = _sqlSugar.Updateable<Fin_DailyFeePayment>()
  2312. .SetColumns(it => it.IsPay == 1)
  2313. .Where(it => dailyPaymentIds.Contains(it.Id))
  2314. .ExecuteCommand();
  2315. if (dailyPaymentStatus > 0)
  2316. {
  2317. changeStatus = true;
  2318. }
  2319. }
  2320. if (changeStatus)
  2321. {
  2322. _sqlSugar.CommitTran();
  2323. #region 应用推送
  2324. try
  2325. {
  2326. foreach (int ccpId in groupIds)
  2327. {
  2328. List<string> tempList = new List<string>() { ccpId.ToString() };
  2329. await AppNoticeLibrary.SendUserMsg_GroupStatus_PayResult(ccpId, tempList);
  2330. }
  2331. foreach (int dailyId in dailyPaymentIds)
  2332. {
  2333. List<string> tempList = new List<string>() { dailyId.ToString() };
  2334. await AppNoticeLibrary.DailyPayReminder_Pay_ToUser(dailyId, tempList);
  2335. }
  2336. }
  2337. catch (Exception ex)
  2338. {
  2339. }
  2340. #endregion
  2341. return Ok(JsonView(true, "操作成功!"));
  2342. }
  2343. _sqlSugar.RollbackTran();
  2344. return Ok(JsonView(false, "付款状态修改失败!"));
  2345. }
  2346. catch (Exception ex)
  2347. {
  2348. _sqlSugar.RollbackTran();
  2349. return Ok(JsonView(false, ex.Message));
  2350. }
  2351. }
  2352. /// <summary>
  2353. /// 付款申请 (PageId=51)
  2354. /// File Download
  2355. /// </summary>
  2356. /// <param name="dto"></param>
  2357. /// <returns></returns>
  2358. [HttpPost]
  2359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2360. public async Task<IActionResult> PostPayRequestFileDownload(PayRequestFileDownloadDto dto)
  2361. {
  2362. Stopwatch stopwatch = Stopwatch.StartNew();
  2363. #region 参数,权限 验证
  2364. if (dto.PortType < 1)
  2365. {
  2366. return Ok(JsonView(false, "请传入有效的PortType参数!"));
  2367. }
  2368. if (dto.UserId < 1)
  2369. {
  2370. return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2371. }
  2372. if (dto.PageId < 1)
  2373. {
  2374. dto.PageId = 51;
  2375. return Ok(JsonView(false, "请传入有效的PageId参数!"));
  2376. }
  2377. if (dto.ConpanyId < 1 || dto.ConpanyId > 4)
  2378. {
  2379. return Ok(JsonView(false, "请传入有效的ConpanyId参数!"));
  2380. }
  2381. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2382. #region 页面操作权限验证
  2383. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  2384. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  2385. #endregion
  2386. #endregion
  2387. try
  2388. {
  2389. PaymentRequestCheckedView checkedView = new PaymentRequestCheckedView();
  2390. var checkedStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("paymentRequestCheckedData");
  2391. if (checkedStr != null)
  2392. {
  2393. checkedView = JsonConvert.DeserializeObject<PaymentRequestCheckedView>(checkedStr.ToString());
  2394. }
  2395. if (checkedView == null)
  2396. {
  2397. return Ok(JsonView(false, "没有选中的数据!"));
  2398. }
  2399. if (checkedView.GroupIds == null && checkedView.DailyPaymentIds == null)
  2400. {
  2401. return Ok(JsonView(false, "没有选中的数据!"));
  2402. }
  2403. tree_Fin_DailyFeePaymentResult dailyResult = PayRequest_DailyByDateRange(2, checkedView.DailyPaymentIds, dto.beginDt, dto.endDt);
  2404. tree_Group_DailyFeePaymentResult groupResult = PayRequest_GroupPaymentByDateRange(2, checkedView.GroupIds, dto.beginDt, dto.endDt);
  2405. if (dailyResult.childList == null)
  2406. {
  2407. dailyResult.childList = new List<Fin_DailyFeePaymentContentInfolView>();
  2408. }
  2409. List<tree_Group_DailyFeePaymentPageListView> _GroupData = new List<tree_Group_DailyFeePaymentPageListView>();
  2410. List<tree_Fin_DailyFeePaymentPageListView> _DailyData = new List<tree_Fin_DailyFeePaymentPageListView>();
  2411. //1 成都泛美商务有限公司
  2412. if (dto.ConpanyId == 1)
  2413. {
  2414. if (groupResult.dataList != null && groupResult.dataList.Count > 0) _GroupData = groupResult.dataList.Where(it => it.CompanyId == 1).ToList();
  2415. if (dailyResult.dataList != null && dailyResult.dataList.Count > 0) _DailyData = dailyResult.dataList.Where(it => it.CompanyId == 1).ToList();
  2416. }
  2417. //2 四川泛美交流有限公司
  2418. else if (dto.ConpanyId == 2)
  2419. {
  2420. if (groupResult.dataList != null && groupResult.dataList.Count > 0) _GroupData = groupResult.dataList.Where(it => it.CompanyId == 2).ToList();
  2421. if (dailyResult.dataList != null && dailyResult.dataList.Count > 0) _DailyData = dailyResult.dataList.Where(it => it.CompanyId == 2).ToList();
  2422. }
  2423. //3 成都纽茵教育科技有限公司
  2424. else if (dto.ConpanyId == 3)
  2425. {
  2426. if (groupResult.dataList != null && groupResult.dataList.Count > 0) _GroupData = groupResult.dataList.Where(it => it.CompanyId == 3).ToList();
  2427. if (dailyResult.dataList != null && dailyResult.dataList.Count > 0) _DailyData = dailyResult.dataList.Where(it => it.CompanyId == 3).ToList();
  2428. }
  2429. //4 成都鸿企中元科技有限公司
  2430. else if (dto.ConpanyId == 4)
  2431. {
  2432. return Ok(JsonView(false, "暂未开放该类型!"));
  2433. }
  2434. else
  2435. {
  2436. return Ok(JsonView(false, "参数ConpanyId不可使用!"));
  2437. }
  2438. string _requestPaymentDt = DateTime.Now.ToString("yyyy-MM-dd"),//申请付款日期
  2439. _appliedAmount = "", //申请付款金额
  2440. _GZStr = "", //公转价格描述
  2441. _SZStr = ""; //私转价格描述
  2442. decimal groupGZAmout = 0.00M, groupSZAmout = 0.00M;
  2443. decimal dailyGZAmout = 0.00M, dailySZAmout = 0.00M;
  2444. string dailyGZStr = "", dailySZStr = "", groupGZStr = "", groupSZStr = "";
  2445. #region 数据处理
  2446. //团组费用相关
  2447. foreach (var item in _GroupData)
  2448. {
  2449. string groupGZSubStr = "";
  2450. string groupSZSubStr = "";
  2451. foreach (var subItem in item.ChildList)
  2452. {
  2453. if (subItem.TransferMark.Equals("公转"))
  2454. {
  2455. groupGZAmout += subItem.CNYSubTotalAmount;
  2456. groupGZSubStr += $"{subItem.RemaksDescription}\r\n";
  2457. }
  2458. else if (subItem.TransferMark.Equals("私转"))
  2459. {
  2460. groupSZAmout += subItem.CNYSubTotalAmount;
  2461. groupSZSubStr += $"{subItem.RemaksDescription}\r\n";
  2462. }
  2463. //groupGZSubStr += $"\t";
  2464. }
  2465. //if (!string.IsNullOrEmpty(groupGZSubStr)) groupGZStr += $"团组:{item.GroupName}\r\n{groupGZSubStr}\r\n";
  2466. //if (!string.IsNullOrEmpty(groupSZSubStr)) groupSZStr += $"团组:{item.GroupName}\r\n{groupSZSubStr}\r\n";
  2467. if (!string.IsNullOrEmpty(groupGZSubStr)) groupGZStr += $"{groupGZSubStr}\r\n";
  2468. if (!string.IsNullOrEmpty(groupSZSubStr)) groupSZStr += $"{groupSZSubStr}\r\n";
  2469. }
  2470. //日常费用相关
  2471. foreach (var item in _DailyData)
  2472. {
  2473. foreach (var subItem in item.childList)
  2474. {
  2475. if (item.transferParentId == 62) //公转
  2476. {
  2477. dailyGZAmout += item.SumPrice ?? 0.00M;
  2478. dailyGZStr += $"{item.RowNumber}、【{item.CompanyName}】{subItem.ExcelRemaksDescription}\r\n";
  2479. }
  2480. else if (item.transferParentId == 63) //私转
  2481. {
  2482. dailySZAmout += item.SumPrice ?? 0.00M;
  2483. dailySZStr += $"{item.RowNumber}、【{item.CompanyName}】{subItem.ExcelRemaksDescription}\r\n";
  2484. }
  2485. }
  2486. }
  2487. _GZStr = $"【公转】团组相关费用(合计:CNY {groupGZAmout.ToString("#0.00")}):\r\n{groupGZStr}【公转】日常付款费用(合计:CNY {dailyGZAmout.ToString("#0.00")}):\r\n{dailyGZStr}";
  2488. _SZStr = $"【私转】团组相关费用(合计:CNY {groupSZAmout.ToString("#0.00")}):\r\n{groupSZStr}【私转】日常付款费用(合计:CNY {dailySZAmout.ToString("#0.00")}):\r\n{dailySZStr}";
  2489. _appliedAmount = $"公转:CNY {(groupGZAmout + dailyGZAmout).ToString("#0.00")}\r\n私转:CNY {(groupSZAmout + dailySZAmout).ToString("#0.00")}";
  2490. #endregion
  2491. WorkbookDesigner designer = new WorkbookDesigner();
  2492. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/付款申请书.xls");
  2493. designer.SetDataSource("Date", _requestPaymentDt);
  2494. designer.SetDataSource("Price", _appliedAmount);
  2495. designer.SetDataSource("Content", _GZStr);
  2496. designer.SetDataSource("Content1", _SZStr);
  2497. //根据数据源处理生成报表内容
  2498. designer.Process();
  2499. string fileName = ("PayRequest/付款申请(" + dto.beginDt + "~" + dto.endDt + ").xlsx");
  2500. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2501. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2502. stopwatch.Stop();
  2503. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds / 1000}s", new { url = rst }));
  2504. }
  2505. catch (Exception ex)
  2506. {
  2507. return Ok(JsonView(false, ex.Message));
  2508. }
  2509. }
  2510. #endregion
  2511. #region 超支费用
  2512. /// <summary>
  2513. /// 超支费用
  2514. /// 1增、2改、3删
  2515. /// </summary>
  2516. /// <param name="dto"></param>
  2517. /// <returns></returns>
  2518. [HttpPost]
  2519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2520. public async Task<IActionResult> PostGroupExtraCost_Operator(Fin_GroupExtraCostDto_OP dto)
  2521. {
  2522. #region 验证
  2523. #endregion
  2524. Fin_GroupExtraCost _entity = new Fin_GroupExtraCost();
  2525. _entity.DiId = dto.diId;
  2526. _entity.PriceName = dto.priceName;
  2527. _entity.Price = dto.price;
  2528. _entity.PriceCurrency = dto.currency;
  2529. _entity.PriceType = dto.priceType;
  2530. _entity.Coefficient = dto.coefficient;
  2531. _entity.PriceDetailType = dto.priceDetailType;
  2532. _entity.FilePath = dto.filePath;
  2533. _entity.Remark = dto.remark;
  2534. _entity.PriceCount = dto.PriceCount;
  2535. DateTime dt_PriceDt;
  2536. bool b_PriceDt = DateTime.TryParse(dto.PriceDt, out dt_PriceDt);
  2537. if (b_PriceDt)
  2538. {
  2539. _entity.PriceDt = dt_PriceDt;
  2540. }
  2541. else
  2542. {
  2543. _entity.PriceDt = DateTime.MinValue;
  2544. }
  2545. _entity.PriceSum = dto.price * dto.PriceCount;
  2546. _daiRep.BeginTran();
  2547. if (dto.editType == 1)
  2548. {
  2549. _entity.CreateUserId = dto.createUser;
  2550. _entity.CreateTime = DateTime.Now;
  2551. _entity.IsDel = 0;
  2552. int returnId = await _daiRep.AddAsyncReturnId<Fin_GroupExtraCost>(_entity);
  2553. if (returnId > 0)
  2554. {
  2555. dto.Id = returnId;
  2556. }
  2557. }
  2558. else if (dto.editType == 2)
  2559. {
  2560. bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
  2561. {
  2562. PriceName = dto.priceName,
  2563. Price = dto.price,
  2564. PriceCurrency = dto.currency,
  2565. PriceType = dto.priceType,
  2566. PriceDetailType = dto.priceDetailType,
  2567. Coefficient = dto.coefficient,
  2568. FilePath = dto.filePath,
  2569. Remark = dto.remark,
  2570. PriceCount = dto.PriceCount,
  2571. PriceDt = _entity.PriceDt,
  2572. PriceSum = _entity.PriceSum
  2573. });
  2574. if (!res)
  2575. {
  2576. _daiRep.RollbackTran();
  2577. return Ok(JsonView(false, "2操作失败!"));
  2578. }
  2579. }
  2580. else if (dto.editType == 3)
  2581. {
  2582. string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
  2583. bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
  2584. {
  2585. IsDel = 1,
  2586. DeleteTime = delTime,
  2587. DeleteUserId = dto.createUser
  2588. });
  2589. if (!res)
  2590. {
  2591. _daiRep.RollbackTran();
  2592. return Ok(JsonView(false, "3操作失败!"));
  2593. }
  2594. }
  2595. else
  2596. {
  2597. _daiRep.RollbackTran();
  2598. return Ok(JsonView(false, "未知的editType"));
  2599. }
  2600. if (!extraCost_editCreditCardPayment(dto))
  2601. {
  2602. return Ok(JsonView(false, "ccp操作失败"));
  2603. }
  2604. _daiRep.CommitTran();
  2605. return Ok(JsonView(true, "操作成功"));
  2606. }
  2607. private Result PostCurrencyByDiid_Sync(int diId, int CId, int currencyId)
  2608. {
  2609. if (diId == 0)
  2610. {
  2611. return new Result() { Code = -1, Msg = "请传入团组Id!" };
  2612. }
  2613. if (CId == 0)
  2614. {
  2615. return new Result() { Code = -1, Msg = "请传入类型Id!" };
  2616. }
  2617. if (currencyId == 0)
  2618. {
  2619. return new Result() { Code = -1, Msg = "请传入币种Id!" };
  2620. }
  2621. Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == diId && a.IsDel == 0 && a.CTable == CId);
  2622. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
  2623. CurrencyInfo CurrencyRate = new CurrencyInfo();
  2624. try
  2625. {
  2626. if (_TeamRate != null)
  2627. {
  2628. Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == currencyId);
  2629. if (_SetData != null)
  2630. {
  2631. currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
  2632. CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
  2633. if (CurrencyRate != null)
  2634. {
  2635. return new Result() { Code = 0, Msg = "查询成功!", Data = CurrencyRate };
  2636. }
  2637. else
  2638. {
  2639. return new Result() { Code = -1, Msg = "暂无团组汇率,请前往设置!", Data = CurrencyRate };
  2640. }
  2641. }
  2642. else
  2643. {
  2644. return new Result() { Code = -1, Msg = "暂无团组汇率,请前往设置!", Data = CurrencyRate };
  2645. }
  2646. }
  2647. else
  2648. {
  2649. return new Result() { Code = -1, Msg = "暂无团组汇率,请前往设置!", Data = CurrencyRate };
  2650. }
  2651. }
  2652. catch (Exception)
  2653. {
  2654. return new Result() { Code = -1, Msg = "查询异常!", Data = CurrencyRate };
  2655. }
  2656. }
  2657. private bool extraCost_editCreditCardPayment(Fin_GroupExtraCostDto_OP costDto)
  2658. {
  2659. //设置团组汇率
  2660. decimal dcm_dayrate = 1M;
  2661. decimal dcm_rmbPrice = costDto.price;
  2662. int ispay = costDto.payType == 72 ? 1 : 0;
  2663. if (costDto.costSign != 3)
  2664. {
  2665. //获取新汇率 int diId,int CId, int currencyId
  2666. Result rate = this.PostCurrencyByDiid_Sync(costDto.diId, 1015, costDto.currency);
  2667. if (rate.Code == 0)
  2668. {
  2669. var rateInfo = (rate.Data as CurrencyInfo);
  2670. if (rateInfo is not null)
  2671. {
  2672. dcm_dayrate = rateInfo.Rate;
  2673. dcm_rmbPrice = rateInfo.Rate * dcm_rmbPrice;
  2674. }
  2675. else
  2676. {
  2677. dcm_dayrate = 1;
  2678. }
  2679. }
  2680. }
  2681. Grp_CreditCardPayment ccp = _daiRep.Query<Grp_CreditCardPayment>(s => s.CId == costDto.Id && s.CTable == 1015).First();
  2682. if (ccp == null)
  2683. {
  2684. ccp = new Grp_CreditCardPayment();
  2685. ccp.PayDId = costDto.payType;// dto
  2686. ccp.ConsumptionPatterns = "";
  2687. ccp.ConsumptionDate = "";
  2688. ccp.CTDId = costDto.payCardId;// dto
  2689. ccp.BankNo = "";
  2690. ccp.CardholderName = "";
  2691. ccp.PayMoney = costDto.price;// dto
  2692. ccp.PaymentCurrency = costDto.currency;// dto
  2693. ccp.CompanyBankNo = "";
  2694. ccp.OtherBankName = "";
  2695. ccp.OtherSideNo = "";
  2696. ccp.OtherSideName = "";
  2697. ccp.Remark = "";
  2698. ccp.CreateUserId = costDto.createUser;
  2699. ccp.CreateTime = DateTime.Now;
  2700. ccp.MFOperator = 0;
  2701. ccp.MFOperatorDate = "";
  2702. ccp.IsAuditDM = 0;
  2703. ccp.AuditDMOperate = 0;
  2704. ccp.AuditDMDate = "";
  2705. ccp.IsAuditMF = 0;
  2706. ccp.AuditMFOperate = 0;
  2707. ccp.AuditMFDate = "";
  2708. ccp.IsAuditGM = 0;
  2709. ccp.AuditGMOperate = 0;
  2710. ccp.AuditGMDate = "";
  2711. ccp.IsPay = ispay; // upd
  2712. ccp.DIId = costDto.diId;// dto
  2713. ccp.CId = costDto.Id;// dto
  2714. ccp.CTable = 1015; //超支费用指向id
  2715. ccp.IsDel = 0;
  2716. ccp.PayPercentage = 100M;
  2717. ccp.PayThenMoney = 0M;
  2718. ccp.PayPercentageOld = 100M;
  2719. ccp.PayThenMoneyOld = 0M;
  2720. ccp.UpdateDate = "";
  2721. ccp.Payee = costDto.payee;// dto
  2722. ccp.OrbitalPrivateTransfer = costDto.costSign;// dto
  2723. ccp.ExceedBudget = 0;
  2724. ccp.DayRate = dcm_dayrate; //upd
  2725. ccp.RMBPrice = dcm_rmbPrice; //upd
  2726. int ccpInsertId = _daiRep.AddReturnId<Grp_CreditCardPayment>(ccp);
  2727. if (ccpInsertId > 0)
  2728. {
  2729. return true;
  2730. }
  2731. }
  2732. else
  2733. {
  2734. if (costDto.editType == 2)
  2735. {
  2736. bool res = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
  2737. {
  2738. PayDId = costDto.payType,
  2739. CTDId = costDto.payCardId,
  2740. PayMoney = costDto.price,
  2741. PaymentCurrency = costDto.currency,
  2742. IsPay = ispay,
  2743. Payee = costDto.payee,
  2744. OrbitalPrivateTransfer = costDto.costSign,
  2745. DayRate = dcm_dayrate,
  2746. RMBPrice = dcm_rmbPrice
  2747. });
  2748. return res;
  2749. }
  2750. else if (costDto.editType == 3)
  2751. {
  2752. string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
  2753. bool res2 = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
  2754. {
  2755. IsDel = 1,
  2756. DeleteTime = delTime,
  2757. DeleteUserId = costDto.createUser
  2758. });
  2759. return res2;
  2760. }
  2761. }
  2762. return false;
  2763. }
  2764. /// <summary>
  2765. /// 超支费用
  2766. /// 详情查询
  2767. /// </summary>
  2768. /// <param name="dto"></param>
  2769. /// <returns></returns>
  2770. [HttpPost]
  2771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2772. public async Task<IActionResult> PostGroupExtraCost_Detail(Fin_GroupExtraCostDto_Detail dto)
  2773. {
  2774. if (dto.Id < 1)
  2775. {
  2776. return Ok(JsonView(false, "查询失败"));
  2777. }
  2778. string sql = string.Format(@" Select
  2779. f.Id,f.DiId,
  2780. f.PriceName,f.Price,f.PriceCurrency,c.Payee,c.OrbitalPrivateTransfer,c.PayDId,
  2781. c.CTDId,f.PriceType,f.PriceDetailType,f.Coefficient,f.Remark,f.PriceCount,f.PriceDt
  2782. From Fin_GroupExtraCost f
  2783. Inner Join Grp_CreditCardPayment c On f.Id = c.CId
  2784. Left Join Sys_Users u On f.CreateUserId = u.Id
  2785. Where f.IsDel=0 And c.CTable = 1015
  2786. And f.Id = {0} ", dto.Id);
  2787. Fin_GroupExtraCostDetailView detailView = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostDetailView>(sql).FirstAsync();
  2788. if (detailView == null)
  2789. {
  2790. return Ok(JsonView(false, "查询失败"));
  2791. }
  2792. return Ok(JsonView(true, "查询成功", detailView));
  2793. }
  2794. /// <summary>
  2795. /// 超支费用
  2796. /// 列表查询
  2797. /// </summary>
  2798. /// <param name="dto"></param>
  2799. /// <returns></returns>
  2800. [HttpPost]
  2801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2802. public async Task<IActionResult> PostGroupExtraCost_Search(Fin_GroupExtraCostDto_Search dto)
  2803. {
  2804. string sqlWhere = string.Format(@" And f.DiId = {0} ", dto.diId);
  2805. int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
  2806. int endIndex = startIndex + dto.PageSize - 1;
  2807. string sql_data = string.Format(@"Select * From (
  2808. Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
  2809. f.PriceName,f.PriceType,f.PriceDetailType,CAST(f.Price as varchar)+' '+s.[Name] as PriceStr,f.PriceCount,CAST(f.PriceSum as varchar)+' '+s.[Name] as PriceSumStr,
  2810. f.CreateUserId,f.PriceDt,c.IsAuditGM
  2811. From Fin_GroupExtraCost f
  2812. Inner Join Grp_CreditCardPayment c On f.Id = c.CId
  2813. Inner Join Sys_SetData s On f.PriceCurrency = s.Id
  2814. Left Join Sys_Users u On f.CreateUserId = u.Id
  2815. Where f.IsDel=0 And c.CTable = 1015 {0}
  2816. ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
  2817. string sql_count = string.Format(@"Select Count(1) as DataCount From (
  2818. Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
  2819. f.PriceName,f.PriceType,f.Price,f.FilePath,f.CreateUserId,f.CreateTime,c.IsAuditGM
  2820. From Fin_GroupExtraCost f
  2821. Inner Join Grp_CreditCardPayment c On f.Id = c.CId
  2822. Inner Join Sys_SetData s On f.PriceCurrency = s.Id
  2823. Left Join Sys_Users u On f.CreateUserId = u.Id
  2824. Where f.IsDel=0 And c.CTable = 1015 {0}
  2825. ) temp ", sqlWhere);
  2826. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  2827. {
  2828. //Fin_DailyFeePaymentPageCount
  2829. var count = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostViewDataCount>(sql_count).FirstAsync();
  2830. List<Fin_GroupExtraCostView> dataList = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostView>(sql_data).ToListAsync();
  2831. Dictionary<int, string> dic_setData = new Dictionary<int, string>();
  2832. Dictionary<int, string> dic_user = new Dictionary<int, string>();
  2833. foreach (var item in dataList)
  2834. {
  2835. DateTime dtTemp_PriceDt;
  2836. bool b_ct = DateTime.TryParse(item.PriceDt, out dtTemp_PriceDt);
  2837. if (b_ct)
  2838. {
  2839. item.PriceDt = dtTemp_PriceDt.ToString("yyyy-MM-dd");
  2840. }
  2841. //费用类型
  2842. if (dic_setData.ContainsKey(item.PriceType))
  2843. {
  2844. item.PriceTypeStr = dic_setData[item.PriceType];
  2845. }
  2846. else
  2847. {
  2848. Sys_SetData sd_priceTypeDetail = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceType).First();
  2849. if (sd_priceTypeDetail != null)
  2850. {
  2851. string tempName = sd_priceTypeDetail.Name.Replace("n", "");
  2852. item.PriceTypeStr = tempName;
  2853. dic_setData.Add(item.PriceType, tempName);
  2854. }
  2855. }
  2856. if (item.PriceDetailType > 0)
  2857. {
  2858. if (dic_setData.ContainsKey(item.PriceDetailType))
  2859. {
  2860. item.PriceTypeStr = item.PriceTypeStr + " - " + dic_setData[item.PriceDetailType];
  2861. }
  2862. else
  2863. {
  2864. Sys_SetData sd_priceTypeDetail = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceDetailType).First();
  2865. if (sd_priceTypeDetail != null)
  2866. {
  2867. string tempName = sd_priceTypeDetail.Name.Replace("n", "");
  2868. item.PriceTypeStr = item.PriceTypeStr + " - " + tempName;
  2869. dic_setData.Add(item.PriceDetailType, tempName);
  2870. }
  2871. }
  2872. }
  2873. //系统用户
  2874. if (dic_user.ContainsKey(item.CreateUserId))
  2875. {
  2876. item.CreateUserIdStr = dic_user[item.CreateUserId];
  2877. }
  2878. else
  2879. {
  2880. Sys_Users users = _daiRep.Query<Sys_Users>(s => s.Id == item.CreateUserId).First();
  2881. if (users != null)
  2882. {
  2883. item.CreateUserIdStr = users.CnName;
  2884. dic_user.Add(item.CreateUserId, users.CnName);
  2885. }
  2886. }
  2887. switch (item.IsAuditGM)
  2888. {
  2889. case 0: item.IsAuditGMStr = "未审核"; break;
  2890. case 1: item.IsAuditGMStr = "已通过"; break;
  2891. case 2: item.IsAuditGMStr = "未通过"; break;
  2892. default: item.IsAuditGMStr = "未知状态"; break;
  2893. }
  2894. }
  2895. var result = new ListViewBase<Fin_GroupExtraCostView>
  2896. {
  2897. CurrPageIndex = dto.PageIndex,
  2898. CurrPageSize = dto.PageSize,
  2899. DataCount = count.DataCount,
  2900. DataList = dataList
  2901. };
  2902. return Ok(JsonView(true, "查询成功", result));
  2903. }
  2904. return Ok(JsonView(false, "查询失败"));
  2905. }
  2906. /// <summary>
  2907. /// 超支费用
  2908. /// 数据集合配置
  2909. /// </summary>
  2910. /// <param name="dto"></param>
  2911. /// <returns></returns>
  2912. [HttpPost]
  2913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2914. public async Task<IActionResult> PostGroupExtraCost_ListDataInit(Fin_GroupExtraCostDto_DataListInit dto)
  2915. {
  2916. //支付方式
  2917. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  2918. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  2919. //信用卡类型
  2920. List<Sys_SetData> Card = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  2921. List<SetDataInfoView> _Card = _mapper.Map<List<SetDataInfoView>>(Card);
  2922. //超支费用类型
  2923. List<Sys_SetData> PriceType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 79 && a.IsDel == 0).ToList();
  2924. List<SetDataInfoView> _PriceType = _mapper.Map<List<SetDataInfoView>>(PriceType);
  2925. //超支费用详细类型
  2926. List<Sys_SetData> PriceDetailType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 80 && a.IsDel == 0).ToList();
  2927. PriceDetailType.ForEach(a => { a.Name = a.Name.Replace("n", ""); });
  2928. List<SetDataInfoView> _PriceDetailType = _mapper.Map<List<SetDataInfoView>>(PriceDetailType);
  2929. var data = new
  2930. {
  2931. Payment = _Payment,
  2932. Card = _Card,
  2933. PriceType = _PriceType,
  2934. PriceDetailType = _PriceDetailType
  2935. };
  2936. return Ok(JsonView(true, "", data));
  2937. }
  2938. /// <summary>
  2939. /// 超支费用
  2940. /// 导出团组超支费用Excel
  2941. /// </summary>
  2942. /// <param name="dto"></param>
  2943. /// <returns></returns>
  2944. [HttpPost]
  2945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2946. public async Task<IActionResult> PostGroupExtraCost_OutputExcel(Fin_GroupExtraCostExcelDto dto)
  2947. {
  2948. string sqlGroup = string.Format(@" Select * From Grp_DelegationInfo WIth(Nolock) where Id = {0} ", dto.diId);
  2949. Grp_DelegationInfo grp_DelegationInfo = await _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sqlGroup).FirstAsync();
  2950. if (grp_DelegationInfo == null)
  2951. {
  2952. return Ok(JsonView(false, "导出失败,未查询到团组"));
  2953. }
  2954. Workbook workbook = new Workbook();
  2955. Worksheet sheet = workbook.Worksheets[0];
  2956. Cells cells = sheet.Cells;
  2957. //sheet.Protect(Aspose.Cells.ProtectionType.All, "123123", "");//保护工作表
  2958. //sheet.Protection.IsSelectingLockedCellsAllowed = true;//设置只能选择解锁单元格
  2959. //sheet.Protection.IsFormattingColumnsAllowed = true;//设置可以调整列
  2960. //sheet.Protection.IsFormattingRowsAllowed = true;//设置可以调整行
  2961. #region 数据源
  2962. string sqlData = string.Format(@" Select f.PriceType,REPLACE(s2.[Name],'超支费用','') as PriceTypeStr,'('+REPLACE(s3.[Name],'n','')+')' as PriceDetailTypeStr, PriceDt,PriceName,
  2963. Price,PriceCount,s.[Name] as Currency,PriceSum,f.Remark
  2964. From Fin_GroupExtraCost as f With(Nolock)
  2965. Inner Join Grp_CreditCardPayment as c With(Nolock) On f.Id = c.CId
  2966. Inner Join Sys_SetData as s With(Nolock) On f.PriceCurrency = s.Id
  2967. Inner Join Sys_SetData as s2 With(Nolock) On f.PriceType = s2.Id
  2968. Inner Join Sys_SetData as s3 With(Nolock) On f.PriceDetailType = s3.Id
  2969. Where f.DiId = {0} And f.IsDel=0 And c.CTable=1015
  2970. Order by PriceType ASC,PriceDt ASC ", dto.diId);
  2971. string sqlDataCount = string.Format(@" Select f.PriceType,COUNT(f.PriceType) as DataCount
  2972. From Fin_GroupExtraCost as f With(Nolock)
  2973. Inner Join Grp_CreditCardPayment as c With(Nolock) On f.Id = c.CId
  2974. Where f.DiId = {0} And f.IsDel=0 And c.CTable=1015
  2975. Group by PriceType ", dto.diId);
  2976. List<Fin_GroupExtraCost_ExcelView> dataList = await _sqlSugar.SqlQueryable<Fin_GroupExtraCost_ExcelView>(sqlData).ToListAsync();
  2977. List<Fin_GroupExtraCost_ExcelCountView> countList = await _sqlSugar.SqlQueryable<Fin_GroupExtraCost_ExcelCountView>(sqlDataCount).ToListAsync();
  2978. if (dataList.Count < 1 || countList.Count < 1)
  2979. {
  2980. return Ok(JsonView(false, "导出失败,未查询到数据"));
  2981. }
  2982. #endregion
  2983. #region 标题
  2984. string cellValue_Header = grp_DelegationInfo.TeamName;
  2985. //Aspose.Cells.Style style1 = workbook.Styles[workbook.Styles.Add()];//新增样式
  2986. Aspose.Cells.Style style_Header = workbook.CreateStyle();
  2987. style_Header.HorizontalAlignment = TextAlignmentType.Center;//文字居中
  2988. style_Header.VerticalAlignment = TextAlignmentType.Center;
  2989. style_Header.Font.Name = "微软雅黑";//文字字体
  2990. style_Header.Font.Size = 18;//文字大小
  2991. style_Header.IsLocked = false;//单元格解锁
  2992. style_Header.Font.IsBold = false;//粗体
  2993. style_Header.Font.Color = Color.FromArgb(255, 0, 0);
  2994. //style1.ForegroundColor = Color.FromArgb(0x99, 0xcc, 0xff);//设置背景色
  2995. //style1.Pattern = BackgroundType.Solid; //设置背景样式
  2996. //style1.IsTextWrapped = true;//单元格内容自动换行
  2997. style_Header.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //应用边界线 左边界线
  2998. style_Header.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Thin; //应用边界线 右边界线
  2999. style_Header.Borders[Aspose.Cells.BorderType.TopBorder].LineStyle = CellBorderType.Thin; //应用边界线 上边界线
  3000. style_Header.Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //应用边界线 下边界线
  3001. cells.Merge(1, 1, 1, 10);
  3002. Aspose.Cells.Range range_header = cells.CreateRange(1, 1, 1, 10);
  3003. range_header.PutValue(cellValue_Header, false, false);
  3004. range_header.SetStyle(style_Header);
  3005. cells.SetRowHeight(1, 35);
  3006. #endregion
  3007. #region 列名
  3008. Aspose.Cells.Style style_colName = workbook.CreateStyle();
  3009. style_colName.Name = "colName";
  3010. style_colName.HorizontalAlignment = TextAlignmentType.Center;//文字居中
  3011. style_colName.VerticalAlignment = TextAlignmentType.Center;
  3012. style_colName.Font.Name = "微软雅黑";//文字字体
  3013. style_colName.Font.Size = 12;//文字大小
  3014. style_colName.IsLocked = false;//单元格解锁
  3015. style_colName.Font.IsBold = true;//粗体
  3016. style_colName.Font.Color = Color.FromArgb(0, 0, 0);
  3017. style_colName.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //应用边界线 左边界线
  3018. style_colName.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Thin; //应用边界线 右边界线
  3019. style_colName.Borders[Aspose.Cells.BorderType.TopBorder].LineStyle = CellBorderType.Thin; //应用边界线 上边界线
  3020. style_colName.Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //应用边界线 下边界线
  3021. List<Fin_GroupExtraCostExcelColumnSetting> colNameSettingList = new List<Fin_GroupExtraCostExcelColumnSetting>()
  3022. {
  3023. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 1, columnName="类型", columnWidth= 25},
  3024. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 2, columnName="时间", columnWidth= 16},
  3025. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 3, columnName="内容", columnWidth= 35},
  3026. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 4, columnName="单价", columnWidth= 12},
  3027. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 5, columnName="数量", columnWidth= 12},
  3028. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 6, columnName="货币", columnWidth= 12},
  3029. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 7, columnName="费用", columnWidth= 12},
  3030. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 8, columnName="汇率", columnWidth= 12},
  3031. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 9, columnName="人民币", columnWidth= 12},
  3032. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 10, columnName="备注信息", columnWidth= 24}
  3033. };
  3034. foreach (var col in colNameSettingList)
  3035. {
  3036. cells[2, col.columnIndex].PutValue(col.columnName);
  3037. cells[2, col.columnIndex].SetStyle(style_colName);
  3038. cells.SetColumnWidth(col.columnIndex, col.columnWidth);
  3039. }
  3040. cells.SetRowHeight(2, 25);
  3041. #endregion
  3042. #region 数据填充
  3043. Aspose.Cells.Style style_dataCol = workbook.GetNamedStyle("colName");
  3044. style_dataCol.Font.IsBold = false;
  3045. style_dataCol.Name = "dataCol";
  3046. Aspose.Cells.Style style_dataBlue = workbook.CreateStyle();
  3047. style_dataBlue.HorizontalAlignment = TextAlignmentType.Center;//文字居中
  3048. style_dataBlue.VerticalAlignment = TextAlignmentType.Center;
  3049. style_dataBlue.Font.Name = "微软雅黑";//文字字体
  3050. style_dataBlue.Font.Size = 12;//文字大小
  3051. style_dataBlue.IsLocked = false;//单元格解锁
  3052. style_dataBlue.Font.IsBold = false;//粗体
  3053. style_dataBlue.ForegroundColor = Color.FromArgb(189, 215, 238);
  3054. style_dataBlue.Pattern = BackgroundType.Solid;
  3055. style_dataBlue.Font.Color = Color.FromArgb(0, 0, 0);
  3056. style_dataBlue.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //应用边界线 左边界线
  3057. style_dataBlue.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Thin; //应用边界线 右边界线
  3058. style_dataBlue.Borders[Aspose.Cells.BorderType.TopBorder].LineStyle = CellBorderType.Thin; //应用边界线 上边界线
  3059. style_dataBlue.Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //应用边界线 下边界线
  3060. Aspose.Cells.Style style_dataYellow = workbook.CreateStyle();
  3061. style_dataYellow.HorizontalAlignment = TextAlignmentType.Center;//文字居中
  3062. style_dataYellow.VerticalAlignment = TextAlignmentType.Center;
  3063. style_dataYellow.Font.Name = "微软雅黑";//文字字体
  3064. style_dataYellow.Font.Size = 12;//文字大小
  3065. style_dataYellow.IsLocked = false;//单元格解锁
  3066. style_dataYellow.Font.IsBold = false;//粗体
  3067. style_dataYellow.ForegroundColor = Color.FromArgb(255, 242, 204);
  3068. style_dataYellow.Pattern = BackgroundType.Solid;
  3069. style_dataYellow.Font.Color = Color.FromArgb(0, 0, 0);
  3070. style_dataYellow.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //应用边界线 左边界线
  3071. style_dataYellow.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Thin; //应用边界线 右边界线
  3072. style_dataYellow.Borders[Aspose.Cells.BorderType.TopBorder].LineStyle = CellBorderType.Thin; //应用边界线 上边界线
  3073. style_dataYellow.Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //应用边界线 下边界线
  3074. int rowIndex = 4;
  3075. foreach (var d in dataList)
  3076. {
  3077. //内容
  3078. string typeStr = d.PriceDetailTypeStr + d.PriceName;
  3079. cells["B" + rowIndex.ToString()].PutValue(d.PriceTypeStr);
  3080. cells["C" + rowIndex.ToString()].PutValue(d.PriceDtStr);
  3081. cells["D" + rowIndex.ToString()].PutValue(typeStr);
  3082. cells["E" + rowIndex.ToString()].PutValue(d.Price.ToString("#0.00"));
  3083. cells["F" + rowIndex.ToString()].PutValue(d.PriceCount);
  3084. cells["G" + rowIndex.ToString()].PutValue(d.Currency);
  3085. cells["H" + rowIndex.ToString()].PutValue(d.PriceSum.ToString("#0.00"));
  3086. cells["K" + rowIndex.ToString()].PutValue(d.Remark);
  3087. //样式
  3088. cells["B" + rowIndex.ToString()].SetStyle(style_dataCol);
  3089. cells["C" + rowIndex.ToString()].SetStyle(style_dataCol);
  3090. cells["D" + rowIndex.ToString()].SetStyle(style_dataCol);
  3091. cells["E" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3092. cells["F" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3093. cells["G" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3094. cells["H" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3095. cells["I" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3096. cells["J" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3097. cells["K" + rowIndex.ToString()].SetStyle(style_dataYellow);
  3098. //公式
  3099. cells["H" + rowIndex.ToString()].Formula = string.Format(@"E{0}*F{0}", rowIndex);
  3100. cells["J" + rowIndex.ToString()].Formula = string.Format(@"H{0}*I{0}", rowIndex);
  3101. cells.SetRowHeight(rowIndex - 1, 25);
  3102. rowIndex++;
  3103. }
  3104. cells["B" + rowIndex.ToString()].SetStyle(style_dataCol);
  3105. cells["C" + rowIndex.ToString()].SetStyle(style_dataCol);
  3106. cells["D" + rowIndex.ToString()].SetStyle(style_dataCol);
  3107. cells["E" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3108. cells["F" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3109. cells["G" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3110. cells["H" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3111. cells["I" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3112. cells["J" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3113. cells["K" + rowIndex.ToString()].SetStyle(style_dataYellow);
  3114. rowIndex++;
  3115. cells["B" + rowIndex.ToString()].SetStyle(style_dataCol);
  3116. cells["C" + rowIndex.ToString()].SetStyle(style_dataCol);
  3117. cells["D" + rowIndex.ToString()].SetStyle(style_dataCol);
  3118. cells["E" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3119. cells["F" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3120. cells["G" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3121. cells["H" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3122. cells["I" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3123. cells["J" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3124. cells["K" + rowIndex.ToString()].SetStyle(style_dataYellow);
  3125. rowIndex = 3;
  3126. int tempPriceType = 0;
  3127. foreach (var c in dataList)
  3128. {
  3129. if (tempPriceType == c.PriceType)
  3130. {
  3131. continue;
  3132. }
  3133. tempPriceType = c.PriceType;
  3134. int _rowCount = countList.First(s => s.PriceType == tempPriceType).DataCount;
  3135. cells.Merge(rowIndex, 1, _rowCount, 1);
  3136. Aspose.Cells.Range tempRange = cells.CreateRange(rowIndex, 1, _rowCount, 1);
  3137. rowIndex += _rowCount;
  3138. }
  3139. rowIndex = 4 + dataList.Count;
  3140. cells["D" + rowIndex.ToString()].PutValue("合计");
  3141. cells["J" + rowIndex.ToString()].Formula = string.Format(@"SUM(J4,J{0})", rowIndex - 1);
  3142. cells.SetRowHeight(rowIndex - 1, 25);
  3143. rowIndex++;
  3144. cells["D" + rowIndex.ToString()].PutValue("服务费10%开票税金8%");
  3145. cells["J" + rowIndex.ToString()].Formula = string.Format(@"J{0}*1.1*1.08", rowIndex - 1);
  3146. cells.SetRowHeight(rowIndex - 1, 25);
  3147. #endregion
  3148. #region IO
  3149. System.IO.MemoryStream ms = workbook.SaveToStream();//生成数据流
  3150. string fileName = ("GroupExtraCost/超支费用(" + cellValue_Header + ").xlsx");
  3151. byte[] bt = ms.ToArray();
  3152. workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3153. #endregion
  3154. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3155. return Ok(JsonView(true, "成功", new { url = rst }));
  3156. }
  3157. #endregion
  3158. }
  3159. }