DuGuYang 1 год назад
Родитель
Сommit
e074ec73d3

+ 8 - 4
Areas/Api/Controllers/Main/ConsumerOrdersController.cs

@@ -53,10 +53,10 @@ namespace MySystem.Areas.Api.Controllers.v1
             {
                 return Json(new AppResultJson() { Status = "-1", Info = "请填写正确的支付金额" });
             }
-            if(SnNo.Length > 20)
+            if (SnNo.Length > 20)
             {
                 // SnNo = System.Web.HttpUtility.UrlDecode(SnNo);
-                if(!SnNo.EndsWith("="))
+                if (!SnNo.EndsWith("="))
                 {
                     SnNo += "=";
                 }
@@ -64,7 +64,7 @@ namespace MySystem.Areas.Api.Controllers.v1
                 SnNo = SnNo.TrimEnd('\0');
                 SnNo = SnNo.Substring(0, 20);
             }
-            if(!string.IsNullOrEmpty(Machine))
+            if (!string.IsNullOrEmpty(Machine))
             {
                 if (Machine.Length > 20)
                 {
@@ -79,7 +79,7 @@ namespace MySystem.Areas.Api.Controllers.v1
                 }
             }
             int MerchantId = 0;
-            if(Machine == SnNo)
+            if (Machine == SnNo)
             {
                 var qrcode = MerchantQrCodeService.Query(" SnNo='" + SnNo + "'");
                 MerchantId = qrcode.MerchantId;
@@ -94,6 +94,10 @@ namespace MySystem.Areas.Api.Controllers.v1
             var merchantset = MerchantParamSetService.Query(MerchantId);
             var ledgerModel = merchantset.IsAll == 1 ? "1" : "5";
             string openid = "";
+            if (merchant.IsAct == 0)
+            {
+                return Json(new AppResultJson() { Status = "-1", Info = "支付失败,商户尚未激活,请前往来客吧商户版激活后使用" });
+            }
             if (PayMode == 1)
             {
                 openid = new AlipayFunction(_accessor.HttpContext).GetAlipayUserId(Code);

+ 85 - 0
Areas/Api/Controllers/Main/MerchantDepositBackController.cs

@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using Microsoft.AspNetCore.Authorization;
+using System.Web;
+using MySystem.Models.Main;
+using LitJson;
+using Library;
+using System.Data;
+using MySystem.Service.Main;
+
+/// <summary>
+/// 商户服务费退还
+/// </summary>
+namespace MySystem.Areas.Api.Controllers.v1
+{
+    [Area("Api")]
+    [Route("Api/v1/[controller]/[action]")]
+    public class MerchantDepositBackController : BaseController
+    {
+        public MerchantDepositBackController(IHttpContextAccessor accessor) : base(accessor)
+        {
+        }
+
+        #region 商户激活—商户服务费退还
+        [Authorize]
+        public JsonResult AddMerchantDepositBack(string value)
+        {
+            value = DesDecrypt(value);
+            JsonData data = JsonMapper.ToObject(value);
+            AppResultJson result = AddMerchantDepositBackDo(value);
+            return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
+        }
+        private AppResultJson AddMerchantDepositBackDo(string value)
+        {
+            JsonData data = JsonMapper.ToObject(value);
+            int MerchantId = int.Parse(function.CheckInt(data.getItem("MerchantId").ToString())); //商户Id
+            int ReturnWay = int.Parse(function.CheckInt(data.getItem("ReturnWay").ToString())); //退还方式
+            string MobileCode = data["MobileCode"].ToString(); //短信验证码
+            string ReturnNo = data["ReturnNo"].ToString(); //退还账号
+            if (string.IsNullOrEmpty(data["MerchantId"].ToString()))
+            {
+                return new AppResultJson() { Status = "-1", Info = "请填写商户Id" };
+            }
+            if (!function.IsInt(data["MerchantId"].ToString()))
+            {
+                return new AppResultJson() { Status = "-1", Info = "请填写正确的商户Id" };
+            }
+            if (string.IsNullOrEmpty(data["ReturnWay"].ToString()))
+            {
+                return new AppResultJson() { Status = "-1", Info = "请填写退还方式" };
+            }
+            if (!function.IsInt(data["ReturnWay"].ToString()))
+            {
+                return new AppResultJson() { Status = "-1", Info = "请填写正确的退还方式" };
+            }
+            MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:手机号");
+            if (mobilecheck == null)
+            {
+                return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
+            }
+            if (mobilecheck.CheckCode != MobileCode)
+            {
+                return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
+            }
+            RedisDbconn.Instance.Clear("MobileCodeCheck:手机号");
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            MerchantDepositBack query = new MerchantDepositBack();
+            Dictionary<string, object> fields = new Dictionary<string, object>();
+            fields.Add("CreateDate", DateTime.Now); //创建时间
+            fields.Add("UpdateDate", DateTime.Now); //修改时间
+            fields.Add("MerchantId", MerchantId); //商户Id
+            fields.Add("ReturnWay", ReturnWay); //退还方式
+            // AppResultJson resultJson = MerchantDepositBackService.Add(fields);
+
+            return new AppResultJson() { Status = "1", Info = "", Data = Obj };
+        }
+        #endregion
+
+    }
+}

+ 105 - 0
Areas/Api/Controllers/Main/MerchantDepositOrderController.cs

@@ -0,0 +1,105 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using Microsoft.AspNetCore.Authorization;
+using System.Web;
+using MySystem.Models.Main;
+using LitJson;
+using Library;
+using System.Data;
+using MySystem.Service.Main;
+
+namespace MySystem.Areas.Api.Controllers.v1
+{
+    [Area("Api")]
+    [Route("Api/v1/[controller]/[action]")]
+    public class MerchantDepositOrderController : BaseController
+    {
+        public MerchantDepositOrderController(IHttpContextAccessor accessor) : base(accessor)
+        {
+        }
+
+        #region 商户激活-确认支付
+        // [Authorize]
+        public JsonResult Pay(string value)
+        {
+            value = DesDecrypt(value);
+            JsonData data = JsonMapper.ToObject(value);
+            AppResultJson result = PayDo(value);
+            return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
+        }
+        public AppResultJson PayDo(string value)
+        {
+            JsonData data = JsonMapper.ToObject(value);
+            int PayMode = int.Parse(function.CheckInt(data["PayMode"].ToString())); //支付方式(1 支付宝)
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString()));
+            int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
+            Orders query = db.Orders.FirstOrDefault(m => m.Id == Id);
+            if (query != null)
+            {
+                query.PayMode = PayMode; //支付方式
+                kxsdb.SaveChanges();
+                string PayData = "";
+                PublicAccountSet set = new AlipayFunctionForKxs(_accessor.HttpContext).SetData(MerchantId);
+                if (PayMode == 1)
+                {
+                    string TotalPrice = query.TotalPrice.ToString();
+                    function.WriteLog(query.OrderNo, "支付宝支付日志");
+                    function.WriteLog(TotalPrice.ToString(), "支付宝支付日志");
+                    function.WriteLog("商户激活—确认订单", "支付宝支付日志");
+                    string ProductName = "商户激活—确认订单";
+                    PayData = new Alipay.AlipayPublicClass(_accessor.HttpContext).GetAlipayInfo(query.OrderNo, TotalPrice, ProductName, set.AlipayAppId, set.AlipayPrivateKey, SpHost + "/Api/Alipay/NoticePay");
+                    function.WriteLog(PayData, "支付宝支付日志");
+                }
+                Obj.Add("PayData", PayData); //支付宝微信SDK所需数据
+            }
+            return new AppResultJson() { Status = "1", Info = "", Data = Obj };
+        }
+        #endregion
+
+
+        #region 商户激活—确认订单
+        // [Authorize]
+        public JsonResult ConfirmOrder(string value)
+        {
+            value = DesDecrypt(value);
+            JsonData data = JsonMapper.ToObject(value);
+            AppResultJson result = ConfirmOrderDo(value);
+            return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
+        }
+        public AppResultJson ConfirmOrderDo(string value)
+        {
+            function.WriteLog(value, "商户激活—确认订单");
+            JsonData data = JsonMapper.ToObject(value);
+            int MerchantId = int.Parse(function.CheckInt(data["MerchantId"].ToString())); //商户Id
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            string OrderNo = "SHJH" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
+            string check = RedisDbconn.Instance.Get<string>("ConfirmOrder:" + MerchantId + "_" + OrderNo);
+            if (!string.IsNullOrEmpty(check))
+            {
+                return new AppResultJson() { Status = "-1", Info = "请勿重复下单!" };
+            }
+            RedisDbconn.Instance.Set("ConfirmOrder:" + MerchantId + "_" + OrderNo, "1");
+            RedisDbconn.Instance.SetExpire("ConfirmOrder:" + MerchantId + "_" + OrderNo, 60);
+            decimal ActPayPrice = 365; //服务费总额
+            // MerchantActOrders query = maindb.MerchantActOrders.Add(new MerchantActOrders()
+            // {
+            //     OrderNo = OrderNo,
+            //     UserId = UserId, //创客
+            //     MerchantId = MerchantId, //商户Id
+            //     ActPayPrice = ActPayPrice, //服务费总额
+            // }).Entity;
+            // maindb.SaveChanges();
+            // Obj.Add("Id", query.Id); //Id
+            // Obj.Add("CreateDate", query.CreateDate); //创建时间
+            return new AppResultJson() { Status = "1", Info = "", Data = Obj };
+        }
+        #endregion
+
+    }
+}

+ 4 - 4
Areas/Api/Controllers/Main/MerchantInfoController.cs

@@ -47,10 +47,10 @@ namespace MySystem.Areas.Api.Controllers.v1
             condition.Condition("Sort", 1);
             if (Status > 0)
             {
-                if (Status == 1) Status = 0;
-                if (Status == 2) Status = -1;
-                if (Status == 3) Status = 1;
-                if (Status == 4) Status = 2;
+                if (Status == 1) Status = 0; // 审核中
+                if (Status == 2) Status = -1; // 审核失败
+                if (Status == 3) Status = 1; // 待签约
+                if (Status == 4) Status = 2; // 已签约
                 condition.Condition("Status", Status);
             }
             if (!string.IsNullOrEmpty(SearchKey))

+ 1 - 1
Areas/Api/Controllers/Main/PayController.cs

@@ -53,7 +53,7 @@ namespace MySystem.Areas.Api.Controllers.v1.pos
                     function.WriteLog(TotalPrice.ToString(), "支付宝支付日志");
                     function.WriteLog("商户激活—确认订单", "支付宝支付日志");
                     string ProductName = "商户激活—确认订单";
-                    PayData = new Alipay.AlipayPublicClass(_accessor.HttpContext).GetAlipayInfo(query.OrderNo, TotalPrice, ProductName, set.AlipayAppId, set.AlipayPrivateKey, SourceHost + "/Api/Alipay/NoticePay");
+                    PayData = new Alipay.AlipayPublicClass(_accessor.HttpContext).GetAlipayInfo(query.OrderNo, TotalPrice, ProductName, set.AlipayAppId, set.AlipayPrivateKey, SpHost + "/Api/Alipay/NoticePay");
                     function.WriteLog(PayData, "支付宝支付日志");
                 }
                 Obj.Add("PayData", PayData); //支付宝微信SDK所需数据