Commit 34b584e8 authored by 黄奎's avatar 黄奎
parents 63654d6c 61769241
...@@ -291,5 +291,34 @@ namespace Mall.Common.Pay.WeChatPat ...@@ -291,5 +291,34 @@ namespace Mall.Common.Pay.WeChatPat
} }
return wx; return wx;
} }
/// <summary>
/// 验证微信签名
/// * 将token、timestamp、nonce三个参数进行字典序排序
/// * 将三个参数字符串拼接成一个字符串进行sha1加密
/// * 开发者获得加密后的字符串可与signature对比,标识该请求来源于微信。
/// </summary>
/// <param name="signature"></param>
/// <param name="timestamp"></param>
/// <param name="nonce"></param>
/// <param name="_token"></param>
/// <returns></returns>
[Obsolete]
public static bool CheckSignature(string signature, string timestamp, string nonce, string _token)
{
return false;
//var vs = new[] { timestamp, nonce, _token }.OrderBy(s => s);
//var str = string.Join("", vs);
//var tmpStr = FormsAuthentication.HashPasswordForStoringInConfigFile(str, "SHA1");
//tmpStr = tmpStr.ToLower();
//Plugin.LogHelper.Write("tmpStr:" + tmpStr + ",_token:" + _token);
//if (tmpStr == null)
//{
// return false;
//}
//return tmpStr.Equals(signature, StringComparison.CurrentCultureIgnoreCase);
}
} }
} }
...@@ -892,21 +892,22 @@ namespace Mall.Module.TradePavilion ...@@ -892,21 +892,22 @@ namespace Mall.Module.TradePavilion
//审核通过了的 直接查询资料表 //审核通过了的 直接查询资料表
var blist = buildingRepository.GetBuildingRepository(new RB_Building_Extend() { TenantId = model.TenantId, MallBaseId = model.MallBaseId, UserId = userId }); var blist = buildingRepository.GetBuildingRepository(new RB_Building_Extend() { TenantId = model.TenantId, MallBaseId = model.MallBaseId, UserId = userId });
model.buildingApplyForModel = blist.FirstOrDefault().RefMapperTo<RB_BuildingApplyFor_Extend>(); model.buildingApplyForModel = blist.FirstOrDefault().RefMapperTo<RB_BuildingApplyFor_Extend>();
if (model.EnterpriseServicesModel != null) model.buildingApplyForModel.ID = blist.FirstOrDefault().BuildId;
if (model.buildingApplyForModel != null)
{ {
if (!string.IsNullOrWhiteSpace(model.EnterpriseServicesModel.Banner)) if (!string.IsNullOrWhiteSpace(model.buildingApplyForModel.Banner))
{ {
model.EnterpriseServicesModel.BannerList = JsonConvert.DeserializeObject<List<string>>(model.EnterpriseServicesModel.Banner); model.buildingApplyForModel.BannerList = JsonConvert.DeserializeObject<List<string>>(model.buildingApplyForModel.Banner);
} }
else else
{ {
model.EnterpriseServicesModel.BannerList = new List<string>(); model.buildingApplyForModel.BannerList = new List<string>();
} }
} }
else else
{ {
model.EnterpriseServicesModel = new RB_EnterpriseServicesApply_Extend model.buildingApplyForModel = new RB_BuildingApplyFor_Extend
{ {
BannerList = new List<string>(), BannerList = new List<string>(),
}; };
......
...@@ -539,10 +539,13 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -539,10 +539,13 @@ namespace Mall.WebApi.Controllers.AppletWeChat
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[HttpGet] [HttpGet]
public void EventMessageCall(int MallBaseId, int TenantId, string signature, string echostr, string timestamp, string nonce, string openid, string encrypt_type, string msg_signature) public string EventMessageCall(int MallBaseId, int TenantId, string signature, string echostr, string timestamp, string nonce, string openid, string encrypt_type, string msg_signature)
{ {
LogHelper.WriteInfo("我进来了参数如下[MallBaseId:" + MallBaseId+ ",TenantId:"+ TenantId + ",TenantId:" + signature + ",signature:" + signature + ",echostr:" + echostr + ",timestamp:" + timestamp + ",nonce:" + nonce + ",openid:" + openid + ",encrypt_type:" + encrypt_type + ",msg_signature:" + msg_signature);
var req = new RequestHandler();
try try
{ {
int qrCodeType = 0; int qrCodeType = 0;
int userId = 0; int userId = 0;
string textpl = ""; string textpl = "";
...@@ -551,35 +554,42 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -551,35 +554,42 @@ namespace Mall.WebApi.Controllers.AppletWeChat
string sAppID = "wxaeb077c07ed6f30d"; string sAppID = "wxaeb077c07ed6f30d";
string sEncodingAESKey = "9FgR0wMXxe6wXBB5hwgpn2mZM6sQMi3E3Vk5sxrXEAL"; string sEncodingAESKey = "9FgR0wMXxe6wXBB5hwgpn2mZM6sQMi3E3Vk5sxrXEAL";
var request = _accessor.HttpContext.Request; var request = _accessor.HttpContext.Request;
LogHelper.Write("我是回调方法:EventMessageCall" + "请求方式:" + request.Method);
if (request.Method == "GET")
{
//WXBizMsgCrypt.CheckSignature(signature, timestamp, nonce, sToken);
}
// var inputStream = request.Body; // var inputStream = request.Body;
var str = new StreamReader(request.Body); var str = new StreamReader(request.Body);
string postStr = str.ReadToEnd(); string postStr = str.ReadToEnd();
LogHelper.Write("我是返回信息:" + postStr); LogHelper.Write("我是返回信息:" + postStr);
lock (_lock) lock (_lock)
{ {
WechatMessage wx = WXBizMsgCrypt.GetWxMessage(postStr, timestamp, nonce, signature, encrypt_type, msg_signature, openid); if (!string.IsNullOrWhiteSpace(postStr))
if (!string.IsNullOrWhiteSpace(wx.EventKey))// 用户未关注时,进行关注后的事件推送;事件KEY值,qrscene_为前缀,后面为二维码的参数值
{ {
textpl = ReceivedText(wx.FromUserName, wx.ToUserName, content); WechatMessage wx = WXBizMsgCrypt.GetWxMessage(postStr, timestamp, nonce, signature, encrypt_type, msg_signature, openid);
if (encrypt_type.ToLower() == "aes".ToLower())//加密模式需要先解密 if (!string.IsNullOrWhiteSpace(wx.MsgType))// 用户未关注时,进行关注后的事件推送;事件KEY值,qrscene_为前缀,后面为二维码的参数值
{ {
var ret = new WXBizMsgCrypt(sToken, sEncodingAESKey, sAppID); textpl = ReceivedText(wx.FromUserName, wx.ToUserName, content);
int r = ret.EncryptMsg(textpl, timestamp, nonce, ref textpl); if (encrypt_type.ToLower() == "aes".ToLower())//加密模式需要先解密
if (r != 0)
{ {
LogHelper.WriteInfo("GetWxMessage_消息加密失败:"); var ret = new WXBizMsgCrypt(sToken, sEncodingAESKey, sAppID);
textpl = ""; int r = ret.EncryptMsg(textpl, timestamp, nonce, ref textpl);
if (r != 0)
{
LogHelper.WriteInfo("GetWxMessage_消息加密失败:");
textpl = "";
}
} }
} }
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
LogHelper.Write(ex.ToString()); LogHelper.Write(ex.ToString());
} }
return echostr ?? "echostr is null";
} }
/// <summary> /// <summary>
......
...@@ -3483,7 +3483,9 @@ namespace Mall.WebApi.Controllers.TradePavilion ...@@ -3483,7 +3483,9 @@ namespace Mall.WebApi.Controllers.TradePavilion
{ {
var userInfo = AppletUserInfo; var userInfo = AppletUserInfo;
RB_Building_Extend query = JsonConvert.DeserializeObject<RB_Building_Extend>(RequestParm.msg.ToString()); RB_Building_Extend query = JsonConvert.DeserializeObject<RB_Building_Extend>(RequestParm.msg.ToString());
JObject parms = JObject.Parse(RequestParm.msg.ToString());
int ID = parms.GetInt("ID");
query.BuildId = ID;
if (query.BuildId <= 0) if (query.BuildId <= 0)
{ {
return ApiResult.ParamIsNull("请传递楼宇id"); return ApiResult.ParamIsNull("请传递楼宇id");
......
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