李昊 4 年之前
父节点
当前提交
20980223a0

+ 21 - 3
gx_api/GxPress/Api/GxPress.Api/WebControllers/WxpayController.cs

@@ -1,8 +1,10 @@
 using GxPress.Common.WechatPay;
+using GxPress.Repository.Interface.Order;
 using GxPress.Service.Interface.Order;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using System;
 using System.IO;
 using System.Threading.Tasks;
 
@@ -15,18 +17,21 @@ namespace GxPress.Api.WebControllers
     {
         private IHttpContextAccessor _contextAccessor;
         private HttpContext _context { get { return _contextAccessor.HttpContext; } }
+
+        private readonly IOrderRepository orderRepository;
         private IOrderService orderService;
-        public WxpayController(IHttpContextAccessor contextAccessor, IOrderService orderService)
+        public WxpayController(IHttpContextAccessor contextAccessor, IOrderService orderService, IOrderRepository orderRepository)
         {
             _contextAccessor = contextAccessor;
             this.orderService = orderService;
+            this.orderRepository = orderRepository;
         }
         [HttpGet()]
         [AllowAnonymous]
         public string GetNativePayUrl()
         {
             var nativePay = new NativePay();
-            return nativePay.GetPayUrl("637263608658642540", "汪峰讲故事", 7);
+            return nativePay.GetPayUrl("637263608658642540", "汪峰讲故事", 7, 1);
         }
         /// <summary>
         /// 回调地址
@@ -73,7 +78,20 @@ namespace GxPress.Api.WebControllers
             notifyData.SetValue("return_msg", "支付结果中微信订单号不存在");
             return (notifyData.ToXml());
         }
-
+        /// <summary>
+        /// 退款
+        /// </summary>
+        /// <param name="orderNumber"></param>
+        /// <returns></returns>
+        [HttpGet("{orderNumber}")]
+        [AllowAnonymous]
+        public async Task<string> Refund(string orderNumber)
+        {
+            var order = await orderRepository.GetOrderAsync(orderNumber);
+            var nativePay = new NativePay();
+            var price = Convert.ToInt32((order.Price) * 100).ToString();
+            return nativePay.Refund(order.TransactionId, order.OutTradeNo, price, price);
+        }
         private async Task<WxPayData> GetNotifyData()
         {
             var body = string.Empty;

+ 2 - 2
gx_api/GxPress/Infrastructure/GxPress.Common/WechatPay/NativePay.cs

@@ -9,7 +9,7 @@ namespace GxPress.Common.WechatPay
       * @param productId 商品ID
       * @return 模式二URL
       */
-        public string GetPayUrl(string productId,string productInfo,int userId)
+        public string GetPayUrl(string productId,string productInfo,int userId,int total_fee)
         {
             //Log.Info(this.GetType().ToString(), "Native pay mode 2 url is producing...");
             try
@@ -18,7 +18,7 @@ namespace GxPress.Common.WechatPay
                 data.SetValue("body", productInfo);//商品描述
                 data.SetValue("attach", $"{productId}_{userId}");//附加数据
                 data.SetValue("out_trade_no", WxPayApi.GenerateOutTradeNo());//随机字符串
-                data.SetValue("total_fee", 1);//总金额
+                data.SetValue("total_fee", total_fee);//总金额
                 data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));//交易起始时间
                 data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));//交易结束时间
                 data.SetValue("goods_tag", "jjj");//商品标记

+ 18 - 0
gx_api/GxPress/Model/GxPress.Entity/Navigations/MiddleLable.cs

@@ -32,5 +32,23 @@ namespace GxPress.Entity.Navigations
         /// <value></value>
         [DataColumn]
         public bool IsDisable { get; set; }
+        /// <summary>
+        /// 是否开启搜索
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public bool IsSearch { get; set; }
+        /// <summary>
+        /// 是否开启轮播
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public bool IsSlide { get; set; }
+        /// <summary>
+        /// 1 APP 2 首页频道  3首页精选
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int TypeId { get; set; }
     }
 }

+ 2 - 1
gx_api/GxPress/Model/GxPress.Entity/tede2/Media/MediaLable.cs

@@ -13,7 +13,7 @@ namespace GxPress.Entity.tede2.Media
         /// </summary>
         /// <value></value>
         [DataColumn]
-        public int MediaId { get; set; } 
+        public int MediaId { get; set; }
 
         /// <summary>
         /// 标签ID
@@ -27,5 +27,6 @@ namespace GxPress.Entity.tede2.Media
         /// <value></value>
         [DataColumn]
         public string LableName { get; set; }
+        
     }
 }

+ 5 - 0
gx_api/GxPress/Model/GxPress.Result/Navigation/NavigationResult.cs

@@ -81,6 +81,11 @@ namespace GxPress.Result.Navigation
         /// </summary>
         /// <value></value>
         public List<MediaResult> MediaResults { get; set; }
+        // /// <summary>
+        // /// 获取轮播
+        // /// </summary>
+        // /// <value></value>
+        // public List<Entity.Slide> Sildes{get;set;}
     }
     /// <summary>
     /// 导航数据的显示

+ 5 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/Navigation/NavigationRepository.cs

@@ -156,6 +156,11 @@ namespace GxPress.Repository.Implement.Navigation
                 var middleLable = await _middleLableRepository.GetAsync(navigation.MiddleLableId);
                 if (string.IsNullOrEmpty(middleLable.LabelId))
                     return result;
+                //获取轮播
+                if (middleLable.IsSlide)
+                {
+                    //result
+                }
                 //获取标签
                 var systemLabels = await _systemLabelRepository.GetAllAsync(Q.WhereIn(nameof(Entity.SystemLabel.SystemLabel.Id), StringUtils.StringCollectionToIntList(middleLable.LabelId)));
                 foreach (var item in systemLabels)

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

@@ -114,5 +114,14 @@ namespace GxPress.Repository.Implement.Order
         {
             return await _repository.InsertAsync(order);
         }
+        /// <summary>
+        ///获取订单
+        /// </summary>
+        /// <param name="orderNumber"></param>
+        /// <returns></returns>
+        public async Task<Entity.Order.Order> GetOrderAsync(string orderNumber)
+        {
+            return await _repository.GetAsync(Q.Where(nameof(Entity.Order.Order.OrderNumber), orderNumber));
+        }
     }
 }

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

@@ -26,5 +26,11 @@ namespace GxPress.Repository.Interface.Order
         /// <param name="order"></param>
         /// <returns></returns>
         Task<int> InsertAsync(Entity.Order.Order order);
+          /// <summary>
+        ///获取订单
+        /// </summary>
+        /// <param name="orderNumber"></param>
+        /// <returns></returns>
+        Task<Entity.Order.Order> GetOrderAsync(string orderNumber);
     }
 }