1添加随机上传商品 2优化pdd api授权逻辑
This commit is contained in:
1 parent
07b912e9eb
commit
c0b7c2d986
34 files changed
+1651
-603
No files matched your search
@@ -272,6 +272,10 @@ namespace TemuKJD.BLL.PddApi
|
||||
return upResult;
|
||||
}
|
||||
|
||||
|
||||
public static string clientId { get; set; } = "ad502ec19e0c49ab9df14f83494e153c";
|
||||
public static string clientSecret { get; set; } = "bd52aba51737d03fc073711d386b3b0779d010ad";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -280,8 +284,6 @@ namespace TemuKJD.BLL.PddApi
|
||||
/// <returns></returns>
|
||||
static string PddApiRequest(string type, Dictionary<string,object> dict)
|
||||
{
|
||||
string clientId = "ad502ec19e0c49ab9df14f83494e153c";
|
||||
string clientSecret = "bd52aba51737d03fc073711d386b3b0779d010ad";
|
||||
|
||||
if (string.IsNullOrEmpty(type))
|
||||
return "{\"success\":false, \"error_msg\":\"调用接口不能为空\"}";
|
||||
|
||||
@@ -15,12 +15,15 @@ namespace TemuKJD.BLL.PddApi
|
||||
{
|
||||
public static void RefreshApi(ShopLoginInfo shop, bool isForceRefresh = false)
|
||||
{
|
||||
if (isForceRefresh || shop.AuthAddTime <= DateTime.Now.AddDays(-1))
|
||||
if (isForceRefresh || (shop.AuthAddTime <= DateTime.Now.AddDays(-1) && shop.AuthExpiresTime <= DateTime.Now))
|
||||
{
|
||||
shop.ApiAuthInfoList.Clear();
|
||||
|
||||
var authInfo = PddApiHelper.GetShopPddToken(shop);
|
||||
shop.ApiAuthInfoList.Add(authInfo);
|
||||
string errStr = "";
|
||||
var authInfo = PddApiHelper.GetE57ShopPddToken(shop, out errStr);
|
||||
if (errStr.IsNullOrEmpty())
|
||||
{
|
||||
shop.ApiAuthInfoList.RemoveAll(a => a.AppKey.IsNullOrEmpty() || a.AppKey == PddApi.clientId);
|
||||
shop.ApiAuthInfoList.Add(authInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,14 +35,18 @@ namespace TemuKJD.BLL.PddApi
|
||||
}
|
||||
}
|
||||
|
||||
public static AuthInfo GetShopPddToken(ShopLoginInfo shop)
|
||||
public static AuthInfo GetE57ShopPddToken(ShopLoginInfo shop, out string errorStr)
|
||||
{
|
||||
errorStr = "";
|
||||
var url = BaseClass.BuildObjString("shop/e57_get_pdd_shop_token");
|
||||
var data = UserLogin.GetSignaturex();
|
||||
data += "&mall_id=" + shop.MallId;
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":0"))
|
||||
{
|
||||
errorStr = BaseRegex.GetStringJson(ref html, "msg");
|
||||
if (string.IsNullOrEmpty(errorStr))
|
||||
errorStr = html;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -47,7 +54,7 @@ namespace TemuKJD.BLL.PddApi
|
||||
{
|
||||
ShopId = shop.ShopId,
|
||||
AddTime = DateTime.Now,
|
||||
AppKey = BaseRegex.GetStringJson(ref html, "appKey").ParseToString(),
|
||||
AppKey = PddApi.clientId, // BaseRegex.GetStringJson(ref html, "appKey").ParseToString(),
|
||||
AccessToken = BaseRegex.GetStringJson(ref html, "accessToken"),
|
||||
ExpiresTime = BaseClass.StampToDateTime(BaseRegex.GetIntJson(ref html, "tokenExpiresTime")),
|
||||
ApiAuthStatus = "授权成功",
|
||||
@@ -57,16 +64,17 @@ namespace TemuKJD.BLL.PddApi
|
||||
return new AuthInfo() { ShopId = shop.ShopId, AddTime = DateTime.Now, ExpiresTime = DateTime.Now };
|
||||
}
|
||||
|
||||
public static List<List<AuthInfo>> LstAuthInfos;
|
||||
public static void PddGetLocalTokens()
|
||||
{
|
||||
if (BaseClass.MainPath == "binxixi")
|
||||
{
|
||||
List<List<AuthInfo>> lsts = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<List<AuthInfo>>>("pdd_shop_api_auth_info_lists");
|
||||
if (lsts == null)
|
||||
lsts = new List<List<AuthInfo>>();
|
||||
LstAuthInfos = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<List<AuthInfo>>>("pdd_shop_api_auth_info_lists");
|
||||
if (LstAuthInfos == null)
|
||||
LstAuthInfos = new List<List<AuthInfo>>();
|
||||
foreach (var shop in GlobalConfig.ShopLoginList)
|
||||
{
|
||||
shop.ApiAuthInfoList = lsts.FirstOrDefault(l => l.FirstOrDefault()?.ShopId == shop.ShopId);
|
||||
shop.ApiAuthInfoList = LstAuthInfos.FirstOrDefault(l => l.FirstOrDefault()?.ShopId == shop.ShopId);
|
||||
if (shop.ApiAuthInfoList == null)
|
||||
shop.ApiAuthInfoList = new List<AuthInfo>();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user