110 lines
3.8 KiB
C#
110 lines
3.8 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 支付订单控制器
|
|
/// </summary>
|
|
[Verify]
|
|
[Route("business/[controller]")]
|
|
public class PaymentController : BaseController
|
|
{
|
|
private readonly IPaymentService _PaymentService;
|
|
|
|
/// <summary>
|
|
/// 依赖注入
|
|
/// </summary>
|
|
/// <param name="PaymentService">支付订单支付订单服务</param>
|
|
public PaymentController(IPaymentService PaymentService)
|
|
{
|
|
_PaymentService = PaymentService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取支付订单列表
|
|
/// </summary>
|
|
/// <param name="parm">查询参数</param>
|
|
/// <returns></returns>
|
|
[HttpGet("getPaymentList")]
|
|
[ActionPermissionFilter(Permission = "business:payment:list")]
|
|
public IActionResult GetPaymentList([FromQuery] PaymentQueryDto parm)
|
|
{
|
|
var res = _PaymentService.GetPaymentList(parm);
|
|
return SUCCESS(res.Result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加或修改支付订单
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
[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<Payment>().ToUpdate(HttpContext);
|
|
var addModal = parm.Adapt<Payment>().ToCreate(HttpContext);
|
|
|
|
if (parm.PaymentId != 0)
|
|
{
|
|
var response = _PaymentService.UpdateAsync(updateModal);
|
|
return SUCCESS("修改成功!");
|
|
}
|
|
else
|
|
{
|
|
var response = _PaymentService.InsertReturnSnowflakeIdAsync(addModal);
|
|
return SUCCESS("添加成功!");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除支付订单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[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, "删除成功!");
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 导出支付订单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[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 });
|
|
}
|
|
|
|
}
|
|
}
|