322 lines
11 KiB
C#
322 lines
11 KiB
C#
using AllBase;
|
|
using AllBase.Model.DBModel;
|
|
using AllBase.Model.Result;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Work.Api
|
|
{
|
|
public class DouyinApi
|
|
{
|
|
public Dictionary<string, string> Data = new Dictionary<string, string>();
|
|
public Dictionary<string, string> JsonData = new Dictionary<string, string>();
|
|
public ShopLoginInfo Shop = null;
|
|
public string Type, Name;
|
|
public string path = "";
|
|
public static string Gate = "https://openapi-fxg.jinritemai.com/";
|
|
public DouyinApi(ShopLoginInfo shop)
|
|
{
|
|
Shop = shop;
|
|
}
|
|
|
|
public string GetDataDouyin()
|
|
{
|
|
|
|
return "";
|
|
}
|
|
/// <summary>
|
|
/// 订单备注
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string AddOrderRemark()
|
|
{
|
|
path = "/order/addOrderRemark";
|
|
Type = "order.addOrderRemark";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
/// <summary>
|
|
/// 售后
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string GetAfterSaleOrder()
|
|
{
|
|
path = "/afterSale/List";
|
|
Type = "afterSale.List";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
/// <summary>
|
|
/// 脱敏
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string GetOrderbatchSensitive()
|
|
{
|
|
path = "/order/batchSensitive";
|
|
Type = "order.batchSensitive";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
public string GetOrderBatchDecrypt()
|
|
{
|
|
path = "/order/batchDecrypt";
|
|
Type = "order.batchDecrypt";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
public string GetOrderList()
|
|
{
|
|
path = "/order/searchList";
|
|
Type = "order.searchList";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
public string GetOrderDetail()
|
|
{
|
|
path = "/order/orderDetail";
|
|
Type = "order.orderDetail";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 读取售后详情
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string GetAfterSaleDetail()
|
|
{
|
|
path = "/afterSale/Detail";
|
|
Type = "afterSale.Detail";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
public string GetShopBrandList()
|
|
{
|
|
path = "/shop/brandList";
|
|
Type = "shop.brandList";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
public string GetOrderLogisticsCompanyList()
|
|
{
|
|
path = "/order/logisticsCompanyList";
|
|
Type = "order.logisticsCompanyList";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
public string GetAddressProvince()
|
|
{
|
|
path = "/address/getProvince";
|
|
Type = "address.getProvince";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
public string GetAreasByProvince(string province_id)
|
|
{
|
|
path = "/address/getAreasByProvince";
|
|
Type = "address.getAreasByProvince";
|
|
JsonData["province_id"] = province_id;
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
public string AfterSaleOperate()
|
|
{
|
|
path = "/afterSale/operate";
|
|
Type = "afterSale.operate";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 物流发货
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string OrderLogisticsAdd()
|
|
{
|
|
path = "/order/logisticsAdd";
|
|
Type = "order.logisticsAdd";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
public string CreateOrder()
|
|
{
|
|
path = "/logistics/newCreateOrder";
|
|
Type = "logistics.newCreateOrder";
|
|
string html = GetData();
|
|
return html;
|
|
}
|
|
|
|
public string GetDataJson()
|
|
{
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
foreach (string current in JsonData.Keys)
|
|
{
|
|
if (JsonData[current].ToString().Contains("{"))
|
|
{
|
|
stringBuilder.AppendFormat((stringBuilder.Length > 0) ? ",\"{0}\":{1}" : "\"{0}\":{1}", current, JsonData[current].ToString());
|
|
}
|
|
else
|
|
{
|
|
stringBuilder.AppendFormat((stringBuilder.Length > 0) ? ",\"{0}\":\"{1}\"" : "\"{0}\":\"{1}\"", current, JsonData[current].ToString());
|
|
}
|
|
}
|
|
string json = "{" + stringBuilder.ToString() + "}";
|
|
return json;
|
|
}
|
|
|
|
public string GetDataSignPara()
|
|
{
|
|
StringBuilder stringBuilderData = new StringBuilder();
|
|
foreach (string current in Data.Keys)
|
|
{
|
|
if (Data[current] == null)
|
|
{
|
|
break;
|
|
}
|
|
if (current == "access_token" || current == "sign" || current == "param_json") {
|
|
continue;
|
|
}
|
|
stringBuilderData.AppendFormat((stringBuilderData.Length > 0) ? ",\"{0}\":\"{1}\"" : "\"{0}\":\"{1}\"", current, Data[current].ToString());
|
|
}
|
|
string param = "{" + stringBuilderData.ToString() + "}";
|
|
return param;
|
|
}
|
|
public string GetDataFxgPara()
|
|
{
|
|
StringBuilder stringBuilderData = new StringBuilder();
|
|
foreach (string current in Data.Keys)
|
|
{
|
|
if (Data[current] == null)
|
|
{
|
|
break;
|
|
}
|
|
stringBuilderData.AppendFormat((stringBuilderData.Length > 0) ? "&{0}={1}" : "{0}={1}", current, Data[current].ToString());
|
|
}
|
|
string param = stringBuilderData.ToString();
|
|
return param;
|
|
}
|
|
|
|
//public string GetData()
|
|
//{
|
|
// #region 获取接口数据
|
|
// string json = GetDataJson();
|
|
// string timestamp =BaseClass.DateTimeToTimestampSeconds(DateTime.Now).ToString();
|
|
// //json = HttpUtility.UrlEncode(json, Encoding.UTF8);
|
|
// #endregion
|
|
// int time = BaseClass.ConvertDateTimeInt(DateTime.Now) + BaseClass.TimeDifferent;
|
|
// string time1 = UserLogin.Encryptionxx(time);
|
|
|
|
// #region 获取sign
|
|
// string param_json = JsonConvert.SerializeObject(JsonData);
|
|
// Data["method"] = Type;
|
|
// Data["path"] = path;
|
|
// Data["param_json"] = HttpUtility.UrlEncode(param_json, Encoding.UTF8);
|
|
// Data["shop_name"] = Shop.ShopName;
|
|
// Data["time"] = time.ToString();
|
|
// Data["code"] =time1;
|
|
// #endregion
|
|
// #region 提交抖店
|
|
|
|
// string fxgPara = GetDataFxgPara();
|
|
// string urlx = BaseClass.ApiUrl + "/doudian-api.php";
|
|
// string datax = fxgPara;
|
|
// string htmlx = GetHtml.PostUtf8(urlx, datax);
|
|
// return htmlx;
|
|
// #endregion
|
|
//}
|
|
public string GetData()
|
|
{
|
|
#region 获取接口数据
|
|
string json = GetHtml.UrlEncodeUtf8(GetDataJson());
|
|
// string timestamp = BaseClass.DateTimeToTimestampSeconds(DateTime.Now).ToString();
|
|
//json = HttpUtility.UrlEncode(json, Encoding.UTF8);
|
|
#endregion
|
|
int time = BaseClass.ConvertDateTimeInt(DateTime.Now) + BaseClass.TimeDifferent;
|
|
string time1 = UserLogin.Encryptionxx(time);
|
|
#region 获取sign
|
|
string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
Data["app_key"] = "7016502755254683171"; //Shop.AppKey;
|
|
Data["timestamp"] = timestamp;
|
|
Data["method"] = Type;
|
|
Data["v"] = "2";
|
|
string param = GetHtml.UrlEncodeUtf8(GetDataSignPara());
|
|
|
|
string url = "http://103.90.155.35:54"+(new Random().Next(10,20))+ "/sign.php?act=signature";
|
|
//string url = BaseClass.Build29WxObjString("sign&act=signature");
|
|
string data = UserLogin.GetSignaturex() + "¶m_json="+ json + ""
|
|
+ "¶ms=" + param + "&service=2";
|
|
string html = GetHtml.PostUtf8(url, data);
|
|
string sign = BaseRegex.GetStringJson(ref html, "sign");
|
|
#endregion
|
|
|
|
#region 提交抖店
|
|
|
|
Data["param_json"] =json;
|
|
Data["access_token"] = Shop.AccessToken;
|
|
Data["sign"] = sign;
|
|
string fxgPara = GetDataFxgPara();
|
|
string urlx = "https://openapi-fxg.jinritemai.com/" + Type.Replace(".", "/") + "?app_key=7016502755254683171×tamp=" + timestamp+ "&method=" + Type + "&v=2¶m_json=" + json + "&access_token=" + Shop.AccessToken + "&sign=" + sign;
|
|
string datax = fxgPara;
|
|
string htmlx = GetHtml.PostUtf8(urlx, datax);
|
|
return htmlx;
|
|
#endregion
|
|
}
|
|
|
|
|
|
public string GetGuanFangData(string types)
|
|
{
|
|
#region 获取接口数据
|
|
string json = GetDataJson();
|
|
json = HttpUtility.UrlEncode(json, Encoding.UTF8);
|
|
#endregion
|
|
#region 获取sign
|
|
string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
Data["app_key"] = "7016502755254683171";//Shop.AppKey;
|
|
Data["timestamp"] = timestamp;
|
|
Data["method"] = types;
|
|
Data["v"] = "2";
|
|
string param = GetDataSignPara();
|
|
string url = BaseClass.Build29WxObjString("sign&act=signature");
|
|
string data = UserLogin.GetSignaturex() + "¶m_json=" + "" + json + ""
|
|
+ "¶ms=" + param + "&service=2";
|
|
string html = GetHtml.PostUtf8("http://192.168.8.191:82/index.php?obj=douyin/sign&act=signature", data);
|
|
string sign = BaseRegex.GetStringJson(ref html, "sign");
|
|
#endregion
|
|
#region 提交抖店
|
|
Data["param_json"] = json;
|
|
Data["access_token"] = Shop.AccessToken;
|
|
Data["sign"] = sign;
|
|
string fxgPara = GetDataFxgPara();
|
|
string urlx = "https://openapi-fxg.jinritemai.com/" + types.Replace(".", "/")+ "?app_key=7016502755254683171×tamp=" + timestamp+ "&method="+types+ "&v=2¶m_json" + json+ "&access_token=" + Shop.AccessToken+ "&sign="+ sign;
|
|
string datax = fxgPara;
|
|
string htmlx = GetHtml.PostUtf8(urlx, datax);
|
|
return htmlx;
|
|
#endregion
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public class setModel{
|
|
public string method { get; set; }
|
|
public string path { get; set; }
|
|
public string param_json { get; set; }
|
|
public string token { get; set; }
|
|
public string shop_name { get; set; }
|
|
|
|
public string time { get; set; }
|
|
public string code { get; set; }
|
|
}
|
|
}
|