FinancialController.cs 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747
  1. using Aspose.Cells;
  2. using Microsoft.AspNetCore.Http;
  3. using Microsoft.AspNetCore.Mvc;
  4. using OASystem.API.OAMethodLib;
  5. using OASystem.API.OAMethodLib.File;
  6. using OASystem.Domain;
  7. using OASystem.Domain.Dtos.Financial;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Financial;
  10. using OASystem.Domain.Entities.Groups;
  11. using OASystem.Domain.ViewModels.Financial;
  12. using OASystem.Domain.ViewModels.Groups;
  13. using OASystem.Domain.ViewModels.SmallFun;
  14. using OASystem.Infrastructure.Repositories.Financial;
  15. using OASystem.Infrastructure.Repositories.Groups;
  16. using SqlSugar;
  17. using StackExchange.Redis;
  18. using System.Data;
  19. using System.Runtime.Intrinsics.Arm;
  20. namespace OASystem.API.Controllers
  21. {
  22. /// <summary>
  23. /// 财务模块
  24. /// </summary>
  25. [Route("api/[controller]/[action]")]
  26. [ApiController]
  27. public class FinancialController : ControllerBase
  28. {
  29. private readonly IMapper _mapper;
  30. private readonly IConfiguration _config;
  31. private readonly SqlSugarClient _sqlSugar;
  32. private readonly SetDataTypeRepository _setDataTypeRep;
  33. private readonly DailyFeePaymentRepository _daiRep; //日付申请仓库
  34. private readonly TeamRateRepository _teamRateRep; //团组汇率仓库
  35. private readonly ForeignReceivablesRepository _ForForeignReceivablesRep; //对外收款账单仓库
  36. private readonly ProceedsReceivedRepository _proceedsReceivedRep; //已收款项仓库
  37. private readonly PaymentRefundAndOtherMoneyRepository _paymentRefundAndOtherMoneyRep; //收款退还与其他款项 仓库
  38. /// <summary>
  39. /// 初始化
  40. /// </summary>
  41. public FinancialController(IMapper mapper, IConfiguration configuration, DailyFeePaymentRepository daiRep, SqlSugarClient sqlSugar, SetDataTypeRepository setDataTypeRep,
  42. TeamRateRepository teamRateRep, ForeignReceivablesRepository ForForeignReceivablesRep, ProceedsReceivedRepository proceedsReceivedRep,
  43. PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep)
  44. {
  45. _mapper = mapper;
  46. _config = configuration;
  47. _daiRep = daiRep;
  48. _sqlSugar = sqlSugar;
  49. _setDataTypeRep = setDataTypeRep;
  50. _teamRateRep = teamRateRep;
  51. _ForForeignReceivablesRep = ForForeignReceivablesRep;
  52. _proceedsReceivedRep = proceedsReceivedRep;
  53. _paymentRefundAndOtherMoneyRep = paymentRefundAndOtherMoneyRep;
  54. }
  55. #region 日付申请
  56. /// <summary>
  57. /// 获取日付申请 基础数据源
  58. /// </summary>
  59. /// <param name="dto"> 日付申请 分页 dto</param>
  60. /// <returns></returns>
  61. [HttpPost]
  62. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  63. public async Task<IActionResult> PostPageSearchDailyPaymentPriceTypeData(PortDtoBase dto)
  64. {
  65. var result = await _daiRep.GetPagePriceTypeData(dto);
  66. if (result == null || result.Code != 0)
  67. {
  68. return Ok(JsonView(false, result.Msg));
  69. }
  70. var data = result.Data;
  71. return Ok(JsonView(data));
  72. }
  73. /// <summary>
  74. /// 获取日付申请 基础数据源 - 转账表识
  75. /// </summary>
  76. /// <param name="dto"> 日付申请 分页 dto</param>
  77. /// <returns></returns>
  78. [HttpPost]
  79. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  80. public async Task<IActionResult> GetSearchDailyPaymentPriceTypeAddData(PortDtoBase dto)
  81. {
  82. var result = await _daiRep.GetPriceTypeAddData(dto);
  83. if (result == null || result.Code != 0)
  84. {
  85. return Ok(JsonView(false, result.Msg));
  86. }
  87. var data = result.Data;
  88. return Ok(JsonView(data));
  89. }
  90. /// <summary>
  91. /// 日付申请 Page Search
  92. /// </summary>
  93. /// <param name="dto"> 日付申请 分页 dto</param>
  94. /// <returns></returns>
  95. [HttpPost]
  96. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  97. public async Task<IActionResult> PostPageSearchDailyPaymentList(PageDailyFeePaymentDto dto)
  98. {
  99. var result = await _daiRep.GetPageSearchAll(dto);
  100. if (result == null || result.Code != 0)
  101. {
  102. return Ok(JsonView(false, result.Msg));
  103. }
  104. var data = result.Data;
  105. if (data == null)
  106. {
  107. return Ok(JsonView(false, result.Msg));
  108. }
  109. return Ok(JsonView(data));
  110. }
  111. /// <summary>
  112. /// 日付申请 Single Search By Id
  113. /// </summary>
  114. /// <param name="dto"></param>
  115. /// <returns></returns>
  116. [HttpPost]
  117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  118. public async Task<IActionResult> PostSearchDailyPaymentInfo(SearchDailyFeePaymentDto dto)
  119. {
  120. var result = await _daiRep.GetSearchById(dto);
  121. if (result == null || result.Code != 0)
  122. {
  123. return Ok(JsonView(false, result.Msg));
  124. }
  125. return Ok(JsonView(result.Data));
  126. }
  127. /// <summary>
  128. /// 日付申请 添加
  129. /// </summary>
  130. /// <param name="dto"> 日付申请 添加 dto</param>
  131. /// <returns></returns>
  132. [HttpPost]
  133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  134. public async Task<IActionResult> PostAddDailyPayment(AddDailyFeePaymentDto dto)
  135. {
  136. var result = await _daiRep.Add(dto);
  137. if (result == null || result.Code != 0)
  138. {
  139. return Ok(JsonView(false, result.Msg));
  140. }
  141. return Ok(JsonView(true));
  142. }
  143. /// <summary>
  144. /// 日付申请 Update
  145. /// </summary>
  146. /// <param name="dto"> 日付申请 修改 dto</param>
  147. /// <returns></returns>
  148. [HttpPost]
  149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  150. public async Task<IActionResult> PostEditDailyPayment(EditDailyFeePaymentDto dto)
  151. {
  152. var result = await _daiRep.Edit(dto);
  153. if (result == null || result.Code != 0)
  154. {
  155. return Ok(JsonView(false, result.Msg));
  156. }
  157. return Ok(JsonView(true));
  158. }
  159. /// <summary>
  160. /// 日付申请 Del
  161. /// </summary>
  162. /// <param name="dto"> 日付申请 删除 dto</param>
  163. /// <returns></returns>
  164. [HttpPost]
  165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  166. public async Task<IActionResult> PostDelDailyPayment(DelDailyFeePaymentDto dto)
  167. {
  168. var result = await _daiRep.Del(dto);
  169. if (result == null || result.Code != 0)
  170. {
  171. return Ok(JsonView(false, result.Msg));
  172. }
  173. return Ok(JsonView(true));
  174. }
  175. /// <summary>
  176. /// 日付申请 财务审核
  177. /// </summary>
  178. /// <param name="dto"> dto </param>
  179. /// <returns></returns>
  180. [HttpPost]
  181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  182. public async Task<IActionResult> PostDelDailyPaymentAudit(DP_AuditStatusDto dto)
  183. {
  184. var result = await _daiRep.DelDailyPaymentAudit(dto);
  185. if (result == null || result.Code != 0)
  186. {
  187. return Ok(JsonView(false, result.Msg));
  188. }
  189. return Ok(JsonView(true));
  190. }
  191. /// <summary>
  192. /// 日付申请 Single Excel Download
  193. /// </summary>
  194. /// <param name="dto"> dto </param>
  195. /// <returns></returns>
  196. [HttpPost]
  197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  198. public async Task<IActionResult> PostExcelDailyPaymentDownload(SearchDailyFeePaymentDto dto)
  199. {
  200. if (dto.PortType == 1 || dto.PortType == 2)
  201. {
  202. Fin_DailyFeePaymentInfolView feeData = new Fin_DailyFeePaymentInfolView();
  203. string feeSql = string.Format(@"Select * From Fin_DailyFeePayment
  204. Where IsDel=0 And Id = {0} ", dto.Id);
  205. feeData = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentInfolView>(feeSql).FirstAsync();
  206. if (feeData == null)
  207. {
  208. return Ok(JsonView(false, "暂无数据!"));
  209. }
  210. string feeContentSql = string.Format(@"Select * From Fin_DailyFeePaymentContent
  211. Where IsDel=0 And DFPId = {0} ", dto.Id);
  212. feeData.FeeContents = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentContentInfolView>(feeContentSql).ToListAsync();
  213. if (feeData != null)
  214. {
  215. string userName = string.Empty;
  216. string userSql = string.Format("Select * From Sys_Users Where Id={0} And Isdel = {1}", feeData.CreateUserId, 0);
  217. Sys_Users user = await _sqlSugar.SqlQueryable<Sys_Users>(userSql).FirstAsync();
  218. if (user != null) { userName = user.CnName; }
  219. var setData = _setDataTypeRep.QueryDto<Sys_SetData, Fin_DailyFeePaymentPagePriceSubTypeView>().ToList();
  220. //48人员费用 49办公费用 50 销售费用 51 其他费用 55 大运会
  221. var priceSubTypeData = setData.Where(s => s.STid == 55).ToList();
  222. Dictionary<string, object> pairs = new Dictionary<string, object>();
  223. List<DataTable> datas = new List<DataTable>();
  224. //if (priceSubTypeData.Where(s => s.Id == feeData.PriceTypeId).ToList().Count() > 0)//大运会专属模板
  225. //{
  226. // //AsposeHelper.ExpertExcelToModel("日常费用付款申请模板-大运会数据.xls", "DailyPayment", "大运会所有日常费用付款申请.xls",
  227. // // pairs, datas);
  228. //}
  229. //else //日付常规模板
  230. //{
  231. pairs.Clear();
  232. pairs.Add("Opertor", userName);
  233. pairs.Add("DateTime", feeData.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  234. pairs.Add("FAuditStatus", feeData.FAuditDesc);
  235. pairs.Add("MAuditStatus", feeData.MAuditDesc);
  236. pairs.Add("SumPrice", feeData.SumPrice);
  237. DataTable data = AsposeHelper.ListToDataTable("DailyFeePayment", feeData.FeeContents);
  238. datas.Clear();
  239. datas.Add(data);
  240. string fileName = string.Format("{0}-日常费用付款申请.xlsx", feeData.Instructions);
  241. string msg = AsposeHelper.ExpertExcelToModel("日常费用付款申请模板.xlsx", "DailyPayment", fileName, pairs, datas);
  242. return Ok(JsonView(true, msg));
  243. //}
  244. }
  245. else
  246. {
  247. return Ok(JsonView(false, "暂无数据!"));
  248. }
  249. }
  250. return Ok(JsonView(true));
  251. }
  252. #endregion
  253. #region 团组提成
  254. /// <summary>
  255. /// 提成 Page Search
  256. /// </summary>
  257. /// <param name="dto"> 提成 分页 dto</param>
  258. /// <returns></returns>
  259. [HttpPost]
  260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  261. public async Task<IActionResult> PostPageSearchCommissionList(GroupCommissionDto dto)
  262. {
  263. var data = await GroupCommission.GetCommissionPageList(dto);
  264. return Ok(JsonView(data.Data));
  265. }
  266. #endregion
  267. #region 团组汇率
  268. /// <summary>
  269. /// 团组汇率 Select数据源(团组列,汇率列)
  270. /// </summary>
  271. /// <param name="dto"></param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  275. public async Task<IActionResult> GetGroupRateDataSources(TeamRateDto dto)
  276. {
  277. try
  278. {
  279. Result teamRateData = await _teamRateRep.GetGroupRateDataSource(dto);
  280. if (teamRateData.Code != 0)
  281. {
  282. return Ok(JsonView(false, teamRateData.Msg));
  283. }
  284. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  285. }
  286. catch (Exception ex)
  287. {
  288. return Ok(JsonView(false, ex.Message));
  289. throw;
  290. }
  291. }
  292. ///// <summary>
  293. ///// 团组汇率 changge
  294. ///// </summary>
  295. ///// <returns></returns>
  296. //[HttpPost]
  297. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  298. //public async Task<IActionResult> ChangeGroupRateInfo()
  299. //{
  300. // try
  301. // {
  302. // Result teamRateData = await _teamRateRep.GetGroupRateChangeData();
  303. // if (teamRateData.Code != 0)
  304. // {
  305. // return Ok(JsonView(false, teamRateData.Msg));
  306. // }
  307. // return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  308. // }
  309. // catch (Exception ex)
  310. // {
  311. // return Ok(JsonView(false, ex.Message));
  312. // throw;
  313. // }
  314. //}
  315. /// <summary>
  316. /// 团组汇率 Select汇率详情
  317. /// </summary>
  318. /// <param name="dto"></param>
  319. /// <returns></returns>
  320. [HttpPost]
  321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  322. public async Task<IActionResult> GetGroupRateInfo(TeamRateInfoDto dto)
  323. {
  324. try
  325. {
  326. Result teamRateData = await _teamRateRep.GetGroupRateInfoByDiid(dto);
  327. if (teamRateData.Code != 0)
  328. {
  329. return Ok(JsonView(false, teamRateData.Msg));
  330. }
  331. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  332. }
  333. catch (Exception ex)
  334. {
  335. return Ok(JsonView(false, ex.Message));
  336. throw;
  337. }
  338. }
  339. /// <summary>
  340. /// 团组汇率 添加 or 更新
  341. /// </summary>
  342. /// <param name="dto"></param>
  343. /// <returns></returns>
  344. [HttpPost]
  345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  346. public async Task<IActionResult> PostGroupRateUpdate(TeamRateUpdateDto dto)
  347. {
  348. try
  349. {
  350. Result teamRateData = await _teamRateRep.PostGroupRateUpdate(dto);
  351. if (teamRateData.Code != 0)
  352. {
  353. return Ok(JsonView(false, teamRateData.Msg));
  354. }
  355. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  356. }
  357. catch (Exception ex)
  358. {
  359. return Ok(JsonView(false, ex.Message));
  360. throw;
  361. }
  362. }
  363. #endregion
  364. #region 对外收款账单 关联已收款项
  365. /// <summary>
  366. /// 对外收款账单 Select数据源(团组名,币种,汇款方式)
  367. /// 关联已收款项
  368. /// </summary>
  369. /// <param name="dto"></param>
  370. /// <returns></returns>
  371. [HttpPost]
  372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  373. public async Task<IActionResult> GetForeignReceivablesDataSources()
  374. {
  375. try
  376. {
  377. Result ffrData = await _ForForeignReceivablesRep.GetDataSource();
  378. if (ffrData.Code != 0)
  379. {
  380. return Ok(JsonView(false, ffrData.Msg));
  381. }
  382. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  383. }
  384. catch (Exception ex)
  385. {
  386. return Ok(JsonView(false, ex.Message));
  387. throw;
  388. }
  389. }
  390. /// <summary>
  391. /// 对外收款账单
  392. /// 账单详情
  393. /// 关联已收款项
  394. /// </summary>
  395. /// <param name="dto"></param>
  396. /// <returns></returns>
  397. [HttpPost]
  398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  399. public async Task<IActionResult> GetGroupReceivablesInfoByDiId(ForForeignReceivablesInfoDto dto)
  400. {
  401. try
  402. {
  403. Result ffrData = await _ForForeignReceivablesRep.GetGroupReceivablesInfoByDiId(dto);
  404. if (ffrData.Code != 0)
  405. {
  406. return Ok(JsonView(false, ffrData.Msg));
  407. }
  408. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  409. }
  410. catch (Exception ex)
  411. {
  412. return Ok(JsonView(false, ex.Message));
  413. throw;
  414. }
  415. }
  416. /// <summary>
  417. /// 对外收款账单
  418. /// 账单 删除
  419. /// 关联已收款项
  420. /// </summary>
  421. /// <param name="dto"></param>
  422. /// <returns></returns>
  423. [HttpPost]
  424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  425. public async Task<IActionResult> PostGroupReceivablesDel(DelForForeignReceivablesInfoDto dto)
  426. {
  427. try
  428. {
  429. Result ffrData = await _ForForeignReceivablesRep._Del(dto);
  430. if (ffrData.Code != 0)
  431. {
  432. return Ok(JsonView(false, ffrData.Msg));
  433. }
  434. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  435. }
  436. catch (Exception ex)
  437. {
  438. return Ok(JsonView(false, ex.Message));
  439. throw;
  440. }
  441. }
  442. /// <summary>
  443. /// 对外收款账单
  444. /// 添加 And 更新
  445. /// 关联已收款项
  446. /// </summary>
  447. /// <param name="dto"></param>
  448. /// <returns></returns>
  449. [HttpPost]
  450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  451. public async Task<IActionResult> PostReceivablesOperate(ForeignReceivablesAddAndUpdateDto dto)
  452. {
  453. try
  454. {
  455. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesOperate(dto);
  456. if (ffrData.Code != 0)
  457. {
  458. return Ok(JsonView(false, ffrData.Msg));
  459. }
  460. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  461. }
  462. catch (Exception ex)
  463. {
  464. return Ok(JsonView(false, ex.Message));
  465. throw;
  466. }
  467. }
  468. /// <summary>
  469. /// 已收款项
  470. /// 账单 删除
  471. /// 关联已收款项
  472. /// </summary>
  473. /// <param name="dto"></param>
  474. /// <returns></returns>
  475. [HttpPost]
  476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  477. public async Task<IActionResult> PostAmountReceivedDel(ProceedsReceivedDelDto dto)
  478. {
  479. try
  480. {
  481. Result ffrData = await _proceedsReceivedRep._Del(dto);
  482. if (ffrData.Code != 0)
  483. {
  484. return Ok(JsonView(false, ffrData.Msg));
  485. }
  486. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  487. }
  488. catch (Exception ex)
  489. {
  490. return Ok(JsonView(false, ex.Message));
  491. throw;
  492. }
  493. }
  494. /// <summary>
  495. /// 已收款项
  496. /// 添加 And 更新
  497. /// 关联已收款项
  498. /// </summary>
  499. /// <param name="dto"></param>
  500. /// <returns></returns>
  501. [HttpPost]
  502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  503. public async Task<IActionResult> PostAmountReceivedOperate(ProceedsReceivedDto dto)
  504. {
  505. try
  506. {
  507. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedOperate(dto);
  508. if (ffrData.Code != 0)
  509. {
  510. return Ok(JsonView(false, ffrData.Msg));
  511. }
  512. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  513. }
  514. catch (Exception ex)
  515. {
  516. return Ok(JsonView(false, ex.Message));
  517. throw;
  518. }
  519. }
  520. /// <summary>
  521. /// 财务 已收款项
  522. /// 分配已收款项至 应收项下
  523. /// 关联已收款项
  524. /// </summary>
  525. /// <param name="dto"></param>
  526. /// <returns></returns>
  527. [HttpPost]
  528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  529. public async Task<IActionResult> PostAllocateAmountReceived(AllocateAmountReceivedDto dto)
  530. {
  531. try
  532. {
  533. Result ffrData = await _proceedsReceivedRep.PostAllocateAmountReceived(dto);
  534. if (ffrData.Code != 0)
  535. {
  536. return Ok(JsonView(false, ffrData.Msg));
  537. }
  538. return Ok(JsonView(true));
  539. }
  540. catch (Exception ex)
  541. {
  542. return Ok(JsonView(false, ex.Message));
  543. throw;
  544. }
  545. }
  546. ///// <summary>
  547. ///// 财务 收款账单
  548. ///// 导出Word(北京,四川)
  549. ///// </summary>
  550. ///// <param name="dto"></param>
  551. ///// <returns></returns>
  552. //[HttpPost]
  553. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  554. //public async Task<IActionResult> PostAccountReceivableWordExport(AccountReceivableWordExportDto dto)
  555. //{
  556. // try
  557. // {
  558. // //模板处理
  559. // string typeName = string.Empty;
  560. // if (dto.TemplateType == 1) //四川
  561. // {
  562. // typeName = "四川";
  563. // }
  564. // else if (dto.TemplateType == 2) //北京
  565. // {
  566. // typeName = "北京";
  567. // }
  568. // else return Ok(JsonView(false,"请选择正确的模板类型!"));
  569. // string wordTempName = string.Format("收款账单({0})模板.doc", typeName);
  570. // }
  571. // catch (Exception ex)
  572. // {
  573. // return Ok(JsonView(false, ex.Message));
  574. // }
  575. //}
  576. #endregion
  577. #region 对外收款账单
  578. /// <summary>
  579. /// 对外收款账单
  580. /// 数据源
  581. /// </summary>
  582. /// <param name="dto"></param>
  583. /// <returns></returns>
  584. [HttpPost]
  585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  586. public async Task<IActionResult> PostGroupReceivablesDataSource()
  587. {
  588. try
  589. {
  590. Result ffrData = await _ForForeignReceivablesRep.PostDataSource();
  591. if (ffrData.Code != 0)
  592. {
  593. return Ok(JsonView(false, ffrData.Msg));
  594. }
  595. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  596. }
  597. catch (Exception ex)
  598. {
  599. return Ok(JsonView(false, ex.Message));
  600. throw;
  601. }
  602. }
  603. /// <summary>
  604. /// 对外收款账单
  605. /// 账单详情
  606. /// </summary>
  607. /// <param name="dto"></param>
  608. /// <returns></returns>
  609. [HttpPost]
  610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  611. public async Task<IActionResult> PostGroupReceivablesInfoByDiId(ForForeignReceivablesNewDto dto)
  612. {
  613. try
  614. {
  615. Result ffrData = await _ForForeignReceivablesRep.PostGroupReceivablesInfoByDiId(dto);
  616. if (ffrData.Code != 0)
  617. {
  618. return Ok(JsonView(false, ffrData.Msg));
  619. }
  620. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  621. }
  622. catch (Exception ex)
  623. {
  624. return Ok(JsonView(false, ex.Message));
  625. throw;
  626. }
  627. }
  628. /// <summary>
  629. /// 对外收款账单
  630. /// 添加 And 更新
  631. /// </summary>
  632. /// <param name="dto"></param>
  633. /// <returns></returns>
  634. [HttpPost]
  635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  636. public async Task<IActionResult> PostReceivablesSave(ForeignReceivablesSaveDto dto)
  637. {
  638. try
  639. {
  640. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesSave(dto);
  641. if (ffrData.Code != 0)
  642. {
  643. return Ok(JsonView(false, ffrData.Msg));
  644. }
  645. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  646. }
  647. catch (Exception ex)
  648. {
  649. return Ok(JsonView(false, ex.Message));
  650. throw;
  651. }
  652. }
  653. /// <summary>
  654. /// 已收账单
  655. /// 删除
  656. /// </summary>
  657. /// <param name="dto"></param>
  658. /// <returns></returns>
  659. [HttpPost]
  660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  661. public async Task<IActionResult> PostReceivablesDel(ForeignReceivablesDelDto dto)
  662. {
  663. try
  664. {
  665. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesDel(dto);
  666. if (ffrData.Code != 0)
  667. {
  668. return Ok(JsonView(false, ffrData.Msg));
  669. }
  670. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  671. }
  672. catch (Exception ex)
  673. {
  674. return Ok(JsonView(false, ex.Message));
  675. throw;
  676. }
  677. }
  678. #endregion
  679. #region 已收款项
  680. /// <summary>
  681. /// 已收款项
  682. /// 查询
  683. /// </summary>
  684. /// <param name="dto"></param>
  685. /// <returns></returns>
  686. [HttpPost]
  687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  688. public async Task<IActionResult> PostAmountReceived(AmountReceivedDto dto)
  689. {
  690. try
  691. {
  692. if (dto == null)
  693. {
  694. return Ok(JsonView(false, "参数不能为空!"));
  695. }
  696. Result ffrData = await _proceedsReceivedRep.PostAmountReceived(dto.DiId);
  697. dynamic data = null;
  698. if (dto.PortType == 1)
  699. {
  700. if (ffrData.Code != 0)
  701. {
  702. return Ok(JsonView(false, ffrData.Msg));
  703. }
  704. data = ffrData.Data;
  705. }
  706. else if (dto.PortType == 2)
  707. {
  708. if (ffrData.Code != 0)
  709. {
  710. return Ok(JsonView(false, ffrData.Msg));
  711. }
  712. data = ffrData.Data;
  713. }
  714. else if (dto.PortType == 2)
  715. {
  716. if (ffrData.Code != 0)
  717. {
  718. return Ok(JsonView(false, ffrData.Msg));
  719. }
  720. data = ffrData.Data;
  721. }
  722. else
  723. {
  724. return Ok(JsonView(false, "请选择正确的端口号!"));
  725. }
  726. return Ok(JsonView(true, "操作成功!", data));
  727. }
  728. catch (Exception ex)
  729. {
  730. return Ok(JsonView(false, ex.Message));
  731. }
  732. }
  733. /// <summary>
  734. /// 已收款项
  735. /// Add Or Edit
  736. /// </summary>
  737. /// <param name="dto"></param>
  738. /// <returns></returns>
  739. [HttpPost]
  740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  741. public async Task<IActionResult> PostAmountReceivedAddOrEdit(AmountReceivedAddOrEditDto dto)
  742. {
  743. try
  744. {
  745. if (dto == null)
  746. {
  747. return Ok(JsonView(false, "参数不能为空!"));
  748. }
  749. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedAddOrEditDto(dto);
  750. if (dto.PortType == 1)
  751. {
  752. if (ffrData.Code != 0)
  753. {
  754. return Ok(JsonView(false, ffrData.Msg));
  755. }
  756. }
  757. else if (dto.PortType == 2)
  758. {
  759. if (ffrData.Code != 0)
  760. {
  761. return Ok(JsonView(false, ffrData.Msg));
  762. }
  763. }
  764. else if (dto.PortType == 2)
  765. {
  766. if (ffrData.Code != 0)
  767. {
  768. return Ok(JsonView(false, ffrData.Msg));
  769. }
  770. }
  771. else
  772. {
  773. return Ok(JsonView(false, "请选择正确的端口号!"));
  774. }
  775. return Ok(JsonView(true, "操作成功!"));
  776. }
  777. catch (Exception ex)
  778. {
  779. return Ok(JsonView(false, ex.Message));
  780. }
  781. }
  782. /// <summary>
  783. /// 已收款项
  784. /// Del
  785. /// </summary>
  786. /// <param name="dto"></param>
  787. /// <returns></returns>
  788. [HttpPost]
  789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  790. public async Task<IActionResult> PostAmountReceived_Del(AmountReceivedDelDto dto)
  791. {
  792. try
  793. {
  794. if (dto == null)
  795. {
  796. return Ok(JsonView(false, "参数不能为空!"));
  797. }
  798. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedDel(dto);
  799. if (ffrData.Code != 0)
  800. {
  801. return Ok(JsonView(false, ffrData.Msg));
  802. }
  803. return Ok(JsonView(true, "操作成功!"));
  804. }
  805. catch (Exception ex)
  806. {
  807. return Ok(JsonView(false, ex.Message));
  808. }
  809. }
  810. #endregion
  811. #region 收款退还与其他款项
  812. /// <summary>
  813. /// 收款退还与其他款项
  814. /// 查询 根据团组Id
  815. /// </summary>
  816. /// <param name="dto"></param>
  817. /// <returns></returns>
  818. [HttpPost]
  819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  820. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyItemByDiId(PaymentRefundAndOtherMoneyItemByDiIdDto dto)
  821. {
  822. try
  823. {
  824. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  825. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  826. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  827. #region 页面功能权限处理
  828. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  829. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  830. if (pageFunAuth.CheckAuth == 0)
  831. {
  832. return Ok(JsonView(false, "您没有当前页面查询权限!"));
  833. }
  834. #endregion
  835. Result _result = await _paymentRefundAndOtherMoneyRep._ItemByDiId(dto.DiId);
  836. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //1 Web 2 Android 3 Ios
  837. {
  838. if (_result.Code != 0)
  839. {
  840. return Ok(JsonView(false, _result.Msg));
  841. }
  842. var data = new
  843. {
  844. PageFuncAuth = pageFunAuth,
  845. Data = _result.Data
  846. };
  847. return Ok(JsonView(true, "操作成功!", data));
  848. }
  849. else
  850. {
  851. return Ok(JsonView(false, "请输入正确的端口号! 1 Web 2 Android 3 Ios;"));
  852. }
  853. }
  854. catch (Exception ex)
  855. {
  856. return Ok(JsonView(false, ex.Message));
  857. }
  858. }
  859. /// <summary>
  860. /// 收款退还与其他款项
  861. /// 删除
  862. /// </summary>
  863. /// <param name="dto"></param>
  864. /// <returns></returns>
  865. [HttpPost]
  866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  867. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyDel(PaymentRefundAndOtherMoneyDelDto dto)
  868. {
  869. try
  870. {
  871. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  872. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  873. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  874. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  875. #region 页面功能权限处理
  876. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  877. #endregion
  878. if (pageFunAuth.DeleteAuth == 0)
  879. {
  880. return Ok(JsonView(false, "您没有当前页面删除权限!"));
  881. }
  882. Result _result = await _paymentRefundAndOtherMoneyRep._Del(dto);
  883. if (_result.Code != 0)
  884. {
  885. return Ok(JsonView(false, _result.Msg));
  886. }
  887. return Ok(JsonView(true, "操作成功!"));
  888. }
  889. catch (Exception ex)
  890. {
  891. return Ok(JsonView(false, ex.Message));
  892. }
  893. }
  894. /// <summary>
  895. /// 收款退还与其他款项
  896. /// Info Data Source
  897. /// </summary>
  898. /// <param name="dto"></param>
  899. /// <returns></returns>
  900. [HttpPost]
  901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  902. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyInfoDataSource(PortDtoBase dto)
  903. {
  904. try
  905. {
  906. Result _result = await _paymentRefundAndOtherMoneyRep._InfoDataSource(dto);
  907. if (_result.Code != 0)
  908. {
  909. return Ok(JsonView(false, _result.Msg));
  910. }
  911. return Ok(JsonView(true, "查询成功!", _result.Data));
  912. }
  913. catch (Exception ex)
  914. {
  915. return Ok(JsonView(false, ex.Message));
  916. }
  917. }
  918. /// <summary>
  919. /// 收款退还与其他款项
  920. /// Info
  921. /// </summary>
  922. /// <param name="dto"></param>
  923. /// <returns></returns>
  924. [HttpPost]
  925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  926. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyInfo(PaymentRefundAndOtherMoneyInfoDto dto)
  927. {
  928. try
  929. {
  930. if (dto == null)
  931. {
  932. return Ok(JsonView(false, "参数不能为空!"));
  933. }
  934. Result _result = await _paymentRefundAndOtherMoneyRep._Info(dto);
  935. if (_result.Code != 0)
  936. {
  937. return Ok(JsonView(false, _result.Msg));
  938. }
  939. return Ok(JsonView(true, "查询成功!", _result.Data));
  940. }
  941. catch (Exception ex)
  942. {
  943. return Ok(JsonView(false, ex.Message));
  944. }
  945. }
  946. /// <summary>
  947. /// 收款退还与其他款项
  948. /// 操作(Add Or Edit)
  949. /// </summary>
  950. /// <param name="dto"></param>
  951. /// <returns></returns>
  952. [HttpPost]
  953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  954. public async Task<IActionResult> PostPaymentRefundAndOtherMoneyAddOrEdit(PaymentRefundAndOtherMoneyAddOrEditDto dto)
  955. {
  956. try
  957. {
  958. if (dto == null) return Ok(JsonView(false, "参数不能为空!"));
  959. if (dto.PageId <= 0) return Ok(JsonView(false, "请传入正确的的页面Id!"));
  960. if (dto.UserId <= 0) return Ok(JsonView(false, "请传入正确的的员工Id!"));
  961. #region 页面功能权限处理
  962. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  963. pageFunAuth = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  964. #endregion
  965. if (dto.Status == 1) //add
  966. {
  967. if (pageFunAuth.AddAuth == 0)
  968. {
  969. return Ok(JsonView(false, "您没有当前页面添加权限!"));
  970. }
  971. }
  972. else if (dto.Status == 2) //edit
  973. {
  974. if (pageFunAuth.EditAuth == 0)
  975. {
  976. return Ok(JsonView(false, "您没有当前页面编辑权限!"));
  977. }
  978. }
  979. else
  980. {
  981. return Ok(JsonView(false, "请输入正确的操作状态! 1 添加 2 修改!"));
  982. }
  983. Result _result = await _paymentRefundAndOtherMoneyRep._AddOrEdit(dto);
  984. if (_result.Code != 0)
  985. {
  986. return Ok(JsonView(false, _result.Msg));
  987. }
  988. return Ok(JsonView(true, "操作成功!"));
  989. }
  990. catch (Exception ex)
  991. {
  992. return Ok(JsonView(false, ex.Message));
  993. }
  994. }
  995. #endregion
  996. #region 应收报表
  997. /// <summary>
  998. /// 应收报表
  999. /// 查询 根据日期范围
  1000. /// </summary>
  1001. /// <param name="dto"></param>
  1002. /// <returns></returns>
  1003. [HttpPost]
  1004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1005. public async Task<IActionResult> PostSyntheticalReceivableByDateRange(PostSyntheticalReceivableByDateRangeDto dto)
  1006. {
  1007. string sqlWhere = " Where di.IsDel=0 ";
  1008. #region 验证
  1009. if (string.IsNullOrEmpty(dto.beginDt) && string.IsNullOrEmpty(dto.endDt))
  1010. {
  1011. return Ok(JsonView(false, "日期参数至少填写一个!"));
  1012. }
  1013. if (!string.IsNullOrEmpty(dto.beginDt))
  1014. {
  1015. if (Regex.Match(dto.beginDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
  1016. {
  1017. return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
  1018. }
  1019. else
  1020. {
  1021. sqlWhere += string.Format(@" And di.VisitDate >= '{0} 00:00:00' ", dto.beginDt);
  1022. }
  1023. }
  1024. if (!string.IsNullOrEmpty(dto.endDt))
  1025. {
  1026. if (Regex.Match(dto.endDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
  1027. {
  1028. return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
  1029. }
  1030. else
  1031. {
  1032. sqlWhere += string.Format(@" And di.VisitDate <= '{0} 23:59:59' ", dto.endDt);
  1033. }
  1034. }
  1035. #endregion
  1036. 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);
  1037. List<PostSyntheticalReceivableByDateRangeView> list_rst = _sqlSugar.SqlQueryable<PostSyntheticalReceivableByDateRangeView>(sql).ToList();
  1038. decimal sumAll_fr = 0M;
  1039. decimal sumAll_pr = 0M;
  1040. decimal sumAll_balance = 0M;
  1041. if (list_rst.Count > 0)
  1042. {
  1043. int rowNumber = 1;
  1044. foreach (var item_rst in list_rst)
  1045. {
  1046. item_rst.No = rowNumber;
  1047. rowNumber++;
  1048. int diId = item_rst.diid;
  1049. decimal sum_fr = 0M;
  1050. decimal sum_pr = 0M;
  1051. string str_client = string.Empty;
  1052. decimal sum_other = 0M;
  1053. decimal balance = 0M;
  1054. string str_schedule = string.Empty;
  1055. //1. 缺超支费用!!!!!!!!!!!!!!!!!!!!
  1056. string sql_fr = string.Format(@" Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0} ", diId);
  1057. List<Fin_ForeignReceivables> list_fr = _sqlSugar.SqlQueryable<Fin_ForeignReceivables>(sql_fr).ToList();
  1058. sum_fr = list_fr.Sum(s => s.ItemSumPrice);
  1059. //2.
  1060. string sql_pr = string.Format(@" Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0} ", diId);
  1061. List<Fin_ProceedsReceived> list_pr = _sqlSugar.SqlQueryable<Fin_ProceedsReceived>(sql_pr).ToList();
  1062. foreach (var item_pr in list_pr)
  1063. {
  1064. sum_pr += item_pr.Price;
  1065. str_client += string.Format(@"{0};", item_pr.Client);
  1066. str_schedule += string.Format(@"{0};", item_pr.Remark);
  1067. }
  1068. if (str_schedule.Length > 0)
  1069. {
  1070. str_schedule = str_schedule.TrimEnd(';');
  1071. }
  1072. if (str_client.Length > 0)
  1073. {
  1074. str_client = str_client.TrimEnd(';');
  1075. }
  1076. //3.
  1077. string sql_other = string.Format(@" Select * From Fin_OtherPrice where diid = {0} and isdel = 0 and RefundType = 1 and PayType=1 ", diId);
  1078. List<Fin_OtherPrice> list_other = _sqlSugar.SqlQueryable<Fin_OtherPrice>(sql_other).ToList();
  1079. sum_other = list_other.Sum(s => s.Price);
  1080. item_rst.frPrice = sum_fr.ToString("#0.00");
  1081. item_rst.prPrice = (sum_pr - sum_other).ToString("#0.00");
  1082. item_rst.balPrice = (sum_fr - (sum_pr - sum_other)).ToString("#0.00");
  1083. item_rst.prClient = str_client;
  1084. item_rst.schedule = str_schedule;
  1085. string tempVisitDate = Convert.ToDateTime(item_rst.visitDate).ToString("yyyy-MM-dd");
  1086. sumAll_fr += sum_fr;
  1087. sumAll_pr += (sum_pr - sum_other);
  1088. sumAll_balance += (sum_fr - (sum_pr - sum_other));
  1089. }
  1090. PostSyntheticalReceivableByDateRangeResultView result = new PostSyntheticalReceivableByDateRangeResultView();
  1091. result.total_fr = sumAll_fr.ToString("#0.00");
  1092. result.total_pr = sumAll_pr.ToString("#0.00");
  1093. result.total_balance = sumAll_balance.ToString("#0.00");
  1094. result.dataList = new List<PostSyntheticalReceivableByDateRangeView>(list_rst);
  1095. if (dto.requestType == 1)
  1096. {
  1097. return Ok(JsonView(true, "请求成功", result, list_rst.Count));
  1098. }
  1099. else
  1100. {
  1101. //----------------------------
  1102. List<Excel_SyntheticalReceivableByDateRange> list_Ex = new List<Excel_SyntheticalReceivableByDateRange>();
  1103. WorkbookDesigner designer = new WorkbookDesigner();
  1104. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/应收款项模板 - 副本.xls");
  1105. int excNo = 1;
  1106. foreach (var item in list_rst)
  1107. {
  1108. Excel_SyntheticalReceivableByDateRange exc = new Excel_SyntheticalReceivableByDateRange();
  1109. exc.No = excNo.ToString();
  1110. excNo++;
  1111. exc.TeamName = item.teamName;
  1112. exc.ClientUnit = item.clientUnit;
  1113. exc.VisitDate = item.visitDate;
  1114. exc.Accounts = item.frPrice;
  1115. exc.Received = item.prPrice;
  1116. exc.Balance = item.balPrice;
  1117. exc.Collection = item.schedule;
  1118. DateTime time = Convert.ToDateTime(item.visitDate);
  1119. TimeSpan ts = DateTime.Now - time;
  1120. float SY = float.Parse(item.balPrice);
  1121. if (ts.Days >= 365 && SY > 0)
  1122. {
  1123. exc.Sign = "需收款";
  1124. }
  1125. else
  1126. {
  1127. exc.Sign = "";
  1128. }
  1129. list_Ex.Add(exc);
  1130. }
  1131. var dt = CommonFun.GetDataTableFromIList(list_Ex);
  1132. dt.TableName = "Excel_SyntheticalReceivableByDateRange";
  1133. if (dt != null)
  1134. {
  1135. designer.SetDataSource("SumPrice", "应收合计:" + result.total_fr + "RMB 已收合计:" + result.total_pr + "RMB 余款合计:" + result.total_balance + "RMB");
  1136. //数据源
  1137. designer.SetDataSource(dt);
  1138. //根据数据源处理生成报表内容
  1139. designer.Process();
  1140. string fileName = ("Receivable/应收款项(" + dto.beginDt + "~" + dto.endDt + ").xlsx");
  1141. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1142. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1143. return Ok(JsonView(true, "成功", new { url = rst }));
  1144. }
  1145. }
  1146. }
  1147. return Ok(JsonView(true, "获取成功", "", list_rst.Count));
  1148. }
  1149. #endregion
  1150. #region 付款申请
  1151. /// <summary>
  1152. /// 应收报表
  1153. /// 查询 根据日期范围
  1154. /// </summary>
  1155. /// <param name="dto"></param>
  1156. /// <returns></returns>
  1157. [HttpPost]
  1158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1159. public async Task<IActionResult> PostPayRequest_Center(PostPayRequestByDateRangeDto dto)
  1160. {
  1161. tree_Fin_DailyFeePaymentResult dailyResult = PayRequest_DailyByDateRange(dto.beginDt, dto.endDt);
  1162. return Ok(JsonView(true, "获取成功", new { daily = dailyResult }));
  1163. return Ok(JsonView(false, "获取失败"));
  1164. }
  1165. /// <summary>
  1166. /// 付款申请
  1167. /// 查询 根据日期范围
  1168. /// </summary>
  1169. /// <param name="dto"></param>
  1170. /// <returns></returns>
  1171. private tree_Fin_DailyFeePaymentResult PayRequest_DailyByDateRange(string beginDt, string endDt)
  1172. {
  1173. #region sql条件处理
  1174. string sqlWhere = string.Format(@" And dfp.CreateTime between '{0} 00:00:00' And '{1} 23:59:59' ", beginDt, endDt);
  1175. string sql_1 = string.Format(@"Select * From (
  1176. Select row_number() over (order by dfp.Id Desc) as RowNumber,
  1177. dfp.Id,dfp.CompanyId,c.CompanyName,dfp.Instructions,dfp.SumPrice,
  1178. dfp.CreateUserId,u.CnName CreateUser,dfp.CreateTime,dfp.FAudit,dfp.MAudit,
  1179. dfp.PriceTypeId,dfp.TransferTypeId
  1180. From Fin_DailyFeePayment dfp
  1181. Inner Join Sys_Company c On dfp.CompanyId = c.Id
  1182. Left Join Sys_Users u On dfp.CreateUserId = u.Id
  1183. Where dfp.IsDel=0 {0} And dfp.FAudit = 1 And dfp.MAudit = 1
  1184. ) temp ", sqlWhere);
  1185. #endregion
  1186. List<tree_Fin_DailyFeePaymentPageListView> DailyFeePaymentData = _sqlSugar.SqlQueryable<tree_Fin_DailyFeePaymentPageListView>(sql_1).ToList();
  1187. Dictionary<int, string> dic_setData = new Dictionary<int, string>();
  1188. foreach (var item in DailyFeePaymentData)
  1189. {
  1190. if (dic_setData.ContainsKey(item.PriceTypeId))
  1191. {
  1192. item.priceTypeStr = dic_setData[item.PriceTypeId];
  1193. }
  1194. else
  1195. {
  1196. Sys_SetData sd_priceType = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceTypeId).First();
  1197. if (sd_priceType != null)
  1198. {
  1199. item.priceTypeStr = sd_priceType.Name;
  1200. dic_setData.Add(item.PriceTypeId, sd_priceType.Name);
  1201. }
  1202. }
  1203. if (dic_setData.ContainsKey(item.transferTypeId))
  1204. {
  1205. item.transferTypeIdStr = dic_setData[item.transferTypeId];
  1206. Sys_SetData sd_transfer = _daiRep.Query<Sys_SetData>(s => s.Id == item.transferTypeId).First();
  1207. if (sd_transfer != null)
  1208. {
  1209. item.transferParentId = sd_transfer.STid;
  1210. item.transferParentIdStr = sd_transfer.STid == 62 ? "公转" : sd_transfer.STid == 63 ? "私转" : "";
  1211. }
  1212. }
  1213. else
  1214. {
  1215. Sys_SetData sd_transfer = _daiRep.Query<Sys_SetData>(s => s.Id == item.transferTypeId).First();
  1216. if (sd_transfer != null)
  1217. {
  1218. item.transferTypeIdStr = sd_transfer.Name;
  1219. item.transferParentId = sd_transfer.STid;
  1220. item.transferParentIdStr = sd_transfer.STid == 62 ? "公转" : sd_transfer.STid == 63 ? "私转" : "";
  1221. dic_setData.Add(item.transferTypeId, sd_transfer.Name);
  1222. }
  1223. }
  1224. string feeContentSql = string.Format(@"Select * From Fin_DailyFeePaymentContent
  1225. Where IsDel=0 And DFPId = {0} ", item.Id);
  1226. item.childList = _sqlSugar.SqlQueryable<Fin_DailyFeePaymentContentInfolView>(feeContentSql).ToList();
  1227. }
  1228. decimal total_gz = DailyFeePaymentData.Where(s => s.transferParentId == 62).Sum(d => d.SumPrice ?? 0M);
  1229. decimal total_sz = DailyFeePaymentData.Where(s => s.transferParentId == 63).Sum(d => d.SumPrice ?? 0M);
  1230. var result = new tree_Fin_DailyFeePaymentResult() { gz = total_gz, sz = total_sz, dataList = DailyFeePaymentData };
  1231. return result;
  1232. }
  1233. #endregion
  1234. #region 超支费用
  1235. /// <summary>
  1236. /// 超支费用
  1237. /// 1增、2改、3删
  1238. /// </summary>
  1239. /// <param name="dto"></param>
  1240. /// <returns></returns>
  1241. [HttpPost]
  1242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1243. public async Task<IActionResult> PostGroupExtraCost_Operator(Fin_GroupExtraCostDto_OP dto)
  1244. {
  1245. #region 验证
  1246. #endregion
  1247. Fin_GroupExtraCost _entity = new Fin_GroupExtraCost();
  1248. _entity.DiId = dto.diId;
  1249. _entity.PriceName = dto.priceName;
  1250. _entity.Price = dto.price;
  1251. _entity.PriceCurrency = dto.currency;
  1252. _entity.PriceType = dto.priceType;
  1253. _entity.Coefficient = dto.coefficient;
  1254. _entity.PriceDetailType = dto.priceDetailType;
  1255. _entity.FilePath = dto.filePath;
  1256. _entity.Remark = dto.remark;
  1257. _daiRep.BeginTran();
  1258. if (dto.editType == 1)
  1259. {
  1260. _entity.CreateUserId = dto.createUser;
  1261. _entity.CreateTime = DateTime.Now;
  1262. _entity.IsDel = 0;
  1263. int returnId = await _daiRep.AddAsyncReturnId<Fin_GroupExtraCost>(_entity);
  1264. if (returnId > 0)
  1265. {
  1266. dto.Id = returnId;
  1267. }
  1268. }
  1269. else if (dto.editType == 2)
  1270. {
  1271. bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
  1272. {
  1273. PriceName = dto.priceName,
  1274. Price = dto.price,
  1275. PriceCurrency = dto.currency,
  1276. PriceType = dto.priceType,
  1277. PriceDetailType = dto.priceDetailType,
  1278. Coefficient = dto.coefficient,
  1279. FilePath = dto.filePath,
  1280. Remark = dto.remark
  1281. });
  1282. if (!res)
  1283. {
  1284. _daiRep.RollbackTran();
  1285. return Ok(JsonView(false, "2操作失败!"));
  1286. }
  1287. }
  1288. else if (dto.editType == 3)
  1289. {
  1290. string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
  1291. bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
  1292. {
  1293. IsDel = 1,
  1294. DeleteTime = delTime,
  1295. DeleteUserId = dto.createUser
  1296. });
  1297. if (!res)
  1298. {
  1299. _daiRep.RollbackTran();
  1300. return Ok(JsonView(false, "3操作失败!"));
  1301. }
  1302. }
  1303. else
  1304. {
  1305. _daiRep.RollbackTran();
  1306. return Ok(JsonView(false, "未知的editType"));
  1307. }
  1308. if (!extraCost_editCreditCardPayment(dto))
  1309. {
  1310. return Ok(JsonView(false, "ccp操作失败"));
  1311. }
  1312. _daiRep.CommitTran();
  1313. return Ok(JsonView(false, "操作成功"));
  1314. }
  1315. private bool extraCost_editCreditCardPayment(Fin_GroupExtraCostDto_OP costDto)
  1316. {
  1317. //设置团组汇率
  1318. decimal dcm_dayrate = 1M;
  1319. decimal dcm_rmbPrice = costDto.price;
  1320. int ispay = costDto.payType == 72 ? 1 : 0;
  1321. if (costDto.costSign != 3)
  1322. {
  1323. Grp_TeamRate tr = _daiRep.Query<Grp_TeamRate>(s => s.DiId == costDto.diId && s.CTable == 1015).First();
  1324. if (tr != null)
  1325. {
  1326. if (costDto.currency == 49)
  1327. {
  1328. dcm_dayrate = tr.RateU;
  1329. dcm_rmbPrice = dcm_rmbPrice * tr.RateU;
  1330. }
  1331. else if (costDto.currency == 51)
  1332. {
  1333. dcm_dayrate = tr.RateE;
  1334. dcm_rmbPrice = dcm_rmbPrice * tr.RateE;
  1335. }
  1336. }
  1337. }
  1338. Grp_CreditCardPayment ccp = _daiRep.Query<Grp_CreditCardPayment>(s => s.CId == costDto.Id && s.CTable == 1015).First();
  1339. if (ccp == null)
  1340. {
  1341. ccp = new Grp_CreditCardPayment();
  1342. ccp.PayDId = costDto.payType;// dto
  1343. ccp.ConsumptionPatterns = "";
  1344. ccp.ConsumptionDate = "";
  1345. ccp.CTDId = costDto.payCardId;// dto
  1346. ccp.BankNo = "";
  1347. ccp.CardholderName = "";
  1348. ccp.PayMoney = costDto.price;// dto
  1349. ccp.PaymentCurrency = costDto.currency;// dto
  1350. ccp.CompanyBankNo = "";
  1351. ccp.OtherBankName = "";
  1352. ccp.OtherSideNo = "";
  1353. ccp.OtherSideName = "";
  1354. ccp.Remark = "";
  1355. ccp.CreateUserId = costDto.createUser;
  1356. ccp.CreateTime = DateTime.Now;
  1357. ccp.MFOperator = 0;
  1358. ccp.MFOperatorDate = "";
  1359. ccp.IsAuditDM = 0;
  1360. ccp.AuditDMOperate = 0;
  1361. ccp.AuditDMDate = "";
  1362. ccp.IsAuditMF = 0;
  1363. ccp.AuditMFOperate = 0;
  1364. ccp.AuditMFDate = "";
  1365. ccp.IsAuditGM = 0;
  1366. ccp.AuditGMOperate = 0;
  1367. ccp.AuditGMDate = "";
  1368. ccp.IsPay = ispay; // upd
  1369. ccp.DIId = costDto.diId;// dto
  1370. ccp.CId = costDto.Id;// dto
  1371. ccp.CTable = 1015; //超支费用指向id
  1372. ccp.IsDel = 0;
  1373. ccp.PayPercentage = 100M;
  1374. ccp.PayThenMoney = 0M;
  1375. ccp.PayPercentageOld = 100M;
  1376. ccp.PayThenMoneyOld = 0M;
  1377. ccp.UpdateDate = "";
  1378. ccp.Payee = costDto.payee;// dto
  1379. ccp.OrbitalPrivateTransfer = costDto.costSign;// dto
  1380. ccp.ExceedBudget = 0;
  1381. ccp.DayRate = dcm_dayrate; //upd
  1382. ccp.RMBPrice = dcm_rmbPrice; //upd
  1383. int ccpInsertId = _daiRep.AddReturnId<Grp_CreditCardPayment>(ccp);
  1384. if (ccpInsertId > 0)
  1385. {
  1386. return true;
  1387. }
  1388. }
  1389. else
  1390. {
  1391. if (costDto.editType == 2)
  1392. {
  1393. bool res = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
  1394. {
  1395. PayDId = costDto.payType,
  1396. CTDId = costDto.payCardId,
  1397. PayMoney = costDto.price,
  1398. PaymentCurrency = costDto.currency,
  1399. IsPay = ispay,
  1400. Payee = costDto.payee,
  1401. OrbitalPrivateTransfer = costDto.costSign,
  1402. DayRate = dcm_dayrate,
  1403. RMBPrice = dcm_rmbPrice
  1404. });
  1405. return res;
  1406. }
  1407. else if (costDto.editType == 3)
  1408. {
  1409. string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
  1410. bool res2 = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
  1411. {
  1412. IsDel = 1,
  1413. DeleteTime = delTime,
  1414. DeleteUserId = costDto.createUser
  1415. });
  1416. return res2;
  1417. }
  1418. }
  1419. return false;
  1420. }
  1421. /// <summary>
  1422. /// 超支费用
  1423. /// 列表查询
  1424. /// </summary>
  1425. /// <param name="dto"></param>
  1426. /// <returns></returns>
  1427. [HttpPost]
  1428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1429. public async Task<IActionResult> PostGroupExtraCost_Search(Fin_GroupExtraCostDto_Search dto)
  1430. {
  1431. string sqlWhere = string.Format(@" And f.DiId = {0} ", dto.diId);
  1432. int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
  1433. int endIndex = startIndex + dto.PageSize - 1;
  1434. string sql_data = string.Format(@"Select * From (
  1435. Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
  1436. f.PriceName,f.Price,f.FilePath,f.CreateUserId,f.CreateTime,c.IsAuditGM
  1437. From Fin_GroupExtraCost f
  1438. Inner Join Grp_CreditCardPayment c On f.Id = c.CId
  1439. Left Join Sys_Users u On f.CreateUserId = u.Id
  1440. Where f.IsDel=0 And c.CTable = 1015 {0}
  1441. ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
  1442. string sql_count = string.Format(@"Select Count(1) as DataCount From (
  1443. Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
  1444. f.PriceName,f.PriceType,f.Price,f.FilePath,f.CreateUserId,f.CreateTime,c.IsAuditGM
  1445. From Fin_GroupExtraCost f
  1446. Inner Join Grp_CreditCardPayment c On f.Id = c.CId
  1447. Left Join Sys_Users u On f.CreateUserId = u.Id
  1448. Where f.IsDel=0 And c.CTable = 1015 {0}
  1449. ) temp ", sqlWhere);
  1450. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
  1451. {
  1452. //Fin_DailyFeePaymentPageCount
  1453. var count = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostViewDataCount>(sql_count).FirstAsync();
  1454. List<Fin_GroupExtraCostView> dataList = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostView>(sql_data).ToListAsync();
  1455. Dictionary<int, string> dic_setData = new Dictionary<int, string>();
  1456. Dictionary<int, string> dic_user = new Dictionary<int, string>();
  1457. foreach (var item in dataList)
  1458. {
  1459. //费用详细类型
  1460. if (dic_setData.ContainsKey(item.PriceType))
  1461. {
  1462. item.PriceTypeStr = dic_setData[item.PriceType];
  1463. }
  1464. else
  1465. {
  1466. Sys_SetData sd_priceTypeDetail = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceType).First();
  1467. if (sd_priceTypeDetail != null)
  1468. {
  1469. string tempName = sd_priceTypeDetail.Name.Replace("n", "");
  1470. item.PriceTypeStr = tempName;
  1471. dic_setData.Add(item.PriceType, tempName);
  1472. }
  1473. }
  1474. //系统用户
  1475. if (dic_user.ContainsKey(item.CreateUserId))
  1476. {
  1477. item.CreateUserIdStr = dic_setData[item.CreateUserId];
  1478. }
  1479. else
  1480. {
  1481. Sys_Users users = _daiRep.Query<Sys_Users>(s => s.Id == item.CreateUserId).First();
  1482. if (users != null)
  1483. {
  1484. item.CreateUserIdStr = users.CnName;
  1485. dic_setData.Add(item.CreateUserId, users.CnName);
  1486. }
  1487. }
  1488. switch (item.IsAuditGM)
  1489. {
  1490. case 0: item.IsAuditGMStr = "未审核"; break;
  1491. case 1: item.IsAuditGMStr = "已通过"; break;
  1492. case 2: item.IsAuditGMStr = "未通过"; break;
  1493. default: item.IsAuditGMStr = "未知状态"; break;
  1494. }
  1495. }
  1496. var result = new ListViewBase<Fin_GroupExtraCostView>
  1497. {
  1498. CurrPageIndex = dto.PageIndex,
  1499. CurrPageSize = dto.PageSize,
  1500. DataCount = count.DataCount,
  1501. DataList = dataList
  1502. };
  1503. return Ok(JsonView(true, "查询成功", result));
  1504. }
  1505. return Ok(JsonView(false, "查询成功"));
  1506. }
  1507. /// <summary>
  1508. /// 超支费用
  1509. /// 数据集合配置
  1510. /// </summary>
  1511. /// <param name="dto"></param>
  1512. /// <returns></returns>
  1513. [HttpPost]
  1514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1515. public async Task<IActionResult> PostGroupExtraCost_ListDataInit(Fin_GroupExtraCostDto_DataListInit dto)
  1516. {
  1517. //支付方式
  1518. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  1519. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  1520. //超支费用类型
  1521. List<Sys_SetData> PriceType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 79 && a.IsDel == 0).ToList();
  1522. List<SetDataInfoView> _PriceType = _mapper.Map<List<SetDataInfoView>>(Payment);
  1523. //超支费用详细类型
  1524. List<Sys_SetData> PriceDetailType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 80 && a.IsDel == 0).ToList();
  1525. List<SetDataInfoView> _PriceDetailType = _mapper.Map<List<SetDataInfoView>>(Payment);
  1526. var data = new
  1527. {
  1528. Payment = _Payment,
  1529. PriceType = _PriceType,
  1530. PriceDetailType = _PriceDetailType
  1531. };
  1532. return Ok(JsonView(true, "", data));
  1533. }
  1534. #endregion
  1535. }
  1536. }