其他平台买手拍单发送功能 店铺筛选功能逻辑优化

This commit is contained in:
wule committed 2026-05-15 19:27:52 +08:00
1 parent 2dece676c1
commit aa45b35145
46 files changed
+4038 -2223

No files matched your search

@@ -42,9 +42,7 @@ namespace TemuKJD.WXForms.ProductForms
public CancellationTokenSource cancellationTokenSource { get; set; } = null;
public bool IsLoadComplate { get; set; } = false;
public ConcurrentList<AuthInfo> lstShopAuthInfo = new ConcurrentList<AuthInfo>();
public ConcurrentList<WXShopTokenInfo> lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
//public Dictionary<string, bool> dicCheckedShopId = new Dictionary<string, bool>();
public Dictionary<string, WxShopUploadInfo> dicShopUpload = new Dictionary<string, WxShopUploadInfo>();
WXAddFinderParam wxAddFinderParam = new WXAddFinderParam();
@@ -67,11 +65,6 @@ namespace TemuKJD.WXForms.ProductForms
{
this.splitContainer1.Dock = DockStyle.Fill;
// 授权状态信息
lstShopAuthInfo = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<AuthInfo>>("wx_shop_auth_list");
if (lstShopAuthInfo == null)
lstShopAuthInfo = new ConcurrentList<AuthInfo>();
// 授权Token
lstWXShopTokenInfo = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<WXShopTokenInfo>>("wx_shop_token_list");
if (lstWXShopTokenInfo == null)
@@ -82,11 +75,6 @@ namespace TemuKJD.WXForms.ProductForms
//if (dicCheckedShopId == null)
// dicCheckedShopId = new Dictionary<string, bool>();
// 上货信息
dicShopUpload = NaiBa.Util.Helper.ConfigHelper.LoadConfig<Dictionary<string, WxShopUploadInfo>>("wx_shop_upload_info");
if (dicShopUpload == null)
dicShopUpload = new Dictionary<string, WxShopUploadInfo>();
// 邀约参数
wxAddFinderParam = NaiBa.Util.Helper.ConfigHelper.LoadConfig<WXAddFinderParam>("wx_add_finder_param");
if (wxAddFinderParam == null)
@@ -193,91 +181,6 @@ namespace TemuKJD.WXForms.ProductForms
});
}
private void btnRefreshAuthor_Click(object sender, EventArgs e)
{
updateAuthor(true);
}
/// <summary>
/// 更新授权状态
/// </summary>
/// <param name="idRefreshTodayHasGet">今日取过的也取</param>
private void updateAuthor(bool idRefreshTodayHasGet = false)
{
this.pbLoadingShop.Visible = true;
Task.Run(() =>
{
// 店铺Id
var updateIds = dgvShop.Rows.Cast<DataGridViewRow>().Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
var selectIds = dgvShop.Rows.Cast<DataGridViewRow>().Where(row
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
if (idRefreshTodayHasGet == true)
updateIds = selectIds;
List<Task> tList = new List<Task>();
if (idRefreshTodayHasGet)
lstShopAuthInfo.RemoveAll(s => updateIds.Contains(s.ShopId));
foreach (var shop in GlobalConfig.ShopLoginList.Where(s => updateIds.Contains(s.ShopId)))
{
Invoke(new Action(() => { BindShop(shop, selectIds, ""); }));
var t = Task.Run(() =>
{
try
{
if (shop.LoginStatus != "登录成功")
{
Invoke(new Action(() => { BindShop(shop, selectIds, "店铺掉线"); }));
return;
}
var authInfo = lstShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shop.ShopId);
if (idRefreshTodayHasGet || authInfo == null || authInfo?.UpdateTime.Date != DateTime.Now.Date)
{
lstShopAuthInfo.RemoveAll(sa => sa.ShopId == shop.ShopId);
var rst = WXUpload.GetApiServiceList(shop);
if (!rst.Contains("\"code\":0"))
{
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
if (shop.LoginStatus != "登录成功")
{
Invoke(new Action(() => { BindShop(shop, selectIds, "店铺掉线"); }));
return;
}
lstShopAuthInfo.Add(new AuthInfo() { ShopId = shop.ShopId, UpdateTime = DateTime.Now, ExpiresTime = DateTime.Now });
Invoke(new Action(() => { BindShop(shop, selectIds, "授权查询失败"); }));
return;
}
foreach (var itemObj in JsonHelper.JObjectParse(rst)["itemList"])
{
// 找到了指定服务
if (itemObj["serviceName"].ParseToString() == "店统领供应链-商品管理")
{
var expiresTick = itemObj["expireTime"].ParseToLong();
lstShopAuthInfo.Add(new AuthInfo() { ShopId = shop.ShopId, UpdateTime = DateTime.Now, ExpiresTime = BaseClass.StampToDateTime(expiresTick.ParseToInt()) });
Invoke(new Action(() => { BindShop(shop, selectIds, "已查询"); }));
return;
}
}
// 没找到指定服务
lstShopAuthInfo.Add(new AuthInfo() { ShopId = shop.ShopId, UpdateTime = DateTime.Now, ExpiresTime = DateTime.Now });
Invoke(new Action(() => { BindShop(shop, selectIds, "已查询"); }));
}
}
catch (Exception ex)
{
}
});
tList.Add(t);
while (tList.Where(ta => !ta.IsFaulted && !ta.IsCompleted).Count() >= 20) { Thread.Sleep(100); }
}
while (tList.Where(ta => !ta.IsFaulted && !ta.IsCompleted).Count() >= 1) { Thread.Sleep(100); }
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_shop_auth_list", lstShopAuthInfo);
Invoke(new Action(() => { pbLoadingShop.Visible = false; }));
});
}
private void chkSelectAll_CheckedChanged(object sender, EventArgs e)
{
if (!chkSelectAll.Checked)
@@ -316,7 +219,6 @@ namespace TemuKJD.WXForms.ProductForms
if (Visible == true)
{
RefreshShopLogin();
updateAuthor();
}
}
@@ -370,7 +272,7 @@ namespace TemuKJD.WXForms.ProductForms
shopEntity.Notes,
"选择商品",
canUse ? "在线" : "掉线",
lstShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shopEntity.ShopId)?.ExpiresTime > DateTime.Now.AddMinutes(5) ? "可用" : "过期",
GlobalConfig.lstWxShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shopEntity.ShopId)?.ExpiresTime > DateTime.Now.AddMinutes(5) ? "可用" : "过期",
canUse,
dicShopUpload.ContainsKey(shopEntity.ShopId) && dicShopUpload[shopEntity.ShopId].DicDayUploadCount.ContainsKey(day) ?
dicShopUpload[shopEntity.ShopId].DicDayUploadCount[day] : 0,
@@ -389,7 +291,7 @@ namespace TemuKJD.WXForms.ProductForms
row.Cells["colLoginStatus"].Value = canUse ? "在线" : "掉线";
row.Cells["colLoginStatus"].Style.ForeColor = canUse ? Color.Green : Color.Red;
row.Cells["colCanUse"].Value = canUse;
row.Cells["colApi"].Value = lstShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shopEntity.ShopId)?.ExpiresTime > DateTime.Now.AddMinutes(5) ? "可用" : "过期";
row.Cells["colApi"].Value = GlobalConfig.lstWxShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shopEntity.ShopId)?.ExpiresTime > DateTime.Now.AddMinutes(5) ? "可用" : "过期";
row.Cells["colRemaining"].Value = shopEntity.AddProductRemaining;
row.Cells["colUploadCount"].Value = dicShopUpload.ContainsKey(shopEntity.ShopId) && dicShopUpload[shopEntity.ShopId].DicDayUploadCount.ContainsKey(day) ?
dicShopUpload[shopEntity.ShopId].DicDayUploadCount[day] : 0;