- 系统配置管理模块 (Config) - 内容管理模块 (Banner, Promotion) - 测评管理模块 (Type, Question, Category, Mapping, Conclusion) - 用户管理模块 (User) - 订单管理模块 (Order) - 规划师管理模块 (Planner) - 分销管理模块 (InviteCode, Commission, Withdrawal) - 数据统计仪表盘模块 (Dashboard) - 权限控制集成 - 服务注册配置 全部381个测试通过
124 lines
3.4 KiB
C#
124 lines
3.4 KiB
C#
using MiAssessment.Admin.Business.Attributes;
|
|
using MiAssessment.Admin.Business.Models;
|
|
using MiAssessment.Admin.Business.Models.Common;
|
|
using MiAssessment.Admin.Business.Models.Order;
|
|
using MiAssessment.Admin.Business.Services.Interfaces;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace MiAssessment.Admin.Business.Controllers;
|
|
|
|
/// <summary>
|
|
/// 订单管理控制器
|
|
/// </summary>
|
|
[Route("api/admin/order")]
|
|
public class OrderController : BusinessControllerBase
|
|
{
|
|
private readonly IOrderService _orderService;
|
|
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="orderService">订单服务</param>
|
|
public OrderController(IOrderService orderService)
|
|
{
|
|
_orderService = orderService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取订单列表
|
|
/// </summary>
|
|
/// <param name="request">查询请求</param>
|
|
/// <returns>分页订单列表</returns>
|
|
[HttpGet("getList")]
|
|
[BusinessPermission("order:view")]
|
|
public async Task<IActionResult> GetList([FromQuery] OrderQueryRequest request)
|
|
{
|
|
try
|
|
{
|
|
var result = await _orderService.GetOrderListAsync(request);
|
|
return Ok(result);
|
|
}
|
|
catch (BusinessException ex)
|
|
{
|
|
return Error(ex.Code, ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取订单详情
|
|
/// </summary>
|
|
/// <param name="id">订单ID</param>
|
|
/// <returns>订单详情</returns>
|
|
[HttpGet("getDetail")]
|
|
[BusinessPermission("order:view")]
|
|
public async Task<IActionResult> GetDetail([FromQuery] long id)
|
|
{
|
|
try
|
|
{
|
|
var result = await _orderService.GetOrderDetailAsync(id);
|
|
if (result == null)
|
|
{
|
|
return Error(ErrorCodes.OrderNotFound, "订单不存在");
|
|
}
|
|
return Ok(result);
|
|
}
|
|
catch (BusinessException ex)
|
|
{
|
|
return Error(ex.Code, ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发起退款
|
|
/// </summary>
|
|
/// <param name="request">退款请求</param>
|
|
/// <returns>操作结果</returns>
|
|
[HttpPost("refund")]
|
|
[BusinessPermission("order:update")]
|
|
public async Task<IActionResult> Refund([FromBody] RefundRequest request)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return ValidationError("参数验证失败");
|
|
}
|
|
|
|
try
|
|
{
|
|
var result = await _orderService.RefundAsync(
|
|
request.OrderId,
|
|
request.RefundAmount,
|
|
request.RefundReason);
|
|
|
|
if (result)
|
|
{
|
|
return Ok("退款申请已提交");
|
|
}
|
|
return Error(ErrorCodes.OrderCannotRefund, "退款申请失败");
|
|
}
|
|
catch (BusinessException ex)
|
|
{
|
|
return Error(ex.Code, ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出订单列表
|
|
/// </summary>
|
|
/// <param name="request">查询请求</param>
|
|
/// <returns>导出数据</returns>
|
|
[HttpGet("export")]
|
|
[BusinessPermission("order:view")]
|
|
public async Task<IActionResult> Export([FromQuery] OrderQueryRequest request)
|
|
{
|
|
try
|
|
{
|
|
var result = await _orderService.ExportOrdersAsync(request);
|
|
return Ok(result);
|
|
}
|
|
catch (BusinessException ex)
|
|
{
|
|
return Error(ex.Code, ex.Message);
|
|
}
|
|
}
|
|
}
|