fixed 修改订单相关功能
This commit is contained in:
parent
77d3a673d1
commit
90ad56e15b
44
ARW.Model/Dto/Api/Pay/RepayDtoApi.cs
Normal file
44
ARW.Model/Dto/Api/Pay/RepayDtoApi.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Dto.Api.OrderManage.Orders;
|
||||
using ARW.Model.Models.Business.Carts;
|
||||
|
||||
namespace ARW.Model.Dto.Api.Pay
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 下单信息Dto对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-10-24
|
||||
/// </summary>
|
||||
public class RepayDtoApi
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户Guid
|
||||
/// </summary>
|
||||
public long UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 小程序用户OpenId
|
||||
/// </summary>
|
||||
public string OpenId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 支付类型
|
||||
/// </summary>
|
||||
public int PayType { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 前端传递金额
|
||||
/// </summary>
|
||||
public decimal TotalAmount { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ namespace ARW.Model.Vo.Api.OrderManage.Orders
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 类型 (2撤销 3填写运单号 4修改运单号 5查看物流 )
|
||||
/// 类型 (2撤销 3填写运单号 4修改运单号 5查看物流 7删除订单 )
|
||||
/// </summary>
|
||||
public int Type { get; set; }
|
||||
|
||||
|
@ -102,7 +102,7 @@ namespace ARW.Model.Vo.Api.OrderManage.Orders
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单状态名称 (1待付款 2待发货 3待收货 4已完成)
|
||||
/// 订单状态名称 (1待付款 2待发货 3待收货 4已完成 5已取消)
|
||||
/// </summary>
|
||||
public string StatusName { get; set; }
|
||||
|
||||
|
@ -84,11 +84,11 @@ namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<Order>();
|
||||
|
||||
predicate = predicate.AndIF(parm.CustomerGuid != 0, s => s.CustomerGuid == parm.CustomerGuid);
|
||||
predicate = predicate.AndIF(parm.Status == 1, s => s.PayStatus == 1 && s.OrderStatus == 1);
|
||||
predicate = predicate.AndIF(parm.Status == 2, s => s.DeliveryStatus == 1 && s.PayStatus == 2 && s.OrderStatus == 1);
|
||||
predicate = predicate.AndIF(parm.Status == 3, s => s.ReceiptStatus == 1 && s.DeliveryStatus == 2 && s.PayStatus == 2 && s.OrderStatus == 1);
|
||||
predicate = predicate.AndIF(parm.Status == 4, s => s.PayStatus == 2 && s.OrderStatus == 4);
|
||||
predicate = predicate.AndIF(parm.CustomerGuid != 0, s => s.CustomerGuid == parm.CustomerGuid);
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.OrderNumber), s => s.OrderNumber.Contains(parm.OrderNumber));
|
||||
var query = _OrderRepository
|
||||
.Queryable()
|
||||
@ -138,7 +138,7 @@ namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
|
||||
|
||||
/* 处理订单状态 */
|
||||
if(item.PayStatus == 1 && item.OrderStatus == 1)
|
||||
if (item.PayStatus == 1 && item.OrderStatus == 1)
|
||||
{
|
||||
item.Status = 1;
|
||||
item.StatusName = "待付款";
|
||||
@ -151,13 +151,14 @@ namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
var buttonVo1 = new ButtonVO()
|
||||
{
|
||||
Name = "付款",
|
||||
Primary = true,
|
||||
Type = 1
|
||||
};
|
||||
buttonVoList.Add(buttonVo);
|
||||
buttonVoList.Add(buttonVo1);
|
||||
item.ButtonVOs = buttonVoList;
|
||||
}
|
||||
if(item.DeliveryStatus == 1 && item.PayStatus == 2 && item.OrderStatus == 1)
|
||||
if (item.DeliveryStatus == 1 && item.PayStatus == 2 && item.OrderStatus == 1)
|
||||
{
|
||||
item.Status = 2;
|
||||
item.StatusName = "待发货";
|
||||
@ -170,6 +171,7 @@ namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
var buttonVo1 = new ButtonVO()
|
||||
{
|
||||
Name = "再次购买",
|
||||
Primary = true,
|
||||
Type = 9
|
||||
};
|
||||
buttonVoList.Add(buttonVo);
|
||||
@ -184,6 +186,7 @@ namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
var buttonVo = new ButtonVO()
|
||||
{
|
||||
Name = "确认收货",
|
||||
Primary = true,
|
||||
Type = 3
|
||||
};
|
||||
buttonVoList.Add(buttonVo);
|
||||
@ -193,10 +196,10 @@ namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
{
|
||||
item.Status = 4;
|
||||
item.StatusName = "已完成";
|
||||
|
||||
|
||||
var buttonVoList = new List<ButtonVO>();
|
||||
var refund = await _OrderRefundRepository.GetFirstAsync(s => s.OrderGuid == item.OrderGuid);
|
||||
if(refund != null)
|
||||
if (refund == null)
|
||||
{
|
||||
var buttonVo = new ButtonVO()
|
||||
{
|
||||
@ -205,17 +208,37 @@ namespace ARW.Service.Api.BusinessService.OrderManage.Orders
|
||||
};
|
||||
buttonVoList.Add(buttonVo);
|
||||
}
|
||||
if (item.IsComment == 2)
|
||||
if (item.IsComment == 1)
|
||||
{
|
||||
var buttonVo1 = new ButtonVO()
|
||||
{
|
||||
Name = "评价",
|
||||
Primary = true,
|
||||
Type = 6
|
||||
};
|
||||
buttonVoList.Add(buttonVo1);
|
||||
}
|
||||
item.ButtonVOs = buttonVoList;
|
||||
}
|
||||
if (item.OrderStatus == 2)
|
||||
{
|
||||
item.Status = 5;
|
||||
item.StatusName = "已取消";
|
||||
|
||||
var buttonVoList = new List<ButtonVO>();
|
||||
var buttonVo = new ButtonVO()
|
||||
{
|
||||
Name = "删除订单",
|
||||
Type = 7
|
||||
};
|
||||
buttonVoList.Add(buttonVo);
|
||||
item.ButtonVOs = buttonVoList;
|
||||
}
|
||||
if (item.OrderStatus == 3)
|
||||
{
|
||||
item.Status = 5;
|
||||
item.StatusName = "待取消";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
||||
jsApiUiPackage = payEntity,
|
||||
outTradeNo = orderNo,
|
||||
CreateTime = res.Create_time,
|
||||
OverTime = res.Create_time.AddMinutes(2)
|
||||
OverTime = res.Create_time.AddMinutes(30)
|
||||
};
|
||||
return payRes;
|
||||
|
||||
@ -441,7 +441,7 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
||||
{
|
||||
CustomerGuid = parm.UserId,
|
||||
OrderGuid = orderGuid,
|
||||
EndTime = order.Create_time.AddMinutes(2),
|
||||
EndTime = order.Create_time.AddMinutes(30),
|
||||
PayStatus = 1,
|
||||
CancelStatus = 1,
|
||||
};
|
||||
|
@ -1,23 +1,29 @@
|
||||
using ARW.Common;
|
||||
using Aliyun.OSS;
|
||||
using ARW.Common;
|
||||
using ARW.Model.Models.Business.OrderManage.Orders;
|
||||
using ARW.Model.Models.Business.OrderTasks;
|
||||
using ARW.Model.Models.Business.Payments;
|
||||
using ARW.Model.Models.Business.SubscribeTasks;
|
||||
using ARW.Model.System;
|
||||
using ARW.Service.Business.IBusinessService.Custom.Customers;
|
||||
using ARW.Service.Business.IBusinessService.OrderManage.Orders;
|
||||
using ARW.Service.Business.IBusinessService.OrderTasks;
|
||||
using ARW.Service.Business.IBusinessService.Payments;
|
||||
using ARW.Service.Business.IBusinessService.SubscribeTasks;
|
||||
using ARW.Service.System.IService;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.WeChat.SubScribe;
|
||||
using Infrastructure.WeChat.TenPay;
|
||||
using Quartz;
|
||||
using Senparc.CO2NET.Extensions;
|
||||
using Senparc.CO2NET.HttpUtility;
|
||||
using Senparc.Weixin.Entities.TemplateMessage;
|
||||
using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp.WxAppJson;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using SystemTime = System.SystemTime;
|
||||
|
||||
@ -36,15 +42,19 @@ namespace ARW.Tasks.TaskScheduler.Business
|
||||
private readonly IOrderTaskService _OrderTaskService;
|
||||
private readonly IOrderService _OrderService;
|
||||
private readonly ICustomerService _CustomerService;
|
||||
private readonly IPaymentService _PaymentService;
|
||||
private readonly SenparcHttpClient _httpClient;
|
||||
|
||||
|
||||
public OrderTask_Job(ISysTasksLogService sysTasksLogService, ISysTasksQzService sysTasksQzService, IOrderTaskService orderTaskService, IOrderService orderService, ICustomerService customerService)
|
||||
public OrderTask_Job(ISysTasksLogService sysTasksLogService, ISysTasksQzService sysTasksQzService, IOrderTaskService orderTaskService, IOrderService orderService, ICustomerService customerService, SenparcHttpClient httpClient, IPaymentService paymentService)
|
||||
{
|
||||
SysTasksLogService = sysTasksLogService;
|
||||
SysTasksQzService = sysTasksQzService;
|
||||
_OrderTaskService = orderTaskService;
|
||||
_OrderService = orderService;
|
||||
_CustomerService = customerService;
|
||||
_httpClient = httpClient;
|
||||
_PaymentService = paymentService;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
@ -71,6 +81,23 @@ namespace ARW.Tasks.TaskScheduler.Business
|
||||
if (item.EndTime < DateTime.Now)
|
||||
{
|
||||
//logger.Info("推送结果:" + res);
|
||||
Pay pay = new Pay(_httpClient);
|
||||
|
||||
var customer = await _CustomerService.GetFirstAsync(s => s.CustomerGuid == item.CustomerGuid);
|
||||
var order = await _OrderService.GetFirstAsync(s => s.OrderGuid == item.OrderGuid);
|
||||
var payment = await _PaymentService.GetFirstAsync(s => s.PaymentGuid == order.PaymentGuid);
|
||||
|
||||
var res = await pay.CloseOrder(payment.PaymentNumber);
|
||||
if (res == null)
|
||||
throw new CustomException("订单关闭失败!");
|
||||
else
|
||||
{
|
||||
var respones = _PaymentService.UpdateAsync(f => new Payment
|
||||
{
|
||||
PaymentStatus = 3,
|
||||
Update_time = DateTime.Now
|
||||
}, f => f.PaymentNumber == payment.PaymentNumber);
|
||||
}
|
||||
|
||||
// 修改订单状态
|
||||
await _OrderService.UpdateAsync(f => new Order
|
||||
@ -84,9 +111,6 @@ namespace ARW.Tasks.TaskScheduler.Business
|
||||
CancelStatus = 2
|
||||
}, s => s.OrderGuid == item.OrderGuid);
|
||||
|
||||
var customer = await _CustomerService.GetFirstAsync(s => s.CustomerGuid == item.CustomerGuid);
|
||||
var order = await _OrderService.GetFirstAsync(s => s.OrderGuid == item.OrderGuid);
|
||||
|
||||
taskList.Add("订单号:" + order.OrderNumber + " " + customer.CustomerNickname + "用户的订单已取消");
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ using ARW.Model.Models.Business.GoodsManager.GoodsComments;
|
||||
using ARW.Admin.WebApi.Framework;
|
||||
using ARW.Service.Business.IBusinessService.ShopManager.Shops;
|
||||
using ARW.Model.Vo.Api.GoodsManager.Goodss;
|
||||
using ARW.Service.Business.IBusinessService.OrderManage.Orders;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Api.OrderManage.Orders
|
||||
{
|
||||
@ -153,5 +154,24 @@ namespace ARW.WebApi.Controllers.Api.OrderManage.Orders
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除订单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "business:order:delete")]
|
||||
[Log(Title = "订单删除", BusinessType = BusinessType.DELETE)]
|
||||
public async Task<IActionResult> Delete(string ids)
|
||||
{
|
||||
int[] idsArr = Tools.SpitIntArrary(ids);
|
||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||
|
||||
var response = _OrderServiceApi.Delete(idsArr);
|
||||
|
||||
return SUCCESS("删除成功!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ using ARW.Service.Api.IBusinessService.PayManage;
|
||||
using ARW.Service.Api.BusinessService.PaymentManage;
|
||||
using ARW.Model.Dto.Api.Carts;
|
||||
using ARW.Model.Dto.Api.Pay;
|
||||
using ARW.Repository.Business.Payments;
|
||||
using ARW.Service.Business.IBusinessService.OrderManage.Orders;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
|
||||
{
|
||||
@ -28,14 +30,16 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
|
||||
|
||||
private readonly ICustomerService _CustomerService;
|
||||
private readonly IPayServiceApi _PayServiceApi;
|
||||
private readonly IOrderService _OrderServiceApi;
|
||||
private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
private readonly SenparcHttpClient _httpClient;
|
||||
|
||||
public WxPayController(ICustomerService customerService, SenparcHttpClient httpClient, IPayServiceApi payServiceApi)
|
||||
public WxPayController(ICustomerService customerService, SenparcHttpClient httpClient, IPayServiceApi payServiceApi, IOrderService orderServiceApi)
|
||||
{
|
||||
_CustomerService = customerService;
|
||||
_httpClient = httpClient;
|
||||
_PayServiceApi = payServiceApi;
|
||||
_OrderServiceApi = orderServiceApi;
|
||||
}
|
||||
|
||||
|
||||
@ -60,6 +64,48 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付(取消后重新调起)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("wxRepay")]
|
||||
public async Task<IActionResult> WxRepay([FromBody] RepayDtoApi parm)
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||
parm.UserId = user.UserId;
|
||||
var order = await _OrderServiceApi.GetFirstAsync(s => s.OrderNumber == parm.OrderNo);
|
||||
var payment = await _PayServiceApi.GetFirstAsync(s => s.PaymentGuid == order.PaymentGuid);
|
||||
|
||||
// 获取金额
|
||||
var price = 1;//单位:分
|
||||
//var price = payment.PaymentBeforeMoney;//单位:分
|
||||
|
||||
var orderNo = Common.Common.CreateNoQuery();
|
||||
|
||||
// 调用统一下单(接口)
|
||||
Pay pay = new Pay(_httpClient);
|
||||
var payEntity = await pay.PrePay(parm.OpenId, payment.PaymentNumber, parm.PayType, price);
|
||||
|
||||
if (payEntity == null)
|
||||
{
|
||||
throw new CustomException("下单失败!");
|
||||
}
|
||||
// 返回拼接好的支付调起信息
|
||||
PayParams payRes = new()
|
||||
{
|
||||
jsApiUiPackage = payEntity,
|
||||
outTradeNo = orderNo,
|
||||
CreateTime = payment.Create_time,
|
||||
};
|
||||
|
||||
return SUCCESS(payRes);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付回调
|
||||
/// </summary>
|
||||
@ -159,7 +205,7 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
|
||||
throw new CustomException("订单退款失败!");
|
||||
else
|
||||
{
|
||||
var respones = _PayServiceApi.UpdateAsync(f => new Payment
|
||||
var respones = await _PayServiceApi.UpdateAsync(f => new Payment
|
||||
{
|
||||
PaymentRefundNumber = res.out_refund_no,
|
||||
}, f => f.PaymentNumber == res.out_trade_no);
|
||||
|
@ -27,6 +27,11 @@ using System.Net.Http;
|
||||
using Senparc.CO2NET.HttpUtility;
|
||||
using ARW.Service.Business.IBusinessService.Payments;
|
||||
using ARW.Model.Models.Business.Payments;
|
||||
using ARW.Repository.Business.GoodsManager.Goodss;
|
||||
using ARW.Repository.Business.GoodsManager.GoodsSpecs.GoodsSkus;
|
||||
using ARW.Repository.Business.ShopManager.Shops;
|
||||
using ARW.Service.Business.IBusinessService.GoodsManager.Goodss;
|
||||
using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.GoodsSkus;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Business.OrderManage.Orders
|
||||
{
|
||||
@ -46,12 +51,15 @@ namespace ARW.WebApi.Controllers.Business.OrderManage.Orders
|
||||
private readonly IOrderCustomerAddressService _OrderCustomerAddressService;
|
||||
private readonly IPaymentService _PaymentService;
|
||||
private readonly SenparcHttpClient _httpClient;
|
||||
private readonly IGoodsService _GoodsService;
|
||||
private readonly IGoodsSkuService _GoodsSkuService;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="OrderService">订单服务</param>
|
||||
public OrderController(IOrderService OrderService, IOrderGoodsService orderGoodsService, IOrderCustomerAddressService orderCustomerAddressService, IShopService shopService, SenparcHttpClient httpClient, IPaymentService paymentService)
|
||||
public OrderController(IOrderService OrderService, IOrderGoodsService orderGoodsService, IOrderCustomerAddressService orderCustomerAddressService, IShopService shopService, SenparcHttpClient httpClient, IPaymentService paymentService, IGoodsService goodsService, IGoodsSkuService goodsSkuService)
|
||||
{
|
||||
_OrderService = OrderService;
|
||||
_OrderGoodsService = orderGoodsService;
|
||||
@ -59,6 +67,8 @@ namespace ARW.WebApi.Controllers.Business.OrderManage.Orders
|
||||
_ShopService = shopService;
|
||||
_httpClient = httpClient;
|
||||
_PaymentService = paymentService;
|
||||
_GoodsService = goodsService;
|
||||
_GoodsSkuService = goodsSkuService;
|
||||
}
|
||||
|
||||
|
||||
@ -170,10 +180,41 @@ namespace ARW.WebApi.Controllers.Business.OrderManage.Orders
|
||||
throw new CustomException("订单退款失败!");
|
||||
else
|
||||
{
|
||||
var respones = _PaymentService.UpdateAsync(f => new Payment
|
||||
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 == parm.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user