FinancialController.cs 157 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569
  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. }