优化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);
|
||||
|
||||
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.ContentType = "application/json";
|
||||
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)
|
||||
{
|
||||
@@ -866,24 +866,38 @@ namespace TemuKJD.WXForms.AiTalkForms
|
||||
string body = @"{""id"":""" + appId + @""",""appId"":""" + appId + @""",""name"":""" + shop.ShopAccount +
|
||||
@""",""apiKey"":""" + appSecret + @""",""secret"":""" + appSecret + @""",""token"":""" + appId +
|
||||
@""",""encodingAesKey"":""" + aesKey + @""",""callbackUrl"":""" + callbackUrl + @"""}";
|
||||
string url = AiTalkUrl + "/api/stores";
|
||||
string url = AiTalkUrl + "/api/stores/upsert";
|
||||
string refer = AiTalkUrl + "/workbanch";
|
||||
var cookies = CEFBrowser.GetCookieList("", aiTalkAdminWebBrowser.RequestContext.GetCookieManager(null));
|
||||
var rst = HttpResponseWxAiTalkBLL.PostResponse(new ShopLoginInfo() { Cookies = JsonHelper.SerializeObject(cookies) }, url, body, refer);
|
||||
if (!rst.Contains("\"id\":\"" + appId + "\""))
|
||||
string rst = "";
|
||||
await Task.Run(() =>
|
||||
{
|
||||
rst = HttpResponseWxAiTalkBLL.PostResponse(new ShopLoginInfo() { Cookies = JsonHelper.SerializeObject(cookies) }, url, body, refer);
|
||||
});
|
||||
if (!rst.Contains("\"id\":\"" + appId + "\""))
|
||||
{
|
||||
shopLoginFrom.lblSecret.Text = "接入Ai客服错误!请重试!";
|
||||
return;
|
||||
}
|
||||
|
||||
// 拿到密钥去微信小店开通消息推送
|
||||
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"}
|
||||
body = "{\"url\":\"" + callbackUrl + "\",\"token\":\"" + appId + "\",\"base64Key\":\"" + aesKey + "\"}";
|
||||
rst = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, refer);
|
||||
//{"ret":0,"success":true,"code":0}
|
||||
if (!rst.Contains("\"code\":0"))
|
||||
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"}
|
||||
body = "{\"url\":\"" + callbackUrl + "\",\"token\":\"" + appId + "\",\"base64Key\":\"" + aesKey + "\"}";
|
||||
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);
|
||||
if (shop.LoginStatus != "登录成功")
|
||||
@@ -899,7 +913,7 @@ namespace TemuKJD.WXForms.AiTalkForms
|
||||
shopLoginFrom.lblSecret.Text = "请点击客服设置,接入自研客服,扫码接入(不接入接收不到消息)";
|
||||
shopLoginFrom.btnSaveAppSecret.Text = "我已接入,关闭窗口";
|
||||
|
||||
Task.Run(() =>
|
||||
await Task.Run(() =>
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
BatchBindShop(new List<string> { shop.ShopId });
|
||||
|
||||
Reference in new issue
Block a user