更新bug和增加部分api
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
<link href="~/lib/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
|
<link href="~/lib/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
|
||||||
<link href="~/hplus/css/style.css" rel="stylesheet" />
|
<link href="~/hplus/css/style.css" rel="stylesheet" />
|
||||||
<link href="~/hplus/css/font-awesome.min.css" rel="stylesheet" />
|
<link href="~/hplus/css/font-awesome.min.css" rel="stylesheet" />
|
||||||
|
<link href="~/hplus/css/animate.css" rel="stylesheet" />
|
||||||
<script>if (window.top !== window.self) { window.top.location = window.location; }</script>
|
<script>if (window.top !== window.self) { window.top.location = window.location; }</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@
|
|||||||
<span class="text-muted text-xs block">超级管理员<b class="caret"></b></span>
|
<span class="text-muted text-xs block">超级管理员<b class="caret"></b></span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu animated fadeInRight m-t-xs">
|
<ul class="dropdown-menu animated fadeIn m-t-xs">
|
||||||
@*<li>
|
@*<li>
|
||||||
<a class="J_menuItem" href="/Admin/User/ChangeAvata">修改头像</a>
|
<a class="J_menuItem" href="/Admin/User/ChangeAvata">修改头像</a>
|
||||||
</li>*@
|
</li>*@
|
||||||
@@ -390,7 +391,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 全局js -->
|
<!-- 全局js -->
|
||||||
|
|
||||||
<script src="~/js/jquery2.min.js"></script>
|
<script src="~/js/jquery2.min.js"></script>
|
||||||
|
<script src="~/lib/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||||
<script src="~/js/layer/layer.js"></script>
|
<script src="~/js/layer/layer.js"></script>
|
||||||
<script src="~/js/rtpost.js"></script>
|
<script src="~/js/rtpost.js"></script>
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
namespace COMCMS.Web.Controllers.api
|
namespace COMCMS.Web.Controllers.api
|
||||||
{
|
{
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
public class APIBaseController : Controller
|
public class APIBaseController : Controller
|
||||||
{
|
{
|
||||||
#region 通用信息
|
#region 通用信息
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using XCode;
|
|||||||
|
|
||||||
namespace COMCMS.Web.Controllers.api
|
namespace COMCMS.Web.Controllers.api
|
||||||
{
|
{
|
||||||
[Route("api/[controller]/[action]")]
|
|
||||||
public class IndexController : APIBaseController
|
public class IndexController : APIBaseController
|
||||||
{
|
{
|
||||||
// GET: api/<controller>
|
// GET: api/<controller>
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ namespace COMCMS.Web.Controllers.api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 支付API
|
/// 支付API
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Produces("application/json")]
|
|
||||||
[Route("api/Payment")]
|
|
||||||
public class PaymentController : APIBaseController
|
public class PaymentController : APIBaseController
|
||||||
{
|
{
|
||||||
#region 微信小程序订单支付
|
#region 微信小程序订单支付
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using COMCMS.Common;
|
||||||
|
using COMCMS.Core;
|
||||||
|
using COMCMS.Core.Models;
|
||||||
|
using XCode;
|
||||||
|
|
||||||
|
namespace COMCMS.Web.Controllers.api
|
||||||
|
{
|
||||||
|
public class UserController : APIBaseController
|
||||||
|
{
|
||||||
|
#region 用户登录
|
||||||
|
[HttpGet]
|
||||||
|
public object Test()
|
||||||
|
{
|
||||||
|
return "abc";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using COMCMS.Core;
|
||||||
|
using COMCMS.Common;
|
||||||
|
using XCode;
|
||||||
|
using NewLife.Log;
|
||||||
|
using Senparc.Weixin.Exceptions;
|
||||||
|
using Senparc.Weixin;
|
||||||
|
using Senparc.Weixin.MP;
|
||||||
|
using Senparc.Weixin.MP.TenPayLibV3;
|
||||||
|
using System.Collections;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace COMCMS.Web.Controllers
|
||||||
|
{
|
||||||
|
public class wxpaymentController : HomeController
|
||||||
|
{
|
||||||
|
#region 微信支付异步通知
|
||||||
|
/// <summary>
|
||||||
|
/// 微信支付异步通知
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IActionResult notify()
|
||||||
|
{
|
||||||
|
XTrace.WriteLine("微信支付异步通知开始:");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
ResponseHandler resHandler = new ResponseHandler(null);
|
||||||
|
|
||||||
|
string return_code = resHandler.GetParameter("return_code");
|
||||||
|
string return_msg = resHandler.GetParameter("return_msg");
|
||||||
|
|
||||||
|
//配置
|
||||||
|
Core.Config cfg = Core.Config.GetSystemConfig();
|
||||||
|
string appId = cfg.WXAppId;// ConfigurationManager.AppSettings["WeixinAppId"];
|
||||||
|
string appSecrect = cfg.WXAppSecret;// ConfigurationManager.AppSettings["WeixinAppSecrect"];
|
||||||
|
string wxmchId = cfg.MCHId;// ConfigurationManager.AppSettings["WeixinMCHId"];
|
||||||
|
string wxmchKey = cfg.MCHKey;// ConfigurationManager.AppSettings["WeixinMCHKey"];
|
||||||
|
|
||||||
|
TenPayV3Info TenPayV3Info = new TenPayV3Info(appId, appSecrect, wxmchId, wxmchKey, Utils.GetServerUrl() + "/wxpayment/notify");
|
||||||
|
|
||||||
|
string res = null;
|
||||||
|
|
||||||
|
resHandler.SetKey(TenPayV3Info.Key);
|
||||||
|
//验证请求是否从微信发过来(安全)
|
||||||
|
if (resHandler.IsTenpaySign() && return_code.ToUpper() == "SUCCESS")
|
||||||
|
{
|
||||||
|
res = "success";//正确的订单处理
|
||||||
|
//直到这里,才能认为交易真正成功了,可以进行数据库操作,但是别忘了返回规定格式的消息!
|
||||||
|
string out_trade_no = resHandler.GetParameter("out_trade_no");//商户订单号
|
||||||
|
XTrace.WriteLine("微信异步通知订单号:" + out_trade_no + ";" + JsonConvert.SerializeObject(resHandler));
|
||||||
|
|
||||||
|
OnlinePayOrder payOrder = OnlinePayOrder.Find(OnlinePayOrder._.PayOrderNum == out_trade_no);
|
||||||
|
if (payOrder == null)
|
||||||
|
{
|
||||||
|
XTrace.WriteLine($"支付成功,但是支付订单不存在:{out_trade_no}");
|
||||||
|
res = "wrong";//错误的订单处理
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (payOrder.PaymentStatus == Utils.PaymentState[0])
|
||||||
|
{
|
||||||
|
//更新支付订单
|
||||||
|
payOrder.PaymentStatus = Utils.PaymentState[1];
|
||||||
|
payOrder.ReceiveTime = DateTime.Now;
|
||||||
|
payOrder.IsOK = 1;
|
||||||
|
payOrder.Update();
|
||||||
|
|
||||||
|
//获取订单
|
||||||
|
Order order = Order.Find(Order._.OrderNum == payOrder.OrderNum);
|
||||||
|
if (order != null)
|
||||||
|
{
|
||||||
|
order.PaymentStatus = Utils.PaymentState[1];
|
||||||
|
order.PayType = "微信支付";
|
||||||
|
if (order.MyType == (int)Utils.MyType.分销商认证)
|
||||||
|
{
|
||||||
|
order.OrderStatus = Utils.OrdersState[2];
|
||||||
|
}
|
||||||
|
order.Update();
|
||||||
|
//如果是属于升级会员的,那要修改会员状态
|
||||||
|
if (order.MyType == (int)Utils.MyType.分销商认证 && order.OrderType > 0)
|
||||||
|
{
|
||||||
|
Member he = Member.FindById(order.UId);
|
||||||
|
if (he.RoleId != order.OrderType)
|
||||||
|
{
|
||||||
|
he.RoleId = order.OrderType;
|
||||||
|
he.IsVerifySellers = 1;
|
||||||
|
he.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//写入订单记录
|
||||||
|
OrderLog log = new OrderLog();
|
||||||
|
log.AddTime = DateTime.Now;
|
||||||
|
log.OrderId = order.Id;
|
||||||
|
log.OrderNum = order.OrderNum;
|
||||||
|
log.UId = order.UId;
|
||||||
|
log.Actions = "微信支付成功;订单号:" + order.OrderNum + ";金额:" + order.TotalPay.ToString("N2");
|
||||||
|
log.Insert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res = "wrong";//错误的订单处理
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 记录日志
|
||||||
|
XTrace.WriteLine($"微信支付回调处理结果:{res}");
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
string xml = string.Format(@"<xml>
|
||||||
|
<return_code><![CDATA[{0}]]></return_code>
|
||||||
|
<return_msg><![CDATA[{1}]]></return_msg>
|
||||||
|
</xml>", return_code, return_msg);
|
||||||
|
return Content(xml, "text/xml");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
new WeixinException(ex.Message, ex);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
+483
-329
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user