其他平台买手拍单发送功能 店铺筛选功能逻辑优化
This commit is contained in:
1 parent
2dece676c1
commit
aa45b35145
46 files changed
+4038
-2223
No files matched your search
@@ -42,7 +42,6 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
|
||||
bool isInit = false;
|
||||
CheckBox chkSelectAll = null;
|
||||
ConcurrentList<AuthInfo> lstShopAuthInfo = new ConcurrentList<AuthInfo>();
|
||||
ConcurrentList<WXShopTokenInfo> lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
|
||||
public NaiBa.Util.ConcurrentList<TemuDBProductSelect> lstTemuDBProductSelect = new NaiBa.Util.ConcurrentList<TemuDBProductSelect>();
|
||||
NaiBa.Util.ConcurrentList<AddPriceRule> lstAddPriceRule = new NaiBa.Util.ConcurrentList<AddPriceRule>();
|
||||
@@ -59,10 +58,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>();
|
||||
|
||||
lstWXShopTokenInfo = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<WXShopTokenInfo>>("wx_shop_token_list");
|
||||
if (lstWXShopTokenInfo == null)
|
||||
lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
|
||||
@@ -83,11 +78,6 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
dicCheckedShopId = NaiBa.Util.Helper.ConfigHelper.LoadConfig<Dictionary<string, bool>>("wx_checked_shop_dic");
|
||||
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>();
|
||||
|
||||
|
||||
|
||||
chkSelectAll = dgvShop.Columns["colSelect"].AddHeaderCheckBox(HorizontalAlignment.Center, 0, 0, null, null, false);
|
||||
dgvShop.Columns["colSelect"].HeaderText = "";
|
||||
@@ -114,91 +104,6 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
IsLoadComplate = true;
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -237,7 +142,6 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
if (Visible == true)
|
||||
{
|
||||
RefreshShopLogin();
|
||||
updateAuthor();
|
||||
|
||||
if (!isInit)
|
||||
{
|
||||
@@ -313,7 +217,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,
|
||||
@@ -333,7 +237,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;
|
||||
|
||||
Reference in new issue
Block a user