1拼多多接口上传及相关功能(不含部分功能) 2拼多多选品
This commit is contained in:
1 parent
ff42506091
commit
07b912e9eb
37 files changed
+21117
-206
No files matched your search
@@ -19,6 +19,11 @@ namespace TemuKJD.BLL.PddApi
|
||||
|
||||
public PddApi(ShopLoginInfo shop)
|
||||
{
|
||||
if (shop.CurrentAuthInfo == null)
|
||||
{
|
||||
PddApiHelper.RefreshApi(shop);
|
||||
}
|
||||
|
||||
Data["access_token"] = shop.AccessToken;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AllBase;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.Result;
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
@@ -12,6 +13,25 @@ namespace TemuKJD.BLL.PddApi
|
||||
{
|
||||
public class PddApiHelper
|
||||
{
|
||||
public static void RefreshApi(ShopLoginInfo shop, bool isForceRefresh = false)
|
||||
{
|
||||
if (isForceRefresh || shop.AuthAddTime <= DateTime.Now.AddDays(-1))
|
||||
{
|
||||
shop.ApiAuthInfoList.Clear();
|
||||
|
||||
var authInfo = PddApiHelper.GetShopPddToken(shop);
|
||||
shop.ApiAuthInfoList.Add(authInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RefreshApi(List<ShopLoginInfo> shops, bool isForceRefresh = false)
|
||||
{
|
||||
foreach (var shop in shops)
|
||||
{
|
||||
RefreshApi(shop, isForceRefresh);
|
||||
}
|
||||
}
|
||||
|
||||
public static AuthInfo GetShopPddToken(ShopLoginInfo shop)
|
||||
{
|
||||
var url = BaseClass.BuildObjString("shop/e57_get_pdd_shop_token");
|
||||
@@ -26,13 +46,31 @@ namespace TemuKJD.BLL.PddApi
|
||||
var token = new AuthInfo()
|
||||
{
|
||||
ShopId = shop.ShopId,
|
||||
AppKey = BaseClass.GetFileMd5(BaseRegex.GetStringJson(ref html, "appKey").ParseToString()),
|
||||
AddTime = DateTime.Now,
|
||||
AppKey = BaseRegex.GetStringJson(ref html, "appKey").ParseToString(),
|
||||
AccessToken = BaseRegex.GetStringJson(ref html, "accessToken"),
|
||||
ExpiresTime = BaseClass.StampToDateTime(BaseRegex.GetIntJson(ref html, "tokenExpiresTime")),
|
||||
ApiAuthStatus = "授权成功",
|
||||
};
|
||||
return token;
|
||||
}
|
||||
return new AuthInfo() { ShopId = shop.ShopId, AccessToken = "", ExpiresTime = DateTime.Now };
|
||||
return new AuthInfo() { ShopId = shop.ShopId, AddTime = DateTime.Now, ExpiresTime = DateTime.Now };
|
||||
}
|
||||
|
||||
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>>();
|
||||
foreach (var shop in GlobalConfig.ShopLoginList)
|
||||
{
|
||||
shop.ApiAuthInfoList = lsts.FirstOrDefault(l => l.FirstOrDefault()?.ShopId == shop.ShopId);
|
||||
if (shop.ApiAuthInfoList == null)
|
||||
shop.ApiAuthInfoList = new List<AuthInfo>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user