新版本号 优化上货

This commit is contained in:
wule committed 2026-11-19 16:43:33 +08:00
1 parent 5a6995d70b
commit f1577027e5
14 files changed
+296 -83

No files matched your search

@@ -48,7 +48,6 @@ 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 static ConcurrentList<TemuDBProductSelect> lstTemuDBProductSelect = new ConcurrentList<TemuDBProductSelect>();
public CancellationTokenSource cancellationTokenSource { get; set; } = null;
@@ -194,14 +193,6 @@ namespace TemuKJD.WXForms.ProductForms
lstWxSaleAssistantCookie = new List<Cookie>();
}
GlobalConfig.lstWxShopAuthInfo = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<AuthInfo>>("wx_shop_auth_list");
if (GlobalConfig.lstWxShopAuthInfo == null)
GlobalConfig.lstWxShopAuthInfo = new ConcurrentList<AuthInfo>();
lstWXShopTokenInfo = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<WXShopTokenInfo>>("wx_shop_token_list");
if (lstWXShopTokenInfo == null)
lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
lstTemuDBProductSelect = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<TemuDBProductSelect>>("wx_db_prod_upload_list");
if (lstTemuDBProductSelect == null)
lstTemuDBProductSelect = new NaiBa.Util.ConcurrentList<TemuDBProductSelect>();
@@ -2592,7 +2583,7 @@ namespace TemuKJD.WXForms.ProductForms
#region 获取店铺 Api Token
// 获取店铺的accessToken
WXShopTokenInfo token = lstWXShopTokenInfo.FirstOrDefault(t => t.shopId == shop.ShopId);
WXShopTokenInfo token = GlobalConfig.lstWXShopTokenInfo.FirstOrDefault(t => t.shopId == shop.ShopId);
if (token == null)
token = new WXShopTokenInfo();
if (token.isExpire || string.IsNullOrEmpty(token.accessToken))
@@ -2600,14 +2591,7 @@ namespace TemuKJD.WXForms.ProductForms
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))
{
lstWXShopTokenInfo.RemoveAll(t => t.shopId == shop.ShopId);
lstWXShopTokenInfo.Add(token);
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_shop_token_list", lstWXShopTokenInfo);
}
token = new WxApiBLL().GetWxToken(shop);
}
}
// 如果店铺token不可用,提示报错
@@ -3256,25 +3240,35 @@ namespace TemuKJD.WXForms.ProductForms
#endregion
#region 检测是否有提审额度
var urlAuditQuota = BaseClass.BuildWXImgObjString("product/wx_api_get_audit_quota");
var checkData = UserLogin.GetSignaturex();
checkData += "&token=" + token.accessToken;
//checkData += "&post_data=" + GetHtml.UrlEncodeUtf8("{\"cat_id\":\"" + leafCatId + "\"}");
checkData += "&post_data=" + GetHtml.UrlEncodeUtf8("{\"cat_id\":" + leafCatId + "}");
var apiRst = GetHtml.PostUtf8(urlAuditQuota, checkData);
if (apiRst.Contains("access_token expired"))
if (!wxUploadRule.UpDraft)
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"店铺接口授权已过期\"}";
}
if (!apiRst.Contains("\"errcode\":0"))
{
string errMsg = BaseRegex.GetStringJsonByRegs(ref apiRst, apiRst, "msg", "errMsg", "errorMsg", "err_msg", "error_msg");
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"店铺类目提审次数查询失败 " + errMsg + "\"}";
}
var avail_quota = BaseRegex.GetIntJson(ref apiRst, "avail_quota");
if (avail_quota > 0 == false)
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"当前类目店铺提审次数已达上限,请等待明日提审次数重置\"}";
var urlAuditQuota = BaseClass.BuildWXImgObjString("product/wx_api_get_audit_quota");
var checkData = UserLogin.GetSignaturex();
checkData += "&token=" + token.accessToken;
//checkData += "&post_data=" + GetHtml.UrlEncodeUtf8("{\"cat_id\":\"" + leafCatId + "\"}");
checkData += "&post_data=" + GetHtml.UrlEncodeUtf8("{\"cat_id\":" + leafCatId + "}");
var apiRst = GetHtml.PostUtf8(urlAuditQuota, checkData);
if (apiRst.Contains("access_token expired"))
{
token.mdyTime = DateTime.Now.AddDays(-100);
token = new WxApiBLL().GetWxToken(shop);
apiRst = GetHtml.PostUtf8(urlAuditQuota, checkData);
}
if (apiRst.Contains("access_token expired"))
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"店铺接口授权已过期\"}";
}
if (!apiRst.Contains("\"errcode\":0"))
{
string errMsg = BaseRegex.GetStringJsonByRegs(ref apiRst, apiRst, "msg", "errMsg", "errorMsg", "err_msg", "error_msg");
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"店铺类目提审次数查询失败 " + errMsg + "\"}";
}
// audit_total_remaining avail_quota
var avail_quota = BaseRegex.GetIntJson(ref apiRst, "avail_quota");
if (avail_quota > 0 == false)
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"当前类目店铺提审次数已达上限,请等待明日提审次数重置\"}";
}
}
#endregion