微信自动回复功能
This commit is contained in:
1 parent
ccde645d98
commit
dc83334c59
12 files changed
+1126
-153
No files matched your search
@@ -27,13 +27,21 @@ using TemuKJD.Helper;
|
||||
using TemuKJD.ToolForms;
|
||||
using TemuKJD.WXForms.ShopForms;
|
||||
using TemuKJD.WXForms.TalkForms.TalkHelper;
|
||||
using TemuKJD.WXForms.TalkForms.TalkModel;
|
||||
|
||||
namespace TemuKJD.WXForms.TalkForms
|
||||
{
|
||||
public partial class WxTalkForm : BaseTalkForm
|
||||
{
|
||||
public static List<KeyValuePair<string, string>> LstTalkTemplatePair { get; set; } = null;
|
||||
|
||||
public ConcurrentList<WxShopKfStatistics> lstShopKfStatistics = new ConcurrentList<WxShopKfStatistics>();
|
||||
public ConcurrentList<WxShopAfterSaleInfo> lstShopAfterSale = new ConcurrentList<WxShopAfterSaleInfo>();
|
||||
public ConcurrentList<WxTalkFormShopMainInfo> lstShopAfterSale = new ConcurrentList<WxTalkFormShopMainInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 等待自动回复的消息队列
|
||||
/// </summary>
|
||||
public ConcurrentList<AutoReplayParam> lstAutoReplayParam = new ConcurrentList<AutoReplayParam>();
|
||||
|
||||
public delegate void SearchResultReceivedHandler(ShopLoginInfo shop);
|
||||
/// <summary>
|
||||
@@ -56,6 +64,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
/// </summary>
|
||||
public static List<TalkMessageForm> lstChatMessageForm = new List<TalkMessageForm>();
|
||||
public static Dictionary<DataGridViewRow, Color> dicRowColor = new Dictionary<DataGridViewRow, Color>();
|
||||
public List<string> LstTagShop = new List<string>();
|
||||
|
||||
public int LocationXY = 0;
|
||||
public int LocationSize = 200;
|
||||
@@ -83,20 +92,33 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
|
||||
//SetTitle();
|
||||
|
||||
// 点击变绿的按钮
|
||||
LstTagShop = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<string>>("wx_talk_tag_shop_list");
|
||||
if (LstTagShop == null)
|
||||
LstTagShop = new List<string>();
|
||||
|
||||
// 初始化自动回复话术
|
||||
InitAutoReply();
|
||||
|
||||
//this.chkIsAutoReLogin.CheckedChanged -= chkIsAutoReLogin_CheckedChanged;
|
||||
//this.chkIsAutoReply.CheckedChanged -= chkIsAutoReply_CheckedChanged;
|
||||
//this.txtAutoReplyText.TextChanged -= txtAutoReplyText_TextChanged;
|
||||
//this.cmbMessage.SelectedIndexChanged -= cmbMessage_SelectedIndexChanged;
|
||||
|
||||
this.chkNotShowMessageWindow.CheckedChanged -= chkNotShowMessageWindow_CheckedChanged;
|
||||
if (this.cmbMessage.Items.Contains(ChatConfig.ChatSettingConfig.MessageSound))
|
||||
this.cmbMessage.SelectedItem = ChatConfig.ChatSettingConfig.MessageSound;
|
||||
else
|
||||
this.cmbMessage.SelectedIndex = 0;
|
||||
this.chkIsAutoReply.Checked = ChatConfig.ChatSettingConfig.IsAutoReply;
|
||||
this.txtAutoReplyText.Text = ChatConfig.ChatSettingConfig.AutoReplayText;
|
||||
this.chkNotShowMessageWindow.Checked = ChatConfig.ChatSettingConfig.IsNotShowMessageWindow;
|
||||
|
||||
this.chkIsAutoReLogin.CheckedChanged += chkIsAutoReLogin_CheckedChanged;
|
||||
this.chkIsAutoReply.CheckedChanged += chkIsAutoReply_CheckedChanged;
|
||||
this.txtAutoReplyText.TextChanged += txtAutoReplyText_TextChanged;
|
||||
this.cmbMessage.SelectedIndexChanged += cmbMessage_SelectedIndexChanged;
|
||||
this.chkNotShowMessageWindow.CheckedChanged += chkNotShowMessageWindow_CheckedChanged;
|
||||
|
||||
SearchResultReceived += Chat_SearchResultReceived;
|
||||
InfomationReceived += Collect_InfomationReceived;
|
||||
@@ -114,6 +136,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
mainWebBrowser.FrameLoadEnd += cefWebBrowser1_FrameLoadEnd;
|
||||
mainPanel.Controls.Add(mainWebBrowser);
|
||||
}
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
// 直到店铺加载完后再加载客服内容
|
||||
@@ -130,9 +153,9 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
this.cmbFiltNotes.Items.Add(shopNote);
|
||||
}
|
||||
|
||||
lstShopAfterSale = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<WxShopAfterSaleInfo>>("wx_shop_after_sale_list");
|
||||
lstShopAfterSale = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<WxTalkFormShopMainInfo>>("wx_shop_after_sale_list");
|
||||
if (lstShopAfterSale == null)
|
||||
lstShopAfterSale = new ConcurrentList<WxShopAfterSaleInfo>();
|
||||
lstShopAfterSale = new ConcurrentList<WxTalkFormShopMainInfo>();
|
||||
//RefreshAfterSale();
|
||||
}));
|
||||
|
||||
@@ -170,6 +193,124 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
}
|
||||
});
|
||||
|
||||
// 关闭弹窗
|
||||
//if (chkIsAutoReply.Checked)
|
||||
ClosePopWindow();
|
||||
|
||||
// 自动回复
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//if (lstAutoReplayParam.Count > 0)
|
||||
// lstAutoReplayParam.Clear();
|
||||
|
||||
if (chkIsAutoReply.Checked && 1==1)
|
||||
{
|
||||
while (lstAutoReplayParam.Count > 0)
|
||||
{
|
||||
AutoReplayParam autoReplayParam = lstAutoReplayParam.FirstOrDefault();
|
||||
var autoReplayParamLst = lstAutoReplayParam.Where(r => r.nickName == autoReplayParam.nickName).ToList();
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == autoReplayParam.shopId);
|
||||
if (shop == null)
|
||||
continue;
|
||||
|
||||
// 选择正确的用户
|
||||
var jsStr1 = @"function clickUser() {
|
||||
var users = document.getElementsByClassName('user-nickname');
|
||||
for (i=0; i<users.length; i++) {
|
||||
if (users[i].innerHTML == '" + autoReplayParam.nickName + @"') {
|
||||
users[i].click();
|
||||
//alert('hello world');
|
||||
return 'success';
|
||||
}
|
||||
return 'fail';
|
||||
}
|
||||
}
|
||||
clickUser();";
|
||||
var response1 = shop.Chat.GetBrowser().MainFrame.EvaluateScriptAsync(jsStr1);
|
||||
response1.Wait(2000);
|
||||
if (response1.Result.Result.ParseToString() != "success")
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
continue;
|
||||
}
|
||||
Thread.Sleep(1500);
|
||||
|
||||
// 输入内容
|
||||
// 默认回复
|
||||
string replyContent = "亲,客服打包去了,请稍候!";
|
||||
// 分割完整语句匹配
|
||||
var replyContentLst = LstTalkTemplatePair
|
||||
.Where(t => lstAutoReplayParam.Any(a => t.Key.Split('|').Any(k => !k.IsNullOrEmpty() && a.talkContent == k)))
|
||||
.OrderBy(x => Randomx.GetId(100000)).ToList();
|
||||
// 分割完整语句匹配(过滤标点符号)
|
||||
if (replyContentLst.Count == 0)
|
||||
replyContentLst = LstTalkTemplatePair
|
||||
.Where(t => lstAutoReplayParam.Any(a => t.Key.Split('|').Any(k => !k.IsNullOrEmpty() && a.talkContent.Trim('?', '?', ',', ',', '.', '。', '!', '!') == k)))
|
||||
.OrderBy(x => Randomx.GetId(100000)).ToList();
|
||||
// 反向包含匹配
|
||||
if (replyContentLst.Count == 0)
|
||||
replyContentLst = LstTalkTemplatePair.Where(t => lstAutoReplayParam.Any(a => a.talkContent.Contains(t.Key))).OrderBy(x => Randomx.GetId(100000)).ToList();
|
||||
|
||||
// 不能匹配的发默认消息
|
||||
if (replyContentLst.Count == 0)
|
||||
replyContentLst = LstTalkTemplatePair.Where(t => t.Key.IsNullOrEmpty()).OrderBy(x => Randomx.GetId(100000)).ToList();
|
||||
if (replyContentLst.Count > 0)
|
||||
replyContent = replyContentLst.FirstOrDefault().Value;
|
||||
shop.Chat.GetBrowser().MainFrame.EvaluateScriptAsync(KJDForms.ShopForms.ShopLoginForm.sInputValueChange2);
|
||||
jsStr1 = "var txtarea = document.getElementById('input-textarea'); " +
|
||||
"changeReactInputValue(txtarea,'" + replyContent + "');";
|
||||
response1 = shop.Chat.GetBrowser().MainFrame.EvaluateScriptAsync(jsStr1);
|
||||
response1.Wait(2000);
|
||||
Thread.Sleep(Randomx.GetId(100, 200));
|
||||
|
||||
// 点击回车发送自动回复
|
||||
jsStr1 = @"var event = new KeyboardEvent('keydown', {
|
||||
key: 'Enter',
|
||||
keyCode: 13,
|
||||
code: 'Enter',
|
||||
which: 13
|
||||
});
|
||||
txtarea.dispatchEvent(event);";
|
||||
response1 = shop.Chat.GetBrowser().MainFrame.EvaluateScriptAsync(jsStr1);
|
||||
response1.Wait(2000);
|
||||
|
||||
// 删除队列里的消息
|
||||
lstAutoReplayParam.RemoveAll(r => r.nickName == autoReplayParam.nickName);
|
||||
|
||||
Thread.Sleep(Randomx.GetId(100, 200));
|
||||
}
|
||||
}
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ClosePopWindow()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
for (int i = 0; i < 120; i++)
|
||||
{
|
||||
foreach (var shop in GlobalConfig.ShopLoginList)
|
||||
{
|
||||
if (shop.Chat?.IsBrowserInitialized != true)
|
||||
continue;
|
||||
|
||||
//关闭弹窗
|
||||
var jsStr1 = @"var btnLst = document.getElementsByTagName('button');
|
||||
for (i=0;i<btnLst.length;i++)
|
||||
{
|
||||
if (btnLst[i].innerHTML.indexOf('暂不启用') !== -1)
|
||||
btnLst[i].click();
|
||||
}";
|
||||
var response1 = shop.Chat.GetBrowser().MainFrame.EvaluateScriptAsync(jsStr1);
|
||||
response1.Wait(2000);
|
||||
}
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void MainWebBrowser_AddressChanged(object sender, AddressChangedEventArgs e)
|
||||
@@ -295,6 +436,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
}
|
||||
r.Cells["colShopId"].Value = shop.ShopId; // 店铺ID
|
||||
r.Cells["colShopName"].Value = shop.ShopAccount; // 店铺名称
|
||||
r.Cells["colShopName"].Style.ForeColor = LstTagShop.Contains(shop.ShopId) ? Color.Green : Control.DefaultForeColor;
|
||||
r.Cells["colShopNotes"].Value = shop.Notes; // 备注
|
||||
r.Cells["colLoginStatus"].Value = shop.LoginStatus == "登录成功" ? "在线" : "掉线"; // 登录状态
|
||||
bool canUse = shop.LoginStatus == "登录成功";
|
||||
@@ -377,14 +519,19 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadShopAfterSale(WxShopAfterSaleInfo shopAfterSale, string msg)
|
||||
private void LoadShopAfterSale(WxTalkFormShopMainInfo shopAfterSale, string msg)
|
||||
{
|
||||
var r = dgvShop.Rows.Cast<DataGridViewRow>().FirstOrDefault(x => x.Cells["colShopId"].Value.ToString() == shopAfterSale.ShopId);
|
||||
if (r != null)
|
||||
{
|
||||
r.Cells["colMessage"].Value = msg;
|
||||
r.Cells["colAfterSale"].Value = shopAfterSale.AfterSaleCount;
|
||||
r.Cells["colAfterSale"].Style.ForeColor = shopAfterSale.AfterSaleCount > 0 ? Color.Red : Color.Black;
|
||||
r.Cells["colAfterSale"].Style.ForeColor = shopAfterSale.AfterSaleCount > 0 ? Color.OrangeRed : Color.Black;
|
||||
r.Cells["colWaitSend"].Value = shopAfterSale.WaitSendCount;
|
||||
r.Cells["colWaitSend"].Style.ForeColor = shopAfterSale.WaitSendCount > 0 ? Color.OrangeRed : Color.Black;
|
||||
r.Cells["colWaybillError"].Value = shopAfterSale.WaybillError;
|
||||
r.Cells["colWaybillError"].Style.ForeColor = shopAfterSale.WaybillError > 0 ? Color.OrangeRed : Color.Black;
|
||||
r.Cells["colScore"].Value = shopAfterSale.ShopScore.IsNullOrEmpty() ? "-" : shopAfterSale.ShopScore.ParseToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,6 +565,9 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
if (row == null)
|
||||
return;
|
||||
|
||||
string nickName = "";
|
||||
string talkContent = "";
|
||||
|
||||
if (url.Contains("action=get_nosession_summary"))
|
||||
{
|
||||
//{"base_resp":{"err_msg":"ok","ret":0},"list":[{"session_status":1,"summary":{"accept_by_robot":2,"accept_by_robot_time":"0","complaint_info":{"complaint_expire_time":0,"complaint_id":"0"},"extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/Q3auHgzwzM6vehibAAib9ia4ejxH7ibula7RuH4rTO7H7equgOZPVZl5Ew\\/64\",\"nickname\":\"Vader\",\"list\":[],\"qa_info_list\":[]}","id":"1","is_delete":0,"lastest_msg_content":"","lastest_msg_id":"4348928114244206592","lastest_msg_kf_content":"{\"content\":\"你好\"}","lastest_user_msg_time":"1768807915","msg_type":1,"recv_open_account":"wxf4460bce24e5d58d","recv_openid":"","room_id":"4348927951587721218","scene":6,"send_open_account":"","send_openid":"o9cq802Ue5pCVRmzuzkFUcnoHjcM","send_scene":6,"unread_msg_num":"1","unreplied_msg_time":"1768807915","update_time":"1768807915"}}],"num":1}
|
||||
@@ -464,12 +614,45 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
var send_open_account = summaryObj["send_open_account"].ParseToString();
|
||||
if (send_open_account == shop.ShopId)
|
||||
continue;
|
||||
// 虽然没有回复,但是最后一条消息是两天以前收到的,返回
|
||||
// 虽然没有回复,但是最后一条消息是一天以前收到的,返回
|
||||
var lastUpTime = summaryObj["update_time"].ParseToLong();
|
||||
if (lastUpTime < BaseClass.DateTimeToTimestampSeconds(DateTime.Now.AddDays(-2)))
|
||||
if (lastUpTime < BaseClass.DateTimeToTimestampSeconds(DateTime.Now.AddDays(-1)))
|
||||
continue;
|
||||
// 其他情况,标记需要回复
|
||||
needReply = true;
|
||||
|
||||
|
||||
// 历史消息自动回复
|
||||
if (chkIsAutoReply.Checked)
|
||||
{
|
||||
//lastest_msg_kf_content
|
||||
var msgObj = summaryObj;
|
||||
//var msgStr = JsonHelper.SerializeObject(msgObj);
|
||||
// 用户发送商品信息
|
||||
if ((msgObj?["msg_type"]).ParseToInt() == 11)
|
||||
{
|
||||
talkContent = "";
|
||||
}
|
||||
else if ((msgObj?["recv_open_account"]).ParseToString() == shop.ShopId)
|
||||
{
|
||||
var contentObj = (msgObj?["lastest_msg_kf_content"]).ParseToString();
|
||||
var content = BaseRegex.GetStringJson(ref contentObj, "content").ParseToString();
|
||||
talkContent = content;
|
||||
}
|
||||
|
||||
string extra_info = (msgObj?["extra_info"]).ParseToString();
|
||||
var extraInfoObj = JsonHelper.JObjectParse(extra_info);
|
||||
nickName = (extraInfoObj?["nickname"]).ParseToString();
|
||||
if (chkIsAutoReply.Checked && !string.IsNullOrWhiteSpace(nickName))
|
||||
{
|
||||
lstAutoReplayParam.Add(new AutoReplayParam()
|
||||
{
|
||||
nickName = nickName,
|
||||
shopId = shop.ShopId,
|
||||
talkContent = talkContent,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -519,7 +702,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
}
|
||||
var msg_kf_content = jObj["list"].LastOrDefault(l => !JsonHelper.SerializeObject(l).Contains("更新房间游标"))?["msg_kf_content"].ParseToString();
|
||||
var contentObj = JsonHelper.JObjectParse(msg_kf_content);
|
||||
var content = contentObj["content"].ParseToString();
|
||||
var content = (contentObj?["content"]).ParseToString();
|
||||
//if (content.Contains("更新房间游标"))
|
||||
// return;
|
||||
|
||||
@@ -530,6 +713,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
// 你已超过10分钟未回复该会话,请及时处理。
|
||||
// 超过48小时未回复用户,会话已结束
|
||||
// {"base_resp":{"err_msg":"ok","ret":0},"kf_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","list":[{"accept_by_robot":0,"async_check_spam_stage":0,"client_ms":"1768806150100","create_time":"1768806150","create_time_ms":"1768806150100","encrypt_msg_kf_content":"","extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/Q3auHgzwzM6vehibAAib9ia4ejxH7ibula7RuH4rTO7H7equgOZPVZl5Ew\\/64\",\"nickname\":\"Vader\",\"list\":[],\"qa_info_list\":[]}","id":"31","imunion_msg_id":"mmec-commkf-v2-4348898496719831040","insert_create_time_ms":"1768806150148","is_anonymous_msg":0,"is_delete":0,"is_expired":0,"is_fail":0,"is_hit_spam":0,"is_revoked":0,"is_sys_msg":1,"msg_direction":3,"msg_id":"4348898496719831040","msg_kf_content":"{\"type\":\"EndRoom\",\"content\":\"用户超时未回,会话已结束,两天内仍可再次联系\",\"room_id\":\"4348684483414425612\",\"msg_id\":\"4348898496719831040\",\"is_anonymous_msg\":0,\"need_update_summary\":1}","msg_type":5,"properties":"0","recv_open_account":"wxad4163db54e87b44","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","reply_type":0,"room_id":"4348684483414425612","room_useruin":"0","scene":6,"send_open_account":"","send_openid":"o9cq802Ue5pCVRmzuzkFUcnoHjcM","send_scene":6,"session_id":"0","update_time":"1768806150"}],"total_num":1}
|
||||
//{"base_resp":{"err_msg":"ok","ret":0},"kf_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","list":[{"accept_by_robot":2,"async_check_spam_stage":0,"client_ms":"1773134620500","create_time":"1773134620","create_time_ms":"1773134621082","encrypt_msg_kf_content":"","extra_info":"{\"head_img\":\"http:\\/\\/wx.qlogo.cn\\/mmhead\\/Q3auHgzwzM6vehibAAib9ia4ejxH7ibula7RuH4rTO7H7equgOZPVZl5Ew\\/64\",\"nickname\":\"Vader\",\"unread_msg_num\":1,\"list\":[],\"qa_info_list\":[]}","id":"2280","imunion_msg_id":"4875563441394659225","insert_create_time_ms":"1773134621580","is_anonymous_msg":0,"is_delete":0,"is_expired":0,"is_fail":0,"is_hit_spam":0,"is_revoked":0,"is_sys_msg":0,"msg_direction":1,"msg_id":"4421518190792900611","msg_kf_content":"{\"content\":\"有优惠吗?\"}","msg_type":1,"properties":"0","recv_open_account":"wxf4460bce24e5d58d","recv_openid":"o9cq801T0m1dIivQzMyUwBvW5Znk","reply_type":0,"room_id":"4348927951587721218","room_useruin":"0","scene":6,"send_open_account":"","send_openid":"o9cq802Ue5pCVRmzuzkFUcnoHjcM","send_scene":6,"session_id":"4421510266814349317","update_time":"1773134621"}],"total_num":1}
|
||||
if (content.Contains("用户超时未回,会话已结束,两天内仍可再次联系"))
|
||||
return;
|
||||
if (content.Contains("会话已结束"))
|
||||
@@ -545,6 +729,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
//if (content.Contains("用户已接入"))
|
||||
// return;
|
||||
|
||||
//msg_type 11 发送商品
|
||||
//content {"finder_live_id":"","finder_username":"","finder_object_id":"","finder_nonce_id":"","app_id":"wxca8d4b8e8feedc2a","page_path":"main/pages/productDetail/productDetail.html?productId=10000458846351&realappid=wxad4163db54e87b44&cacheKey=5e17e5db9339a95043ba1f8a3d02454d&cacheType=backup&businessId=1&requestId=4349008357285756937&subScene=1208","product_id":"10000458846351","cover_url":"https://wst.wxapp.tc.qq.com/161/20304/snscosdownload/SH/reserved/695a8faa000d37b31b2e9b6f55e91715000000a100004f50?imageView2/1/w/400/h/400/q/50","product_title":"旗袍复古国风外套新款加绒中老年时尚中式盘扣妈妈唐装开衫上衣女","market_price":"0","selling_price":"15895","platform_head_img":"http://mmbiz.qpic.cn/mmbiz_jpg/v9IeicMmfib92I87ia9hWs58ozuHZ8CRk6jyf6qgLwzibNSjAPekLzdf7yxOdQqR6od63tLH9s2zTxJbuqVTs6E19w/0?wx_fmt=jpeg/0","platform_name":"曼月森工厂店","shop_window_id":"","live_status":"","flash_sale_price":0,"flash_sale_end_time":0,"ec_source":"","selling_price_wording":"","ext_conv":{"ext_conv_type":1,"ec_product_url":"https://channels.weixin.qq.com/shop?login_appid=wxad4163db54e87b44&redirect_url=%2Fgoods%2Fentry%3FproductId%3D10000458846351","context":""}}
|
||||
var product_title = BaseRegex.GetStringJson(ref content, "product_title");
|
||||
if (!string.IsNullOrWhiteSpace(product_title))
|
||||
@@ -552,6 +737,36 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
|
||||
// 在消息格子内显示消息
|
||||
row.Cells["colMessage"].Value = content;
|
||||
|
||||
|
||||
// 即时消息自动回复
|
||||
if(chkIsAutoReply.Checked)
|
||||
{
|
||||
var msgObj = jObj["list"].LastOrDefault(l => !JsonHelper.SerializeObject(l).Contains("更新房间游标"));
|
||||
//var msgStr = JsonHelper.SerializeObject(msgObj);
|
||||
// 用户发送商品信息
|
||||
if ((msgObj?["msg_type"]).ParseToInt() == 11)
|
||||
{
|
||||
talkContent = "";
|
||||
}
|
||||
else if ((msgObj?["recv_open_account"]).ParseToString() == shop.ShopId)
|
||||
{
|
||||
talkContent = content;
|
||||
}
|
||||
|
||||
string extra_info = (msgObj?["extra_info"]).ParseToString();
|
||||
var extraInfoObj = JsonHelper.JObjectParse(extra_info);
|
||||
nickName = (extraInfoObj?["nickname"]).ParseToString();
|
||||
if (chkIsAutoReply.Checked && !string.IsNullOrWhiteSpace(nickName))
|
||||
{
|
||||
lstAutoReplayParam.Add(new AutoReplayParam()
|
||||
{
|
||||
nickName = nickName,
|
||||
shopId = shop.ShopId,
|
||||
talkContent = talkContent,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -571,10 +786,6 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
FlashDgvRow(row);
|
||||
// 播放声音
|
||||
playSound();
|
||||
// 消息弹框,暂时废弃
|
||||
if (!ChatConfig.ChatSettingConfig.IsNotShowMessageWindow)
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -839,6 +1050,19 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
ChatConfig.SaveChatSettingParam();
|
||||
}
|
||||
|
||||
private void chkNotShowMessageWindow_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ChatConfig.ChatSettingConfig.IsNotShowMessageWindow = chkNotShowMessageWindow.Checked;
|
||||
ChatConfig.SaveChatSettingParam();
|
||||
|
||||
}
|
||||
|
||||
private void pnlSet_Click(object sender, EventArgs e)
|
||||
{
|
||||
TalkAutoReplyConfigForm autoReplyConfigForm = new TalkAutoReplyConfigForm(LstTalkTemplatePair);
|
||||
autoReplyConfigForm.ShowDialog();
|
||||
}
|
||||
|
||||
private void Chat_SearchResultReceived(ShopLoginInfo shop)
|
||||
{
|
||||
//var r = dgvShop.Rows.Cast<DataGridViewRow>().FirstOrDefault(x => x.Cells["columnShopId"].Value.ToString() == shop.ShopId);
|
||||
@@ -924,6 +1148,36 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void dgvShop_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||||
return;
|
||||
|
||||
if (e.Button != MouseButtons.Right)
|
||||
return;
|
||||
|
||||
string shopId = dgvShop.Rows[e.RowIndex].Cells["colShopId"].Value?.ToString();
|
||||
if (string.IsNullOrEmpty(shopId))
|
||||
return;
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId);
|
||||
if (shop == null)
|
||||
return;
|
||||
|
||||
if (!LstTagShop.Contains(shop.ShopId))
|
||||
{
|
||||
LstTagShop.Add(shop.ShopId);
|
||||
dgvShop.Rows[e.RowIndex].Cells["colShopName"].Style.ForeColor = Color.Green;
|
||||
}
|
||||
else
|
||||
{
|
||||
LstTagShop.Remove(shop.ShopId);
|
||||
dgvShop.Rows[e.RowIndex].Cells["colShopName"].Style.ForeColor = DefaultForeColor;
|
||||
}
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig<List<string>>("wx_talk_tag_shop_list", LstTagShop);
|
||||
}
|
||||
|
||||
private void dgvShop_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||||
@@ -961,7 +1215,6 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void dgvShop_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
@@ -1020,7 +1273,11 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
var r = dgvShop.Rows.Cast<DataGridViewRow>().FirstOrDefault(x => x.Cells["colShopId"].Value.ToString() == shop.ShopId);
|
||||
if (r != null)
|
||||
{
|
||||
r.Cells[0].Selected = true;
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
//r.Cells[1].Selected = true;
|
||||
r.Selected = true;
|
||||
}));
|
||||
var sender = this.dgvShop;
|
||||
DataGridViewCellEventArgs e = new DataGridViewCellEventArgs(0, r.Index);
|
||||
dgvShop_CellClick(sender, e);
|
||||
@@ -1115,17 +1372,17 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
lstShopAfterSale.Clear();
|
||||
foreach (var shop in GlobalConfig.ShopLoginList)
|
||||
{
|
||||
var afterInfo = lstShopAfterSale.FirstOrDefault(sa => sa.ShopId == shop.ShopId);
|
||||
if (afterInfo == null)
|
||||
afterInfo = new WxShopAfterSaleInfo() { ShopId = shop.ShopId };
|
||||
Invoke(new Action(() => { LoadShopAfterSale(afterInfo, ""); }));
|
||||
var shopMainInfo = lstShopAfterSale.FirstOrDefault(sa => sa.ShopId == shop.ShopId);
|
||||
if (shopMainInfo == null)
|
||||
shopMainInfo = new WxTalkFormShopMainInfo() { ShopId = shop.ShopId };
|
||||
Invoke(new Action(() => { LoadShopAfterSale(shopMainInfo, ""); }));
|
||||
var t = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (shop.LoginStatus != "登录成功")
|
||||
{
|
||||
Invoke(new Action(() => { LoadShopAfterSale(new WxShopAfterSaleInfo() { ShopId = shop.ShopId }, "店铺掉线"); }));
|
||||
Invoke(new Action(() => { LoadShopAfterSale(new WxTalkFormShopMainInfo() { ShopId = shop.ShopId }, "店铺掉线"); }));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1141,7 +1398,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||||
if (shop.LoginStatus != "登录成功")
|
||||
{
|
||||
Invoke(new Action(() => { LoadShopAfterSale(new WxShopAfterSaleInfo() { ShopId = shop.ShopId }, "店铺掉线"); }));
|
||||
Invoke(new Action(() => { LoadShopAfterSale(new WxTalkFormShopMainInfo() { ShopId = shop.ShopId }, "店铺掉线"); }));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1151,16 +1408,46 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
if (string.IsNullOrEmpty(errMsg)) errMsg = BaseRegex.GetStringJson(ref rst, "errmsg");
|
||||
if (string.IsNullOrEmpty(errMsg)) errMsg = rst;
|
||||
|
||||
afterInfo = new WxShopAfterSaleInfo() { ShopId = shop.ShopId, RefreshTime = DateTime.Now };
|
||||
lstShopAfterSale.Add(afterInfo);
|
||||
Invoke(new Action(() => { LoadShopAfterSale(afterInfo, "查询失败 " + errMsg); }));
|
||||
shopMainInfo = new WxTalkFormShopMainInfo() { ShopId = shop.ShopId, RefreshTime = DateTime.Now };
|
||||
lstShopAfterSale.Add(shopMainInfo);
|
||||
Invoke(new Action(() => { LoadShopAfterSale(shopMainInfo, "查询失败 " + errMsg); }));
|
||||
return;
|
||||
}
|
||||
|
||||
var afterCount = JsonHelper.JObjectParse(rst)["aftersaleAllRet"]["totalNum"].ParseToInt();
|
||||
afterInfo = new WxShopAfterSaleInfo() { ShopId = shop.ShopId, RefreshTime = DateTime.Now, AfterSaleCount = afterCount };
|
||||
lstShopAfterSale.Add(afterInfo);
|
||||
Invoke(new Action(() => { LoadShopAfterSale(afterInfo, "已查询"); }));
|
||||
var waitSendCount = JsonHelper.JObjectParse(rst)["orderNumRet"]["pendingShipNum"].ParseToInt();
|
||||
var waybillErrorCount = JsonHelper.JObjectParse(rst)["waybillErrorRet"]["totalNum"].ParseToInt();
|
||||
shopMainInfo = new WxTalkFormShopMainInfo()
|
||||
{
|
||||
ShopId = shop.ShopId,
|
||||
RefreshTime = DateTime.Now,
|
||||
AfterSaleCount = afterCount,
|
||||
WaitSendCount = waitSendCount,
|
||||
WaybillError = waybillErrorCount,
|
||||
};
|
||||
|
||||
var shopScoreRst = WxShopStatisticsForm.GetShopScore(shop);
|
||||
System.Threading.Thread.Sleep(Randomx.GetId(50, 100));
|
||||
if (shopScoreRst.Contains("\"code\":0"))
|
||||
{
|
||||
shopMainInfo.ShopScore = BaseRegex.GetDecimalJson(ref shopScoreRst, "curValue");
|
||||
}
|
||||
else
|
||||
{
|
||||
string errStr = BaseRegex.GetStringJson(ref shopScoreRst, "errorMsg");
|
||||
if (string.IsNullOrEmpty(errStr))
|
||||
errStr = BaseRegex.GetStringJson(ref shopScoreRst, "error_msg");
|
||||
if (string.IsNullOrEmpty(errStr))
|
||||
errStr = shopScoreRst;
|
||||
WXShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false);
|
||||
shopMainInfo.err_msg = errStr;
|
||||
|
||||
Invoke(new Action(() => { LoadShopAfterSale(shopMainInfo, "评分查询失败 " + errStr); }));
|
||||
return;
|
||||
}
|
||||
|
||||
lstShopAfterSale.Add(shopMainInfo);
|
||||
Invoke(new Action(() => { LoadShopAfterSale(shopMainInfo, "已查询"); }));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1248,5 +1535,98 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
lblReplyCount.Text = lstShopKfStatistics.Sum(s => s.service_reply_ratio * 100 / count).ParseToDecimal().ToString("0.0") + "%";
|
||||
}));
|
||||
}
|
||||
|
||||
public static void InitAutoReply()
|
||||
{
|
||||
LstTalkTemplatePair = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<KeyValuePair<string, string>>>("wx_talk_auto_reply_template");
|
||||
if (LstTalkTemplatePair == null)
|
||||
{
|
||||
UpdateAutoReply(defaultTalkTemplate);
|
||||
}
|
||||
}
|
||||
public static void UpdateAutoReply(string talkTemplate)
|
||||
{
|
||||
LstTalkTemplatePair = new List<KeyValuePair<string, string>>();
|
||||
var keyValueStrLst = talkTemplate.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var keyValueStr in keyValueStrLst)
|
||||
{
|
||||
if (keyValueStr.StartsWith("//"))
|
||||
continue;
|
||||
var keyValueLst = keyValueStr.Split(new string[] { "###" }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
if (keyValueLst.Count == 1)
|
||||
keyValueLst.Insert(0, "");
|
||||
LstTalkTemplatePair.Add(new KeyValuePair<string, string>(keyValueLst.FirstOrDefault(), keyValueLst.LastOrDefault()));
|
||||
}
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_talk_auto_reply_template", LstTalkTemplatePair);
|
||||
}
|
||||
|
||||
public static string defaultTalkTemplate = @"###亲亲,客服人员正在仓库核实打包发货,您的问题我们记录好,客服小姐姐回来会为您解答哦!
|
||||
###亲亲,在的呢亲亲,这款商品质量很好的呢,现在下单为您优先发出哦
|
||||
###亲,客户已经听到您的呼叫,请稍等!
|
||||
###亲,客服正在来的路上喔,您看到的商品基本都是有货的,请放心购买!
|
||||
###亲,如果您有什么疑问可以直接留言,客服看到了会记录下来的,没有及时回复您,真的非常抱歉!
|
||||
###亲,您好,有什么需要帮助的吗~喜欢可以直接拍下哦,拍下后尽快给您安排发出~
|
||||
###目前顾客比较多哦,客服小姐姐一个一个回复呢,麻烦您耐心等待下
|
||||
###客服小姐姐加急回复哦,请您再稍等一下哦
|
||||
###亲,已经听到您的呼叫,请稍等!
|
||||
###亲,客服正在来的路上喔,您看到的商品基本都是有货的,拍下后尽快给您安排发出~
|
||||
###亲,如果您有什么疑问可以直接留言,客服看到了会记录下来的,没有及时回复您,真的非常抱歉!
|
||||
###需要可以拍下,这边尽快给您发出,不指定快递哦
|
||||
###若客服未及时回,可能是系统延迟,请留言,客服上线后处理,谢谢!
|
||||
###客服正在仓库打包包裹,您可以先留言,看到消息后会及时回复~
|
||||
###亲,我会乐意为你服务。请收藏一下本小店,我们会不定期上新款。祝你网购愉快。
|
||||
###亲~ 不好意思,现在忙于打包发货中,有事请留言,晚点给你回复,谢谢!
|
||||
###亲,我会乐意为你服务。收藏一下本小店,我们会不定期上新款。祝你网购愉快。
|
||||
快递###亲,我们根据您的收货地址选择最优的快递!
|
||||
什么时候发货###亲,我们48小时内发货,一般我们都是当天发货的喔
|
||||
什么时候发货###亲,除(预售商品)外我们48小时内发货,一般我们都是当天发货的喔
|
||||
哪里发货###亲,我们全国多仓发货,尽快为您发出,随机发极兔,韵达,邮政等(暂不接受指定),一般24小时内发货,慢的48小时内按顺序发货,一般发货后省内1-2天,省外3-4天,偏远地区可能会稍慢一些
|
||||
备注一下|标注一下|注明一下###好的,亲!我会为您备注的!
|
||||
您好|老板|店家|哈喽|嗨|亲|亲你好|亲,你好###在的,亲!很高兴能为您服务,请问有什么可以帮到您?
|
||||
晕!|哦!|喔!|恩!|嗯!|奥!|好!|噢!|噢噢!|奥奥!|哦哦!|喔喔!|!|嗯嗯!|好的!###感谢您的支持呢亲!
|
||||
退款|退款吧|退了|退了吧|不要了|买错了|退货###亲,如您未收到货,可直接申请仅退款,如已收到货,退款步骤-个人中心-订单与卡包-申请退款-【我要退货退款】(不是 我要退款)-申请原因-选择第一个【多拍/拍错/不想要】或最后一个【其他】,退货申请会秒通过并自动发送地址给亲的哦。拒收平邮及到付哦!注意:申请通过后请及时填写退货单号,超时会自动关闭退款哦!
|
||||
麻烦了###不客气的,亲!
|
||||
答复|回答###好的,亲!有结果我们会第一时间答复您的!
|
||||
说句话|说话|回话|回个话###在的,亲!我正在想怎样回答您呢,能把问题具体再说一下吗?
|
||||
好了吗|可以了吗###亲稍等,正在为您核实处理!
|
||||
有货吗|有货?|还有货###亲:我们的库存是很充足得哦。放心好了。
|
||||
么回事|咋回事|怎么办|咋办###亲,您不要着急,请把事情的具体情况和我说明一下,如果有图片也最好提供一下,我们会为您核实处理的哦!
|
||||
什么情况###虽然我也不清楚什么情况,但我们会为您处理好的哦!
|
||||
您好|老板|店家|哈喽|嗨|亲|亲你好|亲,你好###在的,亲!很高兴能为您服务,请问有什么可以帮到您?
|
||||
退款|退款吧|退了|退了吧|不要了|买错了###亲,如您未收到货,可直接申请仅退款,如已收到货,退款步骤-个人中心-订单与卡包-申请退款-【我要退货退款】(不是 我要退款)-申请原因-选择第一个【多拍/拍错/不想要】或最后一个【其他】,退货申请会秒通过并自动发送地址给亲的哦。拒收平邮及到付哦!注意:申请通过后请及时填写退货单号,超时会自动关闭退款哦!
|
||||
么回事|咋回事|怎么办|咋办###亲,您不要着急,请把事情的具体情况和我说明一下,如果有图片也最好提供一下,我们会为您核实处理的哦!
|
||||
怎么申请退货|申请退货|申请退款|怎么退|退###亲,退货步骤-个人中心-订单与卡包-申请退款-【我要退货退款】(不是 我要退款)-申请原因-选择第一个【多拍/拍错/不想要】或最后一个【其他】,退货申请会秒通过并自动发送地址给亲的哦。拒收平邮及到付哦!注意:申请通过后请及时填写退货单号,超时会自动关闭退款哦!
|
||||
退了吧|我退款###亲,如您未收到货,可直接申请仅退款,如已收到货,退款步骤-个人中心-订单与卡包-申请退款-【我要退货退款】(不是 我要退款)-申请原因-选择第一个【多拍/拍错/不想要】或最后一个【其他】,退货申请会秒通过并自动发送地址给亲的哦。拒收平邮及到付哦!注意:申请通过后请及时填写退货单号,超时会自动关闭退款哦!
|
||||
好评###非常感谢您的支持呢亲
|
||||
拍了|已拍|拼了|已买|已下单|现在拍|买好了|下单了|下好单了|下好了|买好了|买完了|拍好了|拍完了|拍下了|购买了|已购买|买单了|拼单成功###好的,亲!这边核实后会及时为您安排发出的哦!
|
||||
同意一下|通过一下###好的,亲!我们的售后专员会及时为您处理的。
|
||||
差评###亲,差评并不是解决问题的办法,沟通才是最有效的哦,有任何问题欢迎与我们联系哦!
|
||||
机器人###哈,我不是机器人,我是可爱的客服妹子哦!(*^__^*) ,您的问题我已经收到,不过现在有点小忙,稍等一会回复您哦!
|
||||
我已经拼单成功###好的亲,这边通知仓库为您优先发货!
|
||||
发货时间|发货###亲,除(预售商品)外我们48小时内发货,一般我们都是当天发货的喔
|
||||
发什么快递###亲,我们在全国有多个仓库,会根据您的收货地址和库存进行动态调配的,请您放心,商品一定会寄送到您手里!
|
||||
什么时候发货###拍下后我们会尽快给您安排发出,拍下后亲耐心稍等哦~
|
||||
多久能到###亲,一般发货以后3天左右可以到货的呢,您收到货以后可以仔细检查一下,如有任何质量问题,7天内可以无条件退换货的。
|
||||
可以便宜###亲,非常抱歉,我们的定价已经是最低销售价格了呢,没有办法再优惠啦~~~
|
||||
质量问题###亲,我们是商城正品,质量都是有保证的,您这边可以完全放心拍下哦。。。我们支持7天无理由退货的。
|
||||
包邮###亲,我们是全场包邮的喔,请放心拍下。
|
||||
我考虑###亲,可以的,等你考虑清楚了再下单,我们尽快给您安排发货。
|
||||
物流慢###亲,非常抱歉,最近物流比较繁忙,发货比较慢(容易出错),您这边先不要着急,我先联系一下快递公司询问一下具体是什么情况好吗?然后根据具体情况具体解决。
|
||||
质量问题###亲,请您放心哦,如果是我们的质量问题,这边一定会为您处理好的, 您需要配合一下 请您发拍张有质量问题处的图片给我们,好吧?
|
||||
是否有货###亲,您看中的这款宝贝是有现货的呢,您可以放心拍哦O(_)O~
|
||||
质量怎么样###我们是厂家直接供货,质量绝对保证。保证正品
|
||||
//不放卡片|不放清单###好的,亲!我会为您备注不放卡片清单的!
|
||||
//已联系卖家尽快为您发|催发货###好的,亲!我们会尽快为您安排发货的哦!
|
||||
//商家同意退货,请及时退货###亲,退货后请记得填写退货运单号,方便我们及时为您处理哦!
|
||||
//申请未同意,待买家处理###亲,由于快递还在运输途中或已经签收,我们暂时不能同意您的退款,待与快递核实后我们会及时为您处理的哦!
|
||||
//物流投诉|我已提交投诉物流单###亲,您的诉求我们已经收到,请不要着急,我们马上联系快递加急处理!
|
||||
//纠纷预警,请立即跟进###亲,有什么问题可以随时与我们联系,我们将竭诚为您服务!
|
||||
//开启商品卡片自动回复###亲,您的眼光真好,这款产品不仅价格实惠,质量也是非常好的哦!
|
||||
//当前用户来自###亲,您正在看的这款宝贝有货的哦,请问有什么可以帮到您?
|
||||
//商家购买退货包运费服务后###亲,您拍下商品前,商品标题后显示【退货包运费】的,表示此商品有运费险,当您拍下后订单详情显示运费险生效中就表示此订单您享有运费险的。
|
||||
//催处理售后###亲,稍安勿躁,我们的售后专员会及时为您处理的哦!
|
||||
//催发货###亲,您的订单我们已经收到,仓库正在为您进行质量检查,确认无误后就会发出的哦!
|
||||
//订单编号###亲,您的这笔订单已核实,请问是遇到什么问题了呢?
|
||||
//退款成功###亲,您的退款已办理成功,欢迎下次光临哦!";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user