FinancialController.cs 51 KB

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