优化了微店商品上传 优化pdd买手读单

This commit is contained in:
wule committed 2026-04-15 21:04:37 +08:00
1 parent 6c4f16b897
commit f360688c43
62 files changed
+5620 -1432

No files matched your search

+32 -20
View File
@@ -1,4 +1,5 @@
using AllBase;
using AllBase.Helper;
using AllBase.Model.Result;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
@@ -25,8 +26,18 @@ namespace TemuKJD.BLL.PddApi
}
Data["access_token"] = shop.AccessToken;
Data["client_id"] = shop.AppKey;
}
/// <summary>
/// 貔貅管家
/// </summary>
public static string clientId_pi_xiu_guan_jia { get; set; } = "ad502ec19e0c49ab9df14f83494e153c";
///// <summary>
///// 小红椒商品管理
///// </summary>
//public static string clientId_xiao_hong_jiao_ { get; set; } = "48e76c60853d47d8a4e2e631b6db26b5";
public string PddGoodsAdd()
{
string type = "pdd.goods.add";
@@ -91,11 +102,11 @@ namespace TemuKJD.BLL.PddApi
return html;
}
public string PddPopAuthTokenCreate()
public string PddPopAuthTokenCreate(string code)
{
string type = "pdd.pop.auth.token.create";
if (!Data.Keys.Contains("code"))
Data["code"] = "83be994d5ed04e6cb9643a423094a3296bf8827a";
Data["code"] = code; //"83be994d5ed04e6cb9643a423094a3296bf8827a";
string html = PddApiRequest(type, Data);
return html;
}
@@ -103,7 +114,7 @@ namespace TemuKJD.BLL.PddApi
/// <summary>
/// 关联
/// </summary>
/// <param name="pid"></param>
/// <param name="goodsId"></param>
/// <param name="outGoodsId"></param>
/// <param name="minPrice">最低价 分</param>
/// <param name="maxPrice">最高价 分</param>
@@ -114,12 +125,11 @@ namespace TemuKJD.BLL.PddApi
/// 15-折800,16-当当,17-青创网,18-开山网,19-新款网
/// </param>
/// <returns></returns>
public string Relation2603(long pid, long outGoodsId, int minPrice, int maxPrice, int postAge, int sourceType)
public string Relation2603(long goodsId, string outGoodsId, int minPrice, int maxPrice, int postAge, int sourceType)
{
string type = "pdd.goods.relation.set";
Data = new Dictionary<string, object>();
Data.Add("goods_id", pid.ToString());
Data.Add("out_goods_id", outGoodsId.ToString());
Data["goods_id"] = goodsId.ToString();
Data["out_goods_id"] = outGoodsId.ToString();
string detailUrl = "";
if (sourceType == 0)
detailUrl = "https://item.taobao.com/item.htm?id=" + outGoodsId;
@@ -129,11 +139,11 @@ namespace TemuKJD.BLL.PddApi
detailUrl = "https://weidian.com/item.html?itemID=" + outGoodsId;
else if (sourceType == 1)
detailUrl = "https://item.jd.com/" + outGoodsId + ".html";
Data.Add("out_detail_url", detailUrl);
Data.Add("out_low_goods_price", minPrice.ToString());
Data.Add("out_high_goods_price", maxPrice.ToString());
Data.Add("source_type", sourceType.ToString());
Data.Add("postage", postAge.ToString());
Data["out_detail_url"] = detailUrl;
Data["out_low_goods_price"] = minPrice.ToString();
Data["out_high_goods_price"] = maxPrice.ToString();
//Data["source_type"] = sourceType.ToString();
Data["postage"] = postAge.ToString();
string html = PddApiRequest(type, Data);
return html;
}
@@ -255,7 +265,7 @@ namespace TemuKJD.BLL.PddApi
#region 设置关联
try
{
string html = this.Relation2603(pddRelation.goods_id.Value, long.Parse(pddRelation.out_goods_id),
string html = this.Relation2603(pddRelation.goods_id.Value, pddRelation.out_goods_id,
(int)pddRelation.out_low_goods_price.Value, (int)pddRelation.out_high_goods_price,
(int)pddRelation.postage.Value, pddRelation.source_type.Value);
if (string.IsNullOrEmpty(html) || !html.Contains("\"is_success\":true"))
@@ -272,10 +282,6 @@ namespace TemuKJD.BLL.PddApi
return upResult;
}
public static string clientId { get; set; } = "ad502ec19e0c49ab9df14f83494e153c";
public static string clientSecret { get; set; } = "bd52aba51737d03fc073711d386b3b0779d010ad";
/// <summary>
///
/// </summary>
@@ -283,18 +289,24 @@ namespace TemuKJD.BLL.PddApi
/// <param name="dict">拼多多接口入参</param>
/// <returns></returns>
static string PddApiRequest(string type, Dictionary<string,object> dict)
{
{
if (string.IsNullOrEmpty(type))
return "{\"success\":false, \"error_msg\":\"调用接口不能为空\"}";
if (dict == null)
return "{\"success\":false, \"error_msg\":\"参数数组不能为空\"}";
if (!dict.Keys.Contains("client_id") || string.IsNullOrEmpty(dict["client_id"].ParseToString()))
return "{\"success\":false, \"error_msg\":\"调用Api编号不能为空\"}";
if (!dict.Keys.Contains("access_token") || string.IsNullOrWhiteSpace(dict["access_token"].ParseToString()))
return "{\"success\":false, \"error_msg\":\"调用令牌不能为空\"}";
var clientSecret = GlobalConfig.PddClentInfoList.FirstOrDefault(c => c.client_id == dict["client_id"].ParseToString())?.client_secret;
if (clientSecret.IsNullOrEmpty())
return "{\"success\":false, \"error_msg\":\"调用密钥不能为空\"}";
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
var timeStamp = (long)(DateTime.Now - startTime).TotalMilliseconds;
dict["type"] = type;
dict["client_id"] = clientId;
dict["timestamp"] = timeStamp.ToString();
dict["data_type"] = "JSON";