Commit 16fc4a6c authored by 吴春's avatar 吴春

1

parent 2804b713
......@@ -11,16 +11,13 @@ namespace Mall.WeChat.Common
/// </summary>
public class WechatMessage
{
/// <summary>
/// 本公众帐号
/// </summary>
public string ToUserName { get; set; }
/// <summary>
/// appid
/// </summary>
public string Appid { get; set; }
public string AppId { get; set; }
/// <summary>
/// Token
......@@ -31,6 +28,11 @@ namespace Mall.WeChat.Common
/// EncodingAESKey
/// </summary>
public string EncodingAESKey { get; set; }
/// <summary>
/// 本公众帐号
/// </summary>
public string ToUserName { get; set; }
/// <summary>
/// 用户帐号
/// </summary>
......@@ -52,16 +54,24 @@ namespace Mall.WeChat.Common
/// </summary>
public string EventName { get; set; }
/// <summary>
/// 这两个属性会在后面的讲解中提到
/// 消息id
/// </summary>
public string Ticket { get; set; }
public string MsgId { get; set; }
/// <summary>
/// 事件KEY值,qrscene_为前缀,后面为二维码的参数值
/// 消息标题
/// </summary>
public string EventKey { get; set; }
public string Title { get; set; }
/// <summary>
/// 消息url地址
/// </summary>
public string PagePath { get; set; }
}
}
......@@ -21,7 +21,7 @@ using Org.BouncyCastle.Crypto.Generators;
//-40010 : base64解密异常
namespace Mall.Common.Pay.WeChatPat
{
public class WXBizMsgCrypt
public class WXBizMsgCrypt
{
string m_sToken;
string m_sEncodingAESKey;
......@@ -42,9 +42,9 @@ namespace Mall.Common.Pay.WeChatPat
};
//构造函数
// @param sToken: 公众平台上,开发者设置的Token
// @param sEncodingAESKey: 公众平台上,开发者设置的EncodingAESKey
// @param sAppID: 公众帐号的appid
// @param sToken: 公众平台上,开发者设置的Token
// @param sEncodingAESKey: 公众平台上,开发者设置的EncodingAESKey
// @param sAppID: 公众帐号的appid
public WXBizMsgCrypt(string sToken, string sEncodingAESKey, string sAppID)
{
m_sToken = sToken;
......@@ -62,10 +62,10 @@ namespace Mall.Common.Pay.WeChatPat
// @return: 成功0,失败返回对应的错误码
public int DecryptMsg(string sMsgSignature, string sTimeStamp, string sNonce, string sPostData, ref string sMsg)
{
if (m_sEncodingAESKey.Length!=43)
{
return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_IllegalAesKey;
}
if (m_sEncodingAESKey.Length != 43)
{
return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_IllegalAesKey;
}
XmlDocument doc = new XmlDocument();
XmlNode root;
string sEncryptMsg;
......@@ -112,10 +112,10 @@ namespace Mall.Common.Pay.WeChatPat
// return:成功0,失败返回对应的错误码
public int EncryptMsg(string sReplyMsg, string sTimeStamp, string sNonce, ref string sEncryptMsg)
{
if (m_sEncodingAESKey.Length!=43)
{
return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_IllegalAesKey;
}
if (m_sEncodingAESKey.Length != 43)
{
return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_IllegalAesKey;
}
string raw = "";
try
{
......@@ -187,7 +187,7 @@ namespace Mall.Common.Pay.WeChatPat
}
}
public static int GenarateSinature(string sToken, string sTimeStamp, string sNonce, string sMsgEncrypt ,ref string sMsgSignature)
public static int GenarateSinature(string sToken, string sTimeStamp, string sNonce, string sMsgEncrypt, ref string sMsgSignature)
{
ArrayList AL = new ArrayList();
AL.Add(sToken);
......@@ -245,7 +245,7 @@ namespace Mall.Common.Pay.WeChatPat
int r = ret.DecryptMsg(msg_signature, timestamp, nonce, postStr, ref postStr);
if (r != 0)
{
Plugin.LogHelper.WriteInfo("GetWxMessage_消息解密失败:");
Plugin.LogHelper.WriteInfo("GetWxMessage_消息解密失败111:");
return wx;
}
}
......@@ -255,39 +255,23 @@ namespace Mall.Common.Pay.WeChatPat
wx.ToUserName = xml.SelectSingleNode("xml").SelectSingleNode("ToUserName").InnerText;
wx.FromUserName = xml.SelectSingleNode("xml").SelectSingleNode("FromUserName").InnerText;
wx.MsgType = xml.SelectSingleNode("xml").SelectSingleNode("MsgType").InnerText;
if (wx.MsgType.Trim() == "text")
{
wx.Content = xml.SelectSingleNode("xml").SelectSingleNode("Content").InnerText;
}
if (wx.MsgType.Trim() == "event")
else if (wx.MsgType.Trim() == "miniprogrampage")
{
wx.EventName = xml.SelectSingleNode("xml").SelectSingleNode("Event").InnerText;
try
{
wx.EventKey = xml.SelectSingleNode("xml").SelectSingleNode("EventKey").InnerText;
Plugin.LogHelper.Write("wx.EventKey:" + wx.EventKey.Trim());
}
catch (Exception ex)
{
Plugin.LogHelper.Write( ex);
wx.EventKey = "";
}
try
{
wx.Ticket = xml.SelectSingleNode("xml").SelectSingleNode("Ticket")?.InnerText ?? "";
Plugin.LogHelper.Write("wx.Ticket:" + wx.Ticket.Trim());
}
catch (Exception ex)
{
Plugin.LogHelper.Write(ex);
wx.Ticket = "";
}
wx.MsgId = xml.SelectSingleNode("xml").SelectSingleNode("MsgId").InnerText;
//wx.Title = xml.SelectSingleNode("xml").SelectSingleNode("Title").InnerText;
wx.AppId = xml.SelectSingleNode("xml").SelectSingleNode("AppId").InnerText;
wx.PagePath = xml.SelectSingleNode("xml").SelectSingleNode("PagePath").InnerText;
}
}
}
catch (Exception ex)
{
Plugin.LogHelper.Write(ex);
Plugin.LogHelper.Write(ex, "我是解析方法GetWxMessage:");
}
return wx;
}
......@@ -307,7 +291,7 @@ namespace Mall.Common.Pay.WeChatPat
[Obsolete]
public static bool CheckSignature(string signature, string timestamp, string nonce, string _token)
{
return false;
return false;
//var vs = new[] { timestamp, nonce, _token }.OrderBy(s => s);
//var str = string.Join("", vs);
//var tmpStr = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "SHA1");
......
......@@ -11,6 +11,7 @@ using Mall.Common;
using Mall.Common.API;
using Mall.Common.Plugin;
using Mall.Module.User;
using Mall.Repository.TradePavilion;
namespace Mall.Module.Education
{
......@@ -35,6 +36,8 @@ namespace Mall.Module.Education
private readonly RB_Education_TeacherRepository education_TeacherRepository = new RB_Education_TeacherRepository();
#region 用户基本信息
public Model.Entity.User.RB_Member_User GetUserEntity(int UserId)
......@@ -1120,5 +1123,8 @@ namespace Mall.Module.Education
}
#endregion
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment