FBAIncidentalController.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using Microsoft.AspNetCore.Mvc;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading.Tasks;
  5. using XYY.Authentication.Standard;
  6. using XYY.Core.Standard.ExcelHelper.MSExcelHelper;
  7. using XYY.Core.Standard.Mvc;
  8. using XYY.Data.Standard.Order;
  9. using XYY.Model.Standard.Finance;
  10. namespace XYY.Api.Finance.Controllers
  11. {
  12. [Route("api/[controller]/[action]")]
  13. [ApiController]
  14. public class FBAIncidentalController : ApiControllerBase
  15. {
  16. IFBA_IncidentalRepository _incidentalRepository;
  17. public FBAIncidentalController(IFBA_IncidentalRepository incidentalRepository)
  18. {
  19. _incidentalRepository = incidentalRepository;
  20. }
  21. [HttpGet]
  22. public async Task<ApiJsonModel<List<string>>> GetFeeType(FBAIncidentalCalculateTarget target)
  23. {
  24. var list = await _incidentalRepository.GetFeeTypes(target);
  25. return ApiJsonModel<List<string>>.OK(list);
  26. }
  27. public async Task<ApiJsonModel<List<FBA_Incidental>>> GetFBA_Incidentals(FBAIncidentalDto dto)
  28. {
  29. var list = await _incidentalRepository.GetFBA_Incidentals(dto);
  30. return ApiJsonModel<List<FBA_Incidental>>.OK(list);
  31. }
  32. public async Task<ApiJsonModel<FBAIncidentalDto>> GetFBAIncidentalDto(FBAIncidentalDto dto)
  33. {
  34. dto = await _incidentalRepository.GetFBAIncidentalDto(dto);
  35. return ApiJsonModel<FBAIncidentalDto>.OK(dto);
  36. }
  37. public async Task<ApiJsonModel> SetComfig(FBAIncidentalDto dto)
  38. {
  39. await _incidentalRepository.SetComfig(dto);
  40. return ApiJsonModel.OK();
  41. }
  42. public async Task<ApiJsonModel> SaveFee(FBAIncidentalDto dto)
  43. {
  44. await _incidentalRepository.SaveOtherFee(dto);
  45. return ApiJsonModel.OK();
  46. }
  47. public async Task<IActionResult> GetFBAFee(int OrderId)
  48. {
  49. var fees = await _incidentalRepository.GetFBAFee(OrderId);
  50. return Ok(fees);
  51. }
  52. [HttpPost]
  53. public async Task<IActionResult> IncFBAIncidentals(int IncFBATarget)
  54. {
  55. var filelist = (await Request.ReadFormAsync()).Files;
  56. if (filelist != null && filelist.Count > 0)
  57. {
  58. var file = filelist[0];
  59. var result = await _incidentalRepository.IncFBAIncidentals(IncFBATarget,file.OpenReadStream());
  60. return Ok(result);
  61. }
  62. else
  63. {
  64. return Error("请上传一个文件");
  65. }
  66. }
  67. }
  68. }