李昊 il y a 4 ans
Parent
commit
2a6d261264

+ 13 - 6
gx_api/GxPress/Api/GxPress.Api/WebControllers/AlipayController.cs

@@ -11,6 +11,13 @@ namespace GxPress.Api.WebControllers
     [Authorize]
     public class AlipayController : Controller
     {
+        [HttpGet()]
+        [AllowAnonymous]
+        public string GetNativePayUrl()
+        {
+            var alipay = new PcPay();
+            return alipay.PayRequest("637263608658642540", "汪峰讲故事", "1", "汪峰讲故事");
+        }
         /// <summary>
         /// 回调地址
         /// </summary>
@@ -18,12 +25,12 @@ namespace GxPress.Api.WebControllers
         [AllowAnonymous]
         public void Callback()
         {
-           /* 实际验证过程建议商户添加以下校验。
-            1、商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号,
-            2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
-            3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email)
-            4、验证app_id是否为该商户本身。
-            */
+            /* 实际验证过程建议商户添加以下校验。
+             1、商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号,
+             2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
+             3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email)
+             4、验证app_id是否为该商户本身。
+             */
             Dictionary<string, string> sArray = GetRequestGet();
             if (sArray.Count != 0)
             {

+ 26 - 14
gx_api/GxPress/Api/GxPress.Api/WebControllers/WxpayController.cs

@@ -1,4 +1,5 @@
 using GxPress.Common.WechatPay;
+using GxPress.Service.Interface.Order;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
@@ -14,16 +15,18 @@ namespace GxPress.Api.WebControllers
     {
         private IHttpContextAccessor _contextAccessor;
         private HttpContext _context { get { return _contextAccessor.HttpContext; } }
-        public WxpayController(IHttpContextAccessor contextAccessor)
+        private IOrderService orderService;
+        public WxpayController(IHttpContextAccessor contextAccessor, IOrderService orderService)
         {
             _contextAccessor = contextAccessor;
+            this.orderService = orderService;
         }
         [HttpGet()]
         [AllowAnonymous]
         public string GetNativePayUrl()
         {
             var nativePay = new NativePay();
-            return nativePay.GetPayUrl("637263608658642540","汪峰讲故事",7);
+            return nativePay.GetPayUrl("637263608658642540", "汪峰讲故事", 7);
         }
         /// <summary>
         /// 回调地址
@@ -38,30 +41,39 @@ namespace GxPress.Api.WebControllers
             if (!notifyData.IsSet("transaction_id"))
             {
                 //若transaction_id不存在,则立即返回结果给微信支付后台
-                WxPayData res = new WxPayData();
-                res.SetValue("return_code", "FAIL");
-                res.SetValue("return_msg", "支付结果中微信订单号不存在");
-                return (res.ToXml());
+                notifyData = new WxPayData();
+                notifyData.SetValue("return_code", "FAIL");
+                notifyData.SetValue("return_msg", "支付结果中微信订单号不存在");
+                return (notifyData.ToXml());
             }
             string transaction_id = notifyData.GetValue("transaction_id").ToString();
             //查询订单,判断订单真实性
             if (!Common.WechatPay.WxPayApi.QueryOrder(transaction_id))
             {
                 //若订单查询失败,则立即返回结果给微信支付后台
-                WxPayData res = new WxPayData();
-                res.SetValue("return_code", "FAIL");
-                res.SetValue("return_msg", "订单查询失败");
-                return (res.ToXml());
+                notifyData = new WxPayData();
+                notifyData.SetValue("return_code", "FAIL");
+                notifyData.SetValue("return_msg", "订单查询失败");
+                return (notifyData.ToXml());
             }
             //查询订单成功
             else
             {
-                WxPayData res = new WxPayData();
-                res.SetValue("return_code", "SUCCESS");
-                res.SetValue("return_msg", "OK");
-                return (res.ToXml());
+                notifyData = new WxPayData();
+                //创建订单
+                if (await orderService.InsertWxOrderAsync(notifyData))
+                {
+                    notifyData.SetValue("return_code", "SUCCESS");
+                    notifyData.SetValue("return_msg", "OK");
+                    return (notifyData.ToXml());
+                }
             }
+            notifyData = new WxPayData();
+            notifyData.SetValue("return_code", "FAIL");
+            notifyData.SetValue("return_msg", "支付结果中微信订单号不存在");
+            return (notifyData.ToXml());
         }
+
         private async Task<WxPayData> GetNotifyData()
         {
             var body = string.Empty;

+ 1 - 1
gx_api/GxPress/Infrastructure/GxPress.Common/AliPay/PcPay.cs

@@ -29,7 +29,7 @@ namespace GxPress.Common.AliPay
 
             AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
             // 设置同步回调地址
-            request.SetReturnUrl("http://localhost:5000/Pay/Callback");
+            request.SetReturnUrl("http://payzzz.top/api/web/alipay/notify");
             // 设置异步通知接收地址
             request.SetNotifyUrl("");
             // 将业务model载入到request

+ 12 - 0
gx_api/GxPress/Model/GxPress.Entity/Order/Order.cs

@@ -15,6 +15,18 @@ namespace GxPress.Entity.Order
         [DataColumn]
         public string OrderNumber { get; set; }
         /// <summary>
+        /// 流水号
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public string TransactionId { get; set; }
+        /// <summary>
+        /// 商户订单号
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public string OutTradeNo { get; set; }
+        /// <summary>
         /// 用户ID
         /// </summary>
         /// <value></value>

+ 1 - 1
gx_api/GxPress/Model/GxPress.Entity/SystemLabel/SystemLabel.cs

@@ -15,7 +15,7 @@ namespace GxPress.Entity.SystemLabel
         [DataColumn]
         public string LabelName { get; set; }
 
-         /// <summary>
+        /// <summary>
         /// 标签名称描述
         /// </summary>
         /// <value></value>

+ 20 - 8
gx_api/GxPress/Model/GxPress.Result/Navigation/NavigationResult.cs

@@ -18,6 +18,18 @@ namespace GxPress.Result.Navigation
         /// </summary>
         /// <value></value>
         public string LabelName { get; set; }
+        /// <summary>
+        /// 标签名称描述
+        /// </summary>
+        /// <value></value>
+
+        public string LabelNameDescribe { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        /// <value></value>
+
+        public string Remark { get; set; }
 
         /// <summary>
         /// 排序
@@ -84,44 +96,44 @@ namespace GxPress.Result.Navigation
         /// 导航名称
         /// </summary>
         /// <value></value>
-        
+
         public string Name { get; set; }
         /// <summary>
         /// 是否禁用
         /// </summary>
         /// <value></value>
-        
+
         public bool IsDisable { get; set; }
         /// <summary>
         /// 父级ID
         /// </summary>
         /// <value></value>
-        
+
         public int ParentId { get; set; }
 
         /// <summary>
         /// 排序
         /// </summary>
         /// <value></value>
-        
+
         public int Sort { get; set; }
         /// <summary>
         /// 中间件页面ID
         /// </summary>
         /// <value></value>
-        
+
         public int MiddleLableId { get; set; }
         /// <summary>
         /// 是否可以操作
         /// </summary>
         /// <value></value>
-        
+
         public bool Isoperate { get; set; }
         /// <summary>
         /// 终端 1 pc 2 移动端
         /// </summary>
         /// <value></value>
-        
+
         public int Terminal { get; set; }
         /// <summary>
         /// 是否存在子集
@@ -133,7 +145,7 @@ namespace GxPress.Result.Navigation
         /// </summary>
         /// <value></value>
         public List<NavigationResult> Children { get; set; }
-         /// <summary>
+        /// <summary>
         /// 路径
         /// </summary>
         /// <value></value>

+ 3 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/Navigation/NavigationRepository.cs

@@ -170,7 +170,9 @@ namespace GxPress.Repository.Implement.Navigation
                         IsPage = item.IsPage,
                         IsSkip = item.IsSkip,
                         LabelName = item.LabelName,
-                        ResourceType = item.ResourceType
+                        ResourceType = item.ResourceType,
+                        LabelNameDescribe = item.LabelNameDescribe,
+                        Remark = item.Remark
                     };
                     //获取媒体标签
                     var mediaLables = await _mediaLableRepository.GetAllAsync(Q.Where(nameof(Entity.tede2.Media.MediaLable.LableId), item.Id));

+ 9 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/Order/OrderRepository.cs

@@ -105,5 +105,14 @@ namespace GxPress.Repository.Implement.Order
             result.VipAllOrderCount = await connection.ExecuteScalarAsync<int>(sql);
             return result;
         }
+        /// <summary>
+        /// 添加
+        /// </summary>
+        /// <param name="order"></param>
+        /// <returns></returns>
+        public async Task<int> InsertAsync(Entity.Order.Order order)
+        {
+            return await _repository.InsertAsync(order);
+        }
     }
 }

+ 6 - 0
gx_api/GxPress/Repository/GxPress.Repository.Interface/Order/IOrderRepository.cs

@@ -20,5 +20,11 @@ namespace GxPress.Repository.Interface.Order
         /// <param name="request"></param>
         /// <returns></returns>
         Task<OrderFinanceResult<Entity.Order.Order>> GetAllOrderFinnceAsync(OrderFinanceSearchRequest request);
+         /// <summary>
+        /// 添加
+        /// </summary>
+        /// <param name="order"></param>
+        /// <returns></returns>
+        Task<int> InsertAsync(Entity.Order.Order order);
     }
 }

+ 27 - 0
gx_api/GxPress/Service/GxPress.Service.Implement/Order/OrderService.cs

@@ -0,0 +1,27 @@
+using System.Threading.Tasks;
+using GxPress.Common.WechatPay;
+using GxPress.Repository.Interface.Order;
+using GxPress.Service.Interface.Order;
+
+namespace GxPress.Service.Implement.Order
+{
+    public class OrderService : IOrderService
+    {
+        private readonly IOrderRepository orderRepository;
+        public OrderService(IOrderRepository orderRepository)
+        {
+            this.orderRepository = orderRepository;
+        }
+        /// <summary>
+        /// 创建微信订单
+        /// </summary>
+        /// <param name="data"></param>
+        /// <returns></returns>
+        public async Task<bool> InsertWxOrderAsync(WxPayData data)
+        {
+            var order = new Entity.Order.Order();
+            var attach = data.GetValue("attach").ToString();
+            return await orderRepository.InsertAsync(order) > 0;
+        }
+    }
+}

+ 15 - 0
gx_api/GxPress/Service/GxPress.Service.Interface/Order/IOrderService.cs

@@ -0,0 +1,15 @@
+using System.Threading.Tasks;
+using GxPress.Common.WechatPay;
+
+namespace GxPress.Service.Interface.Order
+{
+    public interface IOrderService : IService
+    {
+        /// <summary>
+        /// 创建微信订单
+        /// </summary>
+        /// <param name="data"></param>
+        /// <returns></returns>
+        Task<bool> InsertWxOrderAsync(WxPayData data);
+    }
+}