FinancialController.cs 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400
  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. namespace OASystem.API.Controllers
  20. {
  21. /// <summary>
  22. /// 财务模块
  23. /// </summary>
  24. [Route("api/[controller]/[action]")]
  25. [ApiController]
  26. public class FinancialController : ControllerBase
  27. {
  28. private readonly IMapper _mapper;
  29. private readonly IConfiguration _config;
  30. private readonly SqlSugarClient _sqlSugar;
  31. private readonly SetDataTypeRepository _setDataTypeRep;
  32. private readonly DailyFeePaymentRepository _daiRep; //日付申请仓库
  33. private readonly TeamRateRepository _teamRateRep; //团组汇率仓库
  34. private readonly ForeignReceivablesRepository _ForForeignReceivablesRep; //对外收款账单仓库
  35. private readonly ProceedsReceivedRepository _proceedsReceivedRep; //已收款项仓库
  36. private readonly PaymentRefundAndOtherMoneyRepository _paymentRefundAndOtherMoneyRep; //收款退还与其他款项 仓库
  37. /// <summary>
  38. /// 初始化
  39. /// </summary>
  40. public FinancialController(IMapper mapper, IConfiguration configuration, DailyFeePaymentRepository daiRep, SqlSugarClient sqlSugar, SetDataTypeRepository setDataTypeRep,
  41. TeamRateRepository teamRateRep, ForeignReceivablesRepository ForForeignReceivablesRep, ProceedsReceivedRepository proceedsReceivedRep,
  42. PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep)
  43. {
  44. _mapper = mapper;
  45. _config = configuration;
  46. _daiRep = daiRep;
  47. _sqlSugar = sqlSugar;
  48. _setDataTypeRep = setDataTypeRep;
  49. _teamRateRep = teamRateRep;
  50. _ForForeignReceivablesRep = ForForeignReceivablesRep;
  51. _proceedsReceivedRep = proceedsReceivedRep;
  52. _paymentRefundAndOtherMoneyRep = paymentRefundAndOtherMoneyRep;
  53. }
  54. #region 日付申请
  55. /// <summary>
  56. /// 获取日付申请 基础数据源
  57. /// </summary>
  58. /// <param name="dto"> 日付申请 分页 dto</param>
  59. /// <returns></returns>
  60. [HttpPost]
  61. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  62. public async Task<IActionResult> PostPageSearchDailyPaymentPriceTypeData(PortDtoBase dto)
  63. {
  64. var result = await _daiRep.GetPagePriceTypeData(dto);
  65. if (result == null || result.Code != 0)
  66. {
  67. return Ok(JsonView(false, result.Msg));
  68. }
  69. var data = result.Data;
  70. return Ok(JsonView(data));
  71. }
  72. /// <summary>
  73. /// 获取日付申请 基础数据源 - 转账表识
  74. /// </summary>
  75. /// <param name="dto"> 日付申请 分页 dto</param>
  76. /// <returns></returns>
  77. [HttpPost]
  78. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  79. public async Task<IActionResult> GetSearchDailyPaymentPriceTypeAddData(PortDtoBase dto)
  80. {
  81. var result = await _daiRep.GetPriceTypeAddData(dto);
  82. if (result == null || result.Code != 0)
  83. {
  84. return Ok(JsonView(false, result.Msg));
  85. }
  86. var data = result.Data;
  87. return Ok(JsonView(data));
  88. }
  89. /// <summary>
  90. /// 日付申请 Page Search
  91. /// </summary>
  92. /// <param name="dto"> 日付申请 分页 dto</param>
  93. /// <returns></returns>
  94. [HttpPost]
  95. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  96. public async Task<IActionResult> PostPageSearchDailyPaymentList(PageDailyFeePaymentDto dto)
  97. {
  98. var result = await _daiRep.GetPageSearchAll(dto);
  99. if (result == null || result.Code != 0)
  100. {
  101. return Ok(JsonView(false, result.Msg));
  102. }
  103. var data = result.Data;
  104. if (data == null)
  105. {
  106. return Ok(JsonView(false, result.Msg));
  107. }
  108. return Ok(JsonView(data));
  109. }
  110. /// <summary>
  111. /// 日付申请 Single Search By Id
  112. /// </summary>
  113. /// <param name="dto"></param>
  114. /// <returns></returns>
  115. [HttpPost]
  116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  117. public async Task<IActionResult> PostSearchDailyPaymentInfo(SearchDailyFeePaymentDto dto)
  118. {
  119. var result = await _daiRep.GetSearchById(dto);
  120. if (result == null || result.Code != 0)
  121. {
  122. return Ok(JsonView(false, result.Msg));
  123. }
  124. return Ok(JsonView(result.Data));
  125. }
  126. /// <summary>
  127. /// 日付申请 添加
  128. /// </summary>
  129. /// <param name="dto"> 日付申请 添加 dto</param>
  130. /// <returns></returns>
  131. [HttpPost]
  132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  133. public async Task<IActionResult> PostAddDailyPayment(AddDailyFeePaymentDto dto)
  134. {
  135. var result = await _daiRep.Add(dto);
  136. if (result == null || result.Code != 0)
  137. {
  138. return Ok(JsonView(false, result.Msg));
  139. }
  140. return Ok(JsonView(true));
  141. }
  142. /// <summary>
  143. /// 日付申请 Update
  144. /// </summary>
  145. /// <param name="dto"> 日付申请 修改 dto</param>
  146. /// <returns></returns>
  147. [HttpPost]
  148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  149. public async Task<IActionResult> PostEditDailyPayment(EditDailyFeePaymentDto dto)
  150. {
  151. var result = await _daiRep.Edit(dto);
  152. if (result == null || result.Code != 0)
  153. {
  154. return Ok(JsonView(false, result.Msg));
  155. }
  156. return Ok(JsonView(true));
  157. }
  158. /// <summary>
  159. /// 日付申请 Del
  160. /// </summary>
  161. /// <param name="dto"> 日付申请 删除 dto</param>
  162. /// <returns></returns>
  163. [HttpPost]
  164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  165. public async Task<IActionResult> PostDelDailyPayment(DelDailyFeePaymentDto dto)
  166. {
  167. var result = await _daiRep.Del(dto);
  168. if (result == null || result.Code != 0)
  169. {
  170. return Ok(JsonView(false, result.Msg));
  171. }
  172. return Ok(JsonView(true));
  173. }
  174. /// <summary>
  175. /// 日付申请 财务审核
  176. /// </summary>
  177. /// <param name="dto"> dto </param>
  178. /// <returns></returns>
  179. [HttpPost]
  180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  181. public async Task<IActionResult> PostDelDailyPaymentAudit(DP_AuditStatusDto dto)
  182. {
  183. var result = await _daiRep.DelDailyPaymentAudit(dto);
  184. if (result == null || result.Code != 0)
  185. {
  186. return Ok(JsonView(false, result.Msg));
  187. }
  188. return Ok(JsonView(true));
  189. }
  190. /// <summary>
  191. /// 日付申请 Single Excel Download
  192. /// </summary>
  193. /// <param name="dto"> dto </param>
  194. /// <returns></returns>
  195. [HttpPost]
  196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  197. public async Task<IActionResult> PostExcelDailyPaymentDownload(SearchDailyFeePaymentDto dto)
  198. {
  199. if (dto.PortType == 1 || dto.PortType == 2)
  200. {
  201. Fin_DailyFeePaymentInfolView feeData = new Fin_DailyFeePaymentInfolView();
  202. string feeSql = string.Format(@"Select * From Fin_DailyFeePayment
  203. Where IsDel=0 And Id = {0} ", dto.Id);
  204. feeData = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentInfolView>(feeSql).FirstAsync();
  205. if (feeData == null)
  206. {
  207. return Ok(JsonView(false, "暂无数据!"));
  208. }
  209. string feeContentSql = string.Format(@"Select * From Fin_DailyFeePaymentContent
  210. Where IsDel=0 And DFPId = {0} ", dto.Id);
  211. feeData.FeeContents = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentContentInfolView>(feeContentSql).ToListAsync();
  212. if (feeData != null)
  213. {
  214. string userName = string.Empty;
  215. string userSql = string.Format("Select * From Sys_Users Where Id={0} And Isdel = {1}", feeData.CreateUserId, 0);
  216. Sys_Users user = await _sqlSugar.SqlQueryable<Sys_Users>(userSql).FirstAsync();
  217. if (user != null) { userName = user.CnName; }
  218. var setData = _setDataTypeRep.QueryDto<Sys_SetData, Fin_DailyFeePaymentPagePriceSubTypeView>().ToList();
  219. //48人员费用 49办公费用 50 销售费用 51 其他费用 55 大运会
  220. var priceSubTypeData = setData.Where(s => s.STid == 55).ToList();
  221. Dictionary<string, object> pairs = new Dictionary<string, object>();
  222. List<DataTable> datas = new List<DataTable>();
  223. //if (priceSubTypeData.Where(s => s.Id == feeData.PriceTypeId).ToList().Count() > 0)//大运会专属模板
  224. //{
  225. // //AsposeHelper.ExpertExcelToModel("日常费用付款申请模板-大运会数据.xls", "DailyPayment", "大运会所有日常费用付款申请.xls",
  226. // // pairs, datas);
  227. //}
  228. //else //日付常规模板
  229. //{
  230. pairs.Clear();
  231. pairs.Add("Opertor", userName);
  232. pairs.Add("DateTime", feeData.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  233. pairs.Add("FAuditStatus", feeData.FAuditDesc);
  234. pairs.Add("MAuditStatus", feeData.MAuditDesc);
  235. pairs.Add("SumPrice", feeData.SumPrice);
  236. DataTable data = AsposeHelper.ListToDataTable("DailyFeePayment", feeData.FeeContents);
  237. datas.Clear();
  238. datas.Add(data);
  239. string fileName = string.Format("{0}-日常费用付款申请.xlsx", feeData.Instructions);
  240. string msg = AsposeHelper.ExpertExcelToModel("日常费用付款申请模板.xlsx", "DailyPayment", fileName, pairs, datas);
  241. return Ok(JsonView(true, msg));
  242. //}
  243. }
  244. else
  245. {
  246. return Ok(JsonView(false, "暂无数据!"));
  247. }
  248. }
  249. return Ok(JsonView(true));
  250. }
  251. #endregion
  252. #region 团组提成
  253. /// <summary>
  254. /// 提成 Page Search
  255. /// </summary>
  256. /// <param name="dto"> 提成 分页 dto</param>
  257. /// <returns></returns>
  258. [HttpPost]
  259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  260. public async Task<IActionResult> PostPageSearchCommissionList(GroupCommissionDto dto)
  261. {
  262. var data = await GroupCommission.GetCommissionPageList(dto);
  263. return Ok(JsonView(data.Data));
  264. }
  265. #endregion
  266. #region 团组汇率
  267. /// <summary>
  268. /// 团组汇率 Select数据源(团组列,汇率列)
  269. /// </summary>
  270. /// <param name="dto"></param>
  271. /// <returns></returns>
  272. [HttpPost]
  273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  274. public async Task<IActionResult> GetGroupRateDataSources(TeamRateDto dto)
  275. {
  276. try
  277. {
  278. Result teamRateData = await _teamRateRep.GetGroupRateDataSource(dto);
  279. if (teamRateData.Code != 0)
  280. {
  281. return Ok(JsonView(false, teamRateData.Msg));
  282. }
  283. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  284. }
  285. catch (Exception ex)
  286. {
  287. return Ok(JsonView(false, ex.Message));
  288. throw;
  289. }
  290. }
  291. ///// <summary>
  292. ///// 团组汇率 changge
  293. ///// </summary>
  294. ///// <returns></returns>
  295. //[HttpPost]
  296. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  297. //public async Task<IActionResult> ChangeGroupRateInfo()
  298. //{
  299. // try
  300. // {
  301. // Result teamRateData = await _teamRateRep.GetGroupRateChangeData();
  302. // if (teamRateData.Code != 0)
  303. // {
  304. // return Ok(JsonView(false, teamRateData.Msg));
  305. // }
  306. // return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  307. // }
  308. // catch (Exception ex)
  309. // {
  310. // return Ok(JsonView(false, ex.Message));
  311. // throw;
  312. // }
  313. //}
  314. /// <summary>
  315. /// 团组汇率 Select汇率详情
  316. /// </summary>
  317. /// <param name="dto"></param>
  318. /// <returns></returns>
  319. [HttpPost]
  320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  321. public async Task<IActionResult> GetGroupRateInfo(TeamRateInfoDto dto)
  322. {
  323. try
  324. {
  325. Result teamRateData = await _teamRateRep.GetGroupRateInfoByDiid(dto);
  326. if (teamRateData.Code != 0)
  327. {
  328. return Ok(JsonView(false, teamRateData.Msg));
  329. }
  330. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  331. }
  332. catch (Exception ex)
  333. {
  334. return Ok(JsonView(false, ex.Message));
  335. throw;
  336. }
  337. }
  338. /// <summary>
  339. /// 团组汇率 添加 or 更新
  340. /// </summary>
  341. /// <param name="dto"></param>
  342. /// <returns></returns>
  343. [HttpPost]
  344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  345. public async Task<IActionResult> PostGroupRateUpdate(TeamRateUpdateDto dto)
  346. {
  347. try
  348. {
  349. Result teamRateData = await _teamRateRep.PostGroupRateUpdate(dto);
  350. if (teamRateData.Code != 0)
  351. {
  352. return Ok(JsonView(false, teamRateData.Msg));
  353. }
  354. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  355. }
  356. catch (Exception ex)
  357. {
  358. return Ok(JsonView(false, ex.Message));
  359. throw;
  360. }
  361. }
  362. #endregion
  363. #region 对外收款账单 关联已收款项
  364. /// <summary>
  365. /// 对外收款账单 Select数据源(团组名,币种,汇款方式)
  366. /// 关联已收款项
  367. /// </summary>
  368. /// <param name="dto"></param>
  369. /// <returns></returns>
  370. [HttpPost]
  371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  372. public async Task<IActionResult> GetForeignReceivablesDataSources()
  373. {
  374. try
  375. {
  376. Result ffrData = await _ForForeignReceivablesRep.GetDataSource();
  377. if (ffrData.Code != 0)
  378. {
  379. return Ok(JsonView(false, ffrData.Msg));
  380. }
  381. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  382. }
  383. catch (Exception ex)
  384. {
  385. return Ok(JsonView(false, ex.Message));
  386. throw;
  387. }
  388. }
  389. /// <summary>
  390. /// 对外收款账单
  391. /// 账单详情
  392. /// 关联已收款项
  393. /// </summary>
  394. /// <param name="dto"></param>
  395. /// <returns></returns>
  396. [HttpPost]
  397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  398. public async Task<IActionResult> GetGroupReceivablesInfoByDiId(ForForeignReceivablesInfoDto dto)
  399. {
  400. try
  401. {
  402. Result ffrData = await _ForForeignReceivablesRep.GetGroupReceivablesInfoByDiId(dto);
  403. if (ffrData.Code != 0)
  404. {
  405. return Ok(JsonView(false, ffrData.Msg));
  406. }
  407. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  408. }
  409. catch (Exception ex)
  410. {
  411. return Ok(JsonView(false, ex.Message));
  412. throw;
  413. }
  414. }
  415. /// <summary>
  416. /// 对外收款账单
  417. /// 账单 删除
  418. /// 关联已收款项
  419. /// </summary>
  420. /// <param name="dto"></param>
  421. /// <returns></returns>
  422. [HttpPost]
  423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  424. public async Task<IActionResult> PostGroupReceivablesDel(DelForForeignReceivablesInfoDto dto)
  425. {
  426. try
  427. {
  428. Result ffrData = await _ForForeignReceivablesRep._Del(dto);
  429. if (ffrData.Code != 0)
  430. {
  431. return Ok(JsonView(false, ffrData.Msg));
  432. }
  433. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  434. }
  435. catch (Exception ex)
  436. {
  437. return Ok(JsonView(false, ex.Message));
  438. throw;
  439. }
  440. }
  441. /// <summary>
  442. /// 对外收款账单
  443. /// 添加 And 更新
  444. /// 关联已收款项
  445. /// </summary>
  446. /// <param name="dto"></param>
  447. /// <returns></returns>
  448. [HttpPost]
  449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  450. public async Task<IActionResult> PostReceivablesOperate(ForeignReceivablesAddAndUpdateDto dto)
  451. {
  452. try
  453. {
  454. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesOperate(dto);
  455. if (ffrData.Code != 0)
  456. {
  457. return Ok(JsonView(false, ffrData.Msg));
  458. }
  459. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  460. }
  461. catch (Exception ex)
  462. {
  463. return Ok(JsonView(false, ex.Message));
  464. throw;
  465. }
  466. }
  467. /// <summary>
  468. /// 已收款项
  469. /// 账单 删除
  470. /// 关联已收款项
  471. /// </summary>
  472. /// <param name="dto"></param>
  473. /// <returns></returns>
  474. [HttpPost]
  475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  476. public async Task<IActionResult> PostAmountReceivedDel(ProceedsReceivedDelDto dto)
  477. {
  478. try
  479. {
  480. Result ffrData = await _proceedsReceivedRep._Del(dto);
  481. if (ffrData.Code != 0)
  482. {
  483. return Ok(JsonView(false, ffrData.Msg));
  484. }
  485. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  486. }
  487. catch (Exception ex)
  488. {
  489. return Ok(JsonView(false, ex.Message));
  490. throw;
  491. }
  492. }
  493. /// <summary>
  494. /// 已收款项
  495. /// 添加 And 更新
  496. /// 关联已收款项
  497. /// </summary>
  498. /// <param name="dto"></param>
  499. /// <returns></returns>
  500. [HttpPost]
  501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  502. public async Task<IActionResult> PostAmountReceivedOperate(ProceedsReceivedDto dto)
  503. {
  504. try
  505. {
  506. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedOperate(dto);
  507. if (ffrData.Code != 0)
  508. {
  509. return Ok(JsonView(false, ffrData.Msg));
  510. }
  511. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  512. }
  513. catch (Exception ex)
  514. {
  515. return Ok(JsonView(false, ex.Message));
  516. throw;
  517. }
  518. }
  519. /// <summary>
  520. /// 财务 已收款项
  521. /// 分配已收款项至 应收项下
  522. /// 关联已收款项
  523. /// </summary>
  524. /// <param name="dto"></param>
  525. /// <returns></returns>
  526. [HttpPost]
  527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  528. public async Task<IActionResult> PostAllocateAmountReceived(AllocateAmountReceivedDto dto)
  529. {
  530. try
  531. {
  532. Result ffrData = await _proceedsReceivedRep.PostAllocateAmountReceived(dto);
  533. if (ffrData.Code != 0)
  534. {
  535. return Ok(JsonView(false, ffrData.Msg));
  536. }
  537. return Ok(JsonView(true));
  538. }
  539. catch (Exception ex)
  540. {
  541. return Ok(JsonView(false, ex.Message));
  542. throw;
  543. }
  544. }
  545. ///// <summary>
  546. ///// 财务 收款账单
  547. ///// 导出Word(北京,四川)
  548. ///// </summary>
  549. ///// <param name="dto"></param>
  550. ///// <returns></returns>
  551. //[HttpPost]
  552. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  553. //public async Task<IActionResult> PostAccountReceivableWordExport(AccountReceivableWordExportDto dto)
  554. //{
  555. // try
  556. // {
  557. // //模板处理
  558. // string typeName = string.Empty;
  559. // if (dto.TemplateType == 1) //四川
  560. // {
  561. // typeName = "四川";
  562. // }
  563. // else if (dto.TemplateType == 2) //北京
  564. // {
  565. // typeName = "北京";
  566. // }
  567. // else return Ok(JsonView(false,"请选择正确的模板类型!"));
  568. // string wordTempName = string.Format("收款账单({0})模板.doc", typeName);
  569. // }
  570. // catch (Exception ex)
  571. // {
  572. // return Ok(JsonView(false, ex.Message));
  573. // }
  574. //}
  575. #endregion
  576. #region 对外收款账单
  577. /// <summary>
  578. /// 对外收款账单
  579. /// 数据源
  580. /// </summary>
  581. /// <param name="dto"></param>
  582. /// <returns></returns>
  583. [HttpPost]
  584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  585. public async Task<IActionResult> PostGroupReceivablesDataSource()
  586. {
  587. try
  588. {
  589. Result ffrData = await _ForForeignReceivablesRep.PostDataSource();
  590. if (ffrData.Code != 0)
  591. {
  592. return Ok(JsonView(false, ffrData.Msg));
  593. }
  594. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  595. }
  596. catch (Exception ex)
  597. {
  598. return Ok(JsonView(false, ex.Message));
  599. throw;
  600. }
  601. }
  602. /// <summary>
  603. /// 对外收款账单
  604. /// 账单详情
  605. /// </summary>
  606. /// <param name="dto"></param>
  607. /// <returns></returns>
  608. [HttpPost]
  609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  610. public async Task<IActionResult> PostGroupReceivablesInfoByDiId(ForForeignReceivablesNewDto dto)
  611. {
  612. try
  613. {
  614. Result ffrData = await _ForForeignReceivablesRep.PostGroupReceivablesInfoByDiId(dto);
  615. if (ffrData.Code != 0)
  616. {
  617. return Ok(JsonView(false, ffrData.Msg));
  618. }
  619. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  620. }
  621. catch (Exception ex)
  622. {
  623. return Ok(JsonView(false, ex.Message));
  624. throw;
  625. }
  626. }
  627. /// <summary>
  628. /// 对外收款账单
  629. /// 添加 And 更新
  630. /// </summary>
  631. /// <param name="dto"></param>
  632. /// <returns></returns>
  633. [HttpPost]
  634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  635. public async Task<IActionResult> PostReceivablesSave(ForeignReceivablesSaveDto dto)
  636. {
  637. try
  638. {
  639. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesSave(dto);
  640. if (ffrData.Code != 0)
  641. {
  642. return Ok(JsonView(false, ffrData.Msg));
  643. }
  644. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  645. }
  646. catch (Exception ex)
  647. {
  648. return Ok(JsonView(false, ex.Message));
  649. throw;
  650. }
  651. }
  652. /// <summary>
  653. /// 已收账单
  654. /// 删除
  655. /// </summary>
  656. /// <param name="dto"></param>
  657. /// <returns></returns>
  658. [HttpPost]
  659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  660. public async Task<IActionResult> PostReceivablesDel(ForeignReceivablesDelDto dto)
  661. {
  662. try
  663. {
  664. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesDel(dto);
  665. if (ffrData.Code != 0)
  666. {
  667. return Ok(JsonView(false, ffrData.Msg));
  668. }
  669. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  670. }
  671. catch (Exception ex)
  672. {
  673. return Ok(JsonView(false, ex.Message));
  674. throw;
  675. }
  676. }
  677. #endregion
  678. #region 已收款项
  679. /// <summary>
  680. /// 已收款项
  681. /// 查询
  682. /// </summary>
  683. /// <param name="dto"></param>
  684. /// <returns></returns>
  685. [HttpPost]
  686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  687. public async Task<IActionResult> PostAmountReceived(AmountReceivedDto dto)
  688. {
  689. try
  690. {
  691. if (dto == null)
  692. {
  693. return Ok(JsonView(false, "参数不能为空!"));
  694. }
  695. Result ffrData = await _proceedsReceivedRep.PostAmountReceived(dto.DiId);
  696. dynamic data = null;
  697. if (dto.PortType == 1)
  698. {
  699. if (ffrData.Code != 0)
  700. {
  701. return Ok(JsonView(false, ffrData.Msg));
  702. }
  703. data = ffrData.Data;
  704. }
  705. else if (dto.PortType == 2)
  706. {
  707. if (ffrData.Code != 0)
  708. {
  709. return Ok(JsonView(false, ffrData.Msg));
  710. }
  711. data = ffrData.Data;
  712. }
  713. else if (dto.PortType == 2)
  714. {
  715. if (ffrData.Code != 0)
  716. {
  717. return Ok(JsonView(false, ffrData.Msg));
  718. }
  719. data = ffrData.Data;
  720. }
  721. else
  722. {
  723. return Ok(JsonView(false, "请选择正确的端口号!"));
  724. }
  725. return Ok(JsonView(true, "操作成功!", data));
  726. }
  727. catch (Exception ex)
  728. {
  729. return Ok(JsonView(false, ex.Message));
  730. }
  731. }
  732. /// <summary>
  733. /// 已收款项
  734. /// Add Or Edit
  735. /// </summary>
  736. /// <param name="dto"></param>
  737. /// <returns></returns>
  738. [HttpPost]
  739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  740. public async Task<IActionResult> PostAmountReceivedAddOrEdit(AmountReceivedAddOrEditDto dto)
  741. {
  742. try
  743. {
  744. if (dto == null)
  745. {
  746. return Ok(JsonView(false, "参数不能为空!"));
  747. }
  748. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedAddOrEditDto(dto);
  749. if (dto.PortType == 1)
  750. {
  751. if (ffrData.Code != 0)
  752. {
  753. return Ok(JsonView(false, ffrData.Msg));
  754. }
  755. }
  756. else if (dto.PortType == 2)
  757. {
  758. if (ffrData.Code != 0)
  759. {
  760. return Ok(JsonView(false, ffrData.Msg));
  761. }
  762. }
  763. else if (dto.PortType == 2)
  764. {
  765. if (ffrData.Code != 0)
  766. {
  767. return Ok(JsonView(false, ffrData.Msg));
  768. }
  769. }
  770. else
  771. {
  772. return Ok(JsonView(false, "请选择正确的端口号!"));
  773. }
  774. return Ok(JsonView(true, "操作成功!"));
  775. }
  776. catch (Exception ex)
  777. {
  778. return Ok(JsonView(false, ex.Message));
  779. }
  780. }
  781. /// <summary>
  782. /// 已收款项
  783. /// Del
  784. /// </summary>
  785. /// <param name="dto"></param>
  786. /// <returns></returns>
  787. [HttpPost]
  788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  789. public async Task<IActionResult> PostAmountReceived_Del(AmountReceivedDelDto dto)
  790. {
  791. try
  792. {
  793. if (dto == null)
  794. {
  795. return Ok(JsonView(false, "参数不能为空!"));
  796. }
  797. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedDel(dto);
  798. if (ffrData.Code != 0)
  799. {
  800. return Ok(JsonView(false, ffrData.Msg));
  801. }
  802. return Ok(JsonView(true, "操作成功!"));
  803. }
  804. catch (Exception ex)
  805. {
  806. return Ok(JsonView(false, ex.Message));
  807. }
  808. }
  809. #endregion
  810. #region 收款退还与其他款项
  811. /// <summary>
  812. /// 收款退还与其他款项
  813. /// 查询 根据团组Id
  814. /// </summary>
  815. /// <param name="dto"></param>
  816. /// <returns></returns>
  817. [HttpPost]
  818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  819. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyItemByDiId(PaymentRefundAndOtherMoneyItemByDiIdDto dto)
  820. {
  821. try
  822. {
  823. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  824. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  825. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  826. #region 页面功能权限处理
  827. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  828. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  829. if (pageFunAuth.CheckAuth == 0)
  830. {
  831. return Ok(JsonView(false, "您没有当前页面查询权限!"));
  832. }
  833. #endregion
  834. Result _result = await _paymentRefundAndOtherMoneyRep._ItemByDiId(dto.DiId);
  835. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //1 Web 2 Android 3 Ios
  836. {
  837. if (_result.Code != 0)
  838. {
  839. return Ok(JsonView(false, _result.Msg));
  840. }
  841. var data = new
  842. {
  843. PageFuncAuth = pageFunAuth,
  844. Data = _result.Data
  845. };
  846. return Ok(JsonView(true, "操作成功!", data));
  847. }
  848. else
  849. {
  850. return Ok(JsonView(false, "请输入正确的端口号! 1 Web 2 Android 3 Ios;"));
  851. }
  852. }
  853. catch (Exception ex)
  854. {
  855. return Ok(JsonView(false, ex.Message));
  856. }
  857. }
  858. /// <summary>
  859. /// 收款退还与其他款项
  860. /// 删除
  861. /// </summary>
  862. /// <param name="dto"></param>
  863. /// <returns></returns>
  864. [HttpPost]
  865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  866. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyDel(PaymentRefundAndOtherMoneyDelDto dto)
  867. {
  868. try
  869. {
  870. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  871. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  872. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  873. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  874. #region 页面功能权限处理
  875. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  876. #endregion
  877. if (pageFunAuth.DeleteAuth == 0)
  878. {
  879. return Ok(JsonView(false, "您没有当前页面删除权限!"));
  880. }
  881. Result _result = await _paymentRefundAndOtherMoneyRep._Del(dto);
  882. if (_result.Code != 0)
  883. {
  884. return Ok(JsonView(false, _result.Msg));
  885. }
  886. return Ok(JsonView(true, "操作成功!"));
  887. }
  888. catch (Exception ex)
  889. {
  890. return Ok(JsonView(false, ex.Message));
  891. }
  892. }
  893. /// <summary>
  894. /// 收款退还与其他款项
  895. /// Info Data Source
  896. /// </summary>
  897. /// <param name="dto"></param>
  898. /// <returns></returns>
  899. [HttpPost]
  900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  901. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyInfoDataSource(PortDtoBase dto)
  902. {
  903. try
  904. {
  905. Result _result = await _paymentRefundAndOtherMoneyRep._InfoDataSource(dto);
  906. if (_result.Code != 0)
  907. {
  908. return Ok(JsonView(false, _result.Msg));
  909. }
  910. return Ok(JsonView(true, "查询成功!", _result.Data));
  911. }
  912. catch (Exception ex)
  913. {
  914. return Ok(JsonView(false, ex.Message));
  915. }
  916. }
  917. /// <summary>
  918. /// 收款退还与其他款项
  919. /// Info
  920. /// </summary>
  921. /// <param name="dto"></param>
  922. /// <returns></returns>
  923. [HttpPost]
  924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  925. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyInfo(PaymentRefundAndOtherMoneyInfoDto dto)
  926. {
  927. try
  928. {
  929. if (dto == null)
  930. {
  931. return Ok(JsonView(false, "参数不能为空!"));
  932. }
  933. Result _result = await _paymentRefundAndOtherMoneyRep._Info(dto);
  934. if (_result.Code != 0)
  935. {
  936. return Ok(JsonView(false, _result.Msg));
  937. }
  938. return Ok(JsonView(true, "查询成功!", _result.Data));
  939. }
  940. catch (Exception ex)
  941. {
  942. return Ok(JsonView(false, ex.Message));
  943. }
  944. }
  945. /// <summary>
  946. /// 收款退还与其他款项
  947. /// 操作(Add Or Edit)
  948. /// </summary>
  949. /// <param name="dto"></param>
  950. /// <returns></returns>
  951. [HttpPost]
  952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  953. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyAddOrEdit(PaymentRefundAndOtherMoneyAddOrEditDto dto)
  954. {
  955. try
  956. {
  957. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  958. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  959. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  960. #region 页面功能权限处理
  961. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  962. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  963. #endregion
  964. if (dto.Status == 1) //add
  965. {
  966. if (pageFunAuth.AddAuth == 0)
  967. {
  968. return Ok(JsonView(false, "您没有当前页面添加权限!"));
  969. }
  970. }
  971. else if (dto.Status == 2) //edit
  972. {
  973. if (pageFunAuth.EditAuth == 0)
  974. {
  975. return Ok(JsonView(false, "您没有当前页面编辑权限!"));
  976. }
  977. }
  978. else
  979. {
  980. return Ok(JsonView(false, "请输入正确的操作状态! 1 添加 2 修改!"));
  981. }
  982. Result _result = await _paymentRefundAndOtherMoneyRep._AddOrEdit(dto);
  983. if (_result.Code != 0)
  984. {
  985. return Ok(JsonView(false, _result.Msg));
  986. }
  987. return Ok(JsonView(true, "操作成功!"));
  988. }
  989. catch (Exception ex)
  990. {
  991. return Ok(JsonView(false, ex.Message));
  992. }
  993. }
  994. #endregion
  995. #region 应收报表
  996. /// <summary>
  997. /// 应收报表
  998. /// 查询 根据日期范围
  999. /// </summary>
  1000. /// <param name="dto"></param>
  1001. /// <returns></returns>
  1002. [HttpPost]
  1003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1004. public async Task<IActionResult> PostSyntheticalReceivableByDateRange(PostSyntheticalReceivableByDateRangeDto dto)
  1005. {
  1006. string sqlWhere = " Where di.IsDel=0 ";
  1007. #region 验证
  1008. if (string.IsNullOrEmpty(dto.beginDt) && string.IsNullOrEmpty(dto.endDt))
  1009. {
  1010. return Ok(JsonView(false, "日期参数至少填写一个!"));
  1011. }
  1012. if (!string.IsNullOrEmpty(dto.beginDt))
  1013. {
  1014. if (Regex.Match(dto.beginDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
  1015. {
  1016. return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
  1017. }
  1018. else
  1019. {
  1020. sqlWhere += string.Format(@" And di.VisitDate >= '{0} 00:00:00' ", dto.beginDt);
  1021. }
  1022. }
  1023. if (!string.IsNullOrEmpty(dto.endDt))
  1024. {
  1025. if (Regex.Match(dto.endDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
  1026. {
  1027. return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
  1028. }
  1029. else
  1030. {
  1031. sqlWhere += string.Format(@" And di.VisitDate <= '{0} 23:59:59' ", dto.endDt);
  1032. }
  1033. }
  1034. #endregion
  1035. 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);
  1036. List<PostSyntheticalReceivableByDateRangeView> list_rst = _sqlSugar.SqlQueryable<PostSyntheticalReceivableByDateRangeView>(sql).ToList();
  1037. decimal sumAll_fr = 0M;
  1038. decimal sumAll_pr = 0M;
  1039. decimal sumAll_balance = 0M;
  1040. if (list_rst.Count > 0)
  1041. {
  1042. int rowNumber = 1;
  1043. foreach (var item_rst in list_rst)
  1044. {
  1045. item_rst.No = rowNumber;
  1046. rowNumber++;
  1047. int diId = item_rst.diid;
  1048. decimal sum_fr = 0M;
  1049. decimal sum_pr = 0M;
  1050. string str_client = string.Empty;
  1051. decimal sum_other = 0M;
  1052. decimal balance = 0M;
  1053. string str_schedule = string.Empty;
  1054. //1. 缺超支费用!!!!!!!!!!!!!!!!!!!!
  1055. string sql_fr = string.Format(@" Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0} ", diId);
  1056. List<Fin_ForeignReceivables> list_fr = _sqlSugar.SqlQueryable<Fin_ForeignReceivables>(sql_fr).ToList();
  1057. sum_fr = list_fr.Sum(s => s.ItemSumPrice);
  1058. //2.
  1059. string sql_pr = string.Format(@" Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0} ", diId);
  1060. List<Fin_ProceedsReceived> list_pr = _sqlSugar.SqlQueryable<Fin_ProceedsReceived>(sql_pr).ToList();
  1061. foreach (var item_pr in list_pr)
  1062. {
  1063. sum_pr += item_pr.Price;
  1064. str_client += string.Format(@"{0};", item_pr.Client);
  1065. str_schedule += string.Format(@"{0};", item_pr.Remark);
  1066. }
  1067. if (str_schedule.Length > 0)
  1068. {
  1069. str_schedule = str_schedule.TrimEnd(';');
  1070. }
  1071. if (str_client.Length > 0)
  1072. {
  1073. str_client = str_client.TrimEnd(';');
  1074. }
  1075. //3.
  1076. string sql_other = string.Format(@" Select * From Fin_OtherPrice where diid = {0} and isdel = 0 and RefundType = 1 and PayType=1 ", diId);
  1077. List<Fin_OtherPrice> list_other = _sqlSugar.SqlQueryable<Fin_OtherPrice>(sql_other).ToList();
  1078. sum_other = list_other.Sum(s => s.Price);
  1079. item_rst.frPrice = sum_fr.ToString("#0.00");
  1080. item_rst.prPrice = (sum_pr - sum_other).ToString("#0.00");
  1081. item_rst.balPrice = (sum_fr - (sum_pr - sum_other)).ToString("#0.00");
  1082. item_rst.prClient = str_client;
  1083. item_rst.schedule = str_schedule;
  1084. string tempVisitDate = Convert.ToDateTime(item_rst.visitDate).ToString("yyyy-MM-dd");
  1085. sumAll_fr += sum_fr;
  1086. sumAll_pr += (sum_pr - sum_other);
  1087. sumAll_balance += (sum_fr - (sum_pr - sum_other));
  1088. }
  1089. PostSyntheticalReceivableByDateRangeResultView result = new PostSyntheticalReceivableByDateRangeResultView();
  1090. result.total_fr = sumAll_fr.ToString("#0.00");
  1091. result.total_pr = sumAll_pr.ToString("#0.00");
  1092. result.total_balance = sumAll_balance.ToString("#0.00");
  1093. result.dataList = new List<PostSyntheticalReceivableByDateRangeView>(list_rst);
  1094. if (dto.requestType == 1)
  1095. {
  1096. return Ok(JsonView(true, "请求成功", result, list_rst.Count));
  1097. }
  1098. else
  1099. {
  1100. //----------------------------
  1101. List<Excel_SyntheticalReceivableByDateRange> list_Ex = new List<Excel_SyntheticalReceivableByDateRange>();
  1102. WorkbookDesigner designer = new WorkbookDesigner();
  1103. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/应收款项模板 - 副本.xls");
  1104. int excNo = 1;
  1105. foreach (var item in list_rst)
  1106. {
  1107. Excel_SyntheticalReceivableByDateRange exc = new Excel_SyntheticalReceivableByDateRange();
  1108. exc.No = excNo.ToString();
  1109. excNo++;
  1110. exc.TeamName = item.teamName;
  1111. exc.ClientUnit = item.clientUnit;
  1112. exc.VisitDate = item.visitDate;
  1113. exc.Accounts = item.frPrice;
  1114. exc.Received = item.prPrice;
  1115. exc.Balance = item.balPrice;
  1116. exc.Collection = item.schedule;
  1117. DateTime time = Convert.ToDateTime(item.visitDate);
  1118. TimeSpan ts = DateTime.Now - time;
  1119. float SY = float.Parse(item.balPrice);
  1120. if (ts.Days >= 365 && SY > 0)
  1121. {
  1122. exc.Sign = "需收款";
  1123. }
  1124. else
  1125. {
  1126. exc.Sign = "";
  1127. }
  1128. list_Ex.Add(exc);
  1129. }
  1130. var dt = CommonFun.GetDataTableFromIList(list_Ex);
  1131. dt.TableName = "Excel_SyntheticalReceivableByDateRange";
  1132. if (dt != null)
  1133. {
  1134. designer.SetDataSource("SumPrice", "应收合计:" + result.total_fr + "RMB 已收合计:" + result.total_pr + "RMB 余款合计:" + result.total_balance + "RMB");
  1135. //数据源
  1136. designer.SetDataSource(dt);
  1137. //根据数据源处理生成报表内容
  1138. designer.Process();
  1139. string fileName = ("Receivable/应收款项(" + dto.beginDt + "~" + dto.endDt + ").xlsx");
  1140. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1141. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1142. return Ok(JsonView(true, "成功", new { url = rst }));
  1143. }
  1144. }
  1145. }
  1146. return Ok(JsonView(true, "获取成功", "", list_rst.Count));
  1147. }
  1148. #endregion
  1149. #region 付款申请
  1150. /// <summary>
  1151. /// 应收报表
  1152. /// 查询 根据日期范围
  1153. /// </summary>
  1154. /// <param name="dto"></param>
  1155. /// <returns></returns>
  1156. [HttpPost]
  1157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1158. public async Task<IActionResult> PostPayRequest_Center(PostPayRequestByDateRangeDto dto)
  1159. {
  1160. tree_Fin_DailyFeePaymentResult dailyResult = PayRequest_DailyByDateRange(dto.beginDt, dto.endDt);
  1161. return Ok(JsonView(true, "获取成功", new { daily = dailyResult }));
  1162. return Ok(JsonView(false, "获取失败"));
  1163. }
  1164. /// <summary>
  1165. /// 付款申请
  1166. /// 查询 根据日期范围
  1167. /// </summary>
  1168. /// <param name="dto"></param>
  1169. /// <returns></returns>
  1170. private tree_Fin_DailyFeePaymentResult PayRequest_DailyByDateRange(string beginDt, string endDt)
  1171. {
  1172. #region sql条件处理
  1173. string sqlWhere = string.Format(@" And dfp.CreateTime between '{0} 00:00:00' And '{1} 23:59:59' ", beginDt, endDt);
  1174. string sql_1 = string.Format(@"Select * From (
  1175. Select row_number() over (order by dfp.Id Desc) as RowNumber,
  1176. dfp.Id,dfp.CompanyId,c.CompanyName,dfp.Instructions,dfp.SumPrice,
  1177. dfp.CreateUserId,u.CnName CreateUser,dfp.CreateTime,dfp.FAudit,dfp.MAudit,
  1178. dfp.PriceTypeId,dfp.TransferTypeId
  1179. From Fin_DailyFeePayment dfp
  1180. Inner Join Sys_Company c On dfp.CompanyId = c.Id
  1181. Left Join Sys_Users u On dfp.CreateUserId = u.Id
  1182. Where dfp.IsDel=0 {0} And dfp.FAudit = 1 And dfp.MAudit = 1
  1183. ) temp ", sqlWhere);
  1184. #endregion
  1185. List<tree_Fin_DailyFeePaymentPageListView> DailyFeePaymentData = _sqlSugar.SqlQueryable<tree_Fin_DailyFeePaymentPageListView>(sql_1).ToList();
  1186. Dictionary<int, string> dic_setData = new Dictionary<int, string>();
  1187. foreach (var item in DailyFeePaymentData)
  1188. {
  1189. if (dic_setData.ContainsKey(item.PriceTypeId))
  1190. {
  1191. item.priceTypeStr = dic_setData[item.PriceTypeId];
  1192. }
  1193. else
  1194. {
  1195. Sys_SetData sd_priceType = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceTypeId).First();
  1196. if (sd_priceType != null)
  1197. {
  1198. item.priceTypeStr = sd_priceType.Name;
  1199. dic_setData.Add(item.PriceTypeId, sd_priceType.Name);
  1200. }
  1201. }
  1202. if (dic_setData.ContainsKey(item.transferTypeId))
  1203. {
  1204. item.transferTypeIdStr = dic_setData[item.transferTypeId];
  1205. Sys_SetData sd_transfer = _daiRep.Query<Sys_SetData>(s => s.Id == item.transferTypeId).First();
  1206. if (sd_transfer != null)
  1207. {
  1208. item.transferParentId = sd_transfer.STid;
  1209. item.transferParentIdStr = sd_transfer.STid == 62 ? "公转" : sd_transfer.STid == 63 ? "私转" : "";
  1210. }
  1211. }
  1212. else
  1213. {
  1214. Sys_SetData sd_transfer = _daiRep.Query<Sys_SetData>(s => s.Id == item.transferTypeId).First();
  1215. if (sd_transfer != null)
  1216. {
  1217. item.transferTypeIdStr = sd_transfer.Name;
  1218. item.transferParentId = sd_transfer.STid;
  1219. item.transferParentIdStr = sd_transfer.STid == 62 ? "公转" : sd_transfer.STid == 63 ? "私转" : "";
  1220. dic_setData.Add(item.transferTypeId, sd_transfer.Name);
  1221. }
  1222. }
  1223. string feeContentSql = string.Format(@"Select * From Fin_DailyFeePaymentContent
  1224. Where IsDel=0 And DFPId = {0} ", item.Id);
  1225. item.childList = _sqlSugar.SqlQueryable<Fin_DailyFeePaymentContentInfolView>(feeContentSql).ToList();
  1226. }
  1227. decimal total_gz = DailyFeePaymentData.Where(s => s.transferParentId == 62).Sum(d => d.SumPrice ?? 0M);
  1228. decimal total_sz = DailyFeePaymentData.Where(s => s.transferParentId == 63).Sum(d => d.SumPrice ?? 0M);
  1229. var result = new tree_Fin_DailyFeePaymentResult() { gz = total_gz, sz = total_sz, dataList = DailyFeePaymentData };
  1230. return result;
  1231. }
  1232. #endregion
  1233. }
  1234. }