Преглед на файлове

Merge branch 'feature-dgy-上传oss图片' into feature-dgy-功能测试

DuGuYang преди 1 година
родител
ревизия
a9f23be3a5

+ 3 - 0
Areas/Api/Controllers/BaseController.cs

@@ -30,6 +30,9 @@ namespace MySystem.Areas.Api.Controllers
         public string SourceHost = Library.ConfigurationManager.AppSettings["SourceHost"].ToString();
         public string SpHost = Library.ConfigurationManager.AppSettings["SpHost"].ToString();
         public string OssHost = Library.ConfigurationManager.AppSettings["OssHost"].ToString();
+        public string OssKey = Library.ConfigurationManager.AppSettings["OSSKey"].ToString();
+        public string OssSecret = Library.ConfigurationManager.AppSettings["OSSSecret"].ToString();
+        public string OssEndpoint = Library.ConfigurationManager.AppSettings["OSSEndpoint"].ToString();
         public string Database = Library.ConfigurationManager.AppSettings["Database"].ToString();
         public string defaultImage = Library.ConfigurationManager.AppSettings["Host"].ToString() + "/skin/app/default/static/images/header.png";
 

+ 48 - 7
Areas/Api/Controllers/PublicMethodController.cs

@@ -1,18 +1,15 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Http;
 using Microsoft.Extensions.Logging;
 using Microsoft.Extensions.Options;
-using System.DrawingCore.Imaging;
-using System.IO;
 using Library;
-using System.Collections;
-using LitJson;
-using System.Globalization;
 using System.Web;
+using System.Security.Cryptography;
+using System.Text;
+using Aliyun.OSS;
+using LitJson;
 
 // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
 
@@ -49,5 +46,49 @@ namespace MySystem.Areas.Api.Controllers
         }
         #endregion
 
+        
+       #region 前端上传oss返回参数
+        public JsonResult OssInfo(string value)
+        {
+            value = DesDecrypt(value);
+            JsonData data = JsonMapper.ToObject(value);
+            string dir = data["dir"].ToString(); //文件上传路径        
+            if (string.IsNullOrEmpty(data["dir"].ToString()))
+            {
+                return Json(new AppResultJson() { Status = "1", Info = "文件上传路径不能为空" });
+            }
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            var OssUrl = OssHost;
+            var AccessKeyId = OssKey;
+            var AccessKeySecret = OssSecret;
+            var endpoint = "https://" + OssEndpoint;
+
+            // 构造OssClient实例。 endpoint 格式:https://oss-cn-beijing.aliyuncs.com
+            var ossClient = new OssClient(endpoint, AccessKeyId, AccessKeySecret);
+            var config = new PolicyConditions();
+            config.AddConditionItem(PolicyConditions.CondContentLengthRange, 1, 1024L * 1024 * 1024 * 5);// 文件大小范围:单位byte
+            config.AddConditionItem(MatchMode.StartWith, PolicyConditions.CondKey, dir);
+            var expire = DateTimeOffset.Now.AddMinutes(30);// 过期时间
+
+            // 生成 Policy,并进行 Base64 编码
+            var policy = ossClient.GeneratePostPolicy(expire.LocalDateTime, config);
+            var policyBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(policy));
+
+            // 计算签名
+            var hmac = new HMACSHA1(Encoding.UTF8.GetBytes(AccessKeySecret));
+            var bytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(policyBase64));
+            var Signature = Convert.ToBase64String(bytes);
+
+            Obj.Add("OssUrl", OssUrl);
+            Obj.Add("AccessKeyId", AccessKeyId);
+            // Obj.Add("AccessKeySecret", AccessKeySecret);
+            Obj.Add("Policy", policyBase64);
+            Obj.Add("Expiration", expire);
+            Obj.Add("Signature", Signature);
+            Obj.Add("dir", dir);
+            return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
+        }
+        #endregion
+
     }
 }

+ 7 - 2
Areas/Api/Controllers/v1/MainServer/ConsumerOrdersController.cs

@@ -224,7 +224,7 @@ namespace MySystem.Areas.Api.Controllers.v1
 
 
         #region 消费者-支付接口
-        // [Authorize]
+        [Authorize]
         public JsonResult Pay(string value)
         {
             if (string.IsNullOrEmpty(value))
@@ -277,6 +277,11 @@ namespace MySystem.Areas.Api.Controllers.v1
             if (pos.OpId == 1)
             {
                 MerchantInfo merchant = MerchantInfoDbconn.Instance.Get(qrcode.MerchantId) ?? new MerchantInfo();
+                //商户未激活也能支付(365服务费)
+                // if (merchant.IsAct == 0)
+                // {
+                //     return Json(new AppResultJson() { Status = "-1", Info = "支付失败,商户尚未激活,请前往来客吧商户版激活后使用" });
+                // }
                 MerchantAddInfo merchantAdd = MerchantAddInfoDbconn.Instance.Get(qrcode.MerchantId) ?? new MerchantAddInfo();
                 MerchantParamSet merchantset = MerchantParamSetDbconn.Instance.Get(qrcode.MerchantId) ?? new MerchantParamSet();
                 string openid = "";
@@ -406,7 +411,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             ConsumerOrders order = maindb.ConsumerOrders.FirstOrDefault(m => m.Id == Id);
             if (order != null)
             {
-                List<ConsumerOrders> suborders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId);
+                List<ConsumerOrders> suborders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, 1, 999999);
                 if (suborders.Count > 0)
                 {
                     ConsumerOrders suborder = suborders.FirstOrDefault(m => m.Id == Id);

+ 5 - 1
Areas/Api/Controllers/v1/MainServer/MerchantParamSetController.cs

@@ -110,6 +110,10 @@ namespace MySystem.Areas.Api.Controllers.v1
             }
             int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
             MerchantInfo merchant = maindb.MerchantInfo.FirstOrDefault(m => m.Id == Id);
+            if (merchant.Id > 0 && merchant.IsAct == 0)
+            {
+                return new AppResultJson() { Status = "-1", Info = "商户尚未激活,不能开启活动配置活动参数" };
+            }
             MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + merchant.Mobile);
             if (mobilecheck == null)
             {
@@ -122,7 +126,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             RedisDbconn.Instance.Clear("MobileCodeCheck:" + merchant.Mobile);
             Dictionary<string, object> Obj = new Dictionary<string, object>();
             MerchantParamSet query = maindb.MerchantParamSet.FirstOrDefault(m => m.Id == Id);
-            if(query == null)
+            if (query == null)
             {
                 query = maindb.MerchantParamSet.Add(new MerchantParamSet()
                 {

+ 5 - 5
appsettings.Development.json

@@ -13,7 +13,7 @@
     "Host2": "http://test.mpap2.kexiaoshuang.com/",
     "SourceHost": "http://test.mpap.kexiaoshuang.com/",
     "SpHost": "http://test.mpsp.kexiaoshuang.com/",
-    "OssHost": "http://oss.qrcodeplate.com",
+    "OssHost": "https://laikeba.oss-cn-chengdu.aliyuncs.com",
     "QrCodeHost": "http://test.mpap.kexiaoshuang.com/",
     "Database": "ApServer",
     "KxsSqlConnStr": "server=47.109.31.237;port=3306;user=KxsMainServer;password=FrW8ZfxlcaVdm1r0;database=KxsMainServer;charset=utf8;",
@@ -25,10 +25,10 @@
     "RedisConnStr": "47.109.31.237:6379,password=klm@redis,DefaultDatabase=5,poolsize=500,preheat=50,asyncPipeline=true",
     "IOSAppVersion": "1.0.0",
     "AndroidAppVersion": "1.0.0",
-    "OSSKey": "",
-    "OSSSecret": "",
-    "OSSEndpoint": "",
-    "OSSBucketName": "",
+    "OSSKey": "LTAI5tJsPaNzqCSMCPwb8zfz",
+    "OSSSecret": "efM31Up75fQcgZ32U6xvAciagceQae",
+    "OSSEndpoint": "oss-cn-chengdu.aliyuncs.com",
+    "OSSBucketName": "laikeba",
     "AppSource": "/skin/app/default/",
     "JwtSecret": "JvDHuowbOnWiyxMIFc9gG5rw1LSSc0xx68L31oRfxS0",
     "JwtIss": "ApServer",