类目识别token改用店铺自己的

This commit is contained in:
wule committed 2026-06-13 14:05:09 +08:00
1 parent 0a9980335f
commit b1afcd2cd8
6 files changed
+132 -85

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ namespace AllBase
/// <summary>
/// 版本ID
/// </summary>
public static int VersionCount = 1180;
public static int VersionCount = 1182;
public static string MainPath = "29wx";
//public static string MainPath = "29wx";
//public static string MainPath = "29pdd";
@@ -50,10 +50,19 @@ namespace KJD_Web.BLL.WXXD
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile")?.Replace("'", "\\'");
var password = RegexUtils.GetStringQuery(ref inputData, "password")?.Replace("'", "\\'");
var sub_soft_type = RegexUtils.GetStringQuery(ref inputData, "sub_soft_type")?.Replace("'", "\\'");
var version = RegexUtils.GetStringQuery(ref inputData, "version").ParseToInt();
if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt())
return "{\"code\":1,\"msg\":\"当前版本过于陈旧,请立即升级新版\"}";
if (sub_soft_type == "order")
{
}
else
{
if (version < (System.Configuration.ConfigurationManager.ConnectionStrings["LimitVersion"]?.ConnectionString).ParseToInt())
return "{\"code\":1,\"msg\":\"当前版本过于陈旧,请立即升级新版\"}";
}
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
@@ -288,7 +288,7 @@ namespace KJD_Web.Upload.Prod
if (wxDisSku != null)
sku.productSkuInfo.salePrice = wxDisSku.price;
else
sku.productSkuInfo.salePrice = (sku.productSkuInfo.salePrice - sku.productSkuInfo.salePrice * realPricePer).ParseToInt();
sku.productSkuInfo.salePrice = (sku.productSkuInfo.salePrice - sku.productSkuInfo.salePrice * (1m - realPricePer)).ParseToInt();
}
if (wxClientProd.productSkus.Min(s => s.productSkuInfo.salePrice * 0.01m) == 0)
@@ -130,6 +130,11 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.dtpStart.Value = new DateTime(2026, 3, 12, 0, 0, 0);
this.dtpEnd.Value = new DateTime(2026, 3, 13, 13, 0, 0);
WXDBProdUploadForm.lstWXShopTokenInfo = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<WXShopTokenInfo>>("wx_shop_token_list");
if (WXDBProdUploadForm.lstWXShopTokenInfo == null)
WXDBProdUploadForm.lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
}
private void btnSearch_Click(object sender, EventArgs e)
@@ -1310,8 +1315,29 @@ namespace TemuKJD.PDDForms.ProductSelectForms
public static void GetProdWxCat(KJDDBProduct prod, DataGridViewRow row)
{
// 获取微信accessToken
var token = new WxApiBLL().GetRandomWxToken();
var shop = GlobalConfig.ShopLoginList.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
WXShopTokenInfo token = WXDBProdUploadForm.lstWXShopTokenInfo.FirstOrDefault(t => t.shopId == shop.ShopId);
if (token == null)
token = new WXShopTokenInfo();
if (token.isExpire || string.IsNullOrEmpty(token.accessToken))
{
AuthInfo auth = GlobalConfig.lstWxShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shop.ShopId);
//if (auth != null && auth.ExpiresTime > DateTime.Now.AddMinutes(5))
{
token = new WxApiBLL().GetShopWxToken(shop);
if (!string.IsNullOrEmpty(token.accessToken))
{
WXDBProdUploadForm.lstWXShopTokenInfo.RemoveAll(t => t.shopId == shop.ShopId);
WXDBProdUploadForm.lstWXShopTokenInfo.Add(token);
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_shop_token_list", WXDBProdUploadForm.lstWXShopTokenInfo);
}
}
}
// 如果店铺token不可用,随机获取一个上传图片的accessToken
if (token == null || token.isExpire || string.IsNullOrEmpty(token.accessToken))
// 获取微信accessToken
token = new WxApiBLL().GetRandomWxToken();
try
{
JObject obj = new JObject();
@@ -1611,6 +1637,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
{
row.Cells["colMainCate"].Value = mainCatName;
row.Cells["col_cat_name"].Value = catName;
row.Cells["colCatBound"].Value = GlobalConfig.WxCatBoundList.FirstOrDefault(cb => cb.leaf_id == dbProd.wx_cat_leaf)?.cat_bound;
}));
}
}
@@ -37,13 +37,13 @@ namespace TemuKJD.WXForms.ProductForms
public partial class WXDBProdUploadForm : BaseForm
{
public static WXDBProdUploadForm Instance { get; set; } = null;
public static ConcurrentList<WXShopTokenInfo> lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
public CancellationTokenSource cancellationTokenSource { get; set; } = null;
public bool IsWxNotUseSoftwareDefaultAddressOnce { get; set; } = false;
public bool IsLoadComplate { get; set; } = false;
public ConcurrentList<TemuDBProductSelect> lstTemuDBProductSelect = new ConcurrentList<TemuDBProductSelect>();
ConcurrentList<WXShopTokenInfo> lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
ConcurrentList<AddPriceRule> lstAddPriceRule = new ConcurrentList<AddPriceRule>();
bool isInit = false;
@@ -353,9 +353,20 @@ namespace TemuKJD.WXForms.ProductForms
if (BaseClass.UserAuthority.Contains("商品采集") || BaseClass.ParentAuthority.Contains("商品采集"))
{
cmbSourceType.Items.Insert(1, "------");
cmbSourceType.Items.Insert(1, "微信商品");
cmbSourceType.Items.Insert(1, "1688商品");
cmbSourceType.Items.Insert(1, "多多商品");
cmbSourceType.Items.Insert(1, "微信商品");
if (!BaseClass.UserAuthority.ParseToString().Contains("货源选择"))
{
this.lblSourceType.Visible = true;
this.cmbSourceType.Visible = true;
this.cmbSourceType.Items.Clear();
this.cmbSourceType.Items.Add("多多商品,1688商品,微信商品");
this.cmbSourceType.Items.Add("多多商品");
this.cmbSourceType.Items.Add("1688商品");
this.cmbSourceType.Items.Add("微信商品");
}
chkRandomFissionProduct.Visible = true;
txtRandomFissionProductCount.Visible = true;
@@ -557,6 +568,7 @@ namespace TemuKJD.WXForms.ProductForms
{
Invoke(new Action(() =>
{
//cmbGroupFilter.Items.Remove("用户" + mainUserName);
cmbGroupFilter.Items.Remove("------");
cmbGroupFilter.Items.Remove("我的商品");
cmbGroupFilter.Items.Insert(1, "------");
@@ -1208,7 +1220,7 @@ namespace TemuKJD.WXForms.ProductForms
result = UploadProduct(shop, kjdDbProdTmp, selectProd, row.Cells["colOpResult"], startTime);
if (result.Contains("今日提审次数已用尽,请明日再试") || result.Contains("如需上架请先缴纳足额保证金") || result.Contains("在架商品数已达到上限") ||
result.Contains("提审次数已达上限") || result.Contains("拥金上货失败:需要开通优选联盟"))
result.Contains("提审次数已达上限") || result.Contains("拥金上货失败:需要开通优选联盟") || result.Contains("本店铺近期提审失败比例较高,已被限"))
{
var shopRow = dgvShop.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colShopId"].Value.ParseToString() == shop.ShopId);
if (shopRow != null)
@@ -2038,7 +2050,7 @@ namespace TemuKJD.WXForms.ProductForms
if (token.isExpire || string.IsNullOrEmpty(token.accessToken))
{
AuthInfo auth = GlobalConfig.lstWxShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shop.ShopId);
if (auth != null && auth.ExpiresTime > DateTime.Now.AddMinutes(5))
//if (auth != null && auth.ExpiresTime > DateTime.Now.AddMinutes(5))
{
token = new WxApiBLL().GetShopWxToken(shop);
@@ -3281,20 +3293,10 @@ namespace TemuKJD.WXForms.ProductForms
attrValue = "平装";
}
}
if (attrValue.IsNullOrEmpty() && attr.isRequired == true)
// 强制改为国产
{
if (attrValueLst.Contains("其他"))
attrValue = "其他";
else if (attrValueLst.Contains("常规"))
attrValue = "常规";
else if (attrValueLst.Contains("通用"))
attrValue = "通用";
else if (attrValueLst.Contains("国产"))
if (attrValueLst.Contains("国产"))
attrValue = "国产";
else if (attr.value.Contains("绒丝;羽毛;白鸭绒;白鹅绒;灰鸭绒;灰鹅绒;鸭毛片;鹅毛片"))
{
attrValue = "绒丝";
}
else if (attr.name == "是否进口")
{
attrValue = "非进口";
@@ -3309,6 +3311,19 @@ namespace TemuKJD.WXForms.ProductForms
{
attrValue = "中国大陆";
}
}
if (attrValue.IsNullOrEmpty() && attr.isRequired == true)
{
if (attrValueLst.Contains("其他"))
attrValue = "其他";
else if (attrValueLst.Contains("常规"))
attrValue = "常规";
else if (attrValueLst.Contains("通用"))
attrValue = "通用";
else if (attr.value.Contains("绒丝;羽毛;白鸭绒;白鹅绒;灰鸭绒;灰鹅绒;鸭毛片;鹅毛片"))
{
attrValue = "绒丝";
}
//else if (attrValueLst.Any(v => v.Contains("%")))
//{
// attrValue = attrValueLst.FirstOrDefault();
@@ -3655,28 +3670,28 @@ namespace TemuKJD.WXForms.ProductForms
prodInfo.detail.sku.FirstOrDefault().thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
// 处理系统指定的规格名称
if ((upProdParam.product.info.category.FirstOrDefault()?.name == "食品饮料" || prodInfo.detail.cats.FirstOrDefault() == "食品饮料") &&
(selectProd.cat_name == "坚果炒货" || selectProd.cat_name == "果干"))
{
if (!prodInfo.detail.sku.FirstOrDefault().spec.Any(s => s.parent_name == "规格/净含量"))
{
foreach (var sku in prodInfo.detail.sku)
{
sku.spec.FirstOrDefault().parent_name = "规格/净含量";
}
}
}
//else if ((upProdParam.product.info.category.FirstOrDefault()?.name == "食品饮料" || prodInfo.detail.cats.FirstOrDefault() == "食品饮料"))
//if ((upProdParam.product.info.category.FirstOrDefault()?.name == "食品饮料" || prodInfo.detail.cats.FirstOrDefault() == "食品饮料") &&
// (selectProd.cat_name == "坚果炒货" || selectProd.cat_name == "果干"))
//{
// if (!prodInfo.detail.sku.FirstOrDefault().spec.Any(s => s.parent_name == "规格"))
// if (!prodInfo.detail.sku.FirstOrDefault().spec.Any(s => s.parent_name == "规格/净含量"))
// {
// foreach (var sku in prodInfo.detail.sku)
// {
// sku.spec.FirstOrDefault().parent_name = "规格";
// sku.spec.FirstOrDefault().parent_name = "规格/净含量";
// }
// }
//}
else
////else if ((upProdParam.product.info.category.FirstOrDefault()?.name == "食品饮料" || prodInfo.detail.cats.FirstOrDefault() == "食品饮料"))
////{
//// if (!prodInfo.detail.sku.FirstOrDefault().spec.Any(s => s.parent_name == "规格"))
//// {
//// foreach (var sku in prodInfo.detail.sku)
//// {
//// sku.spec.FirstOrDefault().parent_name = "规格";
//// }
//// }
////}
//else
{
var leafCat = upProdParam.product.info.category.LastOrDefault();
if (leafCat?.catInfo?.saleAttr?.attr != null)
@@ -3685,18 +3700,24 @@ namespace TemuKJD.WXForms.ProductForms
{
if (att.isRequired == true)
{
// 规格属性名放在第二个规格上
if (att.normalRelease.ruleType == 2 && prodInfo.detail.sku.FirstOrDefault()?.spec.Count == 2)
{
foreach (var sku in prodInfo.detail.sku)
{
sku.spec[1].parent_name = att.name;
// 如果有指定规格属性名称就不再设置
if (!sku.spec.Any(sp => sp.parent_name == att.name))
sku.spec[1].parent_name = att.name;
}
}
// 规格属性名放在第一个规格上
else
{
foreach (var sku in prodInfo.detail.sku)
{
sku.spec[0].parent_name = att.name;
// 如果有指定规格属性名称就不再设置
if (!sku.spec.Any(sp => sp.parent_name == att.name))
sku.spec[0].parent_name = att.name;
}
}
}
@@ -5218,9 +5239,14 @@ namespace TemuKJD.WXForms.ProductForms
string addUserName = BaseClass.UserAuthority.Contains("商品采集") ? ("admin," + BaseClass.UserName) : "admin";
if (BaseClass.GroupId != 3)
addUserName = BaseClass.ParentAuthority.Contains("商品采集") ? ("admin," + BaseClass.ParentUserName) : "admin";
// 如果指定只有自己采集的商品,则只随机自己采集的商品
if ((cmbSourceType.Text.Trim().Contains("多多商品") || cmbSourceType.Text.Trim().Contains("1688商品") || cmbSourceType.Text.Trim().Contains("微信商品")) &&
cmbSourceType.Text.Trim().Replace("多多商品", "").Replace("1688商品", "").Replace("微信商品", "").Trim(',').IsNullOrEmpty())
// 采集用户如果没有爆款数据或货源选择权限,则只能随机自己采集的商品
if ((BaseClass.UserAuthority.Contains("商品采集") || BaseClass.UserAuthority.Contains("商品采集")) &&
cmbHot.Text != "爆款数据" && !BaseClass.UserAuthority.Contains("货源选择"))
data += "&add_user_name=" + (BaseClass.GroupId == 3 ? BaseClass.UserName : BaseClass.ParentUserName);
// 如果指定只有自己采集的商品,则只会随机自己采集的商品
else if ((cmbSourceType.Text.Trim().Contains("多多商品") || cmbSourceType.Text.Trim().Contains("1688商品") || cmbSourceType.Text.Trim().Contains("微信商品")) &&
cmbSourceType.Text.Trim().Replace("多多商品", "").Replace("1688商品", "").Replace("微信商品", "").Trim(',').IsNullOrEmpty())
data += "&add_user_name=" + (BaseClass.GroupId == 3 ? BaseClass.UserName : BaseClass.ParentUserName);
else
data += "&add_user_name=" + addUserName;
@@ -5751,45 +5777,6 @@ namespace TemuKJD.WXForms.ProductForms
{
cmbJstInitSet.Text = "是";
}
string sourceType = cmbSourceType.Text.Trim().Replace("已采集数据", "1688外部数据");
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); // 同时刷新下商品分组
if (BaseClass.UserAuthority.Contains("商品采集") || BaseClass.ParentAuthority.Contains("商品采集"))
{
var mainUserName = BaseClass.GroupId == 3 ? BaseClass.UserName : BaseClass.ParentUserName;
if (cmbGroupFilter.Items.Cast<object>().Any(it => it.ParseToString() == "用户" + mainUserName))
{
Invoke(new Action(() =>
{
cmbGroupFilter.Items.Remove("用户" + mainUserName);
cmbGroupFilter.Items.Remove("------");
cmbGroupFilter.Items.Remove("我的商品");
cmbGroupFilter.Items.Insert(1, "------");
cmbGroupFilter.Items.Insert(1, "我的商品");
}));
}
}
});
if (!string.IsNullOrWhiteSpace(cmbSourceType.Text) || cmbSourceType.Text == "我的商品")
{
//lblGroupFilter.Visible = true;
//cmbGroupFilter.Visible = true;
}
else
{
if (BaseClass.SaLevel != 1)
{
lblGroupFilter.Visible = false;
cmbGroupFilter.Visible = false;
cmbGroupFilter.Text = "";
}
}
}
private void cmbCateFilter1_SelectedIndexChanged(object sender, EventArgs e)
@@ -160,6 +160,27 @@ namespace TemuKJD.WXForms.ProductForms
txtViewUvMin.Visible = true;
}
if (BaseClass.UserAuthority.Contains("商品采集") || BaseClass.ParentAuthority.Contains("商品采集"))
{
cmbSourceType.Items.Insert(1, "------");
cmbSourceType.Items.Insert(1, "微信商品");
cmbSourceType.Items.Insert(1, "1688商品");
cmbSourceType.Items.Insert(1, "多多商品");
if (!BaseClass.UserAuthority.ParseToString().Contains("货源选择"))
{
this.lblSourceType.Visible = true;
this.cmbSourceType.Visible = true;
this.cmbSourceType.Items.Clear();
this.cmbSourceType.Items.Add("多多商品,1688商品,微信商品");
this.cmbSourceType.Items.Add("多多商品");
this.cmbSourceType.Items.Add("1688商品");
this.cmbSourceType.Items.Add("微信商品");
}
}
cmbHot_TextChanged(null, null);
// 调整隐藏控件的布局
var ctrls = tableLayoutPanel1.Controls.Cast<Control>().ToList();
List<Control> ctrlLst = new List<Control>();
for (int j = 0; j < 2; j++)
@@ -208,8 +229,6 @@ namespace TemuKJD.WXForms.ProductForms
tableLayoutPanel1.ColumnStyles[i].SizeType = SizeType.AutoSize;
}
}
cmbHot_TextChanged(null, null);
}
private void btnSearch_Click(object sender, EventArgs e)
@@ -453,8 +472,13 @@ namespace TemuKJD.WXForms.ProductForms
string addUserName = BaseClass.UserAuthority.Contains("商品采集") ? ("admin," + BaseClass.UserName) : "admin";
if (BaseClass.GroupId != 3)
addUserName = BaseClass.ParentAuthority.Contains("商品采集") ? ("admin," + BaseClass.ParentUserName) : "admin";
// 如果指定只有自己采集的商品,则只随机自己采集的商品
if ((cmbSourceType.Text.Trim().Contains("多多商品") || cmbSourceType.Text.Trim().Contains("1688商品") || cmbSourceType.Text.Trim().Contains("微信商品")) &&
// 采集用户如果没有爆款数据或货源选择权限,则只能随机自己采集的商品
if ((BaseClass.UserAuthority.Contains("商品采集") || BaseClass.UserAuthority.Contains("商品采集")) &&
cmbHot.Text != "爆款数据" && !BaseClass.UserAuthority.Contains("货源选择"))
data += "&add_user_name=" + (BaseClass.GroupId == 3 ? BaseClass.UserName : BaseClass.ParentUserName);
// 如果指定只有自己采集的商品,则只会随机自己采集的商品
else if ((cmbSourceType.Text.Trim().Contains("多多商品") || cmbSourceType.Text.Trim().Contains("1688商品") || cmbSourceType.Text.Trim().Contains("微信商品")) &&
cmbSourceType.Text.Trim().Replace("多多商品", "").Replace("1688商品", "").Replace("微信商品", "").Trim(',').IsNullOrEmpty())
data += "&add_user_name=" + (BaseClass.GroupId == 3 ? BaseClass.UserName : BaseClass.ParentUserName);
else