FinancialController.cs 116 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804
  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. namespace OASystem.API.Controllers
  32. {
  33. /// <summary>
  34. /// 财务模块
  35. /// </summary>
  36. [Route("api/[controller]/[action]")]
  37. [ApiController]
  38. public class FinancialController : ControllerBase
  39. {
  40. private readonly IMapper _mapper;
  41. private readonly IConfiguration _config;
  42. private readonly SqlSugarClient _sqlSugar;
  43. private readonly HttpClient _httpClient;
  44. private readonly SetDataTypeRepository _setDataTypeRep;
  45. private readonly DailyFeePaymentRepository _daiRep; //日付申请仓库
  46. private readonly TeamRateRepository _teamRateRep; //团组汇率仓库
  47. private readonly ForeignReceivablesRepository _ForForeignReceivablesRep; //对外收款账单仓库
  48. private readonly ProceedsReceivedRepository _proceedsReceivedRep; //已收款项仓库
  49. private readonly PaymentRefundAndOtherMoneyRepository _paymentRefundAndOtherMoneyRep; //收款退还与其他款项 仓库
  50. /// <summary>
  51. /// 初始化
  52. /// </summary>
  53. public FinancialController(IMapper mapper, IConfiguration configuration, DailyFeePaymentRepository daiRep, SqlSugarClient sqlSugar, SetDataTypeRepository setDataTypeRep,
  54. TeamRateRepository teamRateRep, ForeignReceivablesRepository ForForeignReceivablesRep, ProceedsReceivedRepository proceedsReceivedRep,
  55. PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep, HttpClient httpClient)
  56. {
  57. _mapper = mapper;
  58. _config = configuration;
  59. _daiRep = daiRep;
  60. _sqlSugar = sqlSugar;
  61. _setDataTypeRep = setDataTypeRep;
  62. _teamRateRep = teamRateRep;
  63. _ForForeignReceivablesRep = ForForeignReceivablesRep;
  64. _proceedsReceivedRep = proceedsReceivedRep;
  65. _paymentRefundAndOtherMoneyRep = paymentRefundAndOtherMoneyRep;
  66. _httpClient = httpClient;
  67. }
  68. #region 日付申请
  69. /// <summary>
  70. /// 获取日付申请 基础数据源
  71. /// </summary>
  72. /// <param name="dto"> 日付申请 分页 dto</param>
  73. /// <returns></returns>
  74. [HttpPost]
  75. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  76. public async Task<IActionResult> PostPageSearchDailyPaymentPriceTypeData(PortDtoBase dto)
  77. {
  78. var result = await _daiRep.GetPagePriceTypeData(dto);
  79. if (result == null || result.Code != 0)
  80. {
  81. return Ok(JsonView(false, result.Msg));
  82. }
  83. var data = result.Data;
  84. return Ok(JsonView(data));
  85. }
  86. /// <summary>
  87. /// 获取日付申请 基础数据源 - 转账表识
  88. /// </summary>
  89. /// <param name="dto"> 日付申请 分页 dto</param>
  90. /// <returns></returns>
  91. [HttpPost]
  92. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  93. public async Task<IActionResult> GetSearchDailyPaymentPriceTypeAddData(PortDtoBase dto)
  94. {
  95. var result = await _daiRep.GetPriceTypeAddData(dto);
  96. if (result == null || result.Code != 0)
  97. {
  98. return Ok(JsonView(false, result.Msg));
  99. }
  100. var data = result.Data;
  101. return Ok(JsonView(data));
  102. }
  103. /// <summary>
  104. /// 日付申请 Page Search
  105. /// </summary>
  106. /// <param name="dto"> 日付申请 分页 dto</param>
  107. /// <returns></returns>
  108. [HttpPost]
  109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  110. public async Task<IActionResult> PostPageSearchDailyPaymentList(PageDailyFeePaymentDto dto)
  111. {
  112. var result = await _daiRep.GetPageSearchAll(dto);
  113. if (result == null || result.Code != 0)
  114. {
  115. return Ok(JsonView(false, result.Msg));
  116. }
  117. var data = result.Data;
  118. if (data == null)
  119. {
  120. return Ok(JsonView(false, result.Msg));
  121. }
  122. return Ok(JsonView(data));
  123. }
  124. /// <summary>
  125. /// 日付申请 Single Search By Id
  126. /// </summary>
  127. /// <param name="dto"></param>
  128. /// <returns></returns>
  129. [HttpPost]
  130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  131. public async Task<IActionResult> PostSearchDailyPaymentInfo(SearchDailyFeePaymentDto dto)
  132. {
  133. var result = await _daiRep.GetSearchById(dto);
  134. if (result == null || result.Code != 0)
  135. {
  136. return Ok(JsonView(false, result.Msg));
  137. }
  138. return Ok(JsonView(result.Data));
  139. }
  140. /// <summary>
  141. /// 日付申请 添加
  142. /// </summary>
  143. /// <param name="dto"> 日付申请 添加 dto</param>
  144. /// <returns></returns>
  145. [HttpPost]
  146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  147. public async Task<IActionResult> PostAddDailyPayment(AddDailyFeePaymentDto dto)
  148. {
  149. var result = await _daiRep.Add(dto);
  150. if (result == null || result.Code != 0)
  151. {
  152. return Ok(JsonView(false, result.Msg));
  153. }
  154. return Ok(JsonView(true));
  155. }
  156. /// <summary>
  157. /// 日付申请 Update
  158. /// </summary>
  159. /// <param name="dto"> 日付申请 修改 dto</param>
  160. /// <returns></returns>
  161. [HttpPost]
  162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  163. public async Task<IActionResult> PostEditDailyPayment(EditDailyFeePaymentDto dto)
  164. {
  165. var result = await _daiRep.Edit(dto);
  166. if (result == null || result.Code != 0)
  167. {
  168. return Ok(JsonView(false, result.Msg));
  169. }
  170. return Ok(JsonView(true));
  171. }
  172. /// <summary>
  173. /// 日付申请 Del
  174. /// </summary>
  175. /// <param name="dto"> 日付申请 删除 dto</param>
  176. /// <returns></returns>
  177. [HttpPost]
  178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  179. public async Task<IActionResult> PostDelDailyPayment(DelDailyFeePaymentDto dto)
  180. {
  181. var result = await _daiRep.Del(dto);
  182. if (result == null || result.Code != 0)
  183. {
  184. return Ok(JsonView(false, result.Msg));
  185. }
  186. return Ok(JsonView(true));
  187. }
  188. /// <summary>
  189. /// 日付申请 财务审核
  190. /// </summary>
  191. /// <param name="dto"> dto </param>
  192. /// <returns></returns>
  193. [HttpPost]
  194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  195. public async Task<IActionResult> PostDelDailyPaymentAudit(DP_AuditStatusDto dto)
  196. {
  197. var result = await _daiRep.DelDailyPaymentAudit(dto);
  198. if (result == null || result.Code != 0)
  199. {
  200. return Ok(JsonView(false, result.Msg));
  201. }
  202. return Ok(JsonView(true));
  203. }
  204. /// <summary>
  205. /// 日付申请 Single Excel Download
  206. /// </summary>
  207. /// <param name="dto"> dto </param>
  208. /// <returns></returns>
  209. [HttpPost]
  210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  211. public async Task<IActionResult> PostExcelDailyPaymentDownload(SearchDailyFeePaymentDto dto)
  212. {
  213. if (dto.PortType == 1 || dto.PortType == 2)
  214. {
  215. Fin_DailyFeePaymentInfolView feeData = new Fin_DailyFeePaymentInfolView();
  216. string feeSql = string.Format(@"Select * From Fin_DailyFeePayment
  217. Where IsDel=0 And Id = {0} ", dto.Id);
  218. feeData = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentInfolView>(feeSql).FirstAsync();
  219. if (feeData == null)
  220. {
  221. return Ok(JsonView(false, "暂无数据!"));
  222. }
  223. string feeContentSql = string.Format(@"Select * From Fin_DailyFeePaymentContent
  224. Where IsDel=0 And DFPId = {0} ", dto.Id);
  225. feeData.FeeContents = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentContentInfolView>(feeContentSql).ToListAsync();
  226. if (feeData != null)
  227. {
  228. string userName = string.Empty;
  229. string userSql = string.Format("Select * From Sys_Users Where Id={0} And Isdel = {1}", feeData.CreateUserId, 0);
  230. Sys_Users user = await _sqlSugar.SqlQueryable<Sys_Users>(userSql).FirstAsync();
  231. if (user != null) { userName = user.CnName; }
  232. var setData = _setDataTypeRep.QueryDto<Sys_SetData, Fin_DailyFeePaymentPagePriceSubTypeView>().ToList();
  233. //48人员费用 49办公费用 50 销售费用 51 其他费用 55 大运会
  234. var priceSubTypeData = setData.Where(s => s.STid == 55).ToList();
  235. Dictionary<string, object> pairs = new Dictionary<string, object>();
  236. List<DataTable> datas = new List<DataTable>();
  237. //if (priceSubTypeData.Where(s => s.Id == feeData.PriceTypeId).ToList().Count() > 0)//大运会专属模板
  238. //{
  239. // //AsposeHelper.ExpertExcelToModel("日常费用付款申请模板-大运会数据.xls", "DailyPayment", "大运会所有日常费用付款申请.xls",
  240. // // pairs, datas);
  241. //}
  242. //else //日付常规模板
  243. //{
  244. pairs.Clear();
  245. pairs.Add("Opertor", userName);
  246. pairs.Add("DateTime", feeData.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  247. pairs.Add("FAuditStatus", feeData.FAuditDesc);
  248. pairs.Add("MAuditStatus", feeData.MAuditDesc);
  249. pairs.Add("SumPrice", feeData.SumPrice);
  250. DataTable data = AsposeHelper.ListToDataTable("DailyFeePayment", feeData.FeeContents);
  251. datas.Clear();
  252. datas.Add(data);
  253. string fileName = string.Format("{0}-日常费用付款申请.xlsx", feeData.Instructions);
  254. string msg = AsposeHelper.ExpertExcelToModel("日常费用付款申请模板.xlsx", "DailyPayment", fileName, pairs, datas);
  255. return Ok(JsonView(true, msg));
  256. //}
  257. }
  258. else
  259. {
  260. return Ok(JsonView(false, "暂无数据!"));
  261. }
  262. }
  263. return Ok(JsonView(true));
  264. }
  265. #endregion
  266. #region 团组提成
  267. /// <summary>
  268. /// 提成 Page Search
  269. /// </summary>
  270. /// <param name="dto"> 提成 分页 dto</param>
  271. /// <returns></returns>
  272. [HttpPost]
  273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  274. public async Task<IActionResult> PostPageSearchCommissionList(GroupCommissionDto dto)
  275. {
  276. var data = await GroupCommission.GetCommissionPageList(dto);
  277. return Ok(JsonView(data.Data));
  278. }
  279. #endregion
  280. #region 团组汇率
  281. /// <summary>
  282. /// 团组汇率 Select数据源(团组列,汇率列)
  283. /// </summary>
  284. /// <param name="dto"></param>
  285. /// <returns></returns>
  286. [HttpPost]
  287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  288. public async Task<IActionResult> GetGroupRateDataSources(TeamRateDto dto)
  289. {
  290. try
  291. {
  292. Result teamRateData = await _teamRateRep.GetGroupRateDataSource(dto);
  293. if (teamRateData.Code != 0)
  294. {
  295. return Ok(JsonView(false, teamRateData.Msg));
  296. }
  297. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  298. }
  299. catch (Exception ex)
  300. {
  301. return Ok(JsonView(false, ex.Message));
  302. throw;
  303. }
  304. }
  305. ///// <summary>
  306. ///// 团组汇率 changge
  307. ///// </summary>
  308. ///// <returns></returns>
  309. //[HttpPost]
  310. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. //public async Task<IActionResult> ChangeGroupRateInfo()
  312. //{
  313. // try
  314. // {
  315. // Result teamRateData = await _teamRateRep.GetGroupRateChangeData();
  316. // if (teamRateData.Code != 0)
  317. // {
  318. // return Ok(JsonView(false, teamRateData.Msg));
  319. // }
  320. // return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  321. // }
  322. // catch (Exception ex)
  323. // {
  324. // return Ok(JsonView(false, ex.Message));
  325. // throw;
  326. // }
  327. //}
  328. /// <summary>
  329. /// 团组汇率 Select汇率详情
  330. /// </summary>
  331. /// <param name="dto"></param>
  332. /// <returns></returns>
  333. [HttpPost]
  334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  335. public async Task<IActionResult> GetGroupRateInfo(TeamRateInfoDto dto)
  336. {
  337. try
  338. {
  339. Result teamRateData = await _teamRateRep.GetGroupRateInfoByDiid(dto);
  340. if (teamRateData.Code != 0)
  341. {
  342. return Ok(JsonView(false, teamRateData.Msg));
  343. }
  344. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  345. }
  346. catch (Exception ex)
  347. {
  348. return Ok(JsonView(false, ex.Message));
  349. throw;
  350. }
  351. }
  352. /// <summary>
  353. /// 团组汇率 添加 or 更新
  354. /// </summary>
  355. /// <param name="dto"></param>
  356. /// <returns></returns>
  357. [HttpPost]
  358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  359. public async Task<IActionResult> PostGroupRateUpdate(TeamRateUpdateDto dto)
  360. {
  361. try
  362. {
  363. Result teamRateData = await _teamRateRep.PostGroupRateUpdate(dto);
  364. if (teamRateData.Code != 0)
  365. {
  366. return Ok(JsonView(false, teamRateData.Msg));
  367. }
  368. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  369. }
  370. catch (Exception ex)
  371. {
  372. return Ok(JsonView(false, ex.Message));
  373. throw;
  374. }
  375. }
  376. #endregion
  377. #region 对外收款账单 关联已收款项
  378. /// <summary>
  379. /// 对外收款账单 Select数据源(团组名,币种,汇款方式)
  380. /// 关联已收款项
  381. /// </summary>
  382. /// <param name="dto"></param>
  383. /// <returns></returns>
  384. [HttpPost]
  385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  386. public async Task<IActionResult> GetForeignReceivablesDataSources()
  387. {
  388. try
  389. {
  390. Result ffrData = await _ForForeignReceivablesRep.GetDataSource();
  391. if (ffrData.Code != 0)
  392. {
  393. return Ok(JsonView(false, ffrData.Msg));
  394. }
  395. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  396. }
  397. catch (Exception ex)
  398. {
  399. return Ok(JsonView(false, ex.Message));
  400. throw;
  401. }
  402. }
  403. /// <summary>
  404. /// 对外收款账单
  405. /// 账单详情
  406. /// 关联已收款项
  407. /// </summary>
  408. /// <param name="dto"></param>
  409. /// <returns></returns>
  410. [HttpPost]
  411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  412. public async Task<IActionResult> GetGroupReceivablesInfoByDiId(ForForeignReceivablesInfoDto dto)
  413. {
  414. try
  415. {
  416. Result ffrData = await _ForForeignReceivablesRep.GetGroupReceivablesInfoByDiId(dto);
  417. if (ffrData.Code != 0)
  418. {
  419. return Ok(JsonView(false, ffrData.Msg));
  420. }
  421. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  422. }
  423. catch (Exception ex)
  424. {
  425. return Ok(JsonView(false, ex.Message));
  426. throw;
  427. }
  428. }
  429. /// <summary>
  430. /// 对外收款账单
  431. /// 账单 删除
  432. /// 关联已收款项
  433. /// </summary>
  434. /// <param name="dto"></param>
  435. /// <returns></returns>
  436. [HttpPost]
  437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  438. public async Task<IActionResult> PostGroupReceivablesDel(DelForForeignReceivablesInfoDto dto)
  439. {
  440. try
  441. {
  442. Result ffrData = await _ForForeignReceivablesRep._Del(dto);
  443. if (ffrData.Code != 0)
  444. {
  445. return Ok(JsonView(false, ffrData.Msg));
  446. }
  447. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  448. }
  449. catch (Exception ex)
  450. {
  451. return Ok(JsonView(false, ex.Message));
  452. throw;
  453. }
  454. }
  455. /// <summary>
  456. /// 对外收款账单
  457. /// 添加 And 更新
  458. /// 关联已收款项
  459. /// </summary>
  460. /// <param name="dto"></param>
  461. /// <returns></returns>
  462. [HttpPost]
  463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  464. public async Task<IActionResult> PostReceivablesOperate(ForeignReceivablesAddAndUpdateDto dto)
  465. {
  466. try
  467. {
  468. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesOperate(dto);
  469. if (ffrData.Code != 0)
  470. {
  471. return Ok(JsonView(false, ffrData.Msg));
  472. }
  473. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  474. }
  475. catch (Exception ex)
  476. {
  477. return Ok(JsonView(false, ex.Message));
  478. throw;
  479. }
  480. }
  481. /// <summary>
  482. /// 已收款项
  483. /// 账单 删除
  484. /// 关联已收款项
  485. /// </summary>
  486. /// <param name="dto"></param>
  487. /// <returns></returns>
  488. [HttpPost]
  489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  490. public async Task<IActionResult> PostAmountReceivedDel(ProceedsReceivedDelDto dto)
  491. {
  492. try
  493. {
  494. Result ffrData = await _proceedsReceivedRep._Del(dto);
  495. if (ffrData.Code != 0)
  496. {
  497. return Ok(JsonView(false, ffrData.Msg));
  498. }
  499. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  500. }
  501. catch (Exception ex)
  502. {
  503. return Ok(JsonView(false, ex.Message));
  504. throw;
  505. }
  506. }
  507. /// <summary>
  508. /// 已收款项
  509. /// 添加 And 更新
  510. /// 关联已收款项
  511. /// </summary>
  512. /// <param name="dto"></param>
  513. /// <returns></returns>
  514. [HttpPost]
  515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  516. public async Task<IActionResult> PostAmountReceivedOperate(ProceedsReceivedDto dto)
  517. {
  518. try
  519. {
  520. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedOperate(dto);
  521. if (ffrData.Code != 0)
  522. {
  523. return Ok(JsonView(false, ffrData.Msg));
  524. }
  525. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  526. }
  527. catch (Exception ex)
  528. {
  529. return Ok(JsonView(false, ex.Message));
  530. throw;
  531. }
  532. }
  533. /// <summary>
  534. /// 财务 已收款项
  535. /// 分配已收款项至 应收项下
  536. /// 关联已收款项
  537. /// </summary>
  538. /// <param name="dto"></param>
  539. /// <returns></returns>
  540. [HttpPost]
  541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  542. public async Task<IActionResult> PostAllocateAmountReceived(AllocateAmountReceivedDto dto)
  543. {
  544. try
  545. {
  546. Result ffrData = await _proceedsReceivedRep.PostAllocateAmountReceived(dto);
  547. if (ffrData.Code != 0)
  548. {
  549. return Ok(JsonView(false, ffrData.Msg));
  550. }
  551. return Ok(JsonView(true));
  552. }
  553. catch (Exception ex)
  554. {
  555. return Ok(JsonView(false, ex.Message));
  556. throw;
  557. }
  558. }
  559. ///// <summary>
  560. ///// 财务 收款账单
  561. ///// 导出Word(北京,四川)
  562. ///// </summary>
  563. ///// <param name="dto"></param>
  564. ///// <returns></returns>
  565. //[HttpPost]
  566. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  567. //public async Task<IActionResult> PostAccountReceivableWordExport(AccountReceivableWordExportDto dto)
  568. //{
  569. // try
  570. // {
  571. // //模板处理
  572. // string typeName = string.Empty;
  573. // if (dto.TemplateType == 1) //四川
  574. // {
  575. // typeName = "四川";
  576. // }
  577. // else if (dto.TemplateType == 2) //北京
  578. // {
  579. // typeName = "北京";
  580. // }
  581. // else return Ok(JsonView(false,"请选择正确的模板类型!"));
  582. // string wordTempName = string.Format("收款账单({0})模板.doc", typeName);
  583. // }
  584. // catch (Exception ex)
  585. // {
  586. // return Ok(JsonView(false, ex.Message));
  587. // }
  588. //}
  589. #endregion
  590. #region 对外收款账单
  591. /// <summary>
  592. /// 对外收款账单
  593. /// 数据源
  594. /// </summary>
  595. /// <param name="dto"></param>
  596. /// <returns></returns>
  597. [HttpPost]
  598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  599. public async Task<IActionResult> PostGroupReceivablesDataSource()
  600. {
  601. try
  602. {
  603. Result ffrData = await _ForForeignReceivablesRep.PostDataSource();
  604. if (ffrData.Code != 0)
  605. {
  606. return Ok(JsonView(false, ffrData.Msg));
  607. }
  608. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  609. }
  610. catch (Exception ex)
  611. {
  612. return Ok(JsonView(false, ex.Message));
  613. }
  614. }
  615. /// <summary>
  616. /// 对外收款账单
  617. /// 账单详情
  618. /// </summary>
  619. /// <param name="dto"></param>
  620. /// <returns></returns>
  621. [HttpPost]
  622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  623. public async Task<IActionResult> PostGroupReceivablesInfoByDiId(ForForeignReceivablesNewDto dto)
  624. {
  625. try
  626. {
  627. Result ffrData = await _ForForeignReceivablesRep.PostGroupReceivablesInfoByDiId(dto);
  628. if (ffrData.Code != 0)
  629. {
  630. return Ok(JsonView(false, ffrData.Msg));
  631. }
  632. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  633. }
  634. catch (Exception ex)
  635. {
  636. return Ok(JsonView(false, ex.Message));
  637. }
  638. }
  639. /// <summary>
  640. /// 对外收款账单
  641. /// 添加 And 更新
  642. /// </summary>
  643. /// <param name="dto"></param>
  644. /// <returns></returns>
  645. [HttpPost]
  646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  647. public async Task<IActionResult> PostReceivablesSave(ForeignReceivablesSaveDto dto)
  648. {
  649. try
  650. {
  651. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesSave(dto);
  652. if (ffrData.Code != 0)
  653. {
  654. return Ok(JsonView(false, ffrData.Msg));
  655. }
  656. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  657. }
  658. catch (Exception ex)
  659. {
  660. return Ok(JsonView(false, ex.Message));
  661. throw;
  662. }
  663. }
  664. /// <summary>
  665. /// 已收账单
  666. /// 删除
  667. /// </summary>
  668. /// <param name="dto"></param>
  669. /// <returns></returns>
  670. [HttpPost]
  671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  672. public async Task<IActionResult> PostReceivablesDel(ForeignReceivablesDelDto dto)
  673. {
  674. try
  675. {
  676. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesDel(dto);
  677. if (ffrData.Code != 0)
  678. {
  679. return Ok(JsonView(false, ffrData.Msg));
  680. }
  681. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  682. }
  683. catch (Exception ex)
  684. {
  685. return Ok(JsonView(false, ex.Message));
  686. throw;
  687. }
  688. }
  689. /// <summary>
  690. /// 已收账单
  691. /// File Downloasd
  692. /// </summary>
  693. /// <param name="dto"></param>
  694. /// <returns></returns>
  695. [HttpPost]
  696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  697. public async Task<IActionResult> PostReceivablesFeilDownload(ForeignReceivablesFeilDownloadDto dto)
  698. {
  699. try
  700. {
  701. if (dto.DiId < 1)
  702. {
  703. return Ok(JsonView(false, "请传入有效DiId参数!"));
  704. }
  705. if (dto.FileType < 1 || dto.FileType > 3)
  706. {
  707. return Ok(JsonView(false, "请传入有效FileType参数! 1 生成收款单(四川) 2 生成收款单(北京) 3 汇款账单"));
  708. }
  709. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  710. if (_DelegationInfo == null)
  711. {
  712. return Ok(JsonView(false, "暂无团组信息!!"));
  713. }
  714. if (dto.FileType == 1 || dto.FileType == 2)
  715. {
  716. var _ForeignReceivables = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  717. if (_ForeignReceivables.Count < 1)
  718. {
  719. return Ok(JsonView(false, "暂无收款信息!!"));
  720. }
  721. string tempName = "";
  722. if (dto.FileType == 1) tempName = $"收款账单(四川)模板.docx";
  723. else if (dto.FileType == 2) tempName = $"收款账单(北京)模板.docx";
  724. string tempPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/Temp/{tempName}";
  725. //载入模板
  726. Document doc = new Document(tempPath);
  727. DocumentBuilder builder = new DocumentBuilder(doc);
  728. #region 替换Word模板书签内容
  729. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  730. //付款方
  731. if (doc.Range.Bookmarks["To"] != null)
  732. {
  733. Bookmark mark = doc.Range.Bookmarks["To"];
  734. mark.Text = _ForeignReceivables[0].To == null ? "" : _ForeignReceivables[0].To.ToString();
  735. }
  736. //付款方电话
  737. if (doc.Range.Bookmarks["ToTel"] != null)
  738. {
  739. Bookmark mark = doc.Range.Bookmarks["ToTel"];
  740. mark.Text = _ForeignReceivables[0].ToTel == null ? "" : _ForeignReceivables[0].ToTel.ToString();
  741. }
  742. //导出时间
  743. if (doc.Range.Bookmarks["Date"] != null)
  744. {
  745. Bookmark mark = doc.Range.Bookmarks["Date"];
  746. mark.Text = DateTime.Now.ToString("yyyy-MM-dd");
  747. }
  748. //注
  749. if (doc.Range.Bookmarks["Attention"] != null)
  750. {
  751. Bookmark mark = doc.Range.Bookmarks["Attention"];
  752. mark.Text = _ForeignReceivables[0].Attention == null ? "" : _ForeignReceivables[0].Attention.ToString();
  753. }
  754. //团队名称
  755. if (doc.Range.Bookmarks["Team"] != null)
  756. {
  757. Bookmark mark = doc.Range.Bookmarks["Team"];
  758. mark.Text = _DelegationInfo.VisitCountry == null ? "" : _DelegationInfo.VisitCountry.ToString();
  759. }
  760. //付款日期
  761. if (doc.Range.Bookmarks["PayDate"] != null)
  762. {
  763. Bookmark mark = doc.Range.Bookmarks["PayDate"];
  764. mark.Text = _ForeignReceivables[0].PayDate == null ? "" : Convert.ToDateTime(_ForeignReceivables[0].PayDate).ToString("yyyy年MM月dd日");
  765. }
  766. decimal sumPrice = 0;
  767. //各项费用
  768. if (doc.Range.Bookmarks["PayItemContent"] != null)
  769. {
  770. string items = "";
  771. foreach (var fr in _ForeignReceivables)
  772. {
  773. items += fr.PriceName + " " + fr.Currency + " " + fr.Price.ToString("#0.00") + " * " + fr.Count + " " + fr.Unit + " * " + fr.Rate + ".................. RMB " + fr.ItemSumPrice.ToString("#0.00") + "\n";
  774. sumPrice += fr.ItemSumPrice;
  775. }
  776. Bookmark mark = doc.Range.Bookmarks["PayItemContent"];
  777. mark.Text = items;
  778. }
  779. //合计
  780. if (doc.Range.Bookmarks["Total"] != null)
  781. {
  782. Bookmark mark = doc.Range.Bookmarks["Total"];
  783. mark.Text = sumPrice.ToString("#0.00");
  784. }
  785. #endregion
  786. //文件名
  787. string strFileName = _DelegationInfo.TeamName + "-收款账单.docx";
  788. doc.Save(AppSettingsHelper.Get("WordBasePath") + "ForeignReceivables/File/" + strFileName);
  789. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/ForeignReceivables/File/" + strFileName;
  790. return Ok(JsonView(true, "成功", new { Url = url }));
  791. }
  792. else if (dto.FileType == 3) //汇款通知
  793. {
  794. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  795. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  796. if (_EnterExitCosts == null)
  797. {
  798. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  799. }
  800. //数据源
  801. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  802. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  803. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  804. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  805. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  806. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  807. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  808. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  809. .Select((tcl, dc, cc) => new
  810. {
  811. Name = dc.LastName + dc.FirstName,
  812. Sex = dc.Sex,
  813. Birthday = dc.BirthDay,
  814. Company = cc.CompanyFullName,
  815. Job = dc.Job,
  816. AirType = tcl.ShippingSpaceTypeId
  817. })
  818. .ToList();
  819. if (DeleClientList.Count<1)
  820. {
  821. return Ok(JsonView(false, "暂无团组成员,请先填写团组成员!!!"));
  822. }
  823. var _ClientNames = DeleClientList.Select(x => x.Name).ToList();
  824. var _GroupClient = DeleClientList.GroupBy(x => x.Company).ToList();
  825. Dictionary<string, string> bookmarkArr = null;
  826. string tempPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/Temp/汇款通知.docx";
  827. //载入模板
  828. Document doc = new Document(tempPath);
  829. DocumentBuilder builder = null;
  830. List<string> filesToZip = new List<string>();
  831. foreach (var ClientItem in _GroupClient) //遍历单位
  832. {
  833. doc = new Document(tempPath);
  834. builder = new DocumentBuilder(doc);
  835. Paragraph paragraph = new Paragraph(doc);
  836. bookmarkArr = new Dictionary<string, string>();
  837. bookmarkArr.Add("titleClientUnit", ClientItem.Key); //title单位
  838. bookmarkArr.Add("ClientUnit", ClientItem.Key); //单位
  839. bookmarkArr.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));//出发日期
  840. bookmarkArr.Add("name", string.Join(",", ClientItem.Select(x => x.Name).ToArray()).TrimEnd(','));//全部人员信息
  841. bookmarkArr.Add("VisitCountry", _DelegationInfo.VisitCountry);//出访国家
  842. bookmarkArr.Add("dayTime", DateTime.Now.ToString("yyyy年MM月dd日"));//今天日期
  843. var ClientItemList = ClientItem.ToList();
  844. string UsersTop = string.Empty;//word中人员以及金额
  845. decimal WordAllPrice = 0.00M;
  846. //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(),
  847. // 6, 3 + dac1.Where(x=>!string.IsNullOrWhiteSpace(x.Place)).Select(x=>(Convert.ToDecimal(x.SubTotal) / Convert.ToDecimal(x.Cost)).ToString().Length).Max() };
  848. //遍历人员
  849. for (int i = 0; i < ClientItemList.Count(); i++)
  850. {
  851. Dictionary<string, string> TeableBookmarkArr = new Dictionary<string, string>();
  852. var client = ClientItemList[i]; //每个人员
  853. var firstName = ClientItemList[i].Name;
  854. //计算费用总和
  855. decimal airPrice = client.AirType == 460 ? _EnterExitCosts.AirJJ : _EnterExitCosts.AirGW;
  856. decimal AllPrice = airPrice + _EnterExitCosts.CityTranffic + dac1.Sum(x => x.SubTotal) + dac2.Sum(x => x.SubTotal) +
  857. dac3.Sum(x => x.SubTotal) + dac4.Sum(x => x.SubTotal) + _EnterExitCosts.Visa + _EnterExitCosts.Safe +
  858. _EnterExitCosts.Service;
  859. WordAllPrice += AllPrice;
  860. UsersTop += firstName + "出访费用为¥" + AllPrice.ToString("#0.00") + "元、";
  861. TeableBookmarkArr.Add("jp",(client.AirType == 460 ? _EnterExitCosts.AirJJ : _EnterExitCosts.AirGW).ToString("#0.00") + " 元"); //机票金额
  862. TeableBookmarkArr.Add("cs", _EnterExitCosts.CityTranffic.ToString("#0.00") + " 元"); //城市交通费用
  863. TeableBookmarkArr.Add("zs", dac1.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //住宿费
  864. string zsinfo = string.Empty;
  865. string hsinfo = string.Empty;
  866. string gzinfo = string.Empty;
  867. List<string> placeArr = new List<string>();
  868. Aspose.Words.Tables.Table FirstTable = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
  869. Aspose.Words.Tables.Table ChildTable = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 0, true);
  870. Aspose.Words.Tables.Table ChildTable1 = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 1, true);
  871. Aspose.Words.Tables.Table ChildTable2 = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 2, true);
  872. int rowIndex = 0;
  873. foreach (var item in dac1)
  874. {
  875. if (string.IsNullOrWhiteSpace(item.Place))
  876. {
  877. continue;
  878. }
  879. if (placeArr.Contains(item.Place))
  880. {
  881. continue;
  882. }
  883. else
  884. {
  885. placeArr.Add(item.Place);
  886. }
  887. if (!string.IsNullOrWhiteSpace(item.Place))
  888. {
  889. if (rowIndex > ChildTable.Rows.Count - 1)
  890. {
  891. var chitableRow = ChildTable.LastRow.Clone(true);
  892. ChildTable.AppendChild(chitableRow);
  893. }
  894. int days = dac1.FindAll(x => x.Place == item.Place).Count();
  895. SetCells(ChildTable, doc, rowIndex, 0, item.Place);
  896. SetCells(ChildTable, doc, rowIndex, 1, days + "晚");
  897. SetCells(ChildTable, doc, rowIndex, 2, item.Cost + item.Currency + "/晚");
  898. SetCells(ChildTable, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
  899. SetCells(ChildTable, doc, rowIndex, 4, "CNY" + item.SubTotal * days + "\r\n");
  900. rowIndex++;
  901. zsinfo += item.Place + " " + days + "晚 " + item.Cost + item.Currency + "/晚" + " 汇率" + (item.SubTotal /item.Cost).ToString("#0.00") + " CNY" + item.SubTotal * days + "\r\n";
  902. }
  903. }
  904. placeArr.Clear();
  905. rowIndex = 0;
  906. foreach (var item in dac2)
  907. {
  908. if (string.IsNullOrWhiteSpace(item.Place))
  909. {
  910. continue;
  911. }
  912. if (placeArr.Contains(item.Place))
  913. {
  914. continue;
  915. }
  916. else
  917. {
  918. placeArr.Add(item.Place);
  919. }
  920. if (!string.IsNullOrWhiteSpace(item.Place))
  921. {
  922. if (rowIndex > ChildTable1.Rows.Count - 1)
  923. {
  924. var chitableRow = ChildTable1.LastRow.Clone(true);
  925. ChildTable1.AppendChild(chitableRow);
  926. }
  927. int days = dac2.FindAll(x => x.Place == item.Place).Count();
  928. SetCells(ChildTable1, doc, rowIndex, 0, item.Place);
  929. SetCells(ChildTable1, doc, rowIndex, 1, days + "天");
  930. SetCells(ChildTable1, doc, rowIndex, 2, item.Cost + item.Currency + "/天");
  931. SetCells(ChildTable1, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
  932. SetCells(ChildTable1, doc, rowIndex, 4, "CNY" +item.SubTotal * days);
  933. rowIndex++;
  934. hsinfo += item.Place + " " + days + "天 " + item.Cost + item.Currency + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00") + " CNY" +item.SubTotal * days + "\r\n";
  935. }
  936. }
  937. placeArr.Clear();
  938. rowIndex = 0;
  939. foreach (var item in dac3)
  940. {
  941. if (string.IsNullOrWhiteSpace(item.Place))
  942. {
  943. continue;
  944. }
  945. if (placeArr.Contains(item.Place))
  946. {
  947. continue;
  948. }
  949. else
  950. {
  951. placeArr.Add(item.Place);
  952. }
  953. if (!string.IsNullOrWhiteSpace(item.Place))
  954. {
  955. if (rowIndex > ChildTable2.Rows.Count - 1)
  956. {
  957. var chitableRow = ChildTable2.LastRow.Clone(true);
  958. ChildTable2.AppendChild(chitableRow);
  959. }
  960. int days = dac3.FindAll(x => x.Place == item.Place).Count();
  961. SetCells(ChildTable2, doc, rowIndex, 0, item.Place);
  962. SetCells(ChildTable2, doc, rowIndex, 1, days + "天");
  963. SetCells(ChildTable2, doc, rowIndex, 2, item.Cost + item.Currency + "/天");
  964. SetCells(ChildTable2, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
  965. SetCells(ChildTable2, doc, rowIndex, 4, "CNY" + item.SubTotal * days + "\r\n");
  966. rowIndex++;
  967. gzinfo += item.Place + " " + days + "天 " + item.Cost + item.Currency + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00") + " CNY" + item.SubTotal * days + "\r\n";
  968. }
  969. }
  970. placeArr.Clear();
  971. TeableBookmarkArr.Add("zsinfo", zsinfo); //住宿费详情
  972. TeableBookmarkArr.Add("hs", dac2.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //伙食费
  973. TeableBookmarkArr.Add("hsinfo", hsinfo); //伙食费详情
  974. TeableBookmarkArr.Add("gz", dac3.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //公杂费
  975. TeableBookmarkArr.Add("gzinfo", gzinfo); //公杂费详情
  976. TeableBookmarkArr.Add("qt", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00") + " 元");//其他费用
  977. TeableBookmarkArr.Add("qtinfo", $"(签证费{_EnterExitCosts.Visa.ToString("#0.00")}元、保险{_EnterExitCosts.Safe.ToString("#0.00")}元等费用)");//其他费用第二列
  978. TeableBookmarkArr.Add("fw", _EnterExitCosts.Service.ToString("#0.00") + "元/人");//服务费
  979. TeableBookmarkArr.Add("AllPrice", AllPrice.ToString("#0.00") + "元/人");//表格合计费用
  980. string airStr = client.AirType == 460 ? "经济舱" : client.AirType == 458 ? "公务舱" : "";
  981. TeableBookmarkArr.Add("title", $"费用清单-{airStr}({firstName})");
  982. foreach (var book in TeableBookmarkArr.Keys)
  983. {
  984. if (doc.Range.Bookmarks[book] != null)
  985. {
  986. Bookmark mark = doc.Range.Bookmarks[book];
  987. mark.Text = TeableBookmarkArr[book];
  988. }
  989. }
  990. if (i != ClientItemList.Count - 1)
  991. {
  992. builder.PageSetup.Orientation = Aspose.Words.Orientation.Portrait;
  993. Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
  994. table.ParentNode.InsertAfter(paragraph, table);
  995. var CloneTable = (Aspose.Words.Tables.Table)table.Clone(true);
  996. table.ParentNode.InsertAfter(CloneTable, paragraph);
  997. }
  998. TeableBookmarkArr.Clear();
  999. }
  1000. bookmarkArr.Add("VisitPrice", WordAllPrice.ToString());//出访费用总额
  1001. bookmarkArr.Add("CnAllPrice", WordAllPrice.ConvertCNYUpper());//出访费用总额中文
  1002. bookmarkArr.Add("namesPrice", UsersTop.TrimEnd('、'));//各人员出访费用 付辰同志出访费用为¥73,604.8元
  1003. foreach (var book in bookmarkArr.Keys)
  1004. {
  1005. if (doc.Range.Bookmarks[book] != null)
  1006. {
  1007. Bookmark mark = doc.Range.Bookmarks[book];
  1008. mark.Text = bookmarkArr[book];
  1009. }
  1010. }
  1011. //MemoryStream outSteam = new MemoryStream();
  1012. string filsPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/File/{ClientItem.Key}.docx";
  1013. doc.Save(filsPath);
  1014. filesToZip.Add(filsPath);
  1015. //streams.Add(ClientItem.Key + ".docx", outSteam.ToArray());
  1016. }
  1017. //文件名
  1018. string zipFileName = _DelegationInfo.TeamName + "-收款账单.zip";
  1019. string zipPath = $"ForeignReceivables/File/{_DelegationInfo.TeamName}-收款账单{DateTime.Now.ToString("yyyyMMddHHmmss")}.zip";
  1020. try
  1021. {
  1022. using (var zip = ZipFile.Open(AppSettingsHelper.Get("WordBasePath") + zipPath, ZipArchiveMode.Create))
  1023. {
  1024. foreach (var file in filesToZip)
  1025. {
  1026. zip.CreateEntryFromFile(file, Path.GetFileName(file));
  1027. }
  1028. }
  1029. }
  1030. catch (Exception ex)
  1031. {
  1032. return Ok(JsonView(false, ex.Message));
  1033. }
  1034. string url = AppSettingsHelper.Get("WordBaseUrl") + $"Office/Word/{zipPath}";
  1035. return Ok(JsonView(true, "成功", new { Url = url }));
  1036. }
  1037. return Ok(JsonView(false, "操作失败!"));
  1038. }
  1039. catch (Exception ex)
  1040. {
  1041. return Ok(JsonView(false, ex.Message));
  1042. }
  1043. }
  1044. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  1045. {
  1046. //获取table中的某个单元格,从0开始
  1047. Aspose.Words.Tables.Cell lshCell = table.Rows[rows].Cells[cells];
  1048. //将单元格中的第一个段落移除
  1049. lshCell.FirstParagraph.Remove();
  1050. //新建一个段落
  1051. Paragraph p = new Paragraph(doc);
  1052. var r = new Run(doc, val);
  1053. r.Font.Size = 8;
  1054. //把设置的值赋给之前新建的段落
  1055. p.AppendChild(r);
  1056. //将此段落加到单元格内
  1057. lshCell.AppendChild(p);
  1058. }
  1059. #endregion
  1060. #region 已收款项
  1061. /// <summary>
  1062. /// 已收款项
  1063. /// 查询
  1064. /// </summary>
  1065. /// <param name="dto"></param>
  1066. /// <returns></returns>
  1067. [HttpPost]
  1068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1069. public async Task<IActionResult> PostAmountReceived(AmountReceivedDto dto)
  1070. {
  1071. try
  1072. {
  1073. if (dto == null)
  1074. {
  1075. return Ok(JsonView(false, "参数不能为空!"));
  1076. }
  1077. Result ffrData = await _proceedsReceivedRep.PostAmountReceived(dto.DiId);
  1078. dynamic data = null;
  1079. if (dto.PortType == 1)
  1080. {
  1081. if (ffrData.Code != 0)
  1082. {
  1083. return Ok(JsonView(false, ffrData.Msg));
  1084. }
  1085. data = ffrData.Data;
  1086. }
  1087. else if (dto.PortType == 2)
  1088. {
  1089. if (ffrData.Code != 0)
  1090. {
  1091. return Ok(JsonView(false, ffrData.Msg));
  1092. }
  1093. data = ffrData.Data;
  1094. }
  1095. else if (dto.PortType == 2)
  1096. {
  1097. if (ffrData.Code != 0)
  1098. {
  1099. return Ok(JsonView(false, ffrData.Msg));
  1100. }
  1101. data = ffrData.Data;
  1102. }
  1103. else
  1104. {
  1105. return Ok(JsonView(false, "请选择正确的端口号!"));
  1106. }
  1107. return Ok(JsonView(true, "操作成功!", data));
  1108. }
  1109. catch (Exception ex)
  1110. {
  1111. return Ok(JsonView(false, ex.Message));
  1112. }
  1113. }
  1114. /// <summary>
  1115. /// 已收款项
  1116. /// Add Or Edit
  1117. /// </summary>
  1118. /// <param name="dto"></param>
  1119. /// <returns></returns>
  1120. [HttpPost]
  1121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1122. public async Task<IActionResult> PostAmountReceivedAddOrEdit(AmountReceivedAddOrEditDto dto)
  1123. {
  1124. try
  1125. {
  1126. if (dto == null)
  1127. {
  1128. return Ok(JsonView(false, "参数不能为空!"));
  1129. }
  1130. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedAddOrEditDto(dto);
  1131. if (dto.PortType == 1)
  1132. {
  1133. if (ffrData.Code != 0)
  1134. {
  1135. return Ok(JsonView(false, ffrData.Msg));
  1136. }
  1137. }
  1138. else if (dto.PortType == 2)
  1139. {
  1140. if (ffrData.Code != 0)
  1141. {
  1142. return Ok(JsonView(false, ffrData.Msg));
  1143. }
  1144. }
  1145. else if (dto.PortType == 2)
  1146. {
  1147. if (ffrData.Code != 0)
  1148. {
  1149. return Ok(JsonView(false, ffrData.Msg));
  1150. }
  1151. }
  1152. else
  1153. {
  1154. return Ok(JsonView(false, "请选择正确的端口号!"));
  1155. }
  1156. return Ok(JsonView(true, "操作成功!"));
  1157. }
  1158. catch (Exception ex)
  1159. {
  1160. return Ok(JsonView(false, ex.Message));
  1161. }
  1162. }
  1163. /// <summary>
  1164. /// 已收款项
  1165. /// Del
  1166. /// </summary>
  1167. /// <param name="dto"></param>
  1168. /// <returns></returns>
  1169. [HttpPost]
  1170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1171. public async Task<IActionResult> PostAmountReceived_Del(AmountReceivedDelDto dto)
  1172. {
  1173. try
  1174. {
  1175. if (dto == null)
  1176. {
  1177. return Ok(JsonView(false, "参数不能为空!"));
  1178. }
  1179. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedDel(dto);
  1180. if (ffrData.Code != 0)
  1181. {
  1182. return Ok(JsonView(false, ffrData.Msg));
  1183. }
  1184. return Ok(JsonView(true, "操作成功!"));
  1185. }
  1186. catch (Exception ex)
  1187. {
  1188. return Ok(JsonView(false, ex.Message));
  1189. }
  1190. }
  1191. #endregion
  1192. #region 收款退还与其他款项
  1193. /// <summary>
  1194. /// 收款退还与其他款项
  1195. /// 查询 根据团组Id
  1196. /// </summary>
  1197. /// <param name="dto"></param>
  1198. /// <returns></returns>
  1199. [HttpPost]
  1200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1201. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyItemByDiId(PaymentRefundAndOtherMoneyItemByDiIdDto dto)
  1202. {
  1203. try
  1204. {
  1205. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  1206. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  1207. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  1208. #region 页面功能权限处理
  1209. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  1210. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1211. if (pageFunAuth.CheckAuth == 0)
  1212. {
  1213. return Ok(JsonView(false, "您没有当前页面查询权限!"));
  1214. }
  1215. #endregion
  1216. Result _result = await _paymentRefundAndOtherMoneyRep._ItemByDiId(dto.DiId);
  1217. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //1 Web 2 Android 3 Ios
  1218. {
  1219. if (_result.Code != 0)
  1220. {
  1221. return Ok(JsonView(false, _result.Msg));
  1222. }
  1223. var data = new
  1224. {
  1225. PageFuncAuth = pageFunAuth,
  1226. Data = _result.Data
  1227. };
  1228. return Ok(JsonView(true, "操作成功!", data));
  1229. }
  1230. else
  1231. {
  1232. return Ok(JsonView(false, "请输入正确的端口号! 1 Web 2 Android 3 Ios;"));
  1233. }
  1234. }
  1235. catch (Exception ex)
  1236. {
  1237. return Ok(JsonView(false, ex.Message));
  1238. }
  1239. }
  1240. /// <summary>
  1241. /// 收款退还与其他款项
  1242. /// 删除
  1243. /// </summary>
  1244. /// <param name="dto"></param>
  1245. /// <returns></returns>
  1246. [HttpPost]
  1247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1248. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyDel(PaymentRefundAndOtherMoneyDelDto dto)
  1249. {
  1250. try
  1251. {
  1252. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  1253. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  1254. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  1255. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  1256. #region 页面功能权限处理
  1257. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1258. #endregion
  1259. if (pageFunAuth.DeleteAuth == 0)
  1260. {
  1261. return Ok(JsonView(false, "您没有当前页面删除权限!"));
  1262. }
  1263. Result _result = await _paymentRefundAndOtherMoneyRep._Del(dto);
  1264. if (_result.Code != 0)
  1265. {
  1266. return Ok(JsonView(false, _result.Msg));
  1267. }
  1268. return Ok(JsonView(true, "操作成功!"));
  1269. }
  1270. catch (Exception ex)
  1271. {
  1272. return Ok(JsonView(false, ex.Message));
  1273. }
  1274. }
  1275. /// <summary>
  1276. /// 收款退还与其他款项
  1277. /// Info Data Source
  1278. /// </summary>
  1279. /// <param name="dto"></param>
  1280. /// <returns></returns>
  1281. [HttpPost]
  1282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1283. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyInfoDataSource(PortDtoBase dto)
  1284. {
  1285. try
  1286. {
  1287. Result _result = await _paymentRefundAndOtherMoneyRep._InfoDataSource(dto);
  1288. if (_result.Code != 0)
  1289. {
  1290. return Ok(JsonView(false, _result.Msg));
  1291. }
  1292. return Ok(JsonView(true, "查询成功!", _result.Data));
  1293. }
  1294. catch (Exception ex)
  1295. {
  1296. return Ok(JsonView(false, ex.Message));
  1297. }
  1298. }
  1299. /// <summary>
  1300. /// 收款退还与其他款项
  1301. /// Info
  1302. /// </summary>
  1303. /// <param name="dto"></param>
  1304. /// <returns></returns>
  1305. [HttpPost]
  1306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1307. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyInfo(PaymentRefundAndOtherMoneyInfoDto dto)
  1308. {
  1309. try
  1310. {
  1311. if (dto == null)
  1312. {
  1313. return Ok(JsonView(false, "参数不能为空!"));
  1314. }
  1315. Result _result = await _paymentRefundAndOtherMoneyRep._Info(dto);
  1316. if (_result.Code != 0)
  1317. {
  1318. return Ok(JsonView(false, _result.Msg));
  1319. }
  1320. return Ok(JsonView(true, "查询成功!", _result.Data));
  1321. }
  1322. catch (Exception ex)
  1323. {
  1324. return Ok(JsonView(false, ex.Message));
  1325. }
  1326. }
  1327. /// <summary>
  1328. /// 收款退还与其他款项
  1329. /// 操作(Add Or Edit)
  1330. /// </summary>
  1331. /// <param name="dto"></param>
  1332. /// <returns></returns>
  1333. [HttpPost]
  1334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1335. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyAddOrEdit(PaymentRefundAndOtherMoneyAddOrEditDto dto)
  1336. {
  1337. try
  1338. {
  1339. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  1340. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  1341. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  1342. #region 页面功能权限处理
  1343. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  1344. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1345. #endregion
  1346. if (dto.Status == 1) //add
  1347. {
  1348. if (pageFunAuth.AddAuth == 0)
  1349. {
  1350. return Ok(JsonView(false, "您没有当前页面添加权限!"));
  1351. }
  1352. }
  1353. else if (dto.Status == 2) //edit
  1354. {
  1355. if (pageFunAuth.EditAuth == 0)
  1356. {
  1357. return Ok(JsonView(false, "您没有当前页面编辑权限!"));
  1358. }
  1359. }
  1360. else
  1361. {
  1362. return Ok(JsonView(false, "请输入正确的操作状态! 1 添加 2 修改!"));
  1363. }
  1364. Result _result = await _paymentRefundAndOtherMoneyRep._AddOrEdit(dto);
  1365. if (_result.Code != 0)
  1366. {
  1367. return Ok(JsonView(false, _result.Msg));
  1368. }
  1369. return Ok(JsonView(true, "操作成功!"));
  1370. }
  1371. catch (Exception ex)
  1372. {
  1373. return Ok(JsonView(false, ex.Message));
  1374. }
  1375. }
  1376. #endregion
  1377. #region 应收报表
  1378. /// <summary>
  1379. /// 应收报表
  1380. /// 查询 根据日期范围
  1381. /// </summary>
  1382. /// <param name="dto"></param>
  1383. /// <returns></returns>
  1384. [HttpPost]
  1385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1386. public async Task<IActionResult> PostSyntheticalReceivableByDateRange(PostSyntheticalReceivableByDateRangeDto dto)
  1387. {
  1388. string sqlWhere = " Where di.IsDel=0 ";
  1389. #region 验证
  1390. if (string.IsNullOrEmpty(dto.beginDt) && string.IsNullOrEmpty(dto.endDt))
  1391. {
  1392. return Ok(JsonView(false, "日期参数至少填写一个!"));
  1393. }
  1394. if (!string.IsNullOrEmpty(dto.beginDt))
  1395. {
  1396. if (Regex.Match(dto.beginDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
  1397. {
  1398. return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
  1399. }
  1400. else
  1401. {
  1402. sqlWhere += string.Format(@" And di.VisitDate >= '{0} 00:00:00' ", dto.beginDt);
  1403. }
  1404. }
  1405. if (!string.IsNullOrEmpty(dto.endDt))
  1406. {
  1407. if (Regex.Match(dto.endDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
  1408. {
  1409. return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
  1410. }
  1411. else
  1412. {
  1413. sqlWhere += string.Format(@" And di.VisitDate <= '{0} 23:59:59' ", dto.endDt);
  1414. }
  1415. }
  1416. #endregion
  1417. string sql = string.Format(@" select distinct fr.diid,di.TeamName,di.ClientUnit,di.VisitDate from Fin_ForeignReceivables fr join Grp_DelegationInfo di on fr.DIID = di.id {0} ", sqlWhere);
  1418. List<PostSyntheticalReceivableByDateRangeView> list_rst = _sqlSugar.SqlQueryable<PostSyntheticalReceivableByDateRangeView>(sql).ToList();
  1419. decimal sumAll_fr = 0M;
  1420. decimal sumAll_pr = 0M;
  1421. decimal sumAll_balance = 0M;
  1422. if (list_rst.Count > 0)
  1423. {
  1424. int rowNumber = 1;
  1425. foreach (var item_rst in list_rst)
  1426. {
  1427. item_rst.No = rowNumber;
  1428. rowNumber++;
  1429. int diId = item_rst.diid;
  1430. decimal sum_fr = 0M;
  1431. decimal sum_pr = 0M;
  1432. string str_client = string.Empty;
  1433. decimal sum_other = 0M; //收款退还
  1434. decimal sum_extra = 0M; //超支费用
  1435. decimal balance = 0M;
  1436. string str_schedule = string.Empty;
  1437. //1. 缺超支费用!!!!!!!!!!!!!!!!!!!!
  1438. string sql_fr = string.Format(@" Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0} ", diId);
  1439. List<Fin_ForeignReceivables> list_fr = _sqlSugar.SqlQueryable<Fin_ForeignReceivables>(sql_fr).ToList();
  1440. sum_fr = list_fr.Sum(s => s.ItemSumPrice);
  1441. //2.
  1442. string sql_pr = string.Format(@" Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0} ", diId);
  1443. List<Fin_ProceedsReceived> list_pr = _sqlSugar.SqlQueryable<Fin_ProceedsReceived>(sql_pr).ToList();
  1444. foreach (var item_pr in list_pr)
  1445. {
  1446. sum_pr += item_pr.Price;
  1447. str_client += string.Format(@"{0};", item_pr.Client);
  1448. str_schedule += string.Format(@"{0};", item_pr.Remark);
  1449. }
  1450. if (str_schedule.Length > 0)
  1451. {
  1452. str_schedule = str_schedule.TrimEnd(';');
  1453. }
  1454. if (str_client.Length > 0)
  1455. {
  1456. str_client = str_client.TrimEnd(';');
  1457. }
  1458. //3.
  1459. string sql_other = string.Format(@" Select * From Fin_OtherPrice where diid = {0} and isdel = 0 and RefundType = 1 and PayType=1 ", diId);
  1460. List<Fin_OtherPrice> list_other = _sqlSugar.SqlQueryable<Fin_OtherPrice>(sql_other).ToList();
  1461. sum_other = list_other.Sum(s => s.Price);
  1462. //4.
  1463. string sql_extra = string.Format(@" Select c.* From Fin_GroupExtraCost f
  1464. Inner join Grp_CreditCardPayment c On f.Id = c.CId
  1465. Where c.CTable = 1015 And c.IsPay = 1 And f.IsDel = 0 And c.IsDel = 0 And f.DiId = {0} ", diId);
  1466. List<Grp_CreditCardPayment> list_extra = _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql_extra).ToList();
  1467. sum_extra = list_extra.Sum(s => s.RMBPrice);
  1468. item_rst.frPrice = (sum_fr + sum_extra).ToString("#0.00");
  1469. item_rst.prPrice = (sum_pr - sum_other).ToString("#0.00");
  1470. item_rst.balPrice = ((sum_fr + sum_extra) - (sum_pr - sum_other)).ToString("#0.00");
  1471. item_rst.prClient = str_client;
  1472. item_rst.schedule = str_schedule;
  1473. string tempVisitDate = Convert.ToDateTime(item_rst.visitDate).ToString("yyyy-MM-dd");
  1474. sumAll_fr += (sum_fr + sum_extra);
  1475. sumAll_pr += (sum_pr - sum_other);
  1476. sumAll_balance += ((sum_fr + sum_extra) - (sum_pr - sum_other));
  1477. }
  1478. PostSyntheticalReceivableByDateRangeResultView result = new PostSyntheticalReceivableByDateRangeResultView();
  1479. result.total_fr = sumAll_fr.ToString("#0.00");
  1480. result.total_pr = sumAll_pr.ToString("#0.00");
  1481. result.total_balance = sumAll_balance.ToString("#0.00");
  1482. result.dataList = new List<PostSyntheticalReceivableByDateRangeView>(list_rst);
  1483. if (dto.requestType == 1)
  1484. {
  1485. return Ok(JsonView(true, "请求成功", result, list_rst.Count));
  1486. }
  1487. else
  1488. {
  1489. //----------------------------
  1490. List<Excel_SyntheticalReceivableByDateRange> list_Ex = new List<Excel_SyntheticalReceivableByDateRange>();
  1491. WorkbookDesigner designer = new WorkbookDesigner();
  1492. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/应收款项模板 - 副本.xls");
  1493. int excNo = 1;
  1494. foreach (var item in list_rst)
  1495. {
  1496. Excel_SyntheticalReceivableByDateRange exc = new Excel_SyntheticalReceivableByDateRange();
  1497. exc.No = excNo.ToString();
  1498. excNo++;
  1499. exc.TeamName = item.teamName;
  1500. exc.ClientUnit = item.clientUnit;
  1501. exc.VisitDate = item.visitDate;
  1502. exc.Accounts = item.frPrice;
  1503. exc.Received = item.prPrice;
  1504. exc.Balance = item.balPrice;
  1505. exc.Collection = item.schedule;
  1506. DateTime time = Convert.ToDateTime(item.visitDate);
  1507. TimeSpan ts = DateTime.Now - time;
  1508. float SY = float.Parse(item.balPrice);
  1509. if (ts.Days >= 365 && SY > 0)
  1510. {
  1511. exc.Sign = "需收款";
  1512. }
  1513. else
  1514. {
  1515. exc.Sign = "";
  1516. }
  1517. list_Ex.Add(exc);
  1518. }
  1519. var dt = CommonFun.GetDataTableFromIList(list_Ex);
  1520. dt.TableName = "Excel_SyntheticalReceivableByDateRange";
  1521. if (dt != null)
  1522. {
  1523. designer.SetDataSource("SumPrice", "应收合计:" + result.total_fr + "RMB 已收合计:" + result.total_pr + "RMB 余款合计:" + result.total_balance + "RMB");
  1524. //数据源
  1525. designer.SetDataSource(dt);
  1526. //根据数据源处理生成报表内容
  1527. designer.Process();
  1528. string fileName = ("Receivable/应收款项(" + dto.beginDt + "~" + dto.endDt + ").xlsx");
  1529. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1530. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1531. return Ok(JsonView(true, "成功", new { url = rst }));
  1532. }
  1533. }
  1534. }
  1535. return Ok(JsonView(true, "获取成功", "", list_rst.Count));
  1536. }
  1537. #endregion
  1538. #region 付款申请
  1539. /// <summary>
  1540. /// 付款申请
  1541. /// 基础数据
  1542. /// </summary>
  1543. /// <param name="dto"></param>
  1544. /// <returns></returns>
  1545. [HttpPost]
  1546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1547. public async Task<IActionResult> PostPayRequestInit()
  1548. {
  1549. try
  1550. {
  1551. var conpanyDatas = _sqlSugar.Queryable<Sys_Company>()
  1552. .Where(it => it.IsDel == 0)
  1553. .Select(it => new
  1554. {
  1555. Id = it.Id,
  1556. ConpamyName = it.CompanyName
  1557. }).ToList();
  1558. return Ok(JsonView(true, "操作成功!",new { ConpanyData = conpanyDatas }));
  1559. }
  1560. catch (Exception ex)
  1561. {
  1562. return Ok(JsonView(false, ex.Message));
  1563. }
  1564. }
  1565. /// <summary>
  1566. /// 付款申请 (PageId=51)
  1567. /// 查询 根据日期范围
  1568. /// </summary>
  1569. /// <param name="dto"></param>
  1570. /// <returns></returns>
  1571. [HttpPost]
  1572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1573. public async Task<IActionResult> PostPayRequest_Center(PostPayRequestByDateRangeDto dto)
  1574. {
  1575. #region 验证
  1576. DateTime beginDt, endDt;
  1577. string format = "yyyy-MM-dd";
  1578. if (!DateTime.TryParseExact(dto.beginDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out beginDt))
  1579. {
  1580. return Ok(JsonView(false, "开始日期格式不正确!正确格式:yyyy-MM-dd"));
  1581. }
  1582. if (!DateTime.TryParseExact(dto.endDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out endDt))
  1583. {
  1584. return Ok(JsonView(false, "结束日期格式不正确!正确格式:yyyy-MM-dd"));
  1585. }
  1586. #region 页面操作权限验证
  1587. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1588. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1589. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  1590. #endregion
  1591. #endregion
  1592. try
  1593. {
  1594. PaymentRequestCheckedView checkedView = new PaymentRequestCheckedView();
  1595. var checkedStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("paymentRequestCheckedData");
  1596. if (checkedStr != null)
  1597. {
  1598. checkedView = JsonConvert.DeserializeObject<PaymentRequestCheckedView>(checkedStr.ToString());
  1599. }
  1600. tree_Fin_DailyFeePaymentResult dailyResult = PayRequest_DailyByDateRange(dto.Status, checkedView.DailyPaymentIds, dto.beginDt, dto.endDt);
  1601. tree_Group_DailyFeePaymentResult groupResult = PayRequest_GroupPaymentByDateRange( dto.Status,checkedView.GroupIds, dto.beginDt, dto.endDt);
  1602. return Ok(JsonView(true, "获取成功", new { daily = dailyResult, group = groupResult }));
  1603. }
  1604. catch (Exception ex)
  1605. {
  1606. return Ok(JsonView(false, ex.Message));
  1607. }
  1608. }
  1609. /// <summary>
  1610. /// 根据团组类型类型处理团组费用所属公司
  1611. /// </summary>
  1612. /// <param name="teamId"></param>
  1613. /// <returns></returns>
  1614. private CompanyInfo ExpenseCompanyByTeamId(int teamId)
  1615. {
  1616. CompanyInfo _companyInfo = new CompanyInfo();
  1617. List<int> _SiChuan = new List<int>() {
  1618. 38 , // 政府团
  1619. 39 , // 企业团
  1620. 40 , // 散客团
  1621. 102, // 未知
  1622. 248, // 非团组
  1623. 691, // 四川-会务活动
  1624. 762, // 四川-赛事项目收入
  1625. };
  1626. List<int> _ChengDu = new List<int>() {
  1627. 302, // 成都-会务活动
  1628. 1047, // 成都-赛事项目收入
  1629. };
  1630. if (_SiChuan.Contains(teamId))
  1631. {
  1632. _companyInfo.Id = 2;
  1633. _companyInfo.ConpanyName = "四川泛美交流有限公司";
  1634. }
  1635. if (_ChengDu.Contains(teamId))
  1636. {
  1637. _companyInfo.Id = 1;
  1638. _companyInfo.ConpanyName = "成都泛美商务有限公司";
  1639. }
  1640. return _companyInfo;
  1641. }
  1642. /// <summary>
  1643. /// 付款申请(团组费用申请相关)
  1644. /// 查询 根据日期范围
  1645. /// </summary>
  1646. /// <param name="_groupIds"></param>
  1647. /// <param name="beginDt"></param>
  1648. /// <param name="endDt"></param>
  1649. /// <returns></returns>
  1650. private tree_Group_DailyFeePaymentResult PayRequest_GroupPaymentByDateRange(int status,List<int> _groupIds, string beginDt, string endDt)
  1651. {
  1652. tree_Group_DailyFeePaymentResult _DailyFeePaymentResult = new tree_Group_DailyFeePaymentResult();
  1653. List<tree_Group_DailyFeePaymentPageListView> dataList = new List<tree_Group_DailyFeePaymentPageListView>();
  1654. #region sql条件处理
  1655. string sqlWhere = string.Format(@" And (AuditGMDate Between '{0} 00:00:00' And '{1} 23:59:59') ", beginDt, endDt);
  1656. if (status == 2)
  1657. {
  1658. if (_groupIds.Count < 1)
  1659. {
  1660. return _DailyFeePaymentResult;
  1661. }
  1662. sqlWhere += string.Format(@" And Id In ({0})", string.Join(",", _groupIds));
  1663. }
  1664. string sql_1 = string.Format(@"Select * From Grp_CreditCardPayment Where IsDel = 0 And IsPay = 0 And IsAuditGM = 1 {0}", sqlWhere);
  1665. #endregion
  1666. var _paymentDatas = _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql_1).ToList();//付款信息
  1667. _DailyFeePaymentResult.gz = _paymentDatas.Where(it => it.OrbitalPrivateTransfer == 0).Sum(it => ((it.PayMoney * it.DayRate) / 100) * it.PayPercentage); //公转
  1668. _DailyFeePaymentResult.sz = _paymentDatas.Where(it => it.OrbitalPrivateTransfer == 1).Sum(it => ((it.PayMoney * it.DayRate) / 100) * it.PayPercentage); ; //私转
  1669. List<int> groupIds = _paymentDatas.Select(it => it.DIId).Distinct().ToList();
  1670. var _groupDatas = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && groupIds.Contains(it.Id)).ToList();
  1671. //_groupDatas = (List<Grp_DelegationInfo>)_groupDatas.GroupBy(it => it.TeamDid);
  1672. #region 相关基础数据源
  1673. var userDatas = _sqlSugar.Queryable<Sys_Users>().ToList();
  1674. var setDatas = _sqlSugar.Queryable<Sys_SetData>().ToList();
  1675. var hotelDatas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1676. var opDatas = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1677. var visaDatas = _sqlSugar.Queryable<Grp_VisaInfo>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DIId)).ToList();
  1678. var ioaDatas = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1679. var insureDatas = _sqlSugar.Queryable<Grp_Customers>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1680. var airDatas = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DIId)).ToList();
  1681. var otherMoneyDatas = _sqlSugar.Queryable<Fin_OtherPrice>().Where(it => it.IsDel == 0 && groupIds.Contains(it.Diid)).ToList();
  1682. var refundPaymentDatas = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1683. var ExtraCostDatas = _sqlSugar.Queryable<Fin_GroupExtraCost>().Where(it => it.IsDel == 0 && groupIds.Contains(it.DiId)).ToList();
  1684. #endregion
  1685. //Expense company
  1686. foreach ( var groupInfo in _groupDatas)
  1687. {
  1688. List<Group_DailyFeePaymentContentInfolView> childList = new List<Group_DailyFeePaymentContentInfolView>();
  1689. var groupPaymentDatas = _paymentDatas.Where(it => groupInfo.Id == it.DIId).ToList();
  1690. int rouNumber = 1;
  1691. foreach (var payInfo in groupPaymentDatas)
  1692. {
  1693. string priName = "";
  1694. switch (payInfo.CTable)
  1695. {
  1696. case 76: //76 酒店预订
  1697. priName = hotelDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.HotelName ?? "";
  1698. break;
  1699. case 79: //79 车/导游地接
  1700. var opData = opDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id);
  1701. if (opData != null)
  1702. {
  1703. if (payInfo.OrbitalPrivateTransfer == 0) //公转
  1704. {
  1705. priName = $"【公转】【导游: {opData.ServiceGuide} 】{opData.Area}" ;
  1706. }
  1707. else if (payInfo.OrbitalPrivateTransfer == 1) //私转
  1708. {
  1709. priName = $"【私转】【导游:{opData.ServiceGuide}】{opData.Area}";
  1710. }
  1711. }
  1712. break;
  1713. case 80: // 80 签证
  1714. priName = visaDatas.Find(it => payInfo.DIId == it.DIId && payInfo.CId == it.Id)?.VisaClient ?? "";
  1715. break;
  1716. case 81: // 81 邀请/公务活动
  1717. priName = ioaDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.Inviter ?? "";
  1718. break;
  1719. case 82: // 82 团组客户保险
  1720. priName = insureDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.ClientName ?? "";
  1721. break;
  1722. case 85: // 85 机票预订
  1723. string flightsCode = airDatas.Find(it => payInfo.DIId == it.DIId && payInfo.CId == it.Id)?.FlightsCode ?? "";
  1724. string airPayType = setDatas.Find(it => it.Id == payInfo.PayDId)?.Name ?? "";
  1725. priName = $"{flightsCode}【{airPayType}】";
  1726. break;
  1727. case 98: // 98 其他款项
  1728. priName = otherMoneyDatas.Find(it => payInfo.DIId == it.Diid && payInfo.CId == it.Id)?.PriceName ?? "";
  1729. break;
  1730. case 285: // 285 收款退还
  1731. priName = refundPaymentDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? "";
  1732. break;
  1733. case 1015: // 1015 超支费用
  1734. priName = ExtraCostDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? "";
  1735. break;
  1736. default:
  1737. priName = "";
  1738. break;
  1739. }
  1740. bool status1 = false;
  1741. if (_groupIds != null)
  1742. {
  1743. status1 = _groupIds.Contains(payInfo.Id);
  1744. }
  1745. childList.Add(new Group_DailyFeePaymentContentInfolView()
  1746. {
  1747. IsChecked = status1,
  1748. Id = payInfo.Id,
  1749. Payee = payInfo.Payee,
  1750. RowNumber = rouNumber,
  1751. Applicant = userDatas.Find(it => it.Id == payInfo.CreateUserId)?.CnName ?? "",
  1752. PayType = setDatas.Find(it => it.Id == payInfo.PayDId)?.Name ?? "",
  1753. TransferMark = payInfo.OrbitalPrivateTransfer == 0 ? "公转": payInfo.OrbitalPrivateTransfer == 1 ? "私转" :"-",
  1754. PriceName = priName,
  1755. ModuleName = setDatas.Find(it => it.Id == payInfo.CTable)?.Name ?? "",
  1756. PayCurrCode = setDatas.Find(it => it.Id == payInfo.PaymentCurrency)?.Name ?? "",
  1757. PaymentAmount = payInfo.PayMoney,
  1758. PayRate = payInfo.DayRate,
  1759. CNYTotalAmount = ((payInfo.DayRate * payInfo.PayMoney) / 100) * payInfo.PayPercentage //此次付款金额
  1760. });
  1761. rouNumber++;
  1762. }
  1763. CompanyInfo companyInfo = new CompanyInfo();
  1764. companyInfo = ExpenseCompanyByTeamId(groupInfo.TeamDid);
  1765. dataList.Add(new tree_Group_DailyFeePaymentPageListView()
  1766. {
  1767. Id = Guid.NewGuid().ToString("N"),
  1768. GroupName = groupInfo.TeamName,
  1769. CompanyId = companyInfo.Id,
  1770. ConpanyName = companyInfo.ConpanyName,
  1771. CNYTotalAmount = childList.Sum(it => it.CNYTotalAmount),
  1772. ChildList = childList,
  1773. });
  1774. }
  1775. _DailyFeePaymentResult.dataList = dataList;
  1776. return _DailyFeePaymentResult;
  1777. }
  1778. /// <summary>
  1779. /// 付款申请(日付申请相关)
  1780. /// 查询 根据日期范围
  1781. /// </summary>
  1782. /// <param name="_dailyIds"></param>
  1783. /// <param name="beginDt"></param>
  1784. /// <param name="endDt"></param>
  1785. /// <returns></returns>
  1786. private tree_Fin_DailyFeePaymentResult PayRequest_DailyByDateRange(int status, List<int> _dailyIds, string beginDt, string endDt)
  1787. {
  1788. #region sql条件处理
  1789. string sqlWhere = string.Format(@" And dfp.CreateTime between '{0} 00:00:00' And '{1} 23:59:59' ", beginDt, endDt);
  1790. if (status == 2)
  1791. {
  1792. if (_dailyIds.Count < 1)
  1793. {
  1794. return new tree_Fin_DailyFeePaymentResult();
  1795. }
  1796. sqlWhere += string.Format(@" And dfp.Id In({0}) ", string.Join(",", _dailyIds));
  1797. }
  1798. string sql_1 = string.Format(@"Select * From (
  1799. Select row_number() over (order by dfp.Id Desc) as RowNumber,
  1800. dfp.Id,dfp.CompanyId,c.CompanyName,dfp.Instructions,dfp.SumPrice,
  1801. dfp.CreateUserId,u.CnName CreateUser,dfp.CreateTime,dfp.FAudit,dfp.MAudit,
  1802. dfp.PriceTypeId,dfp.TransferTypeId
  1803. From Fin_DailyFeePayment dfp
  1804. Inner Join Sys_Company c On dfp.CompanyId = c.Id
  1805. Left Join Sys_Users u On dfp.CreateUserId = u.Id
  1806. Where dfp.IsDel=0 {0} And dfp.FAudit = 1 And dfp.MAudit = 1
  1807. ) temp ", sqlWhere);
  1808. #endregion
  1809. List<tree_Fin_DailyFeePaymentPageListView> DailyFeePaymentData = _sqlSugar.SqlQueryable<tree_Fin_DailyFeePaymentPageListView>(sql_1).ToList();
  1810. Dictionary<int, string> dic_setData = new Dictionary<int, string>();
  1811. foreach (var item in DailyFeePaymentData)
  1812. {
  1813. if (_dailyIds != null)
  1814. {
  1815. item.IsChecked = _dailyIds.Contains(item.Id);
  1816. }
  1817. if (dic_setData.ContainsKey(item.PriceTypeId))
  1818. {
  1819. item.priceTypeStr = dic_setData[item.PriceTypeId];
  1820. }
  1821. else
  1822. {
  1823. Sys_SetData sd_priceType = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceTypeId).First();
  1824. if (sd_priceType != null)
  1825. {
  1826. item.priceTypeStr = sd_priceType.Name;
  1827. dic_setData.Add(item.PriceTypeId, sd_priceType.Name);
  1828. }
  1829. }
  1830. if (dic_setData.ContainsKey(item.transferTypeId))
  1831. {
  1832. item.transferTypeIdStr = dic_setData[item.transferTypeId];
  1833. Sys_SetData sd_transfer = _daiRep.Query<Sys_SetData>(s => s.Id == item.transferTypeId).First();
  1834. if (sd_transfer != null)
  1835. {
  1836. item.transferParentId = sd_transfer.STid;
  1837. item.transferParentIdStr = sd_transfer.STid == 62 ? "公转" : sd_transfer.STid == 63 ? "私转" : "";
  1838. }
  1839. }
  1840. else
  1841. {
  1842. Sys_SetData sd_transfer = _daiRep.Query<Sys_SetData>(s => s.Id == item.transferTypeId).First();
  1843. if (sd_transfer != null)
  1844. {
  1845. item.transferTypeIdStr = sd_transfer.Name;
  1846. item.transferParentId = sd_transfer.STid;
  1847. item.transferParentIdStr = sd_transfer.STid == 62 ? "公转" : sd_transfer.STid == 63 ? "私转" : "";
  1848. dic_setData.Add(item.transferTypeId, sd_transfer.Name);
  1849. }
  1850. }
  1851. string feeContentSql = string.Format(@"Select * From Fin_DailyFeePaymentContent
  1852. Where IsDel=0 And DFPId = {0} ", item.Id);
  1853. item.childList = _sqlSugar.SqlQueryable<Fin_DailyFeePaymentContentInfolView>(feeContentSql).ToList();
  1854. }
  1855. decimal total_gz = DailyFeePaymentData.Where(s => s.transferParentId == 62).Sum(d => d.SumPrice ?? 0M);
  1856. decimal total_sz = DailyFeePaymentData.Where(s => s.transferParentId == 63).Sum(d => d.SumPrice ?? 0M);
  1857. var result = new tree_Fin_DailyFeePaymentResult() { gz = total_gz, sz = total_sz, dataList = DailyFeePaymentData };
  1858. return result;
  1859. }
  1860. /// <summary>
  1861. /// 付款申请 (PageId=51)
  1862. /// 团组,日付相关费用 选中状态变更
  1863. /// </summary>
  1864. /// <param name="dto"></param>
  1865. /// <returns></returns>
  1866. [HttpPost]
  1867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1868. public async Task<IActionResult> PostPayRequestCheckedChange(PayRequestCheckedChangeDto dto)
  1869. {
  1870. #region 验证
  1871. if (dto.Type < 1 || dto.Type > 2)
  1872. {
  1873. return Ok(JsonView(false, "请传入有效的Type参数! 1 checked 2 清除上次勾选"));
  1874. }
  1875. #endregion
  1876. try
  1877. {
  1878. PaymentRequestCheckedView requestCheckedView =new PaymentRequestCheckedView();
  1879. List<int> groupIds = new List<int>();
  1880. List<int> dailyPaymentIds = new List<int>();
  1881. #region 参数处理
  1882. if (!string.IsNullOrEmpty(dto.GroupIds))
  1883. {
  1884. if (dto.GroupIds.Contains(","))
  1885. {
  1886. groupIds = dto.GroupIds.Split(',').Select(int.Parse).ToList();
  1887. }
  1888. else
  1889. {
  1890. groupIds.Add(int.Parse(dto.GroupIds));
  1891. }
  1892. }
  1893. if (!string.IsNullOrEmpty(dto.DailyPaymentIds))
  1894. {
  1895. if (dto.DailyPaymentIds.Contains(","))
  1896. {
  1897. dailyPaymentIds = dto.DailyPaymentIds.Split(',').Select(int.Parse).ToList();
  1898. }
  1899. else
  1900. {
  1901. dailyPaymentIds.Add(int.Parse(dto.DailyPaymentIds));
  1902. }
  1903. }
  1904. #endregion
  1905. requestCheckedView.GroupIds = groupIds;
  1906. requestCheckedView.DailyPaymentIds = dailyPaymentIds;
  1907. if (dto.Type == 1)
  1908. {
  1909. TimeSpan ts = DateTime.Now.AddDays(180) - DateTime.Now; //设置redis 过期时间 半年(180)
  1910. var status = await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("paymentRequestCheckedData", JsonConvert.SerializeObject(requestCheckedView),ts);
  1911. if (status)
  1912. {
  1913. return Ok(JsonView(true, "操作成功!"));
  1914. }
  1915. }
  1916. else if(dto.Type == 2)
  1917. {
  1918. var status = await RedisRepository.RedisFactory.CreateRedisRepository().KeyDeleteAsync("paymentRequestCheckedData" );
  1919. if (status)
  1920. {
  1921. return Ok(JsonView(true, "操作成功!"));
  1922. }
  1923. }
  1924. return Ok(JsonView(false, "操作失败!"));
  1925. }
  1926. catch (Exception ex)
  1927. {
  1928. return Ok(JsonView(false, ex.Message));
  1929. }
  1930. }
  1931. /// <summary>
  1932. /// 付款申请 (PageId=51)
  1933. /// 团组,日付相关费用 汇率变更
  1934. /// </summary>
  1935. /// <param name="dto"></param>
  1936. /// <returns></returns>
  1937. [HttpPost]
  1938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1939. public async Task<IActionResult> PostPayRequestRateChange(PayRequestRateChangeDto dto)
  1940. {
  1941. #region 验证
  1942. DateTime beginDt, endDt;
  1943. string format = "yyyy-MM-dd";
  1944. if (!DateTime.TryParseExact(dto.beginDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out beginDt))
  1945. {
  1946. return Ok(JsonView(false, "开始日期格式不正确!正确格式:yyyy-MM-dd"));
  1947. }
  1948. if (!DateTime.TryParseExact(dto.endDt, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out endDt))
  1949. {
  1950. return Ok(JsonView(false, "结束日期格式不正确!正确格式:yyyy-MM-dd"));
  1951. }
  1952. if (dto.UserId < 1)
  1953. {
  1954. return Ok(JsonView(false, "请传入有效的UserId参数!"));
  1955. }
  1956. if (dto.Id < 1)
  1957. {
  1958. return Ok(JsonView(false, "请传入有效的Id参数!"));
  1959. }
  1960. if (dto.Rate <= 0)
  1961. {
  1962. return Ok(JsonView(false, "请传入有效的Rate参数!"));
  1963. }
  1964. #endregion
  1965. try
  1966. {
  1967. var status = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  1968. .SetColumns(it => it.DayRate == dto.Rate)
  1969. .Where(it => it.Id == dto.Id)
  1970. .ExecuteCommand();
  1971. if (status > 0)
  1972. {
  1973. PaymentRequestCheckedView checkedView = new PaymentRequestCheckedView();
  1974. var checkedStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("paymentRequestCheckedData");
  1975. if (checkedStr != null)
  1976. {
  1977. checkedView = JsonConvert.DeserializeObject<PaymentRequestCheckedView>(checkedStr.ToString());
  1978. }
  1979. tree_Fin_DailyFeePaymentResult dailyResult = PayRequest_DailyByDateRange(1, checkedView.DailyPaymentIds, dto.beginDt, dto.endDt);
  1980. tree_Group_DailyFeePaymentResult groupResult = PayRequest_GroupPaymentByDateRange(1, checkedView.GroupIds, dto.beginDt, dto.endDt);
  1981. decimal _gz = dailyResult.gz + groupResult.gz;
  1982. decimal _sz = dailyResult.sz + groupResult.sz;
  1983. return Ok(JsonView(true, "获取成功", new { gz = dailyResult, sz = groupResult }));
  1984. }
  1985. return Ok(JsonView(false, "该项汇率修改失败!"));
  1986. }
  1987. catch (Exception ex)
  1988. {
  1989. return Ok(JsonView(false, ex.Message));
  1990. }
  1991. }
  1992. /// <summary>
  1993. /// 付款申请 (PageId=51)
  1994. /// 团组,日付相关费用 付款状态变更
  1995. /// </summary>
  1996. /// <param name="dto"></param>
  1997. /// <returns></returns>
  1998. [HttpPost]
  1999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2000. public async Task<IActionResult> PostPayRequestPayChange(PayRequestPayChangeDto dto)
  2001. {
  2002. if (dto.UserId < 1)
  2003. {
  2004. return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2005. }
  2006. //if (string.IsNullOrEmpty(dto.GroupIds))
  2007. //{
  2008. // return Ok(JsonView(false, "请传入有效的GroupIds参数!"));
  2009. //}
  2010. //if (string.IsNullOrEmpty(dto.DailyPaymentIds))
  2011. //{
  2012. // return Ok(JsonView(false, "请传入有效的DailyPaymentIds参数!"));
  2013. //}
  2014. try
  2015. {
  2016. List<int> groupIds = new List<int>();
  2017. List<int> dailyPaymentIds = new List<int>();
  2018. #region 参数处理
  2019. if (!string.IsNullOrEmpty(dto.GroupIds))
  2020. {
  2021. if (dto.GroupIds.Contains(","))
  2022. {
  2023. groupIds = dto.GroupIds.Split(',').Select(int.Parse).ToList();
  2024. }
  2025. else
  2026. {
  2027. groupIds.Add(int.Parse(dto.GroupIds));
  2028. }
  2029. }
  2030. if (!string.IsNullOrEmpty(dto.DailyPaymentIds))
  2031. {
  2032. if (dto.DailyPaymentIds.Contains(","))
  2033. {
  2034. dailyPaymentIds = dto.DailyPaymentIds.Split(',').Select(int.Parse).ToList();
  2035. }
  2036. else
  2037. {
  2038. dailyPaymentIds.Add(int.Parse(dto.DailyPaymentIds));
  2039. }
  2040. }
  2041. #endregion
  2042. bool changeStatus = false;
  2043. _sqlSugar.BeginTran();
  2044. if (groupIds.Count > 0)
  2045. {
  2046. var groupStatus = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2047. .SetColumns(it => it.IsPay == 1)
  2048. .Where(it => groupIds.Contains(it.Id))
  2049. .ExecuteCommand();
  2050. if (groupStatus > 0)
  2051. {
  2052. changeStatus = true;
  2053. }
  2054. }
  2055. if (dailyPaymentIds.Count > 0)
  2056. {
  2057. var dailyPaymentStatus = _sqlSugar.Updateable<Fin_DailyFeePayment>()
  2058. .SetColumns(it => it.IsPay == 1)
  2059. .Where(it => dailyPaymentIds.Contains(it.Id))
  2060. .ExecuteCommand();
  2061. if (dailyPaymentStatus > 0)
  2062. {
  2063. changeStatus = true;
  2064. }
  2065. }
  2066. if (changeStatus)
  2067. {
  2068. _sqlSugar.CommitTran();
  2069. return Ok(JsonView(true, "操作成功!"));
  2070. }
  2071. _sqlSugar.RollbackTran();
  2072. return Ok(JsonView(false, "付款状态修改失败!"));
  2073. }
  2074. catch (Exception ex)
  2075. {
  2076. _sqlSugar.RollbackTran();
  2077. return Ok(JsonView(false, ex.Message));
  2078. }
  2079. }
  2080. /// <summary>
  2081. /// 付款申请 (PageId=51)
  2082. /// 文件下载
  2083. /// </summary>
  2084. /// <param name="dto"></param>
  2085. /// <returns></returns>
  2086. [HttpPost]
  2087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2088. public async Task<IActionResult> PostPayRequestFileDownload(PayRequestFileDownloadDto dto)
  2089. {
  2090. #region 参数,权限 验证
  2091. if (dto.PortType < 1)
  2092. {
  2093. return Ok(JsonView(false, "请传入有效的PortType参数!"));
  2094. }
  2095. if (dto.UserId < 1)
  2096. {
  2097. return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2098. }
  2099. if (dto.PageId < 1)
  2100. {
  2101. dto.PageId = 51;
  2102. return Ok(JsonView(false, "请传入有效的PageId参数!"));
  2103. }
  2104. if (dto.ConpanyId < 1 || dto.ConpanyId > 4)
  2105. {
  2106. return Ok(JsonView(false, "请传入有效的ConpanyId参数!"));
  2107. }
  2108. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2109. #region 页面操作权限验证
  2110. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  2111. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  2112. #endregion
  2113. #endregion
  2114. try
  2115. {
  2116. PaymentRequestCheckedView checkedView = new PaymentRequestCheckedView();
  2117. var checkedStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("paymentRequestCheckedData");
  2118. if (checkedStr != null)
  2119. {
  2120. checkedView = JsonConvert.DeserializeObject<PaymentRequestCheckedView>(checkedStr.ToString());
  2121. }
  2122. if (checkedView == null )
  2123. {
  2124. return Ok(JsonView(false, "没有选中的数据!"));
  2125. }
  2126. if (checkedView.GroupIds == null && checkedView.DailyPaymentIds == null)
  2127. {
  2128. return Ok(JsonView(false, "没有选中的数据!"));
  2129. }
  2130. tree_Fin_DailyFeePaymentResult dailyResult = PayRequest_DailyByDateRange(2, checkedView.DailyPaymentIds, dto.beginDt, dto.endDt);
  2131. tree_Group_DailyFeePaymentResult groupResult = PayRequest_GroupPaymentByDateRange(2, checkedView.GroupIds, dto.beginDt, dto.endDt);
  2132. string _requestPayment = DateTime.Now.ToString("yyyy-MM-dd");//申请付款日期
  2133. //1 成都泛美商务有限公司
  2134. if (dto.ConpanyId == 1)
  2135. {
  2136. }
  2137. //2 四川泛美交流有限公司
  2138. else if (dto.ConpanyId == 2)
  2139. {
  2140. }
  2141. //3 成都纽茵教育科技有限公司
  2142. else if (dto.ConpanyId == 3)
  2143. {
  2144. }
  2145. //4 成都鸿企中元科技有限公司
  2146. else if (dto.ConpanyId == 4)
  2147. {
  2148. }
  2149. else
  2150. {
  2151. return Ok(JsonView(false, "参数ConpanyId不可使用!"));
  2152. }
  2153. return Ok(JsonView(false, "操作失败!"));
  2154. }
  2155. catch (Exception ex)
  2156. {
  2157. return Ok(JsonView(false, ex.Message));
  2158. }
  2159. }
  2160. #endregion
  2161. #region 超支费用
  2162. /// <summary>
  2163. /// 超支费用
  2164. /// 1增、2改、3删
  2165. /// </summary>
  2166. /// <param name="dto"></param>
  2167. /// <returns></returns>
  2168. [HttpPost]
  2169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2170. public async Task<IActionResult> PostGroupExtraCost_Operator(Fin_GroupExtraCostDto_OP dto)
  2171. {
  2172. #region 验证
  2173. #endregion
  2174. Fin_GroupExtraCost _entity = new Fin_GroupExtraCost();
  2175. _entity.DiId = dto.diId;
  2176. _entity.PriceName = dto.priceName;
  2177. _entity.Price = dto.price;
  2178. _entity.PriceCurrency = dto.currency;
  2179. _entity.PriceType = dto.priceType;
  2180. _entity.Coefficient = dto.coefficient;
  2181. _entity.PriceDetailType = dto.priceDetailType;
  2182. _entity.FilePath = dto.filePath;
  2183. _entity.Remark = dto.remark;
  2184. _daiRep.BeginTran();
  2185. if (dto.editType == 1)
  2186. {
  2187. _entity.CreateUserId = dto.createUser;
  2188. _entity.CreateTime = DateTime.Now;
  2189. _entity.IsDel = 0;
  2190. int returnId = await _daiRep.AddAsyncReturnId<Fin_GroupExtraCost>(_entity);
  2191. if (returnId > 0)
  2192. {
  2193. dto.Id = returnId;
  2194. }
  2195. }
  2196. else if (dto.editType == 2)
  2197. {
  2198. bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
  2199. {
  2200. PriceName = dto.priceName,
  2201. Price = dto.price,
  2202. PriceCurrency = dto.currency,
  2203. PriceType = dto.priceType,
  2204. PriceDetailType = dto.priceDetailType,
  2205. Coefficient = dto.coefficient,
  2206. FilePath = dto.filePath,
  2207. Remark = dto.remark
  2208. });
  2209. if (!res)
  2210. {
  2211. _daiRep.RollbackTran();
  2212. return Ok(JsonView(false, "2操作失败!"));
  2213. }
  2214. }
  2215. else if (dto.editType == 3)
  2216. {
  2217. string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
  2218. bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
  2219. {
  2220. IsDel = 1,
  2221. DeleteTime = delTime,
  2222. DeleteUserId = dto.createUser
  2223. });
  2224. if (!res)
  2225. {
  2226. _daiRep.RollbackTran();
  2227. return Ok(JsonView(false, "3操作失败!"));
  2228. }
  2229. }
  2230. else
  2231. {
  2232. _daiRep.RollbackTran();
  2233. return Ok(JsonView(false, "未知的editType"));
  2234. }
  2235. if (!extraCost_editCreditCardPayment(dto))
  2236. {
  2237. return Ok(JsonView(false, "ccp操作失败"));
  2238. }
  2239. _daiRep.CommitTran();
  2240. return Ok(JsonView(false, "操作成功"));
  2241. }
  2242. private bool extraCost_editCreditCardPayment(Fin_GroupExtraCostDto_OP costDto)
  2243. {
  2244. //设置团组汇率
  2245. decimal dcm_dayrate = 1M;
  2246. decimal dcm_rmbPrice = costDto.price;
  2247. int ispay = costDto.payType == 72 ? 1 : 0;
  2248. if (costDto.costSign != 3)
  2249. {
  2250. Grp_TeamRate tr = _daiRep.Query<Grp_TeamRate>(s => s.DiId == costDto.diId && s.CTable == 1015).First();
  2251. if (tr != null)
  2252. {
  2253. if (costDto.currency == 49)
  2254. {
  2255. dcm_dayrate = tr.RateU;
  2256. dcm_rmbPrice = dcm_rmbPrice * tr.RateU;
  2257. }
  2258. else if (costDto.currency == 51)
  2259. {
  2260. dcm_dayrate = tr.RateE;
  2261. dcm_rmbPrice = dcm_rmbPrice * tr.RateE;
  2262. }
  2263. }
  2264. }
  2265. Grp_CreditCardPayment ccp = _daiRep.Query<Grp_CreditCardPayment>(s => s.CId == costDto.Id && s.CTable == 1015).First();
  2266. if (ccp == null)
  2267. {
  2268. ccp = new Grp_CreditCardPayment();
  2269. ccp.PayDId = costDto.payType;// dto
  2270. ccp.ConsumptionPatterns = "";
  2271. ccp.ConsumptionDate = "";
  2272. ccp.CTDId = costDto.payCardId;// dto
  2273. ccp.BankNo = "";
  2274. ccp.CardholderName = "";
  2275. ccp.PayMoney = costDto.price;// dto
  2276. ccp.PaymentCurrency = costDto.currency;// dto
  2277. ccp.CompanyBankNo = "";
  2278. ccp.OtherBankName = "";
  2279. ccp.OtherSideNo = "";
  2280. ccp.OtherSideName = "";
  2281. ccp.Remark = "";
  2282. ccp.CreateUserId = costDto.createUser;
  2283. ccp.CreateTime = DateTime.Now;
  2284. ccp.MFOperator = 0;
  2285. ccp.MFOperatorDate = "";
  2286. ccp.IsAuditDM = 0;
  2287. ccp.AuditDMOperate = 0;
  2288. ccp.AuditDMDate = "";
  2289. ccp.IsAuditMF = 0;
  2290. ccp.AuditMFOperate = 0;
  2291. ccp.AuditMFDate = "";
  2292. ccp.IsAuditGM = 0;
  2293. ccp.AuditGMOperate = 0;
  2294. ccp.AuditGMDate = "";
  2295. ccp.IsPay = ispay; // upd
  2296. ccp.DIId = costDto.diId;// dto
  2297. ccp.CId = costDto.Id;// dto
  2298. ccp.CTable = 1015; //超支费用指向id
  2299. ccp.IsDel = 0;
  2300. ccp.PayPercentage = 100M;
  2301. ccp.PayThenMoney = 0M;
  2302. ccp.PayPercentageOld = 100M;
  2303. ccp.PayThenMoneyOld = 0M;
  2304. ccp.UpdateDate = "";
  2305. ccp.Payee = costDto.payee;// dto
  2306. ccp.OrbitalPrivateTransfer = costDto.costSign;// dto
  2307. ccp.ExceedBudget = 0;
  2308. ccp.DayRate = dcm_dayrate; //upd
  2309. ccp.RMBPrice = dcm_rmbPrice; //upd
  2310. int ccpInsertId = _daiRep.AddReturnId<Grp_CreditCardPayment>(ccp);
  2311. if (ccpInsertId > 0)
  2312. {
  2313. return true;
  2314. }
  2315. }
  2316. else
  2317. {
  2318. if (costDto.editType == 2)
  2319. {
  2320. bool res = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
  2321. {
  2322. PayDId = costDto.payType,
  2323. CTDId = costDto.payCardId,
  2324. PayMoney = costDto.price,
  2325. PaymentCurrency = costDto.currency,
  2326. IsPay = ispay,
  2327. Payee = costDto.payee,
  2328. OrbitalPrivateTransfer = costDto.costSign,
  2329. DayRate = dcm_dayrate,
  2330. RMBPrice = dcm_rmbPrice
  2331. });
  2332. return res;
  2333. }
  2334. else if (costDto.editType == 3)
  2335. {
  2336. string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
  2337. bool res2 = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
  2338. {
  2339. IsDel = 1,
  2340. DeleteTime = delTime,
  2341. DeleteUserId = costDto.createUser
  2342. });
  2343. return res2;
  2344. }
  2345. }
  2346. return false;
  2347. }
  2348. /// <summary>
  2349. /// 超支费用
  2350. /// 列表查询
  2351. /// </summary>
  2352. /// <param name="dto"></param>
  2353. /// <returns></returns>
  2354. [HttpPost]
  2355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2356. public async Task<IActionResult> PostGroupExtraCost_Search(Fin_GroupExtraCostDto_Search dto)
  2357. {
  2358. string sqlWhere = string.Format(@" And f.DiId = {0} ", dto.diId);
  2359. int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
  2360. int endIndex = startIndex + dto.PageSize - 1;
  2361. string sql_data = string.Format(@"Select * From (
  2362. Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
  2363. f.PriceName,f.Price,f.FilePath,f.CreateUserId,f.CreateTime,c.IsAuditGM
  2364. From Fin_GroupExtraCost f
  2365. Inner Join Grp_CreditCardPayment c On f.Id = c.CId
  2366. Left Join Sys_Users u On f.CreateUserId = u.Id
  2367. Where f.IsDel=0 And c.CTable = 1015 {0}
  2368. ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
  2369. string sql_count = string.Format(@"Select Count(1) as DataCount From (
  2370. Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
  2371. f.PriceName,f.PriceType,f.Price,f.FilePath,f.CreateUserId,f.CreateTime,c.IsAuditGM
  2372. From Fin_GroupExtraCost f
  2373. Inner Join Grp_CreditCardPayment c On f.Id = c.CId
  2374. Left Join Sys_Users u On f.CreateUserId = u.Id
  2375. Where f.IsDel=0 And c.CTable = 1015 {0}
  2376. ) temp ", sqlWhere);
  2377. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  2378. {
  2379. //Fin_DailyFeePaymentPageCount
  2380. var count = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostViewDataCount>(sql_count).FirstAsync();
  2381. List<Fin_GroupExtraCostView> dataList = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostView>(sql_data).ToListAsync();
  2382. Dictionary<int, string> dic_setData = new Dictionary<int, string>();
  2383. Dictionary<int, string> dic_user = new Dictionary<int, string>();
  2384. foreach (var item in dataList)
  2385. {
  2386. //费用详细类型
  2387. if (dic_setData.ContainsKey(item.PriceType))
  2388. {
  2389. item.PriceTypeStr = dic_setData[item.PriceType];
  2390. }
  2391. else
  2392. {
  2393. Sys_SetData sd_priceTypeDetail = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceType).First();
  2394. if (sd_priceTypeDetail != null)
  2395. {
  2396. string tempName = sd_priceTypeDetail.Name.Replace("n", "");
  2397. item.PriceTypeStr = tempName;
  2398. dic_setData.Add(item.PriceType, tempName);
  2399. }
  2400. }
  2401. //系统用户
  2402. if (dic_user.ContainsKey(item.CreateUserId))
  2403. {
  2404. item.CreateUserIdStr = dic_setData[item.CreateUserId];
  2405. }
  2406. else
  2407. {
  2408. Sys_Users users = _daiRep.Query<Sys_Users>(s => s.Id == item.CreateUserId).First();
  2409. if (users != null)
  2410. {
  2411. item.CreateUserIdStr = users.CnName;
  2412. dic_setData.Add(item.CreateUserId, users.CnName);
  2413. }
  2414. }
  2415. switch (item.IsAuditGM)
  2416. {
  2417. case 0: item.IsAuditGMStr = "未审核"; break;
  2418. case 1: item.IsAuditGMStr = "已通过"; break;
  2419. case 2: item.IsAuditGMStr = "未通过"; break;
  2420. default: item.IsAuditGMStr = "未知状态"; break;
  2421. }
  2422. }
  2423. var result = new ListViewBase<Fin_GroupExtraCostView>
  2424. {
  2425. CurrPageIndex = dto.PageIndex,
  2426. CurrPageSize = dto.PageSize,
  2427. DataCount = count.DataCount,
  2428. DataList = dataList
  2429. };
  2430. return Ok(JsonView(true, "查询成功", result));
  2431. }
  2432. return Ok(JsonView(false, "查询成功"));
  2433. }
  2434. /// <summary>
  2435. /// 超支费用
  2436. /// 数据集合配置
  2437. /// </summary>
  2438. /// <param name="dto"></param>
  2439. /// <returns></returns>
  2440. [HttpPost]
  2441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2442. public async Task<IActionResult> PostGroupExtraCost_ListDataInit(Fin_GroupExtraCostDto_DataListInit dto)
  2443. {
  2444. //支付方式
  2445. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  2446. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  2447. //信用卡类型
  2448. List<Sys_SetData> Card = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  2449. List<SetDataInfoView> _Card = _mapper.Map<List<SetDataInfoView>>(Card);
  2450. //超支费用类型
  2451. List<Sys_SetData> PriceType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 79 && a.IsDel == 0).ToList();
  2452. List<SetDataInfoView> _PriceType = _mapper.Map<List<SetDataInfoView>>(PriceType);
  2453. //超支费用详细类型
  2454. List<Sys_SetData> PriceDetailType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 80 && a.IsDel == 0).ToList();
  2455. PriceDetailType.ForEach(a => { a.Name = a.Name.Replace("n", ""); });
  2456. List<SetDataInfoView> _PriceDetailType = _mapper.Map<List<SetDataInfoView>>(PriceDetailType);
  2457. var data = new
  2458. {
  2459. Payment = _Payment,
  2460. Card = _Card,
  2461. PriceType = _PriceType,
  2462. PriceDetailType = _PriceDetailType
  2463. };
  2464. return Ok(JsonView(true, "", data));
  2465. }
  2466. #endregion
  2467. }
  2468. }