Commit 5c76ce9f authored by 黄奎's avatar 黄奎

页面修改

parent 1ce7fb4d
......@@ -91,6 +91,4 @@ namespace Mall.Common.Pay.WeChatPat
return data;
}
}
}
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Common.Plugin
{
/// <summary>
/// 推送客服消息
/// </summary>
public class WeChatMessageHelper
{
/// <summary>
/// 发送客服消息
/// </summary>
/// <param name="access_token">token</param>
/// <param name="touser">用户openId</param>
/// <param name="msgtype">消息类型。text表示文本消息;image表示图片消息;link表示图文链接;miniprogrampage表示小程序卡片。</param>
/// <param name="obj"></param>
public static bool SendCustomerMessage(string access_token, string touser, string targetUrl,out string message)
{
message = "";
bool flag = false;
string responseStr = "";
try
{
if (string.IsNullOrEmpty(access_token))
{
flag = false;
return flag;
}
//请求路径
string url = string.Format("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}", access_token);
var postData = new
{
touser = touser,
msgtype = "text",
text = new
{
content = "您有一个新订单未支付,请点击链接地址进行支付 " + targetUrl
},
//link = new
//{
// title = "您有一个新订单代支付",
// description = "请打开浏览器支付",
// url = targetUrl,
// thumb_url = "",
//}
};
string param = JsonHelper.Serialize(postData);
responseStr = Common.Plugin.HttpHelper.HttpPost(url, param, contenttype: "");
if (responseStr != null && !string.IsNullOrEmpty(responseStr))
{
JObject jobj = JObject.Parse(responseStr);
int errcode = jobj.GetInt("errcode");
if (errcode == 0)
{
flag = true;
}
else
{
message = jobj.GetStringValue("errmsg");
}
}
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "SendCustomerMessage:result=" + responseStr);
}
return flag;
}
}
}
......@@ -190,7 +190,7 @@ namespace Mall.Common.Plugin
}
/// <summary>
/// 获取用信息帮助类
/// 获取用信息帮助类
/// </summary>
public class GetUsersHelper
{
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using AdapayCore;
using AdapaySDK;
using Mall.CacheManager.AppletWeChat;
using Mall.Common.API;
using Mall.Common.Plugin;
using Mall.Model.Extend.Product;
......@@ -28,6 +29,8 @@ namespace Mall.WebApi.Controllers.Adapay
private readonly UserCommonModule userCommonModule = new UserCommonModule();
private readonly RB_Trade_ConfigRepository trade_ConfigRepository = new RB_Trade_ConfigRepository();
private readonly MiniProgramModule miniProgramModule = new MiniProgramModule();
/// <summary>
/// 获取支付信息
/// </summary>
......@@ -94,6 +97,34 @@ namespace Mall.WebApi.Controllers.Adapay
}
}
/// <summary>
/// 发送客服消息
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SendMessage()
{
var jobj = JObject.Parse(base.RequestParm.msg.ToString());
int MallBaseId = 17;
string toUser = "";
string targetUrl = "";
toUser = "oyiQo5Gu34eaCeIAu8NG2NzM4ZIo";
targetUrl = "https://qr.alipay.com/bax00835y0gx4mzmeycd0020";
//toUser = base.AppletUserInfo.OpenId;
//targetUrl = jobj.GetStringValue("targetUrl");
string postUrl = string.Format("http://jj.kookaku.com/pages/pay/transition?aliuri={0}", targetUrl);
var miniProgram = miniProgramModule.GetMiniProgramModule(new Model.Extend.User.RB_MiniProgram_Extend() { MallBaseId = MallBaseId });
string token = WeiXinReidsCache.Get(miniProgram.MiniAppId);
if (string.IsNullOrEmpty(token))
{
token = Mall.Common.Pay.WeChatPat.TokenHelper.GetLXYToken(token, miniProgram.MiniAppId, miniProgram.MiniAppSecret);
System.Threading.Tasks.Task.Run(() => WeiXinReidsCache.Set(miniProgram.MiniAppId, token));
}
bool flag = Common.Plugin.WeChatMessageHelper.SendCustomerMessage(token, toUser, targetUrl,out string message);
return flag ? ApiResult.Success() : ApiResult.Failed(message: message);
}
/// <summary>
/// 初始化
/// </summary>
......
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