修复上货页面绑定多次bug

This commit is contained in:
chfei committed 2026-09-21 11:08:45 +08:00
1 parent 2bb20fc107
commit 93d2956d95
1 file changed
+61 -60
@@ -644,83 +644,67 @@ namespace TemuKJD.WXForms.ProductForms
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_checked_shop_dic", dicCheckedShopId);
}
private void btnRefreshShop_Click(object sender, EventArgs e)
private async void btnRefreshShop_Click(object sender, EventArgs e)
{
pbLoadingShop.Visible = true;
RefreshDbProdGroupAndCate();
RefreshShopLogin();
}
private void UserSelectDbProductForm_VisibleChanged(object sender, EventArgs e)
private async void UserSelectDbProductForm_VisibleChanged(object sender, EventArgs e)
{
if (Visible == true)
{
RefreshShopLogin();
updateAuthor();
RefreshDbProdGroupAndCate(InitWaitingProductConfigBinding);
RefreshDbProdGroupAndCate();
lblWaitToUp.Text = "待上传 " + lstTemuDBProductSelect.Count + " 件";
if (!isInit)
{
Task.Run(() =>
{
foreach (var shop in GlobalConfig.ValidShopLoginList)
{
//if (shop.LoginStatus == "登录成功")
//{
// var rst = WXPreSale.scanProductPreview(shop);
// if (!rst.Contains("\"code\":0") && !rst.Contains("\"success\":true"))
// {
// WXShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false);
// }
//}
}
});
InitWaitingProductConfigBinding();
}
isInit = true;
}
}
private void RefreshDbProdGroupAndCate(Action call = null)
private async void RefreshDbProdGroupAndCate()
{
Task.Run(() =>
// 同时刷新下商品分组
//string addUserName = BaseClass.UserAuthority.Contains("商品采集") ? ("admin," + BaseClass.UserName) : "admin";
//if (BaseClass.GroupId != 3)
// addUserName = BaseClass.ParentAuthority.Contains("商品采集") ? ("admin," + BaseClass.ParentUserName) : "admin";
//PDDDBProdListForm.GetPDDProductGroup(cmbGroupFilter, sourceType, "", addUserName); // 同时刷新下商品分组
PDDDBProdListForm.GetPDDProductGroup(new List<ComboBox> { cmbGroupFilter, }, "", "", "admin");
if (BaseClass.UserAuthority.Contains("商品采集") || BaseClass.ParentAuthority.Contains("商品采集"))
{
// 同时刷新下商品分组
//string addUserName = BaseClass.UserAuthority.Contains("商品采集") ? ("admin," + BaseClass.UserName) : "admin";
//if (BaseClass.GroupId != 3)
// addUserName = BaseClass.ParentAuthority.Contains("商品采集") ? ("admin," + BaseClass.ParentUserName) : "admin";
//PDDDBProdListForm.GetPDDProductGroup(cmbGroupFilter, sourceType, "", addUserName); // 同时刷新下商品分组
PDDDBProdListForm.GetPDDProductGroup(new List<ComboBox> { cmbGroupFilter, }, "", "", "admin");
if (BaseClass.UserAuthority.Contains("商品采集") || BaseClass.ParentAuthority.Contains("商品采集"))
{
Invoke(new Action(() =>
{
//cmbGroupFilter.Items.Remove("用户" + mainUserName);
cmbGroupFilter.Items.Remove("--------");
cmbGroupFilter.Items.Remove("我的商品");
cmbGroupFilter.Items.Insert(0, "--------");
cmbGroupFilter.Items.Insert(0, "我的商品");
}));
}
GetPddProductCate();
Invoke(new Action(() =>
{
this.btnSwitchCatType.Text = "P";
btnSwitchCatType_Click(null, null);
pbLoadingShop.Visible = false;
//cmbGroupFilter.Items.Remove("用户" + mainUserName);
cmbGroupFilter.Items.Remove("--------");
cmbGroupFilter.Items.Remove("我的商品");
cmbGroupFilter.Items.Insert(0, "--------");
cmbGroupFilter.Items.Insert(0, "我的商品");
}));
call?.Invoke();
}
await GetPddProductCate();
Invoke(new Action(() =>
{
this.btnSwitchCatType.Text = "P";
btnSwitchCatType_Click(null, null);
pbLoadingShop.Visible = false;
});
}));
waiting_product_config.Assign(NaiBa.Util.Helper.ConfigHelper.LoadConfig<WaitingProductConfig>(nameof(waiting_product_config)));
//call?.Invoke();
}
/// <summary>
/// 获取商品所有类目
/// </summary>
void GetPddProductCate()
async Task GetPddProductCate()
{
var pddMainCats = GlobalConfig.PddCatList.Where(c => c.level == 1);
var mainCatsText = string.Join(",", pddMainCats.Select(c => c.cat_name)) + "," + string.Join(",", pddMainCats.Select(c => c.cat_id));
@@ -729,9 +713,9 @@ namespace TemuKJD.WXForms.ProductForms
var url = BaseClass.BuildObjString("product/get_pdd_product_cates");
var data = UserLogin.GetSignaturex();
var html = GetHtml.PostUtf8(url, data);
var html = await GetHtml.PostUtf8Async(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
html = await GetHtml.PostUtf8Async(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
{
BaseMsgForm.ShowError("商品类目获取失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg"));
@@ -740,18 +724,6 @@ namespace TemuKJD.WXForms.ProductForms
{
pdd_product_cates = BaseRegex.GetStringJson(ref html, "data");
}
//Invoke(new Action(() =>
//{
// if (cmbSourceType.Text.Trim() != "厂商直采" && cmbSourceType.Text.Trim() != "微信店采" && cmbSourceType.Text.Trim() != "微信小店")
// {
// fillPddCate();
// }
// else
// {
// fillWxCate();
// }
//}));
}
void fillPddCate()
@@ -8287,5 +8259,34 @@ Content-Type: application/octet-stream
get => GetValue<decimal>();
set => SetValue(value);
}
public void Assign(WaitingProductConfig config)
{
if (config == null || ReferenceEquals(config, this)) return;
IdFilter = config.IdFilter;
SearchGoodsName = config.SearchGoodsName;
SourceType = config.SourceType;
GroupFilter = config.GroupFilter;
Hot = config.Hot;
WxSafe = config.WxSafe;
CateFilter1 = config.CateFilter1;
CateFilter2 = config.CateFilter2;
CateFilter3 = config.CateFilter3;
Notes = config.Notes;
JstInitSet = config.JstInitSet;
AddCount = config.AddCount;
SkipQualification = config.SkipQualification;
RandomFissionProduct = config.RandomFissionProduct;
RandomFissionProductCount = config.RandomFissionProductCount;
WXComplateProd = config.WXComplateProd;
UpdateInDaysChecked = config.UpdateInDaysChecked;
UpdateInDays = config.UpdateInDays;
UpdateInDaysType = config.UpdateInDaysType;
FilterViewUvChecked = config.FilterViewUvChecked;
FilterViewUv = config.FilterViewUv;
FilterSaleCountNumChecked = config.FilterSaleCountNumChecked;
FilterSaleCountNum = config.FilterSaleCountNum;
}
}
}