FinancialController.cs 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  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> ExcelSyntheticalReceivable(PostSyntheticalReceivableByDateRangeDto dto)
  1005. //{
  1006. //}
  1007. /// <summary>
  1008. /// 应收报表
  1009. /// 查询 根据日期范围
  1010. /// </summary>
  1011. /// <param name="dto"></param>
  1012. /// <returns></returns>
  1013. [HttpPost]
  1014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1015. public async Task<IActionResult> PostSyntheticalReceivableByDateRange(PostSyntheticalReceivableByDateRangeDto dto)
  1016. {
  1017. string sqlWhere = " Where di.IsDel=0 ";
  1018. #region 验证
  1019. if (string.IsNullOrEmpty(dto.beginDt) && string.IsNullOrEmpty(dto.endDt))
  1020. {
  1021. return Ok(JsonView(false, "日期参数至少填写一个!"));
  1022. }
  1023. if (!string.IsNullOrEmpty(dto.beginDt))
  1024. {
  1025. if (Regex.Match(dto.beginDt, @"^\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}' ", dto.beginDt);
  1032. }
  1033. }
  1034. if (!string.IsNullOrEmpty(dto.endDt))
  1035. {
  1036. if (Regex.Match(dto.endDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
  1037. {
  1038. return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
  1039. }
  1040. else
  1041. {
  1042. sqlWhere += string.Format(@" And di.VisitDate <= '{0}' ", dto.endDt);
  1043. }
  1044. }
  1045. #endregion
  1046. 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);
  1047. List<PostSyntheticalReceivableByDateRangeView> list_rst = _sqlSugar.SqlQueryable<PostSyntheticalReceivableByDateRangeView>(sql).ToList();
  1048. decimal sumAll_fr = 0M;
  1049. decimal sumAll_pr = 0M;
  1050. decimal sumAll_balance = 0M;
  1051. if (list_rst.Count > 0)
  1052. {
  1053. int rowNumber = 1;
  1054. foreach (var item_rst in list_rst)
  1055. {
  1056. item_rst.No = rowNumber;
  1057. rowNumber++;
  1058. int diId = item_rst.diid;
  1059. decimal sum_fr = 0M;
  1060. decimal sum_pr = 0M;
  1061. string str_client = string.Empty;
  1062. decimal sum_other = 0M;
  1063. decimal balance = 0M;
  1064. string str_schedule = string.Empty;
  1065. //1.
  1066. string sql_fr = string.Format(@" Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0} ", diId);
  1067. List<Fin_ForeignReceivables> list_fr = _sqlSugar.SqlQueryable<Fin_ForeignReceivables>(sql_fr).ToList();
  1068. sum_fr = list_fr.Sum(s => s.ItemSumPrice);
  1069. //2.
  1070. string sql_pr = string.Format(@" Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0} ", diId);
  1071. List<Fin_ProceedsReceived> list_pr = _sqlSugar.SqlQueryable<Fin_ProceedsReceived>(sql_pr).ToList();
  1072. foreach (var item_pr in list_pr)
  1073. {
  1074. sum_pr += item_pr.Price;
  1075. str_client += string.Format(@"{0};", item_pr.Client);
  1076. str_schedule += string.Format(@"{0};", item_pr.Remark);
  1077. }
  1078. if (str_schedule.Length > 0)
  1079. {
  1080. str_schedule = str_schedule.TrimEnd(';');
  1081. }
  1082. if (str_client.Length > 0)
  1083. {
  1084. str_client = str_client.TrimEnd(';');
  1085. }
  1086. //3.
  1087. string sql_other = string.Format(@" Select * From Fin_OtherPrice where diid = {0} and isdel = 0 and RefundType = 1 and PayType=1 ", diId);
  1088. List<Fin_OtherPrice> list_other = _sqlSugar.SqlQueryable<Fin_OtherPrice>(sql_other).ToList();
  1089. sum_other = list_other.Sum(s => s.Price);
  1090. item_rst.frPrice = sum_fr.ToString("#0.00");
  1091. item_rst.prPrice = (sum_pr - sum_other).ToString("#0.00");
  1092. item_rst.balPrice = (sum_fr - (sum_pr - sum_other)).ToString("#0.00");
  1093. item_rst.clientUnit = str_client;
  1094. item_rst.schedule = str_schedule;
  1095. sumAll_fr += sum_fr;
  1096. sumAll_pr += (sum_pr - sum_other);
  1097. sumAll_balance += (sum_fr - (sum_pr - sum_other));
  1098. }
  1099. PostSyntheticalReceivableByDateRangeResultView result = new PostSyntheticalReceivableByDateRangeResultView();
  1100. result.total_fr = sumAll_fr.ToString("#0.00");
  1101. result.total_pr = sumAll_pr.ToString("#0.00");
  1102. result.total_balance = sumAll_balance.ToString("#0.00");
  1103. result.dataList = new List<PostSyntheticalReceivableByDateRangeView>(list_rst);
  1104. if (dto.requestType == 1)
  1105. {
  1106. return Ok(JsonView(true, "请求成功", result, list_rst.Count));
  1107. }
  1108. else {
  1109. //----------------------------
  1110. List<Excel_SyntheticalReceivableByDateRange> list_Ex = new List<Excel_SyntheticalReceivableByDateRange>();
  1111. WorkbookDesigner designer = new WorkbookDesigner();
  1112. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/应收款项模板 - 副本.xls");
  1113. int excNo = 1;
  1114. foreach (var item in list_rst)
  1115. {
  1116. Excel_SyntheticalReceivableByDateRange exc = new Excel_SyntheticalReceivableByDateRange();
  1117. exc.No = excNo.ToString();
  1118. excNo++;
  1119. exc.TeamName = item.teamName;
  1120. exc.ClientUnit = item.clientUnit;
  1121. exc.VisitDate = item.visitDate;
  1122. exc.Accounts = item.frPrice;
  1123. exc.Received = item.prPrice;
  1124. exc.Balance = item.balPrice;
  1125. exc.Collection = item.schedule;
  1126. DateTime time = Convert.ToDateTime(item.visitDate);
  1127. TimeSpan ts = DateTime.Now - time;
  1128. float SY = float.Parse(item.balPrice);
  1129. if (ts.Days >= 365 && SY > 0)
  1130. {
  1131. exc.Sign = "需收款";
  1132. }
  1133. else
  1134. {
  1135. exc.Sign = "";
  1136. }
  1137. list_Ex.Add(exc);
  1138. }
  1139. var dt = CommonFun.GetDataTableFromIList(list_Ex);
  1140. dt.TableName = "Excel_SyntheticalReceivableByDateRange";
  1141. if (dt != null)
  1142. {
  1143. designer.SetDataSource("SumPrice", "应收合计:" + result.total_fr + "RMB 已收合计:" + result.total_pr + "RMB 余款合计:" + result.total_balance + "RMB");
  1144. //数据源
  1145. designer.SetDataSource(dt);
  1146. //根据数据源处理生成报表内容
  1147. designer.Process();
  1148. string fileName = ("Receivable/应收款项(" + dto.beginDt + "~" + dto.endDt + ").xlsx");
  1149. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1150. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1151. return Ok(JsonView(true, "成功", new { url = rst }));
  1152. }
  1153. }
  1154. }
  1155. return Ok(JsonView(true, "获取成功", "", list_rst.Count));
  1156. }
  1157. #endregion
  1158. }
  1159. }