FinancialController.cs 157 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570
  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 = Convert.ToInt32(result.Data.dailyId);
  168. int sign = Convert.ToInt32(result.Data.sign);
  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 = Convert.ToInt32(result.Data.dailyId);
  195. int sign = Convert.ToInt32(result.Data.sign);
  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.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. doc.Save(AppSettingsHelper.Get("WordBasePath") + "ForeignReceivables/File/" + strFileName);
  854. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/ForeignReceivables/File/" + strFileName;
  855. return Ok(JsonView(true, "成功", new { Url = url }));
  856. }
  857. else if (dto.FileType == 3) //汇款通知
  858. {
  859. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  860. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.NationalTravelFeeId > 0).ToList();
  861. if (_EnterExitCosts == null)
  862. {
  863. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  864. }
  865. var _cityFee = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  866. foreach (var item in _DayAndCosts)
  867. {
  868. var cityInfo = _cityFee.Where(it => it.Id == item.NationalTravelFeeId).FirstOrDefault();
  869. if (cityInfo != null)
  870. {
  871. if (cityInfo.City.Contains("全部城市") || cityInfo.City.Contains("其他城市"))
  872. {
  873. item.Place = cityInfo.Country;
  874. }
  875. else item.Place = cityInfo.City;
  876. }
  877. }
  878. //数据源
  879. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  880. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  881. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  882. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  883. //币种Data
  884. var currData = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  885. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  886. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  887. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  888. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  889. .Select((tcl, dc, cc) => new
  890. {
  891. Name = dc.LastName + dc.FirstName,
  892. Sex = dc.Sex,
  893. Birthday = dc.BirthDay,
  894. Company = cc.CompanyFullName,
  895. Job = dc.Job,
  896. AirType = tcl.ShippingSpaceTypeId
  897. })
  898. .ToList();
  899. if (DeleClientList.Count < 1)
  900. {
  901. return Ok(JsonView(false, "暂无团组成员,请先填写团组成员!!!"));
  902. }
  903. var _ClientNames = DeleClientList.Select(x => x.Name).ToList();
  904. var _GroupClient = DeleClientList.GroupBy(x => x.Company).ToList();
  905. Dictionary<string, string> bookmarkArr = null;
  906. string tempPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/Temp/汇款通知.docx";
  907. //载入模板
  908. Document doc = new Document(tempPath);
  909. DocumentBuilder builder = null;
  910. List<string> filesToZip = new List<string>();
  911. foreach (var ClientItem in _GroupClient) //遍历单位
  912. {
  913. doc = new Document(tempPath);
  914. builder = new DocumentBuilder(doc);
  915. Paragraph paragraph = new Paragraph(doc);
  916. bookmarkArr = new Dictionary<string, string>();
  917. bookmarkArr.Add("titleClientUnit", ClientItem.Key); //title单位
  918. bookmarkArr.Add("ClientUnit", ClientItem.Key); //单位
  919. bookmarkArr.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));//出发日期
  920. bookmarkArr.Add("name", string.Join(",", ClientItem.Select(x => x.Name).ToArray()).TrimEnd(','));//全部人员信息
  921. bookmarkArr.Add("VisitCountry", _DelegationInfo.VisitCountry);//出访国家
  922. bookmarkArr.Add("dayTime", DateTime.Now.ToString("yyyy年MM月dd日"));//今天日期
  923. var ClientItemList = ClientItem.ToList();
  924. string UsersTop = string.Empty;//word中人员以及金额
  925. decimal WordAllPrice = 0.00M;
  926. //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(),
  927. // 6, 3 + dac1.Where(x=>!string.IsNullOrWhiteSpace(x.Place)).Select(x=>(Convert.ToDecimal(x.SubTotal) / Convert.ToDecimal(x.Cost)).ToString().Length).Max() };
  928. //遍历人员
  929. for (int i = 0; i < ClientItemList.Count(); i++)
  930. {
  931. Dictionary<string, string> TeableBookmarkArr = new Dictionary<string, string>();
  932. var client = ClientItemList[i]; //每个人员
  933. var firstName = ClientItemList[i].Name;
  934. //计算费用总和
  935. decimal airPrice = client.AirType == 460 ? _EnterExitCosts.AirJJ : _EnterExitCosts.AirGW;
  936. decimal AllPrice = airPrice + _EnterExitCosts.CityTranffic + dac1.Sum(x => x.SubTotal) + dac2.Sum(x => x.SubTotal) +
  937. dac3.Sum(x => x.SubTotal) + dac4.Sum(x => x.SubTotal) + _EnterExitCosts.Visa + _EnterExitCosts.Safe +
  938. _EnterExitCosts.Service;
  939. WordAllPrice += AllPrice;
  940. UsersTop += firstName + "出访费用为¥" + AllPrice.ToString("#0.00") + "元、";
  941. TeableBookmarkArr.Add("jp", (client.AirType == 460 ? _EnterExitCosts.AirJJ : _EnterExitCosts.AirGW).ToString("#0.00") + " 元"); //机票金额
  942. TeableBookmarkArr.Add("cs", _EnterExitCosts.CityTranffic.ToString("#0.00") + " 元"); //城市交通费用
  943. TeableBookmarkArr.Add("zs", dac1.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //住宿费
  944. string zsinfo = string.Empty;
  945. string hsinfo = string.Empty;
  946. string gzinfo = string.Empty;
  947. List<string> placeArr = new List<string>();
  948. Aspose.Words.Tables.Table FirstTable = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
  949. Aspose.Words.Tables.Table ChildTable = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 0, true);
  950. Aspose.Words.Tables.Table ChildTable1 = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 1, true);
  951. Aspose.Words.Tables.Table ChildTable2 = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 2, true);
  952. int rowIndex = 0;
  953. foreach (var item in dac1)
  954. {
  955. if (string.IsNullOrWhiteSpace(item.Place))
  956. {
  957. continue;
  958. }
  959. if (placeArr.Contains(item.Place))
  960. {
  961. continue;
  962. }
  963. else
  964. {
  965. placeArr.Add(item.Place);
  966. }
  967. if (!string.IsNullOrWhiteSpace(item.Place))
  968. {
  969. if (rowIndex > ChildTable.Rows.Count - 1)
  970. {
  971. var chitableRow = ChildTable.LastRow.Clone(true);
  972. ChildTable.AppendChild(chitableRow);
  973. }
  974. int days = dac1.FindAll(x => x.Place == item.Place).Count();
  975. SetCells(ChildTable, doc, rowIndex, 0, item.Place);
  976. SetCells(ChildTable, doc, rowIndex, 1, days + "晚");
  977. string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
  978. SetCells(ChildTable, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/晚");
  979. SetCells(ChildTable, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
  980. SetCells(ChildTable, doc, rowIndex, 4, "CNY" + item.SubTotal + "\r\n");
  981. rowIndex++;
  982. zsinfo += item.Place + " " + days + "晚 " + item.Cost.ToString("#0.00") + currencyCode + "/晚" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.0000") + " CNY" + item.SubTotal * days + "\r\n";
  983. }
  984. }
  985. placeArr.Clear();
  986. rowIndex = 0;
  987. foreach (var item in dac2)
  988. {
  989. if (string.IsNullOrWhiteSpace(item.Place))
  990. {
  991. continue;
  992. }
  993. if (placeArr.Contains(item.Place))
  994. {
  995. continue;
  996. }
  997. else
  998. {
  999. placeArr.Add(item.Place);
  1000. }
  1001. if (!string.IsNullOrWhiteSpace(item.Place))
  1002. {
  1003. if (rowIndex > ChildTable1.Rows.Count - 1)
  1004. {
  1005. var chitableRow = ChildTable1.LastRow.Clone(true);
  1006. ChildTable1.AppendChild(chitableRow);
  1007. }
  1008. int days = dac2.FindAll(x => x.Place == item.Place).Count();
  1009. SetCells(ChildTable1, doc, rowIndex, 0, item.Place);
  1010. SetCells(ChildTable1, doc, rowIndex, 1, days + "天");
  1011. string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
  1012. SetCells(ChildTable1, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/天");
  1013. SetCells(ChildTable1, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
  1014. SetCells(ChildTable1, doc, rowIndex, 4, "CNY" + item.SubTotal);
  1015. rowIndex++;
  1016. hsinfo += item.Place + " " + days + "天 " + item.Cost.ToString("#0.00") + currencyCode + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.0000") + " CNY" + item.SubTotal * days + "\r\n";
  1017. }
  1018. }
  1019. placeArr.Clear();
  1020. rowIndex = 0;
  1021. foreach (var item in dac3)
  1022. {
  1023. if (string.IsNullOrWhiteSpace(item.Place))
  1024. {
  1025. continue;
  1026. }
  1027. if (placeArr.Contains(item.Place))
  1028. {
  1029. continue;
  1030. }
  1031. else
  1032. {
  1033. placeArr.Add(item.Place);
  1034. }
  1035. if (!string.IsNullOrWhiteSpace(item.Place))
  1036. {
  1037. if (rowIndex > ChildTable2.Rows.Count - 1)
  1038. {
  1039. var chitableRow = ChildTable2.LastRow.Clone(true);
  1040. ChildTable2.AppendChild(chitableRow);
  1041. }
  1042. int days = dac3.FindAll(x => x.Place == item.Place).Count();
  1043. SetCells(ChildTable2, doc, rowIndex, 0, item.Place);
  1044. SetCells(ChildTable2, doc, rowIndex, 1, days + "天");
  1045. string currencyCode = currData.Find(it => it.Id == item.Currency)?.Remark ?? "Unknown";
  1046. SetCells(ChildTable2, doc, rowIndex, 2, item.Cost.ToString("#0.00") + currencyCode + "/天");
  1047. SetCells(ChildTable2, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
  1048. SetCells(ChildTable2, doc, rowIndex, 4, "CNY" + item.SubTotal + "\r\n");
  1049. rowIndex++;
  1050. gzinfo += item.Place + " " + days + "天 " + item.Cost.ToString("#0.00") + currencyCode + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00") + " CNY" + item.SubTotal * days + "\r\n";
  1051. }
  1052. }
  1053. placeArr.Clear();
  1054. TeableBookmarkArr.Add("zsinfo", zsinfo); //住宿费详情
  1055. TeableBookmarkArr.Add("hs", dac2.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //伙食费
  1056. TeableBookmarkArr.Add("hsinfo", hsinfo); //伙食费详情
  1057. TeableBookmarkArr.Add("gz", dac3.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //公杂费
  1058. TeableBookmarkArr.Add("gzinfo", gzinfo); //公杂费详情
  1059. TeableBookmarkArr.Add("qt", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00") + " 元");//其他费用
  1060. TeableBookmarkArr.Add("qtinfo", $"(签证费{_EnterExitCosts.Visa.ToString("#0.00")}元、保险{_EnterExitCosts.Safe.ToString("#0.00")}元等费用)");//其他费用第二列
  1061. TeableBookmarkArr.Add("fw", _EnterExitCosts.Service.ToString("#0.00") + "元/人");//服务费
  1062. TeableBookmarkArr.Add("AllPrice", AllPrice.ToString("#0.00") + "元/人");//表格合计费用
  1063. string airStr = client.AirType == 460 ? "经济舱" : client.AirType == 458 ? "公务舱" : "";
  1064. TeableBookmarkArr.Add("title", $"费用清单-{airStr}({firstName})");
  1065. foreach (var book in TeableBookmarkArr.Keys)
  1066. {
  1067. if (doc.Range.Bookmarks[book] != null)
  1068. {
  1069. Bookmark mark = doc.Range.Bookmarks[book];
  1070. mark.Text = TeableBookmarkArr[book];
  1071. }
  1072. }
  1073. if (i != ClientItemList.Count - 1)
  1074. {
  1075. builder.PageSetup.Orientation = Aspose.Words.Orientation.Portrait;
  1076. Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
  1077. table.ParentNode.InsertAfter(paragraph, table);
  1078. var CloneTable = (Aspose.Words.Tables.Table)table.Clone(true);
  1079. table.ParentNode.InsertAfter(CloneTable, paragraph);
  1080. }
  1081. TeableBookmarkArr.Clear();
  1082. }
  1083. bookmarkArr.Add("VisitPrice", WordAllPrice.ToString());//出访费用总额
  1084. bookmarkArr.Add("CnAllPrice", WordAllPrice.ConvertCNYUpper());//出访费用总额中文
  1085. bookmarkArr.Add("namesPrice", UsersTop.TrimEnd('、'));//各人员出访费用 付辰同志出访费用为¥73,604.8元
  1086. foreach (var book in bookmarkArr.Keys)
  1087. {
  1088. if (doc.Range.Bookmarks[book] != null)
  1089. {
  1090. Bookmark mark = doc.Range.Bookmarks[book];
  1091. mark.Text = bookmarkArr[book];
  1092. }
  1093. }
  1094. //MemoryStream outSteam = new MemoryStream();
  1095. string filsPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/File/{ClientItem.Key.Replace("\n", "")}.docx";
  1096. doc.Save(filsPath);
  1097. filesToZip.Add(filsPath);
  1098. //streams.Add(ClientItem.Key + ".docx", outSteam.ToArray());
  1099. }
  1100. //文件名
  1101. string zipFileName = _DelegationInfo.TeamName + "-收款账单.zip";
  1102. string zipPath = $"ForeignReceivables/File/{_DelegationInfo.TeamName}-收款账单{DateTime.Now.ToString("yyyyMMddHHmmss")}.zip";
  1103. try
  1104. {
  1105. using (var zip = ZipFile.Open(AppSettingsHelper.Get("WordBasePath") + zipPath, ZipArchiveMode.Create))
  1106. {
  1107. foreach (var file in filesToZip)
  1108. {
  1109. zip.CreateEntryFromFile(file, Path.GetFileName(file));
  1110. }
  1111. }
  1112. }
  1113. catch (Exception ex)
  1114. {
  1115. return Ok(JsonView(false, ex.Message));
  1116. }
  1117. string url = AppSettingsHelper.Get("WordBaseUrl") + $"Office/Word/{zipPath}";
  1118. return Ok(JsonView(true, "成功", new { Url = url }));
  1119. }
  1120. return Ok(JsonView(false, "操作失败!"));
  1121. }
  1122. catch (Exception ex)
  1123. {
  1124. return Ok(JsonView(false, ex.Message));
  1125. }
  1126. }
  1127. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  1128. {
  1129. //获取table中的某个单元格,从0开始
  1130. Aspose.Words.Tables.Cell lshCell = table.Rows[rows].Cells[cells];
  1131. //将单元格中的第一个段落移除
  1132. lshCell.FirstParagraph.Remove();
  1133. //新建一个段落
  1134. Paragraph p = new Paragraph(doc);
  1135. var r = new Run(doc, val);
  1136. r.Font.Size = 8;
  1137. //把设置的值赋给之前新建的段落
  1138. p.AppendChild(r);
  1139. //将此段落加到单元格内
  1140. lshCell.AppendChild(p);
  1141. }
  1142. #endregion
  1143. #region 已收款项
  1144. /// <summary>
  1145. /// 已收款项
  1146. /// 查询
  1147. /// </summary>
  1148. /// <param name="dto"></param>
  1149. /// <returns></returns>
  1150. [HttpPost]
  1151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1152. public async Task<IActionResult> PostAmountReceived(AmountReceivedDto dto)
  1153. {
  1154. try
  1155. {
  1156. if (dto == null)
  1157. {
  1158. return Ok(JsonView(false, "参数不能为空!"));
  1159. }
  1160. Result ffrData = await _proceedsReceivedRep.PostAmountReceived(dto.DiId);
  1161. dynamic data = null;
  1162. if (dto.PortType == 1)
  1163. {
  1164. if (ffrData.Code != 0)
  1165. {
  1166. return Ok(JsonView(false, ffrData.Msg));
  1167. }
  1168. data = ffrData.Data;
  1169. }
  1170. else if (dto.PortType == 2)
  1171. {
  1172. if (ffrData.Code != 0)
  1173. {
  1174. return Ok(JsonView(false, ffrData.Msg));
  1175. }
  1176. data = ffrData.Data;
  1177. }
  1178. else if (dto.PortType == 2)
  1179. {
  1180. if (ffrData.Code != 0)
  1181. {
  1182. return Ok(JsonView(false, ffrData.Msg));
  1183. }
  1184. data = ffrData.Data;
  1185. }
  1186. else
  1187. {
  1188. return Ok(JsonView(false, "请选择正确的端口号!"));
  1189. }
  1190. return Ok(JsonView(true, "操作成功!", data));
  1191. }
  1192. catch (Exception ex)
  1193. {
  1194. return Ok(JsonView(false, ex.Message));
  1195. }
  1196. }
  1197. /// <summary>
  1198. /// 已收款项
  1199. /// Add Or Edit
  1200. /// </summary>
  1201. /// <param name="dto"></param>
  1202. /// <returns></returns>
  1203. [HttpPost]
  1204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1205. public async Task<IActionResult> PostAmountReceivedAddOrEdit(AmountReceivedAddOrEditDto dto)
  1206. {
  1207. try
  1208. {
  1209. if (dto == null)
  1210. {
  1211. return Ok(JsonView(false, "参数不能为空!"));
  1212. }
  1213. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedAddOrEditDto(dto);
  1214. if (dto.PortType == 1)
  1215. {
  1216. if (ffrData.Code != 0)
  1217. {
  1218. return Ok(JsonView(false, ffrData.Msg));
  1219. }
  1220. }
  1221. else if (dto.PortType == 2)
  1222. {
  1223. if (ffrData.Code != 0)
  1224. {
  1225. return Ok(JsonView(false, ffrData.Msg));
  1226. }
  1227. }
  1228. else if (dto.PortType == 2)
  1229. {
  1230. if (ffrData.Code != 0)
  1231. {
  1232. return Ok(JsonView(false, ffrData.Msg));
  1233. }
  1234. }
  1235. else
  1236. {
  1237. return Ok(JsonView(false, "请选择正确的端口号!"));
  1238. }
  1239. return Ok(JsonView(true, "操作成功!"));
  1240. }
  1241. catch (Exception ex)
  1242. {
  1243. return Ok(JsonView(false, ex.Message));
  1244. }
  1245. }
  1246. /// <summary>
  1247. /// 已收款项
  1248. /// Del
  1249. /// </summary>
  1250. /// <param name="dto"></param>
  1251. /// <returns></returns>
  1252. [HttpPost]
  1253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1254. public async Task<IActionResult> PostAmountReceived_Del(AmountReceivedDelDto dto)
  1255. {
  1256. try
  1257. {
  1258. if (dto == null)
  1259. {
  1260. return Ok(JsonView(false, "参数不能为空!"));
  1261. }
  1262. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedDel(dto);
  1263. if (ffrData.Code != 0)
  1264. {
  1265. return Ok(JsonView(false, ffrData.Msg));
  1266. }
  1267. return Ok(JsonView(true, "操作成功!"));
  1268. }
  1269. catch (Exception ex)
  1270. {
  1271. return Ok(JsonView(false, ex.Message));
  1272. }
  1273. }
  1274. #endregion
  1275. #region 收款退还与其他款项 --> 收款退还
  1276. /// <summary>
  1277. /// 收款退还与其他款项
  1278. /// 查询 根据团组Id
  1279. /// </summary>
  1280. /// <param name="dto"></param>
  1281. /// <returns></returns>
  1282. [HttpPost]
  1283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1284. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyItemByDiId(PaymentRefundAndOtherMoneyItemByDiIdDto dto)
  1285. {
  1286. try
  1287. {
  1288. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  1289. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  1290. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  1291. #region 页面功能权限处理
  1292. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  1293. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1294. if (pageFunAuth.CheckAuth == 0)
  1295. {
  1296. return Ok(JsonView(false, "您没有当前页面查询权限!"));
  1297. }
  1298. #endregion
  1299. Result _result = await _paymentRefundAndOtherMoneyRep._ItemByDiId(dto.DiId);
  1300. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //1 Web 2 Android 3 Ios
  1301. {
  1302. if (_result.Code != 0)
  1303. {
  1304. return Ok(JsonView(false, _result.Msg));
  1305. }
  1306. var data = new
  1307. {
  1308. PageFuncAuth = pageFunAuth,
  1309. Data = _result.Data
  1310. };
  1311. return Ok(JsonView(true, "操作成功!", data));
  1312. }
  1313. else
  1314. {
  1315. return Ok(JsonView(false, "请输入正确的端口号! 1 Web 2 Android 3 Ios;"));
  1316. }
  1317. }
  1318. catch (Exception ex)
  1319. {
  1320. return Ok(JsonView(false, ex.Message));
  1321. }
  1322. }
  1323. /// <summary>
  1324. /// 收款退还与其他款项
  1325. /// 删除
  1326. /// </summary>
  1327. /// <param name="dto"></param>
  1328. /// <returns></returns>
  1329. [HttpPost]
  1330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1331. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyDel(PaymentRefundAndOtherMoneyDelDto dto)
  1332. {
  1333. try
  1334. {
  1335. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  1336. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  1337. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  1338. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  1339. #region 页面功能权限处理
  1340. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1341. #endregion
  1342. if (pageFunAuth.DeleteAuth == 0)
  1343. {
  1344. return Ok(JsonView(false, "您没有当前页面删除权限!"));
  1345. }
  1346. Result _result = await _paymentRefundAndOtherMoneyRep._Del(dto);
  1347. if (_result.Code != 0)
  1348. {
  1349. return Ok(JsonView(false, _result.Msg));
  1350. }
  1351. return Ok(JsonView(true, "操作成功!"));
  1352. }
  1353. catch (Exception ex)
  1354. {
  1355. return Ok(JsonView(false, ex.Message));
  1356. }
  1357. }
  1358. /// <summary>
  1359. /// 收款退还与其他款项
  1360. /// Info Data Source
  1361. /// </summary>
  1362. /// <param name="dto"></param>
  1363. /// <returns></returns>
  1364. [HttpPost]
  1365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1366. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyInfoDataSource(PortDtoBase dto)
  1367. {
  1368. try
  1369. {
  1370. Result _result = await _paymentRefundAndOtherMoneyRep._InfoDataSource(dto);
  1371. if (_result.Code != 0)
  1372. {
  1373. return Ok(JsonView(false, _result.Msg));
  1374. }
  1375. return Ok(JsonView(true, "查询成功!", _result.Data));
  1376. }
  1377. catch (Exception ex)
  1378. {
  1379. return Ok(JsonView(false, ex.Message));
  1380. }
  1381. }
  1382. /// <summary>
  1383. /// 收款退还与其他款项
  1384. /// Info
  1385. /// </summary>
  1386. /// <param name="dto"></param>
  1387. /// <returns></returns>
  1388. [HttpPost]
  1389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1390. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyInfo(PaymentRefundAndOtherMoneyInfoDto dto)
  1391. {
  1392. try
  1393. {
  1394. if (dto == null)
  1395. {
  1396. return Ok(JsonView(false, "参数不能为空!"));
  1397. }
  1398. Result _result = await _paymentRefundAndOtherMoneyRep._Info(dto);
  1399. if (_result.Code != 0)
  1400. {
  1401. return Ok(JsonView(false, _result.Msg));
  1402. }
  1403. return Ok(JsonView(true, "查询成功!", _result.Data));
  1404. }
  1405. catch (Exception ex)
  1406. {
  1407. return Ok(JsonView(false, ex.Message));
  1408. }
  1409. }
  1410. /// <summary>
  1411. /// 收款退还与其他款项 --> 收款退还(只保留人名币)
  1412. /// 操作(Add Or Edit)
  1413. /// </summary>
  1414. /// <param name="dto"></param>
  1415. /// <returns></returns>
  1416. [HttpPost]
  1417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1418. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyAddOrEdit(PaymentRefundAndOtherMoneyAddOrEditDto dto)
  1419. {
  1420. try
  1421. {
  1422. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  1423. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  1424. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  1425. #region 页面功能权限处理
  1426. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  1427. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1428. #endregion
  1429. if (dto.Status == 1) //add
  1430. {
  1431. if (pageFunAuth.AddAuth == 0)
  1432. {
  1433. return Ok(JsonView(false, "您没有当前页面添加权限!"));
  1434. }
  1435. }
  1436. else if (dto.Status == 2) //edit
  1437. {
  1438. if (pageFunAuth.EditAuth == 0)
  1439. {
  1440. return Ok(JsonView(false, "您没有当前页面编辑权限!"));
  1441. }
  1442. }
  1443. else
  1444. {
  1445. return Ok(JsonView(false, "请输入正确的操作状态! 1 添加 2 修改!"));
  1446. }
  1447. Result _result = await _paymentRefundAndOtherMoneyRep._AddOrEdit(dto);
  1448. if (_result.Code != 0)
  1449. {
  1450. return Ok(JsonView(false, _result.Msg));
  1451. }
  1452. return Ok(JsonView(true, "操作成功!"));
  1453. }
  1454. catch (Exception ex)
  1455. {
  1456. return Ok(JsonView(false, ex.Message));
  1457. }
  1458. }
  1459. #endregion
  1460. #region 应收报表
  1461. /// <summary>
  1462. /// 应收报表
  1463. /// 查询 根据日期范围
  1464. /// </summary>
  1465. /// <param name="dto"></param>
  1466. /// <returns></returns>
  1467. [HttpPost]
  1468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1469. public async Task<IActionResult> PostSyntheticalReceivableByDateRange(PostSyntheticalReceivableByDateRangeDto dto)
  1470. {
  1471. string sqlWhere = " Where di.IsDel=0 ";
  1472. #region 验证
  1473. if (string.IsNullOrEmpty(dto.beginDt) && string.IsNullOrEmpty(dto.endDt))
  1474. {
  1475. return Ok(JsonView(false, "日期参数至少填写一个!"));
  1476. }
  1477. if (!string.IsNullOrEmpty(dto.beginDt))
  1478. {
  1479. if (Regex.Match(dto.beginDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
  1480. {
  1481. return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
  1482. }
  1483. else
  1484. {
  1485. sqlWhere += string.Format(@" And di.VisitDate >= '{0} 00:00:00' ", dto.beginDt);
  1486. }
  1487. }
  1488. if (!string.IsNullOrEmpty(dto.endDt))
  1489. {
  1490. if (Regex.Match(dto.endDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
  1491. {
  1492. return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
  1493. }
  1494. else
  1495. {
  1496. sqlWhere += string.Format(@" And di.VisitDate <= '{0} 23:59:59' ", dto.endDt);
  1497. }
  1498. }
  1499. #endregion
  1500. //排序倒序
  1501. 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);
  1502. List<PostSyntheticalReceivableByDateRangeView> list_rst = _sqlSugar.SqlQueryable<PostSyntheticalReceivableByDateRangeView>(sql).ToList();
  1503. var setData = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToList();
  1504. decimal sumAll_fr = 0M; //应收
  1505. decimal sumAll_pr = 0M; //已收
  1506. decimal sumAll_balance = 0M; //尾款
  1507. if (list_rst.Count > 0)
  1508. {
  1509. int rowNumber = 1;
  1510. foreach (var item_rst in list_rst)
  1511. {
  1512. DateTime dtTemp;
  1513. bool b = DateTime.TryParse(item_rst.visitDate, out dtTemp);
  1514. if (b)
  1515. {
  1516. item_rst.visitDate = dtTemp.ToString("yyyy-MM-dd");
  1517. }
  1518. item_rst.No = rowNumber;
  1519. rowNumber++;
  1520. int diId = item_rst.diid;
  1521. decimal sum_fr = 0M;
  1522. decimal sum_pr = 0M;
  1523. string str_client = string.Empty;
  1524. decimal sum_refund = 0M; //收款退还
  1525. decimal sum_extra = 0M; //超支费用
  1526. decimal balance = 0M;
  1527. string str_schedule = string.Empty;
  1528. //1.应收
  1529. string sql_fr = string.Format(@" Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0} ", diId);
  1530. List<Fin_ForeignReceivables> list_fr = _sqlSugar.SqlQueryable<Fin_ForeignReceivables>(sql_fr).ToList();
  1531. sum_fr = list_fr.Sum(s => s.ItemSumPrice);
  1532. //2.已收
  1533. string sql_pr = string.Format(@" Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0} ", diId);
  1534. List<Fin_ProceedsReceived> list_pr = _sqlSugar.SqlQueryable<Fin_ProceedsReceived>(sql_pr).ToList();
  1535. foreach (var item_pr in list_pr)
  1536. {
  1537. sum_pr += item_pr.Price;
  1538. str_client += string.Format(@"{0};", item_pr.Client);
  1539. str_schedule += string.Format(@"{0};", item_pr.Remark);
  1540. }
  1541. if (str_schedule.Length > 0)
  1542. {
  1543. str_schedule = str_schedule.TrimEnd(';');
  1544. }
  1545. if (str_client.Length > 0)
  1546. {
  1547. str_client = str_client.TrimEnd(';');
  1548. }
  1549. //3.收款退还
  1550. string sql_other = string.Format(@"Select * From Fin_PaymentRefundAndOtherMoney prao
  1551. Inner Join Grp_CreditCardPayment ccp On prao.Id = ccp.CId
  1552. Where ccp.CTable = 285 And ccp.IsPay = 1 And prao.IsDel = 0 And ccp.IsDel = 0 And prao.DiId = {0}", diId);
  1553. List<Grp_CreditCardPayment> list_other = _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql_other).ToList();
  1554. sum_refund = list_other.Sum(s => s.RMBPrice);
  1555. //4.超支
  1556. string sql_extra = string.Format(@" Select c.* From Fin_GroupExtraCost f
  1557. Inner join Grp_CreditCardPayment c On f.Id = c.CId
  1558. Where c.CTable = 1015 And c.IsPay = 1 And f.IsDel = 0 And c.IsDel = 0 And f.DiId = {0} ", diId);
  1559. List<Grp_CreditCardPayment> list_extra = _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql_extra).ToList();
  1560. sum_extra = list_extra.Sum(s => s.RMBPrice);
  1561. item_rst.frPrice = sum_fr.ToString("#0.00");
  1562. item_rst.extraPrice = sum_extra.ToString("#0.00");
  1563. item_rst.receivableTotal = (sum_fr + sum_extra).ToString("#0.00");
  1564. item_rst.prPrice = sum_pr.ToString("#0.00");
  1565. item_rst.refundAmount = sum_refund.ToString("#0.00");
  1566. item_rst.receivedTotal = (sum_pr - sum_refund).ToString("#0.00");
  1567. item_rst.balPrice = ((sum_fr + sum_extra) - (sum_pr - sum_refund)).ToString("#0.00");
  1568. item_rst.prClient = str_client;
  1569. item_rst.schedule = str_schedule;
  1570. string tempVisitDate = Convert.ToDateTime(item_rst.visitDate).ToString("yyyy-MM-dd");
  1571. sumAll_fr += (sum_fr + sum_extra);
  1572. sumAll_pr += (sum_pr - sum_refund);
  1573. sumAll_balance += ((sum_fr + sum_extra) - (sum_pr - sum_refund));
  1574. #region 单位应收已收细项(以应收费用名称为主去(已收费用)匹配) 新增 雷怡 2024-35-08 16:35:28
  1575. List<ClientFeeInfoView> feeDatas = new List<ClientFeeInfoView>();
  1576. //匹配上的数据
  1577. foreach (var item in list_fr)
  1578. {
  1579. var prInfo = list_pr.Find(it => item.PriceName.Contains(it.Client) || item.PriceName.Equals(it.Client));
  1580. decimal _balancePayment = 0.00M;
  1581. if (item.Currency == prInfo?.Currency)
  1582. {
  1583. _balancePayment = item.ItemSumPrice - prInfo?.Price ?? 0.00M;
  1584. }
  1585. feeDatas.Add(new ClientFeeInfoView
  1586. {
  1587. client = item.PriceName,
  1588. frMoney = item.ItemSumPrice.ToString("#0.00"),
  1589. frCurrency = setData.Find(it => it.Id == item.Currency)?.Name ?? "-",
  1590. frRate = item.Rate.ToString("#0.0000"),
  1591. prReceivablesType = setData.Find(it => it.Id == prInfo?.ReceivablesType)?.Name ?? "",
  1592. prTime = prInfo?.SectionTime ?? "-",
  1593. prMoney = prInfo?.Price.ToString("#0.00") ?? "-",
  1594. prCurrency = setData.Find(it => it.Id == prInfo?.Currency)?.Name ?? "",
  1595. balPayment = _balancePayment.ToString("#0.00")
  1596. });
  1597. }
  1598. //未匹配上的数据
  1599. foreach (var item in list_pr)
  1600. {
  1601. var frInfo = list_fr.Find(it => it.PriceName.Contains(item.Client) || it.PriceName.Equals(item.Client));
  1602. if (frInfo == null)
  1603. {
  1604. feeDatas.Add(new ClientFeeInfoView
  1605. {
  1606. client = item.Client + "[未匹配上的已收数据(应收已收公司名称不一致)]",
  1607. frMoney = "0.00",
  1608. frCurrency = "-",
  1609. frRate = "0.0000",
  1610. prReceivablesType = setData.Find(it => it.Id == item?.ReceivablesType)?.Name ?? "",
  1611. prTime = item?.SectionTime ?? "-",
  1612. prMoney = item?.Price.ToString("#0.00") ?? "0.00",
  1613. prCurrency = setData.Find(it => it.Id == item?.Currency)?.Name ?? "",
  1614. balPayment = "0.00"
  1615. });
  1616. }
  1617. }
  1618. item_rst.feeItem = feeDatas;
  1619. #endregion
  1620. }
  1621. PostSyntheticalReceivableByDateRangeResultView result = new PostSyntheticalReceivableByDateRangeResultView();
  1622. result.total_fr = sumAll_fr.ToString("#0.00");
  1623. result.total_pr = sumAll_pr.ToString("#0.00");
  1624. result.total_balance = sumAll_balance.ToString("#0.00");
  1625. result.dataList = new List<PostSyntheticalReceivableByDateRangeView>(list_rst);
  1626. if (dto.requestType == 1)
  1627. {
  1628. return Ok(JsonView(true, "请求成功", result, list_rst.Count));
  1629. }
  1630. else
  1631. {
  1632. //----------------------------
  1633. List<Excel_SyntheticalReceivableByDateRange> list_Ex = new List<Excel_SyntheticalReceivableByDateRange>();
  1634. WorkbookDesigner designer = new WorkbookDesigner();
  1635. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/应收款项模板 - 副本.xls");
  1636. int excNo = 1;
  1637. foreach (var item in list_rst)
  1638. {
  1639. Excel_SyntheticalReceivableByDateRange exc = new Excel_SyntheticalReceivableByDateRange();
  1640. exc.No = excNo.ToString();
  1641. excNo++;
  1642. exc.TeamName = item.teamName;
  1643. exc.ClientUnit = item.clientUnit;
  1644. exc.VisitDate = item.visitDate;
  1645. exc.Accounts = item.frPrice;
  1646. exc.Extra = item.extraPrice;
  1647. exc.ReceivableTotal = item.receivableTotal;
  1648. exc.Received = item.prPrice;
  1649. exc.RefundAmount = item.refundAmount;
  1650. exc.ReceivedTotal = item.receivedTotal;
  1651. exc.Balance = item.balPrice;
  1652. exc.Collection = item.schedule;
  1653. DateTime time = Convert.ToDateTime(item.visitDate);
  1654. TimeSpan ts = DateTime.Now - time;
  1655. float SY = float.Parse(item.balPrice);
  1656. if (ts.Days >= 365 && SY > 0)
  1657. {
  1658. exc.Sign = "需收款";
  1659. }
  1660. else
  1661. {
  1662. exc.Sign = "";
  1663. }
  1664. list_Ex.Add(exc);
  1665. }
  1666. var dt = CommonFun.GetDataTableFromIList(list_Ex);
  1667. dt.TableName = "Excel_SyntheticalReceivableByDateRange";
  1668. if (dt != null)
  1669. {
  1670. designer.SetDataSource("SumPrice", "应收合计:" + result.total_fr + "RMB 已收合计:" + result.total_pr + "RMB 余款合计:" + result.total_balance + "RMB");
  1671. //数据源
  1672. designer.SetDataSource(dt);
  1673. //根据数据源处理生成报表内容
  1674. designer.Process();
  1675. string fileName = ("Receivable/应收款项(" + dto.beginDt + "~" + dto.endDt + ").xlsx");
  1676. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1677. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1678. return Ok(JsonView(true, "成功", new { url = rst }));
  1679. }
  1680. }
  1681. }
  1682. return Ok(JsonView(true, "获取成功", "", list_rst.Count));
  1683. }
  1684. #endregion
  1685. #region 付款申请
  1686. /// <summary>
  1687. /// 付款申请
  1688. /// 基础数据
  1689. /// </summary>
  1690. /// <param name="dto"></param>
  1691. /// <returns></returns>
  1692. [HttpPost]
  1693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1694. public async Task<IActionResult> PostPayRequestInit()
  1695. {
  1696. try
  1697. {
  1698. var conpanyDatas = _sqlSugar.Queryable<Sys_Company>()
  1699. .Where(it => it.IsDel == 0)
  1700. .Select(it => new
  1701. {
  1702. Id = it.Id,
  1703. ConpamyName = it.CompanyName
  1704. }).ToList();
  1705. return Ok(JsonView(true, "操作成功!", new { ConpanyData = conpanyDatas }));
  1706. }
  1707. catch (Exception ex)
  1708. {
  1709. return Ok(JsonView(false, ex.Message));
  1710. }
  1711. }
  1712. /// <summary>
  1713. /// 付款申请 (PageId=51)
  1714. /// 查询 根据日期范围
  1715. /// </summary>
  1716. /// <param name="dto"></param>
  1717. /// <returns></returns>
  1718. [HttpPost]
  1719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1720. public async Task<IActionResult> PostPayRequest_Center(PostPayRequestByDateRangeDto dto)
  1721. {
  1722. Stopwatch stopwatch = Stopwatch.StartNew();
  1723. #region 验证
  1724. DateTime beginDt, endDt;
  1725. string format = "yyyy-MM-dd";
  1726. if (!DateTime.TryParseExact(dto.beginDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out beginDt))
  1727. {
  1728. return Ok(JsonView(false, "开始日期格式不正确!正确格式:yyyy-MM-dd"));
  1729. }
  1730. if (!DateTime.TryParseExact(dto.endDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out endDt))
  1731. {
  1732. return Ok(JsonView(false, "结束日期格式不正确!正确格式:yyyy-MM-dd"));
  1733. }
  1734. #region 页面操作权限验证
  1735. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1736. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1737. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  1738. #endregion
  1739. #endregion
  1740. try
  1741. {
  1742. PaymentRequestCheckedView checkedView = new PaymentRequestCheckedView();
  1743. var checkedStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("paymentRequestCheckedData");
  1744. if (checkedStr != null)
  1745. {
  1746. checkedView = JsonConvert.DeserializeObject<PaymentRequestCheckedView>(checkedStr.ToString());
  1747. }
  1748. tree_Fin_DailyFeePaymentResult dailyResult = PayRequest_DailyByDateRange(dto.Status, checkedView.DailyPaymentIds, dto.beginDt, dto.endDt);
  1749. tree_Group_DailyFeePaymentResult groupResult = PayRequest_GroupPaymentByDateRange(dto.Status, checkedView.GroupIds, dto.beginDt, dto.endDt);
  1750. stopwatch.Stop();
  1751. return Ok(JsonView(true, $"查询成功!耗时{stopwatch.ElapsedMilliseconds / 1000}s", new { daily = dailyResult, group = groupResult }));
  1752. }
  1753. catch (Exception ex)
  1754. {
  1755. return Ok(JsonView(false, ex.Message));
  1756. }
  1757. }
  1758. /// <summary>
  1759. /// 根据团组类型类型处理团组费用所属公司
  1760. /// </summary>
  1761. /// <param name="teamId"></param>
  1762. /// <returns></returns>
  1763. private CompanyInfo ExpenseCompanyByTeamId(int teamId)
  1764. {
  1765. CompanyInfo _companyInfo = new CompanyInfo();
  1766. List<int> _SiChuan = new List<int>() {
  1767. 38 , // 政府团
  1768. 39 , // 企业团
  1769. 40 , // 散客团
  1770. 102, // 未知
  1771. 248, // 非团组
  1772. 691, // 四川-会务活动
  1773. 762, // 四川-赛事项目收入
  1774. };
  1775. List<int> _ChengDu = new List<int>() {
  1776. 302, // 成都-会务活动
  1777. 1047, // 成都-赛事项目收入
  1778. };
  1779. if (_SiChuan.Contains(teamId))
  1780. {
  1781. _companyInfo.Id = 2;
  1782. _companyInfo.ConpanyName = "四川泛美交流有限公司";
  1783. }
  1784. if (_ChengDu.Contains(teamId))
  1785. {
  1786. _companyInfo.Id = 1;
  1787. _companyInfo.ConpanyName = "成都泛美商务有限公司";
  1788. }
  1789. return _companyInfo;
  1790. }
  1791. /// <summary>
  1792. /// 付款申请(团组费用申请相关)
  1793. /// 查询 根据日期范围
  1794. /// </summary>
  1795. /// <param name="_groupIds"></param>
  1796. /// <param name="beginDt"></param>
  1797. /// <param name="endDt"></param>
  1798. /// <returns></returns>
  1799. private tree_Group_DailyFeePaymentResult PayRequest_GroupPaymentByDateRange(int status, List<int> _groupIds, string beginDt, string endDt)
  1800. {
  1801. tree_Group_DailyFeePaymentResult _DailyFeePaymentResult = new tree_Group_DailyFeePaymentResult();
  1802. List<tree_Group_DailyFeePaymentPageListView> dataList = new List<tree_Group_DailyFeePaymentPageListView>();
  1803. #region sql条件处理
  1804. string sqlWhere = string.Format(@" And (AuditGMDate Between '{0} 00:00:00' And '{1} 23:59:59') ", beginDt, endDt);
  1805. if (status == 2)
  1806. {
  1807. if (_groupIds.Count < 1)
  1808. {
  1809. _DailyFeePaymentResult.dataList = new List<tree_Group_DailyFeePaymentPageListView>();
  1810. return _DailyFeePaymentResult;
  1811. }
  1812. sqlWhere += string.Format(@" And Id In ({0})", string.Join(",", _groupIds));
  1813. }
  1814. string sql_1 = string.Format(@"Select * From Grp_CreditCardPayment Where IsDel = 0 And IsPay = 0 And IsAuditGM = 1 {0}", sqlWhere);
  1815. #endregion
  1816. var _paymentDatas = _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql_1).ToList();//付款信息
  1817. _DailyFeePaymentResult.gz = _paymentDatas.Where(it => it.OrbitalPrivateTransfer == 0).Sum(it => ((it.PayMoney * it.DayRate) / 100) * it.PayPercentage); //公转
  1818. _DailyFeePaymentResult.sz = _paymentDatas.Where(it => it.OrbitalPrivateTransfer == 1).Sum(it => ((it.PayMoney * it.DayRate) / 100) * it.PayPercentage); ; //私转
  1819. List<int> groupIds = _paymentDatas.Select(it => it.DIId).Distinct().ToList();
  1820. var _groupDatas = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && groupIds.Contains(it.Id)).ToList();
  1821. //_groupDatas = (List<Grp_DelegationInfo>)_groupDatas.GroupBy(it => it.TeamDid);
  1822. #region 相关基础数据源
  1823. var userDatas = _sqlSugar.Queryable<Sys_Users>().ToList();
  1824. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToList();
  1825. var countryFeeDatas = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  1826. var hotelDatas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1827. var opDatas = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1828. var visaDatas = _sqlSugar.Queryable<Grp_VisaInfo>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DIId)).ToList();
  1829. var ioaDatas = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1830. var insureDatas = _sqlSugar.Queryable<Grp_Customers>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1831. var airDatas = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DIId)).ToList();
  1832. //var otherMoneyDatas = _sqlSugar.Queryable<Fin_OtherPrice>().Where(it => it.IsDel == 0 && groupIds.Contains(it.Diid)).ToList();
  1833. var otherMoneyDatas = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1834. var refundPaymentDatas = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1835. var ExtraCostDatas = _sqlSugar.Queryable<Fin_GroupExtraCost>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1836. #endregion
  1837. //Expense company
  1838. foreach (var groupInfo in _groupDatas)
  1839. {
  1840. List<Group_DailyFeePaymentContentInfolView> childList = new List<Group_DailyFeePaymentContentInfolView>();
  1841. var groupPaymentDatas = _paymentDatas.Where(it => groupInfo.Id == it.DIId).ToList();
  1842. int rouNumber = 1;
  1843. foreach (var payInfo in groupPaymentDatas)
  1844. {
  1845. string priName = "-";
  1846. string orbitalPrivateTransfer = payInfo.OrbitalPrivateTransfer == 0 ? "公转" : payInfo.OrbitalPrivateTransfer == 1 ? "私转" : "-";
  1847. switch (payInfo.CTable)
  1848. {
  1849. case 76: //76 酒店预订
  1850. priName = $"[费用名称:{hotelDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.HotelName ?? ""}]";
  1851. break;
  1852. case 79: //79 车/导游地接
  1853. var opData = opDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id);
  1854. if (opData != null)
  1855. {
  1856. string area = "";
  1857. bool b = int.TryParse(opData.Area, out int areaId);
  1858. if (b)
  1859. {
  1860. string area1 = countryFeeDatas.Find(it => it.Id == areaId)?.Country ?? "-";
  1861. area = $"{area1}({setDatas.Find(it => it.Id == opData.PriceType)?.Name ?? "-"})";
  1862. }
  1863. else area = opData.Area;
  1864. string opPriName = "-";
  1865. if (!string.IsNullOrEmpty(opData.PriceName)) opPriName = opData.PriceName;
  1866. area += $"({opPriName})";
  1867. if (payInfo.OrbitalPrivateTransfer == 0) //公转
  1868. {
  1869. priName = $"【{orbitalPrivateTransfer}】【导游: {opData.ServiceGuide} 】[费用名称:{area}]";
  1870. }
  1871. else if (payInfo.OrbitalPrivateTransfer == 1) //私转
  1872. {
  1873. priName = $"【{orbitalPrivateTransfer}】【导游:{opData.ServiceGuide}】[费用名称:{area}]";
  1874. }
  1875. }
  1876. break;
  1877. case 80: // 80 签证
  1878. 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);
  1879. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1880. string visaClientName = visaDatas.Find(it => payInfo.DIId == it.DIId && payInfo.CId == it.Id)?.VisaClient ?? "";
  1881. string clientName = "-";
  1882. if (Regex.Match(visaClientName, @"\d+,?").Value.Length > 0)
  1883. {
  1884. string[] temparr = visaClientName.Split(',');
  1885. string fistrStr = temparr[0];
  1886. int count = temparr.Count();
  1887. int tempId;
  1888. bool success = int.TryParse(fistrStr, out tempId);
  1889. if (success)
  1890. {
  1891. SimplClientInfo tempInfo = arr.FirstOrDefault(s => s.Id == tempId);
  1892. if (tempInfo != null)
  1893. {
  1894. if (count > 1)
  1895. {
  1896. clientName = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1897. }
  1898. else
  1899. {
  1900. clientName = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1901. }
  1902. }
  1903. }
  1904. else
  1905. {
  1906. clientName = fistrStr;
  1907. }
  1908. }
  1909. priName = $"[费用名称:{clientName}]";
  1910. break;
  1911. case 81: // 81 邀请/公务活动
  1912. priName = $"[费用名称:{ioaDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.Inviter ?? " -"}]";
  1913. break;
  1914. case 82: // 82 团组客户保险
  1915. priName = $"[费用名称:{insureDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.ClientName ?? " -"}]";
  1916. break;
  1917. case 85: // 85 机票预订
  1918. string flightsCode = airDatas.Find(it => payInfo.DIId == it.DIId && payInfo.CId == it.Id)?.FlightsCode ?? "-";
  1919. string airPayType = setDatas.Find(it => it.Id == payInfo.PayDId)?.Name ?? "-";
  1920. priName = $"{flightsCode}【{airPayType}】";
  1921. break;
  1922. case 98: // 98 其他款项
  1923. priName = $"[费用名称:{otherMoneyDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
  1924. break;
  1925. case 285: // 285 收款退还
  1926. priName = $"[费用名称:{refundPaymentDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
  1927. break;
  1928. case 1015: // 1015 超支费用
  1929. priName = $"[费用名称:{ExtraCostDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
  1930. break;
  1931. default:
  1932. priName = "";
  1933. break;
  1934. }
  1935. //
  1936. bool status1 = false;
  1937. if (_groupIds != null)
  1938. {
  1939. status1 = _groupIds.Contains(payInfo.Id);
  1940. }
  1941. string payeeStr = string.Format(@" {0},开户行:{1},银行卡号:{2} ", string.IsNullOrEmpty(payInfo.Payee) ? "-" : payInfo.Payee,
  1942. string.IsNullOrEmpty(payInfo.OtherBankName) ? "-" : payInfo.OtherBankName,
  1943. string.IsNullOrEmpty(payInfo.OtherSideNo) ? "-" : payInfo.OtherSideNo);
  1944. decimal _PaymentAmount = (payInfo.PayMoney / 100) * payInfo.PayPercentage;//此次付款金额
  1945. decimal _CNYSubTotalAmount = _PaymentAmount * payInfo.DayRate;//此次付款金额
  1946. _CNYSubTotalAmount = Convert.ToDecimal(_CNYSubTotalAmount.ToString("#0.00"));
  1947. var childInfo = new Group_DailyFeePaymentContentInfolView()
  1948. {
  1949. IsChecked = status1,
  1950. Id = payInfo.Id,
  1951. Payee = payeeStr,
  1952. RowNumber = rouNumber,
  1953. Applicant = userDatas.Find(it => it.Id == payInfo.CreateUserId)?.CnName ?? "",
  1954. ApplicantDt = payInfo.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
  1955. PayType = setDatas.Find(it => it.Id == payInfo.PayDId)?.Name ?? "",
  1956. TransferMark = orbitalPrivateTransfer,
  1957. PriceName = priName,
  1958. ModuleName = setDatas.Find(it => it.Id == payInfo.CTable)?.Name ?? "",
  1959. PayCurrCode = setDatas.Find(it => it.Id == payInfo.PaymentCurrency)?.Name ?? "",
  1960. PaymentAmount = _PaymentAmount,
  1961. PayRate = payInfo.DayRate,
  1962. CNYSubTotalAmount = _CNYSubTotalAmount
  1963. };
  1964. //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})";
  1965. 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})";
  1966. childInfo.RemaksDescription = remaksDescription;
  1967. childList.Add(childInfo);
  1968. rouNumber++;
  1969. }
  1970. CompanyInfo companyInfo = new CompanyInfo();
  1971. companyInfo = ExpenseCompanyByTeamId(groupInfo.TeamDid);
  1972. dataList.Add(new tree_Group_DailyFeePaymentPageListView()
  1973. {
  1974. Id = Guid.NewGuid().ToString("N"),
  1975. GroupName = groupInfo.TeamName,
  1976. CompanyId = companyInfo.Id,
  1977. ConpanyName = companyInfo.ConpanyName,
  1978. CNYTotalAmount = childList.Sum(it => it.CNYSubTotalAmount),
  1979. ChildList = childList,
  1980. });
  1981. }
  1982. _DailyFeePaymentResult.dataList = dataList;
  1983. return _DailyFeePaymentResult;
  1984. }
  1985. /// <summary>
  1986. /// 付款申请(日付申请相关)
  1987. /// 查询 根据日期范围
  1988. /// </summary>
  1989. /// <param name="_dailyIds"></param>
  1990. /// <param name="beginDt"></param>
  1991. /// <param name="endDt"></param>
  1992. /// <returns></returns>
  1993. private tree_Fin_DailyFeePaymentResult PayRequest_DailyByDateRange(int status, List<int> _dailyIds, string beginDt, string endDt)
  1994. {
  1995. #region sql条件处理
  1996. string sqlWhere = string.Format(@" And dfp.CreateTime between '{0} 00:00:00' And '{1} 23:59:59' ", beginDt, endDt);
  1997. if (status == 2)
  1998. {
  1999. if (_dailyIds.Count < 1)
  2000. {
  2001. return new tree_Fin_DailyFeePaymentResult() { childList = new List<Fin_DailyFeePaymentContentInfolView>() };
  2002. }
  2003. sqlWhere += string.Format(@" And dfp.Id In({0}) ", string.Join(",", _dailyIds));
  2004. }
  2005. string sql_1 = string.Format(@"Select * From (
  2006. Select row_number() over (order by dfp.Id Desc) as RowNumber,
  2007. dfp.Id,dfp.CompanyId,c.CompanyName,dfp.Instructions,dfp.SumPrice,
  2008. dfp.CreateUserId,u.CnName CreateUser,dfp.CreateTime,dfp.FAudit,dfp.MAudit,
  2009. dfp.PriceTypeId,dfp.TransferTypeId
  2010. From Fin_DailyFeePayment dfp
  2011. Inner Join Sys_Company c On dfp.CompanyId = c.Id
  2012. Left Join Sys_Users u On dfp.CreateUserId = u.Id
  2013. Where dfp.IsDel=0 {0} And dfp.FAudit = 1 And dfp.MAudit = 1 And dfp.IsPay = 0
  2014. ) temp ", sqlWhere);
  2015. #endregion
  2016. List<tree_Fin_DailyFeePaymentPageListView> DailyFeePaymentData = _sqlSugar.SqlQueryable<tree_Fin_DailyFeePaymentPageListView>(sql_1).ToList();
  2017. Dictionary<int, string> dic_setData = new Dictionary<int, string>();
  2018. foreach (var item in DailyFeePaymentData)
  2019. {
  2020. if (_dailyIds != null)
  2021. {
  2022. item.IsChecked = _dailyIds.Contains(item.Id);
  2023. }
  2024. if (dic_setData.ContainsKey(item.PriceTypeId))
  2025. {
  2026. item.priceTypeStr = dic_setData[item.PriceTypeId];
  2027. }
  2028. else
  2029. {
  2030. Sys_SetData sd_priceType = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceTypeId).First();
  2031. if (sd_priceType != null)
  2032. {
  2033. item.priceTypeStr = sd_priceType.Name;
  2034. dic_setData.Add(item.PriceTypeId, sd_priceType.Name);
  2035. }
  2036. }
  2037. if (dic_setData.ContainsKey(item.transferTypeId))
  2038. {
  2039. item.transferTypeIdStr = dic_setData[item.transferTypeId];
  2040. Sys_SetData sd_transfer = _daiRep.Query<Sys_SetData>(s => s.Id == item.transferTypeId).First();
  2041. if (sd_transfer != null)
  2042. {
  2043. item.transferParentId = sd_transfer.STid;
  2044. item.transferParentIdStr = sd_transfer.STid == 0 ? "公转" : sd_transfer.STid == 1 ? "私转" : "";
  2045. }
  2046. }
  2047. else
  2048. {
  2049. Sys_SetData sd_transfer = _daiRep.Query<Sys_SetData>(s => s.Id == item.transferTypeId).First();
  2050. if (sd_transfer != null)
  2051. {
  2052. item.transferTypeIdStr = sd_transfer.Name;
  2053. item.transferParentId = sd_transfer.STid;
  2054. item.transferParentIdStr = sd_transfer.STid == 0 ? "公转" : sd_transfer.STid == 1 ? "私转" : "";
  2055. dic_setData.Add(item.transferTypeId, sd_transfer.Name);
  2056. }
  2057. }
  2058. string feeContentSql = string.Format(@"Select * From Fin_DailyFeePaymentContent
  2059. Where IsDel=0 And DFPId = {0} ", item.Id);
  2060. item.childList = _sqlSugar.SqlQueryable<Fin_DailyFeePaymentContentInfolView>(feeContentSql).ToList();
  2061. int rowNumber = 1;
  2062. foreach (var subItem in item.childList)
  2063. {
  2064. string remaksDescription = $"{rowNumber}、【{item.priceTypeStr}】{item.Instructions}({subItem.PriceName}) CNY:{subItem.ItemTotal.ToString("#0.00")}(单价:{subItem.Price.ToString("#0.00")} * {subItem.Quantity})";
  2065. subItem.RemaksDescription = remaksDescription;
  2066. 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")}】";
  2067. subItem.ExcelRemaksDescription = excelRemaksDescription;
  2068. rowNumber++;
  2069. }
  2070. }
  2071. decimal total_gz = DailyFeePaymentData.Where(s => s.transferParentId == 0).Sum(d => d.SumPrice ?? 0M);
  2072. decimal total_sz = DailyFeePaymentData.Where(s => s.transferParentId == 1).Sum(d => d.SumPrice ?? 0M);
  2073. var result = new tree_Fin_DailyFeePaymentResult() { gz = total_gz, sz = total_sz, dataList = DailyFeePaymentData };
  2074. return result;
  2075. }
  2076. /// <summary>
  2077. /// 付款申请 (PageId=51)
  2078. /// 团组,日付相关费用 选中状态变更
  2079. /// </summary>
  2080. /// <param name="dto"></param>
  2081. /// <returns></returns>
  2082. [HttpPost]
  2083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2084. public async Task<IActionResult> PostPayRequestCheckedChange(PayRequestCheckedChangeDto dto)
  2085. {
  2086. #region 验证
  2087. if (dto.Type < 1 || dto.Type > 2)
  2088. {
  2089. return Ok(JsonView(false, "请传入有效的Type参数! 1 checked 2 清除上次勾选"));
  2090. }
  2091. #endregion
  2092. try
  2093. {
  2094. PaymentRequestCheckedView requestCheckedView = new PaymentRequestCheckedView();
  2095. List<int> groupIds = new List<int>();
  2096. List<int> dailyPaymentIds = new List<int>();
  2097. #region 参数处理
  2098. if (!string.IsNullOrEmpty(dto.GroupIds))
  2099. {
  2100. if (dto.GroupIds.Contains(","))
  2101. {
  2102. groupIds = dto.GroupIds.Split(',').Select(int.Parse).ToList();
  2103. }
  2104. else
  2105. {
  2106. groupIds.Add(int.Parse(dto.GroupIds));
  2107. }
  2108. }
  2109. if (!string.IsNullOrEmpty(dto.DailyPaymentIds))
  2110. {
  2111. if (dto.DailyPaymentIds.Contains(","))
  2112. {
  2113. dailyPaymentIds = dto.DailyPaymentIds.Split(',').Select(int.Parse).ToList();
  2114. }
  2115. else
  2116. {
  2117. dailyPaymentIds.Add(int.Parse(dto.DailyPaymentIds));
  2118. }
  2119. }
  2120. #endregion
  2121. requestCheckedView.GroupIds = groupIds;
  2122. requestCheckedView.DailyPaymentIds = dailyPaymentIds;
  2123. if (dto.Type == 1)
  2124. {
  2125. TimeSpan ts = DateTime.Now.AddDays(180) - DateTime.Now; //设置redis 过期时间 半年(180)
  2126. var status = await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("paymentRequestCheckedData", JsonConvert.SerializeObject(requestCheckedView), ts);
  2127. if (status)
  2128. {
  2129. return Ok(JsonView(true, "操作成功!"));
  2130. }
  2131. }
  2132. else if (dto.Type == 2)
  2133. {
  2134. var status = await RedisRepository.RedisFactory.CreateRedisRepository().KeyDeleteAsync("paymentRequestCheckedData");
  2135. if (status)
  2136. {
  2137. return Ok(JsonView(true, "操作成功!"));
  2138. }
  2139. }
  2140. return Ok(JsonView(false, "操作失败!"));
  2141. }
  2142. catch (Exception ex)
  2143. {
  2144. return Ok(JsonView(false, ex.Message));
  2145. }
  2146. }
  2147. /// <summary>
  2148. /// 付款申请 (PageId=51)
  2149. /// 团组,日付相关费用 汇率变更
  2150. /// </summary>
  2151. /// <param name="dto"></param>
  2152. /// <returns></returns>
  2153. [HttpPost]
  2154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2155. public async Task<IActionResult> PostPayRequestRateChange(PayRequestRateChangeDto dto)
  2156. {
  2157. #region 验证
  2158. DateTime beginDt, endDt;
  2159. string format = "yyyy-MM-dd";
  2160. if (!DateTime.TryParseExact(dto.beginDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out beginDt))
  2161. {
  2162. return Ok(JsonView(false, "开始日期格式不正确!正确格式:yyyy-MM-dd"));
  2163. }
  2164. if (!DateTime.TryParseExact(dto.endDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out endDt))
  2165. {
  2166. return Ok(JsonView(false, "结束日期格式不正确!正确格式:yyyy-MM-dd"));
  2167. }
  2168. if (dto.UserId < 1)
  2169. {
  2170. return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2171. }
  2172. if (dto.Id < 1)
  2173. {
  2174. return Ok(JsonView(false, "请传入有效的Id参数!"));
  2175. }
  2176. if (dto.Rate <= 0)
  2177. {
  2178. return Ok(JsonView(false, "请传入有效的Rate参数!"));
  2179. }
  2180. #endregion
  2181. try
  2182. {
  2183. var status = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2184. .SetColumns(it => it.DayRate == dto.Rate)
  2185. .Where(it => it.Id == dto.Id)
  2186. .ExecuteCommand();
  2187. if (status > 0)
  2188. {
  2189. PaymentRequestCheckedView checkedView = new PaymentRequestCheckedView();
  2190. var checkedStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("paymentRequestCheckedData");
  2191. if (checkedStr != null)
  2192. {
  2193. checkedView = JsonConvert.DeserializeObject<PaymentRequestCheckedView>(checkedStr.ToString());
  2194. }
  2195. tree_Fin_DailyFeePaymentResult dailyResult = PayRequest_DailyByDateRange(1, checkedView.DailyPaymentIds, dto.beginDt, dto.endDt);
  2196. tree_Group_DailyFeePaymentResult groupResult = PayRequest_GroupPaymentByDateRange(1, checkedView.GroupIds, dto.beginDt, dto.endDt);
  2197. decimal _gz = dailyResult.gz + groupResult.gz;
  2198. decimal _sz = dailyResult.sz + groupResult.sz;
  2199. return Ok(JsonView(true, "操作成功!", new { gz = dailyResult, sz = groupResult }));
  2200. }
  2201. return Ok(JsonView(false, "该项汇率修改失败!"));
  2202. }
  2203. catch (Exception ex)
  2204. {
  2205. return Ok(JsonView(false, ex.Message));
  2206. }
  2207. }
  2208. /// <summary>
  2209. /// 付款申请 (PageId=51)
  2210. /// 团组,日付相关费用 付款状态变更
  2211. /// </summary>
  2212. /// <param name="dto"></param>
  2213. /// <returns></returns>
  2214. [HttpPost]
  2215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2216. public async Task<IActionResult> PostPayRequestPayChange(PayRequestPayChangeDto dto)
  2217. {
  2218. if (dto.UserId < 1)
  2219. {
  2220. return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2221. }
  2222. //if (string.IsNullOrEmpty(dto.GroupIds))
  2223. //{
  2224. // return Ok(JsonView(false, "请传入有效的GroupIds参数!"));
  2225. //}
  2226. //if (string.IsNullOrEmpty(dto.DailyPaymentIds))
  2227. //{
  2228. // return Ok(JsonView(false, "请传入有效的DailyPaymentIds参数!"));
  2229. //}
  2230. try
  2231. {
  2232. List<int> groupIds = new List<int>();
  2233. List<int> dailyPaymentIds = new List<int>();
  2234. #region 参数处理
  2235. if (!string.IsNullOrEmpty(dto.GroupIds))
  2236. {
  2237. if (dto.GroupIds.Contains(","))
  2238. {
  2239. groupIds = dto.GroupIds.Split(',').Select(int.Parse).ToList();
  2240. }
  2241. else
  2242. {
  2243. groupIds.Add(int.Parse(dto.GroupIds));
  2244. }
  2245. }
  2246. if (!string.IsNullOrEmpty(dto.DailyPaymentIds))
  2247. {
  2248. if (dto.DailyPaymentIds.Contains(","))
  2249. {
  2250. dailyPaymentIds = dto.DailyPaymentIds.Split(',').Select(int.Parse).ToList();
  2251. }
  2252. else
  2253. {
  2254. dailyPaymentIds.Add(int.Parse(dto.DailyPaymentIds));
  2255. }
  2256. }
  2257. #endregion
  2258. bool changeStatus = false;
  2259. _sqlSugar.BeginTran();
  2260. if (groupIds.Count > 0)
  2261. {
  2262. var groupStatus = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2263. .SetColumns(it => it.IsPay == 1)
  2264. .Where(it => groupIds.Contains(it.Id))
  2265. .ExecuteCommand();
  2266. if (groupStatus > 0)
  2267. {
  2268. changeStatus = true;
  2269. }
  2270. }
  2271. if (dailyPaymentIds.Count > 0)
  2272. {
  2273. var dailyPaymentStatus = _sqlSugar.Updateable<Fin_DailyFeePayment>()
  2274. .SetColumns(it => it.IsPay == 1)
  2275. .Where(it => dailyPaymentIds.Contains(it.Id))
  2276. .ExecuteCommand();
  2277. if (dailyPaymentStatus > 0)
  2278. {
  2279. changeStatus = true;
  2280. }
  2281. }
  2282. if (changeStatus)
  2283. {
  2284. _sqlSugar.CommitTran();
  2285. #region 应用推送
  2286. try
  2287. {
  2288. foreach (int ccpId in groupIds)
  2289. {
  2290. List<string> tempList = new List<string>() { ccpId.ToString() };
  2291. await AppNoticeLibrary.SendUserMsg_GroupStatus_PayResult(ccpId, tempList);
  2292. }
  2293. foreach (int dailyId in dailyPaymentIds)
  2294. {
  2295. List<string> tempList = new List<string>() { dailyId.ToString() };
  2296. await AppNoticeLibrary.DailyPayReminder_Pay_ToUser(dailyId, tempList);
  2297. }
  2298. }
  2299. catch (Exception ex)
  2300. {
  2301. }
  2302. #endregion
  2303. return Ok(JsonView(true, "操作成功!"));
  2304. }
  2305. _sqlSugar.RollbackTran();
  2306. return Ok(JsonView(false, "付款状态修改失败!"));
  2307. }
  2308. catch (Exception ex)
  2309. {
  2310. _sqlSugar.RollbackTran();
  2311. return Ok(JsonView(false, ex.Message));
  2312. }
  2313. }
  2314. /// <summary>
  2315. /// 付款申请 (PageId=51)
  2316. /// File Download
  2317. /// </summary>
  2318. /// <param name="dto"></param>
  2319. /// <returns></returns>
  2320. [HttpPost]
  2321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2322. public async Task<IActionResult> PostPayRequestFileDownload(PayRequestFileDownloadDto dto)
  2323. {
  2324. Stopwatch stopwatch = Stopwatch.StartNew();
  2325. #region 参数,权限 验证
  2326. if (dto.PortType < 1)
  2327. {
  2328. return Ok(JsonView(false, "请传入有效的PortType参数!"));
  2329. }
  2330. if (dto.UserId < 1)
  2331. {
  2332. return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2333. }
  2334. if (dto.PageId < 1)
  2335. {
  2336. dto.PageId = 51;
  2337. return Ok(JsonView(false, "请传入有效的PageId参数!"));
  2338. }
  2339. if (dto.ConpanyId < 1 || dto.ConpanyId > 4)
  2340. {
  2341. return Ok(JsonView(false, "请传入有效的ConpanyId参数!"));
  2342. }
  2343. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2344. #region 页面操作权限验证
  2345. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  2346. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  2347. #endregion
  2348. #endregion
  2349. try
  2350. {
  2351. PaymentRequestCheckedView checkedView = new PaymentRequestCheckedView();
  2352. var checkedStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("paymentRequestCheckedData");
  2353. if (checkedStr != null)
  2354. {
  2355. checkedView = JsonConvert.DeserializeObject<PaymentRequestCheckedView>(checkedStr.ToString());
  2356. }
  2357. if (checkedView == null)
  2358. {
  2359. return Ok(JsonView(false, "没有选中的数据!"));
  2360. }
  2361. if (checkedView.GroupIds == null && checkedView.DailyPaymentIds == null)
  2362. {
  2363. return Ok(JsonView(false, "没有选中的数据!"));
  2364. }
  2365. tree_Fin_DailyFeePaymentResult dailyResult = PayRequest_DailyByDateRange(2, checkedView.DailyPaymentIds, dto.beginDt, dto.endDt);
  2366. tree_Group_DailyFeePaymentResult groupResult = PayRequest_GroupPaymentByDateRange(2, checkedView.GroupIds, dto.beginDt, dto.endDt);
  2367. if (dailyResult.childList == null)
  2368. {
  2369. dailyResult.childList = new List<Fin_DailyFeePaymentContentInfolView>();
  2370. }
  2371. List<tree_Group_DailyFeePaymentPageListView> _GroupData = new List<tree_Group_DailyFeePaymentPageListView>();
  2372. List<tree_Fin_DailyFeePaymentPageListView> _DailyData = new List<tree_Fin_DailyFeePaymentPageListView>();
  2373. //1 成都泛美商务有限公司
  2374. if (dto.ConpanyId == 1)
  2375. {
  2376. if (groupResult.dataList != null && groupResult.dataList.Count > 0) _GroupData = groupResult.dataList.Where(it => it.CompanyId == 1).ToList();
  2377. if (dailyResult.dataList != null && dailyResult.dataList.Count > 0) _DailyData = dailyResult.dataList.Where(it => it.CompanyId == 1).ToList();
  2378. }
  2379. //2 四川泛美交流有限公司
  2380. else if (dto.ConpanyId == 2)
  2381. {
  2382. if (groupResult.dataList != null && groupResult.dataList.Count > 0) _GroupData = groupResult.dataList.Where(it => it.CompanyId == 2).ToList();
  2383. if (dailyResult.dataList != null && dailyResult.dataList.Count > 0) _DailyData = dailyResult.dataList.Where(it => it.CompanyId == 2).ToList();
  2384. }
  2385. //3 成都纽茵教育科技有限公司
  2386. else if (dto.ConpanyId == 3)
  2387. {
  2388. if (groupResult.dataList != null && groupResult.dataList.Count > 0) _GroupData = groupResult.dataList.Where(it => it.CompanyId == 3).ToList();
  2389. if (dailyResult.dataList != null && dailyResult.dataList.Count > 0) _DailyData = dailyResult.dataList.Where(it => it.CompanyId == 3).ToList();
  2390. }
  2391. //4 成都鸿企中元科技有限公司
  2392. else if (dto.ConpanyId == 4)
  2393. {
  2394. return Ok(JsonView(false, "暂未开放该类型!"));
  2395. }
  2396. else
  2397. {
  2398. return Ok(JsonView(false, "参数ConpanyId不可使用!"));
  2399. }
  2400. string _requestPaymentDt = DateTime.Now.ToString("yyyy-MM-dd"),//申请付款日期
  2401. _appliedAmount = "", //申请付款金额
  2402. _GZStr = "", //公转价格描述
  2403. _SZStr = ""; //私转价格描述
  2404. decimal groupGZAmout = 0.00M, groupSZAmout = 0.00M;
  2405. decimal dailyGZAmout = 0.00M, dailySZAmout = 0.00M;
  2406. string dailyGZStr = "", dailySZStr = "", groupGZStr = "", groupSZStr = "";
  2407. #region 数据处理
  2408. //团组费用相关
  2409. foreach (var item in _GroupData)
  2410. {
  2411. string groupGZSubStr = "";
  2412. string groupSZSubStr = "";
  2413. foreach (var subItem in item.ChildList)
  2414. {
  2415. if (subItem.TransferMark.Equals("公转"))
  2416. {
  2417. groupGZAmout += subItem.CNYSubTotalAmount;
  2418. groupGZSubStr += $"{subItem.RemaksDescription}\r\n";
  2419. }
  2420. else if (subItem.TransferMark.Equals("私转"))
  2421. {
  2422. groupSZAmout += subItem.CNYSubTotalAmount;
  2423. groupSZSubStr += $"{subItem.RemaksDescription}\r\n";
  2424. }
  2425. //groupGZSubStr += $"\t";
  2426. }
  2427. //if (!string.IsNullOrEmpty(groupGZSubStr)) groupGZStr += $"团组:{item.GroupName}\r\n{groupGZSubStr}\r\n";
  2428. //if (!string.IsNullOrEmpty(groupSZSubStr)) groupSZStr += $"团组:{item.GroupName}\r\n{groupSZSubStr}\r\n";
  2429. if (!string.IsNullOrEmpty(groupGZSubStr)) groupGZStr += $"{groupGZSubStr}\r\n";
  2430. if (!string.IsNullOrEmpty(groupSZSubStr)) groupSZStr += $"{groupSZSubStr}\r\n";
  2431. }
  2432. //日常费用相关
  2433. foreach (var item in _DailyData)
  2434. {
  2435. foreach (var subItem in item.childList)
  2436. {
  2437. if (item.transferParentId == 62) //公转
  2438. {
  2439. dailyGZAmout += item.SumPrice ?? 0.00M;
  2440. dailyGZStr += $"{item.RowNumber}、【{item.CompanyName}】{subItem.ExcelRemaksDescription}\r\n";
  2441. }
  2442. else if (item.transferParentId == 63) //私转
  2443. {
  2444. dailySZAmout += item.SumPrice ?? 0.00M;
  2445. dailySZStr += $"{item.RowNumber}、【{item.CompanyName}】{subItem.ExcelRemaksDescription}\r\n";
  2446. }
  2447. }
  2448. }
  2449. _GZStr = $"【公转】团组相关费用(合计:CNY {groupGZAmout.ToString("#0.00")}):\r\n{groupGZStr}【公转】日常付款费用(合计:CNY {dailyGZAmout.ToString("#0.00")}):\r\n{dailyGZStr}";
  2450. _SZStr = $"【私转】团组相关费用(合计:CNY {groupSZAmout.ToString("#0.00")}):\r\n{groupSZStr}【私转】日常付款费用(合计:CNY {dailySZAmout.ToString("#0.00")}):\r\n{dailySZStr}";
  2451. _appliedAmount = $"公转:CNY {(groupGZAmout + dailyGZAmout).ToString("#0.00")}\r\n私转:CNY {(groupSZAmout + dailySZAmout).ToString("#0.00")}";
  2452. #endregion
  2453. WorkbookDesigner designer = new WorkbookDesigner();
  2454. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/付款申请书.xls");
  2455. designer.SetDataSource("Date", _requestPaymentDt);
  2456. designer.SetDataSource("Price", _appliedAmount);
  2457. designer.SetDataSource("Content", _GZStr);
  2458. designer.SetDataSource("Content1", _SZStr);
  2459. //根据数据源处理生成报表内容
  2460. designer.Process();
  2461. string fileName = ("PayRequest/付款申请(" + dto.beginDt + "~" + dto.endDt + ").xlsx");
  2462. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2463. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2464. stopwatch.Stop();
  2465. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds / 1000}s", new { url = rst }));
  2466. }
  2467. catch (Exception ex)
  2468. {
  2469. return Ok(JsonView(false, ex.Message));
  2470. }
  2471. }
  2472. #endregion
  2473. #region 超支费用
  2474. /// <summary>
  2475. /// 超支费用
  2476. /// 1增、2改、3删
  2477. /// </summary>
  2478. /// <param name="dto"></param>
  2479. /// <returns></returns>
  2480. [HttpPost]
  2481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2482. public async Task<IActionResult> PostGroupExtraCost_Operator(Fin_GroupExtraCostDto_OP dto)
  2483. {
  2484. #region 验证
  2485. #endregion
  2486. Fin_GroupExtraCost _entity = new Fin_GroupExtraCost();
  2487. _entity.DiId = dto.diId;
  2488. _entity.PriceName = dto.priceName;
  2489. _entity.Price = dto.price;
  2490. _entity.PriceCurrency = dto.currency;
  2491. _entity.PriceType = dto.priceType;
  2492. _entity.Coefficient = dto.coefficient;
  2493. _entity.PriceDetailType = dto.priceDetailType;
  2494. _entity.FilePath = dto.filePath;
  2495. _entity.Remark = dto.remark;
  2496. _entity.PriceCount = dto.PriceCount;
  2497. DateTime dt_PriceDt;
  2498. bool b_PriceDt = DateTime.TryParse(dto.PriceDt, out dt_PriceDt);
  2499. if (b_PriceDt)
  2500. {
  2501. _entity.PriceDt = dt_PriceDt;
  2502. }
  2503. else
  2504. {
  2505. _entity.PriceDt = DateTime.MinValue;
  2506. }
  2507. _entity.PriceSum = dto.price * dto.PriceCount;
  2508. _daiRep.BeginTran();
  2509. if (dto.editType == 1)
  2510. {
  2511. _entity.CreateUserId = dto.createUser;
  2512. _entity.CreateTime = DateTime.Now;
  2513. _entity.IsDel = 0;
  2514. int returnId = await _daiRep.AddAsyncReturnId<Fin_GroupExtraCost>(_entity);
  2515. if (returnId > 0)
  2516. {
  2517. dto.Id = returnId;
  2518. }
  2519. }
  2520. else if (dto.editType == 2)
  2521. {
  2522. bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
  2523. {
  2524. PriceName = dto.priceName,
  2525. Price = dto.price,
  2526. PriceCurrency = dto.currency,
  2527. PriceType = dto.priceType,
  2528. PriceDetailType = dto.priceDetailType,
  2529. Coefficient = dto.coefficient,
  2530. FilePath = dto.filePath,
  2531. Remark = dto.remark,
  2532. PriceCount = dto.PriceCount,
  2533. PriceDt = _entity.PriceDt,
  2534. PriceSum = _entity.PriceSum
  2535. });
  2536. if (!res)
  2537. {
  2538. _daiRep.RollbackTran();
  2539. return Ok(JsonView(false, "2操作失败!"));
  2540. }
  2541. }
  2542. else if (dto.editType == 3)
  2543. {
  2544. string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
  2545. bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
  2546. {
  2547. IsDel = 1,
  2548. DeleteTime = delTime,
  2549. DeleteUserId = dto.createUser
  2550. });
  2551. if (!res)
  2552. {
  2553. _daiRep.RollbackTran();
  2554. return Ok(JsonView(false, "3操作失败!"));
  2555. }
  2556. }
  2557. else
  2558. {
  2559. _daiRep.RollbackTran();
  2560. return Ok(JsonView(false, "未知的editType"));
  2561. }
  2562. if (!extraCost_editCreditCardPayment(dto))
  2563. {
  2564. return Ok(JsonView(false, "ccp操作失败"));
  2565. }
  2566. _daiRep.CommitTran();
  2567. return Ok(JsonView(true, "操作成功"));
  2568. }
  2569. private Result PostCurrencyByDiid_Sync(int diId, int CId, int currencyId)
  2570. {
  2571. if (diId == 0)
  2572. {
  2573. return new Result() { Code = -1, Msg = "请传入团组Id!" };
  2574. }
  2575. if (CId == 0)
  2576. {
  2577. return new Result() { Code = -1, Msg = "请传入类型Id!" };
  2578. }
  2579. if (currencyId == 0)
  2580. {
  2581. return new Result() { Code = -1, Msg = "请传入币种Id!" };
  2582. }
  2583. Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == diId && a.IsDel == 0 && a.CTable == CId);
  2584. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
  2585. CurrencyInfo CurrencyRate = new CurrencyInfo();
  2586. try
  2587. {
  2588. if (_TeamRate != null)
  2589. {
  2590. Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == currencyId);
  2591. if (_SetData != null)
  2592. {
  2593. currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
  2594. CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
  2595. if (CurrencyRate != null)
  2596. {
  2597. return new Result() { Code = 0, Msg = "查询成功!", Data = CurrencyRate };
  2598. }
  2599. else
  2600. {
  2601. return new Result() { Code = -1, Msg = "暂无团组汇率,请前往设置!", Data = CurrencyRate };
  2602. }
  2603. }
  2604. else
  2605. {
  2606. return new Result() { Code = -1, Msg = "暂无团组汇率,请前往设置!", Data = CurrencyRate };
  2607. }
  2608. }
  2609. else
  2610. {
  2611. return new Result() { Code = -1, Msg = "暂无团组汇率,请前往设置!", Data = CurrencyRate };
  2612. }
  2613. }
  2614. catch (Exception)
  2615. {
  2616. return new Result() { Code = -1, Msg = "查询异常!", Data = CurrencyRate };
  2617. }
  2618. }
  2619. private bool extraCost_editCreditCardPayment(Fin_GroupExtraCostDto_OP costDto)
  2620. {
  2621. //设置团组汇率
  2622. decimal dcm_dayrate = 1M;
  2623. decimal dcm_rmbPrice = costDto.price;
  2624. int ispay = costDto.payType == 72 ? 1 : 0;
  2625. if (costDto.costSign != 3)
  2626. {
  2627. //获取新汇率 int diId,int CId, int currencyId
  2628. Result rate = this.PostCurrencyByDiid_Sync(costDto.diId, 1015, costDto.currency);
  2629. if (rate.Code == 0)
  2630. {
  2631. var rateInfo = (rate.Data as CurrencyInfo);
  2632. if (rateInfo is not null)
  2633. {
  2634. dcm_dayrate = rateInfo.Rate;
  2635. dcm_rmbPrice = rateInfo.Rate * dcm_rmbPrice;
  2636. }
  2637. else
  2638. {
  2639. dcm_dayrate = 1;
  2640. }
  2641. }
  2642. }
  2643. Grp_CreditCardPayment ccp = _daiRep.Query<Grp_CreditCardPayment>(s => s.CId == costDto.Id && s.CTable == 1015).First();
  2644. if (ccp == null)
  2645. {
  2646. ccp = new Grp_CreditCardPayment();
  2647. ccp.PayDId = costDto.payType;// dto
  2648. ccp.ConsumptionPatterns = "";
  2649. ccp.ConsumptionDate = "";
  2650. ccp.CTDId = costDto.payCardId;// dto
  2651. ccp.BankNo = "";
  2652. ccp.CardholderName = "";
  2653. ccp.PayMoney = costDto.price;// dto
  2654. ccp.PaymentCurrency = costDto.currency;// dto
  2655. ccp.CompanyBankNo = "";
  2656. ccp.OtherBankName = "";
  2657. ccp.OtherSideNo = "";
  2658. ccp.OtherSideName = "";
  2659. ccp.Remark = "";
  2660. ccp.CreateUserId = costDto.createUser;
  2661. ccp.CreateTime = DateTime.Now;
  2662. ccp.MFOperator = 0;
  2663. ccp.MFOperatorDate = "";
  2664. ccp.IsAuditDM = 0;
  2665. ccp.AuditDMOperate = 0;
  2666. ccp.AuditDMDate = "";
  2667. ccp.IsAuditMF = 0;
  2668. ccp.AuditMFOperate = 0;
  2669. ccp.AuditMFDate = "";
  2670. ccp.IsAuditGM = 0;
  2671. ccp.AuditGMOperate = 0;
  2672. ccp.AuditGMDate = "";
  2673. ccp.IsPay = ispay; // upd
  2674. ccp.DIId = costDto.diId;// dto
  2675. ccp.CId = costDto.Id;// dto
  2676. ccp.CTable = 1015; //超支费用指向id
  2677. ccp.IsDel = 0;
  2678. ccp.PayPercentage = 100M;
  2679. ccp.PayThenMoney = 0M;
  2680. ccp.PayPercentageOld = 100M;
  2681. ccp.PayThenMoneyOld = 0M;
  2682. ccp.UpdateDate = "";
  2683. ccp.Payee = costDto.payee;// dto
  2684. ccp.OrbitalPrivateTransfer = costDto.costSign;// dto
  2685. ccp.ExceedBudget = 0;
  2686. ccp.DayRate = dcm_dayrate; //upd
  2687. ccp.RMBPrice = dcm_rmbPrice; //upd
  2688. int ccpInsertId = _daiRep.AddReturnId<Grp_CreditCardPayment>(ccp);
  2689. if (ccpInsertId > 0)
  2690. {
  2691. return true;
  2692. }
  2693. }
  2694. else
  2695. {
  2696. if (costDto.editType == 2)
  2697. {
  2698. bool res = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
  2699. {
  2700. PayDId = costDto.payType,
  2701. CTDId = costDto.payCardId,
  2702. PayMoney = costDto.price,
  2703. PaymentCurrency = costDto.currency,
  2704. IsPay = ispay,
  2705. Payee = costDto.payee,
  2706. OrbitalPrivateTransfer = costDto.costSign,
  2707. DayRate = dcm_dayrate,
  2708. RMBPrice = dcm_rmbPrice
  2709. });
  2710. return res;
  2711. }
  2712. else if (costDto.editType == 3)
  2713. {
  2714. string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
  2715. bool res2 = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
  2716. {
  2717. IsDel = 1,
  2718. DeleteTime = delTime,
  2719. DeleteUserId = costDto.createUser
  2720. });
  2721. return res2;
  2722. }
  2723. }
  2724. return false;
  2725. }
  2726. /// <summary>
  2727. /// 超支费用
  2728. /// 详情查询
  2729. /// </summary>
  2730. /// <param name="dto"></param>
  2731. /// <returns></returns>
  2732. [HttpPost]
  2733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2734. public async Task<IActionResult> PostGroupExtraCost_Detail(Fin_GroupExtraCostDto_Detail dto)
  2735. {
  2736. if (dto.Id < 1)
  2737. {
  2738. return Ok(JsonView(false, "查询失败"));
  2739. }
  2740. string sql = string.Format(@" Select
  2741. f.Id,f.DiId,
  2742. f.PriceName,f.Price,f.PriceCurrency,c.Payee,c.OrbitalPrivateTransfer,c.PayDId,
  2743. c.CTDId,f.PriceType,f.PriceDetailType,f.Coefficient,f.Remark,f.PriceCount,f.PriceDt
  2744. From Fin_GroupExtraCost f
  2745. Inner Join Grp_CreditCardPayment c On f.Id = c.CId
  2746. Left Join Sys_Users u On f.CreateUserId = u.Id
  2747. Where f.IsDel=0 And c.CTable = 1015
  2748. And f.Id = {0} ", dto.Id);
  2749. Fin_GroupExtraCostDetailView detailView = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostDetailView>(sql).FirstAsync();
  2750. if (detailView == null)
  2751. {
  2752. return Ok(JsonView(false, "查询失败"));
  2753. }
  2754. return Ok(JsonView(true, "查询成功", detailView));
  2755. }
  2756. /// <summary>
  2757. /// 超支费用
  2758. /// 列表查询
  2759. /// </summary>
  2760. /// <param name="dto"></param>
  2761. /// <returns></returns>
  2762. [HttpPost]
  2763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2764. public async Task<IActionResult> PostGroupExtraCost_Search(Fin_GroupExtraCostDto_Search dto)
  2765. {
  2766. string sqlWhere = string.Format(@" And f.DiId = {0} ", dto.diId);
  2767. int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
  2768. int endIndex = startIndex + dto.PageSize - 1;
  2769. string sql_data = string.Format(@"Select * From (
  2770. Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
  2771. 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,
  2772. f.CreateUserId,f.PriceDt,c.IsAuditGM
  2773. From Fin_GroupExtraCost f
  2774. Inner Join Grp_CreditCardPayment c On f.Id = c.CId
  2775. Inner Join Sys_SetData s On f.PriceCurrency = s.Id
  2776. Left Join Sys_Users u On f.CreateUserId = u.Id
  2777. Where f.IsDel=0 And c.CTable = 1015 {0}
  2778. ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
  2779. string sql_count = string.Format(@"Select Count(1) as DataCount From (
  2780. Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
  2781. f.PriceName,f.PriceType,f.Price,f.FilePath,f.CreateUserId,f.CreateTime,c.IsAuditGM
  2782. From Fin_GroupExtraCost f
  2783. Inner Join Grp_CreditCardPayment c On f.Id = c.CId
  2784. Inner Join Sys_SetData s On f.PriceCurrency = s.Id
  2785. Left Join Sys_Users u On f.CreateUserId = u.Id
  2786. Where f.IsDel=0 And c.CTable = 1015 {0}
  2787. ) temp ", sqlWhere);
  2788. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  2789. {
  2790. //Fin_DailyFeePaymentPageCount
  2791. var count = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostViewDataCount>(sql_count).FirstAsync();
  2792. List<Fin_GroupExtraCostView> dataList = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostView>(sql_data).ToListAsync();
  2793. Dictionary<int, string> dic_setData = new Dictionary<int, string>();
  2794. Dictionary<int, string> dic_user = new Dictionary<int, string>();
  2795. foreach (var item in dataList)
  2796. {
  2797. DateTime dtTemp_PriceDt;
  2798. bool b_ct = DateTime.TryParse(item.PriceDt, out dtTemp_PriceDt);
  2799. if (b_ct)
  2800. {
  2801. item.PriceDt = dtTemp_PriceDt.ToString("yyyy-MM-dd");
  2802. }
  2803. //费用类型
  2804. if (dic_setData.ContainsKey(item.PriceType))
  2805. {
  2806. item.PriceTypeStr = dic_setData[item.PriceType];
  2807. }
  2808. else
  2809. {
  2810. Sys_SetData sd_priceTypeDetail = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceType).First();
  2811. if (sd_priceTypeDetail != null)
  2812. {
  2813. string tempName = sd_priceTypeDetail.Name.Replace("n", "");
  2814. item.PriceTypeStr = tempName;
  2815. dic_setData.Add(item.PriceType, tempName);
  2816. }
  2817. }
  2818. if (item.PriceDetailType > 0)
  2819. {
  2820. if (dic_setData.ContainsKey(item.PriceDetailType))
  2821. {
  2822. item.PriceTypeStr = item.PriceTypeStr + " - " + dic_setData[item.PriceDetailType];
  2823. }
  2824. else
  2825. {
  2826. Sys_SetData sd_priceTypeDetail = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceDetailType).First();
  2827. if (sd_priceTypeDetail != null)
  2828. {
  2829. string tempName = sd_priceTypeDetail.Name.Replace("n", "");
  2830. item.PriceTypeStr = item.PriceTypeStr + " - " + tempName;
  2831. dic_setData.Add(item.PriceDetailType, tempName);
  2832. }
  2833. }
  2834. }
  2835. //系统用户
  2836. if (dic_user.ContainsKey(item.CreateUserId))
  2837. {
  2838. item.CreateUserIdStr = dic_user[item.CreateUserId];
  2839. }
  2840. else
  2841. {
  2842. Sys_Users users = _daiRep.Query<Sys_Users>(s => s.Id == item.CreateUserId).First();
  2843. if (users != null)
  2844. {
  2845. item.CreateUserIdStr = users.CnName;
  2846. dic_user.Add(item.CreateUserId, users.CnName);
  2847. }
  2848. }
  2849. switch (item.IsAuditGM)
  2850. {
  2851. case 0: item.IsAuditGMStr = "未审核"; break;
  2852. case 1: item.IsAuditGMStr = "已通过"; break;
  2853. case 2: item.IsAuditGMStr = "未通过"; break;
  2854. default: item.IsAuditGMStr = "未知状态"; break;
  2855. }
  2856. }
  2857. var result = new ListViewBase<Fin_GroupExtraCostView>
  2858. {
  2859. CurrPageIndex = dto.PageIndex,
  2860. CurrPageSize = dto.PageSize,
  2861. DataCount = count.DataCount,
  2862. DataList = dataList
  2863. };
  2864. return Ok(JsonView(true, "查询成功", result));
  2865. }
  2866. return Ok(JsonView(false, "查询失败"));
  2867. }
  2868. /// <summary>
  2869. /// 超支费用
  2870. /// 数据集合配置
  2871. /// </summary>
  2872. /// <param name="dto"></param>
  2873. /// <returns></returns>
  2874. [HttpPost]
  2875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2876. public async Task<IActionResult> PostGroupExtraCost_ListDataInit(Fin_GroupExtraCostDto_DataListInit dto)
  2877. {
  2878. //支付方式
  2879. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  2880. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  2881. //信用卡类型
  2882. List<Sys_SetData> Card = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  2883. List<SetDataInfoView> _Card = _mapper.Map<List<SetDataInfoView>>(Card);
  2884. //超支费用类型
  2885. List<Sys_SetData> PriceType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 79 && a.IsDel == 0).ToList();
  2886. List<SetDataInfoView> _PriceType = _mapper.Map<List<SetDataInfoView>>(PriceType);
  2887. //超支费用详细类型
  2888. List<Sys_SetData> PriceDetailType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 80 && a.IsDel == 0).ToList();
  2889. PriceDetailType.ForEach(a => { a.Name = a.Name.Replace("n", ""); });
  2890. List<SetDataInfoView> _PriceDetailType = _mapper.Map<List<SetDataInfoView>>(PriceDetailType);
  2891. var data = new
  2892. {
  2893. Payment = _Payment,
  2894. Card = _Card,
  2895. PriceType = _PriceType,
  2896. PriceDetailType = _PriceDetailType
  2897. };
  2898. return Ok(JsonView(true, "", data));
  2899. }
  2900. /// <summary>
  2901. /// 超支费用
  2902. /// 导出团组超支费用Excel
  2903. /// </summary>
  2904. /// <param name="dto"></param>
  2905. /// <returns></returns>
  2906. [HttpPost]
  2907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2908. public async Task<IActionResult> PostGroupExtraCost_OutputExcel(Fin_GroupExtraCostExcelDto dto)
  2909. {
  2910. string sqlGroup = string.Format(@" Select * From Grp_DelegationInfo WIth(Nolock) where Id = {0} ", dto.diId);
  2911. Grp_DelegationInfo grp_DelegationInfo = await _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sqlGroup).FirstAsync();
  2912. if (grp_DelegationInfo == null)
  2913. {
  2914. return Ok(JsonView(false, "导出失败,未查询到团组"));
  2915. }
  2916. Workbook workbook = new Workbook();
  2917. Worksheet sheet = workbook.Worksheets[0];
  2918. Cells cells = sheet.Cells;
  2919. //sheet.Protect(Aspose.Cells.ProtectionType.All, "123123", "");//保护工作表
  2920. //sheet.Protection.IsSelectingLockedCellsAllowed = true;//设置只能选择解锁单元格
  2921. //sheet.Protection.IsFormattingColumnsAllowed = true;//设置可以调整列
  2922. //sheet.Protection.IsFormattingRowsAllowed = true;//设置可以调整行
  2923. #region 数据源
  2924. string sqlData = string.Format(@" Select f.PriceType,REPLACE(s2.[Name],'超支费用','') as PriceTypeStr,'('+REPLACE(s3.[Name],'n','')+')' as PriceDetailTypeStr, PriceDt,PriceName,
  2925. Price,PriceCount,s.[Name] as Currency,PriceSum,f.Remark
  2926. From Fin_GroupExtraCost as f With(Nolock)
  2927. Inner Join Grp_CreditCardPayment as c With(Nolock) On f.Id = c.CId
  2928. Inner Join Sys_SetData as s With(Nolock) On f.PriceCurrency = s.Id
  2929. Inner Join Sys_SetData as s2 With(Nolock) On f.PriceType = s2.Id
  2930. Inner Join Sys_SetData as s3 With(Nolock) On f.PriceDetailType = s3.Id
  2931. Where f.DiId = {0} And f.IsDel=0 And c.CTable=1015
  2932. Order by PriceType ASC,PriceDt ASC ", dto.diId);
  2933. string sqlDataCount = string.Format(@" Select f.PriceType,COUNT(f.PriceType) as DataCount
  2934. From Fin_GroupExtraCost as f With(Nolock)
  2935. Inner Join Grp_CreditCardPayment as c With(Nolock) On f.Id = c.CId
  2936. Where f.DiId = {0} And f.IsDel=0 And c.CTable=1015
  2937. Group by PriceType ", dto.diId);
  2938. List<Fin_GroupExtraCost_ExcelView> dataList = await _sqlSugar.SqlQueryable<Fin_GroupExtraCost_ExcelView>(sqlData).ToListAsync();
  2939. List<Fin_GroupExtraCost_ExcelCountView> countList = await _sqlSugar.SqlQueryable<Fin_GroupExtraCost_ExcelCountView>(sqlDataCount).ToListAsync();
  2940. if (dataList.Count < 1 || countList.Count < 1)
  2941. {
  2942. return Ok(JsonView(false, "导出失败,未查询到数据"));
  2943. }
  2944. #endregion
  2945. #region 标题
  2946. string cellValue_Header = grp_DelegationInfo.TeamName;
  2947. //Aspose.Cells.Style style1 = workbook.Styles[workbook.Styles.Add()];//新增样式
  2948. Aspose.Cells.Style style_Header = workbook.CreateStyle();
  2949. style_Header.HorizontalAlignment = TextAlignmentType.Center;//文字居中
  2950. style_Header.VerticalAlignment = TextAlignmentType.Center;
  2951. style_Header.Font.Name = "微软雅黑";//文字字体
  2952. style_Header.Font.Size = 18;//文字大小
  2953. style_Header.IsLocked = false;//单元格解锁
  2954. style_Header.Font.IsBold = false;//粗体
  2955. style_Header.Font.Color = Color.FromArgb(255, 0, 0);
  2956. //style1.ForegroundColor = Color.FromArgb(0x99, 0xcc, 0xff);//设置背景色
  2957. //style1.Pattern = BackgroundType.Solid; //设置背景样式
  2958. //style1.IsTextWrapped = true;//单元格内容自动换行
  2959. style_Header.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //应用边界线 左边界线
  2960. style_Header.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Thin; //应用边界线 右边界线
  2961. style_Header.Borders[Aspose.Cells.BorderType.TopBorder].LineStyle = CellBorderType.Thin; //应用边界线 上边界线
  2962. style_Header.Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //应用边界线 下边界线
  2963. cells.Merge(1, 1, 1, 10);
  2964. Aspose.Cells.Range range_header = cells.CreateRange(1, 1, 1, 10);
  2965. range_header.PutValue(cellValue_Header, false, false);
  2966. range_header.SetStyle(style_Header);
  2967. cells.SetRowHeight(1, 35);
  2968. #endregion
  2969. #region 列名
  2970. Aspose.Cells.Style style_colName = workbook.CreateStyle();
  2971. style_colName.Name = "colName";
  2972. style_colName.HorizontalAlignment = TextAlignmentType.Center;//文字居中
  2973. style_colName.VerticalAlignment = TextAlignmentType.Center;
  2974. style_colName.Font.Name = "微软雅黑";//文字字体
  2975. style_colName.Font.Size = 12;//文字大小
  2976. style_colName.IsLocked = false;//单元格解锁
  2977. style_colName.Font.IsBold = true;//粗体
  2978. style_colName.Font.Color = Color.FromArgb(0, 0, 0);
  2979. style_colName.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //应用边界线 左边界线
  2980. style_colName.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Thin; //应用边界线 右边界线
  2981. style_colName.Borders[Aspose.Cells.BorderType.TopBorder].LineStyle = CellBorderType.Thin; //应用边界线 上边界线
  2982. style_colName.Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //应用边界线 下边界线
  2983. List<Fin_GroupExtraCostExcelColumnSetting> colNameSettingList = new List<Fin_GroupExtraCostExcelColumnSetting>()
  2984. {
  2985. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 1, columnName="类型", columnWidth= 25},
  2986. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 2, columnName="时间", columnWidth= 16},
  2987. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 3, columnName="内容", columnWidth= 35},
  2988. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 4, columnName="单价", columnWidth= 12},
  2989. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 5, columnName="数量", columnWidth= 12},
  2990. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 6, columnName="货币", columnWidth= 12},
  2991. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 7, columnName="费用", columnWidth= 12},
  2992. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 8, columnName="汇率", columnWidth= 12},
  2993. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 9, columnName="人民币", columnWidth= 12},
  2994. new Fin_GroupExtraCostExcelColumnSetting(){ columnIndex = 10, columnName="备注信息", columnWidth= 24}
  2995. };
  2996. foreach (var col in colNameSettingList)
  2997. {
  2998. cells[2, col.columnIndex].PutValue(col.columnName);
  2999. cells[2, col.columnIndex].SetStyle(style_colName);
  3000. cells.SetColumnWidth(col.columnIndex, col.columnWidth);
  3001. }
  3002. cells.SetRowHeight(2, 25);
  3003. #endregion
  3004. #region 数据填充
  3005. Aspose.Cells.Style style_dataCol = workbook.GetNamedStyle("colName");
  3006. style_dataCol.Font.IsBold = false;
  3007. style_dataCol.Name = "dataCol";
  3008. Aspose.Cells.Style style_dataBlue = workbook.CreateStyle();
  3009. style_dataBlue.HorizontalAlignment = TextAlignmentType.Center;//文字居中
  3010. style_dataBlue.VerticalAlignment = TextAlignmentType.Center;
  3011. style_dataBlue.Font.Name = "微软雅黑";//文字字体
  3012. style_dataBlue.Font.Size = 12;//文字大小
  3013. style_dataBlue.IsLocked = false;//单元格解锁
  3014. style_dataBlue.Font.IsBold = false;//粗体
  3015. style_dataBlue.ForegroundColor = Color.FromArgb(189, 215, 238);
  3016. style_dataBlue.Pattern = BackgroundType.Solid;
  3017. style_dataBlue.Font.Color = Color.FromArgb(0, 0, 0);
  3018. style_dataBlue.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //应用边界线 左边界线
  3019. style_dataBlue.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Thin; //应用边界线 右边界线
  3020. style_dataBlue.Borders[Aspose.Cells.BorderType.TopBorder].LineStyle = CellBorderType.Thin; //应用边界线 上边界线
  3021. style_dataBlue.Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //应用边界线 下边界线
  3022. Aspose.Cells.Style style_dataYellow = workbook.CreateStyle();
  3023. style_dataYellow.HorizontalAlignment = TextAlignmentType.Center;//文字居中
  3024. style_dataYellow.VerticalAlignment = TextAlignmentType.Center;
  3025. style_dataYellow.Font.Name = "微软雅黑";//文字字体
  3026. style_dataYellow.Font.Size = 12;//文字大小
  3027. style_dataYellow.IsLocked = false;//单元格解锁
  3028. style_dataYellow.Font.IsBold = false;//粗体
  3029. style_dataYellow.ForegroundColor = Color.FromArgb(255, 242, 204);
  3030. style_dataYellow.Pattern = BackgroundType.Solid;
  3031. style_dataYellow.Font.Color = Color.FromArgb(0, 0, 0);
  3032. style_dataYellow.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //应用边界线 左边界线
  3033. style_dataYellow.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Thin; //应用边界线 右边界线
  3034. style_dataYellow.Borders[Aspose.Cells.BorderType.TopBorder].LineStyle = CellBorderType.Thin; //应用边界线 上边界线
  3035. style_dataYellow.Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //应用边界线 下边界线
  3036. int rowIndex = 4;
  3037. foreach (var d in dataList)
  3038. {
  3039. //内容
  3040. string typeStr = d.PriceDetailTypeStr + d.PriceName;
  3041. cells["B" + rowIndex.ToString()].PutValue(d.PriceTypeStr);
  3042. cells["C" + rowIndex.ToString()].PutValue(d.PriceDtStr);
  3043. cells["D" + rowIndex.ToString()].PutValue(typeStr);
  3044. cells["E" + rowIndex.ToString()].PutValue(d.Price.ToString("#0.00"));
  3045. cells["F" + rowIndex.ToString()].PutValue(d.PriceCount);
  3046. cells["G" + rowIndex.ToString()].PutValue(d.Currency);
  3047. cells["H" + rowIndex.ToString()].PutValue(d.PriceSum.ToString("#0.00"));
  3048. cells["K" + rowIndex.ToString()].PutValue(d.Remark);
  3049. //样式
  3050. cells["B" + rowIndex.ToString()].SetStyle(style_dataCol);
  3051. cells["C" + rowIndex.ToString()].SetStyle(style_dataCol);
  3052. cells["D" + rowIndex.ToString()].SetStyle(style_dataCol);
  3053. cells["E" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3054. cells["F" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3055. cells["G" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3056. cells["H" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3057. cells["I" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3058. cells["J" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3059. cells["K" + rowIndex.ToString()].SetStyle(style_dataYellow);
  3060. //公式
  3061. cells["H" + rowIndex.ToString()].Formula = string.Format(@"E{0}*F{0}", rowIndex);
  3062. cells["J" + rowIndex.ToString()].Formula = string.Format(@"H{0}*I{0}", rowIndex);
  3063. cells.SetRowHeight(rowIndex - 1, 25);
  3064. rowIndex++;
  3065. }
  3066. cells["B" + rowIndex.ToString()].SetStyle(style_dataCol);
  3067. cells["C" + rowIndex.ToString()].SetStyle(style_dataCol);
  3068. cells["D" + rowIndex.ToString()].SetStyle(style_dataCol);
  3069. cells["E" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3070. cells["F" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3071. cells["G" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3072. cells["H" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3073. cells["I" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3074. cells["J" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3075. cells["K" + rowIndex.ToString()].SetStyle(style_dataYellow);
  3076. rowIndex++;
  3077. cells["B" + rowIndex.ToString()].SetStyle(style_dataCol);
  3078. cells["C" + rowIndex.ToString()].SetStyle(style_dataCol);
  3079. cells["D" + rowIndex.ToString()].SetStyle(style_dataCol);
  3080. cells["E" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3081. cells["F" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3082. cells["G" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3083. cells["H" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3084. cells["I" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3085. cells["J" + rowIndex.ToString()].SetStyle(style_dataBlue);
  3086. cells["K" + rowIndex.ToString()].SetStyle(style_dataYellow);
  3087. rowIndex = 3;
  3088. int tempPriceType = 0;
  3089. foreach (var c in dataList)
  3090. {
  3091. if (tempPriceType == c.PriceType)
  3092. {
  3093. continue;
  3094. }
  3095. tempPriceType = c.PriceType;
  3096. int _rowCount = countList.First(s => s.PriceType == tempPriceType).DataCount;
  3097. cells.Merge(rowIndex, 1, _rowCount, 1);
  3098. Aspose.Cells.Range tempRange = cells.CreateRange(rowIndex, 1, _rowCount, 1);
  3099. rowIndex += _rowCount;
  3100. }
  3101. rowIndex = 4 + dataList.Count;
  3102. cells["D" + rowIndex.ToString()].PutValue("合计");
  3103. cells["J" + rowIndex.ToString()].Formula = string.Format(@"SUM(J4,J{0})", rowIndex - 1);
  3104. cells.SetRowHeight(rowIndex - 1, 25);
  3105. rowIndex++;
  3106. cells["D" + rowIndex.ToString()].PutValue("服务费10%开票税金8%");
  3107. cells["J" + rowIndex.ToString()].Formula = string.Format(@"J{0}*1.1*1.08", rowIndex - 1);
  3108. cells.SetRowHeight(rowIndex - 1, 25);
  3109. #endregion
  3110. #region IO
  3111. System.IO.MemoryStream ms = workbook.SaveToStream();//生成数据流
  3112. string fileName = ("GroupExtraCost/超支费用(" + cellValue_Header + ").xlsx");
  3113. byte[] bt = ms.ToArray();
  3114. workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3115. #endregion
  3116. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3117. return Ok(JsonView(true, "成功", new { url = rst }));
  3118. }
  3119. #endregion
  3120. }
  3121. }