using Infrastructure; using Infrastructure.Attribute; using Infrastructure.Enums; using Infrastructure.Model; using Mapster; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using ARW.Admin.WebApi.Extensions; using ARW.Admin.WebApi.Filters; using ARW.Common; using ARW.Model.Dto.Business.Payments; using ARW.Service.Business.IBusinessService.Payments; using ARW.Admin.WebApi.Controllers; using ARW.Model.Models.Business.Payments; namespace ARW.WebApi.Controllers.Business.Payments { /// /// 支付订单控制器 /// [Verify] [Route("business/[controller]")] public class PaymentController : BaseController { private readonly IPaymentService _PaymentService; /// /// 依赖注入 /// /// 支付订单支付订单服务 public PaymentController(IPaymentService PaymentService) { _PaymentService = PaymentService; } /// /// 获取支付订单列表 /// /// 查询参数 /// [HttpGet("getPaymentList")] [ActionPermissionFilter(Permission = "business:payment:list")] public IActionResult GetPaymentList([FromQuery] PaymentQueryDto parm) { var res = _PaymentService.GetPaymentList(parm); return SUCCESS(res.Result); } /// /// 添加或修改支付订单 /// /// /// [HttpPost("addOrUpdatePayment")] [ActionPermissionFilter(Permission = "business:payment:addOrUpdate")] [Log(Title = "添加或修改支付订单", BusinessType = BusinessType.ADDORUPDATE)] public IActionResult AddOrUpdatePayment([FromBody] PaymentDto parm) { if (parm == null) { throw new CustomException("请求参数错误"); } var updateModal = parm.Adapt().ToUpdate(HttpContext); var addModal = parm.Adapt().ToCreate(HttpContext); if (parm.PaymentId != 0) { var response = _PaymentService.UpdateAsync(updateModal); return SUCCESS("修改成功!"); } else { var response = _PaymentService.InsertReturnSnowflakeIdAsync(addModal); return SUCCESS("添加成功!"); } } /// /// 删除支付订单 /// /// [HttpDelete("{ids}")] [ActionPermissionFilter(Permission = "business:payment:delete")] [Log(Title = "支付订单删除", BusinessType = BusinessType.DELETE)] public IActionResult Delete(string ids) { long[] idsArr = Tools.SpitLongArrary(ids); if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } var response = _PaymentService.Delete(idsArr); return ToResponse(response, "删除成功!"); } /// /// 导出支付订单 /// /// [Log(Title = "支付订单导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)] [HttpGet("export")] [ActionPermissionFilter(Permission = "business:payment:export")] public IActionResult ExportExcel([FromQuery] PaymentQueryDto parm) { parm.PageSize = 10000; var list = _PaymentService.GetPaymentList(parm).Result.Result; string sFileName = ExportExcel(list, "Payment", "支付订单列表"); return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName }); } } }