1340 lines
53 KiB
C#
1340 lines
53 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using AllBase;
|
|
using System.Text.RegularExpressions;
|
|
using Work.Model;
|
|
|
|
namespace Work.Api
|
|
{
|
|
public class PinduoduoApiGetProduct
|
|
{
|
|
public ShopChatBase Shop;
|
|
public string Type;
|
|
public Dictionary<string, string> Data = new Dictionary<string, string>();
|
|
public static Dictionary<long, string> OutId = new Dictionary<long, string>();
|
|
public static Dictionary<string, List<ProductBase>> Product = new Dictionary<string, List<ProductBase>>();
|
|
public Order_list order;
|
|
public Decrypt decData = new Decrypt();
|
|
Dictionary<string, List<string>> dataDecryptList = new Dictionary<string, List<string>>();
|
|
|
|
Dictionary<string, string> dataDecryptListx = new Dictionary<string, string>();
|
|
public bool IsGetListByApi = false;
|
|
public string orderId;
|
|
public DecType decType;
|
|
|
|
public PinduoduoApiGetProduct(ShopChatBase shop)
|
|
{
|
|
Shop = shop;
|
|
}
|
|
public PinduoduoApiGetProduct(ShopChatBase shop, bool isGetListByApi)
|
|
{
|
|
Shop = shop;
|
|
IsGetListByApi = isGetListByApi;
|
|
}
|
|
public PinduoduoApiGetProduct(ShopChatBase shop, Order_list o)
|
|
{
|
|
Shop = shop;
|
|
order = o;
|
|
}
|
|
public PinduoduoApiGetProduct(ShopChatBase shop, Dictionary<string, List<string>> dataDecList)
|
|
{
|
|
Shop = shop;
|
|
dataDecryptList = dataDecList;
|
|
}
|
|
public PinduoduoApiGetProduct(ShopChatBase shop, string order_Id, DecType type)
|
|
{
|
|
Shop = shop;
|
|
orderId = order_Id;
|
|
decType = type;
|
|
}
|
|
|
|
public string GetRefund(DateTime begen, DateTime end, int page)
|
|
{
|
|
int start = BaseClass.GetTime(begen);
|
|
int after = BaseClass.GetTime(end);
|
|
Type = "pdd.refund.list.increment.get";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("after_sales_status", "1");
|
|
Data.Add("after_sales_type", "1");
|
|
Data.Add("start_updated_at", start.ToString());
|
|
Data.Add("end_updated_at", after.ToString());
|
|
Data.Add("page", page.ToString());
|
|
Data.Add("page_size", "100");
|
|
return GetData();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取订单详情
|
|
/// </summary>
|
|
/// <param name="status">状态:1:待发货,2:已发货待签收,3:已签收 5:全部</param>
|
|
/// <param name="refund_status">售后状态 1:无售后或售后关闭,2:售后处理中,3:退款中,4: 退款成功 5:全部</param>
|
|
/// <returns></returns>
|
|
public string GetOrderList(int status, int refund_status, DateTime begen, DateTime end, int page)
|
|
{
|
|
int start = BaseClass.GetTime(begen);
|
|
int after = BaseClass.GetTime(end);
|
|
Type = "pdd.order.list.get";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("order_status", status.ToString());
|
|
Data.Add("refund_status", refund_status.ToString());
|
|
Data.Add("start_confirm_at", start.ToString());
|
|
Data.Add("end_confirm_at", after.ToString());
|
|
Data.Add("page", page.ToString());
|
|
Data.Add("page_size", "100");
|
|
return GetData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取订单详情--添加use_has_next
|
|
/// </summary>
|
|
/// <param name="status">状态:1:待发货,2:已发货待签收,3:已签收 5:全部</param>
|
|
/// <param name="refund_status">售后状态 1:无售后或售后关闭,2:售后处理中,3:退款中,4: 退款成功 5:全部</param>
|
|
/// <returns></returns>
|
|
public string GetOrderListx(int status, int refund_status, DateTime begen, DateTime end, int page)
|
|
{
|
|
int start = BaseClass.GetTime(begen);
|
|
int after = BaseClass.GetTime(end);
|
|
Type = "pdd.order.list.get";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("order_status", status.ToString());
|
|
Data.Add("refund_status", refund_status.ToString());
|
|
Data.Add("start_confirm_at", start.ToString());
|
|
Data.Add("end_confirm_at", after.ToString());
|
|
Data.Add("page", page.ToString());
|
|
Data.Add("page_size", "100");
|
|
Data.Add("use_has_next", "true");
|
|
|
|
return GetData();
|
|
}
|
|
|
|
public string GetOrderInfo(string oid)
|
|
{
|
|
Type = "pdd.order.information.get";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("order_sn", oid);
|
|
return GetData();
|
|
}
|
|
|
|
public string GetRefundList(int after_sales_status, int after_sales_type, DateTime end_updated, int page, int page_size, DateTime start_updated)
|
|
{
|
|
int end_updated_at = BaseClass.GetTime(end_updated);
|
|
int start_updated_at = BaseClass.GetTime(start_updated);
|
|
Type = "pdd.refund.list.increment.get";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("after_sales_status", after_sales_status.ToString());
|
|
Data.Add("after_sales_type", after_sales_type.ToString());
|
|
Data.Add("end_updated_at", end_updated_at.ToString());
|
|
Data.Add("page", page.ToString());
|
|
Data.Add("page_size", page_size.ToString());
|
|
Data.Add("start_updated_at", start_updated_at.ToString());
|
|
return GetData();
|
|
}
|
|
|
|
public string GetRefundInfo(string after_sales_id, string order_sn)
|
|
{
|
|
Type = "pdd.refund.information.get";
|
|
Data = new Dictionary<string, string>();
|
|
if (!string.IsNullOrEmpty(after_sales_id))
|
|
{
|
|
Data.Add("after_sales_id", after_sales_id);
|
|
}
|
|
Data.Add("order_sn", order_sn);
|
|
return GetData();
|
|
}
|
|
|
|
public string CheckVirtualNumber(string indentify_number, string order_sn, string virtual_number)
|
|
{
|
|
Type = "pdd.open.virtual.number.check";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("indentify_number", indentify_number);
|
|
Data.Add("order_sn", order_sn);
|
|
Data.Add("virtual_number", virtual_number);
|
|
return GetData();
|
|
}
|
|
|
|
public string ChannelReport(string order_sn)
|
|
{
|
|
string order = "['" + order_sn + "']";
|
|
Type = "pdd.open.order.channel.report";
|
|
Data = new Dictionary<string, string>();
|
|
int channel = 0;// (new Random().Next(0, 11)) < BaseClass.bili ? 2 : 1;
|
|
Data.Add("order_channel", channel.ToString());
|
|
Data.Add("order_sn_list", order);
|
|
return GetData();
|
|
}
|
|
|
|
|
|
|
|
public string DecryptReceiverInfox()
|
|
{
|
|
if (dataDecryptList.Count == 0)
|
|
{
|
|
return "";
|
|
}
|
|
decData.data_decrypt_list = dataDecryptList;
|
|
if (decData.data_decrypt_list == null)
|
|
{
|
|
decData.data_decrypt_list = new Dictionary<string, List<string>>();
|
|
}
|
|
if (decData.data_decrypt_list == null)
|
|
{
|
|
return "";
|
|
}
|
|
decData.type = "pdd.open.decrypt.batch";
|
|
|
|
return GetDatax();
|
|
}
|
|
|
|
public string DecryptReceiverInfo(string order_sn, List<string> encData,string types,string verifyAuthToken="")
|
|
{
|
|
//DecData decData = new DecData();
|
|
//if (decData.data_list == null)
|
|
//{
|
|
// decData.data_list = new List<DecDataItem>();
|
|
//}
|
|
//for (int i = 0; i < encData.Count; i++)
|
|
//{
|
|
// DecDataItem item = new DecDataItem();
|
|
// item.data_tag = order_sn;
|
|
// item.encrypted_data = encData[i];
|
|
// decData.data_list.Add(item);
|
|
//}
|
|
|
|
//Data.Add("data_list", JsonHelper.SerializeObject(decData.data_list));
|
|
return GetDecryptData(types, order_sn, verifyAuthToken);
|
|
}
|
|
public string GetDecryptData(string types,string order_sn,string verifyAuthToken)
|
|
{
|
|
try
|
|
{
|
|
string token = Shop == null ? "" : !string.IsNullOrEmpty(Shop.AccessTokenOrder) ? Shop.AccessTokenOrder : Shop.AccessToken;
|
|
string refresh = Shop == null ? "" : !string.IsNullOrEmpty(Shop.RefreshTokenOrder) ? Shop.RefreshTokenOrder : Shop.RefreshToken;
|
|
string clientId = Shop.ClientId;
|
|
if (Data == null)
|
|
Data = new Dictionary<string, string>();
|
|
DateTime dateTime = BaseClass.GetServerTimeString(); //DateTime.Now;
|
|
Data.Add("type", Type);
|
|
Data.Add("data_type", "JSON");
|
|
Data.Add("timestamp", BaseClass.GetTime(dateTime).ToString());
|
|
Data.Add("client_id", clientId);
|
|
if (!string.IsNullOrEmpty(token))
|
|
Data.Add("access_token", token);
|
|
StringBuilder code = new StringBuilder();
|
|
Dictionary<string, string> nd = Data.OrderBy(d => d.Key).ToDictionary(p => p.Key, o => o.Value);
|
|
foreach (KeyValuePair<string, string> key in nd)
|
|
{
|
|
code.Append(key.Key + key.Value);
|
|
}
|
|
string html = "";
|
|
//if (PinduoduoAuth.GateServerUrlDic.ContainsKey(clientId))
|
|
//{
|
|
// int time = BaseClass.ConvertDateTimeInt(dateTime) + BaseClass.TimeDifferent;
|
|
// string time1 = UserLogin.Encryption(time);
|
|
// Data.Add("encCode", time1);
|
|
// if (BaseClass.NewSignatureAuth)
|
|
// {
|
|
// Data.Add("NbCodeVersion", "v1");
|
|
// }
|
|
// string json = JsonHelper.SerializeObject(Data);
|
|
// string data = "¶ms=" + json + "&order_sn=" + order_sn;
|
|
// //if (!PinduoduoAuth.GateServerUrlDic.ContainsKey(clientId))
|
|
// //{
|
|
// // return "";
|
|
// //}
|
|
|
|
// string geturl = "";
|
|
// foreach (KeyValuePair<string, string> item in BaseClass.serverDic)
|
|
// {
|
|
// if (item.Key == clientId)
|
|
// {
|
|
// geturl = item.Value;
|
|
// break;
|
|
// }
|
|
|
|
// }
|
|
// string redirect_url = "http://33.kanwailian.com//risk/control/callback";
|
|
// string htmls = new PinduoduoApiGetProduct(Shop).GetPageCode(redirect_url);
|
|
// string pageCode = BaseRegex.GetStringJson(ref htmls, "pageCode");
|
|
|
|
// //switch (types)
|
|
// //{
|
|
// // case "receiverName":
|
|
// // html = GetHtml.decryptPostUtf8(geturl+"pdd/control/decrypt/v1/receiverName" , data, verifyAuthToken, pageCode);
|
|
// // break;
|
|
// // case "receiverPhone":
|
|
// // html = GetHtml.decryptPostUtf8(geturl + "pdd/control/decrypt/v1/receiverPhone", data, verifyAuthToken, pageCode);
|
|
// // break;
|
|
// // case "address":
|
|
// // html = GetHtml.decryptPostUtf8(geturl + "pdd/control/decrypt/v1/address", data, verifyAuthToken, pageCode);
|
|
// // break;
|
|
// //}
|
|
//}
|
|
//else
|
|
//{
|
|
// if (PinduoduoAuth.GateServerUrlDicNoRds.ContainsKey(clientId))
|
|
// {
|
|
// html = GetServerInfoNoRds(dateTime, clientId);
|
|
// }
|
|
//}
|
|
html = GetHtml.Decode(html);
|
|
return html;
|
|
}
|
|
catch
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void GetProductList()
|
|
{
|
|
string shopName = Shop == null ? BaseClass.ShopName : Shop.ShopName;
|
|
if (string.IsNullOrEmpty(shopName) || Product.ContainsKey(shopName) && Product[shopName].Count > 0)
|
|
return;
|
|
List<ProductBase> pros = new List<ProductBase>();
|
|
try
|
|
{
|
|
Product.Add(shopName, pros);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
|
|
Type = "pdd.goods.list.get";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("page", "1");
|
|
Data.Add("is_onsale", "1");
|
|
//Data.Add("page_size", "50");
|
|
//Data.Add("outer_id", "");
|
|
string html = GetData();
|
|
int count = BaseRegex.GetIntJson(ref html, "total_count");
|
|
int page = count / 100 + 1;
|
|
for (int i = 1; i <= page; i++)
|
|
{
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("page", i.ToString());
|
|
Data.Add("is_onsale", "1");
|
|
//Data.Add("page_size", "50");
|
|
//Data.Add("outer_id", "");
|
|
if (i > 1)
|
|
html = GetData();
|
|
var m = BaseRegex.GetMatchRegex(ref html, @"\{""goods_id"":([\w\W]+?)\]\}");
|
|
for (int j = 0; m != null && j < m.Count; j++)
|
|
{
|
|
string list = m[j].Groups[0].Value;
|
|
long id = BaseRegex.GetLongJson(ref list, "goods_id");
|
|
var mm = BaseRegex.GetMatchRegex(ref list, @"""outer_goods_id"":""[\s]*([^""]+?)""");
|
|
string outId = "";
|
|
if (mm != null && mm.Count > 0)
|
|
outId = mm[mm.Count - 1].Groups[1].Value;
|
|
//if (string.IsNullOrEmpty(outId))
|
|
// outId = BaseRegex.GetStringJson(ref list, "");
|
|
if (!OutId.ContainsKey(id))
|
|
{
|
|
try
|
|
{
|
|
OutId.Add(id, outId);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
ProductBase p = new ProductBase();
|
|
p.Title = BaseRegex.GetStringJson(ref list, "goods_name");
|
|
p.Id = id;
|
|
p.OuterId = outId;
|
|
if (!string.IsNullOrEmpty(outId))
|
|
{
|
|
JumpUpProductNew ju = new JumpUpProductNew();
|
|
ju.Shop = Shop;
|
|
ju.GetUrl(id.ToString());
|
|
p.UpId = ju.UpId.ProductIdFrom;
|
|
}
|
|
pros.Add(p);
|
|
}
|
|
}
|
|
try
|
|
{
|
|
if (!Product.ContainsKey(shopName))
|
|
Product.Add(shopName, pros);
|
|
else
|
|
Product[shopName] = pros;
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 设置上下架
|
|
/// </summary>
|
|
/// <param name="pid"></param>
|
|
/// <param name="online"></param>
|
|
/// <returns></returns>
|
|
public string SetOnline(long pid, bool online)
|
|
{
|
|
Type = "pdd.goods.sale.status.set";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("goods_id", pid.ToString());
|
|
Data.Add("is_onsale", online ? "1" : "0");
|
|
return GetData();
|
|
}
|
|
/// <summary>
|
|
/// 设置库存
|
|
/// </summary>
|
|
/// <param name="sku_id"></param>
|
|
/// <param name="quantity"></param>
|
|
/// <returns></returns>
|
|
public string SetSku(long sku_id, int quantity)
|
|
{
|
|
Type = "pdd.goods.sku.stock.update";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("sku_id", sku_id.ToString());
|
|
Data.Add("quantity", quantity.ToString());
|
|
return GetData();
|
|
}
|
|
|
|
public string GetProduct(long pid)
|
|
{
|
|
Type = "pdd.goods.detail.get";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("goods_id", pid.ToString());
|
|
return GetData();
|
|
}
|
|
|
|
public string GetProductInfor(long pid)
|
|
{
|
|
Type = "pdd.goods.detail.get";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("goods_id", pid.ToString());
|
|
return GetData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加商品
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string Add()
|
|
{
|
|
Type = "pdd.goods.add";
|
|
return GetData();
|
|
}
|
|
public string Updata()
|
|
{
|
|
Type = "pdd.goods.information.update";
|
|
return GetData();
|
|
}
|
|
|
|
public string GetRelation(string pid)
|
|
{
|
|
Type = "pdd.goods.get.relation";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("pdd_goods_id", "[" + pid.ToString() + "]");
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
#region MyRegion
|
|
//public string GetDatax()
|
|
//{
|
|
// string client_id = String.IsNullOrEmpty(Shop.ClientId) ? BaseClass.ClientId : Shop.ClientId;
|
|
// if (!BaseClass.UserApi)
|
|
// return "";
|
|
// try
|
|
// {
|
|
// bool error = false;
|
|
// Agein:
|
|
// string token = Shop.AccessToken;
|
|
// string reflesh = Shop.RefreshToken;
|
|
// string sid = Shop == null ? BaseClass.ShopId : Shop.ShopId;
|
|
// if (Data == null)
|
|
// Data = new Dictionary<string, string>();
|
|
// if (Data.ContainsKey("type"))
|
|
// Data["type"] = Type;
|
|
// else
|
|
// Data.Add("type", Type);
|
|
// if (Type.Contains(".cps.") || Type.Contains(".coupon."))//进宝和优惠券
|
|
// {
|
|
// client_id = "911bd1c0c0a0403da88334e24ca288a2";//蛮牛ERP
|
|
// //token = Shop.CpsShop.AccessToken;
|
|
// }
|
|
// if (!Data.ContainsKey("type"))
|
|
// Data.Add("data_type", "JSON");
|
|
// if (Data.ContainsKey("timestamp"))
|
|
// Data["timestamp"] = BaseClass.GetTime(DateTime.Now).ToString();
|
|
// else
|
|
// Data.Add("timestamp", BaseClass.GetTime(DateTime.Now).ToString());
|
|
// if (Data.ContainsKey("client_id"))
|
|
// Data["client_id"] = client_id;
|
|
// else
|
|
// Data.Add("client_id", client_id);
|
|
// if (!string.IsNullOrEmpty(token))
|
|
// {
|
|
// if (Data.ContainsKey("access_token"))
|
|
// Data["access_token"] = token;
|
|
// else
|
|
// Data.Add("access_token", token);
|
|
// }
|
|
// if (Data.ContainsKey("sign"))
|
|
// Data.Remove("sign");
|
|
// string sign = "";
|
|
// StringBuilder code = new StringBuilder();
|
|
// Dictionary<string, string> nd = Data.OrderBy(d => d.Key).ToDictionary(p => p.Key, o => o.Value);
|
|
// foreach (KeyValuePair<string, string> key in nd)
|
|
// {
|
|
// code.Append(key.Key + key.Value);
|
|
// }
|
|
// sign = Md5Base.GetMd5(BaseClass.ApiKey + code + BaseClass.ApiKey).ToUpper();
|
|
|
|
// string url = BaseClass.BuildObjString("sign&act=get&type=" + Type + "&client_id=" + client_id);
|
|
// sign = GetHtml.PostUtf8(url, UserLogin.GetSignaturex(Shop.ShopId, Shop.ShopName) + "&hadid=1&signcode=" + GetHtml.UrlEncodeUtf8(code.ToString()));
|
|
// Data.Add("sign", sign);
|
|
// string json = JsonHelper.SerializeObject(Data);
|
|
// string html = GetPostTaobaoHtml.GetJsonPost(PinduoduoAuth.Gate, PinduoduoAuth.Gate, true, json);
|
|
// html = GetHtml.Decode(html);
|
|
// if (html.Contains("签名失败"))
|
|
// {
|
|
// //if (Shop.SignErrorTimes.ContainsKey(DateTime.Now.ToString("yyyy-MM-dd")))
|
|
// //{
|
|
// // Shop.SignErrorTimes[DateTime.Now.ToString("yyyy-MM-dd")] = Shop.SignErrorTimes[DateTime.Now.ToString("yyyy-MM-dd")] + 1;
|
|
// // if (Shop.SignErrorTimes[DateTime.Now.ToString("yyyy-MM-dd")] > 3)
|
|
// // html = "\"error_msg\":今日调用次数用完,明天再继续";
|
|
// //}
|
|
// //else
|
|
// // Shop.SignErrorTimes.Add(DateTime.Now.ToString("yyyy-MM-dd"), 1);
|
|
// return html;
|
|
// }
|
|
// if (!string.IsNullOrEmpty(html) && html.Contains("access_token已过期"))
|
|
// {
|
|
// var a = new PinduoduoAuth();
|
|
// if (a.ReFresh(reflesh, client_id))
|
|
// {
|
|
// html = GetPostTaobaoHtml.GetJsonPost(PinduoduoAuth.Gate, PinduoduoAuth.Gate, true, json);
|
|
// html = GetHtml.Decode(html);
|
|
// }
|
|
// }
|
|
// if (!string.IsNullOrEmpty(html) && (html.Contains("access_token") || html.Contains("暂未签署多多进宝") || html.Contains("授权已被取消") || html.Contains("clientId不正确") || html.Contains("access_token")) && !error)
|
|
// {
|
|
// var a = new PinduoduoAuth();
|
|
// a.NoCache = true;
|
|
// a.MustAuth = true;
|
|
// //a.IsCps = Type.Contains(".cps.") || Type.Contains(".coupon.");//进宝和优惠券
|
|
// //a.Auth(Shop, ref client_id);
|
|
// error = true;
|
|
// Data.Remove("type");
|
|
// Data.Remove("data_type");
|
|
// Data.Remove("client_id");
|
|
// Data.Remove("timestamp");
|
|
// if (Data.ContainsKey("access_token"))
|
|
// Data.Remove("access_token");
|
|
// Data.Remove("sign");
|
|
// //if (!a.IsCps && Type != "pdd.goods.outer.cat.mapping.get")
|
|
// // Thread.Sleep(3000);
|
|
// goto Agein;
|
|
// }
|
|
// return html;
|
|
// }
|
|
// catch
|
|
// {
|
|
// return "";
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 关联
|
|
/// </summary>
|
|
/// <param name="pid"></param>
|
|
/// <param name="fromId"></param>
|
|
/// <param name="minPrice">最低价 分</param>
|
|
/// <param name="maxPrice">最高价 分</param>
|
|
/// <param name="postAge">邮费 元</param>
|
|
/// <param name="fromSite">内部来源ID</param>
|
|
/// <returns></returns>
|
|
public string Relation(long pid, long fromId, int minPrice, int maxPrice, int postAge, int fromSite)
|
|
{
|
|
Type = "pdd.goods.relation.set";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("goods_id", pid.ToString());
|
|
Data.Add("out_goods_id", fromId.ToString());
|
|
//Data.Add("outer_detail_url", "1");
|
|
Data.Add("out_low_goods_price", minPrice.ToString());
|
|
Data.Add("out_high_goods_price", maxPrice.ToString());
|
|
Data.Add("source_type", fromSite.ToString());
|
|
Data.Add("postage", postAge.ToString());
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
#region 编辑商品
|
|
/// <summary>
|
|
/// 更新商品,然后设置关联映射(更新成功必须设置映射关系)。
|
|
/// 拼多多要求所有的商品必须与淘宝商品ID关联,且拼多多每个SKU价格小于等于淘宝价格*1.08。
|
|
/// 如果有以下情况:1.上家为拼多多商品、2.加价大于8%、3.单独有增加邮费,则去淘宝查找同款,获取单价大于当前加价后价格93%的
|
|
/// 淘宝ID,然后把价格和淘宝ID通过接口影射修改商品接口。其他情况,使用拼多多查询之前的映射关系,再次映射。如果无法通过以上
|
|
/// 办法获取映射,则想尽所有办法做一个正确的,甚至虚假的映射。
|
|
/// </summary>
|
|
/// <param name="pddRelation">关联参数类</param>
|
|
/// <returns></returns>
|
|
public string UpdataThenRelation()
|
|
{
|
|
//Dictionary<string, string> dataTemp = new Dictionary<string, string>();
|
|
//foreach (var keyValue in this.Data)
|
|
//{
|
|
// dataTemp.Add(keyValue.Key, keyValue.Value);
|
|
//}
|
|
string upResult = string.Empty;
|
|
|
|
#region 先判断是否有基本数据足以关联,不足直接退出
|
|
//if (pddRelation == null)
|
|
// pddRelation = new PinduoduoRelation();
|
|
//if (pddRelation.goods_id == null)
|
|
//{
|
|
// if (dataTemp.ContainsKey("goods_id"))
|
|
// {
|
|
// try
|
|
// {
|
|
// pddRelation.goods_id = Convert.ToInt64(dataTemp["goods_id"]);
|
|
// }
|
|
// catch
|
|
// {
|
|
// //LogSave.Add(Name, "拼多多id获取失败,跳过");
|
|
// return "拼多多id获取失败";
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// //LogSave.Add(Name, "拼多多id获取失败,跳过");
|
|
// return "拼多多id获取失败";
|
|
// }
|
|
//}
|
|
//if (pddRelation.out_low_goods_price == null || pddRelation.out_high_goods_price == null)
|
|
//{
|
|
// pddRelation.out_low_goods_price = int.MaxValue;
|
|
// pddRelation.out_high_goods_price = 0;
|
|
// if (dataTemp.ContainsKey("sku_list"))
|
|
// {
|
|
// var skuJson = dataTemp["sku_list"];
|
|
// var mPriceMatches = BaseRegex.GetMatchRegex(skuJson, "\"multi_price\":\"([\\s\\S]*?)\"");
|
|
// if (mPriceMatches.Count > 0)
|
|
// {
|
|
// foreach (Match mPriceMatch in mPriceMatches)
|
|
// {
|
|
// try
|
|
// {
|
|
// string strPrice = BaseRegex.GetMatchRegexString(mPriceMatch.ToString(), "\"multi_price\":\"([\\s\\S]*?)\"");
|
|
// long price = Convert.ToInt64(strPrice);
|
|
// if (price < pddRelation.out_low_goods_price)
|
|
// pddRelation.out_low_goods_price = price;
|
|
// if (price > pddRelation.out_high_goods_price)
|
|
// pddRelation.out_high_goods_price = price;
|
|
// }
|
|
// catch { }
|
|
// }
|
|
// pddRelation.out_low_goods_price = (long)(pddRelation.out_low_goods_price * 0.93);
|
|
// pddRelation.out_high_goods_price = (long)(pddRelation.out_high_goods_price * 0.93);
|
|
// }
|
|
// }
|
|
// if (pddRelation.out_low_goods_price == int.MaxValue)
|
|
// return "关联价格获取失败";
|
|
//}
|
|
#endregion
|
|
|
|
#region 获取其他关联数据
|
|
|
|
#region 通过接口获取关联数据
|
|
//if (pddRelation.out_goods_id == null || pddRelation.source_type == null)
|
|
//{
|
|
// string html = GetRelation(pddRelation.goods_id.ToString());
|
|
// // 有获取到对应的上家id
|
|
// if (html.Contains("out_goods_id") && html.Contains("out_goods_platform"))
|
|
// {
|
|
// if (pddRelation.out_goods_id == null)
|
|
// pddRelation.out_goods_id = BaseRegex.GetLongJson(ref html, "out_goods_id").ToString();
|
|
// if (pddRelation.source_type == null)
|
|
// pddRelation.source_type = BaseRegex.GetIntJson(ref html, "out_goods_platform");
|
|
// }
|
|
// else
|
|
// {
|
|
// // 未获取到上家id的情况,随机淘宝id,临时使用
|
|
// pddRelation.out_goods_id = "5" + Randomx.GetNumber(11);
|
|
// pddRelation.source_type = 0;
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
//if (pddRelation.postage == null)
|
|
// pddRelation.postage = 0;
|
|
#endregion
|
|
|
|
#region 更新商品
|
|
//this.Data = dataTemp;
|
|
upResult = this.Updata();
|
|
// 调用失败直接返回结果,不设置关联
|
|
//if (string.IsNullOrEmpty(upResult) || !upResult.Contains("\"is_success\":true"))
|
|
// return upResult;
|
|
#endregion
|
|
|
|
#region 设置关联
|
|
//try
|
|
//{
|
|
// string html = this.Relation(pddRelation.goods_id.Value, long.Parse(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"))
|
|
// LogSave.Add("", "关联设置失败,商品id是" + pddRelation.goods_id);
|
|
//}
|
|
//catch { }
|
|
#endregion
|
|
|
|
return upResult;
|
|
}
|
|
#endregion
|
|
|
|
#region 获取退货地址
|
|
/// <summary>
|
|
/// 获取退货地址
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string GetReturnGoodsAddress()
|
|
{
|
|
Type = "pdd.refund.address.list.get";
|
|
return GetData();
|
|
}
|
|
#endregion
|
|
|
|
public string ExpressSend(string order_sn, int logistics_id, string tracking_number, string refund_address_id = "")
|
|
{
|
|
Type = "pdd.logistics.online.send";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("order_sn", order_sn);
|
|
Data.Add("logistics_id", logistics_id.ToString());
|
|
Data.Add("tracking_number", tracking_number);
|
|
Data.Add("refund_address_id", refund_address_id);
|
|
return GetData();
|
|
}
|
|
|
|
public string Sync(string order_sn, int logistics_id, string tracking_number)
|
|
{
|
|
Type = "pdd.erp.order.sync";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("order_sn", order_sn);
|
|
Data.Add("order_state", "1");
|
|
Data.Add("logistics_id", logistics_id.ToString());
|
|
Data.Add("waybill_no", tracking_number);
|
|
return GetData();
|
|
}
|
|
|
|
public string UploadImage(byte[] bytes)
|
|
{
|
|
Type = "pdd.goods.image.upload";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("image", "data:image/jpeg;base64, " + Convert.ToBase64String(bytes));
|
|
return GetData();
|
|
}
|
|
/// <summary>
|
|
/// 获取分类
|
|
/// </summary>
|
|
/// <param name="parentId"></param>
|
|
/// <returns></returns>
|
|
public string GetCat(int parentId)
|
|
{
|
|
Type = "pdd.goods.cats.get";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("parent_cat_id", parentId.ToString());
|
|
return GetData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 解密脱敏
|
|
/// </summary>
|
|
/// <param name="parentId"></param>
|
|
/// <returns></returns>
|
|
public string DecryptionMask(string jsons)
|
|
{
|
|
//[{"data_tag":"","encrypted_data":""}]
|
|
Type = "pdd.open.decrypt.mask.batch";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("data_list", jsons);
|
|
return GetData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 解密
|
|
/// </summary>
|
|
/// <param name="parentId"></param>
|
|
/// <returns></returns>
|
|
public string DecryptionInformation(string jsons)
|
|
{
|
|
//[{"data_tag":"","encrypted_data":""}]
|
|
Type = "pdd.open.decrypt.batch";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("data_list", jsons);
|
|
return GetData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取订单同步服务的用户
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string GetOrderSyncUsers(int owner_id)
|
|
{
|
|
Type = "pdd.ddy.pdp.users.get";
|
|
Data = new Dictionary<string, string>();
|
|
if (owner_id > 0)
|
|
{
|
|
Data.Add("owner_id", owner_id.ToString());
|
|
}
|
|
return GetData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加订单同步服务的用户
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string AddOrderPushUsers(string rds_id)
|
|
{
|
|
Type = "pdd.ddy.pdp.user.add";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("rds_id", rds_id);
|
|
return GetData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取编辑ID详情
|
|
/// </summary>
|
|
/// <param name="cid"></param>
|
|
/// <returns></returns>
|
|
public string GetServerOrder(long mall_id)
|
|
{
|
|
Type = "pdd.vas.order.search";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("mall_id", mall_id.ToString());
|
|
Data.Add("page", "1");
|
|
Data.Add("page_size", "10");
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 刷新Access Token
|
|
/// </summary>
|
|
/// <param name="refresh_token"></param>
|
|
/// <returns></returns>
|
|
public string RefreshPddToken(string refresh_token)
|
|
{
|
|
Type = "pdd.pop.auth.token.refresh";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("refresh_token", refresh_token);
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
public string GetData()
|
|
{
|
|
try
|
|
{
|
|
bool error = false;
|
|
Agein:
|
|
string token = Shop == null ? "" : !string.IsNullOrEmpty(Shop.AccessTokenOrder) ? Shop.AccessTokenOrder : Shop.AccessToken;
|
|
string refresh = Shop == null ? "" : !string.IsNullOrEmpty(Shop.RefreshTokenOrder) ? Shop.RefreshTokenOrder : Shop.RefreshToken;
|
|
string clientId = Shop.ClientId;
|
|
if (Data == null)
|
|
Data = new Dictionary<string, string>();
|
|
DateTime dateTime = BaseClass.GetServerTimeString(); //DateTime.Now;
|
|
Data.Add("type", Type);
|
|
Data.Add("data_type", "JSON");
|
|
Data.Add("timestamp", BaseClass.GetTime(dateTime).ToString());
|
|
Data.Add("client_id", clientId);
|
|
//token = "4496d5bdf7b54e15ba7c9bde60e52fbc93e8dd71";
|
|
if (!string.IsNullOrEmpty(token))
|
|
Data.Add("access_token", token);
|
|
StringBuilder code = new StringBuilder();
|
|
Dictionary<string, string> nd = Data.OrderBy(d => d.Key).ToDictionary(p => p.Key, o => o.Value);
|
|
foreach (KeyValuePair<string, string> key in nd)
|
|
{
|
|
code.Append(key.Key + key.Value);
|
|
}
|
|
//string sign = Md5Base.GetMd5(BaseClass.ApiKey + code + BaseClass.ApiKey).ToUpper();
|
|
//string url = BaseClass.BuildObjString("sign&act=get&type=" + Type + "&client_id=" + clientId);
|
|
//if (clientId == "9558f920cf77403bb475243fe44482ad")
|
|
//{
|
|
// url = "http://sign.qixiaoke.com/api/psb_sign.php?&type=" + Type + "&client_id=" + clientId;
|
|
//}
|
|
////else
|
|
////{
|
|
//// url = BaseClass.BuildObjString("sign&act=get&type=" + Type + "&client_id=" + clientId);
|
|
////}
|
|
//sign = GetHtml.PostUtf8(url, UserLogin.GetSignaturex(Shop.ShopId, Shop.ShopName) + "&signcode=" + GetHtml.UrlEncodeUtf8(code.ToString()));
|
|
//if (string.IsNullOrEmpty(sign) || sign.Length != 32)
|
|
//{
|
|
// Thread.Sleep(5000);
|
|
// sign = GetHtml.PostUtf8(url, UserLogin.GetSignaturex(Shop.ShopId, Shop.ShopName) + "&signcode=" + GetHtml.UrlEncodeUtf8(code.ToString()));
|
|
//}
|
|
//Data.Add("sign", sign);
|
|
string html = "";
|
|
string json = "";
|
|
//if ((clientId == "9558f920cf77403bb475243fe44482ad" || clientId == "7feaefdf527d45129219ca398c922bb0")
|
|
//if (PinduoduoAuth.GateServerUrlDic.ContainsKey(clientId))
|
|
//{
|
|
// html = GetOrderInfo(dateTime, clientId);
|
|
//}
|
|
//else
|
|
//{
|
|
// if (PinduoduoAuth.GateServerUrlDicNoRds.ContainsKey(clientId))
|
|
// {
|
|
// html = GetServerInfoNoRds(dateTime, clientId);
|
|
// }
|
|
// //else
|
|
// //{
|
|
// // //string sign = Md5Base.GetMd5(BaseClass.ApiKey + code + BaseClass.ApiKey).ToUpper();
|
|
// // string url = BaseClass.BuildObjString("sign&act=get&type=" + Type + "&client_id=" + clientId);
|
|
// // string sign = GetHtml.PostUtf8(url, UserLogin.GetSignaturex(Shop.ShopId, Shop.ShopName) + "&signcode=" + GetHtml.UrlEncodeUtf8(code.ToString()));
|
|
// // Data.Add("sign", sign);
|
|
// // json = JsonHelper.SerializeObject(Data);
|
|
|
|
// // html = GetPostTaobaoHtml.GetJsonPost(PinduoduoAuth.Gate, PinduoduoAuth.Gate, true, json);
|
|
// //}
|
|
//}
|
|
html = GetHtml.Decode(html);
|
|
//if (!string.IsNullOrEmpty(html) && html.Contains("access_token已过期"))
|
|
//{
|
|
// Shop.AccessTokenOrder = "";
|
|
// Shop.RefreshTokenOrder = "";
|
|
|
|
// var a = new PinduoduoAuth();
|
|
|
|
// if (!string.IsNullOrEmpty(refresh))
|
|
// {
|
|
// a.ReFresh(refresh);
|
|
// html = GetPostTaobaoHtml.GetJsonPost(PinduoduoAuth.Gate, PinduoduoAuth.Gate, true, json);
|
|
// html = GetHtml.Decode(html);
|
|
// }
|
|
//}
|
|
//if (!string.IsNullOrEmpty(html) && (html.Contains("授权已被取消") || html.Contains("clientId不正确") || html.Contains("access_token")) && !error)
|
|
//{
|
|
// var a = new PinduoduoAuth();
|
|
// a.NoCache = true;
|
|
// a.MustAuth = true;
|
|
// a.Auth(Shop);
|
|
// error = true;
|
|
// Data.Remove("type");
|
|
// Data.Remove("data_type");
|
|
// Data.Remove("client_id");
|
|
// Data.Remove("timestamp");
|
|
// if (Data.ContainsKey("access_token"))
|
|
// Data.Remove("access_token");
|
|
// Data.Remove("sign");
|
|
// Thread.Sleep(3000);
|
|
// goto Agein;
|
|
//}
|
|
return html;
|
|
}
|
|
catch
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
#region 处理风控解密相关
|
|
|
|
/// <summary>
|
|
/// 获取编辑ID详情
|
|
/// </summary>
|
|
/// <param name="cid"></param>
|
|
/// <returns></returns>
|
|
public string GetPageCode(string redirect_url)
|
|
{
|
|
//List<string> mallIdList = new List<string>();
|
|
//mallIdList.Add(Shop.MallId.ToString());
|
|
|
|
//string[] str = mallIdList.ToArray();
|
|
string mallIdArr = "[" + Shop.MallId + "]";
|
|
Type = "pdd.cloud.isv.page.code";
|
|
Data = new Dictionary<string, string>();
|
|
Data.Add("mallIdList", mallIdArr);
|
|
Data.Add("httpReferer", redirect_url);
|
|
Data.Add("userId", BaseClass.UserId.ToString());
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
#endregion
|
|
|
|
#region 拼商宝|螃蟹工具|奶爸助理|途途 等
|
|
private string GetOrderInfo(DateTime dateTime, string clientId)
|
|
{
|
|
int time = BaseClass.ConvertDateTimeInt(dateTime) + BaseClass.TimeDifferent;
|
|
string time1 = UserLogin.Encryption(time);
|
|
Data.Add("encCode", time1);
|
|
if (BaseClass.NewSignatureAuth)
|
|
{
|
|
Data.Add("NbCodeVersion", "1");
|
|
}
|
|
if (Type == "pdd.order.list.get" || Type == "pdd.order.information.get")
|
|
{
|
|
Data.Add("mall_id", Shop.MallId.ToString());
|
|
if (clientId == "716a6bcc69d7441d856905eb79b892fd" && IsGetListByApi)
|
|
{
|
|
if (Type == "pdd.order.list.get")
|
|
{
|
|
Data.Add("getOrderListFromPdd", "1");
|
|
}
|
|
if (Type == "pdd.order.information.get")
|
|
{
|
|
Data.Add("getOrderInformationFromPdd", "1");
|
|
}
|
|
}
|
|
}
|
|
string json = JsonHelper.SerializeObject(Data);
|
|
string data = "¶ms=" + json;
|
|
if (data.Contains("698250794")&& data.Contains("\"page\":\"1\"") && data.Contains("pdd.order.list.get"))
|
|
{
|
|
|
|
}
|
|
//if (!PinduoduoAuth.GateServerUrlDic.ContainsKey(clientId))
|
|
//{
|
|
// return "";
|
|
//}
|
|
string url = "";
|
|
//foreach (KeyValuePair<string, string> item in PinduoduoAuth.GateServerUrlDic)
|
|
// {
|
|
// if (item.Key == clientId)
|
|
// {
|
|
// url = item.Value;
|
|
// break;
|
|
// }
|
|
|
|
// }
|
|
string html = GetHtml.PostUtf8(url, data);
|
|
return html;
|
|
}
|
|
|
|
|
|
private string GetDecData(DateTime dateTime, string clientId)
|
|
{
|
|
int time = BaseClass.ConvertDateTimeInt(dateTime) + BaseClass.TimeDifferent;
|
|
string time1 = UserLogin.Encryption(time);
|
|
decData.encCode = time1;
|
|
if (BaseClass.NewSignatureAuth)
|
|
{
|
|
decData.NbCodeVersion = "1";
|
|
}
|
|
string json = JsonHelper.SerializeObject(decData);
|
|
|
|
//string data = "¶ms=" + json;
|
|
//if (!PinduoduoAuth.GateServerUrlDic.ContainsKey(clientId))
|
|
//{
|
|
// return "";
|
|
//}
|
|
string url = "";
|
|
//foreach (KeyValuePair<string, string> item in PinduoduoAuth.GateServerUrlDic)
|
|
//{
|
|
// if (item.Key == clientId)
|
|
// {
|
|
// url = item.Value;
|
|
// break;
|
|
// }
|
|
|
|
//}
|
|
|
|
string html = GetHtml.PostUtf8(url, json);
|
|
return html;
|
|
}
|
|
#endregion
|
|
|
|
public string GetDatax()
|
|
{
|
|
try
|
|
{
|
|
string token = Shop == null ? "" : !string.IsNullOrEmpty(Shop.AccessTokenOrder) ? Shop.AccessTokenOrder : Shop.AccessToken;
|
|
string refresh = Shop == null ? "" : !string.IsNullOrEmpty(Shop.RefreshTokenOrder) ? Shop.RefreshTokenOrder : Shop.RefreshToken;
|
|
string clientId = Shop.ClientId;
|
|
DateTime dateTime = BaseClass.GetServerTimeString(); //DateTime.Now;
|
|
decData.data_type = "JSON";
|
|
decData.timestamp = BaseClass.GetTime(dateTime).ToString();
|
|
decData.client_id = clientId;
|
|
if (!string.IsNullOrEmpty(token))
|
|
{
|
|
decData.access_token = token;
|
|
}
|
|
|
|
string html = "";
|
|
//if (PinduoduoAuth.GateServerUrlDic.ContainsKey(clientId))
|
|
//{
|
|
// html = GetDecData(dateTime, clientId);
|
|
//}
|
|
//else
|
|
//{
|
|
// if (PinduoduoAuth.GateServerUrlDicNoRds.ContainsKey(clientId))
|
|
// {
|
|
// html = GetServerInfoNoRds(dateTime, clientId);
|
|
// }
|
|
//}
|
|
html = GetHtml.Decode(html);
|
|
|
|
return html;
|
|
}
|
|
catch
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
#region 新解密
|
|
public string GetDecDataNew()
|
|
{
|
|
try
|
|
{
|
|
|
|
string clientId = Shop.ClientId;
|
|
|
|
string html = "";
|
|
if (BaseClass.serverDic.ContainsKey(clientId))
|
|
{
|
|
html = GetDecDatax(clientId);
|
|
html = GetHtml.Decode(html);
|
|
}
|
|
return html;
|
|
}
|
|
catch
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
private string GetDecDatax(string clientId)
|
|
{
|
|
//Data = new Dictionary<string, string>();
|
|
//Data.Add("order_sn", orderId);
|
|
//string json = JsonHelper.SerializeObject(Data);
|
|
if (!BaseClass.serverDic.ContainsKey(clientId))
|
|
{
|
|
return "";
|
|
}
|
|
string url = BaseClass.serverDic[clientId];
|
|
if (decType == DecType.receiverPhone)
|
|
{
|
|
url += "pdd/control/decrypt/v1/receiverPhone";
|
|
}
|
|
else if (decType == DecType.receiverName)
|
|
{
|
|
url += "pdd/control/decrypt/v1/receiverName";
|
|
}
|
|
else if (decType == DecType.receiverAddress)
|
|
{
|
|
url += "pdd/control/decrypt/v1/address";
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
string data = "&order_sn=" + orderId;
|
|
data += "&decrypt_report_type=2";
|
|
string html = GetHtml.PostUtf8ForOplb(url, data, Shop.verify_auth_token);
|
|
|
|
//string htmlx = GetHtml.PostUtf8(url, json);
|
|
//string html = GetPostTaobaoHtml.GetJsonPostx(url, url, true, json, Shop.verify_auth_token);
|
|
return html;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 未绑定rds的服务
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="dateTime"></param>
|
|
/// <param name="clientId"></param>
|
|
/// <returns></returns>
|
|
private string GetServerInfoNoRds(DateTime dateTime, string clientId)
|
|
{
|
|
int time = BaseClass.ConvertDateTimeInt(dateTime) + BaseClass.TimeDifferent;
|
|
string time1 = UserLogin.Encryption(time);
|
|
Data.Add("encCode", time1);
|
|
if (BaseClass.NewSignatureAuth)
|
|
{
|
|
Data.Add("NbCodeVersion", "1");
|
|
}
|
|
string json = JsonHelper.SerializeObject(Data);
|
|
string data = "¶ms=" + json;
|
|
//if (!PinduoduoAuth.GateServerUrlDicNoRds.ContainsKey(clientId))
|
|
//{
|
|
// return "";
|
|
//}
|
|
string url = "";
|
|
//foreach (KeyValuePair<string, string> item in PinduoduoAuth.GateServerUrlDicNoRds)
|
|
//{
|
|
// if (item.Key == clientId)
|
|
// {
|
|
// url = item.Value;
|
|
// break;
|
|
// }
|
|
|
|
//}
|
|
|
|
string html = GetHtml.PostUtf8(url, data);
|
|
return html;
|
|
}
|
|
#endregion
|
|
|
|
#region 请求服务
|
|
|
|
#region 获取订单
|
|
|
|
/// <summary>
|
|
/// 获取订单列表--添加use_has_next
|
|
/// </summary>
|
|
/// <param name="status">状态:1:待发货,2:已发货待签收,3:已签收 5:全部</param>
|
|
/// <param name="refund_status">售后状态 1:无售后或售后关闭,2:售后处理中,3:退款中,4: 退款成功 5:全部</param>
|
|
/// <returns></returns>
|
|
//public string GetOrderListByServer(int status, int refund_status, DateTime begen, DateTime end, int page)
|
|
//{
|
|
// int start = BaseClass.GetTime(begen);
|
|
// int after = BaseClass.GetTime(end);
|
|
|
|
// Dictionary<string, string> Data = new Dictionary<string, string>();
|
|
// string token = Shop == null ? "" : !string.IsNullOrEmpty(Shop.AccessTokenOrder) ? Shop.AccessTokenOrder : Shop.AccessToken;
|
|
// Data.Add("access_token", token);
|
|
// Data.Add("order_status", status.ToString());
|
|
// Data.Add("refund_status", refund_status.ToString());
|
|
// Data.Add("start_confirm_at", start.ToString());
|
|
// Data.Add("end_confirm_at", after.ToString());
|
|
// Data.Add("page", page.ToString());
|
|
// Data.Add("page_size", "100");
|
|
// Data.Add("use_has_next", "true");
|
|
// Data.Add("method", "pdd.order.list.get");
|
|
// string paramsArr = JsonHelper.SerializeObject(Data);
|
|
// string data = "¶ms=" + paramsArr + DataParams();
|
|
// return PostServer(data);
|
|
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 发货
|
|
/// <summary>
|
|
/// 发货
|
|
/// </summary>
|
|
/// <param name="order_id">订单编号</param>
|
|
/// <param name="refund_address_id">退货地址</param>
|
|
/// <param name="tracking_number">快递单号</param>
|
|
/// <param name="logistics_id">快递编号</param>
|
|
/// <returns></returns>
|
|
public string OrderSendByServer(string order_id, string refund_address_id, string tracking_number, int logistics_id)
|
|
{
|
|
Dictionary<string, string> Data = new Dictionary<string, string>();
|
|
|
|
string token = Shop == null ? "" : !string.IsNullOrEmpty(Shop.AccessTokenOrder) ? Shop.AccessTokenOrder : Shop.AccessToken;
|
|
Data.Add("access_token", token);
|
|
Data.Add("logistics_id", logistics_id.ToString());
|
|
Data.Add("order_sn", order_id);
|
|
Data.Add("refund_address_id", refund_address_id);
|
|
Data.Add("tracking_number", tracking_number);
|
|
Data.Add("type", "pdd.logistics.online.send");
|
|
Data.Add("timestamp", BaseClass.GetTime(DateTime.Now).ToString());
|
|
int time = BaseClass.ConvertDateTimeInt(DateTime.Now) + BaseClass.TimeDifferent;
|
|
string time1 = UserLogin.Encryption(time);
|
|
Data.Add("encCode", time1);
|
|
if (BaseClass.NewSignatureAuth)
|
|
{
|
|
Data.Add("NbCodeVersion", "1");
|
|
}
|
|
string json = JsonHelper.SerializeObject(Data);
|
|
string data = "¶ms=" + json;
|
|
string clientId = Shop.ClientId;
|
|
return PostServer(data, clientId);
|
|
}
|
|
#endregion
|
|
|
|
//公共参数
|
|
private string DataParams()
|
|
{
|
|
int time = BaseClass.ConvertDateTimeInt(DateTime.Now) + BaseClass.TimeDifferent;
|
|
string time1 = UserLogin.Encryption(time);
|
|
string data = "&code=" + time1 + "&time=" + BaseClass.GetTime(DateTime.Now).ToString();
|
|
return data;
|
|
}
|
|
|
|
private string PostServer(string data, string clientId)
|
|
{
|
|
string url = "";
|
|
//foreach (KeyValuePair<string, string> item in PinduoduoAuth.GateServerUrlDic)
|
|
//{
|
|
// if (item.Key == clientId)
|
|
// {
|
|
// url = item.Value;
|
|
// break;
|
|
// }
|
|
|
|
//}
|
|
string html = GetHtml.PostUtf8(url, data);
|
|
return html;
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
|
|
|
public class Decrypt
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string type { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string data_type { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string timestamp { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string client_id { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string access_token { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string encCode { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public Dictionary<string, List<string>> data_decrypt_list { get; set; }
|
|
|
|
public string NbCodeVersion { get; set; }
|
|
}
|
|
|
|
public enum DecType
|
|
{
|
|
receiverPhone,
|
|
receiverName,
|
|
receiverAddress
|
|
}
|
|
|
|
|
|
#region 订单解密类--新方式
|
|
public class DecData
|
|
{
|
|
public List<DecDataItem> data_list { get; set; }
|
|
}
|
|
|
|
public class DecDataItem
|
|
{
|
|
public string data_tag { get; set; }
|
|
|
|
public string encrypted_data { get; set; }
|
|
}
|
|
#endregion
|
|
|
|
}
|