|
@@ -2,15 +2,22 @@ using System.Threading.Tasks;
|
|
|
using GxPress.Common.WechatPay;
|
|
|
using GxPress.Repository.Interface.Order;
|
|
|
using GxPress.Service.Interface.Order;
|
|
|
+using GxPress.Repository.Interface.Media;
|
|
|
+using GxPress.Repository.Interface;
|
|
|
+using System;
|
|
|
|
|
|
namespace GxPress.Service.Implement.Order
|
|
|
{
|
|
|
public class OrderService : IOrderService
|
|
|
{
|
|
|
private readonly IOrderRepository orderRepository;
|
|
|
- public OrderService(IOrderRepository orderRepository)
|
|
|
+ private readonly IMediaRepository mediaRepository;
|
|
|
+ private readonly IUserRepository userRepository;
|
|
|
+ public OrderService(IOrderRepository orderRepository, IMediaRepository mediaRepository, IUserRepository userRepository)
|
|
|
{
|
|
|
this.orderRepository = orderRepository;
|
|
|
+ this.mediaRepository = mediaRepository;
|
|
|
+ this.userRepository = userRepository;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 创建微信订单
|
|
@@ -21,7 +28,28 @@ namespace GxPress.Service.Implement.Order
|
|
|
{
|
|
|
var order = new Entity.Order.Order();
|
|
|
var attach = data.GetValue("attach").ToString();
|
|
|
- return await orderRepository.InsertAsync(order) > 0;
|
|
|
+ if (attach.Split('_').Length > 0)
|
|
|
+ {
|
|
|
+ //获取medio属性
|
|
|
+ var media = await mediaRepository.GetAsync(attach.Split('_')[0]);
|
|
|
+ //获取用户数据
|
|
|
+ var user = await userRepository.GetAsync(int.Parse(attach.Split('_')[1]));
|
|
|
+ order.OutTradeNo = data.GetValue("out_trade_no").ToString();
|
|
|
+ order.OrderType = 1;
|
|
|
+ order.IsRefund = false;
|
|
|
+ order.IsSuccess = true;
|
|
|
+ order.IsVip = user.IsVip;
|
|
|
+ order.MediaId = media.Id;
|
|
|
+ order.Explain=media.Title;
|
|
|
+ order.Name = user.Name;
|
|
|
+ order.OrderNumber = DateTime.Now.Ticks.ToString();
|
|
|
+ order.Price =Decimal.Parse(data.GetValue("total_fee").ToString())/100;
|
|
|
+ order.TransactionId = data.GetValue("transaction_id").ToString();
|
|
|
+ order.UserId = user.Id;
|
|
|
+ order.PayWay = 1;
|
|
|
+ return await orderRepository.InsertAsync(order) > 0;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
}
|