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.Admin.WebApi.Controllers;
using ARW.Model.Dto.Api.OrderManage.OrderRefunds;
using ARW.Service.Api.IBusinessService.OrderManage.OrderRefunds;
using ARW.Model.Models.Business.OrderManage.OrderRefunds;
using ARW.Model.Vo.Api.OrderManage.OrderRefunds;
using Microsoft.AspNetCore.Authorization;
using Geocoding;
using ARW.Model.Dto.Business.OrderManage.OrderRefunds;
using ARW.Service.Business.IBusinessService.OrderManage.OrderRefunds;
using ARW.Admin.WebApi.Framework;
using ARW.Service.Business.IBusinessService.LogisticsManage.LogisticsCompanys;
using ARW.Service.System.IService;
namespace ARW.WebApi.Controllers.Api.OrderManage.OrderRefunds
{
///
/// 售后单记录表控制器Api
///
/// @author lwh
/// @date 2023-10-16
///
[Verify]
[Route("api/[controller]")]
public class OrderRefundApiController : BaseController
{
private readonly IOrderRefundServiceApi _OrderRefundServiceApi;
private readonly ILogisticsCompanyService _LogisticsCompanyService;
private readonly ISysDictDataService _SysDictDataService;
///
/// 依赖注入
///
/// 售后单记录表售后单记录表Api服务
public OrderRefundApiController(IOrderRefundServiceApi OrderRefundServiceApi, ILogisticsCompanyService logisticsCompanyService, ISysDictDataService sysDictDataService)
{
_OrderRefundServiceApi = OrderRefundServiceApi;
_LogisticsCompanyService = logisticsCompanyService;
_SysDictDataService = sysDictDataService;
}
///
/// 获取售后单记录表列表(Api)
///
/// 查询参数
///
[HttpGet("getOrderRefundList")]
public async Task GetOrderRefundListApi([FromQuery] OrderRefundQueryDtoApi parm)
{
var user = JwtUtil.GetLoginUser(App.HttpContext);
parm.CustomerGuid = user.UserId;
var res = await _OrderRefundServiceApi.GetOrderRefundListApi(parm);
return SUCCESS(res);
}
///
/// 获取OrderRefund详情(Api)
///
/// 查询参数
///
[HttpGet("getOrderRefundDetails")]
public async Task GetOrderRefundDetails([FromQuery] OrderRefundDtoApi parm)
{
//if (parm == null) throw new CustomException("参数错误!");
var res = await _OrderRefundServiceApi.GetOrderRefundDetails(parm);
if (res != "[]")
{
res = res.Remove(0, 1);
res = res.Substring(0, res.Length - 1);
var data = res.FromJSON();
return SUCCESS(data);
}
else
{
return SUCCESS(res);
}
}
///
/// 获取物流公司列表
///
///
[HttpGet("getLogisticsCompanyList")]
public async Task GetLogisticsCompanyList()
{
var res = await _LogisticsCompanyService.GetListAsync();
return SUCCESS(res);
}
///
/// 获取退款原因
///
///
[HttpGet("getRefundReason")]
public async Task GetRefundReason()
{
var res = _SysDictDataService.SelectDictDataByType("refund_reason");
return SUCCESS(res);
}
///
/// 添加售后单记录表
///
///
///
[HttpPost("addOrderRefund")]
[Log(Title = "添加售后单记录表", BusinessType = BusinessType.ADDORUPDATE)]
public async Task AddOrderRefund([FromBody] AddOrderRefundApiDto parm)
{
if (parm == null) { throw new CustomException("请求参数错误"); }
var user = JwtUtil.GetLoginUser(App.HttpContext);
parm.CustomerGuid = user.UserId;
var modal = parm.Adapt().ToCreate(HttpContext);
var res = await _OrderRefundServiceApi.AddOrderRefund(modal);
return SUCCESS(res);
}
///
/// 撤销申请
///
///
///
[HttpPost("repeal")]
[Log(Title = "撤销申请", BusinessType = BusinessType.ADDORUPDATE)]
public async Task RepealOrderRefund([FromBody] AddOrderRefundApiDto parm)
{
if (parm == null) { throw new CustomException("请求参数错误"); }
var res = await _OrderRefundServiceApi.RepealOrderRefund(parm);
return SUCCESS(res);
}
///
/// 买家发货(填写运单号)
///
///
///
[HttpPost("buyerDelivery")]
[Log(Title = "买家发货(填写运单号)", BusinessType = BusinessType.ADDORUPDATE)]
public async Task BuyerDelivery([FromBody] BuyerDeliveryApiDto parm)
{
if (parm == null) { throw new CustomException("请求参数错误"); }
var res = await _OrderRefundServiceApi.BuyerDelivery(parm);
return SUCCESS(res);
}
}
}