优化AI客服注册店铺
This commit is contained in:
1 parent
652fcd1336
commit
78a59247f8
2 files changed
+28
-13
No files matched your search
@@ -93,6 +93,7 @@ namespace TemuKJD.BLL
|
|||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||||
|
|
||||||
request.KeepAlive = true;
|
request.KeepAlive = true;
|
||||||
|
request.Timeout = 1000 * 45;
|
||||||
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";
|
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";
|
||||||
request.ContentType = "application/json";
|
request.ContentType = "application/json";
|
||||||
request.Accept = "*/*";
|
request.Accept = "*/*";
|
||||||
|
|||||||
@@ -849,7 +849,7 @@ namespace TemuKJD.WXForms.AiTalkForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Lf_SaveComplete(object o_shop, object o_appSecret, object o_wxShopLoginForm)
|
private async void Lf_SaveComplete(object o_shop, object o_appSecret, object o_wxShopLoginForm)
|
||||||
{
|
{
|
||||||
if (o_shop is ShopLoginInfo shop && o_wxShopLoginForm is WXShopLoginForm shopLoginFrom)
|
if (o_shop is ShopLoginInfo shop && o_wxShopLoginForm is WXShopLoginForm shopLoginFrom)
|
||||||
{
|
{
|
||||||
@@ -866,24 +866,38 @@ namespace TemuKJD.WXForms.AiTalkForms
|
|||||||
string body = @"{""id"":""" + appId + @""",""appId"":""" + appId + @""",""name"":""" + shop.ShopAccount +
|
string body = @"{""id"":""" + appId + @""",""appId"":""" + appId + @""",""name"":""" + shop.ShopAccount +
|
||||||
@""",""apiKey"":""" + appSecret + @""",""secret"":""" + appSecret + @""",""token"":""" + appId +
|
@""",""apiKey"":""" + appSecret + @""",""secret"":""" + appSecret + @""",""token"":""" + appId +
|
||||||
@""",""encodingAesKey"":""" + aesKey + @""",""callbackUrl"":""" + callbackUrl + @"""}";
|
@""",""encodingAesKey"":""" + aesKey + @""",""callbackUrl"":""" + callbackUrl + @"""}";
|
||||||
string url = AiTalkUrl + "/api/stores";
|
string url = AiTalkUrl + "/api/stores/upsert";
|
||||||
string refer = AiTalkUrl + "/workbanch";
|
string refer = AiTalkUrl + "/workbanch";
|
||||||
var cookies = CEFBrowser.GetCookieList("", aiTalkAdminWebBrowser.RequestContext.GetCookieManager(null));
|
var cookies = CEFBrowser.GetCookieList("", aiTalkAdminWebBrowser.RequestContext.GetCookieManager(null));
|
||||||
var rst = HttpResponseWxAiTalkBLL.PostResponse(new ShopLoginInfo() { Cookies = JsonHelper.SerializeObject(cookies) }, url, body, refer);
|
string rst = "";
|
||||||
if (!rst.Contains("\"id\":\"" + appId + "\""))
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
rst = HttpResponseWxAiTalkBLL.PostResponse(new ShopLoginInfo() { Cookies = JsonHelper.SerializeObject(cookies) }, url, body, refer);
|
||||||
|
});
|
||||||
|
if (!rst.Contains("\"id\":\"" + appId + "\""))
|
||||||
{
|
{
|
||||||
shopLoginFrom.lblSecret.Text = "接入Ai客服错误!请重试!";
|
shopLoginFrom.lblSecret.Text = "接入Ai客服错误!请重试!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拿到密钥去微信小店开通消息推送
|
await Task.Run(() =>
|
||||||
url = "https://store.weixin.qq.com/shop-faas/mmecnodeservicemarket/channel/ChannelsEcVerifyCallbackInfo?token=&lang=zh_CN";
|
{
|
||||||
refer = "https://store.weixin.qq.com/shop/servicemarket/home";
|
// 拿到密钥去微信小店开通消息推送
|
||||||
//{"url":"http://14.103.99.254/wechat/wx316b1291351558aa/callback","token":"wx316b1291351558aa","base64Key":"PZPtKsJ165j3IE1YOe0mxJLwiq125lES2Lq2xplg3KU"}
|
url = "https://store.weixin.qq.com/shop-faas/mmecnodeservicemarket/channel/ChannelsEcVerifyCallbackInfo?token=&lang=zh_CN";
|
||||||
body = "{\"url\":\"" + callbackUrl + "\",\"token\":\"" + appId + "\",\"base64Key\":\"" + aesKey + "\"}";
|
refer = "https://store.weixin.qq.com/shop/servicemarket/home";
|
||||||
rst = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, refer);
|
//{"url":"http://14.103.99.254/wechat/wx316b1291351558aa/callback","token":"wx316b1291351558aa","base64Key":"PZPtKsJ165j3IE1YOe0mxJLwiq125lES2Lq2xplg3KU"}
|
||||||
//{"ret":0,"success":true,"code":0}
|
body = "{\"url\":\"" + callbackUrl + "\",\"token\":\"" + appId + "\",\"base64Key\":\"" + aesKey + "\"}";
|
||||||
if (!rst.Contains("\"code\":0"))
|
Thread.Sleep(Randomx.GetId(250, 500));
|
||||||
|
rst = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, refer);
|
||||||
|
if (!rst.Contains("\"code\":0"))
|
||||||
|
{
|
||||||
|
Thread.Sleep(Randomx.GetId(500, 1000));
|
||||||
|
rst = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, refer);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//{"ret":0,"success":true,"code":0}
|
||||||
|
if (!rst.Contains("\"code\":0"))
|
||||||
{
|
{
|
||||||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||||||
if (shop.LoginStatus != "登录成功")
|
if (shop.LoginStatus != "登录成功")
|
||||||
@@ -899,7 +913,7 @@ namespace TemuKJD.WXForms.AiTalkForms
|
|||||||
shopLoginFrom.lblSecret.Text = "请点击客服设置,接入自研客服,扫码接入(不接入接收不到消息)";
|
shopLoginFrom.lblSecret.Text = "请点击客服设置,接入自研客服,扫码接入(不接入接收不到消息)";
|
||||||
shopLoginFrom.btnSaveAppSecret.Text = "我已接入,关闭窗口";
|
shopLoginFrom.btnSaveAppSecret.Text = "我已接入,关闭窗口";
|
||||||
|
|
||||||
Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
BatchBindShop(new List<string> { shop.ShopId });
|
BatchBindShop(new List<string> { shop.ShopId });
|
||||||
|
|||||||
Reference in new issue
Block a user