修改工单流程页面,订单列表增加工单按钮
This commit is contained in:
1 parent
f9dcae4610
commit
10bb0803d9
44 files changed
+5920
-1291
No files matched your search
+468
-300
@@ -14,6 +14,9 @@ using CefSharp;
|
||||
using NaiBa.Util;
|
||||
using NaiBa.Util.Extension;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OrderSupportTicket.Models;
|
||||
using OrderSupportTicket.Services;
|
||||
using OrderSupportTicket.Views;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -41,249 +44,261 @@ using System.Xml.Linq;
|
||||
using Work;
|
||||
using Work._29Tools.BLL;
|
||||
using Work._29Tools.Forms.UserForms;
|
||||
using WxOrder.Framework.Commons;
|
||||
using WxOrder.Framework.Commons.Dialogs;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
||||
|
||||
namespace _29WxOrderWpf
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow : BaseWindow, INotifyPropertyChanged
|
||||
{
|
||||
public static MainWindow Instance { get; private set; }
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow : BaseWindow, INotifyPropertyChanged
|
||||
{
|
||||
public static MainWindow Instance { get; private set; }
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public string Balance { get { return "快递余额:" + BaseClass.Balance.ToString("0.00"); } set { OnPropertyChanged("Balance"); } }
|
||||
private readonly TicketRealtimeMonitor _ticketMonitor = TicketRealtimeMonitor.Current;
|
||||
private TicketClientOptions _ticketOptions;
|
||||
private OrderSupportTicketView _orderSupportView;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = this;
|
||||
Instance = this;
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public string Balance { get { return "快递余额:" + BaseClass.Balance.ToString("0.00"); } set { OnPropertyChanged("Balance"); } }
|
||||
|
||||
gridUser.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = this;
|
||||
Instance = this;
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
GlobalConfig.Dispatcher = this.Dispatcher;
|
||||
lblDebug.Visibility = Visibility.Collapsed;
|
||||
gridUser.Visibility = Visibility.Collapsed;
|
||||
|
||||
ucWindowBox.SetWindowMax();
|
||||
this.Title = BaseClass.ToolName;
|
||||
_ticketMonitor.NewMessageReceived += OnTicketNewMessageReceived;
|
||||
_ticketMonitor.UnreadCountChanged += OnTicketUnreadCountChanged;
|
||||
Closed += MainWindow_Closed;
|
||||
}
|
||||
|
||||
new Thread(AutoAntiGrabbingMechanism).Start(); // 反抓包
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
GlobalConfig.Dispatcher = this.Dispatcher;
|
||||
lblDebug.Visibility = Visibility.Collapsed;
|
||||
|
||||
#region 弹出登录窗口
|
||||
LoginWindow loginWindow = new LoginWindow(App.args);
|
||||
loginWindow.Owner = this;
|
||||
loginWindow.ShowDialog();
|
||||
#endregion
|
||||
ucWindowBox.SetWindowMax();
|
||||
this.Title = BaseClass.ToolName;
|
||||
|
||||
if (loginWindow.IsLogin)
|
||||
{
|
||||
lblVersion.Content = BaseClass.ToolName + " V" + BaseClass.Varsion + " - " + BaseClass.NickName;
|
||||
new Thread(AutoAntiGrabbingMechanism).Start(); // 反抓包
|
||||
|
||||
//shopListCtrl.Visibility = Visibility.Visible;
|
||||
orderListCtrl.Visibility = Visibility.Visible;
|
||||
#region 弹出登录窗口
|
||||
LoginWindow loginWindow = new LoginWindow(App.args);
|
||||
loginWindow.Owner = this;
|
||||
loginWindow.ShowDialog();
|
||||
#endregion
|
||||
|
||||
if (loginWindow.IsLogin)
|
||||
{
|
||||
lblVersion.Content = BaseClass.ToolName + " V" + BaseClass.Varsion + " - " + BaseClass.NickName;
|
||||
|
||||
//shopListCtrl.Visibility = Visibility.Visible;
|
||||
orderListCtrl.Visibility = Visibility.Visible;
|
||||
pddBuyerOrderReadCtrl.Visibility = Visibility.Visible;
|
||||
tbBuyerOrderReadCtrl.Visibility = Visibility.Visible;
|
||||
pddBuyerSelectCtrl.Visibility = Visibility.Visible;
|
||||
Task.Run(() =>
|
||||
{
|
||||
GetServerShop();
|
||||
Task.Run(() =>
|
||||
{
|
||||
GetServerShop();
|
||||
StartTicketRealtimeMonitor();//启动工单监控
|
||||
GetShopSupplier(GlobalConfig.ShopLoginList.ToList());
|
||||
});
|
||||
Task.Run(() =>
|
||||
{
|
||||
GetPddBuyer();
|
||||
Task.Run(() =>
|
||||
{
|
||||
GetPddBuyer();
|
||||
GetTaobaoBuyer();
|
||||
});
|
||||
}
|
||||
}
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (this.PropertyChanged != null)//有改变
|
||||
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (this.PropertyChanged != null)//有改变
|
||||
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
#region 反抓包功能
|
||||
private void AutoAntiGrabbingMechanism()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
#region 反抓包功能
|
||||
private void AutoAntiGrabbingMechanism()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
#if DEBUG
|
||||
#else
|
||||
AntiGrabbingMechanism();
|
||||
#endif
|
||||
try { Thread.Sleep(3000); } catch { }
|
||||
}
|
||||
}
|
||||
try { Thread.Sleep(3000); } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool IsWow64Process([In] IntPtr process, [Out] out bool wow64Process);
|
||||
private List<string> _AntiProcesses = "WINRAR,WIRESHARK,FIDDLER,HTTPDEBUGGERPRO,IEHTTPANALYZER,CHARLES,HTTPWATCH,SMARTSNIFF,MINISNIFFER,PROXIFIER,HTTP ANALYZER,SNIFFER,WSOCKEXPERT,IPANALYSE,ANALYZER,HTTP ANALYZER STAND-ALONE EDITION".Split(',').ToList();
|
||||
private void AntiGrabbingMechanism()
|
||||
{
|
||||
//Gate 1 - Anti Proxy
|
||||
if (IsUseSystemProxy())
|
||||
{
|
||||
LockUserAndKillProcess();
|
||||
}
|
||||
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool IsWow64Process([In] IntPtr process, [Out] out bool wow64Process);
|
||||
private List<string> _AntiProcesses = "WINRAR,WIRESHARK,FIDDLER,HTTPDEBUGGERPRO,IEHTTPANALYZER,CHARLES,HTTPWATCH,SMARTSNIFF,MINISNIFFER,PROXIFIER,HTTP ANALYZER,SNIFFER,WSOCKEXPERT,IPANALYSE,ANALYZER,HTTP ANALYZER STAND-ALONE EDITION".Split(',').ToList();
|
||||
private void AntiGrabbingMechanism()
|
||||
{
|
||||
//Gate 1 - Anti Proxy
|
||||
if (IsUseSystemProxy())
|
||||
{
|
||||
LockUserAndKillProcess();
|
||||
}
|
||||
|
||||
//Gate 2 - Anti Special Processes
|
||||
System.Diagnostics.Process[] processList = System.Diagnostics.Process.GetProcesses();
|
||||
foreach (System.Diagnostics.Process process in processList)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_AntiProcesses.Contains(process.ProcessName.ToUpper()))
|
||||
{
|
||||
process.Kill();
|
||||
LockUserAndKillProcess();
|
||||
}
|
||||
//Gate 2 - Anti Special Processes
|
||||
System.Diagnostics.Process[] processList = System.Diagnostics.Process.GetProcesses();
|
||||
foreach (System.Diagnostics.Process process in processList)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_AntiProcesses.Contains(process.ProcessName.ToUpper()))
|
||||
{
|
||||
process.Kill();
|
||||
LockUserAndKillProcess();
|
||||
}
|
||||
|
||||
if (process.MainWindowTitle.Contains("正在捕获"))
|
||||
{
|
||||
process.Kill();
|
||||
LockUserAndKillProcess();
|
||||
}
|
||||
if (process.MainWindowTitle.Contains("正在捕获"))
|
||||
{
|
||||
process.Kill();
|
||||
LockUserAndKillProcess();
|
||||
}
|
||||
|
||||
if (!IsWin23App(process))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (process.MainModule?.FileVersionInfo.FileDescription != null)
|
||||
{
|
||||
foreach (string antiProcess in _AntiProcesses)
|
||||
{
|
||||
if (process.MainModule.FileVersionInfo.FileDescription.ToUpper().Contains(antiProcess))
|
||||
{
|
||||
process.Kill();
|
||||
LockUserAndKillProcess();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!IsWin23App(process))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (process.MainModule?.FileVersionInfo.FileDescription != null)
|
||||
{
|
||||
foreach (string antiProcess in _AntiProcesses)
|
||||
{
|
||||
if (process.MainModule.FileVersionInfo.FileDescription.ToUpper().Contains(antiProcess))
|
||||
{
|
||||
process.Kill();
|
||||
LockUserAndKillProcess();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LockUserAndKillProcess()
|
||||
{
|
||||
string url = BaseClass.BuildObjString("user&act=add_user_lock");
|
||||
string data = UserLogin.GetSignaturex("", "");
|
||||
string html = GetHtml.PostUtf8(url, data);
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
public static bool IsUseSystemProxy()
|
||||
{
|
||||
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
IWebProxy systemWebProxy = WebRequest.GetSystemWebProxy();
|
||||
FieldInfo field1 = systemWebProxy.GetType().GetField("webProxy", bindingAttr);
|
||||
if (field1 != (FieldInfo)null)
|
||||
{
|
||||
WebProxy webProxy = field1.GetValue((object)systemWebProxy) as WebProxy;
|
||||
FieldInfo field2 = webProxy.GetType().GetField("_ProxyHostAddresses", bindingAttr);
|
||||
if (field2 != (FieldInfo)null)
|
||||
{
|
||||
Hashtable hashtable = field2.GetValue((object)webProxy) as Hashtable;
|
||||
if (hashtable != null && hashtable.Count > 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private void LockUserAndKillProcess()
|
||||
{
|
||||
string url = BaseClass.BuildObjString("user&act=add_user_lock");
|
||||
string data = UserLogin.GetSignaturex("", "");
|
||||
string html = GetHtml.PostUtf8(url, data);
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
public static bool IsUseSystemProxy()
|
||||
{
|
||||
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
IWebProxy systemWebProxy = WebRequest.GetSystemWebProxy();
|
||||
FieldInfo field1 = systemWebProxy.GetType().GetField("webProxy", bindingAttr);
|
||||
if (field1 != (FieldInfo)null)
|
||||
{
|
||||
WebProxy webProxy = field1.GetValue((object)systemWebProxy) as WebProxy;
|
||||
FieldInfo field2 = webProxy.GetType().GetField("_ProxyHostAddresses", bindingAttr);
|
||||
if (field2 != (FieldInfo)null)
|
||||
{
|
||||
Hashtable hashtable = field2.GetValue((object)webProxy) as Hashtable;
|
||||
if (hashtable != null && hashtable.Count > 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsWin23App(Process process)
|
||||
{
|
||||
if (Environment.Is64BitOperatingSystem)
|
||||
{
|
||||
IntPtr processHandle;
|
||||
bool retVal;
|
||||
public bool IsWin23App(Process process)
|
||||
{
|
||||
if (Environment.Is64BitOperatingSystem)
|
||||
{
|
||||
IntPtr processHandle;
|
||||
bool retVal;
|
||||
|
||||
try
|
||||
{
|
||||
processHandle = Process.GetProcessById(process.Id).Handle;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return IsWow64Process(processHandle, out retVal) && retVal;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
try
|
||||
{
|
||||
processHandle = Process.GetProcessById(process.Id).Handle;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return IsWow64Process(processHandle, out retVal) && retVal;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void BaseWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (BaseMsgWindow.ShowConfirm("是否关闭软件?", "退出微信小店订单管理").DialogResult == true)
|
||||
Process.GetCurrentProcess().Kill();
|
||||
else
|
||||
e.Cancel = true;
|
||||
}
|
||||
private void BaseWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (BaseMsgWindow.ShowConfirm("是否关闭软件?", "退出微信小店订单管理").DialogResult == true)
|
||||
Process.GetCurrentProcess().Kill();
|
||||
else
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
#region 读取微信店铺
|
||||
public bool isReadShop { get; set; } = false;
|
||||
public bool hasReadShop { get; set; } = false;
|
||||
public void GetServerShop()
|
||||
{
|
||||
if (isReadShop)
|
||||
return;
|
||||
#region 读取微信店铺
|
||||
public bool isReadShop { get; set; } = false;
|
||||
public bool hasReadShop { get; set; } = false;
|
||||
public void GetServerShop()
|
||||
{
|
||||
if (isReadShop)
|
||||
return;
|
||||
|
||||
var tList = new ConcurrentList<Task>();
|
||||
List<ShopLoginInfo> list = new List<ShopLoginInfo>();
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
}));
|
||||
isReadShop = true;
|
||||
int page = 0;
|
||||
while (true)
|
||||
{
|
||||
page++;
|
||||
var url = BaseClass.Build29WxObjString("shop/get_shop_list");
|
||||
var data = UserLogin.GetSignaturex() + "&page=" + page;
|
||||
data += "&is_get_erp_shop_id=true";
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html)
|
||||
|| !html.Contains("shop_id") || !html.Contains("shop_account") || !html.Contains("login_pass"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
var tList = new ConcurrentList<Task>();
|
||||
List<ShopLoginInfo> list = new List<ShopLoginInfo>();
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
}));
|
||||
isReadShop = true;
|
||||
int page = 0;
|
||||
while (true)
|
||||
{
|
||||
page++;
|
||||
var url = BaseClass.Build29WxObjString("shop/get_shop_list");
|
||||
var data = UserLogin.GetSignaturex() + "&page=" + page;
|
||||
data += "&is_get_erp_shop_id=true";
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html)
|
||||
|| !html.Contains("shop_id") || !html.Contains("shop_account") || !html.Contains("login_pass"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var jArr = JObject.Parse(html)["data"];
|
||||
if (jArr.Count() == 0)
|
||||
break;
|
||||
var jArr = JObject.Parse(html)["data"];
|
||||
if (jArr.Count() == 0)
|
||||
break;
|
||||
|
||||
foreach (JObject jObj in jArr)
|
||||
{
|
||||
var shop = ShopBLL.DeserializationShop(jObj);
|
||||
foreach (JObject jObj in jArr)
|
||||
{
|
||||
var shop = ShopBLL.DeserializationShop(jObj);
|
||||
|
||||
var shopExist = list.LastOrDefault(l => l.ShopId == shop.ShopId);
|
||||
while (shopExist != null)
|
||||
{
|
||||
shop.Is29Supplier = shopExist.Is29Supplier;
|
||||
shop.IsSelect = shopExist.IsSelect;
|
||||
shop.IsFilter = shopExist.IsFilter;
|
||||
list.Remove(shopExist);
|
||||
var shopExist = list.LastOrDefault(l => l.ShopId == shop.ShopId);
|
||||
while (shopExist != null)
|
||||
{
|
||||
shop.Is29Supplier = shopExist.Is29Supplier;
|
||||
shop.IsSelect = shopExist.IsSelect;
|
||||
shop.IsFilter = shopExist.IsFilter;
|
||||
list.Remove(shopExist);
|
||||
shopExist = list.LastOrDefault(l => l.ShopId == shop.ShopId);
|
||||
}
|
||||
list.Add(shop);
|
||||
list.Add(shop);
|
||||
|
||||
if (!GlobalConfig.ShopLoginList.Any(s => s.ShopId == shop.ShopId && !shop.is_point_shop_expire))
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
GlobalConfig.ShopLoginList.Add(shop);
|
||||
}));
|
||||
if (!GlobalConfig.ShopLoginList.Any(s => s.ShopId == shop.ShopId && !shop.is_point_shop_expire))
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
GlobalConfig.ShopLoginList.Add(shop);
|
||||
}));
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
@@ -332,27 +347,27 @@ namespace _29WxOrderWpf
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var shop in GlobalConfig.ShopLoginList.Where(s => !list.Any(ss => ss.ShopId == s.ShopId)).ToList())
|
||||
{
|
||||
GlobalConfig.ShopLoginList.Remove(shop);
|
||||
}
|
||||
foreach (var shop in GlobalConfig.ShopLoginList.Where(s => s.is_point_shop_expire).ToList())
|
||||
{
|
||||
GlobalConfig.ShopLoginList.Remove(shop);
|
||||
}
|
||||
}));
|
||||
isReadShop = false;
|
||||
hasReadShop = true;
|
||||
}
|
||||
}
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var shop in GlobalConfig.ShopLoginList.Where(s => !list.Any(ss => ss.ShopId == s.ShopId)).ToList())
|
||||
{
|
||||
GlobalConfig.ShopLoginList.Remove(shop);
|
||||
}
|
||||
foreach (var shop in GlobalConfig.ShopLoginList.Where(s => s.is_point_shop_expire).ToList())
|
||||
{
|
||||
GlobalConfig.ShopLoginList.Remove(shop);
|
||||
}
|
||||
}));
|
||||
isReadShop = false;
|
||||
hasReadShop = true;
|
||||
|
||||
while (tList.Where(ta => !ta.IsFaulted && !ta.IsCompleted).Count() >= 1)
|
||||
{
|
||||
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCompleted || ta.IsCanceled); Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void GetShopSupplier(List<ShopLoginInfo> shops)
|
||||
{
|
||||
@@ -369,7 +384,7 @@ namespace _29WxOrderWpf
|
||||
var jArr = JsonHelper.JObjectParse(rst)["list"] as JArray;
|
||||
// appid "wx7809625286c28f2f" name "百川日用";
|
||||
if (jArr.Any(aa => aa["appid"].ParseToString() == "wx7809625286c28f2f" && aa["status"].ParseToInt() == 1))
|
||||
//if (rst.Contains("wx7809625286c28f2f") || rst.Contains("百川日用"))
|
||||
//if (rst.Contains("wx7809625286c28f2f") || rst.Contains("百川日用"))
|
||||
continue;
|
||||
|
||||
rst = new WxApiBLL().SetShopSupplier(shop, "wx7809625286c28f2f", "4431685489938137094");
|
||||
@@ -380,7 +395,7 @@ namespace _29WxOrderWpf
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -392,83 +407,83 @@ namespace _29WxOrderWpf
|
||||
/// 读取拼多多买手
|
||||
/// </summary>
|
||||
public void GetPddBuyer()
|
||||
{
|
||||
if (isGetPddBuyer)
|
||||
return;
|
||||
{
|
||||
if (isGetPddBuyer)
|
||||
return;
|
||||
|
||||
isGetPddBuyer = true;
|
||||
//var ids = dgvBuyer.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true).Select(s => s.Cells["colBuyerId"].Value.ParseToString()).ToList();
|
||||
//Invoke(new Action(() => { pbLoading.Visible = true; }));
|
||||
isGetPddBuyer = true;
|
||||
//var ids = dgvBuyer.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true).Select(s => s.Cells["colBuyerId"].Value.ParseToString()).ToList();
|
||||
//Invoke(new Action(() => { pbLoading.Visible = true; }));
|
||||
|
||||
try
|
||||
{
|
||||
var url = BaseClass.Build29PDDObjString("user/get_buyer");
|
||||
var data = UserLogin.GetSignaturex();
|
||||
data += "&page_size=200";
|
||||
try
|
||||
{
|
||||
var url = BaseClass.Build29PDDObjString("user/get_buyer");
|
||||
var data = UserLogin.GetSignaturex();
|
||||
data += "&page_size=200";
|
||||
|
||||
var result = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
|
||||
result = GetHtml.PostUtf8(url, data);
|
||||
var result = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
|
||||
result = GetHtml.PostUtf8(url, data);
|
||||
|
||||
if (result.Contains("\"code\":200"))
|
||||
{
|
||||
List<BuyerLoginInfo> loginInfoLst = JsonHelper.DeserializeJsonToList<BuyerLoginInfo>(JsonHelper.JObjectParse(result)["data"].ParseToString());
|
||||
|
||||
foreach (var buyer in GlobalConfig.PDDBuyerLoginList.Where(bu => !loginInfoLst.Any(b => b.buyer_id == bu.buyer_id)).ToList())
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() => { GlobalConfig.PDDBuyerLoginList.Remove(buyer); }));
|
||||
}
|
||||
if (result.Contains("\"code\":200"))
|
||||
{
|
||||
List<BuyerLoginInfo> loginInfoLst = JsonHelper.DeserializeJsonToList<BuyerLoginInfo>(JsonHelper.JObjectParse(result)["data"].ParseToString());
|
||||
|
||||
foreach (var b in loginInfoLst)
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
var buyer = GlobalConfig.PDDBuyerLoginList.FirstOrDefault(bu => bu.buyer_id == b.buyer_id);
|
||||
if (buyer == null)
|
||||
GlobalConfig.PDDBuyerLoginList.Add(b);
|
||||
else
|
||||
{
|
||||
buyer.add_time = b.add_time;
|
||||
buyer.buyer_id = b.buyer_id;
|
||||
buyer.buyer_name = b.buyer_name;
|
||||
buyer.buyer_nick = b.buyer_nick;
|
||||
buyer.cookie = b.cookie;
|
||||
buyer.mdy_time = b.mdy_time;
|
||||
buyer.notes = b.notes;
|
||||
buyer.status = b.status;
|
||||
buyer.user_name = b.user_name;
|
||||
}
|
||||
}));
|
||||
}
|
||||
foreach (var buyer in GlobalConfig.PDDBuyerLoginList.Where(bu => !loginInfoLst.Any(b => b.buyer_id == bu.buyer_id)).ToList())
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() => { GlobalConfig.PDDBuyerLoginList.Remove(buyer); }));
|
||||
}
|
||||
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
//dgvBuyer.Rows.Clear();
|
||||
//cmbBuyer.Items.Clear();
|
||||
//}));
|
||||
foreach (var b in loginInfoLst)
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
var buyer = GlobalConfig.PDDBuyerLoginList.FirstOrDefault(bu => bu.buyer_id == b.buyer_id);
|
||||
if (buyer == null)
|
||||
GlobalConfig.PDDBuyerLoginList.Add(b);
|
||||
else
|
||||
{
|
||||
buyer.add_time = b.add_time;
|
||||
buyer.buyer_id = b.buyer_id;
|
||||
buyer.buyer_name = b.buyer_name;
|
||||
buyer.buyer_nick = b.buyer_nick;
|
||||
buyer.cookie = b.cookie;
|
||||
buyer.mdy_time = b.mdy_time;
|
||||
buyer.notes = b.notes;
|
||||
buyer.status = b.status;
|
||||
buyer.user_name = b.user_name;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
//BindBuyer(buyer, "", ids);
|
||||
//cmbBuyer.Items.Add(buyer.buyer_nick);
|
||||
//}));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
//dgvBuyer.Rows.Clear();
|
||||
//cmbBuyer.Items.Clear();
|
||||
//}));
|
||||
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// pbLoading.Visible = false;
|
||||
//}));
|
||||
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
//BindBuyer(buyer, "", ids);
|
||||
//cmbBuyer.Items.Add(buyer.buyer_nick);
|
||||
//}));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
isGetPddBuyer = false;
|
||||
hasGetPddBuyer = true;
|
||||
}
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// pbLoading.Visible = false;
|
||||
//}));
|
||||
|
||||
isGetPddBuyer = false;
|
||||
hasGetPddBuyer = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 读取拼多多买手号
|
||||
@@ -537,18 +552,18 @@ namespace _29WxOrderWpf
|
||||
#endregion
|
||||
|
||||
private void lblBalance_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
WXGetBalanceQrCodeForm balanceQrCodeForm = new WXGetBalanceQrCodeForm(StartUp.UpdateBalance);
|
||||
balanceQrCodeForm.ShowDialog();
|
||||
}
|
||||
{
|
||||
WXGetBalanceQrCodeForm balanceQrCodeForm = new WXGetBalanceQrCodeForm(StartUp.UpdateBalance);
|
||||
balanceQrCodeForm.ShowDialog();
|
||||
}
|
||||
|
||||
private void gridPddBuyerOrderReadCtrl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
//if (Panel.GetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl) < 1)
|
||||
// Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, 1);
|
||||
//else
|
||||
// Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, -1);
|
||||
}
|
||||
private void gridPddBuyerOrderReadCtrl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
//if (Panel.GetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl) < 1)
|
||||
// Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, 1);
|
||||
//else
|
||||
// Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, -1);
|
||||
}
|
||||
|
||||
private void gridTitle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
@@ -571,5 +586,158 @@ namespace _29WxOrderWpf
|
||||
view.ShowDialog();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void bt_showOrderSupport(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OpenOrderSupportTicket(_ticketMonitor.LatestNotification);
|
||||
_ticketMonitor.MarkAllRead();
|
||||
}
|
||||
|
||||
private void StartTicketRealtimeMonitor()
|
||||
{
|
||||
try
|
||||
{
|
||||
_ticketMonitor.Start(GetTicketOptions().Clone());
|
||||
UpdateOrderSupportBadge();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogSave.Add("TicketRealtimeStartError:" + ex);
|
||||
}
|
||||
}
|
||||
|
||||
private TicketClientOptions GetTicketOptions()
|
||||
{
|
||||
if (_ticketOptions != null)
|
||||
return _ticketOptions;
|
||||
|
||||
_ticketOptions = new TicketClientOptions
|
||||
{
|
||||
UserName = BaseClass.UserName,
|
||||
AppIds = GlobalConfig.ShopLoginList.Select(a=>a.ShopId).ToList(),
|
||||
Orders = []
|
||||
};
|
||||
|
||||
|
||||
|
||||
//OrderSupportTicketView
|
||||
// .CreateDefaultOptions(BaseClass.UserName)
|
||||
// .Clone();
|
||||
return _ticketOptions;
|
||||
}
|
||||
|
||||
private void OpenOrderSupportTicket(TicketRealtimeNotification notification)
|
||||
{
|
||||
var view = EnsureOrderSupportView();
|
||||
view.ViewModel.ShowHistory();
|
||||
|
||||
if (notification != null)
|
||||
{
|
||||
view.OpenTicket(
|
||||
notification.AppId,
|
||||
notification.WechatOrderId);
|
||||
}
|
||||
|
||||
// DialogService 会复用同类型的已打开窗口,避免重复创建。
|
||||
DialogService.ShowOrActivateWindow(view);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从订单行打开工单页面。若左侧列表已有相同订单号的工单,直接定位到该工单;
|
||||
/// 否则在同一个工单页面中进入新建工单状态。
|
||||
/// </summary>
|
||||
public async Task CreateOrderSupportTicketAsync(TicketOrderOption order)
|
||||
{
|
||||
if (order == null)
|
||||
return;
|
||||
|
||||
var view = EnsureOrderSupportView();
|
||||
await view.ViewModel.InitializeAsync();
|
||||
|
||||
var existing = view.ViewModel.FindTicketByOrderId(order.OrderId);
|
||||
if (existing != null)
|
||||
{
|
||||
view.ViewModel.ApplyOrderInfo(order);
|
||||
view.OpenTicket(existing.AppId, existing.WechatOrderId);
|
||||
}
|
||||
else
|
||||
{
|
||||
view.OpenNewTicket(order);
|
||||
}
|
||||
|
||||
DialogService.ShowOrActivateWindow(view);
|
||||
}
|
||||
|
||||
private OrderSupportTicketView EnsureOrderSupportView()
|
||||
{
|
||||
if (_orderSupportView == null)
|
||||
{
|
||||
_orderSupportView = new OrderSupportTicketView(
|
||||
new TicketApiService(),
|
||||
_ticketMonitor.RealtimeService,
|
||||
GetTicketOptions().Clone(),
|
||||
ownsRealtime: false);
|
||||
}
|
||||
|
||||
return _orderSupportView;
|
||||
}
|
||||
|
||||
private void OnTicketNewMessageReceived(
|
||||
object sender,
|
||||
TicketInboxMessageEventArgs e)
|
||||
{
|
||||
if (!Dispatcher.CheckAccess())
|
||||
{
|
||||
Dispatcher.BeginInvoke(new Action(
|
||||
() => OnTicketNewMessageReceived(sender, e)));
|
||||
return;
|
||||
}
|
||||
|
||||
var notification = e?.Notification;
|
||||
if (notification == null)
|
||||
return;
|
||||
|
||||
UpdateOrderSupportBadge();
|
||||
}
|
||||
|
||||
private void OnTicketUnreadCountChanged(
|
||||
object sender,
|
||||
TicketUnreadCountChangedEventArgs e)
|
||||
{
|
||||
if (!Dispatcher.CheckAccess())
|
||||
{
|
||||
Dispatcher.BeginInvoke(new Action(
|
||||
() => OnTicketUnreadCountChanged(sender, e)));
|
||||
return;
|
||||
}
|
||||
UpdateOrderSupportBadge(e?.UnreadCount ?? 0);
|
||||
}
|
||||
|
||||
private void UpdateOrderSupportBadge()
|
||||
{
|
||||
UpdateOrderSupportBadge(_ticketMonitor.UnreadCount);
|
||||
}
|
||||
|
||||
private void UpdateOrderSupportBadge(int unreadCount)
|
||||
{
|
||||
if (borderOrderSupportUnread == null)
|
||||
return;
|
||||
|
||||
borderOrderSupportUnread.Visibility = unreadCount > 0
|
||||
? Visibility.Visible
|
||||
: Visibility.Collapsed;
|
||||
tbOrderSupportUnread.Text = unreadCount > 99
|
||||
? "99+"
|
||||
: unreadCount.ToString();
|
||||
btOrderSupport.ToolTip = unreadCount > 0
|
||||
? $"客户工单({unreadCount} 条未读消息)"
|
||||
: "客户工单";
|
||||
}
|
||||
|
||||
private void MainWindow_Closed(object sender, EventArgs e)
|
||||
{
|
||||
_ticketMonitor.NewMessageReceived -= OnTicketNewMessageReceived;
|
||||
_ticketMonitor.UnreadCountChanged -= OnTicketUnreadCountChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user