1拼多多买手读单优化 2商品类目查询优化
This commit is contained in:
1 parent
7601f5b2f3
commit
4ae8e4f1b2
40 files changed
+4743
-745
No files matched your search
@@ -26,6 +26,7 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
public partial class WxShopStatisticsForm : BaseForms.BaseForm
|
||||
{
|
||||
bool isInit = false;
|
||||
public CancellationTokenSource cancellationTokenSource { get; set; } = null;
|
||||
public List<WxShopSaleStatisticsGroup> lstShopStatisticsInfo = new List<WxShopSaleStatisticsGroup>();
|
||||
public List<string> lstHideColumns = new List<string>();
|
||||
public WxShopStatisticsForm()
|
||||
@@ -81,9 +82,9 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
{
|
||||
if (Visible == true)
|
||||
{
|
||||
if (!isInit)
|
||||
//if (!isInit)
|
||||
{
|
||||
isInit = true;
|
||||
//isInit = true;
|
||||
RefreshShop();
|
||||
}
|
||||
}
|
||||
@@ -98,7 +99,7 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
|
||||
// 获取被删除的店铺
|
||||
List<DataGridViewRow> dgvRowList = dgvShop.Rows.Cast<DataGridViewRow>().Where(row
|
||||
=> !GlobalConfig.ShopLoginList.Any(s => s.ShopId == row.Cells["colShopId"]?.Value?.ToString())).ToList();
|
||||
=> !GlobalConfig.ValidShopLoginList.Any(s => s.ShopId == row.Cells["colShopId"]?.Value?.ToString())).ToList();
|
||||
// 更新被删除的店铺列表
|
||||
foreach (var row in dgvRowList)
|
||||
{
|
||||
@@ -106,46 +107,52 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
}
|
||||
// 获取被删除的统计信息并删除
|
||||
List<WxShopSaleStatisticsGroup> statisticsDeleteLst = lstShopStatisticsInfo.Where(row
|
||||
=> !GlobalConfig.ShopLoginList.Any(s => s.ShopId == row.ShopId.ToString())).ToList();
|
||||
=> !GlobalConfig.ValidShopLoginList.Any(s => s.ShopId == row.ShopId.ToString())).ToList();
|
||||
foreach (var s in statisticsDeleteLst)
|
||||
{
|
||||
lstShopStatisticsInfo.Remove(s);
|
||||
}
|
||||
|
||||
// 绑定店铺(含新导入的店铺)
|
||||
foreach (ShopLoginInfo shopEntity in GlobalConfig.ShopLoginList)
|
||||
foreach (ShopLoginInfo shopEntity in GlobalConfig.ValidShopLoginList)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(shopEntity.ShopId))
|
||||
BindShop(shopEntity, selectIds);
|
||||
}
|
||||
|
||||
cmbFilterShopNotes.Items.Clear();
|
||||
foreach (var note in GlobalConfig.ShopLoginList.Select(s => s.Notes).Where(s => !s.IsNullOrEmpty()).Distinct())
|
||||
foreach (var note in GlobalConfig.ValidShopLoginList.Select(s => s.Notes).Where(s => !s.IsNullOrEmpty()).Distinct())
|
||||
{
|
||||
cmbFilterShopNotes.Items.Add(note);
|
||||
}
|
||||
|
||||
cmbFilterShopGroup.Items.Clear();
|
||||
foreach (var group in GlobalConfig.ShopLoginList.Select(s => s.GroupName).Where(s => !s.IsNullOrEmpty()).Distinct())
|
||||
foreach (var group in GlobalConfig.ValidShopLoginList.Select(s => s.GroupName).Where(s => !s.IsNullOrEmpty()).Distinct())
|
||||
{
|
||||
cmbFilterShopGroup.Items.Add(group);
|
||||
}
|
||||
|
||||
GetShopStatistics(GlobalConfig.ShopLoginList.ToList(), selectIds);
|
||||
GetShopStatistics(GlobalConfig.ValidShopLoginList, selectIds);
|
||||
}
|
||||
|
||||
private void GetShopStatistics(List<ShopLoginInfo> shops, List<string> selectIds)
|
||||
private void GetShopStatistics(NaiBa.Util.ConcurrentList<ShopLoginInfo> shops, List<string> selectIds)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.pgbTaskProgress.Maximum = shops.Count;
|
||||
this.statusBar.lblTaskStatus.Text = "正在查询";
|
||||
}));
|
||||
if (cancellationTokenSource != null)
|
||||
cancellationTokenSource.Cancel();
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
Task.Run(() =>
|
||||
{
|
||||
var cancellationToken = cancellationTokenSource.Token;
|
||||
List<Task> tLst = new List<Task>();
|
||||
foreach (ShopLoginInfo shopEntity in shops)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
break;
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.UpdateProgressBar(this.statusBar.pgbTaskProgress.Value + 1);
|
||||
@@ -181,6 +188,8 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
}));
|
||||
var t = Task.Run(() =>
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
if (string.IsNullOrEmpty(shopEntity.ShopId))
|
||||
return;
|
||||
bool canUse = shopEntity.LoginStatus == "登录成功";
|
||||
@@ -230,7 +239,7 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
}));
|
||||
});
|
||||
//t.Wait();
|
||||
while(tLst.Where(ta => !ta.IsCompleted && !ta.IsFaulted && !ta.IsCanceled).Count() >= 2)
|
||||
while(tLst.Where(ta => !ta.IsCompleted && !ta.IsFaulted && !ta.IsCanceled).Count() >= 3)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
@@ -246,13 +255,15 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
this.statusBar.lblTaskStatus.Text = "查询结束";
|
||||
this.pbLoading.Visible = false;
|
||||
}));
|
||||
});
|
||||
}, cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
private void BindShop(ShopLoginInfo shopEntity, List<string> selectShopId = null)
|
||||
{
|
||||
if (shopEntity == null)
|
||||
return;
|
||||
if (shopEntity.is_point_shop_expire)
|
||||
return;
|
||||
if (selectShopId == null)
|
||||
selectShopId = new List<string>();
|
||||
|
||||
@@ -727,7 +738,7 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
string columnName = dgvShop.Columns[e.ColumnIndex].Name;
|
||||
string shopId = dgvShop.Rows[e.RowIndex].Cells["colShopId"].Value.ParseToString();
|
||||
string shopAccount = dgvShop.Rows[e.RowIndex].Cells["colShopAccount"].Value.ToString();
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId.ToString());
|
||||
var shop = GlobalConfig.ValidShopLoginList.FirstOrDefault(s => s.ShopId == shopId.ToString());
|
||||
var row = dgvShop.Rows[e.RowIndex];
|
||||
switch (columnName)
|
||||
{
|
||||
@@ -772,7 +783,8 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
}
|
||||
void ReGetStatistics(List<string> reGetShopIds)
|
||||
{
|
||||
var shopList = GlobalConfig.ShopLoginList.Where(s => reGetShopIds.Contains(s.ShopId)).ToList();
|
||||
var shopList = new NaiBa.Util.ConcurrentList<ShopLoginInfo>();
|
||||
shopList.AddRange(GlobalConfig.ValidShopLoginList.Where(s => reGetShopIds.Contains(s.ShopId)));
|
||||
foreach (var shop in shopList)
|
||||
{
|
||||
WxShopSaleStatisticsGroup statistics = lstShopStatisticsInfo.FirstOrDefault(s => s.ShopId.ToString() == shop.ShopId);
|
||||
@@ -839,5 +851,10 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
cmbFilterShopGroup.Text = "全部";
|
||||
pnlFliter_Click(null, null);
|
||||
}
|
||||
|
||||
private void btnRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
RefreshShop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user