|
@@ -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
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|