FinancialController.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. using Microsoft.AspNetCore.Http;
  2. using Microsoft.AspNetCore.Mvc;
  3. using OASystem.API.OAMethodLib;
  4. using OASystem.API.OAMethodLib.File;
  5. using OASystem.Domain;
  6. using OASystem.Domain.Dtos.Financial;
  7. using OASystem.Domain.Entities.Groups;
  8. using OASystem.Domain.ViewModels.Financial;
  9. using OASystem.Domain.ViewModels.Groups;
  10. using OASystem.Infrastructure.Repositories.Financial;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using System.Data;
  13. namespace OASystem.API.Controllers
  14. {
  15. /// <summary>
  16. /// 财务模块
  17. /// </summary>
  18. [Route("api/[controller]/[action]")]
  19. [ApiController]
  20. public class FinancialController : ControllerBase
  21. {
  22. private readonly IMapper _mapper;
  23. private readonly IConfiguration _config;
  24. private readonly SqlSugarClient _sqlSugar;
  25. private readonly SetDataTypeRepository _setDataTypeRep;
  26. private readonly DailyFeePaymentRepository _daiRep; //日付申请仓库
  27. private readonly TeamRateRepository _teamRateRep; //团组汇率仓库
  28. private readonly ForeignReceivablesRepository _ForForeignReceivablesRep; //对外收款账单仓库
  29. private readonly ProceedsReceivedRepository _proceedsReceivedRep; //已收款项仓库
  30. /// <summary>
  31. /// 初始化
  32. /// </summary>
  33. public FinancialController(IMapper mapper, IConfiguration configuration, DailyFeePaymentRepository daiRep, SqlSugarClient sqlSugar, SetDataTypeRepository setDataTypeRep, TeamRateRepository teamRateRep, ForeignReceivablesRepository ForForeignReceivablesRep, ProceedsReceivedRepository proceedsReceivedRep)
  34. {
  35. _mapper = mapper;
  36. _config = configuration;
  37. _daiRep = daiRep;
  38. _sqlSugar = sqlSugar;
  39. _setDataTypeRep = setDataTypeRep;
  40. _teamRateRep = teamRateRep;
  41. _ForForeignReceivablesRep = ForForeignReceivablesRep;
  42. _proceedsReceivedRep = proceedsReceivedRep;
  43. }
  44. #region 日付申请
  45. /// <summary>
  46. /// 获取日付申请 基础数据源
  47. /// </summary>
  48. /// <param name="dto"> 日付申请 分页 dto</param>
  49. /// <returns></returns>
  50. [HttpPost]
  51. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  52. public async Task<IActionResult> PostPageSearchDailyPaymentPriceTypeData(PortDtoBase dto)
  53. {
  54. var result = await _daiRep.GetPagePriceTypeData(dto);
  55. if (result == null || result.Code != 0)
  56. {
  57. return Ok(JsonView(false, result.Msg));
  58. }
  59. var data = result.Data;
  60. return Ok(JsonView(data));
  61. }
  62. /// <summary>
  63. /// 获取日付申请 基础数据源 - 转账表识
  64. /// </summary>
  65. /// <param name="dto"> 日付申请 分页 dto</param>
  66. /// <returns></returns>
  67. [HttpPost]
  68. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  69. public async Task<IActionResult> GetSearchDailyPaymentPriceTypeAddData(PortDtoBase dto)
  70. {
  71. var result = await _daiRep.GetPriceTypeAddData(dto);
  72. if (result == null || result.Code != 0)
  73. {
  74. return Ok(JsonView(false, result.Msg));
  75. }
  76. var data = result.Data;
  77. return Ok(JsonView(data));
  78. }
  79. /// <summary>
  80. /// 日付申请 Page Search
  81. /// </summary>
  82. /// <param name="dto"> 日付申请 分页 dto</param>
  83. /// <returns></returns>
  84. [HttpPost]
  85. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  86. public async Task<IActionResult> PostPageSearchDailyPaymentList(PageDailyFeePaymentDto dto)
  87. {
  88. var result = await _daiRep.GetPageSearchAll(dto);
  89. if (result == null || result.Code != 0)
  90. {
  91. return Ok(JsonView(false, result.Msg));
  92. }
  93. var data = result.Data;
  94. if (data == null)
  95. {
  96. return Ok(JsonView(false, result.Msg));
  97. }
  98. return Ok(JsonView(data));
  99. }
  100. /// <summary>
  101. /// 日付申请 Single Search By Id
  102. /// </summary>
  103. /// <param name="dto"></param>
  104. /// <returns></returns>
  105. [HttpPost]
  106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  107. public async Task<IActionResult> PostSearchDailyPaymentInfo(SearchDailyFeePaymentDto dto)
  108. {
  109. var result = await _daiRep.GetSearchById(dto);
  110. if (result == null || result.Code != 0)
  111. {
  112. return Ok(JsonView(false, result.Msg));
  113. }
  114. return Ok(JsonView(result.Data));
  115. }
  116. /// <summary>
  117. /// 日付申请 添加
  118. /// </summary>
  119. /// <param name="dto"> 日付申请 添加 dto</param>
  120. /// <returns></returns>
  121. [HttpPost]
  122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  123. public async Task<IActionResult> PostAddDailyPayment(AddDailyFeePaymentDto dto)
  124. {
  125. var result = await _daiRep.Add(dto);
  126. if (result == null || result.Code != 0)
  127. {
  128. return Ok(JsonView(false, result.Msg));
  129. }
  130. return Ok(JsonView(true));
  131. }
  132. /// <summary>
  133. /// 日付申请 Update
  134. /// </summary>
  135. /// <param name="dto"> 日付申请 修改 dto</param>
  136. /// <returns></returns>
  137. [HttpPost]
  138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  139. public async Task<IActionResult> PostEditDailyPayment(EditDailyFeePaymentDto dto)
  140. {
  141. var result = await _daiRep.Edit(dto);
  142. if (result == null || result.Code != 0)
  143. {
  144. return Ok(JsonView(false, result.Msg));
  145. }
  146. return Ok(JsonView(true));
  147. }
  148. /// <summary>
  149. /// 日付申请 Del
  150. /// </summary>
  151. /// <param name="dto"> 日付申请 删除 dto</param>
  152. /// <returns></returns>
  153. [HttpPost]
  154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  155. public async Task<IActionResult> PostDelDailyPayment(DelDailyFeePaymentDto dto)
  156. {
  157. var result = await _daiRep.Del(dto);
  158. if (result == null || result.Code != 0)
  159. {
  160. return Ok(JsonView(false, result.Msg));
  161. }
  162. return Ok(JsonView(true));
  163. }
  164. /// <summary>
  165. /// 日付申请 财务审核
  166. /// </summary>
  167. /// <param name="dto"> dto </param>
  168. /// <returns></returns>
  169. [HttpPost]
  170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  171. public async Task<IActionResult> PostDelDailyPaymentAudit(DP_AuditStatusDto dto)
  172. {
  173. var result = await _daiRep.DelDailyPaymentAudit(dto);
  174. if (result == null || result.Code != 0)
  175. {
  176. return Ok(JsonView(false, result.Msg));
  177. }
  178. return Ok(JsonView(true));
  179. }
  180. /// <summary>
  181. /// 日付申请 Single Excel Download
  182. /// </summary>
  183. /// <param name="dto"> dto </param>
  184. /// <returns></returns>
  185. [HttpPost]
  186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  187. public async Task<IActionResult> PostExcelDailyPaymentDownload(SearchDailyFeePaymentDto dto)
  188. {
  189. if (dto.PortType == 1 || dto.PortType == 2)
  190. {
  191. Fin_DailyFeePaymentInfolView feeData = new Fin_DailyFeePaymentInfolView();
  192. string feeSql = string.Format(@"Select * From Fin_DailyFeePayment
  193. Where IsDel=0 And Id = {0} ", dto.Id);
  194. feeData = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentInfolView>(feeSql).FirstAsync();
  195. if (feeData == null)
  196. {
  197. return Ok(JsonView(false, "暂无数据!"));
  198. }
  199. string feeContentSql = string.Format(@"Select * From Fin_DailyFeePaymentContent
  200. Where IsDel=0 And DFPId = {0} ", dto.Id);
  201. feeData.FeeContents = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentContentInfolView>(feeContentSql).ToListAsync();
  202. if (feeData != null)
  203. {
  204. string userName = string.Empty;
  205. string userSql = string.Format("Select * From Sys_Users Where Id={0} And Isdel = {1}", feeData.CreateUserId, 0);
  206. Sys_Users user = await _sqlSugar.SqlQueryable<Sys_Users>(userSql).FirstAsync();
  207. if (user != null) { userName = user.CnName; }
  208. var setData = _setDataTypeRep.QueryDto<Sys_SetData, Fin_DailyFeePaymentPagePriceSubTypeView>().ToList();
  209. //48人员费用 49办公费用 50 销售费用 51 其他费用 55 大运会
  210. var priceSubTypeData = setData.Where(s => s.STid == 55).ToList();
  211. Dictionary<string, object> pairs = new Dictionary<string, object>();
  212. List<DataTable> datas = new List<DataTable>();
  213. //if (priceSubTypeData.Where(s => s.Id == feeData.PriceTypeId).ToList().Count() > 0)//大运会专属模板
  214. //{
  215. // //AsposeHelper.ExpertExcelToModel("日常费用付款申请模板-大运会数据.xls", "DailyPayment", "大运会所有日常费用付款申请.xls",
  216. // // pairs, datas);
  217. //}
  218. //else //日付常规模板
  219. //{
  220. pairs.Clear();
  221. pairs.Add("Opertor", userName);
  222. pairs.Add("DateTime", feeData.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  223. pairs.Add("FAuditStatus", feeData.FAuditDesc);
  224. pairs.Add("MAuditStatus", feeData.MAuditDesc);
  225. pairs.Add("SumPrice", feeData.SumPrice);
  226. DataTable data = AsposeHelper.ListToDataTable("DailyFeePayment", feeData.FeeContents);
  227. datas.Clear();
  228. datas.Add(data);
  229. string fileName = string.Format("{0}-日常费用付款申请.xlsx", feeData.Instructions);
  230. string msg = AsposeHelper.ExpertExcelToModel("日常费用付款申请模板.xlsx", "DailyPayment", fileName, pairs, datas);
  231. return Ok(JsonView(true, msg));
  232. //}
  233. }
  234. else
  235. {
  236. return Ok(JsonView(false, "暂无数据!"));
  237. }
  238. }
  239. return Ok(JsonView(true));
  240. }
  241. #endregion
  242. #region 团组提成
  243. /// <summary>
  244. /// 提成 Page Search
  245. /// </summary>
  246. /// <param name="dto"> 提成 分页 dto</param>
  247. /// <returns></returns>
  248. [HttpPost]
  249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  250. public async Task<IActionResult> PostPageSearchCommissionList(GroupCommissionDto dto)
  251. {
  252. var data = await GroupCommission.GetCommissionPageList(dto);
  253. return Ok(JsonView(data.Data));
  254. }
  255. #endregion
  256. #region 团组汇率
  257. /// <summary>
  258. /// 团组汇率 Select数据源(团组列,汇率列)
  259. /// </summary>
  260. /// <param name="dto"></param>
  261. /// <returns></returns>
  262. [HttpPost]
  263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  264. public async Task<IActionResult> GetGroupRateDataSources(TeamRateDto dto)
  265. {
  266. try
  267. {
  268. Result teamRateData = await _teamRateRep.GetGroupRateDataSource(dto);
  269. if (teamRateData.Code != 0)
  270. {
  271. return Ok(JsonView(false, teamRateData.Msg));
  272. }
  273. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  274. }
  275. catch (Exception ex)
  276. {
  277. return Ok(JsonView(false, ex.Message));
  278. throw;
  279. }
  280. }
  281. ///// <summary>
  282. ///// 团组汇率 changge
  283. ///// </summary>
  284. ///// <returns></returns>
  285. //[HttpPost]
  286. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  287. //public async Task<IActionResult> ChangeGroupRateInfo()
  288. //{
  289. // try
  290. // {
  291. // Result teamRateData = await _teamRateRep.GetGroupRateChangeData();
  292. // if (teamRateData.Code != 0)
  293. // {
  294. // return Ok(JsonView(false, teamRateData.Msg));
  295. // }
  296. // return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  297. // }
  298. // catch (Exception ex)
  299. // {
  300. // return Ok(JsonView(false, ex.Message));
  301. // throw;
  302. // }
  303. //}
  304. /// <summary>
  305. /// 团组汇率 Select汇率详情
  306. /// </summary>
  307. /// <param name="dto"></param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<IActionResult> GetGroupRateInfo(TeamRateInfoDto dto)
  312. {
  313. try
  314. {
  315. Result teamRateData = await _teamRateRep.GetGroupRateInfoByDiid(dto);
  316. if (teamRateData.Code != 0)
  317. {
  318. return Ok(JsonView(false, teamRateData.Msg));
  319. }
  320. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  321. }
  322. catch (Exception ex)
  323. {
  324. return Ok(JsonView(false, ex.Message));
  325. throw;
  326. }
  327. }
  328. /// <summary>
  329. /// 团组汇率 添加 or 更新
  330. /// </summary>
  331. /// <param name="dto"></param>
  332. /// <returns></returns>
  333. [HttpPost]
  334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  335. public async Task<IActionResult> PostGroupRateUpdate(TeamRateUpdateDto dto)
  336. {
  337. try
  338. {
  339. Result teamRateData = await _teamRateRep.PostGroupRateUpdate(dto);
  340. if (teamRateData.Code != 0)
  341. {
  342. return Ok(JsonView(false, teamRateData.Msg));
  343. }
  344. return Ok(JsonView(true, teamRateData.Msg, teamRateData.Data));
  345. }
  346. catch (Exception ex)
  347. {
  348. return Ok(JsonView(false, ex.Message));
  349. throw;
  350. }
  351. }
  352. #endregion
  353. #region 对外收款账单 关联已收款项
  354. /// <summary>
  355. /// 对外收款账单 Select数据源(团组名,币种,汇款方式)
  356. /// 关联已收款项
  357. /// </summary>
  358. /// <param name="dto"></param>
  359. /// <returns></returns>
  360. [HttpPost]
  361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  362. public async Task<IActionResult> GetForeignReceivablesDataSources()
  363. {
  364. try
  365. {
  366. Result ffrData = await _ForForeignReceivablesRep.GetDataSource();
  367. if (ffrData.Code != 0)
  368. {
  369. return Ok(JsonView(false, ffrData.Msg));
  370. }
  371. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  372. }
  373. catch (Exception ex)
  374. {
  375. return Ok(JsonView(false, ex.Message));
  376. throw;
  377. }
  378. }
  379. /// <summary>
  380. /// 对外收款账单
  381. /// 账单详情
  382. /// 关联已收款项
  383. /// </summary>
  384. /// <param name="dto"></param>
  385. /// <returns></returns>
  386. [HttpPost]
  387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  388. public async Task<IActionResult> GetGroupReceivablesInfoByDiId(ForForeignReceivablesInfoDto dto)
  389. {
  390. try
  391. {
  392. Result ffrData = await _ForForeignReceivablesRep.GetGroupReceivablesInfoByDiId(dto);
  393. if (ffrData.Code != 0)
  394. {
  395. return Ok(JsonView(false, ffrData.Msg));
  396. }
  397. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  398. }
  399. catch (Exception ex)
  400. {
  401. return Ok(JsonView(false, ex.Message));
  402. throw;
  403. }
  404. }
  405. /// <summary>
  406. /// 对外收款账单
  407. /// 账单 删除
  408. /// 关联已收款项
  409. /// </summary>
  410. /// <param name="dto"></param>
  411. /// <returns></returns>
  412. [HttpPost]
  413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  414. public async Task<IActionResult> PostGroupReceivablesDel(DelForForeignReceivablesInfoDto dto)
  415. {
  416. try
  417. {
  418. Result ffrData = await _ForForeignReceivablesRep._Del(dto);
  419. if (ffrData.Code != 0)
  420. {
  421. return Ok(JsonView(false, ffrData.Msg));
  422. }
  423. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  424. }
  425. catch (Exception ex)
  426. {
  427. return Ok(JsonView(false, ex.Message));
  428. throw;
  429. }
  430. }
  431. /// <summary>
  432. /// 对外收款账单
  433. /// 添加 And 更新
  434. /// 关联已收款项
  435. /// </summary>
  436. /// <param name="dto"></param>
  437. /// <returns></returns>
  438. [HttpPost]
  439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  440. public async Task<IActionResult> PostReceivablesOperate(ForeignReceivablesAddAndUpdateDto dto)
  441. {
  442. try
  443. {
  444. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesOperate(dto);
  445. if (ffrData.Code != 0)
  446. {
  447. return Ok(JsonView(false, ffrData.Msg));
  448. }
  449. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  450. }
  451. catch (Exception ex)
  452. {
  453. return Ok(JsonView(false, ex.Message));
  454. throw;
  455. }
  456. }
  457. /// <summary>
  458. /// 已收款项
  459. /// 账单 删除
  460. /// 关联已收款项
  461. /// </summary>
  462. /// <param name="dto"></param>
  463. /// <returns></returns>
  464. [HttpPost]
  465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  466. public async Task<IActionResult> PostAmountReceivedDel(ProceedsReceivedDelDto dto)
  467. {
  468. try
  469. {
  470. Result ffrData = await _proceedsReceivedRep._Del(dto);
  471. if (ffrData.Code != 0)
  472. {
  473. return Ok(JsonView(false, ffrData.Msg));
  474. }
  475. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  476. }
  477. catch (Exception ex)
  478. {
  479. return Ok(JsonView(false, ex.Message));
  480. throw;
  481. }
  482. }
  483. /// <summary>
  484. /// 已收款项
  485. /// 添加 And 更新
  486. /// 关联已收款项
  487. /// </summary>
  488. /// <param name="dto"></param>
  489. /// <returns></returns>
  490. [HttpPost]
  491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  492. public async Task<IActionResult> PostAmountReceivedOperate(ProceedsReceivedDto dto)
  493. {
  494. try
  495. {
  496. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedOperate(dto);
  497. if (ffrData.Code != 0)
  498. {
  499. return Ok(JsonView(false, ffrData.Msg));
  500. }
  501. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  502. }
  503. catch (Exception ex)
  504. {
  505. return Ok(JsonView(false, ex.Message));
  506. throw;
  507. }
  508. }
  509. /// <summary>
  510. /// 财务 已收款项
  511. /// 分配已收款项至 应收项下
  512. /// 关联已收款项
  513. /// </summary>
  514. /// <param name="dto"></param>
  515. /// <returns></returns>
  516. [HttpPost]
  517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  518. public async Task<IActionResult> PostAllocateAmountReceived(AllocateAmountReceivedDto dto)
  519. {
  520. try
  521. {
  522. Result ffrData = await _proceedsReceivedRep.PostAllocateAmountReceived(dto);
  523. if (ffrData.Code != 0)
  524. {
  525. return Ok(JsonView(false, ffrData.Msg));
  526. }
  527. return Ok(JsonView(true));
  528. }
  529. catch (Exception ex)
  530. {
  531. return Ok(JsonView(false, ex.Message));
  532. throw;
  533. }
  534. }
  535. ///// <summary>
  536. ///// 财务 收款账单
  537. ///// 导出Word(北京,四川)
  538. ///// </summary>
  539. ///// <param name="dto"></param>
  540. ///// <returns></returns>
  541. //[HttpPost]
  542. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  543. //public async Task<IActionResult> PostAccountReceivableWordExport(AccountReceivableWordExportDto dto)
  544. //{
  545. // try
  546. // {
  547. // //模板处理
  548. // string typeName = string.Empty;
  549. // if (dto.TemplateType == 1) //四川
  550. // {
  551. // typeName = "四川";
  552. // }
  553. // else if (dto.TemplateType == 2) //北京
  554. // {
  555. // typeName = "北京";
  556. // }
  557. // else return Ok(JsonView(false,"请选择正确的模板类型!"));
  558. // string wordTempName = string.Format("收款账单({0})模板.doc", typeName);
  559. // }
  560. // catch (Exception ex)
  561. // {
  562. // return Ok(JsonView(false, ex.Message));
  563. // }
  564. //}
  565. #endregion
  566. #region 对外收款账单
  567. /// <summary>
  568. /// 对外收款账单
  569. /// 数据源
  570. /// </summary>
  571. /// <param name="dto"></param>
  572. /// <returns></returns>
  573. [HttpPost]
  574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  575. public async Task<IActionResult> PostGroupReceivablesDataSource()
  576. {
  577. try
  578. {
  579. Result ffrData = await _ForForeignReceivablesRep.PostDataSource();
  580. if (ffrData.Code != 0)
  581. {
  582. return Ok(JsonView(false, ffrData.Msg));
  583. }
  584. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  585. }
  586. catch (Exception ex)
  587. {
  588. return Ok(JsonView(false, ex.Message));
  589. throw;
  590. }
  591. }
  592. /// <summary>
  593. /// 对外收款账单
  594. /// 账单详情
  595. /// </summary>
  596. /// <param name="dto"></param>
  597. /// <returns></returns>
  598. [HttpPost]
  599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  600. public async Task<IActionResult> PostGroupReceivablesInfoByDiId(ForForeignReceivablesNewDto dto)
  601. {
  602. try
  603. {
  604. Result ffrData = await _ForForeignReceivablesRep.PostGroupReceivablesInfoByDiId(dto);
  605. if (ffrData.Code != 0)
  606. {
  607. return Ok(JsonView(false, ffrData.Msg));
  608. }
  609. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  610. }
  611. catch (Exception ex)
  612. {
  613. return Ok(JsonView(false, ex.Message));
  614. throw;
  615. }
  616. }
  617. /// <summary>
  618. /// 对外收款账单
  619. /// 添加 And 更新
  620. /// </summary>
  621. /// <param name="dto"></param>
  622. /// <returns></returns>
  623. [HttpPost]
  624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  625. public async Task<IActionResult> PostReceivablesSave(ForeignReceivablesSaveDto dto)
  626. {
  627. try
  628. {
  629. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesSave(dto);
  630. if (ffrData.Code != 0)
  631. {
  632. return Ok(JsonView(false, ffrData.Msg));
  633. }
  634. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  635. }
  636. catch (Exception ex)
  637. {
  638. return Ok(JsonView(false, ex.Message));
  639. throw;
  640. }
  641. }
  642. /// <summary>
  643. /// 已收账单
  644. /// 删除
  645. /// </summary>
  646. /// <param name="dto"></param>
  647. /// <returns></returns>
  648. [HttpPost]
  649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  650. public async Task<IActionResult> PostReceivablesDel(ForeignReceivablesDelDto dto)
  651. {
  652. try
  653. {
  654. Result ffrData = await _ForForeignReceivablesRep.PostReceivablesDel(dto);
  655. if (ffrData.Code != 0)
  656. {
  657. return Ok(JsonView(false, ffrData.Msg));
  658. }
  659. return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
  660. }
  661. catch (Exception ex)
  662. {
  663. return Ok(JsonView(false, ex.Message));
  664. throw;
  665. }
  666. }
  667. #endregion
  668. #region 已收款项
  669. /// <summary>
  670. /// 已收款项
  671. /// 查询
  672. /// </summary>
  673. /// <param name="dto"></param>
  674. /// <returns></returns>
  675. [HttpPost]
  676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  677. public async Task<IActionResult> PostAmountReceived(AmountReceivedDto dto)
  678. {
  679. try
  680. {
  681. if (dto == null)
  682. {
  683. return Ok(JsonView(false, "参数不能为空!"));
  684. }
  685. Result ffrData = await _proceedsReceivedRep.PostAmountReceived(dto.DiId );
  686. dynamic data = null;
  687. if (dto.PortType == 1)
  688. {
  689. if (ffrData.Code != 0)
  690. {
  691. return Ok(JsonView(false, ffrData.Msg));
  692. }
  693. data= ffrData.Data;
  694. }
  695. else if(dto.PortType == 2)
  696. {
  697. if (ffrData.Code != 0)
  698. {
  699. return Ok(JsonView(false, ffrData.Msg));
  700. }
  701. data = ffrData.Data;
  702. }
  703. else if (dto.PortType == 2)
  704. {
  705. if (ffrData.Code != 0)
  706. {
  707. return Ok(JsonView(false, ffrData.Msg));
  708. }
  709. data = ffrData.Data;
  710. }
  711. else
  712. {
  713. return Ok(JsonView(false, "请选择正确的端口号!"));
  714. }
  715. return Ok(JsonView(true,"操作成功!", data));
  716. }
  717. catch (Exception ex)
  718. {
  719. return Ok(JsonView(false, ex.Message));
  720. }
  721. }
  722. /// <summary>
  723. /// 已收款项
  724. /// Add Or Edit
  725. /// </summary>
  726. /// <param name="dto"></param>
  727. /// <returns></returns>
  728. [HttpPost]
  729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  730. public async Task<IActionResult> PostAmountReceivedAddOrEdit(AmountReceivedAddOrEditDto dto)
  731. {
  732. try
  733. {
  734. if (dto == null)
  735. {
  736. return Ok(JsonView(false, "参数不能为空!"));
  737. }
  738. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedAddOrEditDto(dto);
  739. if (dto.PortType == 1)
  740. {
  741. if (ffrData.Code != 0)
  742. {
  743. return Ok(JsonView(false, ffrData.Msg));
  744. }
  745. }
  746. else if (dto.PortType == 2)
  747. {
  748. if (ffrData.Code != 0)
  749. {
  750. return Ok(JsonView(false, ffrData.Msg));
  751. }
  752. }
  753. else if (dto.PortType == 2)
  754. {
  755. if (ffrData.Code != 0)
  756. {
  757. return Ok(JsonView(false, ffrData.Msg));
  758. }
  759. }
  760. else
  761. {
  762. return Ok(JsonView(false, "请选择正确的端口号!"));
  763. }
  764. return Ok(JsonView(true, "操作成功!"));
  765. }
  766. catch (Exception ex)
  767. {
  768. return Ok(JsonView(false, ex.Message));
  769. }
  770. }
  771. /// <summary>
  772. /// 已收款项
  773. /// Del
  774. /// </summary>
  775. /// <param name="dto"></param>
  776. /// <returns></returns>
  777. [HttpPost]
  778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  779. public async Task<IActionResult> PostAmountReceived_Del(AmountReceivedDelDto dto)
  780. {
  781. try
  782. {
  783. if (dto == null)
  784. {
  785. return Ok(JsonView(false, "参数不能为空!"));
  786. }
  787. Result ffrData = await _proceedsReceivedRep.PostAmountReceivedDel(dto);
  788. if (ffrData.Code != 0)
  789. {
  790. return Ok(JsonView(false, ffrData.Msg));
  791. }
  792. return Ok(JsonView(true, "操作成功!"));
  793. }
  794. catch (Exception ex)
  795. {
  796. return Ok(JsonView(false, ex.Message));
  797. }
  798. }
  799. #endregion
  800. }
  801. }