fixed 修改订单相关问题
This commit is contained in:
parent
90ad56e15b
commit
db01c5a87b
@ -212,6 +212,11 @@ namespace ARW.Model.Vo.Api.OrderManage.Orders
|
||||
public string OrderStatusName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 下单时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,11 @@ namespace ARW.Model.Vo.Api.OrderManage.Orders
|
||||
public string GoodsPictureUrl { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 : 单价
|
||||
/// </summary>
|
||||
public decimal Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :购买数量
|
||||
/// </summary>
|
||||
|
@ -57,9 +57,10 @@ namespace ARW.Service.Api.BusinessService.OrderManage.OrderRefunds
|
||||
private readonly IOrderServiceApi _OrderServiceApi;
|
||||
private readonly IRegionService _RegionService;
|
||||
private readonly ISysDictDataService _SysDictDataService;
|
||||
private readonly GoodsSkuRepository _GoodsSkuRepository;
|
||||
|
||||
|
||||
public OrderRefundServiceImplApi(OrderRefundRepository OrderRefundRepository, OrderRepository orderRepository, OrderGoodsRepository orderGoodsRepository, GoodsRepository goodsRepository, IOrderServiceApi orderServiceApi, ShopAddressRepository shopAddressRepository, IRegionService regionService, ISysDictDataService sysDictDataService, LogisticsCompanyRepository logisticsCompanyRepository)
|
||||
public OrderRefundServiceImplApi(OrderRefundRepository OrderRefundRepository, OrderRepository orderRepository, OrderGoodsRepository orderGoodsRepository, GoodsRepository goodsRepository, IOrderServiceApi orderServiceApi, ShopAddressRepository shopAddressRepository, IRegionService regionService, ISysDictDataService sysDictDataService, LogisticsCompanyRepository logisticsCompanyRepository, GoodsSkuRepository goodsSkuRepository)
|
||||
{
|
||||
this._OrderRefundRepository = OrderRefundRepository;
|
||||
_OrderRepository = orderRepository;
|
||||
@ -70,6 +71,7 @@ namespace ARW.Service.Api.BusinessService.OrderManage.OrderRefunds
|
||||
_RegionService = regionService;
|
||||
_SysDictDataService = sysDictDataService;
|
||||
_LogisticsCompanyRepository = logisticsCompanyRepository;
|
||||
_GoodsSkuRepository = goodsSkuRepository;
|
||||
}
|
||||
|
||||
#region Api接口代码
|
||||
@ -139,6 +141,8 @@ namespace ARW.Service.Api.BusinessService.OrderManage.OrderRefunds
|
||||
{
|
||||
item.Status = 2;
|
||||
item.EserRightsStatusDesc = "商家已审核确认,预计1小时内发起退款";
|
||||
if(item.RefundType != 2)
|
||||
{
|
||||
var buttonVoList = new List<ButtonVO>();
|
||||
var buttonVo = new ButtonVO()
|
||||
{
|
||||
@ -148,11 +152,12 @@ namespace ARW.Service.Api.BusinessService.OrderManage.OrderRefunds
|
||||
buttonVoList.Add(buttonVo);
|
||||
item.ButtonVOs = buttonVoList;
|
||||
}
|
||||
}
|
||||
// 已发货
|
||||
if (item.IsCustomerSend == 2 && item.OrderRefundStatus == 1)
|
||||
{
|
||||
item.Status = 3;
|
||||
item.EserRightsStatusDesc = "商家已退款,退回资金将原路三个工作日内返回您的账户";
|
||||
item.EserRightsStatusDesc = "买家已发货,等待商家收货";
|
||||
//var buttonVoList = new List<ButtonVO>();
|
||||
//var buttonVo = new ButtonVO()
|
||||
//{
|
||||
@ -165,7 +170,7 @@ namespace ARW.Service.Api.BusinessService.OrderManage.OrderRefunds
|
||||
if (item.OrderRefundStatus == 3)
|
||||
{
|
||||
item.Status = 4;
|
||||
item.EserRightsStatusDesc = "退款/售后己完成";
|
||||
item.EserRightsStatusDesc = "退款/售后己完成,商家已退款,退回资金将原路三个工作日内返回您的账户";
|
||||
}
|
||||
if (item.OrderRefundStatus == 4)
|
||||
{
|
||||
@ -183,7 +188,7 @@ namespace ARW.Service.Api.BusinessService.OrderManage.OrderRefunds
|
||||
/// <summary>
|
||||
/// 添加售后单记录表
|
||||
/// </summary>
|
||||
public async Task<string> AddOrderRefund(OrderRefund model)
|
||||
public async Task<long> AddOrderRefund(OrderRefund model)
|
||||
{
|
||||
model.GoodsReceiveStatus = 1;
|
||||
model.MerchantAuditStatus = 1;
|
||||
@ -192,7 +197,7 @@ namespace ARW.Service.Api.BusinessService.OrderManage.OrderRefunds
|
||||
model.IsMerchantReceive = 1;
|
||||
|
||||
var response = await _OrderRefundRepository.InsertReturnSnowflakeIdAsync(model);
|
||||
return "添加成功!";
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@ -297,32 +302,38 @@ namespace ARW.Service.Api.BusinessService.OrderManage.OrderRefunds
|
||||
|
||||
/* 处理售后订单状态描述 */
|
||||
// 待审核
|
||||
if (data.MerchantAuditStatus == 1)
|
||||
if (data.MerchantAuditStatus == 1 && data.OrderRefundStatus == 1)
|
||||
{
|
||||
data.Status = 1;
|
||||
data.StatusName = "待审核";
|
||||
data.EserRightsStatusDesc = "商家将尽快确认您的退款申请";
|
||||
}
|
||||
// 已审核
|
||||
if (data.MerchantAuditStatus == 2)
|
||||
if (data.MerchantAuditStatus == 2 && data.OrderRefundStatus == 1)
|
||||
{
|
||||
data.Status = 2;
|
||||
data.StatusName = "已审核";
|
||||
data.EserRightsStatusDesc = "商家已审核确认,预计1小时内发起退款";
|
||||
}
|
||||
// 已发货
|
||||
if (data.IsCustomerSend == 2)
|
||||
if (data.IsCustomerSend == 2 && data.OrderRefundStatus == 1)
|
||||
{
|
||||
data.Status = 3;
|
||||
data.StatusName = "已发货";
|
||||
data.EserRightsStatusDesc = "商家已退款,退回资金将原路三个工作日内返回您的账户";
|
||||
data.EserRightsStatusDesc = "买家已发货,等待商家收货";
|
||||
}
|
||||
// 已完成
|
||||
if (data.OrderRefundStatus == 3)
|
||||
{
|
||||
data.Status = 4;
|
||||
data.StatusName = "已完成";
|
||||
data.EserRightsStatusDesc = "退款/售后己完成";
|
||||
data.EserRightsStatusDesc = "退款/售后己完成,商家已退款,退回资金将原路三个工作日内返回您的账户";
|
||||
}
|
||||
if (data.OrderRefundStatus == 4)
|
||||
{
|
||||
data.Status = 5;
|
||||
data.StatusName = "已取消";
|
||||
data.EserRightsStatusDesc = "退款/售后己取消";
|
||||
}
|
||||
|
||||
// 商家地址
|
||||
@ -377,7 +388,14 @@ namespace ARW.Service.Api.BusinessService.OrderManage.OrderRefunds
|
||||
BuyQuantity = _item.GoodsTotalNum
|
||||
};
|
||||
if (_item.GoodsSkuId != 0)
|
||||
{
|
||||
var sku = await _GoodsSkuRepository.GetFirstAsync(s => s.GoodsSkuId == _item.GoodsSkuId);
|
||||
if (!string.IsNullOrEmpty(sku.GoodsSkuImg))
|
||||
{
|
||||
orderGood.Thumb = sku.GoodsSkuImg;
|
||||
}
|
||||
orderGood.Specifications = await _OrderServiceApi.GetGoodsSpecList(_item.GoodsSkuId);
|
||||
}
|
||||
|
||||
orderRefundGoodList.Add(orderGood);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ using Infrastructure.Kuaidi100;
|
||||
using ARW.Model.Models.Business.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Repository.Business.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Repository.Business.OrderManage.OrderRefunds;
|
||||
using MimeKit.Cryptography;
|
||||
|
||||
namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
{
|
||||
@ -130,13 +131,21 @@ namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
BuyQuantity = _item.GoodsTotalNum
|
||||
};
|
||||
if (_item.GoodsSkuId != 0)
|
||||
{
|
||||
var sku = await _GoodsSkuRepository.GetFirstAsync(s => s.GoodsSkuId == _item.GoodsSkuId);
|
||||
if (!string.IsNullOrEmpty(sku.GoodsSkuImg))
|
||||
{
|
||||
orderGood.Thumb = sku.GoodsSkuImg;
|
||||
}
|
||||
orderGood.Specifications = await GetGoodsSpecList(_item.GoodsSkuId);
|
||||
}
|
||||
|
||||
goodsList.Add(orderGood);
|
||||
}
|
||||
item.GoodsList = goodsList;
|
||||
|
||||
|
||||
#region 处理订单状态
|
||||
/* 处理订单状态 */
|
||||
if (item.PayStatus == 1 && item.OrderStatus == 1)
|
||||
{
|
||||
@ -240,12 +249,49 @@ namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
item.StatusName = "待取消";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取售后订单商品列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<OrderItem>> GetOrderRefundGoodsList(OrderDtoApi parm)
|
||||
{
|
||||
|
||||
var order = await _OrderRepository.GetFirstAsync(s => s.OrderGuid == parm.OrderGuid);
|
||||
|
||||
// 订单商品
|
||||
var orderItemList = new List<OrderItem>();
|
||||
var orderGoodsList = await _OrderGoodsRepository.GetListAsync(s => s.OrderGuid == parm.OrderGuid);
|
||||
foreach (var item in orderGoodsList)
|
||||
{
|
||||
var orderItem = new OrderItem();
|
||||
|
||||
var good = await _GoodsRepository.GetFirstAsync(s => s.GoodsGuid == item.GoodsGuid);
|
||||
|
||||
orderItem.SpuId = item.GoodsGuid;
|
||||
orderItem.SkuId = item.GoodsSkuId;
|
||||
orderItem.GoodsName = good.GoodsName;
|
||||
orderItem.GoodsPictureUrl = good.GoodsPicture.Split(',').First();
|
||||
orderItem.BuyQuantity = item.GoodsTotalNum;
|
||||
|
||||
if (item.GoodsSkuId != 0)
|
||||
{
|
||||
orderItem.Specifications = await GetGoodsSpecList(orderItem.SkuId);
|
||||
}
|
||||
|
||||
orderItemList.Add(orderItem);
|
||||
}
|
||||
return orderItemList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 待付款取消订单
|
||||
/// </summary>
|
||||
@ -393,6 +439,7 @@ namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
FreightFee = s.ExpressPrice,
|
||||
CouponAmount = s.CouponMoney,
|
||||
Remark = s.OrderRemark,
|
||||
CreateTime = s.Create_time
|
||||
}).Take(1);
|
||||
|
||||
|
||||
@ -420,9 +467,15 @@ namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
orderItem.GoodsName = good.GoodsName;
|
||||
orderItem.GoodsPictureUrl = good.GoodsPicture.Split(',').First();
|
||||
orderItem.BuyQuantity = item.GoodsTotalNum;
|
||||
orderItem.Price = item.GoodsPrice;
|
||||
|
||||
if (item.GoodsSkuId != 0)
|
||||
{
|
||||
var sku = await _GoodsSkuRepository.GetFirstAsync(s => s.GoodsSkuId == item.GoodsSkuId);
|
||||
if (!string.IsNullOrEmpty(sku.GoodsSkuImg))
|
||||
{
|
||||
orderItem.GoodsPictureUrl = sku.GoodsSkuImg;
|
||||
}
|
||||
orderItem.Specifications = await GetGoodsSpecList(orderItem.SkuId);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace ARW.Service.Api.IBusinessService.OrderManage.OrderRefunds
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrderRefund(OrderRefund parm);
|
||||
Task<long> AddOrderRefund(OrderRefund parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -27,6 +27,21 @@ namespace ARW.Service.Api.IBusinessService.OrderManage.Orders
|
||||
Task<PagedInfo<OrderVoApi>> GetOrderListApi(OrderQueryDtoApi parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取售后订单商品列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<OrderItem>> GetOrderRefundGoodsList(OrderDtoApi parm);
|
||||
|
||||
/// <summary>
|
||||
/// 获取订单详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetOrderDetails(OrderDtoApi parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 待付款取消订单
|
||||
/// </summary>
|
||||
@ -59,14 +74,6 @@ namespace ARW.Service.Api.IBusinessService.OrderManage.Orders
|
||||
Task<string> AddComment(GoodsComment parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取订单详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetOrderDetails(OrderDtoApi parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取订单商品规格
|
||||
/// </summary>
|
||||
@ -74,5 +81,6 @@ namespace ARW.Service.Api.IBusinessService.OrderManage.Orders
|
||||
/// <returns></returns>
|
||||
Task<List<OrderGoodsSpecApiVo>> GetGoodsSpecList(int? skuId);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ namespace ARW.Service.Business.BusinessService.OrderManage.OrderRefunds
|
||||
GoodsReceiveStatus = s.GoodsReceiveStatus,
|
||||
MerchantAuditStatus = s.MerchantAuditStatus,
|
||||
MerchantRefuseDesc = s.MerchantRefuseDesc,
|
||||
RefundMoney = s.RefundMoney,
|
||||
RefundMoney = s.RefundActualMoney,
|
||||
ShopRefundAddressGuid = s.ShopRefundAddressGuid,
|
||||
IsCustomerSend = s.IsCustomerSend,
|
||||
CustomerSendTime = s.CustomerSendTime,
|
||||
@ -196,12 +196,26 @@ namespace ARW.Service.Business.BusinessService.OrderManage.OrderRefunds
|
||||
var str = "审核成功!";
|
||||
// 同意
|
||||
if (parm.IsAgree == true)
|
||||
{
|
||||
var orderRefund = await _OrderRefundRepository.GetFirstAsync(s => s.OrderRefundGuid == parm.OrderRefundGuid);
|
||||
|
||||
if(orderRefund.RefundType == 1)
|
||||
{
|
||||
await _OrderRefundRepository.UpdateAsync(f => new OrderRefund
|
||||
{
|
||||
MerchantAuditStatus = 2,
|
||||
ShopRefundAddressGuid = parm.ShopAddressGuid,
|
||||
}, s => s.OrderRefundGuid == parm.OrderRefundGuid);
|
||||
}
|
||||
if(orderRefund.RefundType == 2)
|
||||
{
|
||||
await _OrderRefundRepository.UpdateAsync(f => new OrderRefund
|
||||
{
|
||||
MerchantAuditStatus = 2,
|
||||
OrderRefundStatus = 3,
|
||||
}, s => s.OrderRefundGuid == parm.OrderRefundGuid);
|
||||
}
|
||||
|
||||
|
||||
str = "同意申请!";
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ namespace ARW.Tasks.TaskScheduler.Business
|
||||
throw new CustomException("订单关闭失败!");
|
||||
else
|
||||
{
|
||||
var respones = _PaymentService.UpdateAsync(f => new Payment
|
||||
var respones = await _PaymentService.UpdateAsync(f => new Payment
|
||||
{
|
||||
PaymentStatus = 3,
|
||||
Update_time = DateTime.Now
|
||||
|
@ -20,6 +20,7 @@ using ARW.Service.Business.IBusinessService.OrderManage.OrderRefunds;
|
||||
using ARW.Admin.WebApi.Framework;
|
||||
using ARW.Service.Business.IBusinessService.LogisticsManage.LogisticsCompanys;
|
||||
using ARW.Service.System.IService;
|
||||
using ARW.Service.Business.IBusinessService.OrderManage.Orders;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Api.OrderManage.OrderRefunds
|
||||
{
|
||||
@ -36,16 +37,18 @@ namespace ARW.WebApi.Controllers.Api.OrderManage.OrderRefunds
|
||||
private readonly IOrderRefundServiceApi _OrderRefundServiceApi;
|
||||
private readonly ILogisticsCompanyService _LogisticsCompanyService;
|
||||
private readonly ISysDictDataService _SysDictDataService;
|
||||
private readonly IOrderService _OrderService;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="OrderRefundServiceApi">售后单记录表售后单记录表Api服务</param>
|
||||
public OrderRefundApiController(IOrderRefundServiceApi OrderRefundServiceApi, ILogisticsCompanyService logisticsCompanyService, ISysDictDataService sysDictDataService)
|
||||
public OrderRefundApiController(IOrderRefundServiceApi OrderRefundServiceApi, ILogisticsCompanyService logisticsCompanyService, ISysDictDataService sysDictDataService, IOrderService orderService)
|
||||
{
|
||||
_OrderRefundServiceApi = OrderRefundServiceApi;
|
||||
_LogisticsCompanyService = logisticsCompanyService;
|
||||
_SysDictDataService = sysDictDataService;
|
||||
_OrderService = orderService;
|
||||
}
|
||||
|
||||
|
||||
@ -126,6 +129,9 @@ namespace ARW.WebApi.Controllers.Api.OrderManage.OrderRefunds
|
||||
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||
parm.CustomerGuid = user.UserId;
|
||||
|
||||
var order = await _OrderService.GetFirstAsync(s => s.OrderGuid == parm.OrderGuid);
|
||||
parm.ShopGuid = order.ShopGuid;
|
||||
|
||||
var modal = parm.Adapt<OrderRefund>().ToCreate(HttpContext);
|
||||
var res = await _OrderRefundServiceApi.AddOrderRefund(modal);
|
||||
return SUCCESS(res);
|
||||
|
@ -63,6 +63,46 @@ namespace ARW.WebApi.Controllers.Api.OrderManage.Orders
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取售后订单商品列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getOrderRefundGoods")]
|
||||
public async Task<IActionResult> GetOrderRefundGoods([FromQuery] OrderDtoApi parm)
|
||||
{
|
||||
var res = await _OrderServiceApi.GetOrderRefundGoodsList(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取Order详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getOrderDetails")]
|
||||
public async Task<IActionResult> GetOrderDetails([FromQuery] OrderDtoApi parm)
|
||||
{
|
||||
if (parm == null) throw new CustomException("参数错误!");
|
||||
|
||||
var res = await _OrderServiceApi.GetOrderDetails(parm);
|
||||
|
||||
if (res != "[]")
|
||||
{
|
||||
var data = res.FromJSON<OrderApiDetailsVo>();
|
||||
return SUCCESS(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 待付款取消订单
|
||||
/// </summary>
|
||||
@ -130,31 +170,6 @@ namespace ARW.WebApi.Controllers.Api.OrderManage.Orders
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取Order详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getOrderDetails")]
|
||||
public async Task<IActionResult> GetOrderDetails([FromQuery] OrderDtoApi parm)
|
||||
{
|
||||
if (parm == null) throw new CustomException("参数错误!");
|
||||
|
||||
var res = await _OrderServiceApi.GetOrderDetails(parm);
|
||||
|
||||
if (res != "[]")
|
||||
{
|
||||
var data = res.FromJSON<OrderApiDetailsVo>();
|
||||
return SUCCESS(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除订单
|
||||
/// </summary>
|
||||
|
@ -18,6 +18,14 @@ using ARW.Admin.WebApi.Framework;
|
||||
using ARW.Service.Business.IBusinessService.OrderManage.Orders;
|
||||
using Geocoding;
|
||||
using ARW.Service.Business.IBusinessService.ShopManager.Shops;
|
||||
using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.GoodsSkus;
|
||||
using ARW.Service.Business.IBusinessService.OrderManage.OrderGoodss;
|
||||
using ARW.Service.Business.IBusinessService.Payments;
|
||||
using Infrastructure.WeChat.TenPay;
|
||||
using System.Net.Http;
|
||||
using ARW.Service.Business.IBusinessService.GoodsManager.Goodss;
|
||||
using Senparc.CO2NET.HttpUtility;
|
||||
using ARW.Model.Models.Business.Payments;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Business.OrderManage.OrderRefunds
|
||||
{
|
||||
@ -33,15 +41,26 @@ namespace ARW.WebApi.Controllers.Business.OrderManage.OrderRefunds
|
||||
{
|
||||
private readonly IOrderRefundService _OrderRefundService;
|
||||
private readonly IShopService _ShopService;
|
||||
|
||||
private readonly IPaymentService _PaymentService;
|
||||
private readonly SenparcHttpClient _httpClient;
|
||||
private readonly IGoodsService _GoodsService;
|
||||
private readonly IGoodsSkuService _GoodsSkuService;
|
||||
private readonly IOrderService _OrderService;
|
||||
private readonly IOrderGoodsService _OrderGoodsService;
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="OrderRefundService">售后单记录表服务</param>
|
||||
public OrderRefundController(IOrderRefundService OrderRefundService, IShopService shopService)
|
||||
public OrderRefundController(IOrderRefundService OrderRefundService, IShopService shopService, IPaymentService paymentService, SenparcHttpClient httpClient, IGoodsService goodsService, IGoodsSkuService goodsSkuService, IOrderService orderService, IOrderGoodsService orderGoodsService)
|
||||
{
|
||||
_OrderRefundService = OrderRefundService;
|
||||
_ShopService = shopService;
|
||||
_PaymentService = paymentService;
|
||||
_httpClient = httpClient;
|
||||
_GoodsService = goodsService;
|
||||
_GoodsSkuService = goodsSkuService;
|
||||
_OrderService = orderService;
|
||||
_OrderGoodsService = orderGoodsService;
|
||||
}
|
||||
|
||||
|
||||
@ -103,6 +122,71 @@ namespace ARW.WebApi.Controllers.Business.OrderManage.OrderRefunds
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
if (parm.IsAgree == true)
|
||||
{
|
||||
var orderRefund = await _OrderRefundService.GetFirstAsync(s => s.OrderRefundGuid == parm.OrderRefundGuid);
|
||||
var order = await _OrderService.GetFirstAsync(s => s.OrderGuid == orderRefund.OrderGuid);
|
||||
var payment = await _PaymentService.GetFirstAsync(s => s.PaymentGuid == order.PaymentGuid);
|
||||
|
||||
if (orderRefund.RefundType == 2)
|
||||
{
|
||||
Pay pay = new Pay(_httpClient);
|
||||
var transactionId = payment.PaymentWeixinNumber;
|
||||
string paymentRefundNumber = "";
|
||||
if (!string.IsNullOrEmpty(payment.PaymentRefundNumber))
|
||||
{
|
||||
paymentRefundNumber = payment.PaymentRefundNumber;
|
||||
}
|
||||
|
||||
var totalFee = payment.PaymentMoney * 100;
|
||||
var canleRes = await pay.Refund(transactionId, totalFee, paymentRefundNumber, "商品退款");
|
||||
if (canleRes.ResultCode.Success == false)
|
||||
throw new CustomException("订单退款失败!");
|
||||
else
|
||||
{
|
||||
await _OrderRefundService.UpdateAsync(f => new OrderRefund
|
||||
{
|
||||
RefundActualMoney = totalFee,
|
||||
}, f => f.OrderRefundGuid == orderRefund.OrderRefundGuid);
|
||||
|
||||
await _PaymentService.UpdateAsync(f => new Payment
|
||||
{
|
||||
PaymentRefundNumber = canleRes.out_refund_no,
|
||||
}, f => f.PaymentNumber == canleRes.out_trade_no);
|
||||
|
||||
var orderGoodsList = await _OrderGoodsService.GetListAsync(s => s.OrderGuid == orderRefund.OrderGuid);
|
||||
// 库存加回来
|
||||
foreach (var orderGood in orderGoodsList)
|
||||
{
|
||||
var goods = await _GoodsService.GetFirstAsync(s => s.GoodsGuid == orderGood.GoodsGuid);
|
||||
var shop = await _ShopService.GetFirstAsync(s => s.ShopGuid == goods.ShopGuid);
|
||||
|
||||
goods.GoodsSalesActual += orderGood.GoodsTotalNum;
|
||||
await _GoodsService.UpdateAsync(goods);
|
||||
shop.ShopSalesOrderCount += orderGood.GoodsTotalNum;
|
||||
await _ShopService.UpdateAsync(shop);
|
||||
|
||||
if (goods.GoodsDeductStockType == 2)
|
||||
{
|
||||
if (orderGood.GoodsSkuId != 0)
|
||||
{
|
||||
var sku = await _GoodsSkuService.GetFirstAsync(s => s.GoodsSkuId == orderGood.GoodsSkuId);
|
||||
sku.GoodsSkuStockNum += orderGood.GoodsTotalNum;
|
||||
goods.GoodsTotalInventory += orderGood.GoodsTotalNum;
|
||||
await _GoodsSkuService.UpdateAsync(sku);
|
||||
await _GoodsService.UpdateAsync(goods);
|
||||
}
|
||||
else
|
||||
{
|
||||
goods.GoodsTotalInventory += orderGood.GoodsTotalNum;
|
||||
await _GoodsService.UpdateAsync(goods);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var res = await _OrderRefundService.AuditOrderRefund(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
@ -119,6 +203,66 @@ namespace ARW.WebApi.Controllers.Business.OrderManage.OrderRefunds
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
var orderRefund = await _OrderRefundService.GetFirstAsync(s => s.OrderRefundGuid == parm.OrderRefundGuid);
|
||||
var order = await _OrderService.GetFirstAsync(s => s.OrderGuid == orderRefund.OrderGuid);
|
||||
var payment = await _PaymentService.GetFirstAsync(s => s.PaymentGuid == order.PaymentGuid);
|
||||
|
||||
Pay pay = new Pay(_httpClient);
|
||||
var transactionId = payment.PaymentWeixinNumber;
|
||||
string paymentRefundNumber = "";
|
||||
if (!string.IsNullOrEmpty(payment.PaymentRefundNumber))
|
||||
{
|
||||
paymentRefundNumber = payment.PaymentRefundNumber;
|
||||
}
|
||||
|
||||
var totalFee = payment.PaymentMoney * 100;
|
||||
var canleRes = await pay.Refund(transactionId, totalFee, paymentRefundNumber, "商品退款");
|
||||
if (canleRes.ResultCode.Success == false)
|
||||
throw new CustomException("订单退款失败!");
|
||||
else
|
||||
{
|
||||
await _OrderRefundService.UpdateAsync(f => new OrderRefund
|
||||
{
|
||||
RefundActualMoney = totalFee,
|
||||
}, f => f.OrderRefundGuid == orderRefund.OrderRefundGuid);
|
||||
|
||||
var respones = await _PaymentService.UpdateAsync(f => new Payment
|
||||
{
|
||||
PaymentRefundNumber = canleRes.out_refund_no,
|
||||
}, f => f.PaymentNumber == canleRes.out_trade_no);
|
||||
|
||||
var orderGoodsList = await _OrderGoodsService.GetListAsync(s => s.OrderGuid == orderRefund.OrderGuid);
|
||||
// 库存加回来
|
||||
foreach (var orderGood in orderGoodsList)
|
||||
{
|
||||
var goods = await _GoodsService.GetFirstAsync(s => s.GoodsGuid == orderGood.GoodsGuid);
|
||||
var shop = await _ShopService.GetFirstAsync(s => s.ShopGuid == goods.ShopGuid);
|
||||
|
||||
goods.GoodsSalesActual += orderGood.GoodsTotalNum;
|
||||
await _GoodsService.UpdateAsync(goods);
|
||||
shop.ShopSalesOrderCount += orderGood.GoodsTotalNum;
|
||||
await _ShopService.UpdateAsync(shop);
|
||||
|
||||
if (goods.GoodsDeductStockType == 2)
|
||||
{
|
||||
if (orderGood.GoodsSkuId != 0)
|
||||
{
|
||||
var sku = await _GoodsSkuService.GetFirstAsync(s => s.GoodsSkuId == orderGood.GoodsSkuId);
|
||||
sku.GoodsSkuStockNum += orderGood.GoodsTotalNum;
|
||||
goods.GoodsTotalInventory += orderGood.GoodsTotalNum;
|
||||
await _GoodsSkuService.UpdateAsync(sku);
|
||||
await _GoodsService.UpdateAsync(goods);
|
||||
}
|
||||
else
|
||||
{
|
||||
goods.GoodsTotalInventory += orderGood.GoodsTotalNum;
|
||||
await _GoodsService.UpdateAsync(goods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var res = await _OrderRefundService.ConfirmsReceipt(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user