优化买手单读取

This commit is contained in:
wule committed 2026-10-20 14:13:55 +08:00
1 parent 7380763c1d
commit fd07c9ba40
8 files changed
+4381 -127

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
@@ -98,9 +98,9 @@
<Button
x:Name="btnNextBuyer"
Grid.Column="8"
Padding="4,0"
Height="24"
Margin="4,0,0,0"
Padding="4,0"
Click="btnNextBuyer_Click"
Content="下一个买手"
Style="{StaticResource BasePageButtonStyle}" />
@@ -273,7 +273,8 @@
Margin="180,0,0,0"
VerticalAlignment="Center"
Panel.ZIndex="1"
Content="正在操作:" />
d:Content="正在操作:"
Content="{Binding LblMsgStr}" />
<TabControl
x:Name="tabOrderType"
@@ -21,7 +21,9 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
@@ -52,22 +54,43 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
/// <summary>
/// PDDBuyerOrderReadCtrl.xaml 的交互逻辑
/// </summary>
public partial class PDDBuyerOrderReadCtrl : UserControl
public partial class PDDBuyerOrderReadCtrl : UserControl, INotifyPropertyChanged
{
private static readonly object locker = new object();
string lblMsgStr = "当前没有任何操作";
public string LblMsgStr
{
get { return lblMsgStr; }
set
{
if (lblMsgStr != value)
{
lblMsgStr = value;
OnPropertyChanged(new PropertyChangedEventArgs("LblMsgStr"));
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(PropertyChangedEventArgs propertyChangedEventArgs)
{
PropertyChanged?.Invoke(this, propertyChangedEventArgs);
}
Dictionary<BuyerLoginInfo, PddPickInfo> dicPddPickInfo = new Dictionary<BuyerLoginInfo, PddPickInfo>();
ConcurrentList<yh_sync_logistics> lstSyncLogistics = new ConcurrentList<yh_sync_logistics>();
ChromiumWebBrowser cefWebBrowser = null;
public string cefAddress = "";
ChromiumWebBrowser cefShowShopOrderLstWebBrowser = null;
public string cefAddress = "";
public static ConcurrentList<PddBuyerOrderLiteInfo> lstPddBuyerOrderInfoLite { get; set; } = new ConcurrentList<PddBuyerOrderLiteInfo>();
public static ObservableCollection<PddBuyerOrderLiteInfo> lstFilterPddBuyerOrderInfoLite { get; set; } = new ObservableCollection<PddBuyerOrderLiteInfo>();
public static ConcurrentList<PddBuyerAfterSaleLiteInfo> lstPddBuyerAfterSaleInfoLite { get; set; } = new ConcurrentList<PddBuyerAfterSaleLiteInfo>();
public static ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo> lstFilterPddBuyerAfterSaleInfoLite { get; set; } = new ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo>();
public static ConcurrentList<string> lstPddBuyerOrderVoidAfterSaleOrderSn { get; set; } = new ConcurrentList<string>();
public CancellationTokenSource cancellationTokenSource { get; set; } = new CancellationTokenSource();
//public ChromiumWebBrowser cefWebBrowser = null;
public BuyerReadOrderConfig buyerReadOrderConfig = new BuyerReadOrderConfig();
public DateTime nextGetOrderTime = DateTime.MinValue;
public DateTime lastCefReadOrderTime = DateTime.Now;
@@ -105,7 +128,9 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
public PDDBuyerOrderReadCtrl()
{
InitializeComponent();
}
this.lblMsg.DataContext = this;
}
void filterBuyerOrder()
{
@@ -157,8 +182,9 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
this.lbPddBuyer.ItemsSource = GlobalConfig.PDDBuyerLoginList;
{
//this.DataContext = this;
this.lbPddBuyer.ItemsSource = GlobalConfig.PDDBuyerLoginList;
buyerReadOrderConfig = NaiBa.Util.Helper.ConfigHelper.LoadConfig<BuyerReadOrderConfig>("pdd_buyer_read_order_config");
if (buyerReadOrderConfig == null)
@@ -262,24 +288,46 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
{
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
{
Thread.Sleep(1);
Dispatcher.Invoke(new Action(() =>
{
buyer.wpf_browser = WPFCEFBrowser.CreateChromiumWebBrowser("about:blank", false);
LocalResourceRequestHandler resourceRequestHandler = new LocalResourceRequestHandler();
resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete;
resourceRequestHandler.BeforeResourceLoadEvent += RequestHandler_BeforeResourceLoad;
buyer.wpf_browser.RequestHandler = new LocalRequestHandler(resourceRequestHandler);
var lifeSapnHandler = new LocalLifeSpanHandler(PopWindowType.SelfWindow);
buyer.wpf_browser.LifeSpanHandler = lifeSapnHandler;
buyer.wpf_browser.KeyboardHandler = new KeyboardHandler();
buyer.wpf_browser.FrameLoadEnd += CefWebBrowser_FrameLoadEnd;
buyer.wpf_browser.AddressChanged += CefWebBrowser_AddressChanged;
buyer.wpf_browser.LoadError += CefWebBrowser_LoadError;
Grid.SetRow(buyer.wpf_browser, 0);
this.GridCef.Children.Add(buyer.wpf_browser);
}));
}
Thread.Sleep(1);
Dispatcher.Invoke(new Action(() =>
{
if (cefWebBrowser == null)
{
cefWebBrowser = WPFCEFBrowser.CreateChromiumWebBrowser("about:blank", false);
LocalResourceRequestHandler resourceRequestHandler = new LocalResourceRequestHandler();
resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete;
resourceRequestHandler.BeforeResourceLoadEvent += RequestHandler_BeforeResourceLoad;
cefWebBrowser.RequestHandler = new LocalRequestHandler(resourceRequestHandler);
var lifeSapnHandler = new LocalLifeSpanHandler(PopWindowType.SelfWindow);
cefWebBrowser.LifeSpanHandler = lifeSapnHandler;
cefWebBrowser.KeyboardHandler = new CefKeyboardHandler();
cefWebBrowser.FrameLoadEnd += CefWebBrowser_FrameLoadEnd;
cefWebBrowser.AddressChanged += CefWebBrowser_AddressChanged;
cefWebBrowser.LoadError += CefWebBrowser_LoadError;
Grid.SetRow(cefWebBrowser, 0);
this.GridCef.Children.Add(cefWebBrowser);
}
if (buyer.wpf_browser == null)
buyer.wpf_browser = cefWebBrowser;
if (cefShowShopOrderLstWebBrowser == null)
{
cefShowShopOrderLstWebBrowser = WPFCEFBrowser.CreateChromiumWebBrowser("about:blank", false);
LocalResourceRequestHandler resourceRequestHandler = new LocalResourceRequestHandler();
resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete;
resourceRequestHandler.BeforeResourceLoadEvent += RequestHandler_BeforeResourceLoad;
cefShowShopOrderLstWebBrowser.RequestHandler = new LocalRequestHandler(resourceRequestHandler);
var lifeSapnHandler = new LocalLifeSpanHandler(PopWindowType.SelfWindow);
cefShowShopOrderLstWebBrowser.LifeSpanHandler = lifeSapnHandler;
cefShowShopOrderLstWebBrowser.KeyboardHandler = new CefKeyboardHandler();
cefShowShopOrderLstWebBrowser.FrameLoadEnd += CefWebBrowser_FrameLoadEnd;
cefShowShopOrderLstWebBrowser.AddressChanged += CefWebBrowser_AddressChanged;
cefShowShopOrderLstWebBrowser.LoadError += CefWebBrowser_LoadError;
Grid.SetRow(cefShowShopOrderLstWebBrowser, 0);
this.GridCef.Children.Add(cefShowShopOrderLstWebBrowser);
}
}));
}
}
private void CefWebBrowser_LoadError(object sender, LoadErrorEventArgs e)
@@ -317,11 +365,17 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
var noPickupPackageData = BaseRegex.GetJsonObjStrJson(ref data1, "noPickupPackageData").FirstOrDefault();
if (!noPickupPackageData.IsNullOrEmpty() && send1 is ChromiumWebBrowser cef)
{
var buyer = GlobalConfig.PDDBuyerLoginList.FirstOrDefault(buy => buy.wpf_browser == cef);
if (buyer != null)
var cookies = WPFCEFBrowser.GetCookieList("yangkeduo.com", cef.GetCookieManager(null));
var pddUserId = cookies.FirstOrDefault(c => c.Name == "pdd_user_id")?.Value;
if (!string.IsNullOrEmpty(pddUserId))
{
dicPddPickInfo[buyer] = JsonHelper.DeserializeJsonToObject<PddPickInfo>(noPickupPackageData);
SetPickUpNo(dicPddPickInfo[buyer]);
var buyer = GlobalConfig.PDDBuyerLoginList.FirstOrDefault(buy => buy.buyer_id == pddUserId);
if (buyer != null)
{
dicPddPickInfo[buyer] = JsonHelper.DeserializeJsonToObject<PddPickInfo>(noPickupPackageData);
SetPickUpNo(dicPddPickInfo[buyer]);
}
}
}
}
@@ -393,8 +447,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
}
// 读订单
if (/*(cefAddress.Contains("orders.html")) &&*/ url1.StartsWith("https://mobile.yangkeduo.com/proxy/api/api/aristotle/order_list_v"))
//https://mobile.yangkeduo.com/proxy/api/api/aristotle/order_list_v4?pdduid=6766109923730
if (/*(cefAddress.Contains("orders.html")) &&*/ url1.StartsWith("https://mobile.yangkeduo.com/proxy/api/api/aristotle/order_list_v")) //https://mobile.yangkeduo.com/proxy/api/api/aristotle/order_list_v4?pdduid=6766109923730
{
await Task.Run(() =>
{
@@ -1411,7 +1464,8 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
TimeSpan PauseTick = new TimeSpan(1);
private void chkAutoReadBuyerOrder_CheckedChanged(object sender, RoutedEventArgs e)
private void chkAutoReadBuyerOrder_CheckedChanged(object sender, RoutedEventArgs e)
{
if (isLoad)
{
@@ -1433,13 +1487,361 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
void GetOrderAndAfterSale()
{
GetPddOrder();
ScrollGetPddOrder();
//MakeWxToPddAfterSales();
nextGetOrderTime = DateTime.Now.AddMinutes(25);
}
void GetPddOrder()
void JsGetPddOrder()
{
isReadBuyerOrder = true;
lstPddBuyerOrderVoidAfterSaleOrderSn.Clear();
if (cancellationTokenSource != null)
cancellationTokenSource.Cancel();
cancellationTokenSource = new CancellationTokenSource();
Task.Run(() =>
{
var tokenSource = cancellationTokenSource;
while (isInitBuyerOrder || isInitBuyerAfterSale)
{
if (tokenSource.IsCancellationRequested)
{
BindBuyerOrderReadInfo(null, "已取消读取");
break;
}
Thread.Sleep(500);
}
currentReadBuyer = "";
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
{
Dispatcher.Invoke(new Action(() =>
{
Panel.SetZIndex(buyer.wpf_browser, maxZIndex++);
if (buyer.IsSelect != true)
{
foreach (var b in GlobalConfig.PDDBuyerLoginList)
{
b.IsSelect = false;
}
buyer.IsSelect = true;
}
}));
if (tokenSource.IsCancellationRequested)
break;
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
if (buyer.status != "在线")
continue;
try
{
bool isInitial = false;
while (isInitial == false)
{
Thread.Sleep(100);
Dispatcher.Invoke(new Action(() =>
{
if (buyer.wpf_browser != null && buyer.wpf_browser.IsBrowserInitialized)
{
var frame = buyer.wpf_browser.GetBrowser().MainFrame;
isInitial = buyer.wpf_browser != null && buyer.wpf_browser.IsBrowserInitialized && frame.IsValid;
}
}));
}
WPFCEFBrowser.DeleteCookie(buyer.wpf_browser.GetCookieManager(null));
var cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(buyer?.cookie);
var t = WPFCEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), buyer.wpf_browser.GetCookieManager(null));
t.Wait();
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/personal.html");
Thread.Sleep(Randomx.GetId(2000, 3000));
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/psnl_goods_help.html?_t_module_name=assistant_search&refer_scene=no_pickup_package_express&refer_page_name=goods_express");
Thread.Sleep(Randomx.GetId(2000, 3000));
string readBuyer = "";
int top = 0;
int times = 0;
#region 售后
if (1 == 1)
{
readBuyer = buyer.buyer_id;
currentReadBuyer = buyer.buyer_id;
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/complaint_list.html?refer_page_name=personal&refer_page_sn=10001&tab=all");
Dispatcher.Invoke(new Action(() =>
{
Panel.SetZIndex(buyer.wpf_browser, maxZIndex++);
if (buyer.IsSelect != true)
{
foreach (var b in GlobalConfig.PDDBuyerLoginList)
{
b.IsSelect = false;
}
buyer.IsSelect = true;
}
}));
Thread.Sleep(Randomx.GetId(2000, 3000));
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 售后读取中"; }));
BindBuyerOrderReadInfo(buyer, "正在读取售后");
top = 0;
times = 0;
lastCefReadOrderTime = DateTime.Now;
while (currentReadBuyer == readBuyer)
{
if (isSkipNext)
break;
if (tokenSource.IsCancellationRequested)
{
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
if (lastCefReadOrderTime < DateTime.Now.AddSeconds(-30))
{
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
if (buyer.status != "在线")
{
BindBuyerOrderReadInfo(buyer, "店铺掉线");
break;
}
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
break;
}
top += Randomx.GetId(450, 600);
Thread.Sleep(Randomx.GetId(100, 300));
var jsStr = @"window.scroll({
top: document.body.scrollHeight,
left: 0,
behavior: 'smooth' // 可选,使滚动平滑
});";
jsStr = @"window.scroll({
top: " + top + @",
left: 0,
behavior: 'smooth' // 可选,使滚动平滑
});";
//var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr);
//t1.Wait(1000);
var client = buyer.wpf_browser.GetDevToolsClient();
if (client != null)
{
var result = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
result.Wait(5000);
}
}
if (tokenSource.IsCancellationRequested)
{
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
Thread.Sleep(Randomx.GetId(2000, 3000));
}
#endregion
// 待发货
readBuyer = buyer.buyer_id;
currentReadBuyer = buyer.buyer_id;
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/orders.html?type=2");
Dispatcher.Invoke(new Action(() =>
{
Panel.SetZIndex(buyer.wpf_browser, maxZIndex++);
if (buyer.IsSelect != true)
{
foreach (var b in GlobalConfig.PDDBuyerLoginList)
{
b.IsSelect = false;
}
buyer.IsSelect = true;
}
}));
Thread.Sleep(Randomx.GetId(2000, 3000));
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 待发货读取中"; }));
BindBuyerOrderReadInfo(buyer, "正在读取待发货");
top = 0;
lastCefReadOrderTime = DateTime.Now;
while (currentReadBuyer == readBuyer)
{
if (isSkipNext)
break;
if (tokenSource.IsCancellationRequested)
{
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
if (lastCefReadOrderTime < DateTime.Now.AddSeconds(-30))
{
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
if (buyer.status != "在线")
{
BindBuyerOrderReadInfo(buyer, "店铺掉线");
break;
}
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
break;
}
if (times % 100 == 0)
{
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
}
if (buyer.status != "在线")
break;
times++;
top += Randomx.GetId(450, 600);
Thread.Sleep(Randomx.GetId(100, 300));
var jsStr = @"window.scroll({
top: document.body.scrollHeight,
left: 0,
behavior: 'smooth' // 可选,使滚动平滑
});";
jsStr = @"window.scroll({
top: " + top + @",
left: 0,
behavior: 'smooth' // 可选,使滚动平滑
});";
//var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr);
//t1.Wait(1000);
var client = buyer.wpf_browser.GetDevToolsClient();
if (client != null)
{
var result = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
result.Wait(5000);
}
}
if (isSkipNext)
{
isSkipNext = false;
continue;
}
if (tokenSource.IsCancellationRequested)
{
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
Thread.Sleep(Randomx.GetId(2000, 3000));
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 已发货读取中"; }));
BindBuyerOrderReadInfo(buyer, "正在读取已发货");
// 已发货
readBuyer = buyer.buyer_id;
currentReadBuyer = buyer.buyer_id;
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/orders.html?type=3");
Dispatcher.Invoke(new Action(() =>
{
Panel.SetZIndex(buyer.wpf_browser, maxZIndex++);
if (buyer.IsSelect != true)
{
foreach (var b in GlobalConfig.PDDBuyerLoginList)
{
b.IsSelect = false;
}
buyer.IsSelect = true;
}
}));
Thread.Sleep(Randomx.GetId(2000, 3000));
top = 0;
lastCefReadOrderTime = DateTime.Now;
while (currentReadBuyer == readBuyer)
{
if (isSkipNext)
break;
if (tokenSource.IsCancellationRequested)
{
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
if (lastCefReadOrderTime < DateTime.Now.AddSeconds(-30))
{
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
if (buyer.status != "在线")
{
BindBuyerOrderReadInfo(buyer, "店铺掉线");
break;
}
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
break;
}
top += Randomx.GetId(450, 600);
Thread.Sleep(Randomx.GetId(100, 300));
var jsStr = @"window.scroll({
top: document.body.scrollHeight,
left: 0,
behavior: 'smooth' // 可选,使滚动平滑
});";
jsStr = @"window.scroll({
top: " + top + @",
left: 0,
behavior: 'smooth' // 可选,使滚动平滑
});";
//var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr);
//t1.Wait(1000);
var client = buyer.wpf_browser.GetDevToolsClient();
if (client != null)
{
var result = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
result.Wait(5000);
}
}
if (isSkipNext)
{
isSkipNext = false;
continue;
}
if (tokenSource.IsCancellationRequested)
{
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
}
catch (Exception ex)
{
if (isSkipNext)
{
isSkipNext = false;
continue;
}
}
Thread.Sleep(Randomx.GetId(6000, 8000));
}
isReadBuyerOrder = false;
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = "订单读取已结束,等待下次读取"; }));
BindBuyerOrderReadInfo(null, "订单读取已结束,等待下次读取");
}, cancellationTokenSource.Token);
}
void ScrollGetPddOrder()
{
isReadBuyerOrder = true;
lstPddBuyerOrderVoidAfterSaleOrderSn.Clear();
@@ -1455,7 +1857,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
{
if (tokenSource.IsCancellationRequested)
{
BindBuyer(null, "已取消读取");
BindBuyerOrderReadInfo(null, "已取消读取");
break;
}
Thread.Sleep(500);
@@ -1485,17 +1887,6 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
if (buyer.status != "在线")
continue;
//var row = dgvBuyer.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colBuyerNick"].Value.ParseToString() == buyer.buyer_nick);
//if (row == null)
//{
// continue;
//}
//if (row.Cells["colSelect"].Value.ParseToBool() != true)
//{
// Invoke(new Action(() => { row.Cells["colMessage"].Value = "未勾选买手号,跳过"; }));
// continue;
//}
try
{
bool isInitial = false;
@@ -1518,13 +1909,13 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
var t = WPFCEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), buyer.wpf_browser.GetCookieManager(null));
t.Wait();
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/psnl_goods_help.html?_t_module_name=assistant_search&refer_scene=no_pickup_package_express&refer_page_name=goods_express");
Thread.Sleep(Randomx.GetId(2000, 3000));
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/personal.html");
Thread.Sleep(Randomx.GetId(2000, 3000));
string readBuyer = "";
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/psnl_goods_help.html?_t_module_name=assistant_search&refer_scene=no_pickup_package_express&refer_page_name=goods_express");
Thread.Sleep(Randomx.GetId(2000, 3000));
string readBuyer = "";
int top = 0;
int times = 0;
@@ -1551,7 +1942,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
Thread.Sleep(Randomx.GetId(2000, 3000));
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 售后读取中"; }));
BindBuyer(buyer, "正在读取售后");
BindBuyerOrderReadInfo(buyer, "正在读取售后");
top = 0;
times = 0;
@@ -1563,7 +1954,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
if (tokenSource.IsCancellationRequested)
{
BindBuyer(buyer, "已取消读取");
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
@@ -1572,10 +1963,10 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
if (buyer.status != "在线")
{
BindBuyer(buyer, "店铺掉线");
BindBuyerOrderReadInfo(buyer, "店铺掉线");
break;
}
BindBuyer(buyer, "停滞时间超过30秒,跳过");
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
break;
}
@@ -1603,7 +1994,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
}
if (tokenSource.IsCancellationRequested)
{
BindBuyer(buyer, "已取消读取");
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
Thread.Sleep(Randomx.GetId(2000, 3000));
@@ -1631,7 +2022,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
Thread.Sleep(Randomx.GetId(2000, 3000));
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 待发货读取中"; }));
BindBuyer(buyer, "正在读取待发货");
BindBuyerOrderReadInfo(buyer, "正在读取待发货");
top = 0;
lastCefReadOrderTime = DateTime.Now;
@@ -1642,7 +2033,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
if (tokenSource.IsCancellationRequested)
{
BindBuyer(buyer, "已取消读取");
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
@@ -1651,10 +2042,10 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
if (buyer.status != "在线")
{
BindBuyer(buyer, "店铺掉线");
BindBuyerOrderReadInfo(buyer, "店铺掉线");
break;
}
BindBuyer(buyer, "停滞时间超过30秒,跳过");
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
break;
}
@@ -1695,13 +2086,13 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
}
if (tokenSource.IsCancellationRequested)
{
BindBuyer(buyer, "已取消读取");
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
Thread.Sleep(Randomx.GetId(2000, 3000));
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 已发货读取中"; }));
BindBuyer(buyer, "正在读取已发货");
BindBuyerOrderReadInfo(buyer, "正在读取已发货");
// 已发货
readBuyer = buyer.buyer_id;
@@ -1732,7 +2123,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
if (tokenSource.IsCancellationRequested)
{
BindBuyer(buyer, "已取消读取");
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
@@ -1741,10 +2132,10 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
if (buyer.status != "在线")
{
BindBuyer(buyer, "店铺掉线");
BindBuyerOrderReadInfo(buyer, "店铺掉线");
break;
}
BindBuyer(buyer, "停滞时间超过30秒,跳过");
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
break;
}
@@ -1777,14 +2168,9 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
}
if (tokenSource.IsCancellationRequested)
{
BindBuyer(buyer, "已取消读取");
BindBuyerOrderReadInfo(buyer, "已取消读取");
break;
}
//Invoke(new Action(() =>
//{
// if (row.Cells["colMessage"].Value.ParseToString().StartsWith("正在读取"))
// BindBuyer(buyer, " ");
//}));
}
catch (Exception ex)
{
@@ -1799,11 +2185,13 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
isReadBuyerOrder = false;
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = "订单读取已结束,等待下次读取"; }));
}, cancellationTokenSource.Token);
BindBuyerOrderReadInfo(null, "订单读取已结束,等待下次读取");
}, cancellationTokenSource.Token);
}
private void BindBuyer(BuyerLoginInfo buyer, string msg = "", List<string> selectIds = null)
private void BindBuyerOrderReadInfo(BuyerLoginInfo buyer, string msg = "", List<string> selectIds = null)
{
this.LblMsgStr = buyer?.buyer_name + " " + msg + " " + DateTime.Now.ToString("yyMMdd HH:mm:ss");
}
private void btnSendBuyerOrder_Click(object sender, RoutedEventArgs e)
@@ -2826,40 +3214,96 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
Panel.SetZIndex(MainWindow.Instance.gridTbBuyerOrderReadCtrl, -1);
}
private void CheckBox_Click(object sender, RoutedEventArgs e)
private async void CheckBox_Click(object sender, RoutedEventArgs e)
{
if (sender is CheckBox chk)
{
if (chk.DataContext is BuyerLoginInfo pddBuyer)
{
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
{
buyer.IsSelect = false;
}
pddBuyer.IsSelect = true;
if (pddBuyer.wpf_browser != null)
Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
}
}
//if (e.Source)
}
//if (sender is CheckBox chk)
//{
// if (chk.DataContext is BuyerLoginInfo pddBuyer)
// {
// foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
// {
// buyer.IsSelect = false;
// }
// pddBuyer.IsSelect = true;
// if (pddBuyer.wpf_browser != null)
// Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
// }
//}
//if (e.Source)
if (sender is CheckBox chk)
{
if (chk.DataContext is BuyerLoginInfo pddBuyer)
{
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
{
buyer.IsSelect = false;
}
pddBuyer.IsSelect = true;
if (currentReadBuyer == pddBuyer.buyer_id && pddBuyer.wpf_browser != null)
Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
else if (cefShowShopOrderLstWebBrowser != null)
{
WPFCEFBrowser.DeleteCookie(cefShowShopOrderLstWebBrowser.GetCookieManager());
var cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(pddBuyer?.cookie);
//var t = WPFCEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), cefShowShopOrderLstWebBrowser.GetCookieManager(null));
//t.Wait();
foreach (var cook in cookieLst)
{
await WPFCEFBrowser.SetCookieAsync(cook.Domain.Trim('.'), cook.Name + "=" + cook.Value + ";", cefShowShopOrderLstWebBrowser.GetCookieManager(null));
}
private void txtBuyerNick_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
Panel.SetZIndex(this.cefShowShopOrderLstWebBrowser, maxZIndex++);
//cefShowShopOrderLstWebBrowser.Load("https://mobile.yangkeduo.com");
cefShowShopOrderLstWebBrowser.Load("https://mobile.yangkeduo.com/personal.html");
}
}
}
}
private async void txtBuyerNick_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (sender is TextBox txt)
{
if (txt.DataContext is BuyerLoginInfo pddBuyer)
{
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
{
buyer.IsSelect = false;
}
pddBuyer.IsSelect = true;
if (pddBuyer.wpf_browser != null)
Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
}
}
}
//if (sender is TextBox txt)
//{
// if (txt.DataContext is BuyerLoginInfo pddBuyer)
// {
// foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
// {
// buyer.IsSelect = false;
// }
// pddBuyer.IsSelect = true;
// if (pddBuyer.wpf_browser != null)
// Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
// }
//}
if (sender is TextBox txt)
{
if (txt.DataContext is BuyerLoginInfo pddBuyer)
{
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
{
buyer.IsSelect = false;
}
pddBuyer.IsSelect = true;
if (currentReadBuyer == pddBuyer.buyer_id && pddBuyer.wpf_browser != null)
Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
else if (cefShowShopOrderLstWebBrowser != null)
{
WPFCEFBrowser.DeleteCookie(cefShowShopOrderLstWebBrowser.GetCookieManager());
var cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(pddBuyer?.cookie);
//var t = WPFCEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), cefShowShopOrderLstWebBrowser.GetCookieManager(null));
//t.Wait();
foreach (var cook in cookieLst)
{
await WPFCEFBrowser.SetCookieAsync(cook.Domain.Trim('.'), cook.Name + "=" + cook.Value + ";", cefShowShopOrderLstWebBrowser.GetCookieManager(null));
}
Panel.SetZIndex(this.cefShowShopOrderLstWebBrowser, maxZIndex++);
//cefShowShopOrderLstWebBrowser.Load("https://mobile.yangkeduo.com");
cefShowShopOrderLstWebBrowser.Load("https://mobile.yangkeduo.com/personal.html");
}
}
}
}
private void txtBuyerNick_Loaded(object sender, RoutedEventArgs e)
{
@@ -0,0 +1,735 @@
<UserControl
x:Class="_29WxOrderWpf.Ctrls.BuyerCtrls.PDDMultiBuyerOrderReadCtrl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:_29WxOrderWpf.Ctrls.BuyerCtrls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="pddMultiBuyerOrderReadCtrl"
d:DesignHeight="450"
d:DesignWidth="1000"
Loaded="UserControl_Loaded"
mc:Ignorable="d">
<Border
Background="White"
BorderBrush="{StaticResource pageColorBrush}"
BorderThickness="1,1,0,1"
CornerRadius="5,0,0,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button
x:Name="btnHideAll"
Grid.Row="1"
Width="25"
Height="60"
Margin="-20,0,0,20"
HorizontalAlignment="left"
Click="btnHideAll_Click"
Style="{StaticResource BasePageButtonStyle}">
<TextBlock Margin="0,0,5,0">
关<LineBreak />
闭</TextBlock>
</Button>
<Grid Margin="0,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Image
Width="16"
Height="16"
Margin="12,0,4,0"
Cursor="Hand"
MouseLeftButtonUp="btnHideAll_Click"
Source="{StaticResource imgCloseGray}"
Visibility="Collapsed" />
<WrapPanel Grid.Column="1" VerticalAlignment="Center">
<CheckBox
x:Name="chkAutoReadBuyerOrder"
Margin="6,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
BorderBrush="{StaticResource mainColorBrush}"
Checked="chkAutoReadBuyerOrder_CheckedChanged"
Content="自动读多多买手单"
FontSize="12"
IsChecked="true"
Unchecked="chkAutoReadBuyerOrder_CheckedChanged" />
<CheckBox
x:Name="chkHideNoWxIdOrder"
Margin="6,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
BorderBrush="{StaticResource mainColorBrush}"
Checked="chkHideNoWxIdOrder_CheckedChanged"
Content="隐藏无微信订单的买手单"
FontSize="12"
IsChecked="True"
Unchecked="chkHideNoWxIdOrder_CheckedChanged" />
<CheckBox
x:Name="chkAutoAfterSale"
Margin="6,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
BorderBrush="{StaticResource mainColorBrush}"
Checked="chkAutoAfterSale_Checked"
Content="未发货订单自动售后"
FontSize="12"
IsChecked="True"
Unchecked="chkAutoAfterSale_Checked"
Visibility="Visible" />
<Button
x:Name="btnSearch"
Grid.Column="8"
Width="118"
Height="24"
Margin="4,0,0,0"
Click="btnSearch_Click"
Content="刷新订单"
Style="{StaticResource BasePageButtonStyle}" />
<Button
x:Name="btnNextBuyer"
Grid.Column="8"
Height="24"
Margin="4,0,0,0"
Padding="4,0"
Click="btnNextBuyer_Click"
Content="下一个买手"
Style="{StaticResource BasePageButtonStyle}" />
</WrapPanel>
<TextBox
x:Name="txtFilter"
Grid.Column="2"
Height="28"
Margin="28,0,8,0"
VerticalContentAlignment="Center"
BorderBrush="{StaticResource pageColorBrush}"
BorderThickness="1"
Style="{StaticResource BaseRoundCornerTextBoxStyle}"
TextChanged="txtFilter_TextChanged" />
<Button
x:Name="btnFilter"
Grid.Column="3"
Width="50"
Height="24"
Margin="4,0,8,0"
Click="btnFilter_Click"
Content="过滤"
Style="{StaticResource BasePageButtonStyle}" />
</Grid>
<Grid
x:Name="GridCef"
Grid.Row="1"
Background="LightGray" />
<Grid
Grid.Row="1"
Margin="2,2,0,334"
HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Border
x:Name="borderPddBuyer"
Width="138"
Background="White"
CornerRadius="0,4,4,0">
<Grid>
<ListBox x:Name="lbPddBuyer">
<!-- 使用自定义属性模板去除ListBox高亮显示框 -->
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<ContentPresenter
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<!--<local:ShopListRowCtrl></local:ShopListRowCtrl>-->
<Border
MinHeight="50"
Margin="0,0,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderBrush="{StaticResource ListRowBorderColorBrush}"
BorderThickness="0,0,0,1"
CornerRadius="0">
<Border.Style>
<!-- 鼠标进入或悬停Border时切换颜色(悬停时Border的填充控件必须有填充Border,所在层级不限,仅填充透明Grid则触发器无效) -->
<Style TargetType="Border">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{StaticResource ListRowHoverBackColorBrush}" />
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid x:Name="gridListItem">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="colCheck" Width="25*" />
<ColumnDefinition x:Name="colBuyerName" Width="100*" />
</Grid.ColumnDefinitions>
<CheckBox
Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
Click="CheckBox_Click"
IsChecked="{Binding IsSelect, Mode=TwoWay}" />
<TextBox
x:Name="txtBuyerNick"
Grid.Column="1"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Center"
Background="Transparent"
BorderThickness="0"
Cursor="Hand"
IsReadOnly="True"
Loaded="txtBuyerNick_Loaded"
Text="{Binding buyer_nick}"
TextWrapping="Wrap" />
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Border>
<Border
Grid.Column="1"
Height="60"
Margin="-2,0,0,0"
VerticalAlignment="Center"
Panel.ZIndex="-1"
Background="{StaticResource pageColorBrush}"
CornerRadius="0,5,5,0"
Cursor="Hand">
<Button
x:Name="btnHideBuyer"
Grid.Column="1"
Width="20"
Height="60"
Margin="0,0,0,0"
Padding="0,0,0,0"
VerticalContentAlignment="Center"
Click="btnHideBuyer_Click"
Content="◀"
Style="{StaticResource BasePageButtonStyle}" />
</Border>
</Grid>
<Grid
Grid.Row="1"
Margin="0"
VerticalAlignment="Bottom"
Background="Transparent"
Visibility="Visible">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Button
x:Name="btnHide"
Width="60"
Height="25"
Margin="0,0,0,-10"
Padding="0,2,0,0"
VerticalContentAlignment="top"
Click="btnHide_Click"
Content="▼"
Style="{StaticResource BasePageButtonStyle}" />
<Grid
x:Name="gridTable"
Grid.Row="1"
Height="330"
Margin="2"
VerticalAlignment="Bottom"
Background="White"
Visibility="Visible">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label
x:Name="lblMsg"
Margin="180,0,0,0"
VerticalAlignment="Center"
Panel.ZIndex="1"
Content="正在操作:" />
<TabControl
x:Name="tabOrderType"
Grid.Row="1"
Margin="0,-32,0,1"
VerticalAlignment="Stretch">
<TabControl.Resources>
<Style TargetType="{x:Type TabControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border
Grid.Row="1"
MinHeight="4"
Background="#f8f8f9"
BorderBrush="#e0e0e0"
BorderThickness="1,1,1,0"
CornerRadius="0,4,0,0">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" />
</Border>
<Border
Margin="0,0,0,0"
HorizontalAlignment="Left"
Background="#e8e8e9"
BorderBrush="#e1e1e1"
BorderThickness="1,1,1,0"
CornerRadius="4,4,0,0">
<TabPanel
x:Name="HeaderPanel"
Background="Transparent"
IsItemsHost="True" />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="TabItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Border
Name="Border"
Margin="-1,-2,-1,0"
BorderThickness="1,1,1,0"
CornerRadius="4,4,0,0">
<ContentPresenter
x:Name="ContentSite"
Margin="10,5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Header" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background" Value="#f8f8f9" />
<Setter TargetName="Border" Property="BorderBrush" Value="#e0e0e0" />
<Setter TargetName="Border" Property="Margin" Value="-1,-3,-1,-1" />
<Setter Property="Foreground" Value="{StaticResource pageColorBrush}" />
<Setter Property="Panel.ZIndex" Value="100" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Border" Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="#999999" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</TabControl.Resources>
<TabItem Header="买手订单">
<DataGrid
x:Name="dgBuyerOrder"
Grid.Row="1"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
ColumnHeaderHeight="30"
HorizontalGridLinesBrush="{StaticResource HorizontalGridLinesBrush}"
LoadingRow="dgBuyerOrder_LoadingRow"
RowHeaderWidth="0"
RowHeight="50"
SelectionChanged="dgBuyerOrder_SelectionChanged"
VerticalGridLinesBrush="{StaticResource VerticalGridLinesBrush}">
<DataGrid.Columns>
<DataGridTextColumn
Width="40"
Binding="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}, Mode=FindAncestor}}"
CanUserSort="False"
Header="序列"
IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="0.6*"
Binding="{Binding WxSendTypeStr}"
Header="是否直发">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1.5*"
Binding="{Binding order_sn}"
Header="拍单订单号">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1.5*"
Binding="{Binding ShopOrderIdStr}"
Header="店铺订单号">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1*"
Binding="{Binding buyerName}"
Header="买手名称">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="0.8*"
Binding="{Binding OrderTimeStr}"
Header="拍单时间">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1.8*"
Binding="{Binding ProdInfoStr}"
Header="商品信息">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="0.8*"
Binding="{Binding AmoutValue}"
Header="金额">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1*"
Binding="{Binding order_status_prompt}"
Header="订单状态">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1*"
Binding="{Binding outExpressCompanyCode}"
Header="物流名称">
<!-- outExpressCompanyName -->
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1*"
Binding="{Binding tracking_number}"
Header="物流单号">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1*"
Binding="{Binding sendStatus}"
Header="订单信息">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTemplateColumn
x:Name="colSendBuyerOrder"
Width="0.6*"
Header="手动发送">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Button
x:Name="btnSendBuyerOrder"
Grid.Row="2"
Grid.Column="1"
Margin="4,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
BorderBrush="Transparent"
Click="btnSendBuyerOrder_Click"
Content="发送"
Foreground="{StaticResource PageLinkBrush}"
Visibility="{Binding TransitWarehouseIdStr, Converter={StaticResource HasTextVisibility}}" />
<Button
x:Name="btnSendDirectBuyerOrder"
Grid.Row="2"
Grid.Column="1"
Margin="4,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
BorderBrush="Transparent"
Click="btnSendBuyerOrder_Click"
Content="发送"
Foreground="{StaticResource PageLinkBrush}"
Visibility="{Binding WxSendTypeStr, Converter={StaticResource HasTextVisibility}}" />
<!-- 直发单直发标注不为空 -->
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</TabItem>
<TabItem Header="买手售后">
<DataGrid
x:Name="dgBuyerAfterSale"
Grid.Row="1"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
ColumnHeaderHeight="30"
HorizontalGridLinesBrush="{StaticResource HorizontalGridLinesBrush}"
LoadingRow="dgBuyerOrder_LoadingRow"
RowHeaderWidth="0"
RowHeight="50"
VerticalGridLinesBrush="{StaticResource VerticalGridLinesBrush}">
<DataGrid.Columns>
<DataGridTextColumn
Width="40"
Binding="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}, Mode=FindAncestor}}"
CanUserSort="False"
Header="序列"
IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="0.6*"
Binding="{Binding WxSendTypeStr}"
Header="是否直发">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1.5*"
Binding="{Binding afterSalesId}"
Header="售后单号">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1.5*"
Binding="{Binding orderSn}"
Header="拍单订单号">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1.5*"
Binding="{Binding ShopOrderIdStr}"
Header="店铺订单号">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1*"
Binding="{Binding buyerName}"
Header="买手名称">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="0.8*"
Binding="{Binding orderDate}"
Header="拍单日期">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1.8*"
Binding="{Binding ProdInfoStr}"
Header="商品信息">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="0.8*"
Binding="{Binding OrderAmountValue}"
Header="订单金额">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="0.8*"
Binding="{Binding RefundAmountValue}"
Header="售后金额">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1*"
Binding="{Binding AfterSaleStatusStr}"
Header="售后状态">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn
Width="1*"
Binding="{Binding sendStatus}"
Header="订单信息">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="5" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<!--<DataGridTemplateColumn Width="0.6*" Header="手动发送" x:Name="colSendBuyerOrderAfterSale" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Grid.Column="1" Grid.Row="2" x:Name="btnSendBuyerOrder" VerticalAlignment="Center" Background="Transparent" HorizontalAlignment="Center"
Foreground="{StaticResource PageLinkBrush}" BorderBrush="Transparent" Margin="4,0,0,0" Content="发送" Click="btnSendBuyerOrder_Click"
Visibility="{Binding TransitWarehouseIdStr, Converter={StaticResource HasTextVisibility}}"></Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>-->
</DataGrid.Columns>
</DataGrid>
</TabItem>
</TabControl>
</Grid>
</Grid>
</Grid>
</Border>
</UserControl>
File diff suppressed because it is too large. Load diff
@@ -1650,11 +1650,15 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
if (token.IsCancellationRequested)
break;
if (!GlobalConfig.lstFilterOrder.ToList().Any(o => o.order_id == order.order_id))
var orders = GlobalConfig.lstFilterOrder.ToList();
if (!orders.Any(o => o.order_id == order.order_id))
{
Dispatcher.InvokeAsync(() =>
{
GlobalConfig.lstFilterOrder.Add(order);
lock (MainWindow._orderLock)
{
GlobalConfig.lstFilterOrder.Add(order);
}
});
}
}
@@ -1676,7 +1680,12 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
if (order == null)
return;
var orderExist = GlobalConfig.lstFilterOrder.ToList().FirstOrDefault(o => o.order_id == order.order_id);
oms_wei_order_info orderExist = null;
lock (MainWindow._orderLock)
{
orderExist = GlobalConfig.lstFilterOrder.ToList().FirstOrDefault(o => o.order_id == order.order_id);
}
while (orderExist != null)
{
Dispatcher.Invoke(() =>
@@ -1688,26 +1697,31 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
if (!GetOrderIsFilter(order))
{
oms_wei_order_info nextOrder = null;
if (GlobalConfig.OrderTabHeaderStr.StartsWith("需处理售后单") || GlobalConfig.OrderTabHeaderStr.StartsWith("退货仓自动售后单"))
nextOrder = GlobalConfig.lstFilterOrder.ToList().FirstOrDefault(o => o.RefundDatetime < order.RefundDatetime);
else if (GlobalConfig.OrderTabHeaderStr.StartsWith("异常需重拍"))
nextOrder = GlobalConfig.lstFilterOrder.ToList().FirstOrDefault(o => o.update_time < order.update_time);
else
nextOrder = GlobalConfig.lstFilterOrder.ToList().FirstOrDefault(o => o.create_time < order.create_time);
var index = -1;
oms_wei_order_info nextOrder = null;
lock (MainWindow._orderLock)
{
if (GlobalConfig.OrderTabHeaderStr.StartsWith("需处理售后单") || GlobalConfig.OrderTabHeaderStr.StartsWith("退货仓自动售后单"))
nextOrder = GlobalConfig.lstFilterOrder.ToList().FirstOrDefault(o => o.RefundDatetime < order.RefundDatetime);
else if (GlobalConfig.OrderTabHeaderStr.StartsWith("异常需重拍"))
nextOrder = GlobalConfig.lstFilterOrder.ToList().FirstOrDefault(o => o.update_time < order.update_time);
else
nextOrder = GlobalConfig.lstFilterOrder.ToList().FirstOrDefault(o => o.create_time < order.create_time);
}
if (nextOrder != null)
index = GlobalConfig.lstFilterOrder.IndexOf(nextOrder);
index = GlobalConfig.lstFilterOrder.IndexOf(nextOrder);
Dispatcher.InvokeAsync(() =>
{
if (nextOrder != null && index >= 0 && GlobalConfig.lstFilterOrder.Count > index)
lock (MainWindow._orderLock)
{
GlobalConfig.lstFilterOrder.Insert(index, order);
}
else
{
GlobalConfig.lstFilterOrder.Add(order);
if (nextOrder != null && index >= 0 && GlobalConfig.lstFilterOrder.Count > index)
{
GlobalConfig.lstFilterOrder.Insert(index, order);
}
else
{
GlobalConfig.lstFilterOrder.Add(order);
}
}
});
Thread.Sleep(1);
+7 -1
View File
@@ -58,6 +58,7 @@ namespace _29WxOrderWpf
public partial class MainWindow : BaseWindow, INotifyPropertyChanged
{
public static MainWindow Instance { get; private set; }
public static readonly object _orderLock = new object();
private readonly TicketRealtimeMonitor _ticketMonitor = TicketRealtimeMonitor.Current;
private readonly WorkOrderUnreadService _workOrderUnreadService = new WorkOrderUnreadService();
@@ -335,7 +336,12 @@ namespace _29WxOrderWpf
break;
}
foreach (var order in GlobalConfig.lstFilterOrder.Where(o => o.shop_id.ParseToString() == shop.ErpShopId).ToList())
List<oms_wei_order_info> orders;
lock (_orderLock)
{
orders = GlobalConfig.lstFilterOrder.Where(o => o.shop_id.ParseToString() == shop.ErpShopId).ToList();
}
foreach (var order in orders)
{
// 更新代发管理情况
foreach (var orderItem in order.orderItems)
+4 -4
View File
@@ -20,10 +20,10 @@ namespace AllBase.Helper
{
public class GlobalConfig
{
/// <summary>
/// 颜色等图形元素需要在主线程操作
/// </summary>
public static Dispatcher Dispatcher { get; set; }
/// <summary>
/// 颜色等图形元素需要在主线程操作
/// </summary>
public static Dispatcher Dispatcher { get; set; }
/// <summary>
/// 店铺列表
/// </summary>